Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 93283 | Differences between
and this patch

Collapse All | Expand All

(-)linux/drivers/net/sk98lin/h/lm80.h (-2 / +2 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	lm80.h	
3
 * Name:	lm80.h	
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.6 $
5
 * Version:	$Revision: 2.1 $
6
 * Date:	$Date: 2003/05/13 17:26:52 $
6
 * Date:	$Date: 2003/10/27 14:16:08 $
7
 * Purpose:	Contains all defines for the LM80 Chip
7
 * Purpose:	Contains all defines for the LM80 Chip
8
 *		(National Semiconductor).
8
 *		(National Semiconductor).
9
 *
9
 *
(-)linux/drivers/net/sk98lin/h/skaddr.h (-2 / +2 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skaddr.h
3
 * Name:	skaddr.h
4
 * Project:	Gigabit Ethernet Adapters, ADDR-Modul
4
 * Project:	Gigabit Ethernet Adapters, ADDR-Modul
5
 * Version:	$Revision: 1.29 $
5
 * Version:	$Revision: 2.1 $
6
 * Date:	$Date: 2003/05/13 16:57:24 $
6
 * Date:	$Date: 2003/10/27 14:16:07 $
7
 * Purpose:	Header file for Address Management (MC, UC, Prom).
7
 * Purpose:	Header file for Address Management (MC, UC, Prom).
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/h/skcsum.h (-4 / +2 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skcsum.h
3
 * Name:	skcsum.h
4
 * Project:	GEnesis - SysKonnect SK-NET Gigabit Ethernet (SK-98xx)
4
 * Project:	GEnesis - SysKonnect SK-NET Gigabit Ethernet (SK-98xx)
5
 * Version:	$Revision: 1.10 $
5
 * Version:	$Revision: 2.2 $
6
 * Date:	$Date: 2003/08/20 13:59:57 $
6
 * Date:	$Date: 2003/12/29 15:37:26 $
7
 * Purpose:	Store/verify Internet checksum in send/receive packets.
7
 * Purpose:	Store/verify Internet checksum in send/receive packets.
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 157-165 Link Here
157
typedef struct s_Csum {
157
typedef struct s_Csum {
158
	/* Enabled receive SK_PROTO_XXX bit flags. */
158
	/* Enabled receive SK_PROTO_XXX bit flags. */
159
	unsigned ReceiveFlags[SK_MAX_NETS];
159
	unsigned ReceiveFlags[SK_MAX_NETS];
160
#ifdef TX_CSUM
161
	unsigned TransmitFlags[SK_MAX_NETS];
160
	unsigned TransmitFlags[SK_MAX_NETS];
162
#endif /* TX_CSUM */
163
161
164
	/* The protocol statistics structure; one per supported protocol. */
162
	/* The protocol statistics structure; one per supported protocol. */
165
	SKCS_PROTO_STATS ProtoStats[SK_MAX_NETS][SKCS_NUM_PROTOCOLS];
163
	SKCS_PROTO_STATS ProtoStats[SK_MAX_NETS][SKCS_NUM_PROTOCOLS];
(-)linux/drivers/net/sk98lin/h/skdebug.h (-7 / +13 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skdebug.h
3
 * Name:	skdebug.h
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.14 $
5
 * Version:	$Revision: 2.3 $
6
 * Date:	$Date: 2003/05/13 17:26:00 $
6
 * Date:	$Date: 2005/01/25 16:44:28 $
7
 * Purpose:	SK specific DEBUG support
7
 * Purpose:	SK specific DEBUG support
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-23 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2005 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
22
 *
21
 *
23
 ******************************************************************************/
22
 ******************************************************************************/
Lines 28-36 Link Here
28
#ifdef	DEBUG
27
#ifdef	DEBUG
29
#ifndef SK_DBG_MSG
28
#ifndef SK_DBG_MSG
30
#define SK_DBG_MSG(pAC,comp,cat,arg) \
29
#define SK_DBG_MSG(pAC,comp,cat,arg) \
31
		if ( ((comp) & SK_DBG_CHKMOD(pAC)) && 	\
30
		if ( ((comp) & SK_DBG_CHKMOD(pAC)) &&	\
32
		      ((cat) & SK_DBG_CHKCAT(pAC)) ) { 	\
31
		      ((cat) & SK_DBG_CHKCAT(pAC)) ) {	\
33
			SK_DBG_PRINTF arg ;		\
32
			SK_DBG_PRINTF arg;		\
34
		}
33
		}
35
#endif
34
#endif
36
#else
35
#else
Lines 58-63 Link Here
58
#define SK_DBGMOD_ADDR	0x00000080L	/* ADDR module */
57
#define SK_DBGMOD_ADDR	0x00000080L	/* ADDR module */
59
#define SK_DBGMOD_PECP	0x00000100L	/* PECP module */
58
#define SK_DBGMOD_PECP	0x00000100L	/* PECP module */
60
#define SK_DBGMOD_POWM	0x00000200L	/* Power Management module */
59
#define SK_DBGMOD_POWM	0x00000200L	/* Power Management module */
60
#ifdef SK_ASF
61
#define SK_DBGMOD_ASF	0x00000400L	/* ASF module */
62
#endif
63
#ifdef SK_LBFO
64
#define SK_DBGMOD_LACP	0x00000800L	/* link aggregation control protocol */
65
#define SK_DBGMOD_FD	0x00001000L	/* frame distributor (link aggregation) */
66
#endif /* SK_LBFO */
61
67
62
/* Debug events */
68
/* Debug events */
63
69
(-)linux/drivers/net/sk98lin/h/skdrv1st.h (-23 / +17 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skdrv1st.h
3
 * Name:	skdrv1st.h
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.4 $
5
 * Version:	$Revision: 1.5.2.4 $
6
 * Date:	$Date: 2003/11/12 14:28:14 $
6
 * Date:	$Date: 2004/11/22 16:15:55 $
7
 * Purpose:	First header file for driver and all other modules
7
 * Purpose:	First header file for driver and all other modules
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 22-41 Link Here
22
 *
22
 *
23
 ******************************************************************************/
23
 ******************************************************************************/
24
24
25
/******************************************************************************
26
 *
27
 * Description:
28
 *
29
 * This is the first include file of the driver, which includes all
30
 * neccessary system header files and some of the GEnesis header files.
31
 * It also defines some basic items.
32
 *
33
 * Include File Hierarchy:
34
 *
35
 *	see skge.c
36
 *
37
 ******************************************************************************/
38
39
#ifndef __INC_SKDRV1ST_H
25
#ifndef __INC_SKDRV1ST_H
40
#define __INC_SKDRV1ST_H
26
#define __INC_SKDRV1ST_H
41
27
Lines 58-63 Link Here
58
44
59
#define SK_ADDR_EQUAL(a1,a2)		(!memcmp(a1,a2,6))
45
#define SK_ADDR_EQUAL(a1,a2)		(!memcmp(a1,a2,6))
60
46
47
#define SK_STRNCMP(s1,s2,len)		strncmp(s1,s2,len)
48
#define SK_STRCPY(dest,src)		strcpy(dest,src)
49
61
#include <linux/types.h>
50
#include <linux/types.h>
62
#include <linux/kernel.h>
51
#include <linux/kernel.h>
63
#include <linux/string.h>
52
#include <linux/string.h>
Lines 66-73 Link Here
66
#include <linux/slab.h>
55
#include <linux/slab.h>
67
#include <linux/interrupt.h>
56
#include <linux/interrupt.h>
68
#include <linux/pci.h>
57
#include <linux/pci.h>
69
#include <linux/bitops.h>
70
#include <asm/byteorder.h>
58
#include <asm/byteorder.h>
59
#include <asm/bitops.h>
71
#include <asm/io.h>
60
#include <asm/io.h>
72
#include <linux/netdevice.h>
61
#include <linux/netdevice.h>
73
#include <linux/etherdevice.h>
62
#include <linux/etherdevice.h>
Lines 78-88 Link Here
78
#include <net/checksum.h>
67
#include <net/checksum.h>
79
68
80
#define SK_CS_CALCULATE_CHECKSUM
69
#define SK_CS_CALCULATE_CHECKSUM
81
#ifndef CONFIG_X86_64
70
#define SkCsCalculateChecksum(p,l)	(~csum_fold(csum_partial(p, l, 0)))
82
#define SkCsCalculateChecksum(p,l)	((~ip_compute_csum(p, l)) & 0xffff)
83
#else
84
#define SkCsCalculateChecksum(p,l)	((~ip_fast_csum(p, l)) & 0xffff)
85
#endif
86
71
87
#include	"h/sktypes.h"
72
#include	"h/sktypes.h"
88
#include	"h/skerror.h"
73
#include	"h/skerror.h"
Lines 90-95 Link Here
90
#include	"h/lm80.h"
75
#include	"h/lm80.h"
91
#include	"h/xmac_ii.h"
76
#include	"h/xmac_ii.h"
92
77
78
#ifndef SK_BMU_RX_WM_PEX
79
#define SK_BMU_RX_WM_PEX 0x80
80
#endif
81
93
#ifdef __LITTLE_ENDIAN
82
#ifdef __LITTLE_ENDIAN
94
#define SK_LITTLE_ENDIAN
83
#define SK_LITTLE_ENDIAN
95
#else
84
#else
Lines 109-115 Link Here
109
#define SK_MAX_MACS		2
98
#define SK_MAX_MACS		2
110
#define SK_MAX_NETS		2
99
#define SK_MAX_NETS		2
111
100
112
#define SK_IOC			char __iomem *
101
#define SK_IOC			char*
113
102
114
typedef struct s_DrvRlmtMbuf SK_MBUF;
103
typedef struct s_DrvRlmtMbuf SK_MBUF;
115
104
Lines 188-190 Link Here
188
177
189
#endif
178
#endif
190
179
180
/*******************************************************************************
181
 *
182
 * End of file
183
 *
184
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/h/skdrv2nd.h (-297 / +681 lines)
Lines 1-17 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 *
2
 *
3
 * Name:	skdrv2nd.h
3
 * Name:        skdrv2nd.h
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:     GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.10 $
5
 * Version:     $Revision: 1.29.2.16 $
6
 * Date:	$Date: 2003/12/11 16:04:45 $
6
 * Date:        $Date: 2005/03/22 13:55:34 $
7
 * Purpose:	Second header file for driver and all other modules
7
 * Purpose:     Second header file for driver and all other modules
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
10
10
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
Lines 42-51 Link Here
42
#include "h/skqueue.h"
42
#include "h/skqueue.h"
43
#include "h/skgehwt.h"
43
#include "h/skgehwt.h"
44
#include "h/sktimer.h"
44
#include "h/sktimer.h"
45
#include "h/ski2c.h"
45
#include "h/sktwsi.h"
46
#include "h/skgepnmi.h"
46
#include "h/skgepnmi.h"
47
#include "h/skvpd.h"
47
#include "h/skvpd.h"
48
#include "h/skgehw.h"
48
#include "h/skgehw.h"
49
#include "h/sky2le.h"
49
#include "h/skgeinit.h"
50
#include "h/skgeinit.h"
50
#include "h/skaddr.h"
51
#include "h/skaddr.h"
51
#include "h/skgesirq.h"
52
#include "h/skgesirq.h"
Lines 53-156 Link Here
53
#include "h/skrlmt.h"
54
#include "h/skrlmt.h"
54
#include "h/skgedrv.h"
55
#include "h/skgedrv.h"
55
56
57
/******************************************************************************
58
 *
59
 * Generic driver defines
60
 *
61
 ******************************************************************************/
62
63
#define Y2_RX_CHECK		/* RX Check timestamp */
64
#define USE_TIST_FOR_RESET	/* Use timestamp for reset */
65
#define Y2_RECOVERY		/* use specific recovery yukon2 functions */
66
#define Y2_LE_CHECK		/* activate check for LE order */
67
#define Y2_SYNC_CHECK		/* activate check for receiver in sync */
68
#define SK_YUKON2		/* Enable Yukon2 dual net support */
69
#define USE_SK_TX_CHECKSUM	/* use the tx hw checksum driver functionality */
70
#define USE_SK_RX_CHECKSUM	/* use the rx hw checksum driver functionality */
71
#define USE_SK_TSO_FEATURE	/* use TCP segmentation offload if possible */
72
#define SK_COPY_THRESHOLD 50	/* threshold for copying small RX frames; 
73
				 * 0 avoids copying, 9001 copies all */
74
#define SK_MAX_CARD_PARAM 16	/* number of adapters that can be configured via 
75
				 * command line params */
76
//#define USE_TX_COMPLETE	/* use of a transmit complete interrupt */
56
77
57
extern SK_MBUF		*SkDrvAllocRlmtMbuf(SK_AC*, SK_IOC, unsigned);
78
/*
58
extern void		SkDrvFreeRlmtMbuf(SK_AC*, SK_IOC, SK_MBUF*);
79
 * use those defines for a compile-in version of the driver instead
59
extern SK_U64		SkOsGetTime(SK_AC*);
80
 * of command line parameters
60
extern int		SkPciReadCfgDWord(SK_AC*, int, SK_U32*);
81
 */
61
extern int		SkPciReadCfgWord(SK_AC*, int, SK_U16*);
82
// #define LINK_SPEED_A	{"Auto",}
62
extern int		SkPciReadCfgByte(SK_AC*, int, SK_U8*);
83
// #define LINK_SPEED_B	{"Auto",}
63
extern int		SkPciWriteCfgDWord(SK_AC*, int, SK_U32);
84
// #define AUTO_NEG_A	{"Sense",}
64
extern int		SkPciWriteCfgWord(SK_AC*, int, SK_U16);
85
// #define AUTO_NEG_B	{"Sense"}
65
extern int		SkPciWriteCfgByte(SK_AC*, int, SK_U8);
86
// #define DUP_CAP_A	{"Both",}
66
extern int		SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA);
87
// #define DUP_CAP_B	{"Both",}
67
88
// #define FLOW_CTRL_A	{"SymOrRem",}
68
#ifdef SK_DIAG_SUPPORT
89
// #define FLOW_CTRL_B	{"SymOrRem",}
69
extern int		SkDrvEnterDiagMode(SK_AC *pAc);
90
// #define ROLE_A	{"Auto",}
70
extern int		SkDrvLeaveDiagMode(SK_AC *pAc);
91
// #define ROLE_B	{"Auto",}
92
// #define PREF_PORT	{"A",}
93
// #define CON_TYPE 	{"Auto",}
94
// #define RLMT_MODE	{"CheckLinkState",}
95
96
#ifdef Y2_RECOVERY
97
#define CHECK_TRANSMIT_TIMEOUT
98
#define Y2_RESYNC_WATERMARK     1000000L
71
#endif
99
#endif
72
100
101
102
/******************************************************************************
103
 *
104
 * Generic ISR defines
105
 *
106
 ******************************************************************************/
107
108
#define SkIsrRetVar     irqreturn_t
109
#define SkIsrRetNone    IRQ_NONE
110
#define SkIsrRetHandled IRQ_HANDLED
111
112
#define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)
113
#define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb)
114
#define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb)
115
116
/******************************************************************************
117
 *
118
 * Global function prototypes
119
 *
120
 ******************************************************************************/
121
122
extern SK_MBUF *SkDrvAllocRlmtMbuf(SK_AC*, SK_IOC, unsigned);
123
extern void SkDrvFreeRlmtMbuf(SK_AC*, SK_IOC, SK_MBUF*);
124
extern SK_U64 SkOsGetTime(SK_AC*);
125
extern int SkPciReadCfgDWord(SK_AC*, int, SK_U32*);
126
extern int SkPciReadCfgWord(SK_AC*, int, SK_U16*);
127
extern int SkPciReadCfgByte(SK_AC*, int, SK_U8*);
128
extern int SkPciWriteCfgDWord(SK_AC*, int, SK_U32);
129
extern int SkPciWriteCfgWord(SK_AC*, int, SK_U16);
130
extern int SkPciWriteCfgByte(SK_AC*, int, SK_U8);
131
extern int SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA);
132
extern int SkDrvEnterDiagMode(SK_AC *pAc);
133
extern int SkDrvLeaveDiagMode(SK_AC *pAc);
134
135
/******************************************************************************
136
 *
137
 * Linux specific RLMT buffer structure (SK_MBUF typedef in skdrv1st)!
138
 *
139
 ******************************************************************************/
140
73
struct s_DrvRlmtMbuf {
141
struct s_DrvRlmtMbuf {
74
	SK_MBUF		*pNext;		/* Pointer to next RLMT Mbuf. */
142
	SK_MBUF         *pNext;    /* Pointer to next RLMT Mbuf.       */
75
	SK_U8		*pData;		/* Data buffer (virtually contig.). */
143
	SK_U8           *pData;    /* Data buffer (virtually contig.). */
76
	unsigned	Size;		/* Data buffer size. */
144
	unsigned         Size;     /* Data buffer size.                */
77
	unsigned	Length;		/* Length of packet (<= Size). */
145
	unsigned         Length;   /* Length of packet (<= Size).      */
78
	SK_U32		PortIdx;	/* Receiving/transmitting port. */
146
	SK_U32           PortIdx;  /* Receiving/transmitting port.     */
79
#ifdef SK_RLMT_MBUF_PRIVATE
147
#ifdef SK_RLMT_MBUF_PRIVATE
80
	SK_RLMT_MBUF	Rlmt;		/* Private part for RLMT. */
148
	SK_RLMT_MBUF     Rlmt;     /* Private part for RLMT.           */
81
#endif  /* SK_RLMT_MBUF_PRIVATE */
149
#endif
82
	struct sk_buff	*pOs;		/* Pointer to message block */
150
	struct sk_buff  *pOs;      /* Pointer to message block         */
83
};
151
};
84
152
153
/******************************************************************************
154
 *
155
 * Linux specific TIME defines
156
 *
157
 ******************************************************************************/
85
158
86
/*
87
 * Time macros
88
 */
89
#if SK_TICKS_PER_SEC == 100
159
#if SK_TICKS_PER_SEC == 100
90
#define SK_PNMI_HUNDREDS_SEC(t)	(t)
160
#define SK_PNMI_HUNDREDS_SEC(t)	(t)
91
#else
161
#else
92
#define SK_PNMI_HUNDREDS_SEC(t)	((((unsigned long)t) * 100) / \
162
#define SK_PNMI_HUNDREDS_SEC(t) ((((unsigned long)t)*100)/(SK_TICKS_PER_SEC))
93
										(SK_TICKS_PER_SEC))
94
#endif
163
#endif
95
164
96
/*
97
 * New SkOsGetTime
98
 */
99
#define SkOsGetTimeCurrent(pAC, pUsec) {\
165
#define SkOsGetTimeCurrent(pAC, pUsec) {\
100
	struct timeval t;\
166
	struct timeval t;\
101
	do_gettimeofday(&t);\
167
	do_gettimeofday(&t);\
102
	*pUsec = ((((t.tv_sec) * 1000000L)+t.tv_usec)/10000);\
168
	*pUsec = ((((t.tv_sec) * 1000000L)+t.tv_usec)/10000);\
103
}
169
}
104
170
171
/******************************************************************************
172
 *
173
 * Linux specific IOCTL defines and typedefs
174
 *
175
 ******************************************************************************/
105
176
106
/*
177
#define	SK_IOCTL_BASE       (SIOCDEVPRIVATE)
107
 * ioctl definitions
178
#define	SK_IOCTL_GETMIB     (SK_IOCTL_BASE + 0)
108
 */
179
#define	SK_IOCTL_SETMIB     (SK_IOCTL_BASE + 1)
109
#define		SK_IOCTL_BASE		(SIOCDEVPRIVATE)
180
#define	SK_IOCTL_PRESETMIB  (SK_IOCTL_BASE + 2)
110
#define		SK_IOCTL_GETMIB		(SK_IOCTL_BASE + 0)
181
#define	SK_IOCTL_GEN        (SK_IOCTL_BASE + 3)
111
#define		SK_IOCTL_SETMIB		(SK_IOCTL_BASE + 1)
182
#define	SK_IOCTL_DIAG       (SK_IOCTL_BASE + 4)
112
#define		SK_IOCTL_PRESETMIB	(SK_IOCTL_BASE + 2)
113
#define		SK_IOCTL_GEN		(SK_IOCTL_BASE + 3)
114
#define		SK_IOCTL_DIAG		(SK_IOCTL_BASE + 4)
115
116
typedef struct s_IOCTL	SK_GE_IOCTL;
117
183
184
typedef struct s_IOCTL SK_GE_IOCTL;
118
struct s_IOCTL {
185
struct s_IOCTL {
119
	char __user *	pData;
186
	char __user *	pData;
120
	unsigned int	Len;
187
	unsigned int	Len;
121
};
188
};
122
189
190
/******************************************************************************
191
 *
192
 * Generic sizes and length definitions
193
 *
194
 ******************************************************************************/
123
195
124
/*
196
#define TX_RING_SIZE  (24*1024)  /* GEnesis/Yukon */
125
 * define sizes of descriptor rings in bytes
197
#define RX_RING_SIZE  (24*1024)  /* GEnesis/Yukon */
126
 */
198
#define RX_MAX_NBR_BUFFERS   128  /* Yukon-EC/-II */
127
199
#define TX_MAX_NBR_BUFFERS   128  /* Yukon-EC/-II */
128
#define		TX_RING_SIZE	(8*1024)
200
129
#define		RX_RING_SIZE	(24*1024)
201
#define	ETH_BUF_SIZE        1560  /* multiples of 8 bytes */
130
202
#define	ETH_MAX_MTU         1514
131
/*
203
#define ETH_MIN_MTU         60
132
 * Buffer size for ethernet packets
204
#define ETH_MULTICAST_BIT   0x01
133
 */
205
#define SK_JUMBO_MTU        9000
134
#define	ETH_BUF_SIZE	1540
206
135
#define	ETH_MAX_MTU	1514
207
#define TX_PRIO_LOW    0 /* asynchronous queue */
136
#define ETH_MIN_MTU	60
208
#define TX_PRIO_HIGH   1 /* synchronous queue */
137
#define ETH_MULTICAST_BIT	0x01
209
#define DESCR_ALIGN   64 /* alignment of Rx/Tx descriptors */
138
#define SK_JUMBO_MTU	9000
139
210
140
/*
211
/******************************************************************************
141
 * transmit priority selects the queue: LOW=asynchron, HIGH=synchron
212
 *
142
 */
213
 * PNMI related definitions
143
#define TX_PRIO_LOW	0
214
 *
144
#define TX_PRIO_HIGH	1
215
 ******************************************************************************/
145
146
/*
147
 * alignment of rx/tx descriptors
148
 */
149
#define DESCR_ALIGN	64
150
216
151
/*
152
 * definitions for pnmi. TODO
153
 */
154
#define SK_DRIVER_RESET(pAC, IoC)	0
217
#define SK_DRIVER_RESET(pAC, IoC)	0
155
#define SK_DRIVER_SENDEVENT(pAC, IoC)	0
218
#define SK_DRIVER_SENDEVENT(pAC, IoC)	0
156
#define SK_DRIVER_SELFTEST(pAC, IoC)	0
219
#define SK_DRIVER_SELFTEST(pAC, IoC)	0
Lines 159-178 Link Here
159
#define SK_DRIVER_SET_MTU(pAc,IoC,i,v)	0
222
#define SK_DRIVER_SET_MTU(pAc,IoC,i,v)	0
160
#define SK_DRIVER_PRESET_MTU(pAc,IoC,i,v)	0
223
#define SK_DRIVER_PRESET_MTU(pAc,IoC,i,v)	0
161
224
162
/*
163
** Interim definition of SK_DRV_TIMER placed in this file until 
164
** common modules have boon finallized
165
*/
166
#define SK_DRV_TIMER			11 
167
#define	SK_DRV_MODERATION_TIMER		1
168
#define SK_DRV_MODERATION_TIMER_LENGTH  1000000  /* 1 second */
169
#define SK_DRV_RX_CLEANUP_TIMER		2
170
#define SK_DRV_RX_CLEANUP_TIMER_LENGTH	1000000	 /* 100 millisecs */
171
225
172
/*
226
/******************************************************************************
173
** Definitions regarding transmitting frames 
227
 *
174
** any calculating any checksum.
228
 * Various offsets and sizes
175
*/
229
 *
230
 ******************************************************************************/
231
232
#define	SK_DRV_MODERATION_TIMER         1   /* id */
233
#define SK_DRV_MODERATION_TIMER_LENGTH  1   /* 1 second */
234
176
#define C_LEN_ETHERMAC_HEADER_DEST_ADDR 6
235
#define C_LEN_ETHERMAC_HEADER_DEST_ADDR 6
177
#define C_LEN_ETHERMAC_HEADER_SRC_ADDR  6
236
#define C_LEN_ETHERMAC_HEADER_SRC_ADDR  6
178
#define C_LEN_ETHERMAC_HEADER_LENTYPE   2
237
#define C_LEN_ETHERMAC_HEADER_LENTYPE   2
Lines 198-310 Link Here
198
#define C_PROTO_ID_UDP                  17       /* refer to RFC 790 or Stevens'   */
257
#define C_PROTO_ID_UDP                  17       /* refer to RFC 790 or Stevens'   */
199
#define C_PROTO_ID_TCP                  6        /* TCP/IP illustrated for details */
258
#define C_PROTO_ID_TCP                  6        /* TCP/IP illustrated for details */
200
259
201
/* TX and RX descriptors *****************************************************/
260
/******************************************************************************
261
 *
262
 * Tx and Rx descriptor definitions
263
 *
264
 ******************************************************************************/
202
265
203
typedef struct s_RxD RXD; /* the receive descriptor */
266
typedef struct s_RxD RXD; /* the receive descriptor */
204
205
struct s_RxD {
267
struct s_RxD {
206
	volatile SK_U32	RBControl;	/* Receive Buffer Control */
268
	volatile SK_U32  RBControl;     /* Receive Buffer Control            */
207
	SK_U32		VNextRxd;	/* Next receive descriptor,low dword */
269
	SK_U32           VNextRxd;      /* Next receive descriptor,low dword */
208
	SK_U32		VDataLow;	/* Receive buffer Addr, low dword */
270
	SK_U32           VDataLow;      /* Receive buffer Addr, low dword    */
209
	SK_U32		VDataHigh;	/* Receive buffer Addr, high dword */
271
	SK_U32           VDataHigh;     /* Receive buffer Addr, high dword   */
210
	SK_U32		FrameStat;	/* Receive Frame Status word */
272
	SK_U32           FrameStat;     /* Receive Frame Status word         */
211
	SK_U32		TimeStamp;	/* Time stamp from XMAC */
273
	SK_U32           TimeStamp;     /* Time stamp from XMAC              */
212
	SK_U32		TcpSums;	/* TCP Sum 2 / TCP Sum 1 */
274
	SK_U32           TcpSums;       /* TCP Sum 2 / TCP Sum 1             */
213
	SK_U32		TcpSumStarts;	/* TCP Sum Start 2 / TCP Sum Start 1 */
275
	SK_U32           TcpSumStarts;  /* TCP Sum Start 2 / TCP Sum Start 1 */
214
	RXD		*pNextRxd;	/* Pointer to next Rxd */
276
	RXD             *pNextRxd;      /* Pointer to next Rxd               */
215
	struct sk_buff	*pMBuf;		/* Pointer to Linux' socket buffer */
277
	struct sk_buff  *pMBuf;         /* Pointer to Linux' socket buffer   */
216
};
278
};
217
279
218
typedef struct s_TxD TXD; /* the transmit descriptor */
280
typedef struct s_TxD TXD; /* the transmit descriptor */
219
220
struct s_TxD {
281
struct s_TxD {
221
	volatile SK_U32	TBControl;	/* Transmit Buffer Control */
282
	volatile SK_U32  TBControl;     /* Transmit Buffer Control            */
222
	SK_U32		VNextTxd;	/* Next transmit descriptor,low dword */
283
	SK_U32           VNextTxd;      /* Next transmit descriptor,low dword */
223
	SK_U32		VDataLow;	/* Transmit Buffer Addr, low dword */
284
	SK_U32           VDataLow;      /* Transmit Buffer Addr, low dword    */
224
	SK_U32		VDataHigh;	/* Transmit Buffer Addr, high dword */
285
	SK_U32           VDataHigh;     /* Transmit Buffer Addr, high dword   */
225
	SK_U32		FrameStat;	/* Transmit Frame Status Word */
286
	SK_U32           FrameStat;     /* Transmit Frame Status Word         */
226
	SK_U32		TcpSumOfs;	/* Reserved / TCP Sum Offset */
287
	SK_U32           TcpSumOfs;     /* Reserved / TCP Sum Offset          */
227
	SK_U16		TcpSumSt;	/* TCP Sum Start */
288
	SK_U16           TcpSumSt;      /* TCP Sum Start                      */
228
	SK_U16		TcpSumWr;	/* TCP Sum Write */
289
	SK_U16           TcpSumWr;      /* TCP Sum Write                      */
229
	SK_U32		TcpReserved;	/* not used */
290
	SK_U32           TcpReserved;   /* not used                           */
230
	TXD		*pNextTxd;	/* Pointer to next Txd */
291
	TXD             *pNextTxd;      /* Pointer to next Txd                */
231
	struct sk_buff	*pMBuf;		/* Pointer to Linux' socket buffer */
292
	struct sk_buff  *pMBuf;         /* Pointer to Linux' socket buffer    */
232
};
293
};
233
294
234
/* Used interrupt bits in the interrupts source register *********************/
295
/******************************************************************************
296
 *
297
 * Generic Yukon-II defines
298
 *
299
 ******************************************************************************/
235
300
236
#define DRIVER_IRQS	((IS_IRQ_SW)   | \
301
#define LE_SIZE   sizeof(SK_HWLE)
237
			(IS_R1_F)      |(IS_R2_F)  | \
302
#define MAX_NUM_FRAGS   (MAX_SKB_FRAGS + 1)
238
			(IS_XS1_F)     |(IS_XA1_F) | \
303
#define MIN_LEN_OF_LE_TAB   128
239
			(IS_XS2_F)     |(IS_XA2_F))
304
#define MAX_LEN_OF_LE_TAB   4096
240
305
#define MAX_UNUSED_RX_LE_WORKING   8
241
#define SPECIAL_IRQS	((IS_HW_ERR)   |(IS_I2C_READY)  | \
306
#ifdef MAX_FRAG_OVERHEAD
242
			(IS_EXT_REG)   |(IS_TIMINT)     | \
307
#undef MAX_FRAG_OVERHEAD
243
			(IS_PA_TO_RX1) |(IS_PA_TO_RX2)  | \
308
#define MAX_FRAG_OVERHEAD   4
244
			(IS_PA_TO_TX1) |(IS_PA_TO_TX2)  | \
309
#endif
245
			(IS_MAC1)      |(IS_LNK_SYNC_M1)| \
310
// as we have a maximum of 16 physical fragments,
246
			(IS_MAC2)      |(IS_LNK_SYNC_M2)| \
311
// maximum 1 ADDR64 per physical fragment
247
			(IS_R1_C)      |(IS_R2_C)       | \
312
// maximum 4 LEs for VLAN, Csum, LargeSend, Packet
248
			(IS_XS1_C)     |(IS_XA1_C)      | \
313
#define MIN_LE_FREE_REQUIRED   ((16*2) + 4)
249
			(IS_XS2_C)     |(IS_XA2_C))
314
#define IS_GMAC(pAc)   (!pAc->GIni.GIGenesis)
250
315
#ifdef USE_SYNC_TX_QUEUE
251
#define IRQ_MASK	((IS_IRQ_SW)   | \
316
#define TXS_MAX_LE   256
252
			(IS_R1_B)      |(IS_R1_F)     |(IS_R2_B) |(IS_R2_F) | \
317
#else /* !USE_SYNC_TX_QUEUE */
253
			(IS_XS1_B)     |(IS_XS1_F)    |(IS_XA1_B)|(IS_XA1_F)| \
318
#define TXS_MAX_LE   0
254
			(IS_XS2_B)     |(IS_XS2_F)    |(IS_XA2_B)|(IS_XA2_F)| \
319
#endif
255
			(IS_HW_ERR)    |(IS_I2C_READY)| \
320
256
			(IS_EXT_REG)   |(IS_TIMINT)   | \
321
#define ETHER_MAC_HDR_LEN   (6+6+2) // MAC SRC ADDR, MAC DST ADDR, TYPE
257
			(IS_PA_TO_RX1) |(IS_PA_TO_RX2)| \
322
#define IP_HDR_LEN   20
258
			(IS_PA_TO_TX1) |(IS_PA_TO_TX2)| \
323
#define TCP_CSUM_OFFS   0x10
259
			(IS_MAC1)      |(IS_MAC2)     | \
324
#define UDP_CSUM_OFFS   0x06
260
			(IS_R1_C)      |(IS_R2_C)     | \
325
#define TXA_MAX_LE   256
261
			(IS_XS1_C)     |(IS_XA1_C)    | \
326
#define RX_MAX_LE   256
262
			(IS_XS2_C)     |(IS_XA2_C))
327
#define ST_MAX_LE   (SK_MAX_MACS)*((3*RX_MAX_LE)+(TXA_MAX_LE)+(TXS_MAX_LE))
328
329
#if (defined (Y2_RECOVERY) || defined (Y2_LE_CHECK))
330
/* event for recovery from tx hang or rx out of sync */
331
#define SK_DRV_RECOVER                  17
332
#endif
333
/******************************************************************************
334
 *
335
 * Structures specific for Yukon-II
336
 *
337
 ******************************************************************************/
338
339
typedef	struct s_frag SK_FRAG;
340
struct s_frag {
341
 	SK_FRAG       *pNext;
342
 	char          *pVirt;
343
  	SK_U64         pPhys;
344
 	unsigned int   FragLen;
345
};
346
347
typedef	struct s_packet SK_PACKET;
348
struct s_packet {
349
	/* Common infos: */
350
	SK_PACKET       *pNext;         /* pointer for packet queues          */
351
	unsigned int     PacketLen;     /* length of packet                   */
352
	unsigned int     NumFrags;      /* nbr of fragments (for Rx always 1) */
353
	SK_FRAG         *pFrag;         /* fragment list                      */
354
	SK_FRAG          FragArray[MAX_NUM_FRAGS]; /* TX fragment array       */
355
	unsigned int     NextLE;        /* next LE to use for the next packet */
356
357
	/* Private infos: */
358
	struct sk_buff	*pMBuf;         /* Pointer to Linux' socket buffer    */
359
};
360
361
typedef	struct s_queue SK_PKT_QUEUE;
362
struct s_queue {
363
 	SK_PACKET       *pHead;
364
 	SK_PACKET       *pTail;
365
	spinlock_t       QueueLock;     /* serialize packet accesses          */
366
};
367
368
/*******************************************************************************
369
 *
370
 * Macros specific for Yukon-II queues
371
 *
372
 ******************************************************************************/
373
374
#define IS_Q_EMPTY(pQueue)  ((pQueue)->pHead != NULL) ? SK_FALSE : SK_TRUE
375
#define IS_Q_LOCKED(pQueue) spin_is_locked(&((pQueue)->QueueLock))
376
377
#define PLAIN_POP_FIRST_PKT_FROM_QUEUE(pQueue, pPacket)	{	\
378
        if ((pQueue)->pHead != NULL) {				\
379
		(pPacket)       = (pQueue)->pHead;		\
380
		(pQueue)->pHead = (pPacket)->pNext;		\
381
		if ((pQueue)->pHead == NULL) {			\
382
			(pQueue)->pTail = NULL;			\
383
		}						\
384
		(pPacket)->pNext = NULL;			\
385
	} else {						\
386
		(pPacket) = NULL;				\
387
	}							\
388
}
389
390
#define PLAIN_PUSH_PKT_AS_FIRST_IN_QUEUE(pQueue, pPacket) {	\
391
	if ((pQueue)->pHead != NULL) {				\
392
		(pPacket)->pNext = (pQueue)->pHead;		\
393
	} else {						\
394
		(pPacket)->pNext = NULL;			\
395
		(pQueue)->pTail  = (pPacket);			\
396
	}							\
397
      	(pQueue)->pHead  = (pPacket);				\
398
}
399
400
#define PLAIN_PUSH_PKT_AS_LAST_IN_QUEUE(pQueue, pPacket) {	\
401
	(pPacket)->pNext = NULL;				\
402
	if ((pQueue)->pTail != NULL) {				\
403
		(pQueue)->pTail->pNext = (pPacket);		\
404
	} else {						\
405
		(pQueue)->pHead        = (pPacket);		\
406
	}							\
407
	(pQueue)->pTail = (pPacket);				\
408
}
409
410
#define PLAIN_PUSH_MULTIPLE_PKT_AS_LAST_IN_QUEUE(pQueue,pPktGrpStart,pPktGrpEnd) { \
411
	if ((pPktGrpStart) != NULL) {					\
412
		if ((pQueue)->pTail != NULL) {				\
413
			(pQueue)->pTail->pNext = (pPktGrpStart);	\
414
		} else {						\
415
			(pQueue)->pHead = (pPktGrpStart);		\
416
		}							\
417
		(pQueue)->pTail = (pPktGrpEnd);				\
418
	}								\
419
}
420
421
/* Required: 'Flags' */ 
422
#define POP_FIRST_PKT_FROM_QUEUE(pQueue, pPacket)	{	\
423
	spin_lock_irqsave(&((pQueue)->QueueLock), Flags);	\
424
	if ((pQueue)->pHead != NULL) {				\
425
		(pPacket)       = (pQueue)->pHead;		\
426
		(pQueue)->pHead = (pPacket)->pNext;		\
427
		if ((pQueue)->pHead == NULL) {			\
428
			(pQueue)->pTail = NULL;			\
429
		}						\
430
		(pPacket)->pNext = NULL;			\
431
	} else {						\
432
		(pPacket) = NULL;				\
433
	}							\
434
	spin_unlock_irqrestore(&((pQueue)->QueueLock), Flags);	\
435
}
436
437
/* Required: 'Flags' */
438
#define PUSH_PKT_AS_FIRST_IN_QUEUE(pQueue, pPacket)	{	\
439
	spin_lock_irqsave(&(pQueue)->QueueLock, Flags);		\
440
	if ((pQueue)->pHead != NULL) {				\
441
		(pPacket)->pNext = (pQueue)->pHead;		\
442
	} else {						\
443
		(pPacket)->pNext = NULL;			\
444
		(pQueue)->pTail  = (pPacket);			\
445
	}							\
446
	(pQueue)->pHead = (pPacket);				\
447
	spin_unlock_irqrestore(&(pQueue)->QueueLock, Flags);	\
448
}
449
450
/* Required: 'Flags' */
451
#define PUSH_PKT_AS_LAST_IN_QUEUE(pQueue, pPacket)	{	\
452
	(pPacket)->pNext = NULL;				\
453
	spin_lock_irqsave(&(pQueue)->QueueLock, Flags);		\
454
	if ((pQueue)->pTail != NULL) {				\
455
		(pQueue)->pTail->pNext = (pPacket);		\
456
	} else {						\
457
		(pQueue)->pHead = (pPacket);			\
458
	}							\
459
	(pQueue)->pTail = (pPacket);				\
460
	spin_unlock_irqrestore(&(pQueue)->QueueLock, Flags);	\
461
}
462
463
/* Required: 'Flags' */
464
#define PUSH_MULTIPLE_PKT_AS_LAST_IN_QUEUE(pQueue,pPktGrpStart,pPktGrpEnd) {	\
465
	if ((pPktGrpStart) != NULL) {					\
466
		spin_lock_irqsave(&(pQueue)->QueueLock, Flags);		\
467
		if ((pQueue)->pTail != NULL) {				\
468
			(pQueue)->pTail->pNext = (pPktGrpStart);	\
469
		} else {						\
470
			(pQueue)->pHead = (pPktGrpStart);		\
471
		}							\
472
		(pQueue)->pTail = (pPktGrpEnd);				\
473
		spin_unlock_irqrestore(&(pQueue)->QueueLock, Flags);	\
474
	}								\
475
}
476
477
/*******************************************************************************
478
 *
479
 * Macros specific for Yukon-II queues (tist)
480
 *
481
 ******************************************************************************/
482
483
#ifdef USE_TIST_FOR_RESET
484
/* port is fully operational */
485
#define SK_PSTATE_NOT_WAITING_FOR_TIST                  0
486
/* port in reset until any tist LE */
487
#define SK_PSTATE_WAITING_FOR_ANY_TIST          BIT_0
488
/* port in reset until timer reaches pAC->MinTistLo */
489
#define SK_PSTATE_WAITING_FOR_SPECIFIC_TIST     BIT_1   
490
#define SK_PSTATE_PORT_SHIFT    4
491
#define SK_PSTATE_PORT_MASK             ((1 << SK_PSTATE_PORT_SHIFT) - 1)
492
493
/* use this + Port to build OP_MOD_TXINDEX_NO_PORT_A|B */
494
#define OP_MOD_TXINDEX 0x71
495
/* opcode for a TX_INDEX LE in which Port A has to be ignored */
496
#define OP_MOD_TXINDEX_NO_PORT_A 0x71
497
/* opcode for a TX_INDEX LE in which Port B has to be ignored */
498
#define OP_MOD_TXINDEX_NO_PORT_B 0x72
499
/* opcode for LE to be ignored because port is still in reset */
500
#define OP_MOD_LE 0x7F
501
502
/* set tist wait mode Bit for port */ 
503
#define SK_SET_WAIT_BIT_FOR_PORT(pAC, Bit, Port)        \
504
	{ \
505
		(pAC)->AdapterResetState |= ((Bit) << (SK_PSTATE_PORT_SHIFT * Port)); \
506
	}
507
508
/* reset tist waiting for specified port */
509
#define SK_CLR_STATE_FOR_PORT(pAC, Port)        \
510
	{ \
511
		(pAC)->AdapterResetState &= \
512
			~(SK_PSTATE_PORT_MASK << (SK_PSTATE_PORT_SHIFT * Port)); \
513
	}
514
515
/* return SK_TRUE when port is in reset waiting for tist */
516
#define SK_PORT_WAITING_FOR_TIST(pAC, Port) \
517
	((((pAC)->AdapterResetState >> (SK_PSTATE_PORT_SHIFT * Port)) & \
518
		SK_PSTATE_PORT_MASK) != SK_PSTATE_NOT_WAITING_FOR_TIST)
519
520
/* return SK_TRUE when port is in reset waiting for any tist */
521
#define SK_PORT_WAITING_FOR_ANY_TIST(pAC, Port) \
522
	((((pAC)->AdapterResetState >> (SK_PSTATE_PORT_SHIFT * Port)) & \
523
		SK_PSTATE_WAITING_FOR_ANY_TIST) == SK_PSTATE_WAITING_FOR_ANY_TIST)
524
525
/* return SK_TRUE when port is in reset waiting for a specific tist */
526
#define SK_PORT_WAITING_FOR_SPECIFIC_TIST(pAC, Port) \
527
	((((pAC)->AdapterResetState >> (SK_PSTATE_PORT_SHIFT * Port)) & \
528
		SK_PSTATE_WAITING_FOR_SPECIFIC_TIST) == \
529
		SK_PSTATE_WAITING_FOR_SPECIFIC_TIST)
530
        
531
/* return whether adapter is expecting a tist LE */
532
#define SK_ADAPTER_WAITING_FOR_TIST(pAC)        ((pAC)->AdapterResetState != 0)
533
534
/* enable timestamp timer and force creation of tist LEs */
535
#define Y2_ENABLE_TIST(IoC) \
536
	SK_OUT8(IoC, GMAC_TI_ST_CTRL, (SK_U8) GMT_ST_START)
537
        
538
/* disable timestamp timer and stop creation of tist LEs */
539
#define Y2_DISABLE_TIST(IoC) \
540
	SK_OUT8(IoC, GMAC_TI_ST_CTRL, (SK_U8) GMT_ST_STOP)
541
542
/* get current value of timestamp timer */
543
#define Y2_GET_TIST_LOW_VAL(IoC, pVal) \
544
	SK_IN32(IoC, GMAC_TI_ST_VAL, pVal)
545
546
#endif
263
547
264
#define IRQ_HWE_MASK	(IS_ERR_MSK) /* enable all HW irqs */
548
549
/*******************************************************************************
550
 *
551
 * Used interrupt bits in the interrupts source register
552
 *
553
 ******************************************************************************/
554
555
#define DRIVER_IRQS	((IS_IRQ_SW) | \
556
			 (IS_R1_F)   | (IS_R2_F)  | \
557
			 (IS_XS1_F)  | (IS_XA1_F) | \
558
			 (IS_XS2_F)  | (IS_XA2_F))
559
560
#define TX_COMPL_IRQS	((IS_XS1_B)  | (IS_XS1_F) | \
561
			 (IS_XA1_B)  | (IS_XA1_F) | \
562
			 (IS_XS2_B)  | (IS_XS2_F) | \
563
			 (IS_XA2_B)  | (IS_XA2_F))
564
565
#define NAPI_DRV_IRQS	((IS_R1_F)   | (IS_R2_F) | \
566
			 (IS_XS1_F)  | (IS_XA1_F)| \
567
			 (IS_XS2_F)  | (IS_XA2_F))
568
569
#define Y2_DRIVER_IRQS	((Y2_IS_STAT_BMU) | (Y2_IS_IRQ_SW) | (Y2_IS_POLL_CHK))
570
571
#define SPECIAL_IRQS	((IS_HW_ERR)    |(IS_I2C_READY)  | \
572
			 (IS_EXT_REG)   |(IS_TIMINT)     | \
573
			 (IS_PA_TO_RX1) |(IS_PA_TO_RX2)  | \
574
			 (IS_PA_TO_TX1) |(IS_PA_TO_TX2)  | \
575
			 (IS_MAC1)      |(IS_LNK_SYNC_M1)| \
576
			 (IS_MAC2)      |(IS_LNK_SYNC_M2)| \
577
			 (IS_R1_C)      |(IS_R2_C)       | \
578
			 (IS_XS1_C)     |(IS_XA1_C)      | \
579
			 (IS_XS2_C)     |(IS_XA2_C))
580
581
#define Y2_SPECIAL_IRQS	((Y2_IS_HW_ERR)   |(Y2_IS_ASF)      | \
582
			 (Y2_IS_TWSI_RDY) |(Y2_IS_TIMINT)   | \
583
			 (Y2_IS_IRQ_PHY2) |(Y2_IS_IRQ_MAC2) | \
584
			 (Y2_IS_CHK_RX2)  |(Y2_IS_CHK_TXS2) | \
585
			 (Y2_IS_CHK_TXA2) |(Y2_IS_IRQ_PHY1) | \
586
			 (Y2_IS_IRQ_MAC1) |(Y2_IS_CHK_RX1)  | \
587
			 (Y2_IS_CHK_TXS1) |(Y2_IS_CHK_TXA1))
588
589
#define IRQ_MASK	((IS_IRQ_SW)    | \
590
			 (IS_R1_F)      |(IS_R2_F)     | \
591
			 (IS_XS1_F)     |(IS_XA1_F)    | \
592
			 (IS_XS2_F)     |(IS_XA2_F)    | \
593
			 (IS_HW_ERR)    |(IS_I2C_READY)| \
594
			 (IS_EXT_REG)   |(IS_TIMINT)   | \
595
			 (IS_PA_TO_RX1) |(IS_PA_TO_RX2)| \
596
			 (IS_PA_TO_TX1) |(IS_PA_TO_TX2)| \
597
			 (IS_MAC1)      |(IS_MAC2)     | \
598
			 (IS_R1_C)      |(IS_R2_C)     | \
599
			 (IS_XS1_C)     |(IS_XA1_C)    | \
600
			 (IS_XS2_C)     |(IS_XA2_C))
601
602
#define Y2_IRQ_MASK	((Y2_DRIVER_IRQS) | (Y2_SPECIAL_IRQS))
603
604
#define IRQ_HWE_MASK	(IS_ERR_MSK)		/* enable all HW irqs */
605
#define Y2_IRQ_HWE_MASK	(Y2_HWE_ALL_MSK)	/* enable all HW irqs */
265
606
266
typedef struct s_DevNet DEV_NET;
607
typedef struct s_DevNet DEV_NET;
267
608
268
struct s_DevNet {
609
struct s_DevNet {
269
	int             PortNr;
610
	struct		proc_dir_entry *proc;
270
	int             NetNr;
611
	int		PortNr;
271
	int             Mtu;
612
	int		NetNr;
272
	int             Up;
613
	char		InitialDevName[20];
273
	SK_AC   *pAC;
614
#ifdef Y2_RECOVERY
615
	struct 		timer_list KernelTimer;	/* Kernel timer struct  */
616
	int		TransmitTimeoutTimer; 	/* Transmit timer       */
617
	SK_BOOL		TimerExpired;		/* Transmit timer       */
618
	SK_BOOL		InRecover;		/* Recover flag		*/
619
#ifdef Y2_RX_CHECK
620
	SK_U8		FifoReadPointer;	/* Backup of the FRP */
621
	SK_U8		FifoReadLevel;		/* Backup of the FRL */
622
	SK_U32		BmuStateMachine;	/* Backup of the MBU SM */
623
	SK_U32		LastJiffies;		/* Backup of the jiffies */
624
#endif
625
#endif
626
	SK_AC		*pAC;
274
};  
627
};  
275
628
276
typedef struct s_TxPort		TX_PORT;
629
/*******************************************************************************
630
 *
631
 * Rx/Tx Port structures
632
 *
633
 ******************************************************************************/
277
634
278
struct s_TxPort {
635
typedef struct s_TxPort	TX_PORT;
279
	/* the transmit descriptor rings */
636
struct s_TxPort {                       /* the transmit descriptor rings */
280
	caddr_t		pTxDescrRing;	/* descriptor area memory */
637
	caddr_t         pTxDescrRing;   /* descriptor area memory        */
281
	SK_U64		VTxDescrRing;	/* descr. area bus virt. addr. */
638
	SK_U64          VTxDescrRing;   /* descr. area bus virt. addr.   */
282
	TXD		*pTxdRingHead;	/* Head of Tx rings */
639
	TXD            *pTxdRingHead;   /* Head of Tx rings              */
283
	TXD		*pTxdRingTail;	/* Tail of Tx rings */
640
	TXD            *pTxdRingTail;   /* Tail of Tx rings              */
284
	TXD		*pTxdRingPrev;	/* descriptor sent previously */
641
	TXD            *pTxdRingPrev;   /* descriptor sent previously    */
285
	int		TxdRingFree;	/* # of free entrys */
642
	int             TxdRingPrevFree;/* previously # of free entrys   */
286
	spinlock_t	TxDesRingLock;	/* serialize descriptor accesses */
643
	int             TxdRingFree;    /* # of free entrys              */
287
	SK_IOC		HwAddr;		/* bmu registers address */
644
	spinlock_t      TxDesRingLock;  /* serialize descriptor accesses */
288
	int		PortIndex;	/* index number of port (0 or 1) */
645
	caddr_t         HwAddr;         /* bmu registers address         */
646
	int             PortIndex;      /* index number of port (0 or 1) */
647
	SK_PACKET      *TransmitPacketTable;
648
	SK_LE_TABLE     TxALET;         /* tx (async) list element table */
649
	SK_LE_TABLE     TxSLET;         /* tx (sync) list element table  */
650
	SK_PKT_QUEUE    TxQ_free;
651
	SK_PKT_QUEUE    TxAQ_waiting;
652
	SK_PKT_QUEUE    TxSQ_waiting;
653
	SK_PKT_QUEUE    TxAQ_working;
654
	SK_PKT_QUEUE    TxSQ_working;
655
	unsigned	LastDone;
289
};
656
};
290
657
291
typedef struct s_RxPort		RX_PORT;
658
typedef struct s_RxPort	RX_PORT;
292
659
struct s_RxPort {                       /* the receive descriptor rings  */
293
struct s_RxPort {
660
	caddr_t         pRxDescrRing;   /* descriptor area memory        */
294
	/* the receive descriptor rings */
661
	SK_U64          VRxDescrRing;   /* descr. area bus virt. addr.   */
295
	caddr_t		pRxDescrRing;	/* descriptor area memory */
662
	RXD            *pRxdRingHead;   /* Head of Rx rings              */
296
	SK_U64		VRxDescrRing;   /* descr. area bus virt. addr. */
663
	RXD            *pRxdRingTail;   /* Tail of Rx rings              */
297
	RXD		*pRxdRingHead;	/* Head of Rx rings */
664
	RXD            *pRxdRingPrev;   /* descr given to BMU previously */
298
	RXD		*pRxdRingTail;	/* Tail of Rx rings */
665
	int             RxdRingFree;    /* # of free entrys              */
299
	RXD		*pRxdRingPrev;	/* descriptor given to BMU previously */
666
	spinlock_t      RxDesRingLock;  /* serialize descriptor accesses */
300
	int		RxdRingFree;	/* # of free entrys */
667
	int             RxFillLimit;    /* limit for buffers in ring     */
301
	spinlock_t	RxDesRingLock;	/* serialize descriptor accesses */
668
	caddr_t         HwAddr;         /* bmu registers address         */
302
	int		RxFillLimit;	/* limit for buffers in ring */
669
	int             PortIndex;      /* index number of port (0 or 1) */
303
	SK_IOC		HwAddr;		/* bmu registers address */
670
	SK_BOOL         UseRxCsum;      /* use Rx checksumming (yes/no)  */
304
	int		PortIndex;	/* index number of port (0 or 1) */
671
	SK_PACKET      *ReceivePacketTable;
672
	SK_LE_TABLE     RxLET;          /* rx list element table         */
673
	SK_PKT_QUEUE    RxQ_working;
674
	SK_PKT_QUEUE    RxQ_waiting;
305
};
675
};
306
676
307
/* Definitions needed for interrupt moderation *******************************/
677
/*******************************************************************************
678
 *
679
 * Interrupt masks used in combination with interrupt moderation
680
 *
681
 ******************************************************************************/
308
682
309
#define IRQ_EOF_AS_TX     ((IS_XA1_F)     | (IS_XA2_F))
683
#define IRQ_EOF_AS_TX     ((IS_XA1_F)     | (IS_XA2_F))
310
#define IRQ_EOF_SY_TX     ((IS_XS1_F)     | (IS_XS2_F))
684
#define IRQ_EOF_SY_TX     ((IS_XS1_F)     | (IS_XS2_F))
Lines 316-456 Link Here
316
#define IRQ_MASK_SP_TX    ((SPECIAL_IRQS)    | (IRQ_MASK_TX_ONLY))
690
#define IRQ_MASK_SP_TX    ((SPECIAL_IRQS)    | (IRQ_MASK_TX_ONLY))
317
#define IRQ_MASK_RX_TX_SP ((SPECIAL_IRQS)    | (IRQ_MASK_TX_RX))
691
#define IRQ_MASK_RX_TX_SP ((SPECIAL_IRQS)    | (IRQ_MASK_TX_RX))
318
692
319
#define C_INT_MOD_NONE                 1
693
#define IRQ_MASK_Y2_TX_ONLY  (Y2_IS_STAT_BMU)
320
#define C_INT_MOD_STATIC               2
694
#define IRQ_MASK_Y2_RX_ONLY  (Y2_IS_STAT_BMU)
321
#define C_INT_MOD_DYNAMIC              4
695
#define IRQ_MASK_Y2_SP_ONLY  (SPECIAL_IRQS)
322
696
#define IRQ_MASK_Y2_TX_RX    ((IRQ_MASK_TX_ONLY)| (IRQ_MASK_RX_ONLY))
323
#define C_CLK_FREQ_GENESIS      53215000 /* shorter: 53.125 MHz  */
697
#define IRQ_MASK_Y2_SP_RX    ((SPECIAL_IRQS)    | (IRQ_MASK_RX_ONLY))
324
#define C_CLK_FREQ_YUKON        78215000 /* shorter: 78.125 MHz  */
698
#define IRQ_MASK_Y2_SP_TX    ((SPECIAL_IRQS)    | (IRQ_MASK_TX_ONLY))
325
699
#define IRQ_MASK_Y2_RX_TX_SP ((SPECIAL_IRQS)    | (IRQ_MASK_TX_RX))
326
#define C_INTS_PER_SEC_DEFAULT      2000 
327
#define C_INT_MOD_ENABLE_PERCENTAGE   50 /* if higher 50% enable */
328
#define C_INT_MOD_DISABLE_PERCENTAGE  50 /* if lower 50% disable */
329
#define C_INT_MOD_IPS_LOWER_RANGE     30
330
#define C_INT_MOD_IPS_UPPER_RANGE     40000
331
332
333
typedef struct s_DynIrqModInfo  DIM_INFO;
334
struct s_DynIrqModInfo {
335
	unsigned long   PrevTimeVal;
336
	unsigned int    PrevSysLoad;
337
	unsigned int    PrevUsedTime;
338
	unsigned int    PrevTotalTime;
339
	int             PrevUsedDescrRatio;
340
	int             NbrProcessedDescr;
341
        SK_U64          PrevPort0RxIntrCts;
342
        SK_U64          PrevPort1RxIntrCts;
343
        SK_U64          PrevPort0TxIntrCts;
344
        SK_U64          PrevPort1TxIntrCts;
345
	SK_BOOL         ModJustEnabled;     /* Moderation just enabled yes/no */
346
347
	int             MaxModIntsPerSec;            /* Moderation Threshold */
348
	int             MaxModIntsPerSecUpperLimit;  /* Upper limit for DIM  */
349
	int             MaxModIntsPerSecLowerLimit;  /* Lower limit for DIM  */
350
351
	long            MaskIrqModeration;   /* ModIrqType (eg. 'TxRx')      */
352
	SK_BOOL         DisplayStats;        /* Stats yes/no                 */
353
	SK_BOOL         AutoSizing;          /* Resize DIM-timer on/off      */
354
	int             IntModTypeSelect;    /* EnableIntMod (eg. 'dynamic') */
355
700
356
	SK_TIMER        ModTimer; /* just some timer */
701
/*******************************************************************************
357
};
702
 *
703
 * Defines and typedefs regarding interrupt moderation
704
 *
705
 ******************************************************************************/
358
706
359
typedef struct s_PerStrm	PER_STRM;
707
#define C_INT_MOD_NONE			1
708
#define C_INT_MOD_STATIC		2
709
#define C_INT_MOD_DYNAMIC		4
710
711
#define C_CLK_FREQ_GENESIS		 53215000 /* or:  53.125 MHz */
712
#define C_CLK_FREQ_YUKON		 78215000 /* or:  78.125 MHz */
713
#define C_CLK_FREQ_YUKON_EC		125000000 /* or: 125.000 MHz */
714
715
#define C_Y2_INTS_PER_SEC_DEFAULT	5000 
716
#define C_INTS_PER_SEC_DEFAULT		2000 
717
#define C_INT_MOD_IPS_LOWER_RANGE	30        /* in IRQs/second */
718
#define C_INT_MOD_IPS_UPPER_RANGE	40000     /* in IRQs/second */
719
720
typedef struct s_DynIrqModInfo {
721
	SK_U64     PrevPort0RxIntrCts;
722
	SK_U64     PrevPort1RxIntrCts;
723
	SK_U64     PrevPort0TxIntrCts;
724
	SK_U64     PrevPort1TxIntrCts;
725
	SK_U64     PrevPort0StatusLeIntrCts;
726
	SK_U64     PrevPort1StatusLeIntrCts;
727
	int        MaxModIntsPerSec;            /* Moderation Threshold   */
728
	int        MaxModIntsPerSecUpperLimit;  /* Upper limit for DIM    */
729
	int        MaxModIntsPerSecLowerLimit;  /* Lower limit for DIM    */
730
	long       MaskIrqModeration;           /* IRQ Mask (eg. 'TxRx')  */
731
	int        IntModTypeSelect;            /* Type  (eg. 'dynamic')  */
732
	int        DynIrqModSampleInterval;     /* expressed in seconds!  */
733
	SK_TIMER   ModTimer;                    /* Timer for dynamic mod. */
734
} DIM_INFO;
360
735
361
#define SK_ALLOC_IRQ	0x00000001
736
/*******************************************************************************
737
 *
738
 * Defines and typedefs regarding wake-on-lan
739
 *
740
 ******************************************************************************/
741
742
typedef struct s_WakeOnLanInfo {
743
	SK_U32     SupportedWolOptions;         /* e.g. WAKE_PHY...         */
744
	SK_U32     ConfiguredWolOptions;        /* e.g. WAKE_PHY...         */
745
} WOL_INFO;
362
746
363
#ifdef SK_DIAG_SUPPORT
747
#define SK_ALLOC_IRQ	0x00000001
364
#define	DIAG_ACTIVE		1
748
#define	DIAG_ACTIVE		1
365
#define	DIAG_NOTACTIVE		0
749
#define	DIAG_NOTACTIVE		0
366
#endif
367
750
368
/****************************************************************************
751
/****************************************************************************
752
 *
369
 * Per board structure / Adapter Context structure:
753
 * Per board structure / Adapter Context structure:
370
 *	Allocated within attach(9e) and freed within detach(9e).
754
 * Contains all 'per device' necessary handles, flags, locks etc.:
371
 *	Contains all 'per device' necessary handles, flags, locks etc.:
755
 *
372
 */
756
 ******************************************************************************/
757
373
struct s_AC  {
758
struct s_AC  {
374
	SK_GEINIT	GIni;		/* GE init struct */
759
	SK_GEINIT                GIni;          /* GE init struct             */
375
	SK_PNMI		Pnmi;		/* PNMI data struct */
760
	SK_PNMI                  Pnmi;          /* PNMI data struct           */
376
	SK_VPD		vpd;		/* vpd data struct */
761
	SK_VPD                   vpd;           /* vpd data struct            */
377
	SK_QUEUE	Event;		/* Event queue */
762
	SK_QUEUE                 Event;         /* Event queue                */
378
	SK_HWT		Hwt;		/* Hardware Timer control struct */
763
	SK_HWT                   Hwt;           /* Hardware Timer ctrl struct */
379
	SK_TIMCTRL	Tim;		/* Software Timer control struct */
764
	SK_TIMCTRL               Tim;           /* Software Timer ctrl struct */
380
	SK_I2C		I2c;		/* I2C relevant data structure */
765
	SK_I2C                   I2c;           /* I2C relevant data structure*/
381
	SK_ADDR		Addr;		/* for Address module */
766
	SK_ADDR                  Addr;          /* for Address module         */
382
	SK_CSUM		Csum;		/* for checksum module */
767
	SK_CSUM                  Csum;          /* for checksum module        */
383
	SK_RLMT		Rlmt;		/* for rlmt module */
768
	SK_RLMT                  Rlmt;          /* for rlmt module            */
384
	spinlock_t	SlowPathLock;	/* Normal IRQ lock */
769
	spinlock_t               SlowPathLock;  /* Normal IRQ lock            */
385
	struct timer_list BlinkTimer;	/* for LED blinking */
770
	spinlock_t               TxQueueLock;   /* TX Queue lock              */
386
	int		LedsOn;
771
	SK_PNMI_STRUCT_DATA      PnmiStruct;    /* struct for all Pnmi-Data   */
387
	SK_PNMI_STRUCT_DATA PnmiStruct;	/* structure to get all Pnmi-Data */
772
	int                      RlmtMode;      /* link check mode to set     */
388
	int			RlmtMode;	/* link check mode to set */
773
	int                      RlmtNets;      /* Number of nets             */
389
	int			RlmtNets;	/* Number of nets */
774
	SK_IOC                   IoBase;        /* register set of adapter    */
390
	
775
	int                      BoardLevel;    /* level of hw init (0-2)     */
391
	SK_IOC		IoBase;		/* register set of adapter */
776
	char                     DeviceStr[80]; /* adapter string from vpd    */
392
	int		BoardLevel;	/* level of active hw init (0-2) */
777
	SK_U32                   AllocFlag;     /* alloc flag of resources    */
393
	char		DeviceStr[80];	/* adapter string from vpd */
778
	struct pci_dev          *PciDev;        /* for access to pci cfg space*/
394
	SK_U32		AllocFlag;	/* flag allocation of resources */
779
	SK_U32                   PciDevId;      /* pci device id              */
395
	struct pci_dev	*PciDev;	/* for access to pci config space */
780
	struct SK_NET_DEVICE    *dev[2];        /* pointer to device struct   */
396
	SK_U32		PciDevId;	/* pci device id */
781
	char                     Name[30];      /* driver name                */
397
	struct SK_NET_DEVICE	*dev[2];	/* pointer to device struct */
782
	struct SK_NET_DEVICE    *Next;          /* link all devs for cleanup  */
398
	char		Name[30];	/* driver name */
783
	int                      RxBufSize;     /* length of receive buffers  */
399
784
	struct net_device_stats  stats;         /* linux 'netstat -i' stats   */
400
	int		RxBufSize;	/* length of receive buffers */
785
	int                      Index;         /* internal board idx number  */
401
        struct net_device_stats stats;	/* linux 'netstat -i' statistics */
786
	int                      RxQueueSize;   /* memory used for RX queue   */
402
	int		Index;		/* internal board index number */
787
	int                      TxSQueueSize;  /* memory used for TXS queue  */
403
788
	int                      TxAQueueSize;  /* memory used for TXA queue  */
404
	/* adapter RAM sizes for queues of active port */
789
	int                      PromiscCount;  /* promiscuous mode counter   */
405
	int		RxQueueSize;	/* memory used for receive queue */
790
	int                      AllMultiCount; /* allmulticast mode counter  */
406
	int		TxSQueueSize;	/* memory used for sync. tx queue */
791
	int                      MulticCount;   /* number of MC addresses used*/
407
	int		TxAQueueSize;	/* memory used for async. tx queue */
792
	int                      HWRevision;	/* Hardware revision          */
408
793
	int                      ActivePort;	/* the active XMAC port       */
409
	int		PromiscCount;	/* promiscuous mode counter  */
794
	int                      MaxPorts;      /* number of activated ports  */
410
	int		AllMultiCount;  /* allmulticast mode counter */
795
	int                      TxDescrPerRing;/* # of descriptors TX ring   */
411
	int		MulticCount;	/* number of different MC    */
796
	int                      RxDescrPerRing;/* # of descriptors RX ring   */
412
					/*  addresses for this board */
797
	caddr_t                  pDescrMem;     /* Ptr to the descriptor area */
413
					/*  (may be more than HW can)*/
798
	dma_addr_t               pDescrMemDMA;  /* PCI DMA address of area    */
414
799
	SK_U32			 PciState[16];  /* PCI state */
415
	int		HWRevision;	/* Hardware revision */
800
	TX_PORT                  TxPort[SK_MAX_MACS][2];
416
	int		ActivePort;	/* the active XMAC port */
801
	RX_PORT                  RxPort[SK_MAX_MACS];
417
	int		MaxPorts;		/* number of activated ports */
802
	SK_LE_TABLE              StatusLETable; 
418
	int		TxDescrPerRing;	/* # of descriptors per tx ring */
803
	unsigned                 SizeOfAlignedLETables;	
419
	int		RxDescrPerRing;	/* # of descriptors per rx ring */
804
	spinlock_t               SetPutIndexLock;
420
805
	int                      MaxUnusedRxLeWorking;
421
	caddr_t		pDescrMem;	/* Pointer to the descriptor area */
806
	unsigned int             CsOfs1;        /* for checksum calculation   */
422
	dma_addr_t	pDescrMemDMA;	/* PCI DMA address of area */
807
	unsigned int             CsOfs2;        /* for checksum calculation   */
423
808
	SK_U32                   CsOfs;         /* for checksum calculation   */
424
	/* the port structures with descriptor rings */
809
	SK_BOOL                  CheckQueue;    /* check event queue soon     */
425
	TX_PORT		TxPort[SK_MAX_MACS][2];
810
	DIM_INFO                 DynIrqModInfo; /* all data related to IntMod */
426
	RX_PORT		RxPort[SK_MAX_MACS];
811
	WOL_INFO                 WolInfo;       /* all info regarding WOL     */
427
812
	int                      ChipsetType;   /* 0=GENESIS; 1=Yukon         */
428
	unsigned int	CsOfs1;		/* for checksum calculation */
813
	SK_BOOL                  LowLatency;    /* LowLatency optimization on?*/
429
	unsigned int	CsOfs2;		/* for checksum calculation */
814
	SK_U32                   DiagModeActive;/* is diag active?            */
430
	SK_U32		CsOfs;		/* for checksum calculation */
815
	SK_BOOL                  DiagFlowCtrl;  /* for control purposes       */
431
816
	SK_PNMI_STRUCT_DATA      PnmiBackup;    /* backup structure for PNMI  */
432
	SK_BOOL		CheckQueue;	/* check event queue soon */
817
	SK_BOOL                  WasIfUp[SK_MAX_MACS];
433
	SK_TIMER        DrvCleanupTimer;/* to check for pending descriptors */
818
#ifdef USE_TIST_FOR_RESET
434
	DIM_INFO        DynIrqModInfo;  /* all data related to DIM */
819
	int			 AdapterResetState;
435
820
	SK_U32			 MinTistLo;
436
	/* Only for tests */
821
	SK_U32			 MinTistHi;
437
	int		PortUp;
822
#endif
438
	int		PortDown;
823
#ifdef Y2_RECOVERY
439
	int		ChipsetType;	/*  Chipset family type 
824
	int                      LastPort;       /* port for curr. handled rx */
440
					 *  0 == Genesis family support
825
        int                      LastOpc;        /* last rx LEs opcode	      */
441
					 *  1 == Yukon family support
826
#endif
442
					 */
827
#ifdef Y2_SYNC_CHECK
443
#ifdef SK_DIAG_SUPPORT
828
	unsigned long            FramesWithoutSyncCheck; /* since last check  */
444
	SK_U32		DiagModeActive;		/* is diag active?	*/
445
	SK_BOOL		DiagFlowCtrl;		/* for control purposes	*/
446
	SK_PNMI_STRUCT_DATA PnmiBackup;		/* backup structure for all Pnmi-Data */
447
	SK_BOOL         WasIfUp[SK_MAX_MACS];   /* for OpenClose while 
448
						 * DIAG is busy with NIC 
449
						 */
450
#endif
829
#endif
451
452
};
830
};
453
831
454
832
455
#endif /* __INC_SKDRV2ND_H */
456
833
834
#endif
835
836
/*******************************************************************************
837
 *
838
 * End of file
839
 *
840
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/h/skerror.h (-6 / +6 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skerror.h
3
 * Name:	skerror.h
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.7 $
5
 * Version:	$Revision: 2.2 $
6
 * Date:	$Date: 2003/05/13 17:25:13 $
6
 * Date:	$Date: 2004/05/24 15:27:19 $
7
 * Purpose:	SK specific Error log support
7
 * Purpose:	SK specific Error log support
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-23 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
22
 *
21
 *
23
 ******************************************************************************/
22
 ******************************************************************************/
Lines 36-42 Link Here
36
#define	SK_ERRCL_HW			(1L<<4)	/* Hardware Failure */
35
#define	SK_ERRCL_HW			(1L<<4)	/* Hardware Failure */
37
#define	SK_ERRCL_COMM		(1L<<5)	/* Communication error */
36
#define	SK_ERRCL_COMM		(1L<<5)	/* Communication error */
38
37
39
40
/*
38
/*
41
 * Define Error Code Bases
39
 * Define Error Code Bases
42
 */
40
 */
Lines 49-55 Link Here
49
#define	SK_ERRBASE_I2C		 700	/* Base Error number for I2C module */
47
#define	SK_ERRBASE_I2C		 700	/* Base Error number for I2C module */
50
#define	SK_ERRBASE_QUEUE	 800	/* Base Error number for Scheduler */
48
#define	SK_ERRBASE_QUEUE	 800	/* Base Error number for Scheduler */
51
#define	SK_ERRBASE_ADDR		 900	/* Base Error number for Address module */
49
#define	SK_ERRBASE_ADDR		 900	/* Base Error number for Address module */
52
#define SK_ERRBASE_PECP		1000    /* Base Error number for PECP */
50
#define SK_ERRBASE_PECP		1000	/* Base Error number for PECP */
53
#define	SK_ERRBASE_DRV		1100	/* Base Error number for Driver */
51
#define	SK_ERRBASE_DRV		1100	/* Base Error number for Driver */
52
#define SK_ERRBASE_ASF		1200	/* Base Error number for ASF */
54
53
55
#endif	/* _INC_SKERROR_H_ */
54
#endif	/* _INC_SKERROR_H_ */
55
(-)linux/drivers/net/sk98lin/h/skgedrv.h (-2 / +2 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skgedrv.h
3
 * Name:	skgedrv.h
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.10 $
5
 * Version:	$Revision: 2.1 $
6
 * Date:	$Date: 2003/07/04 12:25:01 $
6
 * Date:	$Date: 2003/10/27 14:16:08 $
7
 * Purpose:	Interface with the driver
7
 * Purpose:	Interface with the driver
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/h/skgehw.h (-289 / +1088 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skgehw.h
3
 * Name:	skgehw.h
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.56 $
5
 * Version:	$Revision: 2.49 $
6
 * Date:	$Date: 2003/09/23 09:01:00 $
6
 * Date:	$Date: 2005/01/20 13:01:35 $
7
 * Purpose:	Defines and Macros for the Gigabit Ethernet Adapter Product Family
7
 * Purpose:	Defines and Macros for the Gigabit Ethernet Adapter Product Family
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-23 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
22
 *
21
 *
23
 ******************************************************************************/
22
 ******************************************************************************/
Lines 114-119 Link Here
114
#define SHIFT1(x)	((x) << 1)
113
#define SHIFT1(x)	((x) << 1)
115
#define SHIFT0(x)	((x) << 0)
114
#define SHIFT0(x)	((x) << 0)
116
115
116
/* Macro for arbitrary alignment of a given pointer */
117
#define ALIGN_ADDR( ADDRESS, GRANULARITY ) { \
118
	SK_UPTR addr = (SK_UPTR)(ADDRESS); \
119
	if (addr & ((GRANULARITY)-1)) { \
120
		addr += (GRANULARITY); \
121
		addr &= ~(SK_UPTR)((GRANULARITY)-1); \
122
		ADDRESS = (void *)addr; \
123
	}\
124
}
125
117
/*
126
/*
118
 * Configuration Space header
127
 * Configuration Space header
119
 * Since this module is used for different OS', those may be
128
 * Since this module is used for different OS', those may be
Lines 132-165 Link Here
132
#define PCI_BIST		0x0f	/*  8 bit	Built-in selftest */
141
#define PCI_BIST		0x0f	/*  8 bit	Built-in selftest */
133
#define PCI_BASE_1ST	0x10	/* 32 bit	1st Base address */
142
#define PCI_BASE_1ST	0x10	/* 32 bit	1st Base address */
134
#define PCI_BASE_2ND	0x14	/* 32 bit	2nd Base address */
143
#define PCI_BASE_2ND	0x14	/* 32 bit	2nd Base address */
135
	/* Byte 0x18..0x2b:	reserved */
144
	/* Bytes 0x18..0x2b:	reserved */
136
#define PCI_SUB_VID		0x2c	/* 16 bit	Subsystem Vendor ID */
145
#define PCI_SUB_VID		0x2c	/* 16 bit	Subsystem Vendor ID */
137
#define PCI_SUB_ID		0x2e	/* 16 bit	Subsystem ID */
146
#define PCI_SUB_ID		0x2e	/* 16 bit	Subsystem ID */
138
#define PCI_BASE_ROM	0x30	/* 32 bit	Expansion ROM Base Address */
147
#define PCI_BASE_ROM	0x30	/* 32 bit	Expansion ROM Base Address */
139
#define PCI_CAP_PTR		0x34	/*  8 bit 	Capabilities Ptr */
148
#define PCI_CAP_PTR		0x34	/*  8 bit	Capabilities Pointer */
140
	/* Byte 0x35..0x3b:	reserved */
149
	/* Bytes 0x35..0x3b:	reserved */
141
#define PCI_IRQ_LINE	0x3c	/*  8 bit	Interrupt Line */
150
#define PCI_IRQ_LINE	0x3c	/*  8 bit	Interrupt Line */
142
#define PCI_IRQ_PIN		0x3d	/*  8 bit	Interrupt Pin */
151
#define PCI_IRQ_PIN		0x3d	/*  8 bit	Interrupt Pin */
143
#define PCI_MIN_GNT		0x3e	/*  8 bit	Min_Gnt */
152
#define PCI_MIN_GNT		0x3e	/*  8 bit	Min_Gnt */
144
#define PCI_MAX_LAT		0x3f	/*  8 bit	Max_Lat */
153
#define PCI_MAX_LAT		0x3f	/*  8 bit	Max_Lat */
145
	/* Device Dependent Region */
154
	/* Device Dependent Region */
146
#define PCI_OUR_REG_1	0x40	/* 32 bit 	Our Register 1 */
155
#define PCI_OUR_REG_1	0x40	/* 32 bit	Our Register 1 */
147
#define PCI_OUR_REG_2	0x44	/* 32 bit 	Our Register 2 */
156
#define PCI_OUR_REG_2	0x44	/* 32 bit	Our Register 2 */
148
	/* Power Management Region */
157
	/* Power Management Region */
149
#define PCI_PM_CAP_ID	0x48	/*  8 bit 	Power Management Cap. ID */
158
#define PCI_PM_CAP_ID	0x48	/*  8 bit	Power Management Cap. ID */
150
#define PCI_PM_NITEM	0x49	/*  8 bit 	Next Item Ptr */
159
#define PCI_PM_NITEM	0x49	/*  8 bit	PM Next Item Pointer */
151
#define PCI_PM_CAP_REG	0x4a	/* 16 bit 	Power Management Capabilities */
160
#define PCI_PM_CAP_REG	0x4a	/* 16 bit	Power Management Capabilities */
152
#define PCI_PM_CTL_STS	0x4c	/* 16 bit 	Power Manag. Control/Status */
161
#define PCI_PM_CTL_STS	0x4c	/* 16 bit	Power Manag. Control/Status */
153
	/* Byte 0x4e:	reserved */
162
	/* Byte 0x4e:	reserved */
154
#define PCI_PM_DAT_REG	0x4f	/*  8 bit 	Power Manag. Data Register */
163
#define PCI_PM_DAT_REG	0x4f	/*  8 bit	Power Manag. Data Register */
155
	/* VPD Region */
164
	/* VPD Region */
156
#define PCI_VPD_CAP_ID	0x50	/*  8 bit 	VPD Cap. ID */
165
#define PCI_VPD_CAP_ID	0x50	/*  8 bit	VPD Cap. ID */
157
#define PCI_VPD_NITEM	0x51	/*  8 bit 	Next Item Ptr */
166
#define PCI_VPD_NITEM	0x51	/*  8 bit	VPD Next Item Pointer */
158
#define PCI_VPD_ADR_REG	0x52	/* 16 bit 	VPD Address Register */
167
#define PCI_VPD_ADR_REG	0x52	/* 16 bit	VPD Address Register */
159
#define PCI_VPD_DAT_REG	0x54	/* 32 bit 	VPD Data Register */
168
#define PCI_VPD_DAT_REG	0x54	/* 32 bit	VPD Data Register */
160
	/* Byte 0x58..0x59:	reserved */
169
	/* Bytes 0x58..0x59:	reserved */
161
#define PCI_SER_LD_CTRL	0x5a	/* 16 bit 	SEEPROM Loader Ctrl (YUKON only) */
170
#define PCI_SER_LD_CTRL	0x5a	/* 16 bit	SEEPROM Loader Ctrl (YUKON only) */
162
	/* Byte 0x5c..0xff:	reserved */
171
	/* Bytes 0x5c..0xfc:	used by Yukon-2 */
172
#define PCI_MSI_CAP_ID	0x5c	/*  8 bit	MSI Capability ID Register */
173
#define PCI_MSI_NITEM	0x5d	/*  8 bit	MSI Next Item Pointer */
174
#define PCI_MSI_CTRL	0x5e	/* 16 bit	MSI Message Control */
175
#define PCI_MSI_ADR_LO	0x60	/* 32 bit	MSI Message Address (Lower) */
176
#define PCI_MSI_ADR_HI	0x64	/* 32 bit	MSI Message Address (Upper) */
177
#define PCI_MSI_DATA	0x68	/* 16 bit	MSI Message Data */
178
	/* Bytes 0x6a..0x6b:	reserved */
179
#define PCI_X_CAP_ID	0x6c	/*  8 bit	PCI-X Capability ID Register */
180
#define PCI_X_NITEM		0x6d	/*  8 bit	PCI-X Next Item Pointer */
181
#define PCI_X_COMMAND	0x6e	/* 16 bit	PCI-X Command */
182
#define PCI_X_PE_STAT	0x70	/* 32 bit	PCI-X / PE Status */
183
#define PCI_CAL_CTRL	0x74	/* 16 bit	PCI Calibration Control Register */
184
#define PCI_CAL_STAT	0x76	/* 16 bit	PCI Calibration Status Register */
185
#define PCI_DISC_CNT	0x78	/* 16 bit	PCI Discard Counter */
186
#define PCI_RETRY_CNT	0x7a	/*  8 bit	PCI Retry Counter */
187
	/* Byte 0x7b:	reserved */
188
#define PCI_OUR_STATUS	0x7c	/* 32 bit	Adapter Status Register */
189
	/* Bytes 0x80..0xdf:	reserved */
190
191
/* PCI Express Capability */
192
#define PEX_CAP_ID		0xe0	/*  8 bit	PEX Capability ID */
193
#define PEX_NITEM		0xe1	/*  8 bit	PEX Next Item Pointer */
194
#define PEX_CAP_REG		0xe2	/* 16 bit	PEX Capability Register */
195
#define PEX_DEV_CAP		0xe4	/* 32 bit	PEX Device Capabilities */
196
#define PEX_DEV_CTRL	0xe8	/* 16 bit	PEX Device Control */
197
#define PEX_DEV_STAT	0xea	/* 16 bit	PEX Device Status */
198
#define PEX_LNK_CAP		0xec	/* 32 bit	PEX Link Capabilities */
199
#define PEX_LNK_CTRL	0xf0	/* 16 bit	PEX Link Control */
200
#define PEX_LNK_STAT	0xf2	/* 16 bit	PEX Link Status */
201
	/* Bytes 0xf4..0xff:	reserved */
202
203
/* PCI Express Extended Capabilities */
204
#define PEX_ADV_ERR_REP		0x100	/* 32 bit	PEX Advanced Error Reporting */
205
#define PEX_UNC_ERR_STAT	0x104	/* 32 bit	PEX Uncorr. Errors Status */
206
#define PEX_UNC_ERR_MASK	0x108	/* 32 bit	PEX Uncorr. Errors Mask */
207
#define PEX_UNC_ERR_SEV		0x10c	/* 32 bit	PEX Uncorr. Errors Severity */
208
#define PEX_COR_ERR_STAT	0x110	/* 32 bit	PEX Correc. Errors Status */
209
#define PEX_COR_ERR_MASK	0x114	/* 32 bit	PEX Correc. Errors Mask */
210
#define PEX_ADV_ERR_CAP_C	0x118	/* 32 bit	PEX Advanced Error Cap./Ctrl */
211
#define PEX_HEADER_LOG		0x11c	/* 4x32 bit	PEX Header Log Register */
163
212
164
/*
213
/*
165
 * I2C Address (PCI Config)
214
 * I2C Address (PCI Config)
Lines 180-192 Link Here
180
#define PCI_ADSTEP		BIT_7S		/* Address Stepping */
229
#define PCI_ADSTEP		BIT_7S		/* Address Stepping */
181
#define PCI_PERREN		BIT_6S		/* Parity Report Response enable */
230
#define PCI_PERREN		BIT_6S		/* Parity Report Response enable */
182
#define PCI_VGA_SNOOP	BIT_5S		/* VGA palette snoop */
231
#define PCI_VGA_SNOOP	BIT_5S		/* VGA palette snoop */
183
#define PCI_MWIEN		BIT_4S		/* Memory write an inv cycl ena */
232
#define PCI_MWIEN		BIT_4S		/* Memory write an inv cycl enable */
184
#define PCI_SCYCEN		BIT_3S		/* Special Cycle enable */
233
#define PCI_SCYCEN		BIT_3S		/* Special Cycle enable */
185
#define PCI_BMEN		BIT_2S		/* Bus Master enable */
234
#define PCI_BMEN		BIT_2S		/* Bus Master enable */
186
#define PCI_MEMEN		BIT_1S		/* Memory Space Access enable */
235
#define PCI_MEMEN		BIT_1S		/* Memory Space Access enable */
187
#define PCI_IOEN		BIT_0S		/* I/O Space Access enable */
236
#define PCI_IOEN		BIT_0S		/* I/O Space Access enable */
188
237
189
#define PCI_COMMAND_VAL	(PCI_FBTEN | PCI_SERREN | PCI_PERREN | PCI_MWIEN |\
238
#define PCI_COMMAND_VAL	(PCI_INT_DIS | PCI_SERREN | PCI_PERREN | \
190
						 PCI_BMEN | PCI_MEMEN | PCI_IOEN)
239
						 PCI_BMEN | PCI_MEMEN | PCI_IOEN)
191
240
192
/*	PCI_STATUS	16 bit	Status */
241
/*	PCI_STATUS	16 bit	Status */
Lines 220-226 Link Here
220
269
221
/*	PCI_HEADER_T	8 bit	Header Type */
270
/*	PCI_HEADER_T	8 bit	Header Type */
222
#define PCI_HD_MF_DEV	BIT_7S	/* 0= single, 1= multi-func dev */
271
#define PCI_HD_MF_DEV	BIT_7S	/* 0= single, 1= multi-func dev */
223
#define PCI_HD_TYPE		0x7f	/* Bit 6..0:	Header Layout 0= normal */
272
#define PCI_HD_TYPE		0x7f	/* Bit 6..0:	Header Layout (0=normal) */
224
273
225
/*	PCI_BIST	8 bit	Built-in selftest */
274
/*	PCI_BIST	8 bit	Built-in selftest */
226
/*	Built-in Self test not supported (optional) */
275
/*	Built-in Self test not supported (optional) */
Lines 229-261 Link Here
229
#define PCI_MEMSIZE		0x4000L		/* use 16 kB Memory Base */
278
#define PCI_MEMSIZE		0x4000L		/* use 16 kB Memory Base */
230
#define PCI_MEMBASE_MSK 0xffffc000L	/* Bit 31..14:	Memory Base Address */
279
#define PCI_MEMBASE_MSK 0xffffc000L	/* Bit 31..14:	Memory Base Address */
231
#define PCI_MEMSIZE_MSK 0x00003ff0L	/* Bit 13.. 4:	Memory Size Req. */
280
#define PCI_MEMSIZE_MSK 0x00003ff0L	/* Bit 13.. 4:	Memory Size Req. */
232
#define PCI_PREFEN		BIT_3		/* Prefetchable */
281
#define PCI_PREFEN		BIT_3		/* Prefetch enable */
233
#define PCI_MEM_TYP		(3L<<2)		/* Bit	2.. 1:	Memory Type */
282
#define PCI_MEM_TYP_MSK	(3L<<1)		/* Bit	2.. 1:	Memory Type Mask */
283
#define PCI_MEMSPACE	BIT_0		/* Memory Space Indicator */
284
234
#define PCI_MEM32BIT	(0L<<1)		/* Base addr anywhere in 32 Bit range */
285
#define PCI_MEM32BIT	(0L<<1)		/* Base addr anywhere in 32 Bit range */
235
#define PCI_MEM1M		(1L<<1)		/* Base addr below 1 MegaByte */
286
#define PCI_MEM1M		(1L<<1)		/* Base addr below 1 MegaByte */
236
#define PCI_MEM64BIT	(2L<<1)		/* Base addr anywhere in 64 Bit range */
287
#define PCI_MEM64BIT	(2L<<1)		/* Base addr anywhere in 64 Bit range */
237
#define PCI_MEMSPACE	BIT_0		/* Memory Space Indicator */
238
288
239
/*	PCI_BASE_2ND	32 bit	2nd Base address */
289
/*	PCI_BASE_2ND	32 bit	2nd Base address */
240
#define PCI_IOBASE		0xffffff00L	/* Bit 31.. 8:	I/O Base address */
290
#define PCI_IOBASE		0xffffff00L	/* Bit 31.. 8:	I/O Base address */
241
#define PCI_IOSIZE		0x000000fcL	/* Bit	7.. 2:	I/O Size Requirements */
291
#define PCI_IOSIZE		0x000000fcL	/* Bit	7.. 2:	I/O Size Requirements */
242
									/* Bit	1:	reserved */
292
								/* Bit	1:	reserved */
243
#define PCI_IOSPACE		BIT_0		/* I/O Space Indicator */
293
#define PCI_IOSPACE		BIT_0		/* I/O Space Indicator */
244
294
245
/*	PCI_BASE_ROM	32 bit	Expansion ROM Base Address */
295
/*	PCI_BASE_ROM	32 bit	Expansion ROM Base Address */
246
#define PCI_ROMBASE_MSK	0xfffe0000L	/* Bit 31..17:	ROM Base address */
296
#define PCI_ROMBASE_MSK	0xfffe0000L	/* Bit 31..17:	ROM Base address */
247
#define PCI_ROMBASE_SIZ	(0x1cL<<14)	/* Bit 16..14:	Treat as Base or Size */
297
#define PCI_ROMBASE_SIZ	(0x1cL<<14)	/* Bit 16..14:	Treat as Base or Size */
248
#define PCI_ROMSIZE		(0x38L<<11)	/* Bit 13..11:	ROM Size Requirements */
298
#define PCI_ROMSIZE		(0x38L<<11)	/* Bit 13..11:	ROM Size Requirements */
249
									/* Bit 10.. 1:	reserved */
299
								/* Bit 10.. 1:	reserved */
250
#define PCI_ROMEN		BIT_0		/* Address Decode enable */
300
#define PCI_ROMEN		BIT_0		/* Address Decode enable */
251
301
252
/* Device Dependent Region */
302
/* Device Dependent Region */
253
/*	PCI_OUR_REG_1		32 bit	Our Register 1 */
303
/*	PCI_OUR_REG_1		32 bit	Our Register 1 */
254
									/* Bit 31..29:	reserved */
304
								/* Bit 31..29:	reserved */
255
#define PCI_PHY_COMA	BIT_28		/* Set PHY to Coma Mode (YUKON only) */
305
#define PCI_PHY_COMA	BIT_28		/* Set PHY to Coma Mode (YUKON only) */
256
#define PCI_TEST_CAL	BIT_27		/* Test PCI buffer calib. (YUKON only) */
306
#define PCI_TEST_CAL	BIT_27		/* Test PCI buffer calib. (YUKON only) */
257
#define PCI_EN_CAL		BIT_26		/* Enable PCI buffer calib. (YUKON only) */
307
#define PCI_EN_CAL		BIT_26		/* Enable PCI buffer calib. (YUKON only) */
258
#define PCI_VIO			BIT_25		/* PCI I/O Voltage, 0 = 3.3V, 1 = 5V */
308
#define PCI_VIO			BIT_25		/* PCI I/O Voltage, 0 = 3.3V, 1 = 5V */
309
/* Yukon-2 */
310
#define PCI_Y2_PIG_ENA		BIT_31	/* Enable Plug-in-Go (YUKON-2) */
311
#define PCI_Y2_DLL_DIS		BIT_30	/* Disable PCI DLL (YUKON-2) */
312
#define PCI_Y2_PHY2_COMA	BIT_29	/* Set PHY 2 to Coma Mode (YUKON-2) */
313
#define PCI_Y2_PHY1_COMA	BIT_28	/* Set PHY 1 to Coma Mode (YUKON-2) */
314
#define PCI_Y2_PHY2_POWD	BIT_27	/* Set PHY 2 to Power Down (YUKON-2) */
315
#define PCI_Y2_PHY1_POWD	BIT_26	/* Set PHY 1 to Power Down (YUKON-2) */
316
								/* Bit 25:	reserved */
259
#define PCI_DIS_BOOT	BIT_24		/* Disable BOOT via ROM */
317
#define PCI_DIS_BOOT	BIT_24		/* Disable BOOT via ROM */
260
#define PCI_EN_IO		BIT_23		/* Mapping to I/O space */
318
#define PCI_EN_IO		BIT_23		/* Mapping to I/O space */
261
#define PCI_EN_FPROM	BIT_22		/* Enable FLASH mapping to memory */
319
#define PCI_EN_FPROM	BIT_22		/* Enable FLASH mapping to memory */
Lines 266-274 Link Here
266
#define PCI_PAGE_32K	(1L<<20)	/*		32 k pages	*/
324
#define PCI_PAGE_32K	(1L<<20)	/*		32 k pages	*/
267
#define PCI_PAGE_64K	(2L<<20)	/*		64 k pages	*/
325
#define PCI_PAGE_64K	(2L<<20)	/*		64 k pages	*/
268
#define PCI_PAGE_128K	(3L<<20)	/*		128 k pages	*/
326
#define PCI_PAGE_128K	(3L<<20)	/*		128 k pages	*/
269
									/* Bit 19:	reserved	*/
327
								/* Bit 19:	reserved	*/
270
#define PCI_PAGEREG		(7L<<16)	/* Bit 18..16:	Page Register	*/
328
#define PCI_PAGEREG		(7L<<16)	/* Bit 18..16:	Page Register	*/
271
#define PCI_NOTAR		BIT_15		/* No turnaround cycle */
329
#define PCI_NOTAR		BIT_15		/* No turnaround cycle */
330
#define PCI_PEX_LEGNAT	BIT_15		/* PEX PM legacy/native mode (YUKON-2) */
272
#define PCI_FORCE_BE	BIT_14		/* Assert all BEs on MR */
331
#define PCI_FORCE_BE	BIT_14		/* Assert all BEs on MR */
273
#define PCI_DIS_MRL		BIT_13		/* Disable Mem Read Line */
332
#define PCI_DIS_MRL		BIT_13		/* Disable Mem Read Line */
274
#define PCI_DIS_MRM		BIT_12		/* Disable Mem Read Multiple */
333
#define PCI_DIS_MRM		BIT_12		/* Disable Mem Read Multiple */
Lines 278-290 Link Here
278
#define PCI_DIS_PCI_CLK	BIT_8		/* Disable PCI clock driving */
337
#define PCI_DIS_PCI_CLK	BIT_8		/* Disable PCI clock driving */
279
#define PCI_SKEW_DAS	(0xfL<<4)	/* Bit	7.. 4:	Skew Ctrl, DAS Ext */
338
#define PCI_SKEW_DAS	(0xfL<<4)	/* Bit	7.. 4:	Skew Ctrl, DAS Ext */
280
#define PCI_SKEW_BASE	0xfL		/* Bit	3.. 0:	Skew Ctrl, Base	*/
339
#define PCI_SKEW_BASE	0xfL		/* Bit	3.. 0:	Skew Ctrl, Base	*/
281
340
#define PCI_CLS_OPT		BIT_3		/* Cache Line Size opt. PCI-X (YUKON-2) */ 
282
341
283
/*	PCI_OUR_REG_2		32 bit	Our Register 2 */
342
/*	PCI_OUR_REG_2		32 bit	Our Register 2 */
284
#define PCI_VPD_WR_THR	(0xffL<<24)	/* Bit 31..24:	VPD Write Threshold */
343
#define PCI_VPD_WR_THR	(0xffL<<24)	/* Bit 31..24:	VPD Write Threshold */
285
#define PCI_DEV_SEL		(0x7fL<<17)	/* Bit 23..17:	EEPROM Device Select */
344
#define PCI_DEV_SEL		(0x7fL<<17)	/* Bit 23..17:	EEPROM Device Select */
286
#define PCI_VPD_ROM_SZ	(7L<<14)	/* Bit 16..14:	VPD ROM Size	*/
345
#define PCI_VPD_ROM_SZ	(7L<<14)	/* Bit 16..14:	VPD ROM Size	*/
287
									/* Bit 13..12:	reserved	*/
346
								/* Bit 13..12:	reserved	*/
288
#define PCI_PATCH_DIR	(0xfL<<8)	/* Bit 11.. 8:	Ext Patches dir 3..0 */
347
#define PCI_PATCH_DIR	(0xfL<<8)	/* Bit 11.. 8:	Ext Patches dir 3..0 */
289
#define PCI_PATCH_DIR_3	BIT_11
348
#define PCI_PATCH_DIR_3	BIT_11
290
#define PCI_PATCH_DIR_2	BIT_10
349
#define PCI_PATCH_DIR_2	BIT_10
Lines 297-317 Link Here
297
#define PCI_EXT_PATCH_0	BIT_4
356
#define PCI_EXT_PATCH_0	BIT_4
298
#define PCI_EN_DUMMY_RD	BIT_3		/* Enable Dummy Read */
357
#define PCI_EN_DUMMY_RD	BIT_3		/* Enable Dummy Read */
299
#define PCI_REV_DESC	BIT_2		/* Reverse Desc. Bytes */
358
#define PCI_REV_DESC	BIT_2		/* Reverse Desc. Bytes */
300
									/* Bit	1:	reserved */
359
								/* Bit	1:	reserved */
301
#define PCI_USEDATA64	BIT_0		/* Use 64Bit Data bus ext */
360
#define PCI_USEDATA64	BIT_0		/* Use 64Bit Data bus ext */
302
361
303
304
/* Power Management Region */
362
/* Power Management Region */
305
/*	PCI_PM_CAP_REG		16 bit	Power Management Capabilities */
363
/*	PCI_PM_CAP_REG		16 bit	Power Management Capabilities */
306
#define PCI_PME_SUP_MSK	(0x1f<<11)	/* Bit 15..11:	PM Event Support Mask */
364
#define PCI_PME_SUP_MSK	(0x1f<<11)	/* Bit 15..11:	PM Event Support Mask */
307
#define PCI_PME_D3C_SUP	BIT_15S		/* PME from D3cold Support (if Vaux) */
365
#define PCI_PME_D3C_SUP	BIT_15S		/* PME from D3cold Support (if VAUX) */
308
#define PCI_PME_D3H_SUP	BIT_14S		/* PME from D3hot Support */
366
#define PCI_PME_D3H_SUP	BIT_14S		/* PME from D3hot Support */
309
#define PCI_PME_D2_SUP	BIT_13S		/* PME from D2 Support */
367
#define PCI_PME_D2_SUP	BIT_13S		/* PME from D2 Support */
310
#define PCI_PME_D1_SUP	BIT_12S		/* PME from D1 Support */
368
#define PCI_PME_D1_SUP	BIT_12S		/* PME from D1 Support */
311
#define PCI_PME_D0_SUP	BIT_11S		/* PME from D0 Support */
369
#define PCI_PME_D0_SUP	BIT_11S		/* PME from D0 Support */
312
#define PCI_PM_D2_SUP	BIT_10S		/* D2 Support in 33 MHz mode */
370
#define PCI_PM_D2_SUP	BIT_10S		/* D2 Support in 33 MHz mode */
313
#define PCI_PM_D1_SUP	BIT_9S		/* D1 Support */
371
#define PCI_PM_D1_SUP	BIT_9S		/* D1 Support */
314
									/* Bit	8.. 6:	reserved */
372
								/* Bit	8.. 6:	reserved */
315
#define PCI_PM_DSI		BIT_5S		/* Device Specific Initialization */
373
#define PCI_PM_DSI		BIT_5S		/* Device Specific Initialization */
316
#define PCI_PM_APS		BIT_4S		/* Auxialiary Power Source */
374
#define PCI_PM_APS		BIT_4S		/* Auxialiary Power Source */
317
#define PCI_PME_CLOCK	BIT_3S		/* PM Event Clock */
375
#define PCI_PME_CLOCK	BIT_3S		/* PM Event Clock */
Lines 322-328 Link Here
322
#define PCI_PM_DAT_SCL	(3<<13)		/* Bit 14..13:	Data Reg. scaling factor */
380
#define PCI_PM_DAT_SCL	(3<<13)		/* Bit 14..13:	Data Reg. scaling factor */
323
#define PCI_PM_DAT_SEL	(0xf<<9)	/* Bit 12.. 9:	PM data selector field */
381
#define PCI_PM_DAT_SEL	(0xf<<9)	/* Bit 12.. 9:	PM data selector field */
324
#define PCI_PME_EN		BIT_8S		/* Enable PME# generation (YUKON only) */
382
#define PCI_PME_EN		BIT_8S		/* Enable PME# generation (YUKON only) */
325
									/* Bit	7.. 2:	reserved */
383
								/* Bit	7.. 2:	reserved */
326
#define PCI_PM_STATE_MSK	3		/* Bit	1.. 0:	Power Management State */
384
#define PCI_PM_STATE_MSK	3		/* Bit	1.. 0:	Power Management State */
327
385
328
#define PCI_PM_STATE_D0		0		/* D0:	Operational (default) */
386
#define PCI_PM_STATE_D0		0		/* D0:	Operational (default) */
Lines 333-339 Link Here
333
/* VPD Region */
391
/* VPD Region */
334
/*	PCI_VPD_ADR_REG		16 bit	VPD Address Register */
392
/*	PCI_VPD_ADR_REG		16 bit	VPD Address Register */
335
#define PCI_VPD_FLAG	BIT_15S		/* starts VPD rd/wr cycle */
393
#define PCI_VPD_FLAG	BIT_15S		/* starts VPD rd/wr cycle */
336
#define PCI_VPD_ADR_MSK	0x7fffL		/* Bit 14.. 0:	VPD address mask */
394
#define PCI_VPD_ADR_MSK	0x7fffL		/* Bit 14.. 0:	VPD Address Mask */
395
396
/* PCI_OUR_STATUS		32 bit	Adapter Status Register (Yukon-2) */
397
#define PCI_OS_PCI64B	BIT_31		/* Conventional PCI 64 bits Bus */
398
#define PCI_OS_PCIX		BIT_30		/* PCI-X Bus */
399
#define PCI_OS_MODE_MSK	(3L<<28)	/* Bit 29..28:	PCI-X Bus Mode Mask */
400
#define PCI_OS_PCI66M	BIT_27		/* PCI 66 MHz Bus */
401
#define PCI_OS_PCI_X	BIT_26		/* PCI/PCI-X Bus (0 = PEX) */
402
#define PCI_OS_DLLE_MSK	(3L<<24)	/* Bit 25..24:	DLL Status Indication */
403
#define PCI_OS_DLLR_MSK	(0xfL<<20)	/* Bit 23..20:	DLL Row Counters Values */
404
#define PCI_OS_DLLC_MSK	(0xfL<<16)	/* Bit 19..16:	DLL Col. Counters Values */
405
								/* Bit 15.. 8:	reserved */
406
407
#define PCI_OS_SPEED(val)	((val & PCI_OS_MODE_MSK) >> 28)	/* PCI-X Speed */
408
/* possible values for the speed field of the register */
409
#define PCI_OS_SPD_PCI		0		/* PCI Conventional Bus */
410
#define PCI_OS_SPD_X66		1		/* PCI-X 66MHz Bus */
411
#define PCI_OS_SPD_X100		2		/* PCI-X 100MHz Bus */
412
#define PCI_OS_SPD_X133		3		/* PCI-X 133MHz Bus */
413
414
/* PEX_DEV_CTRL			16 bit	PEX Device Control (Yukon-2) */
415
								/* Bit 15	reserved */
416
#define PEX_DC_MAX_RRS_MSK	(7<<12)	/* Bit 14..12:	Max. Read Request Size */
417
#define PEX_DC_EN_NO_SNOOP	BIT_11S	/* Enable No Snoop */
418
#define PEX_DC_EN_AUX_POW	BIT_10S	/* Enable AUX Power */
419
#define PEX_DC_EN_PHANTOM	BIT_9S	/* Enable Phantom Functions */
420
#define PEX_DC_EN_EXT_TAG	BIT_8S	/* Enable Extended Tag Field */
421
#define PEX_DC_MAX_PLS_MSK	(7<<5)	/* Bit  7.. 5:	Max. Payload Size Mask */
422
#define PEX_DC_EN_REL_ORD	BIT_4S	/* Enable Relaxed Ordering */
423
#define PEX_DC_EN_UNS_RQ_RP	BIT_3S	/* Enable Unsupported Request Reporting */
424
#define PEX_DC_EN_FAT_ER_RP	BIT_2S	/* Enable Fatal Error Reporting */
425
#define PEX_DC_EN_NFA_ER_RP	BIT_1S	/* Enable Non-Fatal Error Reporting */
426
#define PEX_DC_EN_COR_ER_RP	BIT_0S	/* Enable Correctable Error Reporting */
427
428
#define PEX_DC_MAX_RD_RQ_SIZE(x)	(SHIFT12(x) & PEX_DC_MAX_RRS_MSK)
429
430
/* PEX_LNK_STAT			16 bit	PEX Link Status (Yukon-2) */
431
								/* Bit 15..13	reserved */
432
#define PEX_LS_SLOT_CLK_CFG	BIT_12S	/* Slot Clock Config */
433
#define PEX_LS_LINK_TRAIN	BIT_11S	/* Link Training */
434
#define PEX_LS_TRAIN_ERROR	BIT_10S	/* Training Error */
435
#define PEX_LS_LINK_WI_MSK	(0x3f<<4)	/* Bit  9.. 4:	Neg. Link Width Mask */
436
#define PEX_LS_LINK_SP_MSK	0x0f	/* Bit  3.. 0:	Link Speed Mask */
437
438
/* PEX_UNC_ERR_STAT	 PEX Uncorrectable Errors Status Register (Yukon-2) */
439
								/* Bit 31..21	reserved */
440
#define PEX_UNSUP_REQ 	BIT_20		/* Unsupported Request Error */
441
									/* ECRC Error (not supported) */
442
#define PEX_MALFOR_TLP	BIT_18		/* Malformed TLP */
443
									/* Receiver Overflow (not supported) */
444
#define PEX_UNEXP_COMP	BIT_16		/* Unexpected Completion */
445
									/* Completer Abort (not supported) */
446
#define PEX_COMP_TO		BIT_14		/* Completion Timeout */
447
#define PEX_FLOW_CTRL_P	BIT_13		/* Flow Control Protocol Error */
448
#define PEX_POIS_TLP	BIT_12		/* Poisoned TLP */
449
								/* Bit 11.. 5:	reserved */
450
#define PEX_DATA_LINK_P BIT_4		/* Data Link Protocol Error */
451
								/* Bit  3.. 1:	reserved */
452
									/* Training Error (not supported) */
453
454
#define PEX_FATAL_ERRORS	(PEX_MALFOR_TLP | PEX_FLOW_CTRL_P | PEX_DATA_LINK_P)
337
455
338
/*	Control Register File (Address Map) */
456
/*	Control Register File (Address Map) */
339
457
Lines 349-356 Link Here
349
#define B0_IMSK			0x000c	/* 32 bit	Interrupt Mask Register */
467
#define B0_IMSK			0x000c	/* 32 bit	Interrupt Mask Register */
350
#define B0_HWE_ISRC		0x0010	/* 32 bit	HW Error Interrupt Src Reg */
468
#define B0_HWE_ISRC		0x0010	/* 32 bit	HW Error Interrupt Src Reg */
351
#define B0_HWE_IMSK		0x0014	/* 32 bit	HW Error Interrupt Mask Reg */
469
#define B0_HWE_IMSK		0x0014	/* 32 bit	HW Error Interrupt Mask Reg */
352
#define B0_SP_ISRC		0x0018	/* 32 bit	Special Interrupt Source Reg */
470
#define B0_SP_ISRC		0x0018	/* 32 bit	Special Interrupt Source Reg 1 */
353
	/* 0x001c:		reserved */
471
472
/* Special ISR registers (Yukon-2 only) */
473
#define B0_Y2_SP_ISRC2	0x001c	/* 32 bit	Special Interrupt Source Reg 2 */
474
#define B0_Y2_SP_ISRC3	0x0020	/* 32 bit	Special Interrupt Source Reg 3 */
475
#define B0_Y2_SP_EISR	0x0024	/* 32 bit	Enter ISR Reg */
476
#define B0_Y2_SP_LISR	0x0028	/* 32 bit	Leave ISR Reg */
477
#define B0_Y2_SP_ICR	0x002c	/* 32 bit	Interrupt Control Reg */
354
478
355
/* B0 XMAC 1 registers (GENESIS only) */
479
/* B0 XMAC 1 registers (GENESIS only) */
356
#define B0_XM1_IMSK		0x0020	/* 16 bit r/w	XMAC 1 Interrupt Mask Register*/
480
#define B0_XM1_IMSK		0x0020	/* 16 bit r/w	XMAC 1 Interrupt Mask Register*/
Lines 400-413 Link Here
400
#define B2_CONN_TYP		0x0118	/*  8 bit	Connector type */
524
#define B2_CONN_TYP		0x0118	/*  8 bit	Connector type */
401
#define B2_PMD_TYP		0x0119	/*  8 bit	PMD type */
525
#define B2_PMD_TYP		0x0119	/*  8 bit	PMD type */
402
#define B2_MAC_CFG		0x011a	/*  8 bit	MAC Configuration / Chip Revision */
526
#define B2_MAC_CFG		0x011a	/*  8 bit	MAC Configuration / Chip Revision */
403
#define B2_CHIP_ID		0x011b	/*  8 bit 	Chip Identification Number */
527
#define B2_CHIP_ID		0x011b	/*  8 bit	Chip Identification Number */
404
	/* Eprom registers are currently of no use */
528
	/* Eprom registers */
405
#define B2_E_0			0x011c	/*  8 bit	EPROM Byte 0 (ext. SRAM size */
529
#define B2_E_0			0x011c	/*  8 bit	EPROM Byte 0 (ext. SRAM size */
530
/* Yukon and Genesis */
406
#define B2_E_1			0x011d	/*  8 bit	EPROM Byte 1 (PHY type) */
531
#define B2_E_1			0x011d	/*  8 bit	EPROM Byte 1 (PHY type) */
407
#define B2_E_2			0x011e	/*  8 bit	EPROM Byte 2 */
532
#define B2_E_2			0x011e	/*  8 bit	EPROM Byte 2 */
533
/* Yukon-2 */
534
#define B2_Y2_CLK_GATE	0x011d	/*  8 bit	Clock Gating (Yukon-2) */
535
#define B2_Y2_HW_RES	0x011e	/*  8 bit	HW Resources (Yukon-2) */
536
408
#define B2_E_3			0x011f	/*  8 bit	EPROM Byte 3 */
537
#define B2_E_3			0x011f	/*  8 bit	EPROM Byte 3 */
538
539
/* Yukon and Genesis */
409
#define B2_FAR			0x0120	/* 32 bit	Flash-Prom Addr Reg/Cnt */
540
#define B2_FAR			0x0120	/* 32 bit	Flash-Prom Addr Reg/Cnt */
410
#define B2_FDP			0x0124	/*  8 bit	Flash-Prom Data Port */
541
#define B2_FDP			0x0124	/*  8 bit	Flash-Prom Data Port */
542
/* Yukon-2 */
543
#define B2_Y2_CLK_CTRL	0x0120	/* 32 bit	Core Clock Frequency Control */
411
	/* 0x0125 - 0x0127:	reserved */
544
	/* 0x0125 - 0x0127:	reserved */
412
#define B2_LD_CTRL		0x0128	/*  8 bit	EPROM loader control register */
545
#define B2_LD_CTRL		0x0128	/*  8 bit	EPROM loader control register */
413
#define B2_LD_TEST		0x0129	/*  8 bit	EPROM loader test register */
546
#define B2_LD_TEST		0x0129	/*  8 bit	EPROM loader test register */
Lines 439-444 Link Here
439
#define B2_BSC_CTRL		0x0178	/*  8 bit	Blink Source Counter Control */
572
#define B2_BSC_CTRL		0x0178	/*  8 bit	Blink Source Counter Control */
440
#define B2_BSC_STAT		0x0179	/*  8 bit	Blink Source Counter Status */
573
#define B2_BSC_STAT		0x0179	/*  8 bit	Blink Source Counter Status */
441
#define B2_BSC_TST		0x017a	/* 16 bit	Blink Source Counter Test Reg */
574
#define B2_BSC_TST		0x017a	/* 16 bit	Blink Source Counter Test Reg */
575
576
/* Yukon-2 */
577
#define Y2_PEX_PHY_DATA	0x0170	/* 16 bit	PEX PHY Data Register */
578
#define Y2_PEX_PHY_ADDR	0x0172	/* 16 bit	PEX PHY Address Register */
442
	/* 0x017c - 0x017f:	reserved */
579
	/* 0x017c - 0x017f:	reserved */
443
580
444
/*
581
/*
Lines 448-456 Link Here
448
#define B3_RAM_ADDR		0x0180	/* 32 bit	RAM Address, to read or write */
585
#define B3_RAM_ADDR		0x0180	/* 32 bit	RAM Address, to read or write */
449
#define B3_RAM_DATA_LO	0x0184	/* 32 bit	RAM Data Word (low dWord) */
586
#define B3_RAM_DATA_LO	0x0184	/* 32 bit	RAM Data Word (low dWord) */
450
#define B3_RAM_DATA_HI	0x0188	/* 32 bit	RAM Data Word (high dWord) */
587
#define B3_RAM_DATA_HI	0x0188	/* 32 bit	RAM Data Word (high dWord) */
588
589
#define SELECT_RAM_BUFFER(rb, addr) (addr | (rb << 6))	/* Yukon-2 only */
590
451
	/* 0x018c - 0x018f:	reserved */
591
	/* 0x018c - 0x018f:	reserved */
452
592
453
/* RAM Interface Registers */
593
/* RAM Interface Registers */
594
/* Yukon-2: use SELECT_RAM_BUFFER() to access the RAM buffer */
454
/*
595
/*
455
 * The HW-Spec. calls this registers Timeout Value 0..11. But this names are
596
 * The HW-Spec. calls this registers Timeout Value 0..11. But this names are
456
 * not usable in SW. Please notice these are NOT real timeouts, these are
597
 * not usable in SW. Please notice these are NOT real timeouts, these are
Lines 517-524 Link Here
517
	/* 0x01ea - 0x01eb:	reserved */
658
	/* 0x01ea - 0x01eb:	reserved */
518
#define B3_PA_TOVAL_TX2	0x01ec	/* 16 bit	Timeout Val Tx Path MAC 2 */
659
#define B3_PA_TOVAL_TX2	0x01ec	/* 16 bit	Timeout Val Tx Path MAC 2 */
519
	/* 0x01ee - 0x01ef:	reserved */
660
	/* 0x01ee - 0x01ef:	reserved */
520
#define B3_PA_CTRL	0x01f0	/* 16 bit	Packet Arbiter Ctrl Register */
661
#define B3_PA_CTRL		0x01f0	/* 16 bit	Packet Arbiter Ctrl Register */
521
#define B3_PA_TEST	0x01f2	/* 16 bit	Packet Arbiter Test Register */
662
#define B3_PA_TEST		0x01f2	/* 16 bit	Packet Arbiter Test Register */
522
	/* 0x01f4 - 0x01ff:	reserved */
663
	/* 0x01f4 - 0x01ff:	reserved */
523
664
524
/*
665
/*
Lines 532-538 Link Here
532
#define TXA_CTRL		0x0210	/*  8 bit	Tx Arbiter Control Register */
673
#define TXA_CTRL		0x0210	/*  8 bit	Tx Arbiter Control Register */
533
#define TXA_TEST		0x0211	/*  8 bit	Tx Arbiter Test Register */
674
#define TXA_TEST		0x0211	/*  8 bit	Tx Arbiter Test Register */
534
#define TXA_STAT		0x0212	/*  8 bit	Tx Arbiter Status Register */
675
#define TXA_STAT		0x0212	/*  8 bit	Tx Arbiter Status Register */
535
	/* 0x0213 - 0x027f:	reserved */
676
	/* 0x0213 - 0x021f:	reserved */
677
678
	/* RSS key registers for Yukon-2 Family */
679
#define B4_RSS_KEY		0x0220	/* 4x32 bit RSS Key register (Yukon-2) */
680
	/* RSS key register offsets */
681
#define KEY_IDX_0		 0		/* offset for location of KEY 0 */
682
#define KEY_IDX_1		 4		/* offset for location of KEY 1 */
683
#define KEY_IDX_2		 8		/* offset for location of KEY 2 */
684
#define KEY_IDX_3		12		/* offset for location of KEY 3 */
685
536
	/* 0x0280 - 0x0292:	MAC 2 */
686
	/* 0x0280 - 0x0292:	MAC 2 */
537
	/* 0x0213 - 0x027f:	reserved */
687
	/* 0x0213 - 0x027f:	reserved */
538
688
Lines 570-577 Link Here
570
#define Q_T1_SV	0x3f	/*  8 bit	Test Register 1 Supervisor SM */
720
#define Q_T1_SV	0x3f	/*  8 bit	Test Register 1 Supervisor SM */
571
#define Q_T2	0x40	/* 32 bit	Test Register 2	*/
721
#define Q_T2	0x40	/* 32 bit	Test Register 2	*/
572
#define Q_T3	0x44	/* 32 bit	Test Register 3	*/
722
#define Q_T3	0x44	/* 32 bit	Test Register 3	*/
723
724
/* Yukon-2 */
725
#define Q_DONE	0x24	/* 16 bit	Done Index 		(Yukon-2 only) */
726
#define Q_WM	0x40	/* 16 bit	FIFO Watermark */
727
#define Q_AL	0x42	/*  8 bit	FIFO Alignment */
728
#define Q_RSP	0x44	/* 16 bit	FIFO Read Shadow Pointer */
729
#define Q_RSL	0x46	/*  8 bit	FIFO Read Shadow Level */
730
#define Q_RP	0x48	/*  8 bit	FIFO Read Pointer */
731
#define Q_RL	0x4a	/*  8 bit	FIFO Read Level */
732
#define Q_WP	0x4c	/*  8 bit	FIFO Write Pointer */
733
#define Q_WSP	0x4d	/*  8 bit	FIFO Write Shadow Pointer */
734
#define Q_WL	0x4e	/*  8 bit	FIFO Write Level */
735
#define Q_WSL	0x4f	/*  8 bit	FIFO Write Shadow Level */
573
	/* 0x48 - 0x7f:	reserved */
736
	/* 0x48 - 0x7f:	reserved */
574
737
738
/* Queue Prefetch Unit Offsets, use Y2_PREF_Q_ADDR() to address (Yukon-2 only)*/
739
#define Y2_B8_PREF_REGS			0x0450
740
741
#define PREF_UNIT_CTRL_REG		0x00	/* 32 bit	Prefetch Control register */
742
#define PREF_UNIT_LAST_IDX_REG	0x04	/* 16 bit	Last Index */
743
#define PREF_UNIT_ADDR_LOW_REG	0x08	/* 32 bit	List start addr, low part */
744
#define PREF_UNIT_ADDR_HI_REG	0x0c	/* 32 bit	List start addr, high part*/
745
#define PREF_UNIT_GET_IDX_REG	0x10	/* 16 bit	Get Index */
746
#define PREF_UNIT_PUT_IDX_REG	0x14	/* 16 bit	Put Index */
747
#define PREF_UNIT_FIFO_WP_REG	0x20	/*  8 bit	FIFO write pointer */
748
#define PREF_UNIT_FIFO_RP_REG	0x24	/*  8 bit	FIFO read pointer */
749
#define PREF_UNIT_FIFO_WM_REG	0x28	/*  8 bit	FIFO watermark */
750
#define PREF_UNIT_FIFO_LEV_REG	0x2c	/*  8 bit	FIFO level */
751
752
#define PREF_UNIT_MASK_IDX		0x0fff
753
575
/*
754
/*
576
 *	Bank 16 - 23
755
 *	Bank 16 - 23
577
 */
756
 */
Lines 583-599 Link Here
583
#define RB_END			0x04	/* 32 bit	RAM Buffer End Address */
762
#define RB_END			0x04	/* 32 bit	RAM Buffer End Address */
584
#define RB_WP			0x08	/* 32 bit	RAM Buffer Write Pointer */
763
#define RB_WP			0x08	/* 32 bit	RAM Buffer Write Pointer */
585
#define RB_RP			0x0c	/* 32 bit	RAM Buffer Read Pointer */
764
#define RB_RP			0x0c	/* 32 bit	RAM Buffer Read Pointer */
586
#define RB_RX_UTPP		0x10	/* 32 bit	Rx Upper Threshold, Pause Pack */
765
#define RB_RX_UTPP		0x10	/* 32 bit	Rx Upper Threshold, Pause Packet */
587
#define RB_RX_LTPP		0x14	/* 32 bit	Rx Lower Threshold, Pause Pack */
766
#define RB_RX_LTPP		0x14	/* 32 bit	Rx Lower Threshold, Pause Packet */
588
#define RB_RX_UTHP		0x18	/* 32 bit	Rx Upper Threshold, High Prio */
767
#define RB_RX_UTHP		0x18	/* 32 bit	Rx Upper Threshold, High Prio */
589
#define RB_RX_LTHP		0x1c	/* 32 bit	Rx Lower Threshold, High Prio */
768
#define RB_RX_LTHP		0x1c	/* 32 bit	Rx Lower Threshold, High Prio */
590
	/* 0x10 - 0x1f:	reserved at Tx RAM Buffer Registers */
769
	/* 0x10 - 0x1f:	reserved at Tx RAM Buffer Registers */
591
#define RB_PC			0x20	/* 32 bit	RAM Buffer Packet Counter */
770
#define RB_PC			0x20	/* 32 bit	RAM Buffer Packet Counter */
592
#define RB_LEV			0x24	/* 32 bit	RAM Buffer Level Register */
771
#define RB_LEV			0x24	/* 32 bit	RAM Buffer Level Register */
593
#define RB_CTRL			0x28	/*  8 bit	RAM Buffer Control Register */
772
#define RB_CTRL			0x28	/* 32 bit	RAM Buffer Control Register */
594
#define RB_TST1			0x29	/*  8 bit	RAM Buffer Test Register 1 */
773
#define RB_TST1			0x29	/*  8 bit	RAM Buffer Test Register 1 */
595
#define RB_TST2			0x2A	/*  8 bit	RAM Buffer Test Register 2 */
774
#define RB_TST2			0x2a	/*  8 bit	RAM Buffer Test Register 2 */
596
	/* 0x2c - 0x7f:	reserved */
775
	/* 0x2b - 0x7f:	reserved */
597
776
598
/*
777
/*
599
 *	Bank 24
778
 *	Bank 24
Lines 603-609 Link Here
603
 * use MR_ADDR() to access
782
 * use MR_ADDR() to access
604
 */
783
 */
605
#define RX_MFF_EA		0x0c00	/* 32 bit	Receive MAC FIFO End Address */
784
#define RX_MFF_EA		0x0c00	/* 32 bit	Receive MAC FIFO End Address */
606
#define RX_MFF_WP		0x0c04	/* 32 bit 	Receive MAC FIFO Write Pointer */
785
#define RX_MFF_WP		0x0c04	/* 32 bit	Receive MAC FIFO Write Pointer */
607
	/* 0x0c08 - 0x0c0b:	reserved */
786
	/* 0x0c08 - 0x0c0b:	reserved */
608
#define RX_MFF_RP		0x0c0c	/* 32 bit	Receive MAC FIFO Read Pointer */
787
#define RX_MFF_RP		0x0c0c	/* 32 bit	Receive MAC FIFO Read Pointer */
609
#define RX_MFF_PC		0x0c10	/* 32 bit	Receive MAC FIFO Packet Cnt */
788
#define RX_MFF_PC		0x0c10	/* 32 bit	Receive MAC FIFO Packet Cnt */
Lines 628-647 Link Here
628
#define LNK_LED_REG		0x0c3c	/*  8 bit	Link LED Register */
807
#define LNK_LED_REG		0x0c3c	/*  8 bit	Link LED Register */
629
	/* 0x0c3d - 0x0c3f:	reserved */
808
	/* 0x0c3d - 0x0c3f:	reserved */
630
809
631
/* Receive GMAC FIFO (YUKON only), use MR_ADDR() to access */
810
/* Receive GMAC FIFO (YUKON and Yukon-2), use MR_ADDR() to access */
632
#define RX_GMF_EA		0x0c40	/* 32 bit	Rx GMAC FIFO End Address */
811
#define RX_GMF_EA		0x0c40	/* 32 bit	Rx GMAC FIFO End Address */
633
#define RX_GMF_AF_THR	0x0c44	/* 32 bit	Rx GMAC FIFO Almost Full Thresh. */
812
#define RX_GMF_AF_THR	0x0c44	/* 32 bit	Rx GMAC FIFO Almost Full Thresh. */
634
#define RX_GMF_CTRL_T	0x0c48	/* 32 bit	Rx GMAC FIFO Control/Test */
813
#define RX_GMF_CTRL_T	0x0c48	/* 32 bit	Rx GMAC FIFO Control/Test */
635
#define RX_GMF_FL_MSK	0x0c4c	/* 32 bit	Rx GMAC FIFO Flush Mask */
814
#define RX_GMF_FL_MSK	0x0c4c	/* 32 bit	Rx GMAC FIFO Flush Mask */
636
#define RX_GMF_FL_THR	0x0c50	/* 32 bit	Rx GMAC FIFO Flush Threshold */
815
#define RX_GMF_FL_THR	0x0c50	/* 32 bit	Rx GMAC FIFO Flush Threshold */
637
	/* 0x0c54 - 0x0c5f:	reserved */
816
#define RX_GMF_TR_THR	0x0c54	/* 32 bit	Rx Truncation Threshold (Yukon-2) */
638
#define RX_GMF_WP		0x0c60	/* 32 bit 	Rx GMAC FIFO Write Pointer */
817
	/* 0x0c58 - 0x0c5b:	reserved */
818
#define RX_GMF_VLAN		0x0c5c	/* 32 bit	Rx VLAN Type Register (Yukon-2) */
819
#define RX_GMF_WP		0x0c60	/* 32 bit	Rx GMAC FIFO Write Pointer */
639
	/* 0x0c64 - 0x0c67:	reserved */
820
	/* 0x0c64 - 0x0c67:	reserved */
640
#define RX_GMF_WLEV		0x0c68	/* 32 bit 	Rx GMAC FIFO Write Level */
821
#define RX_GMF_WLEV		0x0c68	/* 32 bit	Rx GMAC FIFO Write Level */
641
	/* 0x0c6c - 0x0c6f:	reserved */
822
	/* 0x0c6c - 0x0c6f:	reserved */
642
#define RX_GMF_RP		0x0c70	/* 32 bit 	Rx GMAC FIFO Read Pointer */
823
#define RX_GMF_RP		0x0c70	/* 32 bit	Rx GMAC FIFO Read Pointer */
643
	/* 0x0c74 - 0x0c77:	reserved */
824
	/* 0x0c74 - 0x0c77:	reserved */
644
#define RX_GMF_RLEV		0x0c78	/* 32 bit 	Rx GMAC FIFO Read Level */
825
#define RX_GMF_RLEV		0x0c78	/* 32 bit	Rx GMAC FIFO Read Level */
645
	/* 0x0c7c - 0x0c7f:	reserved */
826
	/* 0x0c7c - 0x0c7f:	reserved */
646
827
647
/*
828
/*
Lines 658-664 Link Here
658
 * use MR_ADDR() to access
839
 * use MR_ADDR() to access
659
 */
840
 */
660
#define TX_MFF_EA		0x0d00	/* 32 bit	Transmit MAC FIFO End Address */
841
#define TX_MFF_EA		0x0d00	/* 32 bit	Transmit MAC FIFO End Address */
661
#define TX_MFF_WP		0x0d04	/* 32 bit 	Transmit MAC FIFO WR Pointer */
842
#define TX_MFF_WP		0x0d04	/* 32 bit	Transmit MAC FIFO WR Pointer */
662
#define TX_MFF_WSP		0x0d08	/* 32 bit	Transmit MAC FIFO WR Shadow Ptr */
843
#define TX_MFF_WSP		0x0d08	/* 32 bit	Transmit MAC FIFO WR Shadow Ptr */
663
#define TX_MFF_RP		0x0d0c	/* 32 bit	Transmit MAC FIFO RD Pointer */
844
#define TX_MFF_RP		0x0d0c	/* 32 bit	Transmit MAC FIFO RD Pointer */
664
#define TX_MFF_PC		0x0d10	/* 32 bit	Transmit MAC FIFO Packet Cnt */
845
#define TX_MFF_PC		0x0d10	/* 32 bit	Transmit MAC FIFO Packet Cnt */
Lines 676-693 Link Here
676
#define TX_LED_TST		0x0d29	/*  8 bit	Transmit LED Cnt Test Reg */
857
#define TX_LED_TST		0x0d29	/*  8 bit	Transmit LED Cnt Test Reg */
677
	/* 0x0d2a - 0x0d3f:	reserved */
858
	/* 0x0d2a - 0x0d3f:	reserved */
678
859
679
/* Transmit GMAC FIFO (YUKON only), use MR_ADDR() to access */
860
/* Transmit GMAC FIFO (YUKON and Yukon-2), use MR_ADDR() to access */
680
#define TX_GMF_EA		0x0d40	/* 32 bit	Tx GMAC FIFO End Address */
861
#define TX_GMF_EA		0x0d40	/* 32 bit	Tx GMAC FIFO End Address */
681
#define TX_GMF_AE_THR	0x0d44	/* 32 bit	Tx GMAC FIFO Almost Empty Thresh.*/
862
#define TX_GMF_AE_THR	0x0d44	/* 32 bit	Tx GMAC FIFO Almost Empty Thresh.*/
682
#define TX_GMF_CTRL_T	0x0d48	/* 32 bit	Tx GMAC FIFO Control/Test */
863
#define TX_GMF_CTRL_T	0x0d48	/* 32 bit	Tx GMAC FIFO Control/Test */
683
	/* 0x0d4c - 0x0d5f:	reserved */
864
	/* 0x0d4c - 0x0d5b:	reserved */
684
#define TX_GMF_WP		0x0d60	/* 32 bit 	Tx GMAC FIFO Write Pointer */
865
#define TX_GMF_VLAN		0x0d5c	/* 32 bit	Tx VLAN Type Register (Yukon-2) */
685
#define TX_GMF_WSP		0x0d64	/* 32 bit 	Tx GMAC FIFO Write Shadow Ptr. */
866
#define TX_GMF_WP		0x0d60	/* 32 bit	Tx GMAC FIFO Write Pointer */
686
#define TX_GMF_WLEV		0x0d68	/* 32 bit 	Tx GMAC FIFO Write Level */
867
#define TX_GMF_WSP		0x0d64	/* 32 bit	Tx GMAC FIFO Write Shadow Pointer */
868
#define TX_GMF_WLEV		0x0d68	/* 32 bit	Tx GMAC FIFO Write Level */
687
	/* 0x0d6c - 0x0d6f:	reserved */
869
	/* 0x0d6c - 0x0d6f:	reserved */
688
#define TX_GMF_RP		0x0d70	/* 32 bit 	Tx GMAC FIFO Read Pointer */
870
#define TX_GMF_RP		0x0d70	/* 32 bit	Tx GMAC FIFO Read Pointer */
689
#define TX_GMF_RSTP		0x0d74	/* 32 bit 	Tx GMAC FIFO Restart Pointer */
871
#define TX_GMF_RSTP		0x0d74	/* 32 bit	Tx GMAC FIFO Restart Pointer */
690
#define TX_GMF_RLEV		0x0d78	/* 32 bit 	Tx GMAC FIFO Read Level */
872
#define TX_GMF_RLEV		0x0d78	/* 32 bit	Tx GMAC FIFO Read Level */
691
	/* 0x0d7c - 0x0d7f:	reserved */
873
	/* 0x0d7c - 0x0d7f:	reserved */
692
874
693
/*
875
/*
Lines 713-724 Link Here
713
#define GMAC_TI_ST_CTRL	0x0e18	/*  8 bit	Time Stamp Timer Ctrl Reg */
895
#define GMAC_TI_ST_CTRL	0x0e18	/*  8 bit	Time Stamp Timer Ctrl Reg */
714
	/* 0x0e19:	reserved */
896
	/* 0x0e19:	reserved */
715
#define GMAC_TI_ST_TST	0x0e1a	/*  8 bit	Time Stamp Timer Test Reg */
897
#define GMAC_TI_ST_TST	0x0e1a	/*  8 bit	Time Stamp Timer Test Reg */
716
	/* 0x0e1b - 0x0e7f:	reserved */
898
	/* 0x0e1b - 0x0e1f:	reserved */
899
900
/* Polling Unit Registers (Yukon-2 only) */
901
#define POLL_CTRL			0x0e20	/* 32 bit	Polling Unit Control Reg */
902
#define POLL_LAST_IDX		0x0e24	/* 16 bit	Polling Unit List Last Index */
903
	/* 0x0e26 - 0x0e27:	reserved */
904
#define POLL_LIST_ADDR_LO	0x0e28	/* 32 bit	Poll. List Start Addr (low) */
905
#define POLL_LIST_ADDR_HI	0x0e2c	/* 32 bit	Poll. List Start Addr (high) */
906
	/* 0x0e30 - 0x0e3f:	reserved */
907
908
/* ASF Subsystem Registers (Yukon-2 only) */
909
#define B28_Y2_SMB_CONFIG	0x0e40	/* 32 bit	ASF SMBus Config Register */
910
#define B28_Y2_SMB_CSD_REG	0x0e44	/* 32 bit	ASF SMB Control/Status/Data */
911
	/* 0x0e48 - 0x0e5f: reserved */
912
#define B28_Y2_ASF_IRQ_V_BASE	0x0e60	/* 32 bit	ASF IRQ Vector Base */
913
	/* 0x0e64 - 0x0e67: reserved */
914
#define B28_Y2_ASF_STAT_CMD	0x0e68	/* 32 bit	ASF Status and Command Reg */
915
#define B28_Y2_ASF_HOST_COM	0x0e6c	/* 32 bit	ASF Host Communication Reg */
916
#define B28_Y2_DATA_REG_1	0x0e70	/* 32 bit	ASF/Host Data Register 1 */
917
#define B28_Y2_DATA_REG_2	0x0e74	/* 32 bit	ASF/Host Data Register 2 */
918
#define B28_Y2_DATA_REG_3	0x0e78	/* 32 bit	ASF/Host Data Register 3 */
919
#define B28_Y2_DATA_REG_4	0x0e7c	/* 32 bit	ASF/Host Data Register 4 */
717
920
718
/*
921
/*
719
 *	Bank 29
922
 *	Bank 29
720
 */
923
 */
721
	/* 0x0e80 - 0x0efc:	reserved */
924
925
/* Status BMU Registers (Yukon-2 only)*/
926
#define STAT_CTRL			0x0e80	/* 32 bit	Status BMU Control Reg */
927
#define STAT_LAST_IDX		0x0e84	/* 16 bit	Status BMU Last Index */
928
	/* 0x0e85 - 0x0e86:	reserved */
929
#define STAT_LIST_ADDR_LO	0x0e88	/* 32 bit	Status List Start Addr (low) */
930
#define STAT_LIST_ADDR_HI	0x0e8c	/* 32 bit	Status List Start Addr (high) */
931
#define STAT_TXA1_RIDX		0x0e90	/* 16 bit	Status TxA1 Report Index Reg */
932
#define STAT_TXS1_RIDX		0x0e92	/* 16 bit	Status TxS1 Report Index Reg */
933
#define STAT_TXA2_RIDX		0x0e94	/* 16 bit	Status TxA2 Report Index Reg */
934
#define STAT_TXS2_RIDX		0x0e96	/* 16 bit	Status TxS2 Report Index Reg */
935
#define STAT_TX_IDX_TH		0x0e98	/* 16 bit	Status Tx Index Threshold Reg */
936
	/* 0x0e9a - 0x0e9b:	reserved */
937
#define STAT_PUT_IDX		0x0e9c	/* 16 bit	Status Put Index Reg */
938
	/* 0x0e9e - 0x0e9f:	reserved */
939
940
/* FIFO Control/Status Registers (Yukon-2 only)*/
941
#define STAT_FIFO_WP		0x0ea0	/*  8 bit	Status FIFO Write Pointer Reg */
942
	/* 0x0ea1 - 0x0ea3:	reserved */
943
#define STAT_FIFO_RP		0x0ea4	/*  8 bit	Status FIFO Read Pointer Reg */
944
	/* 0x0ea5:	reserved */
945
#define STAT_FIFO_RSP		0x0ea6	/*  8 bit	Status FIFO Read Shadow Ptr */
946
	/* 0x0ea7:	reserved */
947
#define STAT_FIFO_LEVEL		0x0ea8	/*  8 bit	Status FIFO Level Reg */
948
	/* 0x0ea9:	reserved */
949
#define STAT_FIFO_SHLVL		0x0eaa	/*  8 bit	Status FIFO Shadow Level Reg */
950
	/* 0x0eab:	reserved */
951
#define STAT_FIFO_WM		0x0eac	/*  8 bit	Status FIFO Watermark Reg */
952
#define STAT_FIFO_ISR_WM	0x0ead	/*  8 bit	Status FIFO ISR Watermark Reg */
953
	/* 0x0eae - 0x0eaf:	reserved */
954
955
/* Level and ISR Timer Registers (Yukon-2 only)*/
956
#define STAT_LEV_TIMER_INI	0x0eb0	/* 32 bit	Level Timer Init. Value Reg */
957
#define STAT_LEV_TIMER_CNT	0x0eb4	/* 32 bit	Level Timer Counter Reg */
958
#define STAT_LEV_TIMER_CTRL	0x0eb8	/*  8 bit	Level Timer Control Reg */
959
#define STAT_LEV_TIMER_TEST	0x0eb9	/*  8 bit	Level Timer Test Reg */
960
	/* 0x0eba - 0x0ebf:	reserved */
961
#define STAT_TX_TIMER_INI	0x0ec0	/* 32 bit	Tx Timer Init. Value Reg */
962
#define STAT_TX_TIMER_CNT	0x0ec4	/* 32 bit	Tx Timer Counter Reg */
963
#define STAT_TX_TIMER_CTRL	0x0ec8	/*  8 bit	Tx Timer Control Reg */
964
#define STAT_TX_TIMER_TEST	0x0ec9	/*  8 bit	Tx Timer Test Reg */
965
	/* 0x0eca - 0x0ecf:	reserved */
966
#define STAT_ISR_TIMER_INI	0x0ed0	/* 32 bit	ISR Timer Init. Value Reg */
967
#define STAT_ISR_TIMER_CNT	0x0ed4	/* 32 bit	ISR Timer Counter Reg */
968
#define STAT_ISR_TIMER_CTRL	0x0ed8	/*  8 bit	ISR Timer Control Reg */
969
#define STAT_ISR_TIMER_TEST	0x0ed9	/*  8 bit	ISR Timer Test Reg */
970
	/* 0x0eda - 0x0eff:	reserved */
971
972
#define ST_LAST_IDX_MASK	0x007f	/* Last Index Mask */
973
#define ST_TXRP_IDX_MASK	0x0fff	/* Tx Report Index Mask */
974
#define ST_TXTH_IDX_MASK	0x0fff	/* Tx Threshold Index Mask */
975
#define ST_WM_IDX_MASK		0x3f	/* FIFO Watermark Index Mask */
722
976
723
/*
977
/*
724
 *	Bank 30
978
 *	Bank 30
Lines 742-752 Link Here
742
#define WOL_MATCH_RES	0x0f23	/*  8 bit	WOL Match Result Reg */
996
#define WOL_MATCH_RES	0x0f23	/*  8 bit	WOL Match Result Reg */
743
#define WOL_MAC_ADDR_LO	0x0f24	/* 32 bit	WOL MAC Address Low */
997
#define WOL_MAC_ADDR_LO	0x0f24	/* 32 bit	WOL MAC Address Low */
744
#define WOL_MAC_ADDR_HI	0x0f28	/* 16 bit	WOL MAC Address High */
998
#define WOL_MAC_ADDR_HI	0x0f28	/* 16 bit	WOL MAC Address High */
745
#define WOL_PATT_RPTR	0x0f2c	/*  8 bit	WOL Pattern Read Ptr */
999
#define WOL_PATT_PME	0x0f2a	/*  8 bit	WOL PME Match Enable (Yukon-2) */
746
1000
#define WOL_PATT_ASFM	0x0f2b	/*  8 bit	WOL ASF Match Enable (Yukon-2) */
747
/* use this macro to access above registers */
1001
#define WOL_PATT_RPTR	0x0f2c	/*  8 bit	WOL Pattern Read Pointer */
748
#define WOL_REG(Reg)	((Reg) + (pAC->GIni.GIWolOffs))
749
750
1002
751
/* WOL Pattern Length Registers (YUKON only) */
1003
/* WOL Pattern Length Registers (YUKON only) */
752
1004
Lines 764-774 Link Here
764
 */
1016
 */
765
/* 0x0f80 - 0x0fff:	reserved */
1017
/* 0x0f80 - 0x0fff:	reserved */
766
1018
1019
/* WOL registers link 2 */
1020
1021
/* use this macro to access WOL registers */
1022
#define WOL_REG(Port, Reg)	((Reg) + ((Port)*0x80) + (pAC->GIni.GIWolOffs))
1023
767
/*
1024
/*
768
 *	Bank 32	- 33
1025
 *	Bank 32	- 33
769
 */
1026
 */
770
#define WOL_PATT_RAM_1	0x1000	/*  WOL Pattern RAM Link 1 */
1027
#define WOL_PATT_RAM_1	0x1000	/*  WOL Pattern RAM Link 1 */
1028
#define WOL_PATT_RAM_2	0x1400	/*  WOL Pattern RAM Link 2 */
771
1029
1030
/* use this macro to retrieve the pattern ram base address */
1031
#define WOL_PATT_RAM_BASE(Port) (WOL_PATT_RAM_1 + (Port)*0x400)
1032
1033
/* offset to configuration space on Yukon-2 */
1034
#define Y2_CFG_SPC 		0x1c00
772
/*
1035
/*
773
 *	Bank 0x22 - 0x3f
1036
 *	Bank 0x22 - 0x3f
774
 */
1037
 */
Lines 800-812 Link Here
800
 */
1063
 */
801
/*	B0_RAP		8 bit	Register Address Port */
1064
/*	B0_RAP		8 bit	Register Address Port */
802
								/* Bit 7:	reserved */
1065
								/* Bit 7:	reserved */
803
#define RAP_RAP			0x3f	/* Bit 6..0:	0 = block 0,..,6f = block 6f */
1066
#define RAP_MSK			0x7f	/* Bit 6..0:	0 = block 0,..,6f = block 6f */
1067
1068
/*	B0_CTST			24 bit	Control/Status register */
1069
								/* Bit 23..18:	reserved */
1070
#define Y2_VMAIN_AVAIL	BIT_17		/* VMAIN available (YUKON-2 only) */
1071
#define Y2_VAUX_AVAIL	BIT_16		/* VAUX available (YUKON-2 only) */
1072
								/* Bit 15..14:	reserved */
1073
#define Y2_ASF_ENABLE	BIT_13S		/* ASF Unit Enable (YUKON-2 only) */
1074
#define Y2_ASF_DISABLE	BIT_12S		/* ASF Unit Disable (YUKON-2 only) */
1075
#define Y2_CLK_RUN_ENA	BIT_11S		/* CLK_RUN Enable  (YUKON-2 only) */
1076
#define Y2_CLK_RUN_DIS	BIT_10S		/* CLK_RUN Disable (YUKON-2 only) */
1077
#define Y2_LED_STAT_ON	BIT_9S		/* Status LED On  (YUKON-2 only) */
1078
#define Y2_LED_STAT_OFF	BIT_8S		/* Status LED Off (YUKON-2 only) */
1079
								/* Bit  7.. 0:	same as below */
804
1080
805
/*	B0_CTST			16 bit	Control/Status register */
1081
/*	B0_CTST			16 bit	Control/Status register */
806
								/* Bit 15..14:	reserved */
1082
								/* Bit 15..14:	reserved */
807
#define CS_CLK_RUN_HOT	BIT_13S		/* CLK_RUN hot m. (YUKON-Lite only) */
1083
#define CS_CLK_RUN_HOT	BIT_13S		/* CLK_RUN Hot m. (YUKON-Lite only) */
808
#define CS_CLK_RUN_RST	BIT_12S		/* CLK_RUN reset  (YUKON-Lite only) */
1084
#define CS_CLK_RUN_RST	BIT_12S		/* CLK_RUN Reset  (YUKON-Lite only) */
809
#define CS_CLK_RUN_ENA	BIT_11S		/* CLK_RUN enable (YUKON-Lite only) */
1085
#define CS_CLK_RUN_ENA	BIT_11S		/* CLK_RUN Enable (YUKON-Lite only) */
810
#define CS_VAUX_AVAIL	BIT_10S		/* VAUX available (YUKON only) */
1086
#define CS_VAUX_AVAIL	BIT_10S		/* VAUX available (YUKON only) */
811
#define CS_BUS_CLOCK	BIT_9S		/* Bus Clock 0/1 = 33/66 MHz */
1087
#define CS_BUS_CLOCK	BIT_9S		/* Bus Clock 0/1 = 33/66 MHz */
812
#define CS_BUS_SLOT_SZ	BIT_8S		/* Slot Size 0/1 = 32/64 bit slot */
1088
#define CS_BUS_SLOT_SZ	BIT_8S		/* Slot Size 0/1 = 32/64 bit slot */
Lines 814-839 Link Here
814
#define CS_CL_SW_IRQ	BIT_6S		/* Clear IRQ SW Request */
1090
#define CS_CL_SW_IRQ	BIT_6S		/* Clear IRQ SW Request */
815
#define CS_STOP_DONE	BIT_5S		/* Stop Master is finished */
1091
#define CS_STOP_DONE	BIT_5S		/* Stop Master is finished */
816
#define CS_STOP_MAST	BIT_4S		/* Command Bit to stop the master */
1092
#define CS_STOP_MAST	BIT_4S		/* Command Bit to stop the master */
817
#define CS_MRST_CLR		BIT_3S		/* Clear Master reset	*/
1093
#define CS_MRST_CLR		BIT_3S		/* Clear Master Reset */
818
#define CS_MRST_SET		BIT_2S		/* Set Master reset	*/
1094
#define CS_MRST_SET		BIT_2S		/* Set   Master Reset */
819
#define CS_RST_CLR		BIT_1S		/* Clear Software reset	*/
1095
#define CS_RST_CLR		BIT_1S		/* Clear Software Reset	*/
820
#define CS_RST_SET		BIT_0S		/* Set   Software reset	*/
1096
#define CS_RST_SET		BIT_0S		/* Set   Software Reset	*/
821
1097
822
/*	B0_LED			 8 Bit	LED register */
1098
/*	B0_LED			 8 Bit	LED register (GENESIS only)*/
823
								/* Bit  7.. 2:	reserved */
1099
								/* Bit  7.. 2:	reserved */
824
#define LED_STAT_ON		BIT_1S		/* Status LED on	*/
1100
#define LED_STAT_ON		BIT_1S		/* Status LED On	*/
825
#define LED_STAT_OFF	BIT_0S		/* Status LED off	*/
1101
#define LED_STAT_OFF	BIT_0S		/* Status LED Off	*/
826
1102
827
/*	B0_POWER_CTRL	 8 Bit	Power Control reg (YUKON only) */
1103
/*	B0_POWER_CTRL	 8 Bit	Power Control reg (YUKON only) */
828
#define PC_VAUX_ENA		BIT_7		/* Switch VAUX Enable  */
1104
#define PC_VAUX_ENA		BIT_7		/* Switch VAUX Enable  */
829
#define PC_VAUX_DIS		BIT_6       /* Switch VAUX Disable */
1105
#define PC_VAUX_DIS		BIT_6		/* Switch VAUX Disable */
830
#define PC_VCC_ENA		BIT_5       /* Switch VCC Enable  */
1106
#define PC_VCC_ENA		BIT_5		/* Switch VCC Enable  */
831
#define PC_VCC_DIS		BIT_4       /* Switch VCC Disable */
1107
#define PC_VCC_DIS		BIT_4		/* Switch VCC Disable */
832
#define PC_VAUX_ON		BIT_3       /* Switch VAUX On  */
1108
#define PC_VAUX_ON		BIT_3		/* Switch VAUX On  */
833
#define PC_VAUX_OFF		BIT_2       /* Switch VAUX Off */
1109
#define PC_VAUX_OFF		BIT_2		/* Switch VAUX Off */
834
#define PC_VCC_ON		BIT_1       /* Switch VCC On  */
1110
#define PC_VCC_ON		BIT_1		/* Switch VCC On  */
835
#define PC_VCC_OFF		BIT_0       /* Switch VCC Off */
1111
#define PC_VCC_OFF		BIT_0		/* Switch VCC Off */
836
1112
1113
/* Yukon and Genesis */
837
/*	B0_ISRC			32 bit	Interrupt Source Register */
1114
/*	B0_ISRC			32 bit	Interrupt Source Register */
838
/*	B0_IMSK			32 bit	Interrupt Mask Register */
1115
/*	B0_IMSK			32 bit	Interrupt Mask Register */
839
/*	B0_SP_ISRC		32 bit	Special Interrupt Source Reg */
1116
/*	B0_SP_ISRC		32 bit	Special Interrupt Source Reg */
Lines 879-890 Link Here
879
#define IS_XA2_F		BIT_1		/* Q_XA2 End of Frame */
1156
#define IS_XA2_F		BIT_1		/* Q_XA2 End of Frame */
880
#define IS_XA2_C		BIT_0		/* Q_XA2 Encoding Error */
1157
#define IS_XA2_C		BIT_0		/* Q_XA2 Encoding Error */
881
1158
1159
/*						(Yukon-2)			*/
1160
/*	B0_ISRC			32 bit	Interrupt Source Register */
1161
/*	B0_IMSK			32 bit	Interrupt Mask Register */
1162
/*	B0_SP_ISRC		32 bit	Special Interrupt Source Reg */
1163
/*	B2_IRQM_MSK		32 bit	IRQ Moderation Mask */
1164
/*	B0_Y2_SP_ISRC2	32 bit	Special Interrupt Source Reg 2 */
1165
/*	B0_Y2_SP_ISRC3	32 bit	Special Interrupt Source Reg 3 */
1166
/*	B0_Y2_SP_EISR	32 bit	Enter ISR Reg */
1167
/*	B0_Y2_SP_LISR	32 bit	Leave ISR Reg */
1168
#define Y2_IS_PORT_MASK(Port, Mask)	((Mask) << (Port*8))
1169
#define Y2_IS_HW_ERR	BIT_31		/* Interrupt HW Error */
1170
#define Y2_IS_STAT_BMU	BIT_30		/* Status BMU Interrupt */
1171
#define Y2_IS_ASF		BIT_29		/* ASF subsystem Interrupt */
1172
							/* Bit 28: reserved */
1173
#define Y2_IS_POLL_CHK	BIT_27		/* Check IRQ from polling unit */
1174
#define Y2_IS_TWSI_RDY	BIT_26		/* IRQ on end of TWSI Tx */
1175
#define Y2_IS_IRQ_SW	BIT_25		/* SW forced IRQ	*/
1176
#define Y2_IS_TIMINT	BIT_24		/* IRQ from Timer	*/
1177
							/* Bit 23..16 reserved */
1178
						/* Link 2 Interrupts */
1179
#define Y2_IS_IRQ_PHY2	BIT_12		/* Interrupt from PHY 2 */
1180
#define Y2_IS_IRQ_MAC2	BIT_11		/* Interrupt from MAC 2 */
1181
#define Y2_IS_CHK_RX2	BIT_10		/* Descriptor error Rx 2 */
1182
#define Y2_IS_CHK_TXS2	BIT_9		/* Descriptor error TXS 2 */
1183
#define Y2_IS_CHK_TXA2	BIT_8		/* Descriptor error TXA 2 */
1184
							/* Bit  7.. 5 reserved */
1185
						/* Link 1 interrupts */
1186
#define Y2_IS_IRQ_PHY1	BIT_4		/* Interrupt from PHY 1 */
1187
#define Y2_IS_IRQ_MAC1	BIT_3		/* Interrupt from MAC 1 */
1188
#define Y2_IS_CHK_RX1	BIT_2		/* Descriptor error Rx 1 */
1189
#define Y2_IS_CHK_TXS1	BIT_1		/* Descriptor error TXS 1 */
1190
#define Y2_IS_CHK_TXA1	BIT_0		/* Descriptor error TXA 1 */
1191
1192
#define Y2_IS_L1_MASK	0x0000001fUL	/* IRQ Mask for port 1 */	
882
1193
1194
#define Y2_IS_L2_MASK	0x00001f00UL	/* IRQ Mask for port 2 */	
1195
1196
#define Y2_IS_ALL_MSK	0xef001f1fUL	/* All Interrupt bits */
1197
1198
/* Yukon and Genesis */
883
/*	B0_HWE_ISRC		32 bit	HW Error Interrupt Src Reg */
1199
/*	B0_HWE_ISRC		32 bit	HW Error Interrupt Src Reg */
884
/*	B0_HWE_IMSK		32 bit	HW Error Interrupt Mask Reg */
1200
/*	B0_HWE_IMSK		32 bit	HW Error Interrupt Mask Reg */
885
/*	B2_IRQM_HWE_MSK	32 bit	IRQ Moderation HW Error Mask */
1201
/*	B2_IRQM_HWE_MSK	32 bit	IRQ Moderation HW Error Mask */
886
#define IS_ERR_MSK		0x00000fffL	/* 		All Error bits */
1202
#define IS_ERR_MSK		0x00000fffL	/* 		All Error bits */
887
								/* Bit 31..14:	reserved */
1203
							/* Bit 31..14:	reserved */
888
#define IS_IRQ_TIST_OV	BIT_13	/* Time Stamp Timer Overflow (YUKON only) */
1204
#define IS_IRQ_TIST_OV	BIT_13	/* Time Stamp Timer Overflow (YUKON only) */
889
#define IS_IRQ_SENSOR	BIT_12	/* IRQ from Sensor (YUKON only) */
1205
#define IS_IRQ_SENSOR	BIT_12	/* IRQ from Sensor (YUKON only) */
890
#define IS_IRQ_MST_ERR	BIT_11	/* IRQ master error detected */
1206
#define IS_IRQ_MST_ERR	BIT_11	/* IRQ master error detected */
Lines 900-905 Link Here
900
#define IS_R1_PAR_ERR	BIT_1	/* Queue R1 Parity Error */
1216
#define IS_R1_PAR_ERR	BIT_1	/* Queue R1 Parity Error */
901
#define IS_R2_PAR_ERR	BIT_0	/* Queue R2 Parity Error */
1217
#define IS_R2_PAR_ERR	BIT_0	/* Queue R2 Parity Error */
902
1218
1219
						/* Yukon-2 */
1220
/*	B0_HWE_ISRC		32 bit	HW Error Interrupt Src Reg */
1221
/*	B0_HWE_IMSK		32 bit	HW Error Interrupt Mask Reg */
1222
/*	B2_IRQM_HWE_MSK	32 bit	IRQ Moderation HW Error Mask */
1223
						/* Bit: 31..30 reserved */
1224
#define Y2_IS_TIST_OV	BIT_29	/* Time Stamp Timer overflow interrupt */
1225
#define Y2_IS_SENSOR	BIT_28	/* Sensor interrupt */
1226
#define Y2_IS_MST_ERR	BIT_27	/* Master error interrupt */
1227
#define Y2_IS_IRQ_STAT	BIT_26	/* Status exception interrupt */
1228
#define Y2_IS_PCI_EXP	BIT_25	/* PCI-Express interrupt */
1229
#define Y2_IS_PCI_NEXP	BIT_24	/* PCI-Express error similar to PCI error */
1230
						/* Bit: 23..14 reserved */
1231
						/* Link 2 */
1232
#define Y2_IS_PAR_RD2	BIT_13	/* Read RAM parity error interrupt */
1233
#define Y2_IS_PAR_WR2	BIT_12	/* Write RAM parity error interrupt */
1234
#define Y2_IS_PAR_MAC2	BIT_11	/* MAC hardware fault interrupt */
1235
#define Y2_IS_PAR_RX2	BIT_10	/* Parity Error Rx Queue 2 */
1236
#define Y2_IS_TCP_TXS2	BIT_9	/* TCP length mismatch sync Tx queue IRQ */
1237
#define Y2_IS_TCP_TXA2	BIT_8	/* TCP length mismatch async Tx queue IRQ */
1238
						/* Bit:  9.. 6 reserved */
1239
						/* Link 1 */
1240
#define Y2_IS_PAR_RD1	BIT_5	/* Read RAM parity error interrupt */
1241
#define Y2_IS_PAR_WR1	BIT_4	/* Write RAM parity error interrupt */
1242
#define Y2_IS_PAR_MAC1	BIT_3	/* MAC hardware fault interrupt */
1243
#define Y2_IS_PAR_RX1	BIT_2	/* Parity Error Rx Queue 1 */
1244
#define Y2_IS_TCP_TXS1	BIT_1	/* TCP length mismatch sync Tx queue IRQ */
1245
#define Y2_IS_TCP_TXA1	BIT_0	/* TCP length mismatch async Tx queue IRQ */
1246
1247
#define Y2_HWE_L1_MASK	(Y2_IS_PAR_RD1 | Y2_IS_PAR_WR1 | Y2_IS_PAR_MAC1 |\
1248
						 Y2_IS_PAR_RX1 | Y2_IS_TCP_TXS1| Y2_IS_TCP_TXA1)
1249
#define Y2_HWE_L2_MASK	(Y2_IS_PAR_RD2 | Y2_IS_PAR_WR2 | Y2_IS_PAR_MAC2 |\
1250
						 Y2_IS_PAR_RX2 | Y2_IS_TCP_TXS2| Y2_IS_TCP_TXA2)
1251
1252
#define Y2_HWE_ALL_MSK	(Y2_IS_TIST_OV | /* Y2_IS_SENSOR | */ Y2_IS_MST_ERR |\
1253
						 Y2_IS_IRQ_STAT | Y2_IS_PCI_EXP | Y2_IS_PCI_NEXP |\
1254
						 Y2_HWE_L1_MASK | Y2_HWE_L2_MASK)
1255
903
/*	B2_CONN_TYP		 8 bit	Connector type */
1256
/*	B2_CONN_TYP		 8 bit	Connector type */
904
/*	B2_PMD_TYP		 8 bit	PMD type */
1257
/*	B2_PMD_TYP		 8 bit	PMD type */
905
/*	Values of connector and PMD type comply to SysKonnect internal std */
1258
/*	Values of connector and PMD type comply to SysKonnect internal std */
Lines 908-926 Link Here
908
#define CFG_CHIP_R_MSK	(0xf<<4)	/* Bit 7.. 4: Chip Revision */
1261
#define CFG_CHIP_R_MSK	(0xf<<4)	/* Bit 7.. 4: Chip Revision */
909
									/* Bit 3.. 2:	reserved */
1262
									/* Bit 3.. 2:	reserved */
910
#define CFG_DIS_M2_CLK	BIT_1S		/* Disable Clock for 2nd MAC */
1263
#define CFG_DIS_M2_CLK	BIT_1S		/* Disable Clock for 2nd MAC */
911
#define CFG_SNG_MAC		BIT_0S		/* MAC Config: 0=2 MACs / 1=1 MAC*/
1264
#define CFG_SNG_MAC		BIT_0S		/* MAC Config: 0 = 2 MACs; 1 = 1 MAC */
912
1265
913
/*	B2_CHIP_ID		 8 bit 	Chip Identification Number */
1266
/*	B2_CHIP_ID		 8 bit	Chip Identification Number */
914
#define CHIP_ID_GENESIS		0x0a	/* Chip ID for GENESIS */
1267
#define CHIP_ID_GENESIS		0x0a	/* Chip ID for GENESIS */
915
#define CHIP_ID_YUKON		0xb0	/* Chip ID for YUKON */
1268
#define CHIP_ID_YUKON		0xb0	/* Chip ID for YUKON */
916
#define CHIP_ID_YUKON_LITE	0xb1	/* Chip ID for YUKON-Lite (Rev. A1-A3) */
1269
#define CHIP_ID_YUKON_LITE	0xb1	/* Chip ID for YUKON-Lite (Rev. A1-A3) */
917
#define CHIP_ID_YUKON_LP	0xb2	/* Chip ID for YUKON-LP */
1270
#define CHIP_ID_YUKON_LP	0xb2	/* Chip ID for YUKON-LP */
1271
#define CHIP_ID_YUKON_XL	0xb3	/* Chip ID for YUKON-2 XL */
1272
#define CHIP_ID_YUKON_EC	0xb6	/* Chip ID for YUKON-2 EC */
1273
#define CHIP_ID_YUKON_FE	0xb7	/* Chip ID for YUKON-2 FE */
918
1274
919
#define CHIP_REV_YU_LITE_A1	3		/* Chip Rev. for YUKON-Lite A1,A2 */
1275
#define CHIP_REV_YU_LITE_A1	3		/* Chip Rev. for YUKON-Lite A1,A2 */
920
#define CHIP_REV_YU_LITE_A3	7		/* Chip Rev. for YUKON-Lite A3 */
1276
#define CHIP_REV_YU_LITE_A3	7		/* Chip Rev. for YUKON-Lite A3 */
921
1277
1278
#define CHIP_REV_YU_EC_A1	0		/* Chip Rev. for Yukon-EC A1/A0 */
1279
#define CHIP_REV_YU_EC_A2	1		/* Chip Rev. for Yukon-EC A2 */
1280
#define CHIP_REV_YU_EC_A3	2		/* Chip Rev. for Yukon-EC A3 */
1281
1282
/*	B2_Y2_CLK_GATE	 8 bit	Clock Gating (Yukon-2 only) */
1283
#define Y2_STATUS_LNK2_INAC	BIT_7S	/* Status Link 2 inactiv (0 = activ) */
1284
#define Y2_CLK_GAT_LNK2_DIS	BIT_6S	/* Disable clock gating Link 2 */
1285
#define Y2_COR_CLK_LNK2_DIS	BIT_5S	/* Disable Core clock Link 2 */
1286
#define Y2_PCI_CLK_LNK2_DIS	BIT_4S	/* Disable PCI clock Link 2 */
1287
#define Y2_STATUS_LNK1_INAC	BIT_3S	/* Status Link 1 inactiv (0 = activ) */
1288
#define Y2_CLK_GAT_LNK1_DIS	BIT_2S	/* Disable clock gating Link 1 */
1289
#define Y2_COR_CLK_LNK1_DIS	BIT_1S	/* Disable Core clock Link 1 */
1290
#define Y2_PCI_CLK_LNK1_DIS	BIT_0S	/* Disable PCI clock Link 1 */
1291
1292
/*	B2_Y2_HW_RES	8 bit	HW Resources (Yukon-2 only) */
1293
								/* Bit 7.. 5:	reserved */
1294
#define CFG_LED_MODE_MSK	(7<<2)	/* Bit  4.. 2:	LED Mode Mask */
1295
#define CFG_LINK_2_AVAIL	BIT_1S	/* Link 2 available */
1296
#define CFG_LINK_1_AVAIL	BIT_0S	/* Link 1 available */
1297
1298
#define CFG_LED_MODE(x)		(((x) & CFG_LED_MODE_MSK) >> 2)
1299
#define CFG_DUAL_MAC_MSK	(CFG_LINK_2_AVAIL | CFG_LINK_1_AVAIL)
1300
1301
#define CFG_LED_SING_ACT_LNK	0	/* Single LED ACT/LNK mode */
1302
#define CFG_LED_DUAL_ACT_LNK	1	/* Dual   LED ACT/LNK mode */
1303
1304
/*	B2_E_3			 8 bit	lower 4 bits used for HW self test result */
1305
#define B2_E3_RES_MASK	0x0f
1306
922
/*	B2_FAR			32 bit	Flash-Prom Addr Reg/Cnt */
1307
/*	B2_FAR			32 bit	Flash-Prom Addr Reg/Cnt */
923
#define FAR_ADDR		0x1ffffL	/* Bit 16.. 0:	FPROM Address mask */
1308
#define FAR_ADDR		0x1ffffL	/* Bit 16.. 0:	FPROM Address Mask */
1309
1310
/*	B2_Y2_CLK_CTRL	32 bit	Core Clock Frequency Control Register (Yukon-2/EC) */
1311
								/* Bit 31..24:	reserved */
1312
/* Yukon-EC/FE */
1313
#define Y2_CLK_DIV_VAL_MSK	(0xffL<<16)	/* Bit 23..16:	Clock Divisor Value */
1314
#define Y2_CLK_DIV_VAL(x)	(SHIFT16(x) & Y2_CLK_DIV_VAL_MSK)
1315
/* Yukon-2 */
1316
#define Y2_CLK_DIV_VAL2_MSK	(7L<<21)	/* Bit 23..21:	Clock Divisor Value */
1317
#define Y2_CLK_SELECT2_MSK	(0x1fL<<16)	/* Bit 20..16:	Clock Select */
1318
#define Y2_CLK_DIV_VAL_2(x)	(SHIFT21(x) & Y2_CLK_DIV_VAL2_MSK)
1319
#define Y2_CLK_SEL_VAL_2(x)	(SHIFT16(x) & Y2_CLK_SELECT2_MSK)
1320
								/* Bit 15.. 2:	reserved */
1321
#define Y2_CLK_DIV_ENA		BIT_1S	/* Enable  Core Clock Division */
1322
#define Y2_CLK_DIV_DIS		BIT_0S	/* Disable Core Clock Division */
924
1323
925
/*	B2_LD_CTRL		 8 bit	EPROM loader control register */
1324
/*	B2_LD_CTRL		 8 bit	EPROM loader control register */
926
/*	Bits are currently reserved */
1325
/*	Bits are currently reserved */
Lines 960-968 Link Here
960
#define DPT_START		BIT_1S	/* Start Descriptor Poll Timer */
1359
#define DPT_START		BIT_1S	/* Start Descriptor Poll Timer */
961
#define DPT_STOP		BIT_0S	/* Stop  Descriptor Poll Timer */
1360
#define DPT_STOP		BIT_0S	/* Stop  Descriptor Poll Timer */
962
1361
963
/*	B2_E_3			 8 bit 	lower 4 bits used for HW self test result */
964
#define B2_E3_RES_MASK	0x0f
965
966
/*	B2_TST_CTRL1	 8 bit	Test Control Register 1 */
1362
/*	B2_TST_CTRL1	 8 bit	Test Control Register 1 */
967
#define TST_FRC_DPERR_MR	BIT_7S	/* force DATAPERR on MST RD */
1363
#define TST_FRC_DPERR_MR	BIT_7S	/* force DATAPERR on MST RD */
968
#define TST_FRC_DPERR_MW	BIT_6S	/* force DATAPERR on MST WR */
1364
#define TST_FRC_DPERR_MW	BIT_6S	/* force DATAPERR on MST WR */
Lines 982-988 Link Here
982
#define TST_FRC_APERR_2M64	BIT_0S	/* AddrPERR on 2. phase */
1378
#define TST_FRC_APERR_2M64	BIT_0S	/* AddrPERR on 2. phase */
983
1379
984
/*	B2_GP_IO		32 bit	General Purpose I/O Register */
1380
/*	B2_GP_IO		32 bit	General Purpose I/O Register */
985
							/* Bit 31..26:	reserved */
1381
						/* Bit 31..26:	reserved */
986
#define GP_DIR_9	BIT_25	/* IO_9 direct, 0=In/1=Out */
1382
#define GP_DIR_9	BIT_25	/* IO_9 direct, 0=In/1=Out */
987
#define GP_DIR_8	BIT_24	/* IO_8 direct, 0=In/1=Out */
1383
#define GP_DIR_8	BIT_24	/* IO_8 direct, 0=In/1=Out */
988
#define GP_DIR_7	BIT_23	/* IO_7 direct, 0=In/1=Out */
1384
#define GP_DIR_7	BIT_23	/* IO_7 direct, 0=In/1=Out */
Lines 1032-1041 Link Here
1032
#define I2C_DATA		BIT_1S		/* I2C Data Port	*/
1428
#define I2C_DATA		BIT_1S		/* I2C Data Port	*/
1033
#define I2C_CLK			BIT_0S		/* I2C Clock Port	*/
1429
#define I2C_CLK			BIT_0S		/* I2C Clock Port	*/
1034
1430
1035
/*
1431
/* I2C Address */
1036
 * I2C Address
1432
#define I2C_SENS_ADDR	LM80_ADDR	/* I2C Sensor Address (Volt and Temp) */
1037
 */
1038
#define I2C_SENS_ADDR	LM80_ADDR	/* I2C Sensor Address, (Volt and Temp)*/
1039
1433
1040
1434
1041
/*	B2_BSC_CTRL		 8 bit	Blink Source Counter Control */
1435
/*	B2_BSC_CTRL		 8 bit	Blink Source Counter Control */
Lines 1052-1067 Link Here
1052
#define BSC_T_OFF	BIT_1S		/* Test mode off */
1446
#define BSC_T_OFF	BIT_1S		/* Test mode off */
1053
#define BSC_T_STEP	BIT_0S		/* Test step */
1447
#define BSC_T_STEP	BIT_0S		/* Test step */
1054
1448
1449
/*	Y2_PEX_PHY_ADDR/DATA		PEX PHY address and data reg  (Yukon-2 only) */
1450
#define PEX_RD_ACCESS	BIT_31	/* Access Mode Read = 1, Write = 0 */
1451
#define PEX_DB_ACCESS	BIT_30	/* Access to debug register */
1452
1055
1453
1056
/*	B3_RAM_ADDR		32 bit	RAM Address, to read or write */
1454
/*	B3_RAM_ADDR		32 bit	RAM Address, to read or write */
1057
					/* Bit 31..19:	reserved */
1455
					/* Bit 31..19:	reserved */
1058
#define RAM_ADR_RAN	0x0007ffffL	/* Bit 18.. 0:	RAM Address Range */
1456
#define RAM_ADR_RAN	0x0007ffffL	/* Bit 18.. 0:	RAM Address Range */
1059
1457
1060
/* RAM Interface Registers */
1458
/* RAM Interface Registers */
1061
/*	B3_RI_CTRL		16 bit	RAM Iface Control Register */
1459
/*	B3_RI_CTRL		16 bit	RAM Interface Control Register */
1062
								/* Bit 15..10:	reserved */
1460
								/* Bit 15..10:	reserved */
1063
#define RI_CLR_RD_PERR	BIT_9S	/* Clear IRQ RAM Read Parity Err */
1461
#define RI_CLR_RD_PERR	BIT_9S	/* Clear IRQ RAM Read  Parity Err */
1064
#define RI_CLR_WR_PERR	BIT_8S	/* Clear IRQ RAM Write Parity Err*/
1462
#define RI_CLR_WR_PERR	BIT_8S	/* Clear IRQ RAM Write Parity Err */
1065
								/* Bit	7.. 2:	reserved */
1463
								/* Bit	7.. 2:	reserved */
1066
#define RI_RST_CLR		BIT_1S	/* Clear RAM Interface Reset */
1464
#define RI_RST_CLR		BIT_1S	/* Clear RAM Interface Reset */
1067
#define RI_RST_SET		BIT_0S	/* Set   RAM Interface Reset */
1465
#define RI_RST_SET		BIT_0S	/* Set   RAM Interface Reset */
Lines 1171-1177 Link Here
1171
								/* Bit 31..16:	reserved */
1569
								/* Bit 31..16:	reserved */
1172
#define BC_MAX			0xffff	/* Bit 15.. 0:	Byte counter */
1570
#define BC_MAX			0xffff	/* Bit 15.. 0:	Byte counter */
1173
1571
1174
/* BMU Control Status Registers */
1572
/* BMU Control / Status Registers	(Yukon and Genesis) */
1175
/*	B0_R1_CSR		32 bit	BMU Ctrl/Stat Rx Queue 1 */
1573
/*	B0_R1_CSR		32 bit	BMU Ctrl/Stat Rx Queue 1 */
1176
/*	B0_R2_CSR		32 bit	BMU Ctrl/Stat Rx Queue 2 */
1574
/*	B0_R2_CSR		32 bit	BMU Ctrl/Stat Rx Queue 2 */
1177
/*	B0_XA1_CSR		32 bit	BMU Ctrl/Stat Sync Tx Queue 1 */
1575
/*	B0_XA1_CSR		32 bit	BMU Ctrl/Stat Sync Tx Queue 1 */
Lines 1212-1217 Link Here
1212
						CSR_SV_RUN | CSR_DREAD_RUN | CSR_DWRITE_RUN |\
1610
						CSR_SV_RUN | CSR_DREAD_RUN | CSR_DWRITE_RUN |\
1213
						CSR_TRANS_RUN)
1611
						CSR_TRANS_RUN)
1214
1612
1613
/* Rx BMU Control / Status Registers (Yukon-2) */
1614
#define BMU_IDLE			BIT_31	/* BMU Idle State */
1615
#define BMU_RX_TCP_PKT		BIT_30	/* Rx TCP Packet (when RSS Hash enabled) */
1616
#define BMU_RX_IP_PKT		BIT_29	/* Rx IP  Packet (when RSS Hash enabled) */
1617
								/* Bit 28..16:	reserved */
1618
#define BMU_ENA_RX_RSS_HASH	BIT_15	/* Enable  Rx RSS Hash */
1619
#define BMU_DIS_RX_RSS_HASH	BIT_14	/* Disable Rx RSS Hash */
1620
#define BMU_ENA_RX_CHKSUM	BIT_13	/* Enable  Rx TCP/IP Checksum Check */
1621
#define BMU_DIS_RX_CHKSUM	BIT_12	/* Disable Rx TCP/IP Checksum Check */
1622
#define BMU_CLR_IRQ_PAR		BIT_11	/* Clear IRQ on Parity errors (Rx) */
1623
#define BMU_CLR_IRQ_TCP		BIT_11	/* Clear IRQ on TCP segmen. error (Tx) */
1624
#define BMU_CLR_IRQ_CHK		BIT_10	/* Clear IRQ Check */
1625
#define BMU_STOP			BIT_9	/* Stop  Rx/Tx Queue */
1626
#define BMU_START			BIT_8	/* Start Rx/Tx Queue */
1627
#define BMU_FIFO_OP_ON		BIT_7	/* FIFO Operational On */
1628
#define BMU_FIFO_OP_OFF 	BIT_6	/* FIFO Operational Off */
1629
#define BMU_FIFO_ENA		BIT_5	/* Enable FIFO */
1630
#define BMU_FIFO_RST		BIT_4	/* Reset  FIFO */
1631
#define BMU_OP_ON			BIT_3	/* BMU Operational On */
1632
#define BMU_OP_OFF			BIT_2	/* BMU Operational Off */
1633
#define BMU_RST_CLR			BIT_1	/* Clear BMU Reset (Enable) */
1634
#define BMU_RST_SET			BIT_0	/* Set   BMU Reset */
1635
1636
#define BMU_CLR_RESET		(BMU_FIFO_RST | BMU_OP_OFF | BMU_RST_CLR)
1637
#define BMU_OPER_INIT		(BMU_CLR_IRQ_PAR | BMU_CLR_IRQ_CHK | BMU_START | \
1638
							BMU_FIFO_ENA | BMU_OP_ON)
1639
							
1640
/* Tx BMU Control / Status Registers (Yukon-2) */
1641
								/* Bit 31: same as for Rx */
1642
								/* Bit 30..14:	reserved */
1643
#define BMU_TX_IPIDINCR_ON	BIT_13	/* Enable  IP ID Increment */
1644
#define BMU_TX_IPIDINCR_OFF	BIT_12	/* Disable IP ID Increment */
1645
#define BMU_TX_CLR_IRQ_TCP	BIT_11	/* Clear IRQ on TCP segm. length mism. */
1646
								/* Bit 10..0: same as for Rx */
1647
1215
/*	Q_F				32 bit	Flag Register */
1648
/*	Q_F				32 bit	Flag Register */
1216
									/* Bit 31..28:	reserved */
1649
									/* Bit 31..28:	reserved */
1217
#define F_ALM_FULL		BIT_27		/* Rx FIFO: almost full */
1650
#define F_ALM_FULL		BIT_27		/* Rx FIFO: almost full */
Lines 1260-1265 Link Here
1260
								/* Bit  3:	reserved */
1693
								/* Bit  3:	reserved */
1261
#define T3_VRAM_MSK		7		/* Bit  2.. 0:	Virtual RAM Buffer Address */
1694
#define T3_VRAM_MSK		7		/* Bit  2.. 0:	Virtual RAM Buffer Address */
1262
1695
1696
/* Queue Prefetch Unit Offsets, use Y2_PREF_Q_ADDR() to address (Yukon-2 only)*/
1697
/* PREF_UNIT_CTRL_REG	32 bit	Prefetch Control register */
1698
#define PREF_UNIT_OP_ON		BIT_3	/* prefetch unit operational */
1699
#define PREF_UNIT_OP_OFF	BIT_2	/* prefetch unit not operational */
1700
#define PREF_UNIT_RST_CLR	BIT_1	/* Clear Prefetch Unit Reset */
1701
#define PREF_UNIT_RST_SET	BIT_0	/* Set   Prefetch Unit Reset */
1702
1263
/* RAM Buffer Register Offsets, use RB_ADDR(Queue, Offs) to access */
1703
/* RAM Buffer Register Offsets, use RB_ADDR(Queue, Offs) to access */
1264
/*	RB_START		32 bit	RAM Buffer Start Address */
1704
/*	RB_START		32 bit	RAM Buffer Start Address */
1265
/*	RB_END			32 bit	RAM Buffer End Address */
1705
/*	RB_END			32 bit	RAM Buffer End Address */
Lines 1275-1298 Link Here
1275
#define RB_MSK	0x0007ffff	/* Bit 18.. 0:	RAM Buffer Pointer Bits */
1715
#define RB_MSK	0x0007ffff	/* Bit 18.. 0:	RAM Buffer Pointer Bits */
1276
1716
1277
/*	RB_TST2			 8 bit	RAM Buffer Test Register 2 */
1717
/*	RB_TST2			 8 bit	RAM Buffer Test Register 2 */
1278
								/* Bit 7.. 4:	reserved */
1718
							/* Bit 7.. 4:	reserved */
1279
#define RB_PC_DEC		BIT_3S	/* Packet Counter Decrem */
1719
#define RB_PC_DEC		BIT_3S	/* Packet Counter Decrement */
1280
#define RB_PC_T_ON		BIT_2S	/* Packet Counter Test On */
1720
#define RB_PC_T_ON		BIT_2S	/* Packet Counter Test On */
1281
#define RB_PC_T_OFF		BIT_1S	/* Packet Counter Tst Off */
1721
#define RB_PC_T_OFF		BIT_1S	/* Packet Counter Test Off */
1282
#define RB_PC_INC		BIT_0S	/* Packet Counter Increm */
1722
#define RB_PC_INC		BIT_0S	/* Packet Counter Increment */
1283
1723
1284
/*	RB_TST1			 8 bit	RAM Buffer Test Register 1 */
1724
/*	RB_TST1			 8 bit	RAM Buffer Test Register 1 */
1285
							/* Bit 7:	reserved */
1725
							/* Bit 7:	reserved */
1286
#define RB_WP_T_ON		BIT_6S	/* Write Pointer Test On */
1726
#define RB_WP_T_ON		BIT_6S	/* Write Pointer Test On */
1287
#define RB_WP_T_OFF		BIT_5S	/* Write Pointer Test Off */
1727
#define RB_WP_T_OFF		BIT_5S	/* Write Pointer Test Off */
1288
#define RB_WP_INC		BIT_4S	/* Write Pointer Increm */
1728
#define RB_WP_INC		BIT_4S	/* Write Pointer Increment */
1289
								/* Bit 3:	reserved */
1729
								/* Bit 3:	reserved */
1290
#define RB_RP_T_ON		BIT_2S	/* Read Pointer Test On */
1730
#define RB_RP_T_ON		BIT_2S	/* Read Pointer Test On */
1291
#define RB_RP_T_OFF		BIT_1S	/* Read Pointer Test Off */
1731
#define RB_RP_T_OFF		BIT_1S	/* Read Pointer Test Off */
1292
#define RB_RP_DEC		BIT_0S	/* Read Pointer Decrement */
1732
#define RB_RP_INC		BIT_0S	/* Read Pointer Increment */
1293
1733
1294
/*	RB_CTRL			 8 bit	RAM Buffer Control Register */
1734
/*	RB_CTRL			 8 bit	RAM Buffer Control Register */
1295
								/* Bit 7.. 6:	reserved */
1735
							/* Bit 7.. 6:	reserved */
1296
#define RB_ENA_STFWD	BIT_5S	/* Enable  Store & Forward */
1736
#define RB_ENA_STFWD	BIT_5S	/* Enable  Store & Forward */
1297
#define RB_DIS_STFWD	BIT_4S	/* Disable Store & Forward */
1737
#define RB_DIS_STFWD	BIT_4S	/* Disable Store & Forward */
1298
#define RB_ENA_OP_MD	BIT_3S	/* Enable  Operation Mode */
1738
#define RB_ENA_OP_MD	BIT_3S	/* Enable  Operation Mode */
Lines 1300-1315 Link Here
1300
#define RB_RST_CLR		BIT_1S	/* Clear RAM Buf STM Reset */
1740
#define RB_RST_CLR		BIT_1S	/* Clear RAM Buf STM Reset */
1301
#define RB_RST_SET		BIT_0S	/* Set   RAM Buf STM Reset */
1741
#define RB_RST_SET		BIT_0S	/* Set   RAM Buf STM Reset */
1302
1742
1743
/* Yukon-2 */
1744
							/* Bit 31..20:	reserved */
1745
#define RB_CNT_DOWN		BIT_19	/* Packet Counter Decrement */
1746
#define RB_CNT_TST_ON	BIT_18  /* Packet Counter Test On */
1747
#define RB_CNT_TST_OFF	BIT_17	/* Packet Counter Test Off */
1748
#define RB_CNT_UP		BIT_16	/* Packet Counter Increment */
1749
							/* Bit 15:	reserved */
1750
#define RB_WP_TST_ON	BIT_14  /* Write Pointer Test On */
1751
#define RB_WP_TST_OFF	BIT_13	/* Write Pointer Test Off */
1752
#define RB_WP_UP		BIT_12	/* Write Pointer Increment  */
1753
							/* Bit 11:	reserved */
1754
#define RB_RP_TST_ON	BIT_10  /* Read Pointer Test On */
1755
#define RB_RP_TST_OFF	BIT_9	/* Read Pointer Test Off */
1756
#define RB_RP_UP		BIT_8	/* Read Pointer Increment */
1757
1303
1758
1304
/* Receive and Transmit MAC FIFO Registers (GENESIS only) */
1759
/* Receive and Transmit MAC FIFO Registers (GENESIS only) */
1305
1760
1306
/*	RX_MFF_EA		32 bit	Receive MAC FIFO End Address */
1761
/*	RX_MFF_EA		32 bit	Receive MAC FIFO End Address */
1307
/*	RX_MFF_WP		32 bit 	Receive MAC FIFO Write Pointer */
1762
/*	RX_MFF_WP		32 bit	Receive MAC FIFO Write Pointer */
1308
/*	RX_MFF_RP		32 bit	Receive MAC FIFO Read Pointer */
1763
/*	RX_MFF_RP		32 bit	Receive MAC FIFO Read Pointer */
1309
/*	RX_MFF_PC		32 bit	Receive MAC FIFO Packet Counter */
1764
/*	RX_MFF_PC		32 bit	Receive MAC FIFO Packet Counter */
1310
/*	RX_MFF_LEV		32 bit	Receive MAC FIFO Level */
1765
/*	RX_MFF_LEV		32 bit	Receive MAC FIFO Level */
1311
/*	TX_MFF_EA		32 bit	Transmit MAC FIFO End Address */
1766
/*	TX_MFF_EA		32 bit	Transmit MAC FIFO End Address */
1312
/*	TX_MFF_WP		32 bit 	Transmit MAC FIFO Write Pointer */
1767
/*	TX_MFF_WP		32 bit	Transmit MAC FIFO Write Pointer */
1313
/*	TX_MFF_WSP		32 bit	Transmit MAC FIFO WR Shadow Pointer */
1768
/*	TX_MFF_WSP		32 bit	Transmit MAC FIFO WR Shadow Pointer */
1314
/*	TX_MFF_RP		32 bit	Transmit MAC FIFO Read Pointer */
1769
/*	TX_MFF_RP		32 bit	Transmit MAC FIFO Read Pointer */
1315
/*	TX_MFF_PC		32 bit	Transmit MAC FIFO Packet Cnt */
1770
/*	TX_MFF_PC		32 bit	Transmit MAC FIFO Packet Cnt */
Lines 1359-1367 Link Here
1359
/*	RX_MFF_TST2	 	 8 bit	Receive MAC FIFO Test Register 2 */
1814
/*	RX_MFF_TST2	 	 8 bit	Receive MAC FIFO Test Register 2 */
1360
/*	TX_MFF_TST2	 	 8 bit	Transmit MAC FIFO Test Register 2 */
1815
/*	TX_MFF_TST2	 	 8 bit	Transmit MAC FIFO Test Register 2 */
1361
								/* Bit 7:	reserved */
1816
								/* Bit 7:	reserved */
1362
#define MFF_WSP_T_ON	BIT_6S	/* Tx: Write Shadow Ptr TestOn */
1817
#define MFF_WSP_T_ON	BIT_6S	/* Tx: Write Shadow Pointer Test On */
1363
#define MFF_WSP_T_OFF	BIT_5S	/* Tx: Write Shadow Ptr TstOff */
1818
#define MFF_WSP_T_OFF	BIT_5S	/* Tx: Write Shadow Pointer Test Off */
1364
#define MFF_WSP_INC		BIT_4S	/* Tx: Write Shadow Ptr Increment */
1819
#define MFF_WSP_INC		BIT_4S	/* Tx: Write Shadow Pointer Increment */
1365
#define MFF_PC_DEC		BIT_3S	/* Packet Counter Decrement */
1820
#define MFF_PC_DEC		BIT_3S	/* Packet Counter Decrement */
1366
#define MFF_PC_T_ON		BIT_2S	/* Packet Counter Test On */
1821
#define MFF_PC_T_ON		BIT_2S	/* Packet Counter Test On */
1367
#define MFF_PC_T_OFF	BIT_1S	/* Packet Counter Test Off */
1822
#define MFF_PC_T_OFF	BIT_1S	/* Packet Counter Test Off */
Lines 1372-1378 Link Here
1372
					/* Bit 7:	reserved */
1827
					/* Bit 7:	reserved */
1373
#define MFF_WP_T_ON		BIT_6S	/* Write Pointer Test On */
1828
#define MFF_WP_T_ON		BIT_6S	/* Write Pointer Test On */
1374
#define MFF_WP_T_OFF	BIT_5S	/* Write Pointer Test Off */
1829
#define MFF_WP_T_OFF	BIT_5S	/* Write Pointer Test Off */
1375
#define MFF_WP_INC		BIT_4S	/* Write Pointer Increm */
1830
#define MFF_WP_INC		BIT_4S	/* Write Pointer Increment */
1376
							/* Bit 3:	reserved */
1831
							/* Bit 3:	reserved */
1377
#define MFF_RP_T_ON		BIT_2S	/* Read Pointer Test On */
1832
#define MFF_RP_T_ON		BIT_2S	/* Read Pointer Test On */
1378
#define MFF_RP_T_OFF	BIT_1S	/* Read Pointer Test Off */
1833
#define MFF_RP_T_OFF	BIT_1S	/* Read Pointer Test Off */
Lines 1391-1402 Link Here
1391
1846
1392
/*	RX_LED_CTRL		 8 bit	Receive LED Cnt Control Reg */
1847
/*	RX_LED_CTRL		 8 bit	Receive LED Cnt Control Reg */
1393
/*	TX_LED_CTRL		 8 bit	Transmit LED Cnt Control Reg */
1848
/*	TX_LED_CTRL		 8 bit	Transmit LED Cnt Control Reg */
1849
							/* Bit 7.. 3:	reserved */
1850
#define LED_START		BIT_2S	/* Start Counter */
1851
#define LED_STOP		BIT_1S	/* Stop Counter */
1852
#define LED_STATE		BIT_0S	/* Rx/Tx: LED State, 1=LED On */
1853
1394
/*	LNK_SYNC_CTRL	 8 bit	Link Sync Cnt Control Register */
1854
/*	LNK_SYNC_CTRL	 8 bit	Link Sync Cnt Control Register */
1395
							/* Bit 7.. 3:	reserved */
1855
							/* Bit 7.. 3:	reserved */
1396
#define LED_START		BIT_2S	/* Start Timer */
1856
#define LNK_START		BIT_2S	/* Start Counter */
1397
#define LED_STOP		BIT_1S	/* Stop Timer */
1857
#define LNK_STOP		BIT_1S	/* Stop Counter */
1398
#define LED_STATE		BIT_0S	/* Rx/Tx: LED State, 1=LED on */
1858
#define LNK_CLR_IRQ		BIT_0S	/* Clear Link IRQ */
1399
#define LED_CLR_IRQ		BIT_0S	/* Lnk: 	Clear Link IRQ */
1400
1859
1401
/*	RX_LED_TST		 8 bit	Receive LED Cnt Test Register */
1860
/*	RX_LED_TST		 8 bit	Receive LED Cnt Test Register */
1402
/*	TX_LED_TST		 8 bit	Transmit LED Cnt Test Register */
1861
/*	TX_LED_TST		 8 bit	Transmit LED Cnt Test Register */
Lines 1407-1492 Link Here
1407
#define LED_T_STEP		BIT_0S	/* LED Counter Step */
1866
#define LED_T_STEP		BIT_0S	/* LED Counter Step */
1408
1867
1409
/*	LNK_LED_REG	 	 8 bit	Link LED Register */
1868
/*	LNK_LED_REG	 	 8 bit	Link LED Register */
1410
								/* Bit 7.. 6:	reserved */
1869
							/* Bit 7.. 6:	reserved */
1411
#define LED_BLK_ON		BIT_5S	/* Link LED Blinking On */
1870
#define LED_BLK_ON		BIT_5S	/* Link LED Blinking On */
1412
#define LED_BLK_OFF		BIT_4S	/* Link LED Blinking Off */
1871
#define LED_BLK_OFF		BIT_4S	/* Link LED Blinking Off */
1413
#define LED_SYNC_ON		BIT_3S	/* Use Sync Wire to switch LED */
1872
#define LED_SYNC_ON		BIT_3S	/* Use Sync Wire to switch LED */
1414
#define LED_SYNC_OFF	BIT_2S	/* Disable Sync Wire Input */
1873
#define LED_SYNC_OFF	BIT_2S	/* Disable Sync Wire Input */
1415
#define LED_ON			BIT_1S	/* switch LED on */
1874
#define LED_ON			BIT_1S	/* Switch LED On */
1416
#define LED_OFF			BIT_0S	/* switch LED off */
1875
#define LED_OFF			BIT_0S	/* Switch LED Off */
1417
1876
1418
/*	Receive and Transmit GMAC FIFO Registers (YUKON only) */
1877
/*	Receive and Transmit GMAC FIFO Registers (YUKON only) */
1419
1878
1420
/*	RX_GMF_EA		32 bit	Rx GMAC FIFO End Address */
1879
/*	RX_GMF_EA		32 bit	Rx GMAC FIFO End Address */
1421
/*	RX_GMF_AF_THR	32 bit	Rx GMAC FIFO Almost Full Thresh. */
1880
/*	RX_GMF_AF_THR	32 bit	Rx GMAC FIFO Almost Full Thresh. */
1422
/*	RX_GMF_WP		32 bit 	Rx GMAC FIFO Write Pointer */
1881
/*	RX_GMF_WP		32 bit	Rx GMAC FIFO Write Pointer */
1423
/*	RX_GMF_WLEV		32 bit 	Rx GMAC FIFO Write Level */
1882
/*	RX_GMF_WLEV		32 bit	Rx GMAC FIFO Write Level */
1424
/*	RX_GMF_RP		32 bit 	Rx GMAC FIFO Read Pointer */
1883
/*	RX_GMF_RP		32 bit	Rx GMAC FIFO Read Pointer */
1425
/*	RX_GMF_RLEV		32 bit 	Rx GMAC FIFO Read Level */
1884
/*	RX_GMF_RLEV		32 bit	Rx GMAC FIFO Read Level */
1426
/*	TX_GMF_EA		32 bit	Tx GMAC FIFO End Address */
1885
/*	TX_GMF_EA		32 bit	Tx GMAC FIFO End Address */
1427
/*	TX_GMF_AE_THR	32 bit	Tx GMAC FIFO Almost Empty Thresh.*/
1886
/*	TX_GMF_AE_THR	32 bit	Tx GMAC FIFO Almost Empty Thresh.*/
1428
/*	TX_GMF_WP		32 bit 	Tx GMAC FIFO Write Pointer */
1887
/*	TX_GMF_WP		32 bit	Tx GMAC FIFO Write Pointer */
1429
/*	TX_GMF_WSP		32 bit 	Tx GMAC FIFO Write Shadow Ptr. */
1888
/*	TX_GMF_WSP		32 bit	Tx GMAC FIFO Write Shadow Pointer */
1430
/*	TX_GMF_WLEV		32 bit 	Tx GMAC FIFO Write Level */
1889
/*	TX_GMF_WLEV		32 bit	Tx GMAC FIFO Write Level */
1431
/*	TX_GMF_RP		32 bit 	Tx GMAC FIFO Read Pointer */
1890
/*	TX_GMF_RP		32 bit	Tx GMAC FIFO Read Pointer */
1432
/*	TX_GMF_RSTP		32 bit 	Tx GMAC FIFO Restart Pointer */
1891
/*	TX_GMF_RSTP		32 bit	Tx GMAC FIFO Restart Pointer */
1433
/*	TX_GMF_RLEV		32 bit 	Tx GMAC FIFO Read Level */
1892
/*	TX_GMF_RLEV		32 bit	Tx GMAC FIFO Read Level */
1434
1893
1435
/*	RX_GMF_CTRL_T	32 bit	Rx GMAC FIFO Control/Test */
1894
/*	RX_GMF_CTRL_T	32 bit	Rx GMAC FIFO Control/Test */
1436
						/* Bits 31..15:	reserved */
1895
						/* Bit 31..28 reserved */
1437
#define GMF_WP_TST_ON	BIT_14		/* Write Pointer Test On */
1896
#define RX_TRUNC_ON		BIT_27  /* enable  packet truncation */
1438
#define GMF_WP_TST_OFF	BIT_13		/* Write Pointer Test Off */
1897
#define RX_TRUNC_OFF	BIT_26	/* disable packet truncation */
1439
#define GMF_WP_STEP		BIT_12		/* Write Pointer Step/Increment */
1898
#define RX_VLAN_STRIP_ON	BIT_25	/* enable  VLAN stripping */
1899
#define RX_VLAN_STRIP_OFF	BIT_24	/* disable VLAN stripping */
1900
						/* Bit 23..15 reserved */
1901
#define GMF_WP_TST_ON	BIT_14	/* Write Pointer Test On */
1902
#define GMF_WP_TST_OFF	BIT_13	/* Write Pointer Test Off */
1903
#define GMF_WP_STEP		BIT_12	/* Write Pointer Step/Increment */
1440
						/* Bit 11:	reserved */
1904
						/* Bit 11:	reserved */
1441
#define GMF_RP_TST_ON	BIT_10		/* Read Pointer Test On */
1905
#define GMF_RP_TST_ON	BIT_10	/* Read Pointer Test On */
1442
#define GMF_RP_TST_OFF	BIT_9		/* Read Pointer Test Off */
1906
#define GMF_RP_TST_OFF	BIT_9	/* Read Pointer Test Off */
1443
#define GMF_RP_STEP		BIT_8		/* Read Pointer Step/Increment */
1907
#define GMF_RP_STEP		BIT_8	/* Read Pointer Step/Increment */
1444
#define GMF_RX_F_FL_ON	BIT_7		/* Rx FIFO Flush Mode On */
1908
#define GMF_RX_F_FL_ON	BIT_7	/* Rx FIFO Flush Mode On */
1445
#define GMF_RX_F_FL_OFF	BIT_6		/* Rx FIFO Flush Mode Off */
1909
#define GMF_RX_F_FL_OFF	BIT_6	/* Rx FIFO Flush Mode Off */
1446
#define GMF_CLI_RX_FO	BIT_5		/* Clear IRQ Rx FIFO Overrun */
1910
#define GMF_CLI_RX_FO	BIT_5	/* Clear IRQ Rx FIFO Overrun */
1447
#define GMF_CLI_RX_FC	BIT_4		/* Clear IRQ Rx Frame Complete */
1911
#define GMF_CLI_RX_FC	BIT_4	/* Clear IRQ Rx Frame Complete */
1448
#define GMF_OPER_ON		BIT_3		/* Operational Mode On */
1912
#define GMF_OPER_ON		BIT_3	/* Operational Mode On */
1449
#define GMF_OPER_OFF	BIT_2		/* Operational Mode Off */
1913
#define GMF_OPER_OFF	BIT_2	/* Operational Mode Off */
1450
#define GMF_RST_CLR		BIT_1		/* Clear GMAC FIFO Reset */
1914
#define GMF_RST_CLR		BIT_1	/* Clear GMAC FIFO Reset */
1451
#define GMF_RST_SET		BIT_0		/* Set   GMAC FIFO Reset */
1915
#define GMF_RST_SET		BIT_0	/* Set   GMAC FIFO Reset */
1452
1916
1453
/*	TX_GMF_CTRL_T	32 bit	Tx GMAC FIFO Control/Test */
1917
/*	TX_GMF_CTRL_T	32 bit	Tx GMAC FIFO Control/Test (YUKON and Yukon-2) */
1454
						/* Bits 31..19:	reserved */
1918
						/* Bits 31..26: reserved */
1455
#define GMF_WSP_TST_ON	BIT_18		/* Write Shadow Pointer Test On */
1919
#define TX_VLAN_TAG_ON	BIT_25	/* enable  VLAN tagging */
1456
#define GMF_WSP_TST_OFF	BIT_17		/* Write Shadow Pointer Test Off */
1920
#define TX_VLAN_TAG_OFF	BIT_24	/* disable VLAN tagging */
1457
#define GMF_WSP_STEP	BIT_16		/* Write Shadow Pointer Step/Increment */
1921
						/* Bits 23..19: reserved */
1458
						/* Bits 15..7: same as for RX_GMF_CTRL_T */
1922
#define GMF_WSP_TST_ON	BIT_18	/* Write Shadow Pointer Test On */
1459
#define GMF_CLI_TX_FU	BIT_6		/* Clear IRQ Tx FIFO Underrun */
1923
#define GMF_WSP_TST_OFF	BIT_17	/* Write Shadow Pointer Test Off */
1460
#define GMF_CLI_TX_FC	BIT_5		/* Clear IRQ Tx Frame Complete */
1924
#define GMF_WSP_STEP	BIT_16	/* Write Shadow Pointer Step/Increment */
1461
#define GMF_CLI_TX_PE	BIT_4		/* Clear IRQ Tx Parity Error */
1925
						/* Bits 15..8: same as for RX_GMF_CTRL_T */
1926
						/* Bit 7:	reserved */
1927
#define GMF_CLI_TX_FU	BIT_6	/* Clear IRQ Tx FIFO Underrun */
1928
#define GMF_CLI_TX_FC	BIT_5	/* Clear IRQ Tx Frame Complete */
1929
#define GMF_CLI_TX_PE	BIT_4	/* Clear IRQ Tx Parity Error */
1462
						/* Bits 3..0: same as for RX_GMF_CTRL_T */
1930
						/* Bits 3..0: same as for RX_GMF_CTRL_T */
1463
1931
1464
#define GMF_RX_CTRL_DEF		(GMF_OPER_ON | GMF_RX_F_FL_ON)
1932
#define GMF_RX_CTRL_DEF		(GMF_OPER_ON | GMF_RX_F_FL_ON)
1465
#define GMF_TX_CTRL_DEF		GMF_OPER_ON
1933
#define GMF_TX_CTRL_DEF		GMF_OPER_ON
1466
1934
1935
#define RX_GMF_AF_THR_MIN	0x0c	/* Rx GMAC FIFO Almost Full Thresh. min. */
1467
#define RX_GMF_FL_THR_DEF	0x0a	/* Rx GMAC FIFO Flush Threshold default */
1936
#define RX_GMF_FL_THR_DEF	0x0a	/* Rx GMAC FIFO Flush Threshold default */
1468
1937
1469
/*	GMAC_TI_ST_CTRL	 8 bit	Time Stamp Timer Ctrl Reg (YUKON only) */
1938
/*	GMAC_TI_ST_CTRL	 8 bit	Time Stamp Timer Ctrl Reg (YUKON only) */
1470
								/* Bit 7.. 3:	reserved */
1939
							/* Bit 7.. 3:	reserved */
1471
#define GMT_ST_START	BIT_2S		/* Start Time Stamp Timer */
1940
#define GMT_ST_START	BIT_2S	/* Start Time Stamp Timer */
1472
#define GMT_ST_STOP		BIT_1S		/* Stop  Time Stamp Timer */
1941
#define GMT_ST_STOP		BIT_1S	/* Stop  Time Stamp Timer */
1473
#define GMT_ST_CLR_IRQ	BIT_0S		/* Clear Time Stamp Timer IRQ */
1942
#define GMT_ST_CLR_IRQ	BIT_0S	/* Clear Time Stamp Timer IRQ */
1474
1943
1944
/*	POLL_CTRL		32 bit	Polling Unit control register (Yukon-2 only) */
1945
							/* Bit 31.. 6:	reserved */
1946
#define PC_CLR_IRQ_CHK	BIT_5	/* Clear IRQ Check */
1947
#define PC_POLL_RQ		BIT_4	/* Poll Request Start */
1948
#define PC_POLL_OP_ON	BIT_3	/* Operational Mode On */
1949
#define PC_POLL_OP_OFF	BIT_2	/* Operational Mode Off */
1950
#define PC_POLL_RST_CLR	BIT_1	/* Clear Polling Unit Reset (Enable) */
1951
#define PC_POLL_RST_SET	BIT_0	/* Set   Polling Unit Reset */
1952
1953
1954
/* The bit definition of the following registers is still missing! */
1955
/* B28_Y2_SMB_CONFIG		32 bit	ASF SMBus Config Register */
1956
/* B28_Y2_SMB_CSD_REG		32 bit	ASF SMB Control/Status/Data */
1957
/* B28_Y2_ASF_IRQ_V_BASE	32 bit	ASF IRQ Vector Base */
1958
1959
/* B28_Y2_ASF_STAT_CMD		32 bit	ASF Status and Command Reg */
1960
/* This register is used by the host driver software */
1961
						/* Bit 31:5	reserved */
1962
#define Y2_ASF_OS_PRES	BIT_4S	/* ASF operation system present */
1963
#define Y2_ASF_RESET	BIT_3S	/* ASF system in reset state */
1964
#define Y2_ASF_RUNNING	BIT_2S	/* ASF system operational */
1965
#define Y2_ASF_CLR_HSTI	BIT_1S	/* Clear ASF IRQ */
1966
#define Y2_ASF_IRQ		BIT_0S	/* Issue an IRQ to ASF system */
1967
1968
#define Y2_ASF_UC_STATE	(3<<2)	/* ASF uC State */
1969
#define Y2_ASF_CLK_HALT	0		/* ASF system clock stopped */
1970
1971
/* B28_Y2_ASF_HOST_COM	32 bit	ASF Host Communication Reg */
1972
/* This register is used by the ASF firmware */
1973
						/* Bit 31:2	reserved */
1974
#define Y2_ASF_CLR_ASFI	BIT_1	/* Clear host IRQ */
1975
#define Y2_ASF_HOST_IRQ	BIT_0	/* Issue an IRQ to HOST system */
1976
1977
1978
/*	STAT_CTRL		32 bit	Status BMU control register (Yukon-2 only) */
1979
							/* Bit  7.. 5:	reserved */
1980
#define SC_STAT_CLR_IRQ	BIT_4	/* Status Burst IRQ clear */
1981
#define SC_STAT_OP_ON	BIT_3	/* Operational Mode On */
1982
#define SC_STAT_OP_OFF	BIT_2	/* Operational Mode Off */
1983
#define SC_STAT_RST_CLR	BIT_1	/* Clear Status Unit Reset (Enable) */
1984
#define SC_STAT_RST_SET	BIT_0	/* Set   Status Unit Reset */
1985
	
1475
/*	GMAC_CTRL		32 bit	GMAC Control Reg (YUKON only) */
1986
/*	GMAC_CTRL		32 bit	GMAC Control Reg (YUKON only) */
1476
						/* Bits 31.. 8:	reserved */
1987
						/* Bits 31.. 8:	reserved */
1477
#define GMC_H_BURST_ON	BIT_7		/* Half Duplex Burst Mode On */
1988
#define GMC_H_BURST_ON	BIT_7	/* Half Duplex Burst Mode On */
1478
#define GMC_H_BURST_OFF	BIT_6		/* Half Duplex Burst Mode Off */
1989
#define GMC_H_BURST_OFF	BIT_6	/* Half Duplex Burst Mode Off */
1479
#define GMC_F_LOOPB_ON	BIT_5		/* FIFO Loopback On */
1990
#define GMC_F_LOOPB_ON	BIT_5	/* FIFO Loopback On */
1480
#define GMC_F_LOOPB_OFF	BIT_4		/* FIFO Loopback Off */
1991
#define GMC_F_LOOPB_OFF	BIT_4	/* FIFO Loopback Off */
1481
#define GMC_PAUSE_ON	BIT_3		/* Pause On */
1992
#define GMC_PAUSE_ON	BIT_3	/* Pause On */
1482
#define GMC_PAUSE_OFF	BIT_2		/* Pause Off */
1993
#define GMC_PAUSE_OFF	BIT_2	/* Pause Off */
1483
#define GMC_RST_CLR		BIT_1		/* Clear GMAC Reset */
1994
#define GMC_RST_CLR		BIT_1	/* Clear GMAC Reset */
1484
#define GMC_RST_SET		BIT_0		/* Set   GMAC Reset */
1995
#define GMC_RST_SET		BIT_0	/* Set   GMAC Reset */
1485
1996
1486
/*	GPHY_CTRL		32 bit	GPHY Control Reg (YUKON only) */
1997
/*	GPHY_CTRL		32 bit	GPHY Control Reg (YUKON only) */
1487
						/* Bits 31..29:	reserved */
1998
						/* Bits 31..29:	reserved */
1488
#define GPC_SEL_BDT		BIT_28	/* Select Bi-Dir. Transfer for MDC/MDIO */
1999
#define GPC_SEL_BDT		BIT_28	/* Select Bi-Dir. Transfer for MDC/MDIO */
1489
#define GPC_INT_POL_HI	BIT_27	/* IRQ Polarity is Active HIGH */
2000
#define GPC_INT_POL		BIT_27	/* IRQ Polarity is Active Low */
1490
#define GPC_75_OHM		BIT_26	/* Use 75 Ohm Termination instead of 50 */
2001
#define GPC_75_OHM		BIT_26	/* Use 75 Ohm Termination instead of 50 */
1491
#define GPC_DIS_FC		BIT_25	/* Disable Automatic Fiber/Copper Detection */
2002
#define GPC_DIS_FC		BIT_25	/* Disable Automatic Fiber/Copper Detection */
1492
#define GPC_DIS_SLEEP	BIT_24	/* Disable Energy Detect */
2003
#define GPC_DIS_SLEEP	BIT_24	/* Disable Energy Detect */
Lines 1540-1553 Link Here
1540
2051
1541
/*	GMAC_IRQ_SRC	 8 bit	GMAC Interrupt Source Reg (YUKON only) */
2052
/*	GMAC_IRQ_SRC	 8 bit	GMAC Interrupt Source Reg (YUKON only) */
1542
/*	GMAC_IRQ_MSK	 8 bit	GMAC Interrupt Mask   Reg (YUKON only) */
2053
/*	GMAC_IRQ_MSK	 8 bit	GMAC Interrupt Mask   Reg (YUKON only) */
1543
#define GM_IS_TX_CO_OV	BIT_5		/* Transmit Counter Overflow IRQ */
2054
#define GM_IS_RX_CO_OV	BIT_5S		/* Receive Counter Overflow IRQ */
1544
#define GM_IS_RX_CO_OV	BIT_4		/* Receive Counter Overflow IRQ */
2055
#define GM_IS_TX_CO_OV	BIT_4S		/* Transmit Counter Overflow IRQ */
1545
#define GM_IS_TX_FF_UR	BIT_3		/* Transmit FIFO Underrun */
2056
#define GM_IS_TX_FF_UR	BIT_3S		/* Transmit FIFO Underrun */
1546
#define GM_IS_TX_COMPL	BIT_2		/* Frame Transmission Complete */
2057
#define GM_IS_TX_COMPL	BIT_2S		/* Frame Transmission Complete */
1547
#define GM_IS_RX_FF_OR	BIT_1		/* Receive FIFO Overrun */
2058
#define GM_IS_RX_FF_OR	BIT_1S		/* Receive FIFO Overrun */
1548
#define GM_IS_RX_COMPL	BIT_0		/* Frame Reception Complete */
2059
#define GM_IS_RX_COMPL	BIT_0S		/* Frame Reception Complete */
1549
2060
1550
#define GMAC_DEF_MSK	(GM_IS_TX_CO_OV | GM_IS_RX_CO_OV | \
2061
#define GMAC_DEF_MSK	(GM_IS_RX_CO_OV | GM_IS_TX_CO_OV | \
1551
						GM_IS_TX_FF_UR)
2062
						GM_IS_TX_FF_UR)
1552
2063
1553
/*	GMAC_LINK_CTRL	16 bit	GMAC Link Control Reg (YUKON only) */
2064
/*	GMAC_LINK_CTRL	16 bit	GMAC Link Control Reg (YUKON only) */
Lines 1579-1593 Link Here
1579
2090
1580
#define WOL_CTL_DEFAULT				\
2091
#define WOL_CTL_DEFAULT				\
1581
	(WOL_CTL_DIS_PME_ON_LINK_CHG |	\
2092
	(WOL_CTL_DIS_PME_ON_LINK_CHG |	\
1582
	WOL_CTL_DIS_PME_ON_PATTERN |	\
2093
	 WOL_CTL_DIS_PME_ON_PATTERN |	\
1583
	WOL_CTL_DIS_PME_ON_MAGIC_PKT |	\
2094
	 WOL_CTL_DIS_PME_ON_MAGIC_PKT |	\
1584
	WOL_CTL_DIS_LINK_CHG_UNIT |		\
2095
	 WOL_CTL_DIS_LINK_CHG_UNIT |	\
1585
	WOL_CTL_DIS_PATTERN_UNIT |		\
2096
	 WOL_CTL_DIS_PATTERN_UNIT |		\
1586
	WOL_CTL_DIS_MAGIC_PKT_UNIT)
2097
	 WOL_CTL_DIS_MAGIC_PKT_UNIT)
1587
2098
1588
/*	WOL_MATCH_CTL	 8 bit	WOL Match Control Reg */
2099
/*	WOL_MATCH_CTL	 8 bit	WOL Match Control Reg */
1589
#define WOL_CTL_PATT_ENA(x)				(BIT_0 << (x))
2100
#define WOL_CTL_PATT_ENA(x)				(BIT_0 << (x))
1590
2101
2102
/*	WOL_PATT_PME	8 bit	WOL PME Match Enable (Yukon-2) */
2103
#define WOL_PATT_FORCE_PME				BIT_7	/* Generates a PME */
2104
#define WOL_PATT_MATCH_PME_ALL			0x7f
2105
1591
#define SK_NUM_WOL_PATTERN		7
2106
#define SK_NUM_WOL_PATTERN		7
1592
#define SK_PATTERN_PER_WORD		4
2107
#define SK_PATTERN_PER_WORD		4
1593
#define SK_BITMASK_PATTERN		7
2108
#define SK_BITMASK_PATTERN		7
Lines 1606-1622 Link Here
1606
	SK_U32	TxAdrLo;		/* Physical Tx Buffer Address lower dword */
2121
	SK_U32	TxAdrLo;		/* Physical Tx Buffer Address lower dword */
1607
	SK_U32	TxAdrHi;		/* Physical Tx Buffer Address upper dword */
2122
	SK_U32	TxAdrHi;		/* Physical Tx Buffer Address upper dword */
1608
	SK_U32	TxStat;			/* Transmit Frame Status Word */
2123
	SK_U32	TxStat;			/* Transmit Frame Status Word */
1609
#ifndef	SK_USE_REV_DESC
2124
#ifndef SK_USE_REV_DESC
1610
	SK_U16	TxTcpOffs;		/* TCP Checksum Calculation Start Value */
2125
	SK_U16	TxTcpOffs;		/* TCP Checksum Calculation Start Value */
1611
	SK_U16	TxRes1;			/* 16 bit reserved field */
2126
	SK_U16	TxRes1;			/* 16 bit reserved field */
1612
	SK_U16	TxTcpWp;		/* TCP Checksum Write Position */
2127
	SK_U16	TxTcpWp;		/* TCP Checksum Write Position */
1613
	SK_U16	TxTcpSp;		/* TCP Checksum Calculation Start Position */
2128
	SK_U16	TxTcpSp;		/* TCP Checksum Calculation Start Position */
1614
#else	/* SK_USE_REV_DESC */
2129
#else  /* SK_USE_REV_DESC */
1615
	SK_U16	TxRes1;			/* 16 bit reserved field */
2130
	SK_U16	TxRes1;			/* 16 bit reserved field */
1616
	SK_U16	TxTcpOffs;		/* TCP Checksum Calculation Start Value */
2131
	SK_U16	TxTcpOffs;		/* TCP Checksum Calculation Start Value */
1617
	SK_U16	TxTcpSp;		/* TCP Checksum Calculation Start Position */
2132
	SK_U16	TxTcpSp;		/* TCP Checksum Calculation Start Position */
1618
	SK_U16	TxTcpWp;		/* TCP Checksum Write Position */
2133
	SK_U16	TxTcpWp;		/* TCP Checksum Write Position */
1619
#endif	/* SK_USE_REV_DESC */
2134
#endif /* SK_USE_REV_DESC */
1620
	SK_U32  TxRes2;			/* 32 bit reserved field */
2135
	SK_U32  TxRes2;			/* 32 bit reserved field */
1621
} SK_HWTXD;
2136
} SK_HWTXD;
1622
2137
Lines 1628-1656 Link Here
1628
	SK_U32	RxAdrHi;		/* Physical Rx Buffer Address upper dword */
2143
	SK_U32	RxAdrHi;		/* Physical Rx Buffer Address upper dword */
1629
	SK_U32	RxStat;			/* Receive Frame Status Word */
2144
	SK_U32	RxStat;			/* Receive Frame Status Word */
1630
	SK_U32	RxTiSt;			/* Receive Time Stamp (from XMAC on GENESIS) */
2145
	SK_U32	RxTiSt;			/* Receive Time Stamp (from XMAC on GENESIS) */
1631
#ifndef	SK_USE_REV_DESC
2146
#ifndef SK_USE_REV_DESC
1632
	SK_U16	RxTcpSum1;		/* TCP Checksum 1 */
2147
	SK_U16	RxTcpSum1;		/* Rx TCP Checksum 1 */
1633
	SK_U16	RxTcpSum2;		/* TCP Checksum 2 */
2148
	SK_U16	RxTcpSum2;		/* Rx TCP Checksum 2 */
1634
	SK_U16	RxTcpSp1;		/* TCP Checksum Calculation Start Position 1 */
2149
	SK_U16	RxTcpSp1;		/* TCP Checksum Calculation Start Position 1 */
1635
	SK_U16	RxTcpSp2;		/* TCP Checksum Calculation Start Position 2 */
2150
	SK_U16	RxTcpSp2;		/* TCP Checksum Calculation Start Position 2 */
1636
#else	/* SK_USE_REV_DESC */
2151
#else  /* SK_USE_REV_DESC */
1637
	SK_U16	RxTcpSum2;		/* TCP Checksum 2 */
2152
	SK_U16	RxTcpSum2;		/* Rx TCP Checksum 2 */
1638
	SK_U16	RxTcpSum1;		/* TCP Checksum 1 */
2153
	SK_U16	RxTcpSum1;		/* Rx TCP Checksum 1 */
1639
	SK_U16	RxTcpSp2;		/* TCP Checksum Calculation Start Position 2 */
2154
	SK_U16	RxTcpSp2;		/* TCP Checksum Calculation Start Position 2 */
1640
	SK_U16	RxTcpSp1;		/* TCP Checksum Calculation Start Position 1 */
2155
	SK_U16	RxTcpSp1;		/* TCP Checksum Calculation Start Position 1 */
1641
#endif	/* SK_USE_REV_DESC */
2156
#endif /* SK_USE_REV_DESC */
1642
} SK_HWRXD;
2157
} SK_HWRXD;
1643
2158
1644
/*
2159
/*
1645
 * Drivers which use the reverse descriptor feature (PCI_OUR_REG_2)
2160
 * Drivers which use the reverse descriptor feature (PCI_OUR_REG_2)
1646
 * should set the define SK_USE_REV_DESC.
2161
 * should set the define SK_USE_REV_DESC.
1647
 * Structures are 'normaly' not endianess dependent. But in
2162
 * Structures are 'normally' not endianess dependent. But in this case
1648
 * this case the SK_U16 fields are bound to bit positions inside the
2163
 * the SK_U16 fields are bound to bit positions inside the descriptor.
1649
 * descriptor. RxTcpSum1 e.g. must start at bit 0 within the 6.th DWord.
2164
 * RxTcpSum1 e.g. must start at bit 0 within the 7.th DWord.
1650
 * The bit positions inside a DWord are of course endianess dependent and
2165
 * The bit positions inside a DWord are of course endianess dependent and
1651
 * swaps if the DWord is swapped by the hardware.
2166
 * swap if the DWord is swapped by the hardware.
1652
 */
2167
 */
1653
2168
2169
/* YUKON-2 descriptors ******************************************************/
2170
2171
typedef struct _TxChksum {
2172
#ifndef SK_USE_REV_DESC
2173
	SK_U16	TxTcpWp;		/* TCP Checksum Write Position */
2174
	SK_U16	TxTcpSp;		/* TCP Checksum Calculation Start Position */
2175
#else  /* SK_USE_REV_DESC */
2176
	SK_U16	TxTcpSp;		/* TCP Checksum Calculation Start Position */
2177
	SK_U16	TxTcpWp;		/* TCP Checksum Write Position */
2178
#endif /* SK_USE_REV_DESC */
2179
} SK_HWTXCS;
2180
2181
typedef struct _LargeSend {
2182
#ifndef SK_USE_REV_DESC
2183
	SK_U16 Length;		/* Large Send Segment Length */
2184
	SK_U16 Reserved;	/* reserved */
2185
#else  /* SK_USE_REV_DESC */
2186
	SK_U16 Reserved;	/* reserved */
2187
	SK_U16 Length;		/* Large Send Segment Length */
2188
#endif /* SK_USE_REV_DESC */
2189
} SK_HWTXLS;
2190
2191
typedef union u_HwTxBuf {
2192
	SK_U16	BufLen;		/* Tx Buffer Length */
2193
	SK_U16	VlanTag;	/* VLAN Tag */
2194
	SK_U16	InitCsum;	/* Init. Checksum */
2195
} SK_HWTXBUF;
2196
2197
/* Tx List Element structure */
2198
typedef struct s_HwLeTx {
2199
	union {
2200
		SK_U32	BufAddr;	/* Tx LE Buffer Address high/low */
2201
		SK_HWTXCS ChkSum;	/* Tx LE TCP Checksum parameters */
2202
		SK_HWTXLS LargeSend;/* Large Send length */
2203
	} TxUn;
2204
#ifndef SK_USE_REV_DESC
2205
	SK_HWTXBUF	Send;
2206
	SK_U8	ControlFlags;	/* Tx LE Control field or Lock Number */
2207
	SK_U8	Opcode;			/* Tx LE Opcode field */
2208
#else  /* SK_USE_REV_DESC */
2209
	SK_U8	Opcode;			/* Tx LE Opcode field */
2210
	SK_U8	ControlFlags;	/* Tx LE Control field or Lock Number */
2211
	SK_HWTXBUF	Send;
2212
#endif /* SK_USE_REV_DESC */
2213
} SK_HWLETX;
2214
2215
typedef struct _RxChkSum{
2216
#ifndef SK_USE_REV_DESC
2217
	SK_U16	RxTcpSp1;		/* TCP Checksum Calculation Start Position 1 */
2218
	SK_U16	RxTcpSp2;		/* TCP Checksum Calculation Start Position 2 */
2219
#else  /* SK_USE_REV_DESC */
2220
	SK_U16	RxTcpSp2;		/* TCP Checksum Calculation Start Position 2 */
2221
	SK_U16	RxTcpSp1;		/* TCP Checksum Calculation Start Position 1 */
2222
#endif /* SK_USE_REV_DESC */
2223
} SK_HWRXCS;
2224
2225
/* Rx List Element structure */
2226
typedef struct s_HwLeRx {
2227
	union {
2228
		SK_U32	BufAddr;	/* Rx LE Buffer Address high/low */
2229
		SK_HWRXCS ChkSum;	/* Rx LE TCP Checksum parameters */
2230
	} RxUn;
2231
#ifndef SK_USE_REV_DESC
2232
	SK_U16	BufferLength;	/* Rx LE Buffer Length field */
2233
	SK_U8	ControlFlags;	/* Rx LE Control field */
2234
	SK_U8	Opcode;			/* Rx LE Opcode field */
2235
#else  /* SK_USE_REV_DESC */
2236
	SK_U8	Opcode;			/* Rx LE Opcode field */
2237
	SK_U8	ControlFlags;	/* Rx LE Control field */
2238
	SK_U16	BufferLength;	/* Rx LE Buffer Length field */
2239
#endif /* SK_USE_REV_DESC */
2240
} SK_HWLERX;
2241
2242
typedef struct s_StRxTCPChkSum {
2243
#ifndef SK_USE_REV_DESC
2244
	SK_U16	RxTCPSum1;		/* Rx TCP Checksum 1 */
2245
	SK_U16	RxTCPSum2;		/* Rx TCP Checksum 2 */
2246
#else  /* SK_USE_REV_DESC */
2247
	SK_U16	RxTCPSum2;		/* Rx TCP Checksum 2 */
2248
	SK_U16	RxTCPSum1;		/* Rx TCP Checksum 1 */
2249
#endif /* SK_USE_REV_DESC */
2250
} SK_HWSTCS;
2251
2252
typedef struct s_StRxRssFlags {
2253
#ifndef SK_USE_REV_DESC
2254
	SK_U8	FlagField;		/* contains TCP and IP flags */
2255
	SK_U8	reserved;		/* reserved */
2256
#else  /* SK_USE_REV_DESC */
2257
	SK_U8	reserved;		/* reserved */
2258
	SK_U8	FlagField;		/* contains TCP and IP flags */
2259
#endif /* SK_USE_REV_DESC */
2260
} SK_HWSTRSS;
2261
2262
/* bit definition of RSS LE bit 32/33 (SK_HWSTRSS.FlagField) */
2263
								/* bit 7..2 reserved */
2264
#define RSS_TCP_FLAG	BIT_1S	/* RSS value related to TCP area */
2265
#define RSS_IP_FLAG		BIT_0S	/* RSS value related to IP area */
2266
/* StRxRssValue is valid if at least RSS_IP_FLAG is set. */
2267
/* For protocol errors or other protocols an empty RSS LE is generated. */
2268
2269
typedef union u_HwStBuf {
2270
	SK_U16	BufLen;		/* Rx Buffer Length */
2271
	SK_U16	VlanTag;	/* VLAN Tag */
2272
	SK_U16	StTxStatHi;	/* Tx Queue Status (high) */
2273
	SK_HWSTRSS	Rss;	/* Flag Field for TCP and IP protocol */
2274
} SK_HWSTBUF;
2275
2276
/* Status List Element structure */
2277
typedef struct s_HwLeSt {
2278
	union {
2279
		SK_U32	StRxStatWord;	/* Rx Status Dword */
2280
		SK_U32	StRxTimeStamp;	/* Rx Timestamp */
2281
		SK_HWSTCS StRxTCPCSum;	/* Rx TCP Checksum */
2282
		SK_U32	StTxStatLow;	/* Tx Queue Status (low) */
2283
		SK_U32	StRxRssValue;	/* Rx RSS value */
2284
	} StUn;
2285
#ifndef SK_USE_REV_DESC
2286
	SK_HWSTBUF	Stat;
2287
	SK_U8	Link;			/* Status LE Link field */
2288
	SK_U8	Opcode;			/* Status LE Opcode field */
2289
#else  /* SK_USE_REV_DESC */
2290
	SK_U8	Opcode;			/* Status LE Opcode field */
2291
	SK_U8	Link;			/* Status LE Link field */
2292
	SK_HWSTBUF	Stat;
2293
#endif /* SK_USE_REV_DESC */
2294
} SK_HWLEST;
2295
2296
/* Special Action List Element */
2297
typedef struct s_HwLeSa {
2298
#ifndef SK_USE_REV_DESC
2299
	SK_U16	TxAIdxVld;		/* Special Action LE TxA Put Index field */
2300
	SK_U16	TxSIdxVld;		/* Special Action LE TxS Put Index field */
2301
	SK_U16	RxIdxVld;		/* Special Action LE Rx Put Index field */
2302
	SK_U8	Link;			/* Special Action LE Link field */
2303
	SK_U8	Opcode;			/* Special Action LE Opcode field */
2304
#else  /* SK_USE_REV_DESC */
2305
	SK_U16	TxSIdxVld;		/* Special Action LE TxS Put Index field */
2306
	SK_U16	TxAIdxVld;		/* Special Action LE TxA Put Index field */
2307
	SK_U8	Opcode;			/* Special Action LE Opcode field */
2308
	SK_U8	Link;			/* Special Action LE Link field */
2309
	SK_U16	RxIdxVld;		/* Special Action LE Rx Put Index field */
2310
#endif /* SK_USE_REV_DESC */
2311
} SK_HWLESA;
2312
2313
/* Common List Element union */
2314
typedef union u_HwLeTxRxSt {
2315
	/* Transmit List Element Structure */
2316
	SK_HWLETX Tx;
2317
	/* Receive List Element Structure */
2318
	SK_HWLERX Rx;
2319
	/* Status List Element Structure */
2320
	SK_HWLEST St;
2321
	/* Special Action List Element Structure */
2322
	SK_HWLESA Sa;
2323
	/* Full List Element */
2324
	SK_U64 Full;
2325
} SK_HWLE;
2326
2327
/* mask and shift value to get Tx async queue status for port 1 */
2328
#define STLE_TXA1_MSKL		0x00000fff
2329
#define STLE_TXA1_SHIFTL	0
2330
2331
/* mask and shift value to get Tx sync queue status for port 1 */
2332
#define STLE_TXS1_MSKL		0x00fff000
2333
#define STLE_TXS1_SHIFTL	12
2334
2335
/* mask and shift value to get Tx async queue status for port 2 */
2336
#define STLE_TXA2_MSKL		0xff000000
2337
#define STLE_TXA2_SHIFTL	24
2338
#define STLE_TXA2_MSKH		0x000f
2339
/* this one shifts up */
2340
#define STLE_TXA2_SHIFTH	8
2341
2342
/* mask and shift value to get Tx sync queue status for port 2 */
2343
#define STLE_TXS2_MSKL		0x00000000
2344
#define STLE_TXS2_SHIFTL	0
2345
#define STLE_TXS2_MSKH		0xfff0
2346
#define STLE_TXS2_SHIFTH	4
2347
2348
/* YUKON-2 bit values */
2349
#define HW_OWNER		BIT_7
2350
#define SW_OWNER		0
2351
2352
#define PU_PUTIDX_VALID		BIT_12
2353
2354
/* YUKON-2 Control flags */
2355
#define UDPTCP			BIT_0S
2356
#define CALSUM			BIT_1S
2357
#define WR_SUM			BIT_2S
2358
#define INIT_SUM		BIT_3S
2359
#define LOCK_SUM		BIT_4S
2360
#define INS_VLAN		BIT_5S
2361
#define FRC_STAT		BIT_6S
2362
#define EOP				BIT_7S
2363
2364
#define TX_LOCK			BIT_8S
2365
#define BUF_SEND		BIT_9S
2366
#define PACKET_SEND		BIT_10S
2367
2368
#define NO_WARNING		BIT_14S
2369
#define NO_UPDATE		BIT_15S
2370
2371
/* YUKON-2 Rx/Tx opcodes defines */
2372
#define OP_TCPWRITE		0x11
2373
#define OP_TCPSTART		0x12
2374
#define OP_TCPINIT		0x14
2375
#define OP_TCPLCK		0x18
2376
#define OP_TCPCHKSUM	OP_TCPSTART
2377
#define OP_TCPIS		(OP_TCPINIT | OP_TCPSTART)
2378
#define OP_TCPLW		(OP_TCPLCK | OP_TCPWRITE)
2379
#define OP_TCPLSW		(OP_TCPLCK | OP_TCPSTART | OP_TCPWRITE)
2380
#define OP_TCPLISW		(OP_TCPLCK | OP_TCPINIT | OP_TCPSTART | OP_TCPWRITE)
2381
#define OP_ADDR64		0x21
2382
#define OP_VLAN		0x22
2383
#define OP_ADDR64VLAN	(OP_ADDR64 | OP_VLAN)
2384
#define OP_LRGLEN		0x24
2385
#define OP_LRGLENVLAN	(OP_LRGLEN | OP_VLAN)
2386
#define OP_BUFFER		0x40
2387
#define OP_PACKET		0x41
2388
#define OP_LARGESEND	0x43
2389
2390
/* YUKON-2 STATUS opcodes defines */
2391
#define OP_RXSTAT		0x60
2392
#define OP_RXTIMESTAMP	0x61
2393
#define OP_RXVLAN		0x62
2394
#define OP_RXCHKS		0x64
2395
#define OP_RXCHKSVLAN	(OP_RXCHKS | OP_RXVLAN)
2396
#define OP_RXTIMEVLAN	(OP_RXTIMESTAMP | OP_RXVLAN)
2397
#define OP_RSS_HASH		0x65
2398
#define OP_TXINDEXLE	0x68
2399
2400
/* YUKON-2 SPECIAL opcodes defines */
2401
#define OP_PUTIDX	0x70
1654
2402
1655
/* Descriptor Bit Definition */
2403
/* Descriptor Bit Definition */
1656
/*	TxCtrl		Transmit Buffer Control Field */
2404
/*	TxCtrl		Transmit Buffer Control Field */
Lines 1685-1690 Link Here
1685
2433
1686
/* macros ********************************************************************/
2434
/* macros ********************************************************************/
1687
2435
2436
/* Macro for accessing the key registers */
2437
#define RSS_KEY_ADDR(Port, KeyIndex)	\
2438
		((B4_RSS_KEY | ( ((Port) == 0) ? 0 : 0x80)) + (KeyIndex))
2439
1688
/* Receive and Transmit Queues */
2440
/* Receive and Transmit Queues */
1689
#define Q_R1	0x0000		/* Receive Queue 1 */
2441
#define Q_R1	0x0000		/* Receive Queue 1 */
1690
#define Q_R2	0x0080		/* Receive Queue 2 */
2442
#define Q_R2	0x0080		/* Receive Queue 2 */
Lines 1693-1698 Link Here
1693
#define Q_XS2	0x0300		/* Synchronous Transmit Queue 2 */
2445
#define Q_XS2	0x0300		/* Synchronous Transmit Queue 2 */
1694
#define Q_XA2	0x0380		/* Asynchronous Transmit Queue 2 */
2446
#define Q_XA2	0x0380		/* Asynchronous Transmit Queue 2 */
1695
2447
2448
#define Q_ASF_R1	0x100	/* ASF Rx Queue 1 */
2449
#define Q_ASF_R2	0x180	/* ASF Rx Queue 2 */
2450
#define Q_ASF_T1	0x140	/* ASF Tx Queue 1 */
2451
#define Q_ASF_T2	0x1c0	/* ASF Tx Queue 2 */
1696
/*
2452
/*
1697
 *	Macro Q_ADDR()
2453
 *	Macro Q_ADDR()
1698
 *
2454
 *
Lines 1704-1714 Link Here
1704
 *	Offs	Queue register offset.
2460
 *	Offs	Queue register offset.
1705
 *				Values: Q_D, Q_DA_L ... Q_T2, Q_T3
2461
 *				Values: Q_D, Q_DA_L ... Q_T2, Q_T3
1706
 *
2462
 *
1707
 * usage	SK_IN32(pAC, Q_ADDR(Q_R2, Q_BC), pVal)
2463
 * usage	SK_IN32(IoC, Q_ADDR(Q_R2, Q_BC), pVal)
1708
 */
2464
 */
1709
#define Q_ADDR(Queue, Offs)	(B8_Q_REGS + (Queue) + (Offs))
2465
#define Q_ADDR(Queue, Offs)	(B8_Q_REGS + (Queue) + (Offs))
1710
2466
1711
/*
2467
/*
2468
 *	Macro Y2_PREF_Q_ADDR()
2469
 *
2470
 *	Use this macro to access the Prefetch Units of the receive and
2471
 *	transmit queues of Yukon-2.
2472
 *
2473
 * para:	
2474
 *	Queue	Queue to access.
2475
 *				Values: Q_R1, Q_R2, Q_XS1, Q_XA1, Q_XS2, Q_XA2,
2476
 *	Offs	Queue register offset.
2477
 *				Values: PREF_UNIT_CTRL_REG ... PREF_UNIT_FIFO_LEV_REG
2478
 *
2479
 * usage	SK_IN16(IoC, Y2_Q_ADDR(Q_R2, PREF_UNIT_GET_IDX_REG), pVal)
2480
 */
2481
#define Y2_PREF_Q_ADDR(Queue, Offs)	(Y2_B8_PREF_REGS + (Queue) + (Offs))
2482
2483
/*
1712
 *	Macro RB_ADDR()
2484
 *	Macro RB_ADDR()
1713
 *
2485
 *
1714
 *	Use this macro to access the RAM Buffer Registers.
2486
 *	Use this macro to access the RAM Buffer Registers.
Lines 1719-1732 Link Here
1719
 *	Offs	Queue register offset.
2491
 *	Offs	Queue register offset.
1720
 *				Values: RB_START, RB_END ... RB_LEV, RB_CTRL
2492
 *				Values: RB_START, RB_END ... RB_LEV, RB_CTRL
1721
 *
2493
 *
1722
 * usage	SK_IN32(pAC, RB_ADDR(Q_R2, RB_RP), pVal)
2494
 * usage	SK_IN32(IoC, RB_ADDR(Q_R2, RB_RP), pVal)
1723
 */
2495
 */
1724
#define RB_ADDR(Queue, Offs)	(B16_RAM_REGS + (Queue) + (Offs))
2496
#define RB_ADDR(Queue, Offs)	(B16_RAM_REGS + (Queue) + (Offs))
1725
2497
1726
2498
1727
/* MAC Related Registers */
2499
/* MAC Related Registers */
1728
#define MAC_1		0	/* belongs to the port near the slot */
2500
#define MAC_1		0	/* 1st port */
1729
#define MAC_2		1	/* belongs to the port far away from the slot */
2501
#define MAC_2		1	/* 2nd port */
1730
2502
1731
/*
2503
/*
1732
 *	Macro MR_ADDR()
2504
 *	Macro MR_ADDR()
Lines 1740-1758 Link Here
1740
 *				Values: RX_MFF_EA, RX_MFF_WP ... LNK_LED_REG,
2512
 *				Values: RX_MFF_EA, RX_MFF_WP ... LNK_LED_REG,
1741
 *						TX_MFF_EA, TX_MFF_WP ... TX_LED_TST
2513
 *						TX_MFF_EA, TX_MFF_WP ... TX_LED_TST
1742
 *
2514
 *
1743
 * usage	SK_IN32(pAC, MR_ADDR(MAC_1, TX_MFF_EA), pVal)
2515
 * usage	SK_IN32(IoC, MR_ADDR(MAC_1, TX_MFF_EA), pVal)
1744
 */
2516
 */
1745
#define MR_ADDR(Mac, Offs)	(((Mac) << 7) + (Offs))
2517
#define MR_ADDR(Mac, Offs)	(((Mac) << 7) + (Offs))
1746
2518
1747
#ifdef	SK_LITTLE_ENDIAN
1748
#define XM_WORD_LO	0
1749
#define XM_WORD_HI	1
1750
#else	/* !SK_LITTLE_ENDIAN */
1751
#define XM_WORD_LO	1
1752
#define XM_WORD_HI	0
1753
#endif	/* !SK_LITTLE_ENDIAN */
1754
1755
1756
/*
2519
/*
1757
 * macros to access the XMAC (GENESIS only)
2520
 * macros to access the XMAC (GENESIS only)
1758
 *
2521
 *
Lines 1777-1798 Link Here
1777
#define XMA(Mac, Reg)									\
2540
#define XMA(Mac, Reg)									\
1778
	((BASE_XMAC_1 + (Mac) * (BASE_XMAC_2 - BASE_XMAC_1)) | ((Reg) << 1))
2541
	((BASE_XMAC_1 + (Mac) * (BASE_XMAC_2 - BASE_XMAC_1)) | ((Reg) << 1))
1779
2542
1780
#define XM_IN16(IoC, Mac, Reg, pVal)					\
2543
#define XM_IN16(IoC, Mac, Reg, pVal)	\
1781
	SK_IN16((IoC), XMA((Mac), (Reg)), (pVal))
2544
	SK_IN16(IoC, XMA(Mac, Reg), pVal)
2545
2546
#define XM_OUT16(IoC, Mac, Reg, Val)	\
2547
	SK_OUT16(IoC, XMA(Mac, Reg), Val)
2548
2549
#ifdef SK_LITTLE_ENDIAN
2550
2551
#define XM_IN32(IoC, Mac, Reg, pVal) {								\
2552
	SK_IN16(IoC, XMA(Mac, Reg), (SK_U16 SK_FAR *)(pVal));			\
2553
	SK_IN16(IoC, XMA(Mac, (Reg) + 2), (SK_U16 SK_FAR *)(pVal) + 1);	\
2554
}
1782
2555
1783
#define XM_OUT16(IoC, Mac, Reg, Val)					\
2556
#else  /* !SK_LITTLE_ENDIAN */
1784
	SK_OUT16((IoC), XMA((Mac), (Reg)), (Val))
1785
2557
1786
#define XM_IN32(IoC, Mac, Reg, pVal) {					\
2558
#define XM_IN32(IoC, Mac, Reg, pVal) {							\
1787
	SK_IN16((IoC), XMA((Mac), (Reg)),					\
2559
	SK_IN16(IoC, XMA(Mac, Reg), (SK_U16 SK_FAR *)(pVal) + 1);	\
1788
		(SK_U16 SK_FAR*)&((SK_U16 SK_FAR*)(pVal))[XM_WORD_LO]);		\
2560
	SK_IN16(IoC, XMA(Mac, (Reg) + 2), (SK_U16 SK_FAR *)(pVal));	\
1789
	SK_IN16((IoC), XMA((Mac), (Reg+2)),					\
1790
		(SK_U16 SK_FAR*)&((SK_U16 SK_FAR*)(pVal))[XM_WORD_HI]);		\
1791
}
2561
}
1792
2562
2563
#endif /* !SK_LITTLE_ENDIAN */
2564
1793
#define XM_OUT32(IoC, Mac, Reg, Val) {										\
2565
#define XM_OUT32(IoC, Mac, Reg, Val) {										\
1794
	SK_OUT16((IoC), XMA((Mac), (Reg)), (SK_U16)((Val) & 0xffffL));			\
2566
	SK_OUT16(IoC, XMA(Mac, Reg), (SK_U16)((Val) & 0xffffL));				\
1795
	SK_OUT16((IoC), XMA((Mac), (Reg+2)), (SK_U16)(((Val) >> 16) & 0xffffL));\
2567
	SK_OUT16(IoC, XMA(Mac, (Reg) + 2), (SK_U16)(((Val) >> 16) & 0xffffL));	\
1796
}
2568
}
1797
2569
1798
/* Remember: we are always writing to / reading from LITTLE ENDIAN memory */
2570
/* Remember: we are always writing to / reading from LITTLE ENDIAN memory */
Lines 1802-1814 Link Here
1802
	SK_U8	*pByte;										\
2574
	SK_U8	*pByte;										\
1803
	pByte = (SK_U8 *)&((SK_U8 *)(pVal))[0];				\
2575
	pByte = (SK_U8 *)&((SK_U8 *)(pVal))[0];				\
1804
	SK_IN16((IoC), XMA((Mac), (Reg)), &Word);			\
2576
	SK_IN16((IoC), XMA((Mac), (Reg)), &Word);			\
1805
	pByte[0] = (SK_U8)(Word  & 0x00ff);					\
2577
	pByte[0] = (SK_U8)(Word & 0x00ff);					\
1806
	pByte[1] = (SK_U8)((Word >> 8) & 0x00ff);			\
2578
	pByte[1] = (SK_U8)((Word >> 8) & 0x00ff);			\
1807
	SK_IN16((IoC), XMA((Mac), (Reg+2)), &Word);			\
2579
	SK_IN16((IoC), XMA((Mac), (Reg) + 2), &Word);		\
1808
	pByte[2] = (SK_U8)(Word  & 0x00ff);					\
2580
	pByte[2] = (SK_U8)(Word & 0x00ff);					\
1809
	pByte[3] = (SK_U8)((Word >> 8) & 0x00ff);			\
2581
	pByte[3] = (SK_U8)((Word >> 8) & 0x00ff);			\
1810
	SK_IN16((IoC), XMA((Mac), (Reg+4)), &Word);			\
2582
	SK_IN16((IoC), XMA((Mac), (Reg) + 4), &Word);		\
1811
	pByte[4] = (SK_U8)(Word  & 0x00ff);					\
2583
	pByte[4] = (SK_U8)(Word & 0x00ff);					\
1812
	pByte[5] = (SK_U8)((Word >> 8) & 0x00ff);			\
2584
	pByte[5] = (SK_U8)((Word >> 8) & 0x00ff);			\
1813
}
2585
}
1814
2586
Lines 1818-1827 Link Here
1818
	SK_OUT16((IoC), XMA((Mac), (Reg)), (SK_U16)			\
2590
	SK_OUT16((IoC), XMA((Mac), (Reg)), (SK_U16)			\
1819
		(((SK_U16)(pByte[0]) & 0x00ff) |				\
2591
		(((SK_U16)(pByte[0]) & 0x00ff) |				\
1820
		(((SK_U16)(pByte[1]) << 8) & 0xff00)));			\
2592
		(((SK_U16)(pByte[1]) << 8) & 0xff00)));			\
1821
	SK_OUT16((IoC), XMA((Mac), (Reg+2)), (SK_U16)		\
2593
	SK_OUT16((IoC), XMA((Mac), (Reg) + 2), (SK_U16)		\
1822
		(((SK_U16)(pByte[2]) & 0x00ff) |				\
2594
		(((SK_U16)(pByte[2]) & 0x00ff) |				\
1823
		(((SK_U16)(pByte[3]) << 8) & 0xff00)));			\
2595
		(((SK_U16)(pByte[3]) << 8) & 0xff00)));			\
1824
	SK_OUT16((IoC), XMA((Mac), (Reg+4)), (SK_U16)		\
2596
	SK_OUT16((IoC), XMA((Mac), (Reg) + 4), (SK_U16)		\
1825
		(((SK_U16)(pByte[4]) & 0x00ff) |				\
2597
		(((SK_U16)(pByte[4]) & 0x00ff) |				\
1826
		(((SK_U16)(pByte[5]) << 8) & 0xff00)));			\
2598
		(((SK_U16)(pByte[5]) << 8) & 0xff00)));			\
1827
}
2599
}
Lines 1831-1846 Link Here
1831
	SK_U8	SK_FAR *pByte;								\
2603
	SK_U8	SK_FAR *pByte;								\
1832
	pByte = (SK_U8 SK_FAR *)&((SK_U8 SK_FAR *)(pVal))[0];	\
2604
	pByte = (SK_U8 SK_FAR *)&((SK_U8 SK_FAR *)(pVal))[0];	\
1833
	SK_IN16((IoC), XMA((Mac), (Reg)), &Word);			\
2605
	SK_IN16((IoC), XMA((Mac), (Reg)), &Word);			\
1834
	pByte[0] = (SK_U8)(Word  & 0x00ff);					\
2606
	pByte[0] = (SK_U8)(Word & 0x00ff);					\
1835
	pByte[1] = (SK_U8)((Word >> 8) & 0x00ff);			\
2607
	pByte[1] = (SK_U8)((Word >> 8) & 0x00ff);			\
1836
	SK_IN16((IoC), XMA((Mac), (Reg+2)), &Word);			\
2608
	SK_IN16((IoC), XMA((Mac), (Reg) + 2), &Word);		\
1837
	pByte[2] = (SK_U8)(Word  & 0x00ff);					\
2609
	pByte[2] = (SK_U8)(Word & 0x00ff);					\
1838
	pByte[3] = (SK_U8)((Word >> 8) & 0x00ff);			\
2610
	pByte[3] = (SK_U8)((Word >> 8) & 0x00ff);			\
1839
	SK_IN16((IoC), XMA((Mac), (Reg+4)), &Word);			\
2611
	SK_IN16((IoC), XMA((Mac), (Reg) + 4), &Word);		\
1840
	pByte[4] = (SK_U8)(Word  & 0x00ff);					\
2612
	pByte[4] = (SK_U8)(Word & 0x00ff);					\
1841
	pByte[5] = (SK_U8)((Word >> 8) & 0x00ff);			\
2613
	pByte[5] = (SK_U8)((Word >> 8) & 0x00ff);			\
1842
	SK_IN16((IoC), XMA((Mac), (Reg+6)), &Word);			\
2614
	SK_IN16((IoC), XMA((Mac), (Reg) + 6), &Word);		\
1843
	pByte[6] = (SK_U8)(Word  & 0x00ff);					\
2615
	pByte[6] = (SK_U8)(Word & 0x00ff);					\
1844
	pByte[7] = (SK_U8)((Word >> 8) & 0x00ff);			\
2616
	pByte[7] = (SK_U8)((Word >> 8) & 0x00ff);			\
1845
}
2617
}
1846
2618
Lines 1850-1862 Link Here
1850
	SK_OUT16((IoC), XMA((Mac), (Reg)), (SK_U16)			\
2622
	SK_OUT16((IoC), XMA((Mac), (Reg)), (SK_U16)			\
1851
		(((SK_U16)(pByte[0]) & 0x00ff)|					\
2623
		(((SK_U16)(pByte[0]) & 0x00ff)|					\
1852
		(((SK_U16)(pByte[1]) << 8) & 0xff00)));			\
2624
		(((SK_U16)(pByte[1]) << 8) & 0xff00)));			\
1853
	SK_OUT16((IoC), XMA((Mac), (Reg+2)), (SK_U16)		\
2625
	SK_OUT16((IoC), XMA((Mac), (Reg) + 2), (SK_U16)		\
1854
		(((SK_U16)(pByte[2]) & 0x00ff)|					\
2626
		(((SK_U16)(pByte[2]) & 0x00ff)|					\
1855
		(((SK_U16)(pByte[3]) << 8) & 0xff00)));			\
2627
		(((SK_U16)(pByte[3]) << 8) & 0xff00)));			\
1856
	SK_OUT16((IoC), XMA((Mac), (Reg+4)), (SK_U16)		\
2628
	SK_OUT16((IoC), XMA((Mac), (Reg) + 4), (SK_U16)		\
1857
		(((SK_U16)(pByte[4]) & 0x00ff)|					\
2629
		(((SK_U16)(pByte[4]) & 0x00ff)|					\
1858
		(((SK_U16)(pByte[5]) << 8) & 0xff00)));			\
2630
		(((SK_U16)(pByte[5]) << 8) & 0xff00)));			\
1859
	SK_OUT16((IoC), XMA((Mac), (Reg+6)), (SK_U16)		\
2631
	SK_OUT16((IoC), XMA((Mac), (Reg) + 6), (SK_U16)		\
1860
		(((SK_U16)(pByte[6]) & 0x00ff)|					\
2632
		(((SK_U16)(pByte[6]) & 0x00ff)|					\
1861
		(((SK_U16)(pByte[7]) << 8) & 0xff00)));			\
2633
		(((SK_U16)(pByte[7]) << 8) & 0xff00)));			\
1862
}
2634
}
Lines 1866-1872 Link Here
1866
 *
2638
 *
1867
 * GM_IN16(),		to read  a 16 bit register (e.g. GM_GP_STAT)
2639
 * GM_IN16(),		to read  a 16 bit register (e.g. GM_GP_STAT)
1868
 * GM_OUT16(),		to write a 16 bit register (e.g. GM_GP_CTRL)
2640
 * GM_OUT16(),		to write a 16 bit register (e.g. GM_GP_CTRL)
1869
 * GM_IN32(),		to read  a 32 bit register (e.g. GM_)
2641
 * GM_IN32(),		to read  a 32 bit register (e.g. GM_RXF_UC_OK)
1870
 * GM_OUT32(),		to write a 32 bit register (e.g. GM_)
2642
 * GM_OUT32(),		to write a 32 bit register (e.g. GM_)
1871
 * GM_INADDR(),		to read  a network address register (e.g. GM_SRC_ADDR_1L)
2643
 * GM_INADDR(),		to read  a network address register (e.g. GM_SRC_ADDR_1L)
1872
 * GM_OUTADDR(),	to write a network address register (e.g. GM_SRC_ADDR_2L)
2644
 * GM_OUTADDR(),	to write a network address register (e.g. GM_SRC_ADDR_2L)
Lines 1885-1906 Link Here
1885
#define GMA(Mac, Reg)									\
2657
#define GMA(Mac, Reg)									\
1886
	((BASE_GMAC_1 + (Mac) * (BASE_GMAC_2 - BASE_GMAC_1)) | (Reg))
2658
	((BASE_GMAC_1 + (Mac) * (BASE_GMAC_2 - BASE_GMAC_1)) | (Reg))
1887
2659
1888
#define GM_IN16(IoC, Mac, Reg, pVal)					\
2660
#define GM_IN16(IoC, Mac, Reg, pVal)	\
1889
	SK_IN16((IoC), GMA((Mac), (Reg)), (pVal))
2661
	SK_IN16(IoC, GMA(Mac, Reg), pVal)
2662
2663
#define GM_OUT16(IoC, Mac, Reg, Val)	\
2664
	SK_OUT16(IoC, GMA(Mac, Reg), Val)
1890
2665
1891
#define GM_OUT16(IoC, Mac, Reg, Val)					\
2666
#ifdef SK_LITTLE_ENDIAN
1892
	SK_OUT16((IoC), GMA((Mac), (Reg)), (Val))
1893
2667
1894
#define GM_IN32(IoC, Mac, Reg, pVal) {					\
2668
#define GM_IN32(IoC, Mac, Reg, pVal) {									\
1895
	SK_IN16((IoC), GMA((Mac), (Reg)),					\
2669
	SK_IN16(IoC, GMA(Mac, Reg), (SK_U16 SK_FAR *)(pVal));				\
1896
		(SK_U16 SK_FAR*)&((SK_U16 SK_FAR*)(pVal))[XM_WORD_LO]);		\
2670
	SK_IN16((IoC), GMA(Mac, (Reg) + 4), (SK_U16 SK_FAR *)(pVal) + 1);	\
1897
	SK_IN16((IoC), GMA((Mac), (Reg+4)),					\
1898
		(SK_U16 SK_FAR*)&((SK_U16 SK_FAR*)(pVal))[XM_WORD_HI]);		\
1899
}
2671
}
1900
2672
2673
#else  /* !SK_LITTLE_ENDIAN */
2674
2675
#define GM_IN32(IoC, Mac, Reg, pVal) {							\
2676
	SK_IN16(IoC, GMA(Mac, Reg), (SK_U16 SK_FAR *)(pVal) + 1);	\
2677
	SK_IN16(IoC, GMA(Mac, (Reg) + 4), (SK_U16 SK_FAR *)(pVal));	\
2678
}
2679
2680
#endif /* !SK_LITTLE_ENDIAN */
2681
1901
#define GM_OUT32(IoC, Mac, Reg, Val) {										\
2682
#define GM_OUT32(IoC, Mac, Reg, Val) {										\
1902
	SK_OUT16((IoC), GMA((Mac), (Reg)), (SK_U16)((Val) & 0xffffL));			\
2683
	SK_OUT16(IoC, GMA(Mac, Reg), (SK_U16)((Val) & 0xffffL));				\
1903
	SK_OUT16((IoC), GMA((Mac), (Reg+4)), (SK_U16)(((Val) >> 16) & 0xffffL));\
2684
	SK_OUT16(IoC, GMA(Mac, (Reg) + 4), (SK_U16)(((Val) >> 16) & 0xffffL));	\
1904
}
2685
}
1905
2686
1906
#define GM_INADDR(IoC, Mac, Reg, pVal) {				\
2687
#define GM_INADDR(IoC, Mac, Reg, pVal) {				\
Lines 1908-1920 Link Here
1908
	SK_U8	*pByte;										\
2689
	SK_U8	*pByte;										\
1909
	pByte = (SK_U8 *)&((SK_U8 *)(pVal))[0];				\
2690
	pByte = (SK_U8 *)&((SK_U8 *)(pVal))[0];				\
1910
	SK_IN16((IoC), GMA((Mac), (Reg)), &Word);			\
2691
	SK_IN16((IoC), GMA((Mac), (Reg)), &Word);			\
1911
	pByte[0] = (SK_U8)(Word  & 0x00ff);					\
2692
	pByte[0] = (SK_U8)(Word & 0x00ff);					\
1912
	pByte[1] = (SK_U8)((Word >> 8) & 0x00ff);			\
2693
	pByte[1] = (SK_U8)((Word >> 8) & 0x00ff);			\
1913
	SK_IN16((IoC), GMA((Mac), (Reg+4)), &Word);			\
2694
	SK_IN16((IoC), GMA((Mac), (Reg) + 4), &Word);		\
1914
	pByte[2] = (SK_U8)(Word  & 0x00ff);					\
2695
	pByte[2] = (SK_U8)(Word & 0x00ff);					\
1915
	pByte[3] = (SK_U8)((Word >> 8) & 0x00ff);			\
2696
	pByte[3] = (SK_U8)((Word >> 8) & 0x00ff);			\
1916
	SK_IN16((IoC), GMA((Mac), (Reg+8)), &Word);			\
2697
	SK_IN16((IoC), GMA((Mac), (Reg) + 8), &Word);		\
1917
	pByte[4] = (SK_U8)(Word  & 0x00ff);					\
2698
	pByte[4] = (SK_U8)(Word & 0x00ff);					\
1918
	pByte[5] = (SK_U8)((Word >> 8) & 0x00ff);			\
2699
	pByte[5] = (SK_U8)((Word >> 8) & 0x00ff);			\
1919
}
2700
}
1920
2701
Lines 1924-1933 Link Here
1924
	SK_OUT16((IoC), GMA((Mac), (Reg)), (SK_U16)			\
2705
	SK_OUT16((IoC), GMA((Mac), (Reg)), (SK_U16)			\
1925
		(((SK_U16)(pByte[0]) & 0x00ff) |				\
2706
		(((SK_U16)(pByte[0]) & 0x00ff) |				\
1926
		(((SK_U16)(pByte[1]) << 8) & 0xff00)));			\
2707
		(((SK_U16)(pByte[1]) << 8) & 0xff00)));			\
1927
	SK_OUT16((IoC), GMA((Mac), (Reg+4)), (SK_U16)		\
2708
	SK_OUT16((IoC), GMA((Mac), (Reg) + 4), (SK_U16)		\
1928
		(((SK_U16)(pByte[2]) & 0x00ff) |				\
2709
		(((SK_U16)(pByte[2]) & 0x00ff) |				\
1929
		(((SK_U16)(pByte[3]) << 8) & 0xff00)));			\
2710
		(((SK_U16)(pByte[3]) << 8) & 0xff00)));			\
1930
	SK_OUT16((IoC), GMA((Mac), (Reg+8)), (SK_U16)		\
2711
	SK_OUT16((IoC), GMA((Mac), (Reg) + 8), (SK_U16)		\
1931
		(((SK_U16)(pByte[4]) & 0x00ff) |				\
2712
		(((SK_U16)(pByte[4]) & 0x00ff) |				\
1932
		(((SK_U16)(pByte[5]) << 8) & 0xff00)));			\
2713
		(((SK_U16)(pByte[5]) << 8) & 0xff00)));			\
1933
}
2714
}
Lines 1937-1952 Link Here
1937
	SK_U8	*pByte;										\
2718
	SK_U8	*pByte;										\
1938
	pByte = (SK_U8 *)&((SK_U8 *)(pVal))[0];				\
2719
	pByte = (SK_U8 *)&((SK_U8 *)(pVal))[0];				\
1939
	SK_IN16((IoC), GMA((Mac), (Reg)), &Word);			\
2720
	SK_IN16((IoC), GMA((Mac), (Reg)), &Word);			\
1940
	pByte[0] = (SK_U8)(Word  & 0x00ff);					\
2721
	pByte[0] = (SK_U8)(Word & 0x00ff);					\
1941
	pByte[1] = (SK_U8)((Word >> 8) & 0x00ff);			\
2722
	pByte[1] = (SK_U8)((Word >> 8) & 0x00ff);			\
1942
	SK_IN16((IoC), GMA((Mac), (Reg+4)), &Word);			\
2723
	SK_IN16((IoC), GMA((Mac), (Reg) + 4), &Word);		\
1943
	pByte[2] = (SK_U8)(Word  & 0x00ff);					\
2724
	pByte[2] = (SK_U8)(Word & 0x00ff);					\
1944
	pByte[3] = (SK_U8)((Word >> 8) & 0x00ff);			\
2725
	pByte[3] = (SK_U8)((Word >> 8) & 0x00ff);			\
1945
	SK_IN16((IoC), GMA((Mac), (Reg+8)), &Word);			\
2726
	SK_IN16((IoC), GMA((Mac), (Reg) + 8), &Word);		\
1946
	pByte[4] = (SK_U8)(Word  & 0x00ff);					\
2727
	pByte[4] = (SK_U8)(Word & 0x00ff);					\
1947
	pByte[5] = (SK_U8)((Word >> 8) & 0x00ff);			\
2728
	pByte[5] = (SK_U8)((Word >> 8) & 0x00ff);			\
1948
	SK_IN16((IoC), GMA((Mac), (Reg+12)), &Word);		\
2729
	SK_IN16((IoC), GMA((Mac), (Reg) + 12), &Word);		\
1949
	pByte[6] = (SK_U8)(Word  & 0x00ff);					\
2730
	pByte[6] = (SK_U8)(Word & 0x00ff);					\
1950
	pByte[7] = (SK_U8)((Word >> 8) & 0x00ff);			\
2731
	pByte[7] = (SK_U8)((Word >> 8) & 0x00ff);			\
1951
}
2732
}
1952
2733
Lines 1956-1968 Link Here
1956
	SK_OUT16((IoC), GMA((Mac), (Reg)), (SK_U16)			\
2737
	SK_OUT16((IoC), GMA((Mac), (Reg)), (SK_U16)			\
1957
		(((SK_U16)(pByte[0]) & 0x00ff)|					\
2738
		(((SK_U16)(pByte[0]) & 0x00ff)|					\
1958
		(((SK_U16)(pByte[1]) << 8) & 0xff00)));			\
2739
		(((SK_U16)(pByte[1]) << 8) & 0xff00)));			\
1959
	SK_OUT16((IoC), GMA((Mac), (Reg+4)), (SK_U16)		\
2740
	SK_OUT16((IoC), GMA((Mac), (Reg) + 4), (SK_U16)		\
1960
		(((SK_U16)(pByte[2]) & 0x00ff)|					\
2741
		(((SK_U16)(pByte[2]) & 0x00ff)|					\
1961
		(((SK_U16)(pByte[3]) << 8) & 0xff00)));			\
2742
		(((SK_U16)(pByte[3]) << 8) & 0xff00)));			\
1962
	SK_OUT16((IoC), GMA((Mac), (Reg+8)), (SK_U16)		\
2743
	SK_OUT16((IoC), GMA((Mac), (Reg) + 8), (SK_U16)		\
1963
		(((SK_U16)(pByte[4]) & 0x00ff)|					\
2744
		(((SK_U16)(pByte[4]) & 0x00ff)|					\
1964
		(((SK_U16)(pByte[5]) << 8) & 0xff00)));			\
2745
		(((SK_U16)(pByte[5]) << 8) & 0xff00)));			\
1965
	SK_OUT16((IoC), GMA((Mac), (Reg+12)), (SK_U16)		\
2746
	SK_OUT16((IoC), GMA((Mac), (Reg) + 12), (SK_U16)	\
1966
		(((SK_U16)(pByte[6]) & 0x00ff)|					\
2747
		(((SK_U16)(pByte[6]) & 0x00ff)|					\
1967
		(((SK_U16)(pByte[7]) << 8) & 0xff00)));			\
2748
		(((SK_U16)(pByte[7]) << 8) & 0xff00)));			\
1968
}
2749
}
Lines 2010-2039 Link Here
2010
 *
2791
 *
2011
 * usage:	PHY_READ(IoC, pPort, MAC_1, PHY_CTRL, Value);
2792
 * usage:	PHY_READ(IoC, pPort, MAC_1, PHY_CTRL, Value);
2012
 * Warning: a PHY_READ on an uninitialized PHY (PHY still in reset) never
2793
 * Warning: a PHY_READ on an uninitialized PHY (PHY still in reset) never
2013
 *          comes back. This is checked in DEBUG mode.
2794
 *	comes back. This is checked in DEBUG mode.
2014
 */
2795
 */
2015
#ifndef DEBUG
2796
#ifndef DEBUG
2016
#define PHY_READ(IoC, pPort, Mac, PhyReg, pVal) {						\
2797
#define PHY_READ(IoC, pPort, Mac, PhyReg, pVal) {						\
2017
	SK_U16 Mmu;  														\
2798
	SK_U16 Mmu;															\
2018
																		\
2799
																		\
2019
	XM_OUT16((IoC), (Mac), XM_PHY_ADDR, (PhyReg) | (pPort)->PhyAddr);	\
2800
	XM_OUT16((IoC), (Mac), XM_PHY_ADDR, (PhyReg) | (pPort)->PhyAddr);	\
2020
	XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal));							\
2801
	XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal));							\
2021
	if ((pPort)->PhyType != SK_PHY_XMAC) {								\
2802
	if ((pPort)->PhyType != SK_PHY_XMAC) {								\
2022
		do {  															\
2803
		do {															\
2023
			XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu);					\
2804
			XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu);					\
2024
		} while ((Mmu & XM_MMU_PHY_RDY) == 0);							\
2805
		} while ((Mmu & XM_MMU_PHY_RDY) == 0);							\
2025
		XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal));						\
2806
		XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal));						\
2026
	}  																	\
2807
	}																	\
2027
}
2808
}
2028
#else
2809
#else
2029
#define PHY_READ(IoC, pPort, Mac, PhyReg, pVal) {						\
2810
#define PHY_READ(IoC, pPort, Mac, PhyReg, pVal) {						\
2030
	SK_U16 Mmu;  														\
2811
	SK_U16 Mmu;															\
2031
	int __i = 0;														\
2812
	int __i = 0;														\
2032
																		\
2813
																		\
2033
	XM_OUT16((IoC), (Mac), XM_PHY_ADDR, (PhyReg) | (pPort)->PhyAddr);	\
2814
	XM_OUT16((IoC), (Mac), XM_PHY_ADDR, (PhyReg) | (pPort)->PhyAddr);	\
2034
	XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal));							\
2815
	XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal));							\
2035
	if ((pPort)->PhyType != SK_PHY_XMAC) {								\
2816
	if ((pPort)->PhyType != SK_PHY_XMAC) {								\
2036
		do {  															\
2817
		do {															\
2037
			XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu);					\
2818
			XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu);					\
2038
			__i++;														\
2819
			__i++;														\
2039
			if (__i > 100000) {											\
2820
			if (__i > 100000) {											\
Lines 2044-2050 Link Here
2044
			}															\
2825
			}															\
2045
		} while ((Mmu & XM_MMU_PHY_RDY) == 0);							\
2826
		} while ((Mmu & XM_MMU_PHY_RDY) == 0);							\
2046
		XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal));						\
2827
		XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal));						\
2047
	}  																	\
2828
	}																	\
2048
}
2829
}
2049
#endif /* DEBUG */
2830
#endif /* DEBUG */
2050
2831
Lines 2052-2068 Link Here
2052
	SK_U16 Mmu;															\
2833
	SK_U16 Mmu;															\
2053
																		\
2834
																		\
2054
	if ((pPort)->PhyType != SK_PHY_XMAC) {								\
2835
	if ((pPort)->PhyType != SK_PHY_XMAC) {								\
2055
		do {  															\
2836
		do {															\
2056
			XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu);					\
2837
			XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu);					\
2057
		} while ((Mmu & XM_MMU_PHY_BUSY) != 0);							\
2838
		} while ((Mmu & XM_MMU_PHY_BUSY) != 0);							\
2058
	}  																	\
2839
	}																	\
2059
	XM_OUT16((IoC), (Mac), XM_PHY_ADDR, (PhyReg) | (pPort)->PhyAddr);	\
2840
	XM_OUT16((IoC), (Mac), XM_PHY_ADDR, (PhyReg) | (pPort)->PhyAddr);	\
2060
	XM_OUT16((IoC), (Mac), XM_PHY_DATA, (Val));							\
2841
	XM_OUT16((IoC), (Mac), XM_PHY_DATA, (Val));							\
2061
	if ((pPort)->PhyType != SK_PHY_XMAC) {								\
2842
	if ((pPort)->PhyType != SK_PHY_XMAC) {								\
2062
		do {  															\
2843
		do {															\
2063
			XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu);					\
2844
			XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu);					\
2064
		} while ((Mmu & XM_MMU_PHY_BUSY) != 0);							\
2845
		} while ((Mmu & XM_MMU_PHY_BUSY) != 0);							\
2065
	}  																	\
2846
	}																	\
2066
}
2847
}
2067
2848
2068
/*
2849
/*
Lines 2071-2082 Link Here
2071
 *	Use this macro to access PCI config register from the I/O space.
2852
 *	Use this macro to access PCI config register from the I/O space.
2072
 *
2853
 *
2073
 * para:
2854
 * para:
2855
 *	pAC		Pointer to adapter context
2074
 *	Addr	PCI configuration register to access.
2856
 *	Addr	PCI configuration register to access.
2075
 *			Values:	PCI_VENDOR_ID ... PCI_VPD_ADR_REG,
2857
 *			Values:	PCI_VENDOR_ID ... PCI_VPD_ADR_REG,
2076
 *
2858
 *
2077
 * usage	SK_IN16(pAC, PCI_C(PCI_VENDOR_ID), pVal);
2859
 * usage	SK_IN16(IoC, PCI_C(pAC, PCI_VENDOR_ID), pVal);
2078
 */
2860
 */
2079
#define PCI_C(Addr)	(B7_CFG_SPC + (Addr))	/* PCI Config Space */
2861
#define PCI_C(p, Addr)		\
2862
	(((CHIP_ID_YUKON_2(p)) ? Y2_CFG_SPC : B7_CFG_SPC) + (Addr))
2080
2863
2081
/*
2864
/*
2082
 *	Macro SK_HW_ADDR(Base, Addr)
2865
 *	Macro SK_HW_ADDR(Base, Addr)
Lines 2088-2094 Link Here
2088
 *	Addr	Address offset
2871
 *	Addr	Address offset
2089
 *
2872
 *
2090
 * usage:	May be used in SK_INxx and SK_OUTxx macros
2873
 * usage:	May be used in SK_INxx and SK_OUTxx macros
2091
 *		#define SK_IN8(pAC, Addr, pVal) ...\
2874
 *		#define SK_IN8(IoC, Addr, pVal) ...\
2092
 *			*pVal = (SK_U8)inp(SK_HW_ADDR(pAC->Hw.Iop, Addr)))
2875
 *			*pVal = (SK_U8)inp(SK_HW_ADDR(pAC->Hw.Iop, Addr)))
2093
 */
2876
 */
2094
#ifdef SK_MEM_MAPPED_IO
2877
#ifdef SK_MEM_MAPPED_IO
Lines 2107-2118 Link Here
2107
 * para:
2890
 * para:
2108
 *	pAC		Pointer to adapter context struct
2891
 *	pAC		Pointer to adapter context struct
2109
 *	IoC		I/O context needed for SK I/O macros
2892
 *	IoC		I/O context needed for SK I/O macros
2110
 *  Port	Port number
2893
 *	Port	Port number
2111
 *	Mode	Mode to set for this LED
2894
 *	Mode	Mode to set for this LED
2112
 */
2895
 */
2113
#define SK_HWAC_LINK_LED(pAC, IoC, Port, Mode) \
2896
#define SK_HWAC_LINK_LED(pAC, IoC, Port, Mode) \
2114
	SK_OUT8(IoC, MR_ADDR(Port, LNK_LED_REG), Mode);
2897
	SK_OUT8(IoC, MR_ADDR(Port, LNK_LED_REG), Mode);
2115
2898
2899
#define SK_SET_GP_IO(IoC, Bit) {	\
2900
	SK_U32	DWord;					\
2901
	SK_IN32(IoC, B2_GP_IO, &DWord);	\
2902
	DWord |= ((GP_DIR_0 | GP_IO_0) << (Bit));\
2903
	SK_OUT32(IoC, B2_GP_IO, DWord);	\
2904
}
2905
2906
#define SK_CLR_GP_IO(IoC, Bit) {	\
2907
	SK_U32	DWord;					\
2908
	SK_IN32(IoC, B2_GP_IO, &DWord);	\
2909
	DWord &= ~((GP_DIR_0 | GP_IO_0) << (Bit));\
2910
	SK_OUT32(IoC, B2_GP_IO, DWord);	\
2911
}
2912
2913
#define SK_GE_PCI_FIFO_SIZE		1600	/* PCI FIFO Size */
2116
2914
2117
/* typedefs *******************************************************************/
2915
/* typedefs *******************************************************************/
2118
2916
Lines 2124-2126 Link Here
2124
#endif	/* __cplusplus */
2922
#endif	/* __cplusplus */
2125
2923
2126
#endif	/* __INC_SKGEHW_H */
2924
#endif	/* __INC_SKGEHW_H */
2925
(-)linux/drivers/net/sk98lin/h/skgehwt.h (-2 / +2 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skhwt.h
3
 * Name:	skhwt.h
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
5
 * Version:	$Revision: 1.7 $
5
 * Version:	$Revision: 2.1 $
6
 * Date:	$Date: 2003/09/16 12:55:08 $
6
 * Date:	$Date: 2003/10/27 14:16:09 $
7
 * Purpose:	Defines for the hardware timer functions
7
 * Purpose:	Defines for the hardware timer functions
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/h/skgei2c.h (-210 lines)
Lines 1-210 Link Here
1
/******************************************************************************
2
 *
3
 * Name:	skgei2c.h
4
 * Project:	Gigabit Ethernet Adapters, TWSI-Module
5
 * Version:	$Revision: 1.25 $
6
 * Date:	$Date: 2003/10/20 09:06:05 $
7
 * Purpose:	Special defines for TWSI
8
 *
9
 ******************************************************************************/
10
11
/******************************************************************************
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
22
 *
23
 ******************************************************************************/
24
25
/*
26
 * SKGEI2C.H	contains all SK-98xx specific defines for the TWSI handling
27
 */
28
29
#ifndef _INC_SKGEI2C_H_
30
#define _INC_SKGEI2C_H_
31
32
/*
33
 * Macros to access the B2_I2C_CTRL
34
 */
35
#define SK_I2C_CTL(IoC, flag, dev, dev_size, reg, burst) \
36
	SK_OUT32(IoC, B2_I2C_CTRL,\
37
		(flag ? 0x80000000UL : 0x0L) | \
38
		(((SK_U32)reg << 16) & I2C_ADDR) | \
39
		(((SK_U32)dev << 9) & I2C_DEV_SEL) | \
40
		(dev_size & I2C_DEV_SIZE) | \
41
		((burst << 4) & I2C_BURST_LEN))
42
43
#define SK_I2C_STOP(IoC) {				\
44
	SK_U32	I2cCtrl;				\
45
	SK_IN32(IoC, B2_I2C_CTRL, &I2cCtrl);		\
46
	SK_OUT32(IoC, B2_I2C_CTRL, I2cCtrl | I2C_STOP);	\
47
}
48
49
#define SK_I2C_GET_CTL(IoC, pI2cCtrl)	SK_IN32(IoC, B2_I2C_CTRL, pI2cCtrl)
50
51
/*
52
 * Macros to access the TWSI SW Registers
53
 */
54
#define SK_I2C_SET_BIT(IoC, SetBits) {			\
55
	SK_U8	OrgBits;				\
56
	SK_IN8(IoC, B2_I2C_SW, &OrgBits);		\
57
	SK_OUT8(IoC, B2_I2C_SW, OrgBits | (SK_U8)(SetBits));	\
58
}
59
60
#define SK_I2C_CLR_BIT(IoC, ClrBits) {			\
61
	SK_U8	OrgBits;				\
62
	SK_IN8(IoC, B2_I2C_SW, &OrgBits);		\
63
	SK_OUT8(IoC, B2_I2C_SW, OrgBits & ~((SK_U8)(ClrBits)));	\
64
}
65
66
#define SK_I2C_GET_SW(IoC, pI2cSw)	SK_IN8(IoC, B2_I2C_SW, pI2cSw)
67
68
/*
69
 * define the possible sensor states
70
 */
71
#define	SK_SEN_IDLE		0	/* Idle: sensor not read */
72
#define	SK_SEN_VALUE	1	/* Value Read cycle */
73
#define	SK_SEN_VALEXT	2	/* Extended Value Read cycle */
74
75
/*
76
 * Conversion factor to convert read Voltage sensor to milli Volt
77
 * Conversion factor to convert read Temperature sensor to 10th degree Celsius
78
 */
79
#define	SK_LM80_VT_LSB		22	/* 22mV LSB resolution */
80
#define	SK_LM80_TEMP_LSB	10	/* 1 degree LSB resolution */
81
#define	SK_LM80_TEMPEXT_LSB	 5	/* 0.5 degree LSB resolution for ext. val. */
82
83
/*
84
 * formula: counter = (22500*60)/(rpm * divisor * pulses/2)
85
 * assuming: 6500rpm, 4 pulses, divisor 1
86
 */
87
#define SK_LM80_FAN_FAKTOR	((22500L*60)/(1*2))
88
89
/*
90
 * Define sensor management data
91
 * Maximum is reached on Genesis copper dual port and Yukon-64
92
 * Board specific maximum is in pAC->I2c.MaxSens
93
 */
94
#define	SK_MAX_SENSORS	8	/* maximal no. of installed sensors */
95
#define	SK_MIN_SENSORS	5	/* minimal no. of installed sensors */
96
97
/*
98
 * To watch the state machine (SM) use the timer in two ways
99
 * instead of one as hitherto
100
 */
101
#define	SK_TIMER_WATCH_SM		0	/* Watch the SM to finish in a spec. time */
102
#define	SK_TIMER_NEW_GAUGING	1	/* Start a new gauging when timer expires */
103
104
/*
105
 * Defines for the individual thresholds
106
 */
107
108
/* Temperature sensor */
109
#define	SK_SEN_TEMP_HIGH_ERR	800	/* Temperature High Err  Threshold */
110
#define	SK_SEN_TEMP_HIGH_WARN	700	/* Temperature High Warn Threshold */
111
#define	SK_SEN_TEMP_LOW_WARN	100	/* Temperature Low  Warn Threshold */
112
#define	SK_SEN_TEMP_LOW_ERR		  0	/* Temperature Low  Err  Threshold */
113
114
/* VCC which should be 5 V */
115
#define	SK_SEN_PCI_5V_HIGH_ERR		5588	/* Voltage PCI High Err  Threshold */
116
#define	SK_SEN_PCI_5V_HIGH_WARN		5346	/* Voltage PCI High Warn Threshold */
117
#define	SK_SEN_PCI_5V_LOW_WARN		4664	/* Voltage PCI Low  Warn Threshold */
118
#define	SK_SEN_PCI_5V_LOW_ERR		4422	/* Voltage PCI Low  Err  Threshold */
119
120
/*
121
 * VIO may be 5 V or 3.3 V. Initialization takes two parts:
122
 * 1. Initialize lowest lower limit and highest higher limit.
123
 * 2. After the first value is read correct the upper or the lower limit to
124
 *    the appropriate C constant.
125
 *
126
 * Warning limits are +-5% of the exepected voltage.
127
 * Error limits are +-10% of the expected voltage.
128
 */
129
130
/* Bug fix AF: 16.Aug.2001: Correct the init base of LM80 sensor */
131
132
#define	SK_SEN_PCI_IO_5V_HIGH_ERR	5566	/* + 10% V PCI-IO High Err Threshold */
133
#define	SK_SEN_PCI_IO_5V_HIGH_WARN	5324	/* +  5% V PCI-IO High Warn Threshold */
134
					/*		5000	mVolt */
135
#define	SK_SEN_PCI_IO_5V_LOW_WARN	4686	/* -  5% V PCI-IO Low Warn Threshold */
136
#define	SK_SEN_PCI_IO_5V_LOW_ERR	4444	/* - 10% V PCI-IO Low Err Threshold */
137
138
#define	SK_SEN_PCI_IO_RANGE_LIMITER	4000	/* 4000 mV range delimiter */
139
140
/* correction values for the second pass */
141
#define	SK_SEN_PCI_IO_3V3_HIGH_ERR	3850	/* + 15% V PCI-IO High Err Threshold */
142
#define	SK_SEN_PCI_IO_3V3_HIGH_WARN	3674	/* + 10% V PCI-IO High Warn Threshold */
143
					/*		3300	mVolt */
144
#define	SK_SEN_PCI_IO_3V3_LOW_WARN	2926	/* - 10% V PCI-IO Low Warn Threshold */
145
#define	SK_SEN_PCI_IO_3V3_LOW_ERR	2772	/* - 15% V PCI-IO Low Err  Threshold */
146
147
/*
148
 * VDD voltage
149
 */
150
#define	SK_SEN_VDD_HIGH_ERR		3630	/* Voltage ASIC High Err  Threshold */
151
#define	SK_SEN_VDD_HIGH_WARN	3476	/* Voltage ASIC High Warn Threshold */
152
#define	SK_SEN_VDD_LOW_WARN		3146	/* Voltage ASIC Low  Warn Threshold */
153
#define	SK_SEN_VDD_LOW_ERR		2970	/* Voltage ASIC Low  Err  Threshold */
154
155
/*
156
 * PHY PLL 3V3 voltage
157
 */
158
#define	SK_SEN_PLL_3V3_HIGH_ERR		3630	/* Voltage PMA High Err  Threshold */
159
#define	SK_SEN_PLL_3V3_HIGH_WARN	3476	/* Voltage PMA High Warn Threshold */
160
#define	SK_SEN_PLL_3V3_LOW_WARN		3146	/* Voltage PMA Low  Warn Threshold */
161
#define	SK_SEN_PLL_3V3_LOW_ERR		2970	/* Voltage PMA Low  Err  Threshold */
162
163
/*
164
 * VAUX (YUKON only)
165
 */
166
#define	SK_SEN_VAUX_3V3_HIGH_ERR	3630	/* Voltage VAUX High Err Threshold */
167
#define	SK_SEN_VAUX_3V3_HIGH_WARN	3476	/* Voltage VAUX High Warn Threshold */
168
#define	SK_SEN_VAUX_3V3_LOW_WARN	3146	/* Voltage VAUX Low Warn Threshold */
169
#define	SK_SEN_VAUX_3V3_LOW_ERR		2970	/* Voltage VAUX Low Err Threshold */
170
#define	SK_SEN_VAUX_0V_WARN_ERR		   0	/* if VAUX not present */
171
#define	SK_SEN_VAUX_RANGE_LIMITER	1000	/* 1000 mV range delimiter */
172
173
/*
174
 * PHY 2V5 voltage
175
 */
176
#define	SK_SEN_PHY_2V5_HIGH_ERR		2750	/* Voltage PHY High Err Threshold */
177
#define	SK_SEN_PHY_2V5_HIGH_WARN	2640	/* Voltage PHY High Warn Threshold */
178
#define	SK_SEN_PHY_2V5_LOW_WARN		2376	/* Voltage PHY Low Warn Threshold */
179
#define	SK_SEN_PHY_2V5_LOW_ERR		2222	/* Voltage PHY Low Err Threshold */
180
181
/*
182
 * ASIC Core 1V5 voltage (YUKON only)
183
 */
184
#define	SK_SEN_CORE_1V5_HIGH_ERR	1650	/* Voltage ASIC Core High Err Threshold */
185
#define	SK_SEN_CORE_1V5_HIGH_WARN	1575	/* Voltage ASIC Core High Warn Threshold */
186
#define	SK_SEN_CORE_1V5_LOW_WARN	1425	/* Voltage ASIC Core Low Warn Threshold */
187
#define	SK_SEN_CORE_1V5_LOW_ERR 	1350	/* Voltage ASIC Core Low Err Threshold */
188
189
/*
190
 * FAN 1 speed
191
 */
192
/* assuming: 6500rpm +-15%, 4 pulses,
193
 * warning at:	80 %
194
 * error at:	70 %
195
 * no upper limit
196
 */
197
#define	SK_SEN_FAN_HIGH_ERR		20000	/* FAN Speed High Err Threshold */
198
#define	SK_SEN_FAN_HIGH_WARN	20000	/* FAN Speed High Warn Threshold */
199
#define	SK_SEN_FAN_LOW_WARN		 5200	/* FAN Speed Low Warn Threshold */
200
#define	SK_SEN_FAN_LOW_ERR		 4550	/* FAN Speed Low Err Threshold */
201
202
/*
203
 * Some Voltages need dynamic thresholds
204
 */
205
#define	SK_SEN_DYN_INIT_NONE		 0  /* No dynamic init of thresholds */
206
#define	SK_SEN_DYN_INIT_PCI_IO		10  /* Init PCI-IO with new thresholds */
207
#define	SK_SEN_DYN_INIT_VAUX		11  /* Init VAUX with new thresholds */
208
209
extern	int SkLm80ReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
210
#endif	/* n_INC_SKGEI2C_H */
(-)linux/drivers/net/sk98lin/h/skgeinit.h (-87 / +282 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skgeinit.h
3
 * Name:	skgeinit.h
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.83 $
5
 * Version:	$Revision: 2.35 $
6
 * Date:	$Date: 2003/09/16 14:07:37 $
6
 * Date:	$Date: 2004/12/17 11:17:25 $
7
 * Purpose:	Structures and prototypes for the GE Init Module
7
 * Purpose:	Structures and prototypes for the GE Init Module
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-23 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
22
 *
21
 *
23
 ******************************************************************************/
22
 ******************************************************************************/
Lines 60-73 Link Here
60
#define SK_XMIT_DUR		0x002faf08UL	/*  50 ms */
59
#define SK_XMIT_DUR		0x002faf08UL	/*  50 ms */
61
#define SK_BLK_DUR		0x01dcd650UL	/* 500 ms */
60
#define SK_BLK_DUR		0x01dcd650UL	/* 500 ms */
62
61
63
#define SK_DPOLL_DEF	0x00ee6b28UL	/* 250 ms at 62.5 MHz */
62
#define SK_DPOLL_DEF	0x00ee6b28UL	/* 250 ms at 62.5 MHz (Genesis) */
63
#define SK_DPOLL_DEF_Y2	0x0000124fUL	/*  75 us (Yukon-2) */
64
64
65
#define SK_DPOLL_MAX	0x00ffffffUL	/* 268 ms at 62.5 MHz */
65
#define SK_DPOLL_MAX	0x00ffffffUL	/* 268 ms at 62.5 MHz */
66
										/* 215 ms at 78.12 MHz */
66
										/* 215 ms at 78.12 MHz (Yukon) */
67
67
68
#define SK_FACT_62		100			/* is given in percent */
68
#define SK_FACT_62		100			/* is given in percent */
69
#define SK_FACT_53		 85         /* on GENESIS:	53.12 MHz */
69
#define SK_FACT_53		 85			/* on GENESIS:	53.12 MHz */
70
#define SK_FACT_78		125			/* on YUKON:	78.12 MHz */
70
#define SK_FACT_78		125			/* on YUKON:	78.12 MHz */
71
#define SK_FACT_100		161			/* on YUKON-FE:	100 MHz */
72
#define SK_FACT_125		202			/* on YUKON-EC:	125 MHz */
71
73
72
/* Timeout values */
74
/* Timeout values */
73
#define SK_MAC_TO_53	72			/* MAC arbiter timeout */
75
#define SK_MAC_TO_53	72			/* MAC arbiter timeout */
Lines 83-92 Link Here
83
#define SK_RB_LLPP_B	(16 * 1024)	/* Lower Level for big Queues */
85
#define SK_RB_LLPP_B	(16 * 1024)	/* Lower Level for big Queues */
84
86
85
#ifndef SK_BMU_RX_WM
87
#ifndef SK_BMU_RX_WM
86
#define SK_BMU_RX_WM	0x600		/* BMU Rx Watermark */
88
#define SK_BMU_RX_WM		0x600	/* BMU Rx Watermark */
87
#endif
89
#endif
90
88
#ifndef SK_BMU_TX_WM
91
#ifndef SK_BMU_TX_WM
89
#define SK_BMU_TX_WM	0x600		/* BMU Tx Watermark */
92
#define SK_BMU_TX_WM		0x600	/* BMU Tx Watermark */
93
#endif
94
95
/* performance sensitive drivers should set this define to 0x80 */
96
#ifndef SK_BMU_RX_WM_PEX
97
#define SK_BMU_RX_WM_PEX	0x600	/* BMU Rx Watermark for PEX */
90
#endif
98
#endif
91
99
92
/* XMAC II Rx High Watermark */
100
/* XMAC II Rx High Watermark */
Lines 104-134 Link Here
104
#define SK_JUMBO_LINK	3		/* driver uses jumbo frames */
112
#define SK_JUMBO_LINK	3		/* driver uses jumbo frames */
105
113
106
/* Minimum RAM Buffer Rx Queue Size */
114
/* Minimum RAM Buffer Rx Queue Size */
107
#define SK_MIN_RXQ_SIZE	16		/* 16 kB */
115
#define SK_MIN_RXQ_SIZE	(((pAC)->GIni.GIYukon2) ? 10 : 16)		/* 10/16 kB */
108
116
109
/* Minimum RAM Buffer Tx Queue Size */
117
/* Minimum RAM Buffer Tx Queue Size */
110
#define SK_MIN_TXQ_SIZE	16		/* 16 kB */
118
#define SK_MIN_TXQ_SIZE	(((pAC)->GIni.GIYukon2) ? 10 : 16)		/* 10/16 kB */
111
119
112
/* Queue Size units */
120
/* Queue Size units (Genesis/Yukon) */
113
#define QZ_UNITS		0x7
121
#define QZ_UNITS		7
114
#define QZ_STEP			8
122
#define QZ_STEP			8
115
123
124
/* Queue Size units (Yukon-2) */
125
#define QZ_STEP_Y2		1
126
116
/* Percentage of queue size from whole memory */
127
/* Percentage of queue size from whole memory */
117
/* 80 % for receive */
128
/* 80 % for receive */
118
#define RAM_QUOTA_RX	80L
129
#define RAM_QUOTA_RX	80
119
/* 0% for sync transfer */
130
/*  0 % for sync transfer */
120
#define	RAM_QUOTA_SYNC	0L
131
#define RAM_QUOTA_SYNC	0
121
/* the rest (20%) is taken for async transfer */
132
/* the rest (20%) is taken for async transfer */
122
133
123
/* Get the rounded queue size in Bytes in 8k steps */
124
#define ROUND_QUEUE_SIZE(SizeInBytes)					\
125
	((((unsigned long) (SizeInBytes) + (QZ_STEP*1024L)-1) / 1024) &	\
126
	~(QZ_STEP-1))
127
128
/* Get the rounded queue size in KBytes in 8k steps */
129
#define ROUND_QUEUE_SIZE_KB(Kilobytes) \
130
	ROUND_QUEUE_SIZE((Kilobytes) * 1024L)
131
132
/* Types of RAM Buffer Queues */
134
/* Types of RAM Buffer Queues */
133
#define SK_RX_SRAM_Q	1	/* small receive queue */
135
#define SK_RX_SRAM_Q	1	/* small receive queue */
134
#define SK_RX_BRAM_Q	2	/* big receive queue */
136
#define SK_RX_BRAM_Q	2	/* big receive queue */
Lines 167-177 Link Here
167
169
168
170
169
/* Link Speed Capabilities */
171
/* Link Speed Capabilities */
170
#define SK_LSPEED_CAP_AUTO			(1<<0)	/* Automatic resolution */
172
#define SK_LSPEED_CAP_AUTO			BIT_0S	/* Automatic resolution */
171
#define SK_LSPEED_CAP_10MBPS		(1<<1)	/* 10 Mbps */
173
#define SK_LSPEED_CAP_10MBPS		BIT_1S	/* 10 Mbps */
172
#define SK_LSPEED_CAP_100MBPS		(1<<2)	/* 100 Mbps */
174
#define SK_LSPEED_CAP_100MBPS		BIT_2S	/* 100 Mbps */
173
#define SK_LSPEED_CAP_1000MBPS		(1<<3)	/* 1000 Mbps */
175
#define SK_LSPEED_CAP_1000MBPS		BIT_3S	/* 1000 Mbps */
174
#define SK_LSPEED_CAP_INDETERMINATED (1<<4) /* indeterminated */
176
#define SK_LSPEED_CAP_INDETERMINATED BIT_4S /* indeterminated */
175
177
176
/* Link Speed Parameter */
178
/* Link Speed Parameter */
177
#define SK_LSPEED_AUTO				1	/* Automatic resolution */
179
#define SK_LSPEED_AUTO				1	/* Automatic resolution */
Lines 189-199 Link Here
189
191
190
192
191
/* Link Capability Parameter */
193
/* Link Capability Parameter */
192
#define SK_LMODE_CAP_HALF		(1<<0)	/* Half Duplex Mode */
194
#define SK_LMODE_CAP_HALF		BIT_0S	/* Half Duplex Mode */
193
#define SK_LMODE_CAP_FULL		(1<<1)	/* Full Duplex Mode */
195
#define SK_LMODE_CAP_FULL		BIT_1S	/* Full Duplex Mode */
194
#define SK_LMODE_CAP_AUTOHALF	(1<<2)	/* AutoHalf Duplex Mode */
196
#define SK_LMODE_CAP_AUTOHALF	BIT_2S	/* AutoHalf Duplex Mode */
195
#define SK_LMODE_CAP_AUTOFULL	(1<<3)	/* AutoFull Duplex Mode */
197
#define SK_LMODE_CAP_AUTOFULL	BIT_3S	/* AutoFull Duplex Mode */
196
#define SK_LMODE_CAP_INDETERMINATED (1<<4) /* indeterminated */
198
#define SK_LMODE_CAP_INDETERMINATED BIT_4S /* indeterminated */
197
199
198
/* Link Mode Current State */
200
/* Link Mode Current State */
199
#define SK_LMODE_STAT_UNKNOWN	1	/* Unknown Duplex Mode */
201
#define SK_LMODE_STAT_UNKNOWN	1	/* Unknown Duplex Mode */
Lines 220-229 Link Here
220
#define SK_FLOW_STAT_INDETERMINATED 5	/* indeterminated */
222
#define SK_FLOW_STAT_INDETERMINATED 5	/* indeterminated */
221
223
222
/* Master/Slave Mode Capabilities */
224
/* Master/Slave Mode Capabilities */
223
#define SK_MS_CAP_AUTO		(1<<0)	/* Automatic resolution */
225
#define SK_MS_CAP_AUTO		BIT_0S	/* Automatic resolution */
224
#define SK_MS_CAP_MASTER	(1<<1)	/* This station is master */
226
#define SK_MS_CAP_MASTER	BIT_1S	/* This station is master */
225
#define SK_MS_CAP_SLAVE		(1<<2)	/* This station is slave */
227
#define SK_MS_CAP_SLAVE		BIT_2S	/* This station is slave */
226
#define SK_MS_CAP_INDETERMINATED (1<<3)	/* indeterminated */
228
#define SK_MS_CAP_INDETERMINATED BIT_3S	/* indeterminated */
227
229
228
/* Set Master/Slave Mode Parameter (and capabilities) */
230
/* Set Master/Slave Mode Parameter (and capabilities) */
229
#define SK_MS_MODE_AUTO		1	/* Automatic resolution */
231
#define SK_MS_MODE_AUTO		1	/* Automatic resolution */
Lines 239-262 Link Here
239
#define SK_MS_STAT_INDETERMINATED 5	/* indeterminated */
241
#define SK_MS_STAT_INDETERMINATED 5	/* indeterminated */
240
242
241
/* parameter 'Mode' when calling SkXmSetRxCmd() */
243
/* parameter 'Mode' when calling SkXmSetRxCmd() */
242
#define SK_STRIP_FCS_ON		(1<<0)	/* Enable  FCS stripping of Rx frames */
244
#define SK_STRIP_FCS_ON		BIT_0S	/* Enable  FCS stripping of Rx frames */
243
#define SK_STRIP_FCS_OFF	(1<<1)	/* Disable FCS stripping of Rx frames */
245
#define SK_STRIP_FCS_OFF	BIT_1S	/* Disable FCS stripping of Rx frames */
244
#define SK_STRIP_PAD_ON		(1<<2)	/* Enable  pad byte stripping of Rx fr */
246
#define SK_STRIP_PAD_ON		BIT_2S	/* Enable  pad byte stripping of Rx fr */
245
#define SK_STRIP_PAD_OFF	(1<<3)	/* Disable pad byte stripping of Rx fr */
247
#define SK_STRIP_PAD_OFF	BIT_3S	/* Disable pad byte stripping of Rx fr */
246
#define SK_LENERR_OK_ON		(1<<4)	/* Don't chk fr for in range len error */
248
#define SK_LENERR_OK_ON		BIT_4S	/* Don't chk fr for in range len error */
247
#define SK_LENERR_OK_OFF	(1<<5)	/* Check frames for in range len error */
249
#define SK_LENERR_OK_OFF	BIT_5S	/* Check frames for in range len error */
248
#define SK_BIG_PK_OK_ON		(1<<6)	/* Don't set Rx Error bit for big frames */
250
#define SK_BIG_PK_OK_ON		BIT_6S	/* Don't set Rx Error bit for big frames */
249
#define SK_BIG_PK_OK_OFF	(1<<7)	/* Set Rx Error bit for big frames */
251
#define SK_BIG_PK_OK_OFF	BIT_7S	/* Set Rx Error bit for big frames */
250
#define SK_SELF_RX_ON		(1<<8)	/* Enable  Rx of own packets */
252
#define SK_SELF_RX_ON		BIT_8S	/* Enable  Rx of own packets */
251
#define SK_SELF_RX_OFF		(1<<9)	/* Disable Rx of own packets */
253
#define SK_SELF_RX_OFF		BIT_9S	/* Disable Rx of own packets */
252
254
253
/* parameter 'Para' when calling SkMacSetRxTxEn() */
255
/* parameter 'Para' when calling SkMacSetRxTxEn() */
254
#define SK_MAC_LOOPB_ON		(1<<0)	/* Enable  MAC Loopback Mode */
256
#define SK_MAC_LOOPB_ON		BIT_0S	/* Enable  MAC Loopback Mode */
255
#define SK_MAC_LOOPB_OFF	(1<<1)	/* Disable MAC Loopback Mode */
257
#define SK_MAC_LOOPB_OFF	BIT_1S	/* Disable MAC Loopback Mode */
256
#define SK_PHY_LOOPB_ON		(1<<2)	/* Enable  PHY Loopback Mode */
258
#define SK_PHY_LOOPB_ON		BIT_2S	/* Enable  PHY Loopback Mode */
257
#define SK_PHY_LOOPB_OFF	(1<<3)	/* Disable PHY Loopback Mode */
259
#define SK_PHY_LOOPB_OFF	BIT_3S	/* Disable PHY Loopback Mode */
258
#define SK_PHY_FULLD_ON		(1<<4)	/* Enable  GMII Full Duplex */
260
#define SK_PHY_FULLD_ON		BIT_4S	/* Enable  GMII Full Duplex */
259
#define SK_PHY_FULLD_OFF	(1<<5)	/* Disable GMII Full Duplex */
261
#define SK_PHY_FULLD_OFF	BIT_5S	/* Disable GMII Full Duplex */
260
262
261
/* States of PState */
263
/* States of PState */
262
#define SK_PRT_RESET	0	/* the port is reset */
264
#define SK_PRT_RESET	0	/* the port is reset */
Lines 266-283 Link Here
266
268
267
/* PHY power down modes */
269
/* PHY power down modes */
268
#define PHY_PM_OPERATIONAL_MODE		0	/* PHY operational mode */
270
#define PHY_PM_OPERATIONAL_MODE		0	/* PHY operational mode */
269
#define PHY_PM_DEEP_SLEEP			1	/* coma mode --> minimal power */
271
#define PHY_PM_DEEP_SLEEP			1	/* Coma mode --> minimal power */
270
#define PHY_PM_IEEE_POWER_DOWN		2	/* IEEE 22.2.4.1.5 compl. power down */
272
#define PHY_PM_IEEE_POWER_DOWN		2	/* IEEE 22.2.4.1.5 compl. power down */
271
#define PHY_PM_ENERGY_DETECT		3	/* energy detect */
273
#define PHY_PM_ENERGY_DETECT		3	/* Energy detect */
272
#define PHY_PM_ENERGY_DETECT_PLUS	4	/* energy detect plus */
274
#define PHY_PM_ENERGY_DETECT_PLUS	4	/* Energy detect plus */
275
276
/* PCI Bus Types */
277
#define SK_PCI_BUS		BIT_0S		/* normal PCI bus */
278
#define SK_PCIX_BUS		BIT_1S		/* PCI-X bus */
279
#define SK_PEX_BUS		BIT_2S		/* PCI-Express bus */
273
280
274
/* Default receive frame limit for Workaround of XMAC Errata */
281
/* Default receive frame limit for Workaround of XMAC Errata */
275
#define SK_DEF_RX_WA_LIM	SK_CONSTU64(100)
282
#define SK_DEF_RX_WA_LIM	SK_CONSTU64(100)
276
283
277
/* values for GILedBlinkCtrl (LED Blink Control) */
284
/* values for GILedBlinkCtrl (LED Blink Control) */
278
#define SK_ACT_LED_BLINK	(1<<0)	/* Active LED blinking */
285
#define SK_ACT_LED_BLINK	BIT_0S	/* Active LED blinking */
279
#define SK_DUP_LED_NORMAL	(1<<1)	/* Duplex LED normal */
286
#define SK_DUP_LED_NORMAL	BIT_1S	/* Duplex LED normal */
280
#define SK_LED_LINK100_ON	(1<<2)	/* Link 100M LED on */
287
#define SK_LED_LINK100_ON	BIT_2S	/* Link 100M LED on */
288
#define SK_DUAL_LED_ACT_LNK	BIT_3S	/* Dual LED ACT/LNK configuration */
281
289
282
/* Link Partner Status */
290
/* Link Partner Status */
283
#define SK_LIPA_UNKNOWN	0	/* Link partner is in unknown state */
291
#define SK_LIPA_UNKNOWN	0	/* Link partner is in unknown state */
Lines 290-307 Link Here
290
/* Max. Auto-neg. timeouts before link detection in sense mode is reset */
298
/* Max. Auto-neg. timeouts before link detection in sense mode is reset */
291
#define SK_MAX_ANEG_TO	10	/* Max. 10 times the sense mode is reset */
299
#define SK_MAX_ANEG_TO	10	/* Max. 10 times the sense mode is reset */
292
300
301
302
/******************************************************************************
303
 *
304
 * HW_FEATURE() macro
305
 */
306
307
/* DWORD 0: Features */
308
#define HWF_SYNC_TX_SUP			0x00800000UL	/* synch Tx queue available */
309
#define HWF_SINGLE_PORT_DEVICE	0x00400000UL	/* device has only one LAN IF */
310
#define HWF_JUMBO_FRAMES_SUP	0x00200000UL	/* Jumbo frames supported */
311
#define HWF_TX_TCP_CSUM_SUP		0x00100000UL	/* TCP Tx checksum supported */
312
#define HWF_TX_UDP_CSUM_SUP		0x00080000UL	/* UDP Tx checksum supported */
313
#define HWF_RX_CSUM_SUP			0x00040000UL	/* RX checksum supported */
314
#define HWF_TCP_SEGM_SUP		0x00020000UL	/* TCP segmentation supported */
315
#define HWF_RSS_HASH_SUP		0x00010000UL	/* RSS Hash supported */
316
#define HWF_PORT_VLAN_SUP		0x00008000UL	/* VLAN can be config per port*/
317
#define HWF_ROLE_PARAM_SUP		0x00004000UL	/* Role parameter supported */
318
#define HWF_LOW_PMODE_SUP		0x00002000UL	/* Low Power Mode supported */
319
#define HWF_ENERGIE_DEMO_SUP	0x00001000UL	/* Energie detect mode supp. */
320
#define HWF_SPEED1000_SUP		0x00000800UL	/* Line Speed 1000 supported */
321
#define HWF_SPEED100_SUP		0x00000400UL	/* Line Speed 100 supported */
322
#define HWF_SPEED10_SUP			0x00000200UL	/* Line Speed 10 supported */
323
#define HWF_AUTONEGSENSE_SUP	0x00000100UL	/* Autoneg Sense supported */
324
#define HWF_PHY_LOOPB_MD_SUP	0x00000080UL	/* PHY loopback mode supp. */
325
#define HWF_ASF_SUP				0x00000040UL	/* ASF support possible */
326
#define HWF_QS_STEPS_1KB		0x00000020UL	/* The Rx/Tx queues can be */
327
												/* configured in units of 1 kB */
328
#define HWF_OWN_RAM_PER_PORT	0x00000010UL	/* Each port has a separate */
329
												/* RAM buffer */
330
#define HWF_MIN_LED_IF			0x00000008UL	/* Minimal LED interface */
331
												/* (e.g. for Yukon-EC) */
332
#define HWF_LIST_ELEMENTS_USED	0x00000004UL	/* HW uses list elements */
333
												/* (otherwise desc. are used) */
334
#define HWF_GMAC_INSIDE			0x00000002UL	/* device contains GMAC */
335
#define HWF_TWSI_PRESENT		0x00000001UL	/* TWSI sensor bus present */
336
337
/*-RMV- DWORD 1: Deviations */
338
#define HWF_WA_DEV_4115			0x10010000UL	/*-RMV- 4.115 (Rx MAC FIFO) */
339
#define HWF_WA_DEV_4109			0x10008000UL	/*-RMV- 4.109 (BIU hang) */
340
#define HWF_WA_DEV_483			0x10004000UL	/*-RMV- 4.83 (Rx TCP wrong) */
341
#define HWF_WA_DEV_479			0x10002000UL	/*-RMV- 4.79 (Rx BMU hang II) */
342
#define HWF_WA_DEV_472			0x10001000UL	/*-RMV- 4.72 (GPHY2 MDC clk) */
343
#define HWF_WA_DEV_463			0x10000800UL	/*-RMV- 4.63 (Rx BMU hang I) */
344
#define HWF_WA_DEV_427			0x10000400UL	/*-RMV- 4.27 (Tx Done Rep) */
345
#define HWF_WA_DEV_42			0x10000200UL	/*-RMV- 4.2 (pref unit burst) */
346
#define HWF_WA_DEV_46			0x10000100UL	/*-RMV- 4.6 (CPU crash II) */
347
#define HWF_WA_DEV_43_418		0x10000080UL	/*-RMV- 4.3 & 4.18 (PCI unexp */
348
												/*-RMV- compl&Stat BMU deadl) */
349
#define HWF_WA_DEV_420			0x10000040UL	/*-RMV- 4.20 (Status BMU ov) */
350
#define HWF_WA_DEV_423			0x10000020UL	/*-RMV- 4.23 (TCP Segm Hang) */
351
#define HWF_WA_DEV_424			0x10000010UL	/*-RMV- 4.24 (MAC reg overwr) */
352
#define HWF_WA_DEV_425			0x10000008UL	/*-RMV- 4.25 (Magic packet */
353
												/*-RMV- with odd offset) */
354
#define HWF_WA_DEV_428			0x10000004UL	/*-RMV- 4.28 (Poll-U &BigEndi)*/
355
#define HWF_WA_FIFO_FLUSH_YLA0	0x10000002UL	/*-RMV- dis Rx GMAC FIFO Flush*/
356
												/*-RMV- for Yu-L Rev. A0 only */
357
#define HWF_WA_COMA_MODE		0x10000001UL	/*-RMV- Coma Mode WA req */
358
359
/* DWORD 2: still unused */
360
/* DWORD 3: still unused */
361
362
363
/*
364
 * HW_FEATURE()	-	returns whether the feature is serviced or not
365
 */
366
#define HW_FEATURE(pAC, ReqFeature) \
367
	(((pAC)->GIni.HwF.Features[((ReqFeature) & 0x30000000UL) >> 28] &\
368
	 ((ReqFeature) & 0x0fffffffUL)) != 0)
369
370
#define HW_FEAT_LIST	0
371
#define HW_DEV_LIST		1
372
373
#define SET_HW_FEATURE_MASK(pAC, List, OffMaskValue, OnMaskValue) {	\
374
	if ((List) == HW_FEAT_LIST || (List) == HW_DEV_LIST) {			\
375
		(pAC)->GIni.HwF.OffMask[List] = (OffMaskValue);				\
376
		(pAC)->GIni.HwF.OnMask[List] = (OnMaskValue);				\
377
	}																\
378
}
379
380
/* driver access macros for GIni structure ***********************************/
381
382
#define CHIP_ID_YUKON_2(pAC)		((pAC)->GIni.GIYukon2)
383
#define HW_SYNC_TX_SUPPORTED(pAC)						\
384
		((pAC)->GIni.GIChipId != CHIP_ID_YUKON_EC &&	\
385
		 (pAC)->GIni.GIChipId != CHIP_ID_YUKON_FE)
386
387
#define HW_MS_TO_TICKS(pAC, MsTime) \
388
	((MsTime) * (62500L/100) * (pAC)->GIni.GIHstClkFact)
389
390
#ifdef XXX
391
/* still under construction */
392
#define HW_IS_SINGLE_PORT(pAC)		((pAC)->GIni.GIMacsFound == 1)
393
#define HW_NUMBER_OF_PORTS(pAC)		((pAC)->GIni.GIMacsFound)
394
395
#define HW_TX_UDP_CSUM_SUPPORTED(pAC) \
396
	((((pAC)->GIni.GIChipId >= CHIP_ID_YUKON) && ((pAC)->GIni.GIChipRev != 0))
397
398
#define HW_DEFAULT_LINESPEED(pAC)	\
399
	((!(pAC)->GIni.GIGenesis && (pAC)->GIni.GICopperType) ? \
400
	SK_LSPEED_AUTO : SK_LSPEED_1000MBPS)
401
402
#define HW_ROLE_PARAM_SUPPORTED(pAC)	((pAC)->GIni.GICopperType)
403
404
#define HW_SPEED1000_SUPPORTED(pAC, Port)		\
405
	 ((pAC)->GIni.GP[Port].PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS)
406
407
#define HW_SPEED100_SUPPORTED(pAC, Port)		\
408
	 ((pAC)->GIni.GP[Port].PLinkSpeedCap & SK_LSPEED_CAP_100MBPS)
409
410
#define HW_SPEED10_SUPPORTED(pAC, Port)		\
411
	 ((pAC)->GIni.GP[Port].PLinkSpeedCap & SK_LSPEED_CAP_10MBPS)
412
413
#define HW_AUTONEGSENSE_SUPPORTED(pAC)	((pAC)->GIni.GP[0].PhyType==SK_PHY_XMAC)
414
415
#define HW_FREQ_TO_CARD_TICKS(pAC, AdapterClkSpeed, Freq) \
416
	(((AdapterClkSpeed / 100) * (pAC)->GIni.GIHstClkFact) / Freq)
417
418
#define HW_IS_LINK_UP(pAC, Port)		((pAC)->GIni.GP[Port].PHWLinkUp)
419
#define HW_LINK_SPEED_USED(pAC, Port)	((pAC)->GIni.GP[Port].PLinkSpeedUsed)
420
#define HW_RAM_SIZE(pAC)				((pAC)->GIni.GIRamSize)
421
422
#define HW_ENA_JUMBO_FRAME_SUPPORT(pAC) (pAC)->GIni.GIPortUsage = SK_JUMBO_LINK
423
#define HW_DIS_JUMBO_FRAME_SUPPORT(pAC) (pAC)->GIni.GIPortUsage = ????
424
#define HW_PHY_LP_MODE_SUPPORTED(pAC)	(pAC0->???
425
#define HW_ASF_ACTIVE(pAC)				???
426
#define RAWIO_OUT32(pAC, pAC->RegIrqMask, pAC->GIni.GIValIrqMask)...
427
428
/* macro to check whether Tx checksum is supported */
429
#define HW_TX_CSUM_SUPPORTED(pAC)	((pAC)->GIni.GIChipId != CHIP_ID_GENESIS)
430
431
BMU_UDP_CHECK : BMU_TCP_CHECK;
432
433
/* macro for - Own Bit mirrored to DWORD7 (Yukon LP receive descriptor) */
434
#endif /* 0 */
435
436
293
/* structures *****************************************************************/
437
/* structures *****************************************************************/
294
438
295
/*
439
/*
440
 * HW Feature structure
441
 */
442
typedef struct s_HwFeatures {
443
	SK_U32	Features[4];	/* Feature list */
444
	SK_U32	OffMask[4];		/* Off Mask */
445
	SK_U32	OnMask[4];		/* On Mask */
446
} SK_HW_FEATURES;
447
448
/*
296
 * MAC specific functions
449
 * MAC specific functions
297
 */
450
 */
298
typedef struct s_GeMacFunc {
451
typedef struct s_GeMacFunc {
299
	int  (*pFnMacUpdateStats)(SK_AC *pAC, SK_IOC IoC, unsigned int Port);
452
	int	(*pFnMacUpdateStats)(SK_AC *, SK_IOC, unsigned int);
300
	int  (*pFnMacStatistic)(SK_AC *pAC, SK_IOC IoC, unsigned int Port,
453
	int	(*pFnMacStatistic)(SK_AC *, SK_IOC, unsigned int, SK_U16, SK_U32 SK_FAR *);
301
							SK_U16 StatAddr, SK_U32 SK_FAR *pVal);
454
	int	(*pFnMacResetCounter)(SK_AC *, SK_IOC, unsigned int);
302
	int  (*pFnMacResetCounter)(SK_AC *pAC, SK_IOC IoC, unsigned int Port);
455
	int	(*pFnMacOverflow)(SK_AC *, SK_IOC, unsigned int, SK_U16, SK_U64 SK_FAR *);
303
	int  (*pFnMacOverflow)(SK_AC *pAC, SK_IOC IoC, unsigned int Port,
456
	void (*pSkGeSirqIsr)(SK_AC *, SK_IOC, SK_U32);
304
						   SK_U16 IStatus, SK_U64 SK_FAR *pVal);
457
#ifdef SK_DIAG
458
	int	(*pFnMacPhyRead)(SK_AC *, SK_IOC, int, int, SK_U16 SK_FAR *);
459
	int	(*pFnMacPhyWrite)(SK_AC *, SK_IOC, int, int, SK_U16);
460
#endif /* SK_DIAG */
305
} SK_GEMACFUNC;
461
} SK_GEMACFUNC;
306
462
307
/*
463
/*
Lines 311-317 Link Here
311
#ifndef SK_DIAG
467
#ifndef SK_DIAG
312
	SK_TIMER	PWaTimer;	/* Workaround Timer */
468
	SK_TIMER	PWaTimer;	/* Workaround Timer */
313
	SK_TIMER	HalfDupChkTimer;
469
	SK_TIMER	HalfDupChkTimer;
314
#endif /* SK_DIAG */
470
#endif /* !SK_DIAG */
315
	SK_U32	PPrevShorts;	/* Previous Short Counter checking */
471
	SK_U32	PPrevShorts;	/* Previous Short Counter checking */
316
	SK_U32	PPrevFcs;		/* Previous FCS Error Counter checking */
472
	SK_U32	PPrevFcs;		/* Previous FCS Error Counter checking */
317
	SK_U64	PPrevRx;		/* Previous RxOk Counter checking */
473
	SK_U64	PPrevRx;		/* Previous RxOk Counter checking */
Lines 367-372 Link Here
367
	int		PMacJamLen;		/* MAC Jam length */
523
	int		PMacJamLen;		/* MAC Jam length */
368
	int		PMacJamIpgVal;	/* MAC Jam IPG */
524
	int		PMacJamIpgVal;	/* MAC Jam IPG */
369
	int		PMacJamIpgData;	/* MAC IPG Jam to Data */
525
	int		PMacJamIpgData;	/* MAC IPG Jam to Data */
526
	int		PMacBackOffLim;	/* MAC Back-off Limit */
527
	int		PMacDataBlind;	/* MAC Data Blinder */
370
	int		PMacIpgData;	/* MAC Data IPG */
528
	int		PMacIpgData;	/* MAC Data IPG */
371
	SK_BOOL PMacLimit4;		/* reset collision counter and backoff algorithm */
529
	SK_BOOL PMacLimit4;		/* reset collision counter and backoff algorithm */
372
} SK_GEPORT;
530
} SK_GEPORT;
Lines 379-396 Link Here
379
	int			GIChipId;		/* Chip Identification Number */
537
	int			GIChipId;		/* Chip Identification Number */
380
	int			GIChipRev;		/* Chip Revision Number */
538
	int			GIChipRev;		/* Chip Revision Number */
381
	SK_U8		GIPciHwRev;		/* PCI HW Revision Number */
539
	SK_U8		GIPciHwRev;		/* PCI HW Revision Number */
540
	SK_U8		GIPciBus;		/* PCI Bus Type (PCI / PCI-X / PCI-Express) */
541
	SK_U8		GIPciMode;		/* PCI / PCI-X Mode @ Clock */
542
	SK_U8		GIPexWidth;		/* PCI-Express Negotiated Link Width */
382
	SK_BOOL		GIGenesis;		/* Genesis adapter ? */
543
	SK_BOOL		GIGenesis;		/* Genesis adapter ? */
383
	SK_BOOL		GIYukon;		/* YUKON-A1/Bx chip */
544
	SK_BOOL		GIYukon;		/* YUKON family (1 and 2) */
384
	SK_BOOL		GIYukonLite;	/* YUKON-Lite chip */
545
	SK_BOOL		GIYukonLite;	/* YUKON-Lite chip */
546
	SK_BOOL		GIYukon2;		/* YUKON-2 chip (-XL, -EC or -FE) */
547
	SK_U8		GIConTyp;		/* Connector Type */
548
	SK_U8		GIPmdTyp;		/* PMD Type */
385
	SK_BOOL		GICopperType;	/* Copper Type adapter ? */
549
	SK_BOOL		GICopperType;	/* Copper Type adapter ? */
386
	SK_BOOL		GIPciSlot64;	/* 64-bit PCI Slot */
550
	SK_BOOL		GIPciSlot64;	/* 64-bit PCI Slot */
387
	SK_BOOL		GIPciClock66;	/* 66 MHz PCI Clock */
551
	SK_BOOL		GIPciClock66;	/* 66 MHz PCI Clock */
388
	SK_BOOL		GIVauxAvail;	/* VAUX available (YUKON) */
552
	SK_BOOL		GIVauxAvail;	/* VAUX available (YUKON) */
389
	SK_BOOL		GIYukon32Bit;	/* 32-Bit YUKON adapter */
553
	SK_BOOL		GIYukon32Bit;	/* 32-Bit YUKON adapter */
554
	SK_BOOL		GIAsfEnabled;	/* ASF subsystem enabled */
555
	SK_BOOL		GIAsfRunning;	/* ASF subsystem running */
390
	SK_U16		GILedBlinkCtrl;	/* LED Blink Control */
556
	SK_U16		GILedBlinkCtrl;	/* LED Blink Control */
391
	int			GIMacsFound;	/* Number of MACs found on this adapter */
557
	int			GIMacsFound;	/* Number of MACs found on this adapter */
392
	int			GIMacType;		/* MAC Type used on this adapter */
558
	int			GIMacType;		/* MAC Type used on this adapter */
393
	int			GIHstClkFact;	/* Host Clock Factor (62.5 / HstClk * 100) */
559
	int			GIChipCap;		/* Adapter's Capabilities */
560
	int			GIHstClkFact;	/* Host Clock Factor (HstClk / 62.5 * 100) */
394
	int			GIPortUsage;	/* Driver Port Usage */
561
	int			GIPortUsage;	/* Driver Port Usage */
395
	int			GILevel;		/* Initialization Level completed */
562
	int			GILevel;		/* Initialization Level completed */
396
	int			GIRamSize;		/* The RAM size of the adapter in kB */
563
	int			GIRamSize;		/* The RAM size of the adapter in kB */
Lines 398-405 Link Here
398
	SK_U32		GIRamOffs;		/* RAM Address Offset for addr calculation */
565
	SK_U32		GIRamOffs;		/* RAM Address Offset for addr calculation */
399
	SK_U32		GIPollTimerVal;	/* Descr. Poll Timer Init Val (HstClk ticks) */
566
	SK_U32		GIPollTimerVal;	/* Descr. Poll Timer Init Val (HstClk ticks) */
400
	SK_U32		GIValIrqMask;	/* Value for Interrupt Mask */
567
	SK_U32		GIValIrqMask;	/* Value for Interrupt Mask */
568
	SK_U32		GIValHwIrqMask;	/* Value for Interrupt Mask */
401
	SK_U32		GITimeStampCnt;	/* Time Stamp High Counter (YUKON only) */
569
	SK_U32		GITimeStampCnt;	/* Time Stamp High Counter (YUKON only) */
402
	SK_GEPORT	GP[SK_MAX_MACS];/* Port Dependent Information */
570
	SK_GEPORT	GP[SK_MAX_MACS];/* Port Dependent Information */
571
	SK_HW_FEATURES HwF;			/* HW Features struct */
403
	SK_GEMACFUNC GIFunc;		/* MAC depedent functions */
572
	SK_GEMACFUNC GIFunc;		/* MAC depedent functions */
404
} SK_GEINIT;
573
} SK_GEINIT;
405
574
Lines 417-423 Link Here
417
#define SKERR_HWI_E005		(SKERR_HWI_E004+1)
586
#define SKERR_HWI_E005		(SKERR_HWI_E004+1)
418
#define SKERR_HWI_E005MSG	"SkGeInitPort(): cannot init running ports"
587
#define SKERR_HWI_E005MSG	"SkGeInitPort(): cannot init running ports"
419
#define SKERR_HWI_E006		(SKERR_HWI_E005+1)
588
#define SKERR_HWI_E006		(SKERR_HWI_E005+1)
420
#define SKERR_HWI_E006MSG	"SkGeMacInit(): PState does not match HW state"
589
#define SKERR_HWI_E006MSG	"unused"
421
#define SKERR_HWI_E007		(SKERR_HWI_E006+1)
590
#define SKERR_HWI_E007		(SKERR_HWI_E006+1)
422
#define SKERR_HWI_E007MSG	"SkXmInitDupMd() called with invalid Dup Mode"
591
#define SKERR_HWI_E007MSG	"SkXmInitDupMd() called with invalid Dup Mode"
423
#define SKERR_HWI_E008		(SKERR_HWI_E007+1)
592
#define SKERR_HWI_E008		(SKERR_HWI_E007+1)
Lines 447-455 Link Here
447
#define SKERR_HWI_E020		(SKERR_HWI_E019+1)
616
#define SKERR_HWI_E020		(SKERR_HWI_E019+1)
448
#define SKERR_HWI_E020MSG	"Illegal Master/Slave parameter"
617
#define SKERR_HWI_E020MSG	"Illegal Master/Slave parameter"
449
#define SKERR_HWI_E021		(SKERR_HWI_E020+1)
618
#define SKERR_HWI_E021		(SKERR_HWI_E020+1)
450
#define	SKERR_HWI_E021MSG	"MacUpdateStats(): cannot update statistic counter"
619
#define SKERR_HWI_E021MSG	"MacUpdateStats(): cannot update statistic counter"
451
#define	SKERR_HWI_E022		(SKERR_HWI_E021+1)
620
#define SKERR_HWI_E022		(SKERR_HWI_E021+1)
452
#define	SKERR_HWI_E022MSG	"MacStatistic(): illegal statistic base address"
621
#define SKERR_HWI_E022MSG	"MacStatistic(): illegal statistic base address"
453
#define SKERR_HWI_E023		(SKERR_HWI_E022+1)
622
#define SKERR_HWI_E023		(SKERR_HWI_E022+1)
454
#define SKERR_HWI_E023MSG	"SkGeInitPort(): Transmit Queue Size too small"
623
#define SKERR_HWI_E023MSG	"SkGeInitPort(): Transmit Queue Size too small"
455
#define SKERR_HWI_E024		(SKERR_HWI_E023+1)
624
#define SKERR_HWI_E024		(SKERR_HWI_E023+1)
Lines 464-469 Link Here
464
/*
633
/*
465
 * public functions in skgeinit.c
634
 * public functions in skgeinit.c
466
 */
635
 */
636
extern void SkGePortVlan(
637
	SK_AC	*pAC,
638
	SK_IOC	IoC,
639
	int		Port,
640
	SK_BOOL Enable);
641
642
extern void SkGeRxRss(
643
	SK_AC	*pAC,
644
	SK_IOC	IoC,
645
	int		Port,
646
	SK_BOOL	Enable);
647
648
extern void SkGeRxCsum(
649
	SK_AC	*pAC,
650
	SK_IOC	IoC,
651
	int		Port,
652
	SK_BOOL Enable);
653
467
extern void	SkGePollRxD(
654
extern void	SkGePollRxD(
468
	SK_AC	*pAC,
655
	SK_AC	*pAC,
469
	SK_IOC	IoC,
656
	SK_IOC	IoC,
Lines 601-613 Link Here
601
	int		Port,
788
	int		Port,
602
	SK_U16	IStatus);
789
	SK_U16	IStatus);
603
790
604
extern void  SkMacSetRxTxEn(
791
extern void	SkMacSetRxTxEn(
605
	SK_AC	*pAC,
792
	SK_AC	*pAC,
606
	SK_IOC	IoC,
793
	SK_IOC	IoC,
607
	int		Port,
794
	int		Port,
608
	int		Para);
795
	int		Para);
609
796
610
extern int  SkMacRxTxEnable(
797
extern int	SkMacRxTxEnable(
611
	SK_AC	*pAC,
798
	SK_AC	*pAC,
612
	SK_IOC	IoC,
799
	SK_IOC	IoC,
613
	int		Port);
800
	int		Port);
Lines 624-651 Link Here
624
	int		Port,
811
	int		Port,
625
	SK_BOOL	Enable);
812
	SK_BOOL	Enable);
626
813
627
extern void	SkXmPhyRead(
814
extern int	SkXmPhyRead(
628
	SK_AC	*pAC,
815
	SK_AC	*pAC,
629
	SK_IOC	IoC,
816
	SK_IOC	IoC,
630
	int		Port,
817
	int		Port,
631
	int		Addr,
818
	int		Addr,
632
	SK_U16	SK_FAR *pVal);
819
	SK_U16	SK_FAR *pVal);
633
820
634
extern void	SkXmPhyWrite(
821
extern int	SkXmPhyWrite(
635
	SK_AC	*pAC,
822
	SK_AC	*pAC,
636
	SK_IOC	IoC,
823
	SK_IOC	IoC,
637
	int		Port,
824
	int		Port,
638
	int		Addr,
825
	int		Addr,
639
	SK_U16	Val);
826
	SK_U16	Val);
640
827
641
extern void	SkGmPhyRead(
828
extern int	SkGmPhyRead(
642
	SK_AC	*pAC,
829
	SK_AC	*pAC,
643
	SK_IOC	IoC,
830
	SK_IOC	IoC,
644
	int		Port,
831
	int		Port,
645
	int		Addr,
832
	int		Addr,
646
	SK_U16	SK_FAR *pVal);
833
	SK_U16	SK_FAR *pVal);
647
834
648
extern void	SkGmPhyWrite(
835
extern int	SkGmPhyWrite(
649
	SK_AC	*pAC,
836
	SK_AC	*pAC,
650
	SK_IOC	IoC,
837
	SK_IOC	IoC,
651
	int		Port,
838
	int		Port,
Lines 713-719 Link Here
713
	SK_AC	*pAC,
900
	SK_AC	*pAC,
714
	SK_IOC	IoC,
901
	SK_IOC	IoC,
715
	unsigned int Port,
902
	unsigned int Port,
716
	SK_U16  IStatus,
903
	SK_U16	IStatus,
717
	SK_U64	SK_FAR *pStatus);
904
	SK_U64	SK_FAR *pStatus);
718
905
719
extern int SkGmOverflowStatus(
906
extern int SkGmOverflowStatus(
Lines 729-734 Link Here
729
	int		Port,
916
	int		Port,
730
	SK_BOOL	StartTest);
917
	SK_BOOL	StartTest);
731
918
919
#ifdef SK_PHY_LP_MODE
732
extern int SkGmEnterLowPowerMode(
920
extern int SkGmEnterLowPowerMode(
733
	SK_AC	*pAC,
921
	SK_AC	*pAC,
734
	SK_IOC	IoC,
922
	SK_IOC	IoC,
Lines 739-744 Link Here
739
	SK_AC	*pAC,
927
	SK_AC	*pAC,
740
	SK_IOC	IoC,
928
	SK_IOC	IoC,
741
	int		Port);
929
	int		Port);
930
#endif /* SK_PHY_LP_MODE */
742
931
743
#ifdef SK_DIAG
932
#ifdef SK_DIAG
744
extern void	SkGePhyRead(
933
extern void	SkGePhyRead(
Lines 794-799 Link Here
794
extern void	SkGeXmitLED();
983
extern void	SkGeXmitLED();
795
extern void	SkGeInitRamIface();
984
extern void	SkGeInitRamIface();
796
extern int	SkGeInitAssignRamToQueues();
985
extern int	SkGeInitAssignRamToQueues();
986
extern void SkGePortVlan();
987
extern void SkGeRxCsum();
988
extern void SkGeRxRss();
797
989
798
/*
990
/*
799
 * public functions in skxmac2.c
991
 * public functions in skxmac2.c
Lines 803-809 Link Here
803
extern void	SkMacHardRst();
995
extern void	SkMacHardRst();
804
extern void	SkMacClearRst();
996
extern void	SkMacClearRst();
805
extern void SkMacInitPhy();
997
extern void SkMacInitPhy();
806
extern int  SkMacRxTxEnable();
998
extern int	SkMacRxTxEnable();
807
extern void SkMacPromiscMode();
999
extern void SkMacPromiscMode();
808
extern void SkMacHashing();
1000
extern void SkMacHashing();
809
extern void SkMacIrqDisable();
1001
extern void SkMacIrqDisable();
Lines 814-824 Link Here
814
extern void	SkMacAutoNegLipaPhy();
1006
extern void	SkMacAutoNegLipaPhy();
815
extern void SkMacSetRxTxEn();
1007
extern void SkMacSetRxTxEn();
816
extern void	SkXmInitMac();
1008
extern void	SkXmInitMac();
817
extern void	SkXmPhyRead();
1009
extern int	SkXmPhyRead();
818
extern void	SkXmPhyWrite();
1010
extern int	SkXmPhyWrite();
819
extern void	SkGmInitMac();
1011
extern void	SkGmInitMac();
820
extern void	SkGmPhyRead();
1012
extern int	SkGmPhyRead();
821
extern void	SkGmPhyWrite();
1013
extern int	SkGmPhyWrite();
822
extern void	SkXmClrExactAddr();
1014
extern void	SkXmClrExactAddr();
823
extern void	SkXmInitDupMd();
1015
extern void	SkXmInitDupMd();
824
extern void	SkXmInitPauseMd();
1016
extern void	SkXmInitPauseMd();
Lines 832-839 Link Here
832
extern int	SkXmOverflowStatus();
1024
extern int	SkXmOverflowStatus();
833
extern int	SkGmOverflowStatus();
1025
extern int	SkGmOverflowStatus();
834
extern int	SkGmCableDiagStatus();
1026
extern int	SkGmCableDiagStatus();
1027
#ifdef SK_PHY_LP_MODE
835
extern int	SkGmEnterLowPowerMode();
1028
extern int	SkGmEnterLowPowerMode();
836
extern int	SkGmLeaveLowPowerMode();
1029
extern int	SkGmLeaveLowPowerMode();
1030
#endif /* SK_PHY_LP_MODE */
837
1031
838
#ifdef SK_DIAG
1032
#ifdef SK_DIAG
839
extern void	SkGePhyRead();
1033
extern void	SkGePhyRead();
Lines 844-853 Link Here
844
extern void	SkXmSendCont();
1038
extern void	SkXmSendCont();
845
#endif /* SK_DIAG */
1039
#endif /* SK_DIAG */
846
1040
847
#endif	/* SK_KR_PROTO */
1041
#endif /* SK_KR_PROTO */
848
1042
849
#ifdef __cplusplus
1043
#ifdef __cplusplus
850
}
1044
}
851
#endif	/* __cplusplus */
1045
#endif	/* __cplusplus */
852
1046
853
#endif	/* __INC_SKGEINIT_H_ */
1047
#endif	/* __INC_SKGEINIT_H_ */
1048
(-)linux/drivers/net/sk98lin/h/skgepnm2.h (-6 / +6 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skgepnm2.h
3
 * Name:	skgepnm2.h
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.36 $
5
 * Version:	$Revision: 2.3 $
6
 * Date:	$Date: 2003/05/23 12:45:13 $
6
 * Date:	$Date: 2004/03/19 16:19:59 $
7
 * Purpose:	Defines for Private Network Management Interface
7
 * Purpose:	Defines for Private Network Management Interface
8
 *
8
 *
9
 ****************************************************************************/
9
 ****************************************************************************/
Lines 70-78 Link Here
70
/*
70
/*
71
 * VCT internal status values
71
 * VCT internal status values
72
 */
72
 */
73
#define SK_PNMI_VCT_PENDING	32
73
#define SK_PNMI_VCT_PENDING		0x20
74
#define SK_PNMI_VCT_TEST_DONE	64
74
#define SK_PNMI_VCT_TEST_DONE	0x40
75
#define SK_PNMI_VCT_LINK	128
75
#define SK_PNMI_VCT_LINK		0x80
76
76
77
/*
77
/*
78
 * Internal table definitions
78
 * Internal table definitions
Lines 323-329 Link Here
323
						vSt, \
323
						vSt, \
324
						pAC->Pnmi.MacUpdatedFlag, \
324
						pAC->Pnmi.MacUpdatedFlag, \
325
						pAC->Pnmi.RlmtUpdatedFlag, \
325
						pAC->Pnmi.RlmtUpdatedFlag, \
326
						pAC->Pnmi.SirqUpdatedFlag))}}
326
						pAC->Pnmi.SirqUpdatedFlag));}}
327
327
328
#else	/* !DEBUG */
328
#else	/* !DEBUG */
329
329
(-)linux/drivers/net/sk98lin/h/skgepnmi.h (-51 / +90 lines)
Lines 1-9 Link Here
1
/*****************************************************************************
1
/*****************************************************************************
2
 *
2
 *
3
 * Name:	skgepnmi.h
3
 * Name:	skgepnmi.h
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	Gigabit Ethernet Adapters, PNMI-Module
5
 * Version:	$Revision: 1.62 $
5
 * Version:	$Revision: 2.9 $
6
 * Date:	$Date: 2003/08/15 12:31:52 $
6
 * Date:	$Date: 2004/10/26 12:42:39 $
7
 * Purpose:	Defines for Private Network Management Interface
7
 * Purpose:	Defines for Private Network Management Interface
8
 *
8
 *
9
 ****************************************************************************/
9
 ****************************************************************************/
Lines 31-37 Link Here
31
#include "h/sktypes.h"
31
#include "h/sktypes.h"
32
#include "h/skerror.h"
32
#include "h/skerror.h"
33
#include "h/sktimer.h"
33
#include "h/sktimer.h"
34
#include "h/ski2c.h"
34
#include "h/sktwsi.h"
35
#include "h/skaddr.h"
35
#include "h/skaddr.h"
36
#include "h/skrlmt.h"
36
#include "h/skrlmt.h"
37
#include "h/skvpd.h"
37
#include "h/skvpd.h"
Lines 41-47 Link Here
41
 */
41
 */
42
#define SK_PNMI_MDB_VERSION		0x00030001	/* 3.1 */
42
#define SK_PNMI_MDB_VERSION		0x00030001	/* 3.1 */
43
43
44
45
/*
44
/*
46
 * Event definitions
45
 * Event definitions
47
 */
46
 */
Lines 54-69 Link Here
54
#define SK_PNMI_EVT_UTILIZATION_TIMER	7	/* Timer event for Utiliza. */
53
#define SK_PNMI_EVT_UTILIZATION_TIMER	7	/* Timer event for Utiliza. */
55
#define SK_PNMI_EVT_CLEAR_COUNTER		8	/* Clear statistic counters */
54
#define SK_PNMI_EVT_CLEAR_COUNTER		8	/* Clear statistic counters */
56
#define SK_PNMI_EVT_XMAC_RESET			9	/* XMAC will be reset */
55
#define SK_PNMI_EVT_XMAC_RESET			9	/* XMAC will be reset */
57
58
#define SK_PNMI_EVT_RLMT_PORT_UP		10	/* Port came logically up */
56
#define SK_PNMI_EVT_RLMT_PORT_UP		10	/* Port came logically up */
59
#define SK_PNMI_EVT_RLMT_PORT_DOWN		11	/* Port went logically down */
57
#define SK_PNMI_EVT_RLMT_PORT_DOWN		11	/* Port went logically down */
60
#define SK_PNMI_EVT_RLMT_SEGMENTATION	13	/* Two SP root bridges found */
58
#define SK_PNMI_EVT_RLMT_SEGMENTATION	13	/* Two SP root bridges found */
61
#define SK_PNMI_EVT_RLMT_ACTIVE_DOWN	14	/* Port went logically down */
59
#define SK_PNMI_EVT_RLMT_ACTIVE_DOWN	14	/* Port went logically down */
62
#define SK_PNMI_EVT_RLMT_ACTIVE_UP		15	/* Port came logically up */
60
#define SK_PNMI_EVT_RLMT_ACTIVE_UP		15	/* Port came logically up */
63
#define SK_PNMI_EVT_RLMT_SET_NETS		16	/* 1. Parameter is number of nets
61
#define SK_PNMI_EVT_RLMT_SET_NETS		16	/* Number of nets (1 or 2). */
64
												1 = single net; 2 = dual net */
62
#define SK_PNMI_EVT_VCT_RESET			17	/* VCT port reset timer event started with SET. */
65
#define SK_PNMI_EVT_VCT_RESET		17	/* VCT port reset timer event started with SET. */
66
67
63
68
/*
64
/*
69
 * Return values
65
 * Return values
Lines 78-84 Link Here
78
#define SK_PNMI_ERR_UNKNOWN_NET 	7
74
#define SK_PNMI_ERR_UNKNOWN_NET 	7
79
#define SK_PNMI_ERR_NOT_SUPPORTED	10
75
#define SK_PNMI_ERR_NOT_SUPPORTED	10
80
76
81
82
/*
77
/*
83
 * Return values of driver reset function SK_DRIVER_RESET() and
78
 * Return values of driver reset function SK_DRIVER_RESET() and
84
 * driver event function SK_DRIVER_EVENT()
79
 * driver event function SK_DRIVER_EVENT()
Lines 86-104 Link Here
86
#define SK_PNMI_ERR_OK			0
81
#define SK_PNMI_ERR_OK			0
87
#define SK_PNMI_ERR_FAIL		1
82
#define SK_PNMI_ERR_FAIL		1
88
83
89
90
/*
84
/*
91
 * Return values of driver test function SK_DRIVER_SELFTEST()
85
 * Return values of driver test function SK_DRIVER_SELFTEST()
92
 */
86
 */
93
#define SK_PNMI_TST_UNKNOWN		(1 << 0)
87
#define SK_PNMI_TST_UNKNOWN		(1 << 0)
94
#define SK_PNMI_TST_TRANCEIVER		(1 << 1)
88
#define SK_PNMI_TST_TRANCEIVER	(1 << 1)
95
#define SK_PNMI_TST_ASIC		(1 << 2)
89
#define SK_PNMI_TST_ASIC		(1 << 2)
96
#define SK_PNMI_TST_SENSOR		(1 << 3)
90
#define SK_PNMI_TST_SENSOR		(1 << 3)
97
#define SK_PNMI_TST_POWERMGMT		(1 << 4)
91
#define SK_PNMI_TST_POWERMGMT	(1 << 4)
98
#define SK_PNMI_TST_PCI			(1 << 5)
92
#define SK_PNMI_TST_PCI			(1 << 5)
99
#define SK_PNMI_TST_MAC			(1 << 6)
93
#define SK_PNMI_TST_MAC			(1 << 6)
100
94
101
102
/*
95
/*
103
 * RLMT specific definitions
96
 * RLMT specific definitions
104
 */
97
 */
Lines 352-357 Link Here
352
#define OID_SKGE_VCT_GET				0xFF020200
345
#define OID_SKGE_VCT_GET				0xFF020200
353
#define OID_SKGE_VCT_SET				0xFF020201
346
#define OID_SKGE_VCT_SET				0xFF020201
354
#define OID_SKGE_VCT_STATUS				0xFF020202
347
#define OID_SKGE_VCT_STATUS				0xFF020202
348
#define OID_SKGE_VCT_CAPABILITIES		0xFF020203
355
349
356
#ifdef SK_DIAG_SUPPORT
350
#ifdef SK_DIAG_SUPPORT
357
/* Defines for driver DIAG mode. */
351
/* Defines for driver DIAG mode. */
Lines 367-388 Link Here
367
#define OID_SKGE_PHY_TYPE				0xFF020215
361
#define OID_SKGE_PHY_TYPE				0xFF020215
368
#define OID_SKGE_PHY_LP_MODE			0xFF020216
362
#define OID_SKGE_PHY_LP_MODE			0xFF020216
369
363
364
/*
365
 * Added for new DualNet IM driver V2
366
 * these OIDs should later  be in pnmi.h
367
 */
368
#define OID_SKGE_MAC_COUNT		0xFF020217
369
#define OID_SKGE_DUALNET_MODE		0xFF020218
370
#define OID_SKGE_SET_TAGHEADER	0xFF020219
371
372
#ifdef SK_ASF
373
/* Defines for ASF */
374
#define OID_SKGE_ASF                    0xFF02021a
375
#define OID_SKGE_ASF_STORE_CONFIG       0xFF02021b
376
#define OID_SKGE_ASF_ENA                0xFF02021c
377
#define OID_SKGE_ASF_RETRANS            0xFF02021d
378
#define OID_SKGE_ASF_RETRANS_INT        0xFF02021e
379
#define OID_SKGE_ASF_HB_ENA             0xFF02021f
380
#define OID_SKGE_ASF_HB_INT             0xFF020220
381
#define OID_SKGE_ASF_WD_ENA             0xFF020221
382
#define OID_SKGE_ASF_WD_TIME            0xFF020222
383
#define OID_SKGE_ASF_IP_SOURCE          0xFF020223
384
#define OID_SKGE_ASF_MAC_SOURCE			0xFF020224
385
#define OID_SKGE_ASF_IP_DEST            0xFF020225
386
#define OID_SKGE_ASF_MAC_DEST           0xFF020226
387
#define OID_SKGE_ASF_COMMUNITY_NAME     0xFF020227
388
#define OID_SKGE_ASF_RSP_ENA            0xFF020228  
389
#define OID_SKGE_ASF_RETRANS_COUNT_MIN	0xFF020229
390
#define OID_SKGE_ASF_RETRANS_COUNT_MAX	0xFF02022a
391
#define OID_SKGE_ASF_RETRANS_INT_MIN	0xFF02022b
392
#define OID_SKGE_ASF_RETRANS_INT_MAX	0xFF02022c
393
#define OID_SKGE_ASF_HB_INT_MIN			0xFF02022d
394
#define OID_SKGE_ASF_HB_INT_MAX			0xFF02022e
395
#define OID_SKGE_ASF_WD_TIME_MIN		0xFF02022f
396
#define OID_SKGE_ASF_WD_TIME_MAX		0xFF020230
397
#define OID_SKGE_ASF_HB_CAP				0xFF020231
398
#define OID_SKGE_ASF_WD_TIMER_RES		0xFF020232
399
#define OID_SKGE_ASF_GUID				0xFF020233
400
#define OID_SKGE_ASF_KEY_OP				0xFF020234
401
#define OID_SKGE_ASF_KEY_ADM			0xFF020235
402
#define OID_SKGE_ASF_KEY_GEN			0xFF020236
403
#define OID_SKGE_ASF_CAP				0xFF020237
404
#define OID_SKGE_ASF_PAR_1				0xFF020238
405
#define OID_SKGE_ASF_OVERALL_OID        0xFF020239
406
#define OID_SKGE_ASF_FWVER_OID          0xFF020240
407
#define OID_SKGE_ASF_ACPI_OID           0xFF020241
408
#define OID_SKGE_ASF_SMBUS_OID          0xFF020242
409
#endif /* SK_ASF */
410
370
/* VCT struct to store a backup copy of VCT data after a port reset. */
411
/* VCT struct to store a backup copy of VCT data after a port reset. */
371
typedef struct s_PnmiVct {
412
typedef struct s_PnmiVct {
372
	SK_U8			VctStatus;
413
	SK_U8			VctStatus;
373
	SK_U8			PCableLen;
414
	SK_U8			CableLen;
374
	SK_U32			PMdiPairLen[4];
415
	SK_U32			MdiPairLen[4];
375
	SK_U8			PMdiPairSts[4];
416
	SK_U8			MdiPairSts[4];
376
} SK_PNMI_VCT;
417
} SK_PNMI_VCT;
377
418
378
419
379
/* VCT status values (to be given to CPA via OID_SKGE_VCT_STATUS). */
420
/* VCT status values (to be given to CPA via OID_SKGE_VCT_STATUS). */
380
#define SK_PNMI_VCT_NONE		0
421
#define SK_PNMI_VCT_NONE			0x00
381
#define SK_PNMI_VCT_OLD_VCT_DATA	1
422
#define SK_PNMI_VCT_OLD_VCT_DATA	0x01
382
#define SK_PNMI_VCT_NEW_VCT_DATA	2
423
#define SK_PNMI_VCT_NEW_VCT_DATA	0x02
383
#define SK_PNMI_VCT_OLD_DSP_DATA	4
424
#define SK_PNMI_VCT_OLD_DSP_DATA	0x04
384
#define SK_PNMI_VCT_NEW_DSP_DATA	8
425
#define SK_PNMI_VCT_NEW_DSP_DATA	0x08
385
#define SK_PNMI_VCT_RUNNING		16
426
#define SK_PNMI_VCT_RUNNING			0x10
386
427
387
428
388
/* VCT cable test status. */
429
/* VCT cable test status. */
Lines 390-396 Link Here
390
#define SK_PNMI_VCT_SHORT_CABLE			1
431
#define SK_PNMI_VCT_SHORT_CABLE			1
391
#define SK_PNMI_VCT_OPEN_CABLE			2
432
#define SK_PNMI_VCT_OPEN_CABLE			2
392
#define SK_PNMI_VCT_TEST_FAIL			3
433
#define SK_PNMI_VCT_TEST_FAIL			3
393
#define SK_PNMI_VCT_IMPEDANCE_MISMATCH		4
434
#define SK_PNMI_VCT_IMPEDANCE_MISMATCH	4
435
#define SK_PNMI_VCT_NOT_PRESENT			5
436
437
/* VCT capabilities (needed for OID_SKGE_VCT_CAPABILITIES. */
438
#define SK_PNMI_VCT_SUPPORTED			1
439
#define SK_PNMI_VCT_NOT_SUPPORTED		0
394
440
395
#define	OID_SKGE_TRAP_SEN_WAR_LOW		500
441
#define	OID_SKGE_TRAP_SEN_WAR_LOW		500
396
#define OID_SKGE_TRAP_SEN_WAR_UPP		501
442
#define OID_SKGE_TRAP_SEN_WAR_UPP		501
Lines 419-425 Link Here
419
#define	SK_SET_FULL_MIB			5
465
#define	SK_SET_FULL_MIB			5
420
#define	SK_PRESET_FULL_MIB		6
466
#define	SK_PRESET_FULL_MIB		6
421
467
422
423
/*
468
/*
424
 * Define error numbers and messages for syslog
469
 * Define error numbers and messages for syslog
425
 */
470
 */
Lines 452-458 Link Here
452
#define SK_PNMI_ERR014		(SK_ERRBASE_PNMI + 14)
497
#define SK_PNMI_ERR014		(SK_ERRBASE_PNMI + 14)
453
#define SK_PNMI_ERR014MSG	"Vpd: Cannot read VPD keys"
498
#define SK_PNMI_ERR014MSG	"Vpd: Cannot read VPD keys"
454
#define SK_PNMI_ERR015		(SK_ERRBASE_PNMI + 15)
499
#define SK_PNMI_ERR015		(SK_ERRBASE_PNMI + 15)
455
#define SK_PNMI_ERR015MSG	"Vpd: Internal array for VPD keys to small"
500
#define SK_PNMI_ERR015MSG	"Vpd: Internal array for VPD keys too small"
456
#define SK_PNMI_ERR016		(SK_ERRBASE_PNMI + 16)
501
#define SK_PNMI_ERR016		(SK_ERRBASE_PNMI + 16)
457
#define SK_PNMI_ERR016MSG	"Vpd: Key string too long"
502
#define SK_PNMI_ERR016MSG	"Vpd: Key string too long"
458
#define SK_PNMI_ERR017		(SK_ERRBASE_PNMI + 17)
503
#define SK_PNMI_ERR017		(SK_ERRBASE_PNMI + 17)
Lines 494-502 Link Here
494
#define SK_PNMI_ERR036		(SK_ERRBASE_PNMI + 36)
539
#define SK_PNMI_ERR036		(SK_ERRBASE_PNMI + 36)
495
#define SK_PNMI_ERR036MSG	""
540
#define SK_PNMI_ERR036MSG	""
496
#define SK_PNMI_ERR037		(SK_ERRBASE_PNMI + 37)
541
#define SK_PNMI_ERR037		(SK_ERRBASE_PNMI + 37)
497
#define SK_PNMI_ERR037MSG	"Rlmt: SK_RLMT_MODE_CHANGE event return not 0"
542
#define SK_PNMI_ERR037MSG	"Rlmt: SK_RLMT_MODE_CHANGE event returned not 0"
498
#define SK_PNMI_ERR038		(SK_ERRBASE_PNMI + 38)
543
#define SK_PNMI_ERR038		(SK_ERRBASE_PNMI + 38)
499
#define SK_PNMI_ERR038MSG	"Rlmt: SK_RLMT_PREFPORT_CHANGE event return not 0"
544
#define SK_PNMI_ERR038MSG	"Rlmt: SK_RLMT_PREFPORT_CHANGE event returned not 0"
500
#define SK_PNMI_ERR039		(SK_ERRBASE_PNMI + 39)
545
#define SK_PNMI_ERR039		(SK_ERRBASE_PNMI + 39)
501
#define SK_PNMI_ERR039MSG	"RlmtStat: Unknown OID"
546
#define SK_PNMI_ERR039MSG	"RlmtStat: Unknown OID"
502
#define SK_PNMI_ERR040		(SK_ERRBASE_PNMI + 40)
547
#define SK_PNMI_ERR040		(SK_ERRBASE_PNMI + 40)
Lines 514-522 Link Here
514
#define SK_PNMI_ERR046		(SK_ERRBASE_PNMI + 46)
559
#define SK_PNMI_ERR046		(SK_ERRBASE_PNMI + 46)
515
#define SK_PNMI_ERR046MSG	"Monitor: Unknown OID"
560
#define SK_PNMI_ERR046MSG	"Monitor: Unknown OID"
516
#define SK_PNMI_ERR047		(SK_ERRBASE_PNMI + 47)
561
#define SK_PNMI_ERR047		(SK_ERRBASE_PNMI + 47)
517
#define SK_PNMI_ERR047MSG	"SirqUpdate: Event function returns not 0"
562
#define SK_PNMI_ERR047MSG	"SirqUpdate: Event function returned not 0"
518
#define SK_PNMI_ERR048		(SK_ERRBASE_PNMI + 48)
563
#define SK_PNMI_ERR048		(SK_ERRBASE_PNMI + 48)
519
#define SK_PNMI_ERR048MSG	"RlmtUpdate: Event function returns not 0"
564
#define SK_PNMI_ERR048MSG	"RlmtUpdate: Event function returned not 0"
520
#define SK_PNMI_ERR049		(SK_ERRBASE_PNMI + 49)
565
#define SK_PNMI_ERR049		(SK_ERRBASE_PNMI + 49)
521
#define SK_PNMI_ERR049MSG	"SkPnmiInit: Invalid size of 'CounterOffset' struct!!"
566
#define SK_PNMI_ERR049MSG	"SkPnmiInit: Invalid size of 'CounterOffset' struct!!"
522
#define SK_PNMI_ERR050		(SK_ERRBASE_PNMI + 50)
567
#define SK_PNMI_ERR050		(SK_ERRBASE_PNMI + 50)
Lines 826-848 Link Here
826
} SK_PNMI_STRUCT_DATA;
871
} SK_PNMI_STRUCT_DATA;
827
872
828
#define SK_PNMI_STRUCT_SIZE	(sizeof(SK_PNMI_STRUCT_DATA))
873
#define SK_PNMI_STRUCT_SIZE	(sizeof(SK_PNMI_STRUCT_DATA))
874
875
/* The ReturnStatus field must be located before VpdFreeBytes! */
829
#define SK_PNMI_MIN_STRUCT_SIZE	((unsigned int)(SK_UPTR)\
876
#define SK_PNMI_MIN_STRUCT_SIZE	((unsigned int)(SK_UPTR)\
830
				 &(((SK_PNMI_STRUCT_DATA *)0)->VpdFreeBytes))
877
				 &(((SK_PNMI_STRUCT_DATA *)0)->VpdFreeBytes))
831
														/*
832
														 * ReturnStatus field
833
														 * must be located
834
														 * before VpdFreeBytes
835
														 */
836
878
837
/*
879
/*
838
 * Various definitions
880
 * Various definitions
839
 */
881
 */
882
#define SK_PNMI_EVT_TIMER_CHECK		28125000L	/* 28125 ms */
883
884
#define SK_PNMI_VCT_TIMER_CHECK		 4000000L	/* 4 sec. */
885
840
#define SK_PNMI_MAX_PROTOS		3
886
#define SK_PNMI_MAX_PROTOS		3
841
887
842
#define SK_PNMI_CNT_NO			66	/* Must have the value of the enum
888
/*
843
									 * SK_PNMI_MAX_IDX. Define SK_PNMI_CHECK
889
 * SK_PNMI_CNT_NO must have the value of the enum SK_PNMI_MAX_IDX.
844
									 * for check while init phase 1
890
 * Define SK_PNMI_CHECK to check this during init level SK_INIT_IO.
845
									 */
891
 */
892
#define SK_PNMI_CNT_NO			66
846
893
847
/*
894
/*
848
 * Estimate data structure
895
 * Estimate data structure
Lines 856-869 Link Here
856
903
857
904
858
/*
905
/*
859
 * VCT timer data structure
860
 */
861
typedef struct s_VctTimer {
862
	SK_TIMER		VctTimer;
863
} SK_PNMI_VCT_TIMER;
864
865
866
/*
867
 * PNMI specific adapter context structure
906
 * PNMI specific adapter context structure
868
 */
907
 */
869
typedef struct s_PnmiPort {
908
typedef struct s_PnmiPort {
Lines 933-941 Link Here
933
	unsigned int	TrapQueueEnd;
972
	unsigned int	TrapQueueEnd;
934
	unsigned int	TrapBufPad;
973
	unsigned int	TrapBufPad;
935
	unsigned int	TrapUnique;
974
	unsigned int	TrapUnique;
936
	SK_U8		VctStatus[SK_MAX_MACS];
975
	SK_U8			VctStatus[SK_MAX_MACS];
937
	SK_PNMI_VCT	VctBackup[SK_MAX_MACS];
976
	SK_PNMI_VCT		VctBackup[SK_MAX_MACS];
938
	SK_PNMI_VCT_TIMER VctTimeout[SK_MAX_MACS];
977
	SK_TIMER		VctTimeout[SK_MAX_MACS];
939
#ifdef SK_DIAG_SUPPORT
978
#ifdef SK_DIAG_SUPPORT
940
	SK_U32			DiagAttached;
979
	SK_U32			DiagAttached;
941
#endif /* SK_DIAG_SUPPORT */
980
#endif /* SK_DIAG_SUPPORT */
(-)linux/drivers/net/sk98lin/h/skgesirq.h (-8 / +32 lines)
Lines 2-23 Link Here
2
 *
2
 *
3
 * Name:	skgesirq.h
3
 * Name:	skgesirq.h
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.30 $
5
 * Version:	$Revision: 2.3 $
6
 * Date:	$Date: 2003/07/04 12:34:13 $
6
 * Date:	$Date: 2004/05/28 14:42:03 $
7
 * Purpose:	SK specific Gigabit Ethernet special IRQ functions
7
 * Purpose:	Gigabit Ethernet special IRQ functions
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
10
10
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
22
 *
21
 *
23
 ******************************************************************************/
22
 ******************************************************************************/
Lines 44-53 Link Here
44
#define SK_HWEV_SET_SPEED		9	/* Set Link Speed by PNMI */
43
#define SK_HWEV_SET_SPEED		9	/* Set Link Speed by PNMI */
45
#define SK_HWEV_HALFDUP_CHK		10	/* Half Duplex Hangup Workaround */
44
#define SK_HWEV_HALFDUP_CHK		10	/* Half Duplex Hangup Workaround */
46
45
47
#define SK_WA_ACT_TIME		(5000000UL)	/* 5 sec */
46
#define SK_WA_ACT_TIME		1000000UL	/* 1000 msec (1 sec) */
48
#define SK_WA_INA_TIME		(100000UL)	/* 100 msec */
47
#define SK_WA_INA_TIME		 100000UL	/*  100 msec */
49
48
50
#define SK_HALFDUP_CHK_TIME	(10000UL)	/* 10 msec */
49
#define SK_HALFDUP_CHK_TIME	  10000UL	/*   10 msec */
51
50
52
/*
51
/*
53
 * Define the error numbers and messages
52
 * Define the error numbers and messages
Lines 102-111 Link Here
102
#define SKERR_SIRQ_E024MSG	"FIFO overflow error"
101
#define SKERR_SIRQ_E024MSG	"FIFO overflow error"
103
#define SKERR_SIRQ_E025		(SKERR_SIRQ_E024+1)
102
#define SKERR_SIRQ_E025		(SKERR_SIRQ_E024+1)
104
#define SKERR_SIRQ_E025MSG	"2 Pair Downshift detected"
103
#define SKERR_SIRQ_E025MSG	"2 Pair Downshift detected"
104
#define SKERR_SIRQ_E026		(SKERR_SIRQ_E025+1)
105
#define SKERR_SIRQ_E026MSG	"Uncorrectable PCI Express error"
106
#define SKERR_SIRQ_E027		(SKERR_SIRQ_E026+1)
107
#define SKERR_SIRQ_E027MSG	"PCI express protocol violation error"
108
#define SKERR_SIRQ_E028		(SKERR_SIRQ_E027+1)
109
#define SKERR_SIRQ_E028MSG	"Parity error on RAM 1 (read)"
110
#define SKERR_SIRQ_E029		(SKERR_SIRQ_E028+1)
111
#define SKERR_SIRQ_E029MSG	"Parity error on RAM 1 (write)"
112
#define SKERR_SIRQ_E030		(SKERR_SIRQ_E029+1)
113
#define SKERR_SIRQ_E030MSG	"Parity error on RAM 2 (read)"
114
#define SKERR_SIRQ_E031		(SKERR_SIRQ_E030+1)
115
#define SKERR_SIRQ_E031MSG	"Parity error on RAM 2 (write)"
116
#define SKERR_SIRQ_E032		(SKERR_SIRQ_E031+1)
117
#define SKERR_SIRQ_E032MSG	"TCP segmentation error async. queue 1"
118
#define SKERR_SIRQ_E033		(SKERR_SIRQ_E032+1)
119
#define SKERR_SIRQ_E033MSG	"TCP segmentation error sync. queue 1"
120
#define SKERR_SIRQ_E034		(SKERR_SIRQ_E033+1)
121
#define SKERR_SIRQ_E034MSG	"TCP segmentation error async. queue 2"
122
#define SKERR_SIRQ_E035		(SKERR_SIRQ_E034+1)
123
#define SKERR_SIRQ_E035MSG	"TCP segmentation error sync. queue 2"
124
#define SKERR_SIRQ_E036		(SKERR_SIRQ_E035+1)
125
#define SKERR_SIRQ_E036MSG	"CHECK failure polling unit"
105
126
106
extern void SkGeSirqIsr(SK_AC *pAC, SK_IOC IoC, SK_U32 Istatus);
127
extern void SkGeSirqIsr(SK_AC *pAC, SK_IOC IoC, SK_U32 Istatus);
107
extern int  SkGeSirqEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
128
extern int  SkGeSirqEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
108
extern void SkHWLinkUp(SK_AC *pAC, SK_IOC IoC, int Port);
129
extern void SkHWLinkUp(SK_AC *pAC, SK_IOC IoC, int Port);
109
extern void SkHWLinkDown(SK_AC *pAC, SK_IOC IoC, int Port);
130
extern void SkHWLinkDown(SK_AC *pAC, SK_IOC IoC, int Port);
131
extern void SkGeYuSirqIsr(SK_AC *pAC, SK_IOC IoC, SK_U32 Istatus);
132
extern void SkYuk2SirqIsr(SK_AC *pAC, SK_IOC IoC, SK_U32 Istatus);
110
133
111
#endif	/* _INC_SKGESIRQ_H_ */
134
#endif	/* _INC_SKGESIRQ_H_ */
135
(-)linux/drivers/net/sk98lin/h/skgetwsi.h (+241 lines)
Line 0 Link Here
1
/******************************************************************************
2
 *
3
 * Name:	skgetwsi.h
4
 * Project:	Gigabit Ethernet Adapters, TWSI-Module
5
 * Version:	$Revision: 1.7 $
6
 * Date:	$Date: 2004/12/20 14:48:51 $
7
 * Purpose:	Special defines for TWSI
8
 *
9
 ******************************************************************************/
10
11
/******************************************************************************
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
20
 *	The information in this file is provided "AS IS" without warranty.
21
 *
22
 ******************************************************************************/
23
24
/*
25
 * SKGETWSI.H	contains all SK-98xx specific defines for the TWSI handling
26
 */
27
28
#ifndef _INC_SKGETWSI_H_
29
#define _INC_SKGETWSI_H_
30
31
/*
32
 * Macros to access the B2_I2C_CTRL
33
 */
34
#define SK_I2C_CTL(IoC, flag, dev, dev_size, reg, burst) \
35
	SK_OUT32(IoC, B2_I2C_CTRL,\
36
		(flag ? 0x80000000UL : 0x0L) | \
37
		(((SK_U32)reg << 16) & I2C_ADDR) | \
38
		(((SK_U32)dev << 9) & I2C_DEV_SEL) | \
39
		(dev_size & I2C_DEV_SIZE) | \
40
		((burst << 4) & I2C_BURST_LEN))
41
42
#define SK_I2C_STOP(IoC) {			\
43
	SK_U32	I2cCtrl;				\
44
	SK_IN32(IoC, B2_I2C_CTRL, &I2cCtrl);		\
45
	SK_OUT32(IoC, B2_I2C_CTRL, I2cCtrl | I2C_STOP);	\
46
}
47
48
#define SK_I2C_GET_CTL(IoC, pI2cCtrl)	SK_IN32(IoC, B2_I2C_CTRL, pI2cCtrl)
49
50
/*
51
 * Macros to access the TWSI SW Registers
52
 */
53
#define SK_I2C_SET_BIT(IoC, SetBits) {			\
54
	SK_U8	OrgBits;				\
55
	SK_IN8(IoC, B2_I2C_SW, &OrgBits);		\
56
	SK_OUT8(IoC, B2_I2C_SW, OrgBits | (SK_U8)(SetBits));	\
57
}
58
59
#define SK_I2C_CLR_BIT(IoC, ClrBits) {			\
60
	SK_U8	OrgBits;				\
61
	SK_IN8(IoC, B2_I2C_SW, &OrgBits);		\
62
	SK_OUT8(IoC, B2_I2C_SW, OrgBits & ~((SK_U8)(ClrBits)));	\
63
}
64
65
#define SK_I2C_GET_SW(IoC, pI2cSw)	SK_IN8(IoC, B2_I2C_SW, pI2cSw)
66
67
/*
68
 * define the possible sensor states
69
 */
70
#define SK_SEN_IDLE		0	/* Idle: sensor not read */
71
#define SK_SEN_VALUE	1	/* Value Read cycle */
72
#define SK_SEN_VALEXT	2	/* Extended Value Read cycle */
73
74
/*
75
 * Conversion factor to convert read Voltage sensor to milli Volt
76
 * Conversion factor to convert read Temperature sensor to 10th degree Celsius
77
 */
78
#define SK_LM80_VT_LSB		22	/* 22mV LSB resolution */
79
#define SK_LM80_TEMP_LSB	10	/* 1 degree LSB resolution */
80
#define SK_LM80_TEMPEXT_LSB	 5	/* 0.5 degree LSB resolution for ext. val. */
81
82
/*
83
 * formula: counter = (22500*60)/(rpm * divisor * pulses/2)
84
 * assuming: 6500rpm, 4 pulses, divisor 1
85
 */
86
#define SK_LM80_FAN_FAKTOR	((22500L*60)/(1*2))
87
88
/*
89
 * Define sensor management data
90
 * Maximum is reached on Genesis copper dual port and Yukon-64
91
 * Board specific maximum is in pAC->I2c.MaxSens
92
 */
93
#define SK_MAX_SENSORS	8	/* maximal no. of installed sensors */
94
#define SK_MIN_SENSORS	5	/* minimal no. of installed sensors */
95
96
/*
97
 * To watch the state machine (SM) use the timer in two ways
98
 * instead of one as hitherto
99
 */
100
#define SK_TIMER_WATCH_SM		0	/* Watch the SM to finish in a spec. time */
101
#define SK_TIMER_NEW_GAUGING	1	/* Start a new gauging when timer expires */
102
103
/*
104
 * Defines for the individual thresholds
105
 */
106
107
#define C_PLUS_20		120 / 100
108
#define C_PLUS_15		115 / 100
109
#define C_PLUS_10		110 / 100
110
#define C_PLUS_5		105 / 100
111
#define C_MINUS_5		 95 / 100
112
#define C_MINUS_10		 90 / 100
113
#define C_MINUS_15		 85 / 100
114
115
/* Temperature sensor */
116
#define SK_SEN_TEMP_HIGH_ERR	800	/* Temperature High Err  Threshold */
117
#define SK_SEN_TEMP_HIGH_WARN	700	/* Temperature High Warn Threshold */
118
#define SK_SEN_TEMP_LOW_WARN	100	/* Temperature Low  Warn Threshold */
119
#define SK_SEN_TEMP_LOW_ERR		  0	/* Temperature Low  Err  Threshold */
120
121
/* VCC which should be 5 V */
122
#define SK_SEN_PCI_5V_HIGH_ERR		5588	/* Voltage PCI High Err  Threshold */
123
#define SK_SEN_PCI_5V_HIGH_WARN		5346	/* Voltage PCI High Warn Threshold */
124
#define SK_SEN_PCI_5V_LOW_WARN		4664	/* Voltage PCI Low  Warn Threshold */
125
#define SK_SEN_PCI_5V_LOW_ERR		4422	/* Voltage PCI Low  Err  Threshold */
126
127
/*
128
 * VIO may be 5 V or 3.3 V. Initialization takes two parts:
129
 * 1. Initialize lowest lower limit and highest higher limit.
130
 * 2. After the first value is read correct the upper or the lower limit to
131
 *    the appropriate C constant.
132
 *
133
 * Warning limits are +-5% of the exepected voltage.
134
 * Error limits are +-10% of the expected voltage.
135
 */
136
137
/* Bug fix AF: 16.Aug.2001: Correct the init base of LM80 sensor */
138
139
#define SK_SEN_PCI_IO_5V_HIGH_ERR	5566	/* + 10% V PCI-IO High Err Threshold */
140
#define SK_SEN_PCI_IO_5V_HIGH_WARN	5324	/* +  5% V PCI-IO High Warn Threshold */
141
					/*		5000	mVolt */
142
#define SK_SEN_PCI_IO_5V_LOW_WARN	4686	/* -  5% V PCI-IO Low Warn Threshold */
143
#define SK_SEN_PCI_IO_5V_LOW_ERR	4444	/* - 10% V PCI-IO Low Err Threshold */
144
145
#define SK_SEN_PCI_IO_RANGE_LIMITER	4000	/* 4000 mV range delimiter */
146
147
/* correction values for the second pass */
148
#define SK_SEN_PCI_IO_3V3_HIGH_ERR	3850	/* + 15% V PCI-IO High Err Threshold */
149
#define SK_SEN_PCI_IO_3V3_HIGH_WARN	3674	/* + 10% V PCI-IO High Warn Threshold */
150
					/*		3300	mVolt */
151
#define SK_SEN_PCI_IO_3V3_LOW_WARN	2926	/* - 10% V PCI-IO Low Warn Threshold */
152
#define SK_SEN_PCI_IO_3V3_LOW_ERR	2772	/* - 15% V PCI-IO Low Err  Threshold */
153
154
/*
155
 * VDD voltage
156
 */
157
#define SK_SEN_VDD_HIGH_ERR		3630	/* Voltage ASIC High Err  Threshold */
158
#define SK_SEN_VDD_HIGH_WARN	3476	/* Voltage ASIC High Warn Threshold */
159
#define SK_SEN_VDD_LOW_WARN		3146	/* Voltage ASIC Low  Warn Threshold */
160
#define SK_SEN_VDD_LOW_ERR		2970	/* Voltage ASIC Low  Err  Threshold */
161
162
/*
163
 * PHY PLL 3V3 voltage
164
 */
165
#define SK_SEN_PLL_3V3_HIGH_ERR		3630	/* Voltage PMA High Err  Threshold */
166
#define SK_SEN_PLL_3V3_HIGH_WARN	3476	/* Voltage PMA High Warn Threshold */
167
#define SK_SEN_PLL_3V3_LOW_WARN		3146	/* Voltage PMA Low  Warn Threshold */
168
#define SK_SEN_PLL_3V3_LOW_ERR		2970	/* Voltage PMA Low  Err  Threshold */
169
170
/*
171
 * VAUX (YUKON only)
172
 */
173
#define SK_SEN_VAUX_3V3_VAL		3300	/* Voltage VAUX 3.3 Volt */
174
175
#define SK_SEN_VAUX_3V3_HIGH_ERR	(SK_I32)(SK_SEN_VAUX_3V3_VAL * C_PLUS_10)
176
#define SK_SEN_VAUX_3V3_HIGH_WARN	(SK_I32)(SK_SEN_VAUX_3V3_VAL * C_PLUS_5)
177
#define SK_SEN_VAUX_3V3_LOW_WARN	(SK_I32)(SK_SEN_VAUX_3V3_VAL * C_MINUS_5)
178
#define SK_SEN_VAUX_3V3_LOW_ERR		(SK_I32)(SK_SEN_VAUX_3V3_VAL * C_MINUS_10)
179
180
#define SK_SEN_VAUX_RANGE_LIMITER	1000	/* 1000 mV range delimiter */
181
182
/*
183
 * PHY 2V5 voltage
184
 */
185
#define SK_SEN_PHY_2V5_VAL		2500	/* Voltage PHY 2.5 Volt */
186
187
#define SK_SEN_PHY_2V5_HIGH_ERR		(SK_I32)(SK_SEN_PHY_2V5_VAL * C_PLUS_10)
188
#define SK_SEN_PHY_2V5_HIGH_WARN	(SK_I32)(SK_SEN_PHY_2V5_VAL * C_PLUS_5)
189
#define SK_SEN_PHY_2V5_LOW_WARN		(SK_I32)(SK_SEN_PHY_2V5_VAL * C_MINUS_5)
190
#define SK_SEN_PHY_2V5_LOW_ERR		(SK_I32)(SK_SEN_PHY_2V5_VAL * C_MINUS_10)
191
192
/*
193
 * ASIC Core 1V5 voltage (YUKON only)
194
 */
195
#define SK_SEN_CORE_1V5_VAL		1500	/* Voltage ASIC Core 1.5 Volt */
196
197
#define SK_SEN_CORE_1V5_HIGH_ERR	(SK_I32)(SK_SEN_CORE_1V5_VAL * C_PLUS_10)
198
#define SK_SEN_CORE_1V5_HIGH_WARN	(SK_I32)(SK_SEN_CORE_1V5_VAL * C_PLUS_5)
199
#define SK_SEN_CORE_1V5_LOW_WARN	(SK_I32)(SK_SEN_CORE_1V5_VAL * C_MINUS_5)
200
#define SK_SEN_CORE_1V5_LOW_ERR 	(SK_I32)(SK_SEN_CORE_1V5_VAL * C_MINUS_10)
201
202
/*
203
 * ASIC Core 1V2 (1V3) voltage (YUKON-2 only)
204
 */
205
#define SK_SEN_CORE_1V2_VAL		1200	/* Voltage ASIC Core 1.2 Volt */
206
207
#define SK_SEN_CORE_1V2_HIGH_ERR	(SK_I32)(SK_SEN_CORE_1V2_VAL * C_PLUS_20)
208
#define SK_SEN_CORE_1V2_HIGH_WARN	(SK_I32)(SK_SEN_CORE_1V2_VAL * C_PLUS_15)
209
#define SK_SEN_CORE_1V2_LOW_WARN	(SK_I32)(SK_SEN_CORE_1V2_VAL * C_MINUS_5)
210
#define SK_SEN_CORE_1V2_LOW_ERR 	(SK_I32)(SK_SEN_CORE_1V2_VAL * C_MINUS_10)
211
212
#define SK_SEN_CORE_1V3_VAL		1300	/* Voltage ASIC Core 1.3 Volt */
213
214
#define SK_SEN_CORE_1V3_HIGH_ERR	(SK_I32)(SK_SEN_CORE_1V3_VAL * C_PLUS_15)
215
#define SK_SEN_CORE_1V3_HIGH_WARN	(SK_I32)(SK_SEN_CORE_1V3_VAL * C_PLUS_10)
216
#define SK_SEN_CORE_1V3_LOW_WARN	(SK_I32)(SK_SEN_CORE_1V3_VAL * C_MINUS_5)
217
#define SK_SEN_CORE_1V3_LOW_ERR 	(SK_I32)(SK_SEN_CORE_1V3_VAL * C_MINUS_10)
218
219
/*
220
 * FAN 1 speed
221
 */
222
/* assuming: 6500rpm +-15%, 4 pulses,
223
 * warning at:	80 %
224
 * error at:	70 %
225
 * no upper limit
226
 */
227
#define SK_SEN_FAN_HIGH_ERR		20000	/* FAN Speed High Err Threshold */
228
#define SK_SEN_FAN_HIGH_WARN	20000	/* FAN Speed High Warn Threshold */
229
#define SK_SEN_FAN_LOW_WARN		 5200	/* FAN Speed Low Warn Threshold */
230
#define SK_SEN_FAN_LOW_ERR		 4550	/* FAN Speed Low Err Threshold */
231
232
/*
233
 * Some Voltages need dynamic thresholds
234
 */
235
#define SK_SEN_DYN_INIT_NONE		 0  /* No dynamic init of thresholds */
236
#define SK_SEN_DYN_INIT_PCI_IO		10  /* Init PCI-IO with new thresholds */
237
#define SK_SEN_DYN_INIT_VAUX		11  /* Init VAUX with new thresholds */
238
239
extern	int SkLm80ReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
240
#endif	/* n_INC_SKGETWSI_H */
241
(-)linux/drivers/net/sk98lin/h/ski2c.h (-177 lines)
Lines 1-177 Link Here
1
/******************************************************************************
2
 *
3
 * Name:	ski2c.h
4
 * Project:	Gigabit Ethernet Adapters, TWSI-Module
5
 * Version:	$Revision: 1.35 $
6
 * Date:	$Date: 2003/10/20 09:06:30 $
7
 * Purpose:	Defines to access Voltage and Temperature Sensor
8
 *
9
 ******************************************************************************/
10
11
/******************************************************************************
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
22
 *
23
 ******************************************************************************/
24
25
/*
26
 * SKI2C.H	contains all I2C specific defines
27
 */
28
29
#ifndef _SKI2C_H_
30
#define _SKI2C_H_
31
32
typedef struct  s_Sensor SK_SENSOR;
33
34
#include "h/skgei2c.h"
35
36
/*
37
 * Define the I2C events.
38
 */
39
#define SK_I2CEV_IRQ	1	/* IRQ happened Event */
40
#define SK_I2CEV_TIM	2	/* Timeout event */
41
#define SK_I2CEV_CLEAR	3	/* Clear MIB Values */
42
43
/*
44
 * Define READ and WRITE Constants.
45
 */
46
#define I2C_READ	0
47
#define I2C_WRITE	1
48
#define I2C_BURST	1
49
#define I2C_SINGLE	0
50
51
#define SKERR_I2C_E001		(SK_ERRBASE_I2C+0)
52
#define SKERR_I2C_E001MSG	"Sensor index unknown"
53
#define SKERR_I2C_E002		(SKERR_I2C_E001+1)
54
#define SKERR_I2C_E002MSG	"TWSI: transfer does not complete"
55
#define SKERR_I2C_E003		(SKERR_I2C_E002+1)
56
#define SKERR_I2C_E003MSG	"LM80: NAK on device send"
57
#define SKERR_I2C_E004		(SKERR_I2C_E003+1)
58
#define SKERR_I2C_E004MSG	"LM80: NAK on register send"
59
#define SKERR_I2C_E005		(SKERR_I2C_E004+1)
60
#define SKERR_I2C_E005MSG	"LM80: NAK on device (2) send"
61
#define SKERR_I2C_E006		(SKERR_I2C_E005+1)
62
#define SKERR_I2C_E006MSG	"Unknown event"
63
#define SKERR_I2C_E007		(SKERR_I2C_E006+1)
64
#define SKERR_I2C_E007MSG	"LM80 read out of state"
65
#define SKERR_I2C_E008		(SKERR_I2C_E007+1)
66
#define SKERR_I2C_E008MSG	"Unexpected sensor read completed"
67
#define SKERR_I2C_E009		(SKERR_I2C_E008+1)
68
#define SKERR_I2C_E009MSG	"WARNING: temperature sensor out of range"
69
#define SKERR_I2C_E010		(SKERR_I2C_E009+1)
70
#define SKERR_I2C_E010MSG	"WARNING: voltage sensor out of range"
71
#define SKERR_I2C_E011		(SKERR_I2C_E010+1)
72
#define SKERR_I2C_E011MSG	"ERROR: temperature sensor out of range"
73
#define SKERR_I2C_E012		(SKERR_I2C_E011+1)
74
#define SKERR_I2C_E012MSG	"ERROR: voltage sensor out of range"
75
#define SKERR_I2C_E013		(SKERR_I2C_E012+1)
76
#define SKERR_I2C_E013MSG	"ERROR: couldn't init sensor"
77
#define SKERR_I2C_E014		(SKERR_I2C_E013+1)
78
#define SKERR_I2C_E014MSG	"WARNING: fan sensor out of range"
79
#define SKERR_I2C_E015		(SKERR_I2C_E014+1)
80
#define SKERR_I2C_E015MSG	"ERROR: fan sensor out of range"
81
#define SKERR_I2C_E016		(SKERR_I2C_E015+1)
82
#define SKERR_I2C_E016MSG	"TWSI: active transfer does not complete"
83
84
/*
85
 * Define Timeout values
86
 */
87
#define SK_I2C_TIM_LONG		2000000L	/* 2 seconds */
88
#define SK_I2C_TIM_SHORT	 100000L	/* 100 milliseconds */
89
#define SK_I2C_TIM_WATCH	1000000L	/* 1 second */
90
91
/*
92
 * Define trap and error log hold times
93
 */
94
#ifndef	SK_SEN_ERR_TR_HOLD
95
#define SK_SEN_ERR_TR_HOLD		(4*SK_TICKS_PER_SEC)
96
#endif
97
#ifndef	SK_SEN_ERR_LOG_HOLD
98
#define SK_SEN_ERR_LOG_HOLD		(60*SK_TICKS_PER_SEC)
99
#endif
100
#ifndef	SK_SEN_WARN_TR_HOLD
101
#define SK_SEN_WARN_TR_HOLD		(15*SK_TICKS_PER_SEC)
102
#endif
103
#ifndef	SK_SEN_WARN_LOG_HOLD
104
#define SK_SEN_WARN_LOG_HOLD	(15*60*SK_TICKS_PER_SEC)
105
#endif
106
107
/*
108
 * Defines for SenType
109
 */
110
#define SK_SEN_UNKNOWN	0
111
#define SK_SEN_TEMP		1
112
#define SK_SEN_VOLT		2
113
#define SK_SEN_FAN		3
114
115
/*
116
 * Define for the SenErrorFlag
117
 */
118
#define SK_SEN_ERR_NOT_PRESENT	0	/* Error Flag: Sensor not present */
119
#define SK_SEN_ERR_OK			1	/* Error Flag: O.K. */
120
#define SK_SEN_ERR_WARN			2	/* Error Flag: Warning */
121
#define SK_SEN_ERR_ERR			3	/* Error Flag: Error */
122
#define SK_SEN_ERR_FAULTY		4	/* Error Flag: Faulty */
123
124
/*
125
 * Define the Sensor struct
126
 */
127
struct	s_Sensor {
128
	char	*SenDesc;			/* Description */
129
	int		SenType;			/* Voltage or Temperature */
130
	SK_I32	SenValue;			/* Current value of the sensor */
131
	SK_I32	SenThreErrHigh;		/* High error Threshhold of this sensor */
132
	SK_I32	SenThreWarnHigh;	/* High warning Threshhold of this sensor */
133
	SK_I32	SenThreErrLow;		/* Lower error Threshold of the sensor */
134
	SK_I32	SenThreWarnLow;		/* Lower warning Threshold of the sensor */
135
	int		SenErrFlag;			/* Sensor indicated an error */
136
	SK_BOOL	SenInit;			/* Is sensor initialized ? */
137
	SK_U64	SenErrCts;			/* Error trap counter */
138
	SK_U64	SenWarnCts;			/* Warning trap counter */
139
	SK_U64	SenBegErrTS;		/* Begin error timestamp */
140
	SK_U64	SenBegWarnTS;		/* Begin warning timestamp */
141
	SK_U64	SenLastErrTrapTS;	/* Last error trap timestamp */
142
	SK_U64	SenLastErrLogTS;	/* Last error log timestamp */
143
	SK_U64	SenLastWarnTrapTS;	/* Last warning trap timestamp */
144
	SK_U64	SenLastWarnLogTS;	/* Last warning log timestamp */
145
	int		SenState;			/* Sensor State (see HW specific include) */
146
	int		(*SenRead)(SK_AC *pAC, SK_IOC IoC, struct s_Sensor *pSen);
147
								/* Sensors read function */
148
	SK_U16	SenReg;				/* Register Address for this sensor */
149
	SK_U8	SenDev;				/* Device Selection for this sensor */
150
};
151
152
typedef	struct	s_I2c {
153
	SK_SENSOR	SenTable[SK_MAX_SENSORS];	/* Sensor Table */
154
	int			CurrSens;	/* Which sensor is currently queried */
155
	int			MaxSens;	/* Max. number of sensors */
156
	int			TimerMode;	/* Use the timer also to watch the state machine */
157
	int			InitLevel;	/* Initialized Level */
158
#ifndef SK_DIAG
159
	int			DummyReads;	/* Number of non-checked dummy reads */
160
	SK_TIMER	SenTimer;	/* Sensors timer */
161
#endif /* !SK_DIAG */
162
} SK_I2C;
163
164
extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level);
165
extern int SkI2cWrite(SK_AC *pAC, SK_IOC IoC, SK_U32 Data, int Dev, int Size,
166
					   int Reg, int Burst);
167
extern int SkI2cReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
168
#ifdef SK_DIAG
169
extern	SK_U32 SkI2cRead(SK_AC *pAC, SK_IOC IoC, int Dev, int Size, int Reg,
170
						 int Burst);
171
#else /* !SK_DIAG */
172
extern int SkI2cEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
173
extern void SkI2cWaitIrq(SK_AC *pAC, SK_IOC IoC);
174
extern void SkI2cIsr(SK_AC *pAC, SK_IOC IoC);
175
#endif /* !SK_DIAG */
176
#endif /* n_SKI2C_H */
177
(-)linux/drivers/net/sk98lin/h/skqueue.h (-2 / +11 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skqueue.h
3
 * Name:	skqueue.h
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
5
 * Version:	$Revision: 1.16 $
5
 * Version:	$Revision: 2.3 $
6
 * Date:	$Date: 2003/09/16 12:50:32 $
6
 * Date:	$Date: 2004/05/14 13:39:15 $
7
 * Purpose:	Defines for the Event queue
7
 * Purpose:	Defines for the Event queue
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 45-50 Link Here
45
#define	SKGE_RSF	11	/* RSF Aggregation Event Class */
45
#define	SKGE_RSF	11	/* RSF Aggregation Event Class */
46
#define	SKGE_MARKER	12	/* MARKER Aggregation Event Class */
46
#define	SKGE_MARKER	12	/* MARKER Aggregation Event Class */
47
#define	SKGE_FD		13	/* FD Distributor Event Class */
47
#define	SKGE_FD		13	/* FD Distributor Event Class */
48
#ifdef SK_ASF
49
#define	SKGE_ASF	14	/* ASF Event Class */
50
#endif
48
51
49
/*
52
/*
50
 * define event queue as circular buffer
53
 * define event queue as circular buffer
Lines 90-94 Link Here
90
#define	SKERR_Q_E001MSG	"Event queue overflow"
93
#define	SKERR_Q_E001MSG	"Event queue overflow"
91
#define	SKERR_Q_E002	(SKERR_Q_E001+1)
94
#define	SKERR_Q_E002	(SKERR_Q_E001+1)
92
#define	SKERR_Q_E002MSG	"Undefined event class"
95
#define	SKERR_Q_E002MSG	"Undefined event class"
96
#define	SKERR_Q_E003	(SKERR_Q_E001+2)
97
#define	SKERR_Q_E003MSG	"Event queued in Init Level 0"
98
#define	SKERR_Q_E004	(SKERR_Q_E001+3)
99
#define	SKERR_Q_E004MSG	"Error Reported from Event Fuction (Queue Blocked)"
100
#define	SKERR_Q_E005	(SKERR_Q_E001+4)
101
#define	SKERR_Q_E005MSG	"Event scheduler called in Init Level 0 or 1"
93
#endif	/* _SKQUEUE_H_ */
102
#endif	/* _SKQUEUE_H_ */
94
103
(-)linux/drivers/net/sk98lin/h/skrlmt.h (-2 / +2 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skrlmt.h
3
 * Name:	skrlmt.h
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.37 $
5
 * Version:	$Revision: 2.1 $
6
 * Date:	$Date: 2003/04/15 09:43:43 $
6
 * Date:	$Date: 2003/10/27 14:16:09 $
7
 * Purpose:	Header file for Redundant Link ManagemenT.
7
 * Purpose:	Header file for Redundant Link ManagemenT.
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/h/sktimer.h (-2 / +2 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	sktimer.h
3
 * Name:	sktimer.h
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
5
 * Version:	$Revision: 1.11 $
5
 * Version:	$Revision: 2.1 $
6
 * Date:	$Date: 2003/09/16 12:58:18 $
6
 * Date:	$Date: 2003/10/27 14:16:09 $
7
 * Purpose:	Defines for the timer functions
7
 * Purpose:	Defines for the timer functions
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/h/sktwsi.h (+177 lines)
Line 0 Link Here
1
/******************************************************************************
2
 *
3
 * Name:	sktwsi.h
4
 * Project:	Gigabit Ethernet Adapters, TWSI-Module
5
 * Version:	$Revision: 1.1 $
6
 * Date:	$Date: 2003/12/19 14:02:56 $
7
 * Purpose:	Defines to access Voltage and Temperature Sensor
8
 *
9
 ******************************************************************************/
10
11
/******************************************************************************
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
22
 *
23
 ******************************************************************************/
24
25
/*
26
 * SKTWSI.H	contains all TWSI specific defines
27
 */
28
29
#ifndef _SKTWSI_H_
30
#define _SKTWSI_H_
31
32
typedef struct  s_Sensor SK_SENSOR;
33
34
#include "h/skgetwsi.h"
35
36
/*
37
 * Define the TWSI events.
38
 */
39
#define SK_I2CEV_IRQ	1	/* IRQ happened Event */
40
#define SK_I2CEV_TIM	2	/* Timeout event */
41
#define SK_I2CEV_CLEAR	3	/* Clear MIB Values */
42
43
/*
44
 * Define READ and WRITE Constants.
45
 */
46
#define I2C_READ	0
47
#define I2C_WRITE	1
48
#define I2C_BURST	1
49
#define I2C_SINGLE	0
50
51
#define SKERR_I2C_E001		(SK_ERRBASE_I2C+0)
52
#define SKERR_I2C_E001MSG	"Sensor index unknown"
53
#define SKERR_I2C_E002		(SKERR_I2C_E001+1)
54
#define SKERR_I2C_E002MSG	"TWSI: transfer does not complete"
55
#define SKERR_I2C_E003		(SKERR_I2C_E002+1)
56
#define SKERR_I2C_E003MSG	"LM80: NAK on device send"
57
#define SKERR_I2C_E004		(SKERR_I2C_E003+1)
58
#define SKERR_I2C_E004MSG	"LM80: NAK on register send"
59
#define SKERR_I2C_E005		(SKERR_I2C_E004+1)
60
#define SKERR_I2C_E005MSG	"LM80: NAK on device (2) send"
61
#define SKERR_I2C_E006		(SKERR_I2C_E005+1)
62
#define SKERR_I2C_E006MSG	"Unknown event"
63
#define SKERR_I2C_E007		(SKERR_I2C_E006+1)
64
#define SKERR_I2C_E007MSG	"LM80 read out of state"
65
#define SKERR_I2C_E008		(SKERR_I2C_E007+1)
66
#define SKERR_I2C_E008MSG	"Unexpected sensor read completed"
67
#define SKERR_I2C_E009		(SKERR_I2C_E008+1)
68
#define SKERR_I2C_E009MSG	"WARNING: temperature sensor out of range"
69
#define SKERR_I2C_E010		(SKERR_I2C_E009+1)
70
#define SKERR_I2C_E010MSG	"WARNING: voltage sensor out of range"
71
#define SKERR_I2C_E011		(SKERR_I2C_E010+1)
72
#define SKERR_I2C_E011MSG	"ERROR: temperature sensor out of range"
73
#define SKERR_I2C_E012		(SKERR_I2C_E011+1)
74
#define SKERR_I2C_E012MSG	"ERROR: voltage sensor out of range"
75
#define SKERR_I2C_E013		(SKERR_I2C_E012+1)
76
#define SKERR_I2C_E013MSG	"ERROR: couldn't init sensor"
77
#define SKERR_I2C_E014		(SKERR_I2C_E013+1)
78
#define SKERR_I2C_E014MSG	"WARNING: fan sensor out of range"
79
#define SKERR_I2C_E015		(SKERR_I2C_E014+1)
80
#define SKERR_I2C_E015MSG	"ERROR: fan sensor out of range"
81
#define SKERR_I2C_E016		(SKERR_I2C_E015+1)
82
#define SKERR_I2C_E016MSG	"TWSI: active transfer does not complete"
83
84
/*
85
 * Define Timeout values
86
 */
87
#define SK_I2C_TIM_LONG		2000000L	/* 2 seconds */
88
#define SK_I2C_TIM_SHORT	 100000L	/* 100 milliseconds */
89
#define SK_I2C_TIM_WATCH	1000000L	/* 1 second */
90
91
/*
92
 * Define trap and error log hold times
93
 */
94
#ifndef	SK_SEN_ERR_TR_HOLD
95
#define SK_SEN_ERR_TR_HOLD		(4*SK_TICKS_PER_SEC)
96
#endif
97
#ifndef	SK_SEN_ERR_LOG_HOLD
98
#define SK_SEN_ERR_LOG_HOLD		(60*SK_TICKS_PER_SEC)
99
#endif
100
#ifndef	SK_SEN_WARN_TR_HOLD
101
#define SK_SEN_WARN_TR_HOLD		(15*SK_TICKS_PER_SEC)
102
#endif
103
#ifndef	SK_SEN_WARN_LOG_HOLD
104
#define SK_SEN_WARN_LOG_HOLD	(15*60*SK_TICKS_PER_SEC)
105
#endif
106
107
/*
108
 * Defines for SenType
109
 */
110
#define SK_SEN_UNKNOWN	0
111
#define SK_SEN_TEMP		1
112
#define SK_SEN_VOLT		2
113
#define SK_SEN_FAN		3
114
115
/*
116
 * Define for the SenErrorFlag
117
 */
118
#define SK_SEN_ERR_NOT_PRESENT	0	/* Error Flag: Sensor not present */
119
#define SK_SEN_ERR_OK			1	/* Error Flag: O.K. */
120
#define SK_SEN_ERR_WARN			2	/* Error Flag: Warning */
121
#define SK_SEN_ERR_ERR			3	/* Error Flag: Error */
122
#define SK_SEN_ERR_FAULTY		4	/* Error Flag: Faulty */
123
124
/*
125
 * Define the Sensor struct
126
 */
127
struct	s_Sensor {
128
	char	*SenDesc;			/* Description */
129
	int		SenType;			/* Voltage or Temperature */
130
	SK_I32	SenValue;			/* Current value of the sensor */
131
	SK_I32	SenThreErrHigh;		/* High error Threshhold of this sensor */
132
	SK_I32	SenThreWarnHigh;	/* High warning Threshhold of this sensor */
133
	SK_I32	SenThreErrLow;		/* Lower error Threshold of the sensor */
134
	SK_I32	SenThreWarnLow;		/* Lower warning Threshold of the sensor */
135
	int		SenErrFlag;			/* Sensor indicated an error */
136
	SK_BOOL	SenInit;			/* Is sensor initialized ? */
137
	SK_U64	SenErrCts;			/* Error trap counter */
138
	SK_U64	SenWarnCts;			/* Warning trap counter */
139
	SK_U64	SenBegErrTS;		/* Begin error timestamp */
140
	SK_U64	SenBegWarnTS;		/* Begin warning timestamp */
141
	SK_U64	SenLastErrTrapTS;	/* Last error trap timestamp */
142
	SK_U64	SenLastErrLogTS;	/* Last error log timestamp */
143
	SK_U64	SenLastWarnTrapTS;	/* Last warning trap timestamp */
144
	SK_U64	SenLastWarnLogTS;	/* Last warning log timestamp */
145
	int		SenState;			/* Sensor State (see HW specific include) */
146
	int		(*SenRead)(SK_AC *pAC, SK_IOC IoC, struct s_Sensor *pSen);
147
								/* Sensors read function */
148
	SK_U16	SenReg;				/* Register Address for this sensor */
149
	SK_U8	SenDev;				/* Device Selection for this sensor */
150
};
151
152
typedef	struct	s_I2c {
153
	SK_SENSOR	SenTable[SK_MAX_SENSORS];	/* Sensor Table */
154
	int			CurrSens;	/* Which sensor is currently queried */
155
	int			MaxSens;	/* Max. number of sensors */
156
	int			TimerMode;	/* Use the timer also to watch the state machine */
157
	int			InitLevel;	/* Initialized Level */
158
#ifndef SK_DIAG
159
	int			DummyReads;	/* Number of non-checked dummy reads */
160
	SK_TIMER	SenTimer;	/* Sensors timer */
161
#endif /* !SK_DIAG */
162
} SK_I2C;
163
164
extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level);
165
extern int SkI2cWrite(SK_AC *pAC, SK_IOC IoC, SK_U32 Data, int Dev, int Size,
166
					   int Reg, int Burst);
167
extern int SkI2cReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
168
#ifdef SK_DIAG
169
extern	SK_U32 SkI2cRead(SK_AC *pAC, SK_IOC IoC, int Dev, int Size, int Reg,
170
						 int Burst);
171
#else /* !SK_DIAG */
172
extern int SkI2cEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
173
extern void SkI2cWaitIrq(SK_AC *pAC, SK_IOC IoC);
174
extern void SkI2cIsr(SK_AC *pAC, SK_IOC IoC);
175
#endif /* !SK_DIAG */
176
#endif /* n_SKTWSI_H */
177
(-)linux/drivers/net/sk98lin/h/sktypes.h (-41 / +21 lines)
Lines 3-9 Link Here
3
 * Name:	sktypes.h
3
 * Name:	sktypes.h
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.2 $
5
 * Version:	$Revision: 1.2 $
6
 * Date:	$Date: 2003/10/07 08:16:51 $
6
 * Date:	$Date: 2004/07/09 13:29:49 $
7
 * Purpose:	Define data types for Linux
7
 * Purpose:	Define data types for Linux
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 22-69 Link Here
22
 *
22
 *
23
 ******************************************************************************/
23
 ******************************************************************************/
24
 
24
 
25
/******************************************************************************
26
 *
27
 * Description:
28
 *
29
 * In this file, all data types that are needed by the common modules
30
 * are mapped to Linux data types.
31
 * 
32
 *
33
 * Include File Hierarchy:
34
 *
35
 *
36
 ******************************************************************************/
37
38
#ifndef __INC_SKTYPES_H
25
#ifndef __INC_SKTYPES_H
39
#define __INC_SKTYPES_H
26
#define __INC_SKTYPES_H
40
27
41
28
#define SK_I8    s8    /* 8 bits (1 byte) signed       */
42
/* defines *******************************************************************/
29
#define SK_U8    u8    /* 8 bits (1 byte) unsigned     */
43
30
#define SK_I16  s16    /* 16 bits (2 bytes) signed     */
44
/*
31
#define SK_U16  u16    /* 16 bits (2 bytes) unsigned   */
45
 * Data types with a specific size. 'I' = signed, 'U' = unsigned.
32
#define SK_I32  s32    /* 32 bits (4 bytes) signed     */
46
 */
33
#define SK_U32  u32    /* 32 bits (4 bytes) unsigned   */
47
#define SK_I8	s8
34
#define SK_I64  s64    /* 64 bits (8 bytes) signed     */
48
#define SK_U8	u8
35
#define SK_U64  u64    /* 64 bits (8 bytes) unsigned   */
49
#define SK_I16	s16
36
50
#define SK_U16	u16
37
#define SK_UPTR	ulong  /* casting pointer <-> integral */
51
#define SK_I32	s32
38
52
#define SK_U32	u32
39
#define SK_BOOL   SK_U8
53
#define SK_I64	s64
40
#define SK_FALSE  0
54
#define SK_U64	u64
41
#define SK_TRUE   (!SK_FALSE)
55
56
#define SK_UPTR	ulong		/* casting pointer <-> integral */
57
58
/*
59
* Boolean type.
60
*/
61
#define SK_BOOL		SK_U8
62
#define SK_FALSE	0
63
#define SK_TRUE		(!SK_FALSE)
64
65
/* typedefs *******************************************************************/
66
67
/* function prototypes ********************************************************/
68
42
69
#endif	/* __INC_SKTYPES_H */
43
#endif	/* __INC_SKTYPES_H */
44
45
/*******************************************************************************
46
 *
47
 * End of file
48
 *
49
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/h/skversion.h (-18 / +16 lines)
Lines 1-17 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 *
2
 *
3
 * Name:	version.h
3
 * Name:	skversion.h
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.5 $
5
 * Version:	$Revision: 1.3 $
6
 * Date:	$Date: 2003/10/07 08:16:51 $
6
 * Date:	$Date: 2004/07/09 13:33:59 $
7
 * Purpose:	SK specific Error log support
7
 * Purpose:	specific version strings and numbers
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
10
10
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
Lines 22-38 Link Here
22
 *
22
 *
23
 ******************************************************************************/
23
 ******************************************************************************/
24
24
25
#ifdef	lint
25
#define BOOT_STRING  "sk98lin: Network Device Driver v8.16.2.3\n" \
26
static const char SysKonnectFileId[] = "@(#) (C) SysKonnect GmbH.";
26
                     "(C)Copyright 1999-2005 Marvell(R)."
27
static const char SysKonnectBuildNumber[] =
27
#define VER_STRING   "8.16.2.3"
28
	"@(#)SK-BUILD: 6.23 PL: 01"; 
28
#define PATCHLEVEL   "02"
29
#endif	/* !defined(lint) */
29
#define DRIVER_FILE_NAME   "sk98lin"
30
30
#define DRIVER_REL_DATE    "Mar-30-2005"
31
#define BOOT_STRING	"sk98lin: Network Device Driver v6.23\n" \
32
			"(C)Copyright 1999-2004 Marvell(R)."
33
34
#define VER_STRING	"6.23"
35
#define DRIVER_FILE_NAME	"sk98lin"
36
#define DRIVER_REL_DATE		"Feb-13-2004"
37
38
31
32
/*******************************************************************************
33
 *
34
 * End of file
35
 *
36
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/h/skvpd.h (-37 / +47 lines)
Lines 1-22 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 *
2
 *
3
 * Name:	skvpd.h
3
 * Name:	skvpd.h
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	Gigabit Ethernet Adapters, VPD-Module
5
 * Version:	$Revision: 1.15 $
5
 * Version:	$Revision: 2.6 $
6
 * Date:	$Date: 2003/01/13 10:39:38 $
6
 * Date:	$Date: 2004/11/09 15:18:00 $
7
 * Purpose:	Defines and Macros for VPD handling
7
 * Purpose:	Defines and Macros for VPD handling
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
10
10
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2003 SysKonnect GmbH.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2004 Marvell.
14
 *
15
 *
15
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
17
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	(at your option) any later version.
19
 *	(at your option) any later version.
19
 *
20
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
21
 *
21
 *
22
 ******************************************************************************/
22
 ******************************************************************************/
Lines 31-37 Link Here
31
/*
31
/*
32
 * Define Resource Type Identifiers and VPD keywords
32
 * Define Resource Type Identifiers and VPD keywords
33
 */
33
 */
34
#define	RES_ID		0x82	/* Resource Type ID String (Product Name) */
34
#define RES_ID		0x82	/* Resource Type ID String (Product Name) */
35
#define RES_VPD_R	0x90	/* start of VPD read only area */
35
#define RES_VPD_R	0x90	/* start of VPD read only area */
36
#define RES_VPD_W	0x91	/* start of VPD read/write area */
36
#define RES_VPD_W	0x91	/* start of VPD read/write area */
37
#define RES_END		0x78	/* Resource Type End Tag */
37
#define RES_END		0x78	/* Resource Type End Tag */
Lines 40-53 Link Here
40
#define VPD_NAME	"Name"	/* Product Name, VPD name of RES_ID */
40
#define VPD_NAME	"Name"	/* Product Name, VPD name of RES_ID */
41
#endif	/* VPD_NAME */
41
#endif	/* VPD_NAME */
42
#define VPD_PN		"PN"	/* Adapter Part Number */
42
#define VPD_PN		"PN"	/* Adapter Part Number */
43
#define	VPD_EC		"EC"	/* Adapter Engineering Level */
43
#define VPD_EC		"EC"	/* Adapter Engineering Level */
44
#define VPD_MN		"MN"	/* Manufacture ID */
44
#define VPD_MN		"MN"	/* Manufacture ID */
45
#define VPD_SN		"SN"	/* Serial Number */
45
#define VPD_SN		"SN"	/* Serial Number */
46
#define VPD_CP		"CP"	/* Extended Capability */
46
#define VPD_CP		"CP"	/* Extended Capability */
47
#define VPD_RV		"RV"	/* Checksum and Reserved */
47
#define VPD_RV		"RV"	/* Checksum and Reserved */
48
#define	VPD_YA		"YA"	/* Asset Tag Identifier */
48
#define VPD_YA		"YA"	/* Asset Tag Identifier */
49
#define VPD_VL		"VL"	/* First Error Log Message (SK specific) */
49
#define VPD_VL		"VL"	/* First Error Log Message (SK specific) */
50
#define VPD_VF		"VF"	/* Second Error Log Message (SK specific) */
50
#define VPD_VF		"VF"	/* Second Error Log Message (SK specific) */
51
#define VPD_VB		"VB"	/* Boot Agent ROM Configuration (SK specific) */
52
#define VPD_VE		"VE"	/* EFI UNDI Configuration (SK specific) */
51
#define VPD_RW		"RW"	/* Remaining Read / Write Area */
53
#define VPD_RW		"RW"	/* Remaining Read / Write Area */
52
54
53
/* 'type' values for vpd_setup_para() */
55
/* 'type' values for vpd_setup_para() */
Lines 55-61 Link Here
55
#define VPD_RW_KEY	2	/* RW keys are "Yx", "Vx", and "RW" */
57
#define VPD_RW_KEY	2	/* RW keys are "Yx", "Vx", and "RW" */
56
58
57
/* 'op' values for vpd_setup_para() */
59
/* 'op' values for vpd_setup_para() */
58
#define	ADD_KEY		1	/* add the key at the pos "RV" or "RW" */
60
#define ADD_KEY		1	/* add the key at the pos "RV" or "RW" */
59
#define OWR_KEY		2	/* overwrite key if already exists */
61
#define OWR_KEY		2	/* overwrite key if already exists */
60
62
61
/*
63
/*
Lines 64-81 Link Here
64
66
65
#define VPD_DEV_ID_GENESIS 	0x4300
67
#define VPD_DEV_ID_GENESIS 	0x4300
66
68
67
#define	VPD_SIZE_YUKON		256
69
#define VPD_SIZE_YUKON		256
68
#define	VPD_SIZE_GENESIS	512
70
#define VPD_SIZE_GENESIS	512
69
#define	VPD_SIZE			512
71
#define VPD_SIZE			512
70
#define VPD_READ	0x0000
72
#define VPD_READ	0x0000
71
#define VPD_WRITE	0x8000
73
#define VPD_WRITE	0x8000
72
74
73
#define VPD_STOP(pAC,IoC)	VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
75
#define VPD_STOP(pAC,IoC)	VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
74
76
75
#define VPD_GET_RES_LEN(p)	((unsigned int) \
77
#define VPD_GET_RES_LEN(p)	((unsigned int)\
76
					(* (SK_U8 *)&(p)[1]) |\
78
					(*(SK_U8 *)&(p)[1]) |\
77
					((* (SK_U8 *)&(p)[2]) << 8))
79
					((*(SK_U8 *)&(p)[2]) << 8))
78
#define VPD_GET_VPD_LEN(p)	((unsigned int)(* (SK_U8 *)&(p)[2]))
80
#define VPD_GET_VPD_LEN(p)	((unsigned int)(*(SK_U8 *)&(p)[2]))
79
#define VPD_GET_VAL(p)		((char *)&(p)[3])
81
#define VPD_GET_VAL(p)		((char *)&(p)[3])
80
82
81
#define VPD_MAX_LEN	50
83
#define VPD_MAX_LEN	50
Lines 126-132 Link Here
126
/*
128
/*
127
 * System specific VPD macros
129
 * System specific VPD macros
128
 */
130
 */
129
#ifndef SKDIAG
131
#ifndef SK_DIAG
130
#ifndef VPD_DO_IO
132
#ifndef VPD_DO_IO
131
#define VPD_OUT8(pAC,IoC,Addr,Val)	(void)SkPciWriteCfgByte(pAC,Addr,Val)
133
#define VPD_OUT8(pAC,IoC,Addr,Val)	(void)SkPciWriteCfgByte(pAC,Addr,Val)
132
#define VPD_OUT16(pAC,IoC,Addr,Val)	(void)SkPciWriteCfgWord(pAC,Addr,Val)
134
#define VPD_OUT16(pAC,IoC,Addr,Val)	(void)SkPciWriteCfgWord(pAC,Addr,Val)
Lines 135-195 Link Here
135
#define VPD_IN16(pAC,IoC,Addr,pVal)	(void)SkPciReadCfgWord(pAC,Addr,pVal)
137
#define VPD_IN16(pAC,IoC,Addr,pVal)	(void)SkPciReadCfgWord(pAC,Addr,pVal)
136
#define VPD_IN32(pAC,IoC,Addr,pVal)	(void)SkPciReadCfgDWord(pAC,Addr,pVal)
138
#define VPD_IN32(pAC,IoC,Addr,pVal)	(void)SkPciReadCfgDWord(pAC,Addr,pVal)
137
#else	/* VPD_DO_IO */
139
#else	/* VPD_DO_IO */
138
#define VPD_OUT8(pAC,IoC,Addr,Val)	SK_OUT8(IoC,PCI_C(Addr),Val)
140
#define VPD_OUT8(pAC,IoC,Addr,Val)	SK_OUT8(IoC,PCI_C(pAC,Addr),Val)
139
#define VPD_OUT16(pAC,IoC,Addr,Val)	SK_OUT16(IoC,PCI_C(Addr),Val)
141
#define VPD_OUT16(pAC,IoC,Addr,Val)	SK_OUT16(IoC,PCI_C(pAC,Addr),Val)
140
#define VPD_OUT32(pAC,IoC,Addr,Val)	SK_OUT32(IoC,PCI_C(Addr),Val)
142
#define VPD_OUT32(pAC,IoC,Addr,Val)	SK_OUT32(IoC,PCI_C(pAC,Addr),Val)
141
#define VPD_IN8(pAC,IoC,Addr,pVal)	SK_IN8(IoC,PCI_C(Addr),pVal)
143
#define VPD_IN8(pAC,IoC,Addr,pVal)	SK_IN8(IoC,PCI_C(pAC,Addr),pVal)
142
#define VPD_IN16(pAC,IoC,Addr,pVal)	SK_IN16(IoC,PCI_C(Addr),pVal)
144
#define VPD_IN16(pAC,IoC,Addr,pVal)	SK_IN16(IoC,PCI_C(pAC,Addr),pVal)
143
#define VPD_IN32(pAC,IoC,Addr,pVal)	SK_IN32(IoC,PCI_C(Addr),pVal)
145
#define VPD_IN32(pAC,IoC,Addr,pVal)	SK_IN32(IoC,PCI_C(pAC,Addr),pVal)
144
#endif	/* VPD_DO_IO */
146
#endif	/* VPD_DO_IO */
145
#else	/* SKDIAG */
147
#else	/* SK_DIAG */
146
#define VPD_OUT8(pAC,Ioc,Addr,Val) {			\
148
#define VPD_OUT8(pAC,Ioc,Addr,Val) {			\
147
		if ((pAC)->DgT.DgUseCfgCycle)			\
149
		if ((pAC)->DgT.DgUseCfgCycle)			\
148
			SkPciWriteCfgByte(pAC,Addr,Val);	\
150
			SkPciWriteCfgByte(pAC,Addr,Val);	\
149
		else									\
151
		else									\
150
			SK_OUT8(pAC,PCI_C(Addr),Val);		\
152
			SK_OUT8(pAC,PCI_C(pAC,Addr),Val);	\
151
		}
153
		}
152
#define VPD_OUT16(pAC,Ioc,Addr,Val) {			\
154
#define VPD_OUT16(pAC,Ioc,Addr,Val) {			\
153
		if ((pAC)->DgT.DgUseCfgCycle)			\
155
		if ((pAC)->DgT.DgUseCfgCycle)			\
154
			SkPciWriteCfgWord(pAC,Addr,Val);	\
156
			SkPciWriteCfgWord(pAC,Addr,Val);	\
155
		else						\
157
		else						\
156
			SK_OUT16(pAC,PCI_C(Addr),Val);		\
158
			SK_OUT16(pAC,PCI_C(pAC,Addr),Val);	\
157
		}
159
		}
158
#define VPD_OUT32(pAC,Ioc,Addr,Val) {			\
160
#define VPD_OUT32(pAC,Ioc,Addr,Val) {			\
159
		if ((pAC)->DgT.DgUseCfgCycle)			\
161
		if ((pAC)->DgT.DgUseCfgCycle)			\
160
			SkPciWriteCfgDWord(pAC,Addr,Val);	\
162
			SkPciWriteCfgDWord(pAC,Addr,Val);	\
161
		else						\
163
		else						\
162
			SK_OUT32(pAC,PCI_C(Addr),Val); 		\
164
			SK_OUT32(pAC,PCI_C(pAC,Addr),Val);	\
163
		}
165
		}
164
#define VPD_IN8(pAC,Ioc,Addr,pVal) {			\
166
#define VPD_IN8(pAC,Ioc,Addr,pVal) {			\
165
		if ((pAC)->DgT.DgUseCfgCycle) 			\
167
		if ((pAC)->DgT.DgUseCfgCycle)			\
166
			SkPciReadCfgByte(pAC,Addr,pVal);	\
168
			SkPciReadCfgByte(pAC,Addr,pVal);	\
167
		else						\
169
		else						\
168
			SK_IN8(pAC,PCI_C(Addr),pVal); 		\
170
			SK_IN8(pAC,PCI_C(pAC,Addr),pVal);	\
169
		}
171
		}
170
#define VPD_IN16(pAC,Ioc,Addr,pVal) {			\
172
#define VPD_IN16(pAC,Ioc,Addr,pVal) {			\
171
		if ((pAC)->DgT.DgUseCfgCycle) 			\
173
		if ((pAC)->DgT.DgUseCfgCycle)			\
172
			SkPciReadCfgWord(pAC,Addr,pVal);	\
174
			SkPciReadCfgWord(pAC,Addr,pVal);	\
173
		else						\
175
		else						\
174
			SK_IN16(pAC,PCI_C(Addr),pVal); 		\
176
			SK_IN16(pAC,PCI_C(pAC,Addr),pVal);	\
175
		}
177
		}
176
#define VPD_IN32(pAC,Ioc,Addr,pVal) {			\
178
#define VPD_IN32(pAC,Ioc,Addr,pVal) {			\
177
		if ((pAC)->DgT.DgUseCfgCycle)			\
179
		if ((pAC)->DgT.DgUseCfgCycle)			\
178
			SkPciReadCfgDWord(pAC,Addr,pVal);	\
180
			SkPciReadCfgDWord(pAC,Addr,pVal);	\
179
		else						\
181
		else						\
180
			SK_IN32(pAC,PCI_C(Addr),pVal);		\
182
			SK_IN32(pAC,PCI_C(pAC,Addr),pVal);	\
181
		}
183
		}
182
#endif	/* nSKDIAG */
184
#endif /* SK_DIAG */
183
185
184
/* function prototypes ********************************************************/
186
/* function prototypes ********************************************************/
185
187
186
#ifndef	SK_KR_PROTO
188
#ifndef	SK_KR_PROTO
187
#ifdef SKDIAG
189
#ifdef SK_DIAG
188
extern SK_U32	VpdReadDWord(
190
extern SK_U32	VpdReadDWord(
189
	SK_AC		*pAC,
191
	SK_AC		*pAC,
190
	SK_IOC		IoC,
192
	SK_IOC		IoC,
191
	int			addr);
193
	int			addr);
192
#endif	/* SKDIAG */
194
#endif /* SK_DIAG */
193
195
194
extern int	VpdSetupPara(
196
extern int	VpdSetupPara(
195
	SK_AC		*pAC,
197
	SK_AC		*pAC,
Lines 240-246 Link Here
240
	SK_IOC		IoC,
242
	SK_IOC		IoC,
241
	char		*msg);
243
	char		*msg);
242
244
243
#ifdef	SKDIAG
245
int VpdInit(
246
	SK_AC		*pAC,
247
	SK_IOC		IoC);
248
249
#if defined(SK_DIAG) || defined(SK_ASF)
250
244
extern int	VpdReadBlock(
251
extern int	VpdReadBlock(
245
	SK_AC		*pAC,
252
	SK_AC		*pAC,
246
	SK_IOC		IoC,
253
	SK_IOC		IoC,
Lines 254-260 Link Here
254
	char		*buf,
261
	char		*buf,
255
	int			addr,
262
	int			addr,
256
	int			len);
263
	int			len);
257
#endif	/* SKDIAG */
264
265
#endif /* SK_DIAG || SK_ASF */
266
258
#else	/* SK_KR_PROTO */
267
#else	/* SK_KR_PROTO */
259
extern SK_U32	VpdReadDWord();
268
extern SK_U32	VpdReadDWord();
260
extern int	VpdSetupPara();
269
extern int	VpdSetupPara();
Lines 269-271 Link Here
269
#endif	/* SK_KR_PROTO */
278
#endif	/* SK_KR_PROTO */
270
279
271
#endif	/* __INC_SKVPD_H_ */
280
#endif	/* __INC_SKVPD_H_ */
281
(-)linux/drivers/net/sk98lin/h/sky2le.h (+891 lines)
Line 0 Link Here
1
/******************************************************************************
2
 *
3
 * Name:	sky2le.h
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.9 $
6
 * Date:	$Date: 2005/01/26 10:53:34 $
7
 * Purpose:	Common list element definitions and access macros.
8
 *
9
 ******************************************************************************/
10
11
/******************************************************************************
12
 *
13
 *	(C)Copyright 2003-2004 Marvell
14
 *
15
 *	This program is free software; you can redistribute it and/or modify
16
 *	it under the terms of the GNU General Public License as published by
17
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	(at your option) any later version.
19
 *	The information in this file is provided "AS IS" without warranty.
20
 *
21
 ******************************************************************************/
22
23
#ifndef __INC_SKY2LE_H
24
#define __INC_SKY2LE_H
25
26
#ifdef __cplusplus
27
extern "C" {
28
#endif	/* __cplusplus */
29
30
/* defines ********************************************************************/
31
32
#define MIN_LEN_OF_LE_TAB	128
33
#define MAX_LEN_OF_LE_TAB	4096
34
#ifdef USE_POLLING_UNIT
35
#define NUM_LE_POLLING_UNIT	2
36
#endif
37
#define MAX_FRAG_OVERHEAD	10
38
39
/* Macro for aligning a given value */
40
#define SK_ALIGN_SIZE(Value, Alignment, AlignedVal) {					\
41
	(AlignedVal) = (((Value) + (Alignment) - 1) & (~((Alignment) - 1)));\
42
}
43
44
/******************************************************************************
45
 *
46
 * LE2DWord() - Converts the given Little Endian value to machine order value
47
 *
48
 * Description:
49
 *	This function converts the Little Endian value received as an argument to
50
 *	the machine order value.
51
 *
52
 * Returns:
53
 *	The converted value
54
 *
55
 */
56
57
#ifdef SK_LITTLE_ENDIAN
58
59
#ifndef	SK_USE_REV_DESC
60
#define LE2DWord(value)	(value)
61
#else	/* SK_USE_REV_DESC */
62
#define LE2DWord(value)					\
63
	((((value)<<24L) & 0xff000000L) +	\
64
	 (((value)<< 8L) & 0x00ff0000L) +	\
65
	 (((value)>> 8L) & 0x0000ff00L) +	\
66
	 (((value)>>24L) & 0x000000ffL))
67
#endif	/* SK_USE_REV_DESC */
68
69
#else	/* !SK_LITTLE_ENDIAN */
70
71
#ifndef	SK_USE_REV_DESC
72
#define LE2DWord(value)					\
73
	((((value)<<24L) & 0xff000000L) +	\
74
	 (((value)<< 8L) & 0x00ff0000L) +	\
75
	 (((value)>> 8L) & 0x0000ff00L) +	\
76
	 (((value)>>24L) & 0x000000ffL))
77
#else	/* SK_USE_REV_DESC */
78
#define LE2DWord(value)	(value)
79
#endif	/* SK_USE_REV_DESC */
80
81
#endif	/* !SK_LITTLE_ENDIAN */
82
83
/******************************************************************************
84
 *
85
 * DWord2LE() - Converts the given value to a Little Endian value
86
 *
87
 * Description:
88
 *	This function converts the value received as an argument to a Little Endian
89
 *	value on Big Endian machines. If the machine running the code is Little
90
 *	Endian, then no conversion is done.
91
 *
92
 * Returns:
93
 *	The converted value
94
 *
95
 */
96
97
#ifdef SK_LITTLE_ENDIAN
98
99
#ifndef	SK_USE_REV_DESC
100
#define DWord2LE(value) (value)
101
#else	/* SK_USE_REV_DESC */
102
#define DWord2LE(value)					\
103
	((((value)<<24L) & 0xff000000L) +	\
104
	 (((value)<< 8L) & 0x00ff0000L) +	\
105
	 (((value)>> 8L) & 0x0000ff00L) +	\
106
	 (((value)>>24L) & 0x000000ffL))
107
#endif	/* SK_USE_REV_DESC */
108
109
#else	/* !SK_LITTLE_ENDIAN */
110
111
#ifndef	SK_USE_REV_DESC
112
#define DWord2LE(value)					\
113
	((((value)<<24L) & 0xff000000L) +	\
114
	 (((value)<< 8L) & 0x00ff0000L) +	\
115
	 (((value)>> 8L) & 0x0000ff00L) +	\
116
	 (((value)>>24L) & 0x000000ffL))
117
#else	/* SK_USE_REV_DESC */
118
#define DWord2LE(value) (value)
119
#endif	/* SK_USE_REV_DESC */
120
#endif	/* !SK_LITTLE_ENDIAN */
121
122
/******************************************************************************
123
 *
124
 * LE2Word() - Converts the given Little Endian value to machine order value
125
 *
126
 * Description:
127
 *	This function converts the Little Endian value received as an argument to
128
 *	the machine order value.
129
 *
130
 * Returns:
131
 *	The converted value
132
 *
133
 */
134
135
#ifdef SK_LITTLE_ENDIAN
136
#ifndef	SK_USE_REV_DESC
137
#define LE2Word(value) (value)
138
#else	/* SK_USE_REV_DESC */
139
#define LE2Word(value)				\
140
	((((value)<< 8L) & 0xff00) +	\
141
	 (((value)>> 8L) & 0x00ff))
142
#endif	/* SK_USE_REV_DESC */
143
144
#else	/* !SK_LITTLE_ENDIAN */
145
#ifndef	SK_USE_REV_DESC
146
#define LE2Word(value)				\
147
	((((value)<< 8L) & 0xff00) +	\
148
	 (((value)>> 8L) & 0x00ff))
149
#else	/* SK_USE_REV_DESC */
150
#define LE2Word(value) (value)
151
#endif	/* SK_USE_REV_DESC */
152
#endif	/* !SK_LITTLE_ENDIAN */
153
154
/******************************************************************************
155
 *
156
 * Word2LE() - Converts the given value to a Little Endian value
157
 *
158
 * Description:
159
 *	This function converts the value received as an argument to a Little Endian
160
 *	value on Big Endian machines. If the machine running the code is Little
161
 *	Endian, then no conversion is done.
162
 *
163
 * Returns:
164
 *	The converted value
165
 *
166
 */
167
168
#ifdef SK_LITTLE_ENDIAN
169
#ifndef	SK_USE_REV_DESC
170
#define Word2LE(value) (value)
171
#else	/* SK_USE_REV_DESC */
172
#define Word2LE(value)				\
173
	((((value)<< 8L) & 0xff00) +	\
174
	 (((value)>> 8L) & 0x00ff))
175
#endif	/* SK_USE_REV_DESC */
176
177
#else	/* !SK_LITTLE_ENDIAN */
178
#ifndef	SK_USE_REV_DESC
179
#define Word2LE(value)				\
180
	((((value)<< 8L) & 0xff00) +	\
181
	 (((value)>> 8L) & 0x00ff))
182
#else	/* SK_USE_REV_DESC */
183
#define Word2LE(value) (value)
184
#endif	/* SK_USE_REV_DESC */
185
#endif	/* !SK_LITTLE_ENDIAN */
186
187
/******************************************************************************
188
 *
189
 * Transmit list element macros
190
 *
191
 */
192
193
#define TXLE_SET_ADDR(pLE, Addr)	\
194
	((pLE)->Tx.TxUn.BufAddr = DWord2LE(Addr))
195
#define TXLE_SET_LSLEN(pLE, Len)	\
196
	((pLE)->Tx.TxUn.LargeSend.Length = Word2LE(Len))
197
#define TXLE_SET_STACS(pLE, Start)	\
198
	((pLE)->Tx.TxUn.ChkSum.TxTcpSp = Word2LE(Start))
199
#define TXLE_SET_WRICS(pLE, Write)	\
200
	((pLE)->Tx.TxUn.ChkSum.TxTcpWp = Word2LE(Write))
201
#define TXLE_SET_INICS(pLE, Ini)	((pLE)->Tx.Send.InitCsum = Word2LE(Ini))
202
#define TXLE_SET_LEN(pLE, Len)		((pLE)->Tx.Send.BufLen = Word2LE(Len))
203
#define TXLE_SET_VLAN(pLE, Vlan)	((pLE)->Tx.Send.VlanTag = Word2LE(Vlan))
204
#define TXLE_SET_LCKCS(pLE, Lock)	((pLE)->Tx.ControlFlags = (Lock))
205
#define TXLE_SET_CTRL(pLE, Ctrl)	((pLE)->Tx.ControlFlags = (Ctrl))
206
#define TXLE_SET_OPC(pLE, Opc)		((pLE)->Tx.Opcode = (Opc))
207
208
#define TXLE_GET_ADDR(pLE)		LE2DWord((pLE)->Tx.TxUn.BufAddr)
209
#define TXLE_GET_LSLEN(pLE)		LE2Word((pLE)->Tx.TxUn.LargeSend.Length)
210
#define TXLE_GET_STACS(pLE)		LE2Word((pLE)->Tx.TxUn.ChkSum.TxTcpSp)
211
#define TXLE_GET_WRICS(pLE)		LE2Word((pLE)->Tx.TxUn.ChkSum.TxTcpWp)
212
#define TXLE_GET_INICS(pLE)		LE2Word((pLE)->Tx.Send.InitCsum)
213
#define TXLE_GET_LEN(pLE) 		LE2Word((pLE)->Tx.Send.BufLen)
214
#define TXLE_GET_VLAN(pLE)		LE2Word((pLE)->Tx.Send.VlanTag)
215
#define TXLE_GET_LCKCS(pLE)		((pLE)->Tx.ControlFlags)
216
#define TXLE_GET_CTRL(pLE)		((pLE)->Tx.ControlFlags)
217
#define TXLE_GET_OPC(pLE)		((pLE)->Tx.Opcode)
218
219
/******************************************************************************
220
 *
221
 * Receive list element macros
222
 *
223
 */
224
225
#define RXLE_SET_ADDR(pLE, Addr)	\
226
	((pLE)->Rx.RxUn.BufAddr = (SK_U32) DWord2LE(Addr))
227
#define RXLE_SET_STACS2(pLE, Offs)	\
228
	((pLE)->Rx.RxUn.ChkSum.RxTcpSp2 = Word2LE(Offs))
229
#define RXLE_SET_STACS1(pLE, Offs)	\
230
	((pLE)->Rx.RxUn.ChkSum.RxTcpSp1 = Word2LE(Offs))
231
#define RXLE_SET_LEN(pLE, Len)		((pLE)->Rx.BufferLength = Word2LE(Len))
232
#define RXLE_SET_CTRL(pLE, Ctrl)	((pLE)->Rx.ControlFlags = (Ctrl))
233
#define RXLE_SET_OPC(pLE, Opc)		((pLE)->Rx.Opcode = (Opc))
234
235
#define RXLE_GET_ADDR(pLE)		LE2DWord((pLE)->Rx.RxUn.BufAddr)
236
#define RXLE_GET_STACS2(pLE)	LE2Word((pLE)->Rx.RxUn.ChkSum.RxTcpSp2)
237
#define RXLE_GET_STACS1(pLE)	LE2Word((pLE)->Rx.RxUn.ChkSum.RxTcpSp1)
238
#define RXLE_GET_LEN(pLE) 		LE2Word((pLE)->Rx.BufferLength)
239
#define RXLE_GET_CTRL(pLE)		((pLE)->Rx.ControlFlags)
240
#define RXLE_GET_OPC(pLE)		((pLE)->Rx.Opcode)
241
242
/******************************************************************************
243
 *
244
 * Status list element macros
245
 *
246
 */
247
248
#define STLE_SET_OPC(pLE, Opc)		((pLE)->St.Opcode = (Opc))
249
250
#define STLE_GET_FRSTATUS(pLE)	LE2DWord((pLE)->St.StUn.StRxStatWord)
251
#define STLE_GET_TIST(pLE)		LE2DWord((pLE)->St.StUn.StRxTimeStamp)
252
#define STLE_GET_TCP1(pLE)		LE2Word((pLE)->St.StUn.StRxTCPCSum.RxTCPSum1)
253
#define STLE_GET_TCP2(pLE)		LE2Word((pLE)->St.StUn.StRxTCPCSum.RxTCPSum2)
254
#define STLE_GET_LEN(pLE)		LE2Word((pLE)->St.Stat.BufLen)
255
#define STLE_GET_VLAN(pLE)		LE2Word((pLE)->St.Stat.VlanTag)
256
#define STLE_GET_LINK(pLE)		((pLE)->St.Link)
257
#define STLE_GET_OPC(pLE)		((pLE)->St.Opcode)
258
#define STLE_GET_DONE_IDX(pLE,LowVal,HighVal) {			\
259
	(LowVal) = LE2DWord((pLE)->St.StUn.StTxStatLow);	\
260
	(HighVal) = LE2Word((pLE)->St.Stat.StTxStatHi);		\
261
}
262
263
#define STLE_GET_RSS(pLE)		LE2DWord((pLE)->St.StUn.StRxRssValue)
264
#define STLE_GET_IPBIT(pLE)		((pLE)->St.Stat.Rss.FlagField & RSS_IP_FLAG)
265
#define STLE_GET_TCPBIT(pLE)	((pLE)->St.Stat.Rss.FlagField & RSS_TCP_FLAG)
266
267
268
/* I always take both values as a paramter to avoid typos */
269
#define STLE_GET_DONE_IDX_TXA1(LowVal,HighVal)			\
270
	(((LowVal) & STLE_TXA1_MSKL) >> STLE_TXA1_SHIFTL)
271
#define STLE_GET_DONE_IDX_TXS1(LowVal,HighVal)			\
272
	((LowVal & STLE_TXS1_MSKL) >> STLE_TXS1_SHIFTL)
273
#define STLE_GET_DONE_IDX_TXA2(LowVal,HighVal)			\
274
	(((LowVal & STLE_TXA2_MSKL) >> STLE_TXA2_SHIFTL) +	\
275
	((HighVal & STLE_TXA2_MSKH) << STLE_TXA2_SHIFTH))
276
#define STLE_GET_DONE_IDX_TXS2(LowVal,HighVal)			\
277
	((HighVal & STLE_TXS2_MSKH) >> STLE_TXS2_SHIFTH)
278
279
280
#define SK_Y2_RXSTAT_CHECK_PKT(Len, RxStat, IsOk) {			\
281
	(IsOk) = (((RxStat) & GMR_FS_RX_OK) != 0) &&			\
282
			 (((RxStat) & GMR_FS_ANY_ERR) == 0);			\
283
															\
284
	if ((IsOk) && ((SK_U16)(((RxStat) & GMR_FS_LEN_MSK) >>	\
285
		GMR_FS_LEN_SHIFT) != (Len))) {						\
286
		/* length in MAC status differs from length in LE */\
287
		(IsOk) = SK_FALSE;									\
288
	}														\
289
}
290
291
292
/******************************************************************************
293
 *
294
 * Polling unit list element macros
295
 *
296
 * NOTE: the Idx must be <= 0xfff and PU_PUTIDX_VALID makes them valid
297
 *
298
 */
299
300
#ifdef USE_POLLING_UNIT
301
302
#define POLE_SET_OPC(pLE, Opc)		((pLE)->Sa.Opcode = (Opc))
303
#define POLE_SET_LINK(pLE, Port)	((pLE)->Sa.Link = (Port))
304
#define POLE_SET_RXIDX(pLE, Idx)	((pLE)->Sa.RxIdxVld = Word2LE(Idx))
305
#define POLE_SET_TXAIDX(pLE, Idx)	((pLE)->Sa.TxAIdxVld = Word2LE(Idx))
306
#define POLE_SET_TXSIDX(pLE, Idx)	((pLE)->Sa.TxSIdxVld = Word2LE(Idx))
307
308
#define POLE_GET_OPC(pLE)		((pLE)->Sa.Opcode)
309
#define POLE_GET_LINK(pLE)		((pLE)->Sa.Link)
310
#define POLE_GET_RXIDX(pLE)		LE2Word((pLE)->Sa.RxIdxVld)
311
#define POLE_GET_TXAIDX(pLE)	LE2Word((pLE)->Sa.TxAIdxVld)
312
#define POLE_GET_TXSIDX(pLE)	LE2Word((pLE)->Sa.TxSIdxVld)
313
314
#endif	/* USE_POLLING_UNIT */
315
316
/******************************************************************************
317
 *
318
 * Debug macros for list elements
319
 *
320
 */
321
322
#ifdef DEBUG
323
324
#define SK_DBG_DUMP_RX_LE(pLE)	{										\
325
	SK_U8	Opcode;														\
326
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
327
		("=== RX_LIST_ELEMENT @addr: %p cont: %02x %02x %02x %02x %02x %02x %02x %02x\n",	\
328
		pLE, ((SK_U8 *) pLE)[0], ((SK_U8 *) pLE)[1], ((SK_U8 *) pLE)[2],\
329
		((SK_U8 *) pLE)[3], ((SK_U8 *) pLE)[4], ((SK_U8 *) pLE)[5],		\
330
		((SK_U8 *) pLE)[6], ((SK_U8 *) pLE)[7])); 						\
331
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
332
		("\t (16bit) %04x %04x %04x %04x\n",							\
333
		((SK_U16 *) pLE)[0], ((SK_U16 *) pLE)[1], ((SK_U16 *) pLE)[2],	\
334
		((SK_U16 *) pLE)[3])); 											\
335
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
336
		("\t (32bit) %08x %08x\n",										\
337
		((SK_U32 *) pLE)[0], ((SK_U32 *) pLE)[1])); 					\
338
	Opcode = RXLE_GET_OPC(pLE);											\
339
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
340
		("\tOwn belongs to %s\n", ((Opcode & HW_OWNER) == HW_OWNER) ?	\
341
		 "Hardware" : "Software"));										\
342
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
343
		("\tOpc: 0x%x ",Opcode));										\
344
	switch (Opcode & (~HW_OWNER)) {										\
345
	case OP_BUFFER:														\
346
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
347
			("\tOP_BUFFER\n"));											\
348
		break;															\
349
	case OP_PACKET:														\
350
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
351
			("\tOP_PACKET\n"));											\
352
		break;															\
353
	case OP_ADDR64:														\
354
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
355
			("\tOP_ADDR64\n"));											\
356
		break;															\
357
	case OP_TCPSTART:													\
358
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
359
			("\tOP_TCPPAR\n"));											\
360
		break;															\
361
	case SW_OWNER:														\
362
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
363
			("\tunused LE\n"));											\
364
		break;															\
365
	default:															\
366
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
367
			("\tunknown Opcode!!!\n"));									\
368
		break;															\
369
	}																	\
370
	if ((Opcode & OP_BUFFER) == OP_BUFFER) {							\
371
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
372
			("\tControl: 0x%x\n", RXLE_GET_CTRL(pLE)));					\
373
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
374
			("\tBufLen: 0x%x\n", RXLE_GET_LEN(pLE)));					\
375
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
376
			("\tLowAddr: 0x%x\n", RXLE_GET_ADDR(pLE)));					\
377
	}																	\
378
	if ((Opcode & OP_ADDR64) == OP_ADDR64) {							\
379
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
380
			("\tHighAddr: 0x%x\n", RXLE_GET_ADDR(pLE)));				\
381
	}																	\
382
	if ((Opcode & OP_TCPSTART) == OP_TCPSTART) {						\
383
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
384
			("\tTCP Sum Start 1 : 0x%x\n", RXLE_GET_STACS1(pLE)));		\
385
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
386
			("\tTCP Sum Start 2 : 0x%x\n", RXLE_GET_STACS2(pLE)));		\
387
	}																	\
388
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
389
		("=====================\n"));									\
390
}
391
392
#define SK_DBG_DUMP_TX_LE(pLE)	{										\
393
	SK_U8	Opcode;														\
394
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
395
		("=== TX_LIST_ELEMENT @addr: %p cont: %02x %02x %02x %02x %02x %02x %02x %02x\n",	\
396
		pLE, ((SK_U8 *) pLE)[0], ((SK_U8 *) pLE)[1], ((SK_U8 *) pLE)[2],\
397
		((SK_U8 *) pLE)[3], ((SK_U8 *) pLE)[4], ((SK_U8 *) pLE)[5],		\
398
		((SK_U8 *) pLE)[6], ((SK_U8 *) pLE)[7])); 						\
399
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
400
		("\t (16bit) %04x %04x %04x %04x\n",							\
401
		((SK_U16 *) pLE)[0], ((SK_U16 *) pLE)[1], ((SK_U16 *) pLE)[2],	\
402
		((SK_U16 *) pLE)[3])); 											\
403
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
404
		("\t (32bit) %08x %08x\n",										\
405
		((SK_U32 *) pLE)[0], ((SK_U32 *) pLE)[1])); 					\
406
	Opcode = TXLE_GET_OPC(pLE);											\
407
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
408
		("\tOwn belongs to %s\n", ((Opcode & HW_OWNER) == HW_OWNER) ?	\
409
		"Hardware" : "Software"));										\
410
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
411
		("\tOpc: 0x%x ",Opcode));										\
412
	switch (Opcode & (~HW_OWNER)) {										\
413
	case OP_TCPCHKSUM:													\
414
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
415
			("\tOP_TCPCHKSUM\n"));										\
416
		break;															\
417
	case OP_TCPIS:														\
418
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
419
			("\tOP_TCPIS\n"));											\
420
		break;															\
421
	case OP_TCPLCK:														\
422
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
423
			("\tOP_TCPLCK\n"));											\
424
		break;															\
425
	case OP_TCPLW:														\
426
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
427
			("\tOP_TCPLW\n"));											\
428
		break;															\
429
	case OP_TCPLSW:														\
430
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
431
			("\tOP_TCPLSW\n"));											\
432
		break;															\
433
	case OP_TCPLISW:													\
434
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
435
			("\tOP_TCPLISW\n"));										\
436
		break;															\
437
	case OP_ADDR64:														\
438
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
439
			("\tOP_ADDR64\n"));											\
440
		break;															\
441
	case OP_VLAN:														\
442
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
443
			("\tOP_VLAN\n"));											\
444
		break;															\
445
	case OP_ADDR64VLAN:													\
446
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
447
			("\tOP_ADDR64VLAN\n"));										\
448
		break;															\
449
	case OP_LRGLEN:														\
450
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
451
			("\tOP_LRGLEN\n"));											\
452
		break;															\
453
	case OP_LRGLENVLAN:													\
454
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
455
			("\tOP_LRGLENVLAN\n"));										\
456
		break;															\
457
	case OP_BUFFER:														\
458
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
459
			("\tOP_BUFFER\n"));											\
460
		break;															\
461
	case OP_PACKET:														\
462
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
463
			("\tOP_PACKET\n"));											\
464
		break;															\
465
	case OP_LARGESEND:													\
466
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
467
			("\tOP_LARGESEND\n"));										\
468
		break;															\
469
	case SW_OWNER:														\
470
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
471
			("\tunused LE\n"));											\
472
		break;															\
473
	default:															\
474
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
475
			("\tunknown Opcode!!!\n"));									\
476
		break;															\
477
	}																	\
478
	if ((Opcode & OP_BUFFER) == OP_BUFFER) {							\
479
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
480
			("\tControl: 0x%x\n", TXLE_GET_CTRL(pLE)));					\
481
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
482
			("\tBufLen: 0x%x\n", TXLE_GET_LEN(pLE)));					\
483
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
484
			("\tLowAddr: 0x%x\n", TXLE_GET_ADDR(pLE)));					\
485
	}																	\
486
	if ((Opcode & OP_ADDR64) == OP_ADDR64) {							\
487
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
488
			("\tHighAddr: 0x%x\n", TXLE_GET_ADDR(pLE)));				\
489
	}																	\
490
	if ((Opcode & OP_VLAN) == OP_VLAN) {								\
491
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
492
			("\tVLAN Id: 0x%x\n", TXLE_GET_VLAN(pLE)));					\
493
	}																	\
494
	if ((Opcode & OP_LRGLEN) == OP_LRGLEN) {							\
495
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
496
			("\tLarge send length: 0x%x\n", TXLE_GET_LSLEN(pLE)));		\
497
	}																	\
498
	if ((Opcode &(~HW_OWNER)) <= OP_ADDR64) {							\
499
		if ((Opcode & OP_TCPWRITE) == OP_TCPWRITE) {					\
500
			SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,				\
501
				("\tTCP Sum Write: 0x%x\n", TXLE_GET_WRICS(pLE)));		\
502
		}																\
503
		if ((Opcode & OP_TCPSTART) == OP_TCPSTART) {					\
504
			SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,				\
505
				("\tTCP Sum Start: 0x%x\n", TXLE_GET_STACS(pLE)));		\
506
		}																\
507
		if ((Opcode & OP_TCPINIT) == OP_TCPINIT) {						\
508
			SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,				\
509
				("\tTCP Sum Init: 0x%x\n", TXLE_GET_INICS(pLE)));		\
510
		}																\
511
		if ((Opcode & OP_TCPLCK) == OP_TCPLCK) {						\
512
			SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,				\
513
				("\tTCP Sum Lock: 0x%x\n", TXLE_GET_LCKCS(pLE)));		\
514
		}																\
515
	}																	\
516
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
517
		("=====================\n"));									\
518
}
519
	
520
#define SK_DBG_DUMP_ST_LE(pLE)	{ 										\
521
	SK_U8	Opcode;														\
522
	SK_U16	HighVal;													\
523
	SK_U32	LowVal;														\
524
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
525
		("=== ST_LIST_ELEMENT @addr: %p contains: %02x %02x %02x %02x %02x %02x %02x %02x\n",\
526
		pLE, ((SK_U8 *) pLE)[0], ((SK_U8 *) pLE)[1], ((SK_U8 *) pLE)[2],\
527
		((SK_U8 *) pLE)[3], ((SK_U8 *) pLE)[4], ((SK_U8 *) pLE)[5],		\
528
		((SK_U8 *) pLE)[6], ((SK_U8 *) pLE)[7]));						\
529
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
530
		("\t (16bit) %04x %04x %04x %04x\n",							\
531
		((SK_U16 *) pLE)[0], ((SK_U16 *) pLE)[1], ((SK_U16 *) pLE)[2],	\
532
		((SK_U16 *) pLE)[3])); 											\
533
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
534
		("\t (32bit) %08x %08x\n",										\
535
		((SK_U32 *) pLE)[0], ((SK_U32 *) pLE)[1]));						\
536
	Opcode = STLE_GET_OPC(pLE);											\
537
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
538
		("\tOwn belongs to %s\n", ((Opcode & HW_OWNER) == SW_OWNER) ?	\
539
		"Hardware" : "Software"));										\
540
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
541
		("\tOpc: 0x%x",	Opcode));										\
542
	Opcode &= (~HW_OWNER);												\
543
	switch (Opcode) {													\
544
	case OP_RXSTAT:														\
545
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
546
			("\tOP_RXSTAT\n"));											\
547
		break;															\
548
	case OP_RXTIMESTAMP:												\
549
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
550
			("\tOP_RXTIMESTAMP\n"));									\
551
		break;															\
552
	case OP_RXVLAN:														\
553
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
554
			("\tOP_RXVLAN\n"));											\
555
		break;															\
556
	case OP_RXCHKS:														\
557
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
558
			("\tOP_RXCHKS\n"));											\
559
		break;															\
560
	case OP_RXCHKSVLAN:													\
561
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
562
			("\tOP_RXCHKSVLAN\n"));										\
563
		break;															\
564
	case OP_RXTIMEVLAN:													\
565
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
566
			("\tOP_RXTIMEVLAN\n"));										\
567
		break;															\
568
	case OP_RSS_HASH:													\
569
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
570
			("\tOP_RSS_HASH\n"));										\
571
		break;															\
572
	case OP_TXINDEXLE:													\
573
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
574
			("\tOP_TXINDEXLE\n"));										\
575
		break;															\
576
	case HW_OWNER:														\
577
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
578
			("\tunused LE\n"));											\
579
		break;															\
580
	default:															\
581
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
582
			("\tunknown status list element!!!\n"));					\
583
		break;															\
584
	}																	\
585
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
586
		("\tPort: %c\n", 'A' + STLE_GET_LINK(pLE)));					\
587
	if (Opcode == OP_RXSTAT) {											\
588
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
589
			("\tFrameLen: 0x%x\n", STLE_GET_LEN(pLE)));					\
590
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
591
			("\tFrameStat: 0x%x\n", STLE_GET_FRSTATUS(pLE)));			\
592
	}																	\
593
	if ((Opcode & OP_RXVLAN) == OP_RXVLAN) {							\
594
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
595
			("\tVLAN Id: 0x%x\n", STLE_GET_VLAN(pLE)));					\
596
	}																	\
597
	if ((Opcode & OP_RXTIMESTAMP) == OP_RXTIMESTAMP) {					\
598
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
599
			("\tTimestamp: 0x%x\n", STLE_GET_TIST(pLE)));				\
600
	}																	\
601
	if ((Opcode & OP_RXCHKS) == OP_RXCHKS) {							\
602
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
603
			("\tTCP: 0x%x 0x%x\n", STLE_GET_TCP1(pLE),					\
604
			STLE_GET_TCP2(pLE)));										\
605
	}																	\
606
	if (Opcode == OP_TXINDEXLE) {										\
607
		STLE_GET_DONE_IDX(pLE, LowVal, HighVal);						\
608
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
609
			("\tTx Index TxA1: 0x%x\n",									\
610
			STLE_GET_DONE_IDX_TXA1(LowVal,HighVal)));					\
611
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
612
			("\tTx Index TxS1: 0x%x\n",									\
613
			STLE_GET_DONE_IDX_TXS1(LowVal,HighVal)));					\
614
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
615
			("\tTx Index TxA2: 0x%x\n",									\
616
			STLE_GET_DONE_IDX_TXA2(LowVal,HighVal)));					\
617
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
618
			("\tTx Index TxS2: 0x%x\n",									\
619
			STLE_GET_DONE_IDX_TXS2(LowVal,HighVal)));					\
620
	}																	\
621
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
622
		("=====================\n"));									\
623
}
624
625
#ifdef USE_POLLING_UNIT
626
#define SK_DBG_DUMP_PO_LE(pLE)	{										\
627
	SK_U8	Opcode;														\
628
	SK_U16	Idx;														\
629
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
630
		("=== PO_LIST_ELEMENT @addr: %p cont: %02x %02x %02x %02x %02x %02x %02x %02x\n",	\
631
		pLE, ((SK_U8 *) pLE)[0], ((SK_U8 *) pLE)[1], ((SK_U8 *) pLE)[2],\
632
		((SK_U8 *) pLE)[3], ((SK_U8 *) pLE)[4], ((SK_U8 *) pLE)[5],		\
633
		((SK_U8 *) pLE)[6], ((SK_U8 *) pLE)[7]));						\
634
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
635
		("\t (16bit) %04x %04x %04x %04x\n",							\
636
		((SK_U16 *) pLE)[0], ((SK_U16 *) pLE)[1], ((SK_U16 *) pLE)[2],	\
637
		((SK_U16 *) pLE)[3])); 											\
638
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
639
		("\t (32bit) %08x %08x\n",										\
640
		((SK_U32 *) pLE)[0], ((SK_U32 *) pLE)[1]));						\
641
	Opcode = POLE_GET_OPC(pLE);											\
642
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
643
		 ("\tOwn belongs to %s\n", ((Opcode & HW_OWNER) == HW_OWNER) ?	\
644
		  "Hardware" : "Software"));									\
645
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
646
		 ("\tOpc: 0x%x ",Opcode));										\
647
	if ((Opcode & ~HW_OWNER) == OP_PUTIDX) {							\
648
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
649
			("\tOP_PUTIDX\n"));											\
650
	}																	\
651
	else {																\
652
		SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,					\
653
			("\tunknown Opcode!!!\n"));									\
654
	}																	\
655
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
656
		("\tPort %c\n", 'A' + POLE_GET_LINK(pLE)));						\
657
	Idx = POLE_GET_TXAIDX(pLE);											\
658
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
659
		("\tTxA Index is 0x%X and %svalid\n", Idx,						\
660
		(Idx & PU_PUTIDX_VALID) ? "" : "not "));						\
661
	Idx = POLE_GET_TXSIDX(pLE);											\
662
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
663
		("\tTxS Index is 0x%X and %svalid\n", Idx,						\
664
		(Idx & PU_PUTIDX_VALID) ? "" : "not "));						\
665
	Idx = POLE_GET_RXIDX(pLE);											\
666
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
667
		("\tRx Index is 0x%X and %svalid\n", Idx,						\
668
		(Idx & PU_PUTIDX_VALID) ? "" : "not "));						\
669
	SK_DBG_MSG(pAc, SK_DBGMOD_HWM, SK_DBGCAT_INIT,						\
670
		("=====================\n"));									\
671
}
672
#endif	/* USE_POLLING_UNIT */
673
674
#else	/* !DEBUG */
675
676
#define SK_DBG_DUMP_RX_LE(pLE)
677
#define SK_DBG_DUMP_TX_LE(pLE)
678
#define SK_DBG_DUMP_ST_LE(pLE)
679
#define SK_DBG_DUMP_PO_LE(pLE)
680
681
#endif	/* !DEBUG */
682
683
/******************************************************************************
684
 *
685
 * Macros for listelement tables
686
 *
687
 *
688
 */
689
690
#define LE_SIZE sizeof(SK_HWLE)
691
#define LE_TAB_SIZE(NumElements)	((NumElements) * LE_SIZE)
692
693
/* Number of unused list elements in table
694
 * this macro always returns the number of free listelements - 1
695
 * this way we want to guarantee that always one LE remains unused
696
 */
697
#define NUM_FREE_LE_IN_TABLE(pTable)								\
698
	( ((pTable)->Put >= (pTable)->Done) ?							\
699
	(NUM_LE_IN_TABLE(pTable) - (pTable)->Put + (pTable)->Done - 1) :\
700
	((pTable)->Done - (pTable)->Put - 1) )
701
702
/* total number of list elements in table */
703
#define NUM_LE_IN_TABLE(pTable)		((pTable)->Num)
704
705
/* get next unused Rx list element */
706
#define GET_RX_LE(pLE, pTable) {									\
707
	pLE = &(pTable)->pLETab[(pTable)->Put];							\
708
	(pTable)->Put = ((pTable)->Put + 1) & (NUM_LE_IN_TABLE(pTable) - 1);\
709
}
710
711
/* get next unused Tx list element */
712
#define GET_TX_LE(pLE, pTable)	GET_RX_LE(pLE, pTable)
713
714
/* get next status list element expected to be finished by hw */
715
#define GET_ST_LE(pLE, pTable) {									\
716
	pLE = &(pTable)->pLETab[(pTable)->Done];						\
717
		(pTable)->Done = ((pTable)->Done +1) & (NUM_LE_IN_TABLE(pTable) - 1);\
718
}
719
720
#ifdef USE_POLLING_UNIT
721
/* get next polling unit list element for port */
722
#define GET_PO_LE(pLE, pTable, Port) {								\
723
	pLE = &(pTable)->pLETab[(Port)];								\
724
}
725
#endif	/* USE_POLLING_UNIT */
726
727
#define GET_PUT_IDX(pTable)			((pTable)->Put)
728
729
#define UPDATE_HWPUT_IDX(pTable)	{(pTable)->HwPut = (pTable)->Put; }
730
731
/*
732
 * get own bit of next status LE
733
 * if the result is != 0 there has been at least one status LE finished
734
 */
735
#define OWN_OF_FIRST_LE(pTable)									\
736
	(STLE_GET_OPC(&(pTable)->pLETab[(pTable)->Done]) & HW_OWNER)
737
738
#define SET_DONE_INDEX(pTable, Idx)	(pTable)->Done = (Idx);
739
740
#define GET_DONE_INDEX(pTable)	((pTable)->Done)
741
742
#ifdef SAFE_BUT_SLOW
743
744
/* check own bit of LE before current done idx */
745
#define CHECK_STLE_OVERFLOW(pTable, IsOk) {						\
746
		unsigned i;												\
747
		if ((i = (pTable)->Done) == 0) {						\
748
			i = NUM_LE_IN_TABLE(pTable);						\
749
		}														\
750
		else {													\
751
			i = i - 1;											\
752
		}														\
753
		if (STLE_GET_OPC(&(pTable)->pLETab[i]) == HW_OWNER) {	\
754
			(IsOk) = SK_TRUE;									\
755
		}														\
756
		else {													\
757
			(IsOk) = SK_FALSE;									\
758
		}														\
759
	}
760
761
762
/*
763
 * for Yukon-2 the hardware is not polling the list elements, so it
764
 * is not necessary to change the own-bit of Rx or Tx LEs before
765
 * reusing them
766
 * but it might make debugging easier if one simply can see whether
767
 * a LE has been worked on
768
 */
769
770
#define CLEAR_LE_OWN(pTable, Idx)								\
771
	STLE_SET_OPC(&(pTable)->pLETab[(Idx)], SW_OWNER)
772
773
/*
774
 * clear all own bits starting from old done index up to the LE before
775
 * the new done index
776
 */
777
#define CLEAR_LE_OWN_FROM_DONE_TO(pTable, To) {					\
778
		int i;													\
779
		i = (pTable)->Done;										\
780
		while (i != To) {										\
781
			CLEAR_LE_OWN(pTable, i);							\
782
			i = (i + 1) & (NUM_LE_IN_TABLE(pTable) - 1);		\
783
		}														\
784
	}
785
786
#else	/* !SAFE_BUT_SLOW */
787
788
#define CHECK_STLE_OVERFLOW(pTable, IsOk)
789
#define CLEAR_LE_OWN(pTable, Idx)
790
#define CLEAR_LE_OWN_FROM_DONE_TO(pTable, To)
791
792
#endif	/* !SAFE_BUT_SLOW */
793
794
795
/* typedefs *******************************************************************/
796
797
typedef struct s_LetRxTx {
798
	SK_U16	VlanId;			/* VLAN Id given down last time */
799
	SK_U16	TcpWp;			/* TCP Checksum Write Position */
800
	SK_U16	TcpSp1;			/* TCP Checksum Calculation Start Position 1 */
801
	SK_U16	TcpSp2;			/* TCP Checksum Calculation Start Position 2 */
802
	SK_U16	MssValue;		/* Maximum Segment Size */
803
	SK_U16	Reserved1;		/* reserved word for furture extensions */
804
	SK_U16	Reserved2;		/* reserved word for furture extensions */
805
	SK_U16	Reserved3;		/* reserved word for furture extensions */
806
} SK_LET_RX_TX;
807
808
typedef struct s_LetStat {
809
	SK_U32	RxTimeStamp;	/* Receive Timestamp */
810
	SK_U32	RssHashValue;	/* RSS Hash Value */
811
	SK_BOOL	RssIsIp;		/* RSS Hash Value: IP packet detected */
812
	SK_BOOL	RssIsTcp;		/* RSS Hash Value: IP+TCP packet detected */
813
	SK_U16	VlanId;			/* VLAN Id given received by Status BMU */
814
	SK_U16	TcpSum1;		/* TCP checksum 1 (status BMU) */
815
	SK_U16	TcpSum2;		/* TCP checksum 2 (status BMU) */
816
} SK_LET_STAT;
817
818
typedef union s_LetBmuSpec {
819
	SK_LET_RX_TX	RxTx;	/* Rx/Tx BMU specific variables */
820
	SK_LET_STAT		Stat;	/* Status BMU specific variables */
821
} SK_LET_BMU_S;
822
823
typedef	struct s_le_table {
824
	/* all LE's between Done and HWPut are owned by the hardware */
825
	/* all LE's between Put and Done can be used from Software */
826
	/* all LE's between HWPut and Put are currently processed in DriverSend */
827
	unsigned Done;			/* done index - consumed from HW and available */
828
	unsigned Put;			/* put index - to be given to hardware */
829
	unsigned HwPut;			/* put index actually given to hardware */
830
	unsigned Num;			/* total number of list elements */
831
	SK_HWLE *pLETab;		/* virtual address of list element table */
832
	SK_U32	pPhyLETABLow;	/* physical address of list element table */
833
	SK_U32	pPhyLETABHigh;	/* physical address of list element table */
834
	/* values to remember in order to save some LEs */
835
	SK_U32	BufHighAddr;	/* high addr given down last time */
836
	SK_LET_BMU_S Bmu;		/* contains BMU specific information */
837
	SK_U32	private;		/* driver private variable free usable */
838
	SK_U16	TcpInitCsum;	/* Init. Checksum */
839
} SK_LE_TABLE;
840
841
/* function prototypes ********************************************************/
842
843
#ifndef	SK_KR_PROTO
844
845
/*
846
 * public functions in sky2le.c
847
 */
848
extern void SkGeY2SetPutIndex(
849
	SK_AC	*pAC,
850
	SK_IOC	IoC,
851
	SK_U32	StartAddrPrefetchUnit,
852
	SK_LE_TABLE *pLETab);
853
854
extern void SkGeY2InitPrefetchUnit(
855
	SK_AC	*pAC,
856
	SK_IOC	IoC,
857
	unsigned int Queue,
858
	SK_LE_TABLE *pLETab);
859
860
extern void SkGeY2InitStatBmu(
861
	SK_AC	*pAC,
862
	SK_IOC	IoC,
863
	SK_LE_TABLE *pLETab);
864
865
extern void SkGeY2InitPollUnit(
866
	SK_AC	*pAC,
867
	SK_IOC	IoC,
868
	SK_LE_TABLE *pLETab);
869
870
extern void SkGeY2InitSingleLETable(
871
	SK_AC	*pAC,
872
	SK_LE_TABLE *pLETab,
873
	unsigned int NumLE,
874
	void	*pVMem,
875
	SK_U32	PMemLowAddr,
876
	SK_U32	PMemHighAddr);
877
878
#else	/* SK_KR_PROTO */
879
extern void SkGeY2SetPutIndex();
880
extern void SkGeY2InitPrefetchUnit();
881
extern void SkGeY2InitStatBmu();
882
extern void SkGeY2InitPollUnit();
883
extern void SkGeY2InitSingleLETable();
884
#endif	/* SK_KR_PROTO */
885
886
#ifdef __cplusplus
887
}
888
#endif	/* __cplusplus */
889
890
#endif	/* __INC_SKY2LE_H */
891
(-)linux/drivers/net/sk98lin/h/xmac_ii.h (-228 / +393 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	xmac_ii.h
3
 * Name:	xmac_ii.h
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.52 $
5
 * Version:	$Revision: 2.11 $
6
 * Date:	$Date: 2003/10/02 16:35:50 $
6
 * Date:	$Date: 2005/01/04 14:14:20 $
7
 * Purpose:	Defines and Macros for Gigabit Ethernet Controller
7
 * Purpose:	Defines and Macros for Gigabit Ethernet Controller
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-23 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
22
 *
21
 *
23
 ******************************************************************************/
22
 ******************************************************************************/
Lines 449-455 Link Here
449
/*
448
/*
450
 * Receive Frame Status Encoding
449
 * Receive Frame Status Encoding
451
 */
450
 */
452
#define XMR_FS_LEN	(0x3fffUL<<18)	/* Bit 31..18:	Rx Frame Length */
451
#define XMR_FS_LEN_MSK	(0x3fffUL<<18)	/* Bit 31..18:	Rx Frame Length */
453
#define XMR_FS_2L_VLAN	(1L<<17)	/* Bit 17:	tagged wh 2Lev VLAN ID*/
452
#define XMR_FS_2L_VLAN	(1L<<17)	/* Bit 17:	tagged wh 2Lev VLAN ID*/
454
#define XMR_FS_1L_VLAN	(1L<<16)	/* Bit 16:	tagged wh 1Lev VLAN ID*/
453
#define XMR_FS_1L_VLAN	(1L<<16)	/* Bit 16:	tagged wh 1Lev VLAN ID*/
455
#define XMR_FS_BC		(1L<<15)	/* Bit 15:	Broadcast Frame */
454
#define XMR_FS_BC		(1L<<15)	/* Bit 15:	Broadcast Frame */
Lines 469-474 Link Here
469
#define XMR_FS_ERR		(1L<<1)		/* Bit  1:	Frame Error */
468
#define XMR_FS_ERR		(1L<<1)		/* Bit  1:	Frame Error */
470
#define XMR_FS_MCTRL	(1L<<0)		/* Bit  0:	MAC Control Packet */
469
#define XMR_FS_MCTRL	(1L<<0)		/* Bit  0:	MAC Control Packet */
471
470
471
#define XMR_FS_LEN_SHIFT	18
472
472
/*
473
/*
473
 * XMR_FS_ERR will be set if
474
 * XMR_FS_ERR will be set if
474
 *	XMR_FS_FCS_ERR, XMR_FS_LNG_ERR, XMR_FS_RUNT,
475
 *	XMR_FS_FCS_ERR, XMR_FS_LNG_ERR, XMR_FS_RUNT,
Lines 510-516 Link Here
510
#define PHY_BCOM_NEPG		0x07	/* 16 bit r/w	Next Page Register */
511
#define PHY_BCOM_NEPG		0x07	/* 16 bit r/w	Next Page Register */
511
#define PHY_BCOM_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
512
#define PHY_BCOM_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
512
	/* Broadcom-specific registers */
513
	/* Broadcom-specific registers */
513
#define PHY_BCOM_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Ctrl Reg */
514
#define PHY_BCOM_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Control Reg */
514
#define PHY_BCOM_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
515
#define PHY_BCOM_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
515
	/* 0x0b - 0x0e:		reserved */
516
	/* 0x0b - 0x0e:		reserved */
516
#define PHY_BCOM_EXT_STAT	0x0f	/* 16 bit r/o	Extended Status Reg */
517
#define PHY_BCOM_EXT_STAT	0x0f	/* 16 bit r/o	Extended Status Reg */
Lines 541-564 Link Here
541
#define PHY_MARV_NEPG		0x07	/* 16 bit r/w	Next Page Register */
542
#define PHY_MARV_NEPG		0x07	/* 16 bit r/w	Next Page Register */
542
#define PHY_MARV_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
543
#define PHY_MARV_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
543
	/* Marvel-specific registers */
544
	/* Marvel-specific registers */
544
#define PHY_MARV_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Ctrl Reg */
545
#define PHY_MARV_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Control Reg */
545
#define PHY_MARV_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
546
#define PHY_MARV_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
546
	/* 0x0b - 0x0e:		reserved */
547
	/* 0x0b - 0x0e:		reserved */
547
#define PHY_MARV_EXT_STAT	0x0f	/* 16 bit r/o	Extended Status Reg */
548
#define PHY_MARV_EXT_STAT	0x0f	/* 16 bit r/o	Extended Status Reg */
548
#define PHY_MARV_PHY_CTRL	0x10	/* 16 bit r/w	PHY Specific Ctrl Reg */
549
#define PHY_MARV_PHY_CTRL	0x10	/* 16 bit r/w	PHY Specific Control Reg */
549
#define PHY_MARV_PHY_STAT	0x11	/* 16 bit r/o	PHY Specific Stat Reg */
550
#define PHY_MARV_PHY_STAT	0x11	/* 16 bit r/o	PHY Specific Status Reg */
550
#define PHY_MARV_INT_MASK	0x12	/* 16 bit r/w	Interrupt Mask Reg */
551
#define PHY_MARV_INT_MASK	0x12	/* 16 bit r/w	Interrupt Mask Reg */
551
#define PHY_MARV_INT_STAT	0x13	/* 16 bit r/o	Interrupt Status Reg */
552
#define PHY_MARV_INT_STAT	0x13	/* 16 bit r/o	Interrupt Status Reg */
552
#define PHY_MARV_EXT_CTRL	0x14	/* 16 bit r/w	Ext. PHY Specific Ctrl */
553
#define PHY_MARV_EXT_CTRL	0x14	/* 16 bit r/w	Ext. PHY Specific Ctrl */
553
#define PHY_MARV_RXE_CNT	0x15	/* 16 bit r/w	Receive Error Counter */
554
#define PHY_MARV_RXE_CNT	0x15	/* 16 bit r/w	Receive Error Counter */
554
#define PHY_MARV_EXT_ADR	0x16	/* 16 bit r/w	Ext. Ad. for Cable Diag. */
555
#define PHY_MARV_EXT_ADR	0x16	/* 16 bit r/w	Ext. Ad. for Cable Diag. */
555
	/* 0x17:		reserved */
556
#define PHY_MARV_PORT_IRQ	0x17	/* 16 bit r/o	Port 0 IRQ (88E1111 only) */
556
#define PHY_MARV_LED_CTRL	0x18	/* 16 bit r/w	LED Control Reg */
557
#define PHY_MARV_LED_CTRL	0x18	/* 16 bit r/w	LED Control Reg */
557
#define PHY_MARV_LED_OVER	0x19	/* 16 bit r/w	Manual LED Override Reg */
558
#define PHY_MARV_LED_OVER	0x19	/* 16 bit r/w	Manual LED Override Reg */
558
#define PHY_MARV_EXT_CTRL_2	0x1a	/* 16 bit r/w	Ext. PHY Specific Ctrl 2 */
559
#define PHY_MARV_EXT_CTRL_2	0x1a	/* 16 bit r/w	Ext. PHY Specific Ctrl 2 */
559
#define PHY_MARV_EXT_P_STAT	0x1b	/* 16 bit r/w	Ext. PHY Spec. Stat Reg */
560
#define PHY_MARV_EXT_P_STAT	0x1b	/* 16 bit r/w	Ext. PHY Spec. Stat Reg */
560
#define PHY_MARV_CABLE_DIAG	0x1c	/* 16 bit r/o	Cable Diagnostic Reg */
561
#define PHY_MARV_CABLE_DIAG	0x1c	/* 16 bit r/o	Cable Diagnostic Reg */
561
	/* 0x1d - 0x1f:		reserved */
562
#define PHY_MARV_PAGE_ADDR	0x1d	/* 16 bit r/w	Extended Page Address Reg */
563
#define PHY_MARV_PAGE_DATA	0x1e	/* 16 bit r/w	Extended Page Data Reg */
564
565
/* for 10/100 Fast Ethernet PHY (88E3082 only) */
566
#define PHY_MARV_FE_LED_PAR	0x16	/* 16 bit r/w	LED Parallel Select Reg. */
567
#define PHY_MARV_FE_LED_SER	0x17	/* 16 bit r/w	LED Stream Select S. LED */
568
#define PHY_MARV_FE_VCT_TX	0x1a	/* 16 bit r/w	VCT Reg. for TXP/N Pins */
569
#define PHY_MARV_FE_VCT_RX	0x1b	/* 16 bit r/o	VCT Reg. for RXP/N Pins */
570
#define PHY_MARV_FE_SPEC_2	0x1c	/* 16 bit r/w	Specific Control Reg. 2 */
562
571
563
/*----------------------------------------------------------------------------*/
572
/*----------------------------------------------------------------------------*/
564
/*
573
/*
Lines 574-582 Link Here
574
#define PHY_LONE_NEPG		0x07	/* 16 bit r/w	Next Page Register */
583
#define PHY_LONE_NEPG		0x07	/* 16 bit r/w	Next Page Register */
575
#define PHY_LONE_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
584
#define PHY_LONE_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
576
	/* Level One-specific registers */
585
	/* Level One-specific registers */
577
#define PHY_LONE_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Control Reg*/
586
#define PHY_LONE_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Control Reg */
578
#define PHY_LONE_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
587
#define PHY_LONE_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
579
	/* 0x0b -0x0e:		reserved */
588
	/* 0x0b - 0x0e:		reserved */
580
#define PHY_LONE_EXT_STAT	0x0f	/* 16 bit r/o	Extended Status Reg */
589
#define PHY_LONE_EXT_STAT	0x0f	/* 16 bit r/o	Extended Status Reg */
581
#define PHY_LONE_PORT_CFG	0x10	/* 16 bit r/w	Port Configuration Reg*/
590
#define PHY_LONE_PORT_CFG	0x10	/* 16 bit r/w	Port Configuration Reg*/
582
#define PHY_LONE_Q_STAT		0x11	/* 16 bit r/o	Quick Status Reg */
591
#define PHY_LONE_Q_STAT		0x11	/* 16 bit r/o	Quick Status Reg */
Lines 585-591 Link Here
585
#define PHY_LONE_LED_CFG	0x14	/* 16 bit r/w	LED Configuration Reg */
594
#define PHY_LONE_LED_CFG	0x14	/* 16 bit r/w	LED Configuration Reg */
586
#define PHY_LONE_PORT_CTRL	0x15	/* 16 bit r/w	Port Control Reg */
595
#define PHY_LONE_PORT_CTRL	0x15	/* 16 bit r/w	Port Control Reg */
587
#define PHY_LONE_CIM		0x16	/* 16 bit r/o	CIM Reg */
596
#define PHY_LONE_CIM		0x16	/* 16 bit r/o	CIM Reg */
588
	/* 0x17 -0x1c:		reserved */
597
	/* 0x17 - 0x1c:		reserved */
589
598
590
/*----------------------------------------------------------------------------*/
599
/*----------------------------------------------------------------------------*/
591
/*
600
/*
Lines 603-616 Link Here
603
	/* National-specific registers */
612
	/* National-specific registers */
604
#define PHY_NAT_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Control Reg */
613
#define PHY_NAT_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Control Reg */
605
#define PHY_NAT_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
614
#define PHY_NAT_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
606
	/* 0x0b -0x0e:		reserved */
615
	/* 0x0b - 0x0e:		reserved */
607
#define PHY_NAT_EXT_STAT	0x0f	/* 16 bit r/o	Extended Status Register */
616
#define PHY_NAT_EXT_STAT	0x0f	/* 16 bit r/o	Extended Status Register */
608
#define PHY_NAT_EXT_CTRL1	0x10	/* 16 bit r/o	Extended Control Reg1 */
617
#define PHY_NAT_EXT_CTRL1	0x10	/* 16 bit r/o	Extended Control Reg1 */
609
#define PHY_NAT_Q_STAT1		0x11	/* 16 bit r/o	Quick Status Reg1 */
618
#define PHY_NAT_Q_STAT1		0x11	/* 16 bit r/o	Quick Status Reg1 */
610
#define PHY_NAT_10B_OP		0x12	/* 16 bit r/o	10Base-T Operations Reg */
619
#define PHY_NAT_10B_OP		0x12	/* 16 bit r/o	10Base-T Operations Reg */
611
#define PHY_NAT_EXT_CTRL2	0x13	/* 16 bit r/o	Extended Control Reg1 */
620
#define PHY_NAT_EXT_CTRL2	0x13	/* 16 bit r/o	Extended Control Reg1 */
612
#define PHY_NAT_Q_STAT2		0x14	/* 16 bit r/o	Quick Status Reg2 */
621
#define PHY_NAT_Q_STAT2		0x14	/* 16 bit r/o	Quick Status Reg2 */
613
	/* 0x15 -0x18:		reserved */
622
	/* 0x15 - 0x18:		reserved */
614
#define PHY_NAT_PHY_ADDR	0x19	/* 16 bit r/o	PHY Address Register */
623
#define PHY_NAT_PHY_ADDR	0x19	/* 16 bit r/o	PHY Address Register */
615
624
616
625
Lines 618-624 Link Here
618
627
619
/*
628
/*
620
 * PHY bit definitions
629
 * PHY bit definitions
621
 * Bits defined as PHY_X_..., PHY_B_..., PHY_L_... or PHY_N_... are
630
 * Bits defined as PHY_X_..., PHY_B_..., PHY_L_..., PHY_N_... or PHY_M_... are
622
 * XMAC/Broadcom/LevelOne/National/Marvell-specific.
631
 * XMAC/Broadcom/LevelOne/National/Marvell-specific.
623
 * All other are general.
632
 * All other are general.
624
 */
633
 */
Lines 629-642 Link Here
629
/*****  PHY_LONE_CTRL	16 bit r/w	PHY Control Register *****/
638
/*****  PHY_LONE_CTRL	16 bit r/w	PHY Control Register *****/
630
#define PHY_CT_RESET	(1<<15)	/* Bit 15: (sc)	clear all PHY related regs */
639
#define PHY_CT_RESET	(1<<15)	/* Bit 15: (sc)	clear all PHY related regs */
631
#define PHY_CT_LOOP		(1<<14)	/* Bit 14:	enable Loopback over PHY */
640
#define PHY_CT_LOOP		(1<<14)	/* Bit 14:	enable Loopback over PHY */
632
#define PHY_CT_SPS_LSB	(1<<13) /* Bit 13: (BC,L1) Speed select, lower bit */
641
#define PHY_CT_SPS_LSB	(1<<13) /* Bit 13:	Speed select, lower bit */
633
#define PHY_CT_ANE		(1<<12)	/* Bit 12:	Auto-Negotiation Enabled */
642
#define PHY_CT_ANE		(1<<12)	/* Bit 12:	Auto-Negotiation Enabled */
634
#define PHY_CT_PDOWN	(1<<11)	/* Bit 11: (BC,L1) Power Down Mode */
643
#define PHY_CT_PDOWN	(1<<11)	/* Bit 11:	Power Down Mode */
635
#define PHY_CT_ISOL		(1<<10)	/* Bit 10: (BC,L1) Isolate Mode */
644
#define PHY_CT_ISOL		(1<<10)	/* Bit 10:	Isolate Mode */
636
#define PHY_CT_RE_CFG	(1<<9)	/* Bit  9: (sc) Restart Auto-Negotiation */
645
#define PHY_CT_RE_CFG	(1<<9)	/* Bit  9:	(sc) Restart Auto-Negotiation */
637
#define PHY_CT_DUP_MD	(1<<8)	/* Bit  8:	Duplex Mode */
646
#define PHY_CT_DUP_MD	(1<<8)	/* Bit  8:	Duplex Mode */
638
#define PHY_CT_COL_TST	(1<<7)	/* Bit  7: (BC,L1) Collision Test enabled */
647
#define PHY_CT_COL_TST	(1<<7)	/* Bit  7:	Collision Test enabled */
639
#define PHY_CT_SPS_MSB	(1<<6)	/* Bit  6: (BC,L1) Speed select, upper bit */
648
#define PHY_CT_SPS_MSB	(1<<6)	/* Bit  6:	Speed select, upper bit */
640
								/* Bit  5..0:	reserved */
649
								/* Bit  5..0:	reserved */
641
650
642
#define PHY_CT_SP1000	PHY_CT_SPS_MSB	/* enable speed of 1000 Mbps */
651
#define PHY_CT_SP1000	PHY_CT_SPS_MSB	/* enable speed of 1000 Mbps */
Lines 649-673 Link Here
649
/*****  PHY_MARV_STAT	16 bit r/w	PHY Status Register *****/
658
/*****  PHY_MARV_STAT	16 bit r/w	PHY Status Register *****/
650
/*****  PHY_LONE_STAT	16 bit r/w	PHY Status Register *****/
659
/*****  PHY_LONE_STAT	16 bit r/w	PHY Status Register *****/
651
								/* Bit 15..9:	reserved */
660
								/* Bit 15..9:	reserved */
652
				/*	(BC/L1) 100/10 Mbps cap bits ignored*/
661
				/*	(BC/L1) 100/10 Mbps cap bits ignored */
653
#define PHY_ST_EXT_ST	(1<<8)	/* Bit  8:	Extended Status Present */
662
#define PHY_ST_EXT_ST	(1<<8)	/* Bit  8:	Extended Status Present */
654
								/* Bit  7:	reserved */
663
								/* Bit  7:	reserved */
655
#define PHY_ST_PRE_SUP	(1<<6)	/* Bit  6: (BC/L1) preamble suppression */
664
#define PHY_ST_PRE_SUP	(1<<6)	/* Bit  6:	Preamble Suppression */
656
#define PHY_ST_AN_OVER	(1<<5)	/* Bit  5:	Auto-Negotiation Over */
665
#define PHY_ST_AN_OVER	(1<<5)	/* Bit  5:	Auto-Negotiation Over */
657
#define PHY_ST_REM_FLT	(1<<4)	/* Bit  4:	Remote Fault Condition Occured */
666
#define PHY_ST_REM_FLT	(1<<4)	/* Bit  4:	Remote Fault Condition Occured */
658
#define PHY_ST_AN_CAP	(1<<3)	/* Bit  3:	Auto-Negotiation Capability */
667
#define PHY_ST_AN_CAP	(1<<3)	/* Bit  3:	Auto-Negotiation Capability */
659
#define PHY_ST_LSYNC	(1<<2)	/* Bit  2:	Link Synchronized */
668
#define PHY_ST_LSYNC	(1<<2)	/* Bit  2:	Link Synchronized */
660
#define PHY_ST_JAB_DET	(1<<1)	/* Bit  1: (BC/L1) Jabber Detected */
669
#define PHY_ST_JAB_DET	(1<<1)	/* Bit  1:	Jabber Detected */
661
#define PHY_ST_EXT_REG	(1<<0)	/* Bit  0:	Extended Register available */
670
#define PHY_ST_EXT_REG	(1<<0)	/* Bit  0:	Extended Register available */
662
671
663
672
664
/*****	PHY_XMAC_ID1		16 bit r/o	PHY ID1 Register */
673
/*****  PHY_XMAC_ID1		16 bit r/o	PHY ID1 Register */
665
/*****	PHY_BCOM_ID1		16 bit r/o	PHY ID1 Register */
674
/*****  PHY_BCOM_ID1		16 bit r/o	PHY ID1 Register */
666
/*****	PHY_MARV_ID1		16 bit r/o	PHY ID1 Register */
675
/*****  PHY_MARV_ID1		16 bit r/o	PHY ID1 Register */
667
/*****	PHY_LONE_ID1		16 bit r/o	PHY ID1 Register */
676
/*****  PHY_LONE_ID1		16 bit r/o	PHY ID1 Register */
668
#define PHY_I1_OUI_MSK	(0x3f<<10)	/* Bit 15..10:	Organization Unique ID */
677
#define PHY_I1_OUI_MSK	(0x3f<<10)	/* Bit 15..10:	Organization Unique ID */
669
#define PHY_I1_MOD_NUM	(0x3f<<4)	/* Bit  9.. 4:	Model Number */
678
#define PHY_I1_MOD_NUM	(0x3f<<4)	/* Bit  9.. 4:	Model Number */
670
#define PHY_I1_REV_MSK	0x0f		/* Bit  3.. 0:	Revision Number */
679
#define PHY_I1_REV_MSK	0xf			/* Bit  3.. 0:	Revision Number */
671
680
672
/* different Broadcom PHY Ids */
681
/* different Broadcom PHY Ids */
673
#define PHY_BCOM_ID1_A1		0x6041
682
#define PHY_BCOM_ID1_A1		0x6041
Lines 675-685 Link Here
675
#define PHY_BCOM_ID1_C0		0x6044
684
#define PHY_BCOM_ID1_C0		0x6044
676
#define PHY_BCOM_ID1_C5		0x6047
685
#define PHY_BCOM_ID1_C5		0x6047
677
686
687
/* different Marvell PHY Ids */
688
#define PHY_MARV_ID0_VAL	0x0141		/* Marvell Unique Identifier */
689
690
#define PHY_MARV_ID1_B0		0x0C23		/* Yukon (PHY 88E1011) */
691
#define PHY_MARV_ID1_B2		0x0C25		/* Yukon-Plus (PHY 88E1011) */
692
#define PHY_MARV_ID1_C2		0x0CC2		/* Yukon-EC (PHY 88E1111) */
693
#define PHY_MARV_ID1_Y2		0x0C91		/* Yukon-2 (PHY 88E1112) */
694
678
695
679
/*****  PHY_XMAC_AUNE_ADV	16 bit r/w	Auto-Negotiation Advertisement *****/
696
/*****  PHY_XMAC_AUNE_ADV	16 bit r/w	Auto-Negotiation Advertisement *****/
680
/*****  PHY_XMAC_AUNE_LP	16 bit r/o	Link Partner Ability Reg *****/
697
/*****  PHY_XMAC_AUNE_LP	16 bit r/o	Link Partner Ability Reg *****/
681
#define PHY_AN_NXT_PG	(1<<15)	/* Bit 15:	Request Next Page */
698
#define PHY_AN_NXT_PG	(1<<15)	/* Bit 15:	Request Next Page */
682
#define PHY_X_AN_ACK	(1<<14)	/* Bit 14: (ro)	Acknowledge Received */
699
#define PHY_X_AN_ACK	(1<<14)	/* Bit 14:	(ro) Acknowledge Received */
683
#define PHY_X_AN_RFB	(3<<12)	/* Bit 13..12:	Remote Fault Bits */
700
#define PHY_X_AN_RFB	(3<<12)	/* Bit 13..12:	Remote Fault Bits */
684
								/* Bit 11.. 9:	reserved */
701
								/* Bit 11.. 9:	reserved */
685
#define PHY_X_AN_PAUSE	(3<<7)	/* Bit  8.. 7:	Pause Bits */
702
#define PHY_X_AN_PAUSE	(3<<7)	/* Bit  8.. 7:	Pause Bits */
Lines 827-833 Link Here
827
#define PHY_B_PEC_BY_MLT3	(1<<8)	/* Bit  8:	Bypass MLT3 Encoder */
844
#define PHY_B_PEC_BY_MLT3	(1<<8)	/* Bit  8:	Bypass MLT3 Encoder */
828
#define PHY_B_PEC_BY_RXA	(1<<7)	/* Bit  7:	Bypass Rx Alignm. */
845
#define PHY_B_PEC_BY_RXA	(1<<7)	/* Bit  7:	Bypass Rx Alignm. */
829
#define PHY_B_PEC_RES_SCR	(1<<6)	/* Bit  6:	Reset Scrambler */
846
#define PHY_B_PEC_RES_SCR	(1<<6)	/* Bit  6:	Reset Scrambler */
830
#define PHY_B_PEC_EN_LTR	(1<<5)	/* Bit  5:	Ena LED Traffic Mode */
847
#define PHY_B_PEC_EN_LTR	(1<<5)	/* Bit  5:	Enable LED Traffic Mode */
831
#define PHY_B_PEC_LED_ON	(1<<4)	/* Bit  4:	Force LED's on */
848
#define PHY_B_PEC_LED_ON	(1<<4)	/* Bit  4:	Force LED's on */
832
#define PHY_B_PEC_LED_OFF	(1<<3)	/* Bit  3:	Force LED's off */
849
#define PHY_B_PEC_LED_OFF	(1<<3)	/* Bit  3:	Force LED's off */
833
#define PHY_B_PEC_EX_IPG	(1<<2)	/* Bit  2:	Extend Tx IPG Mode */
850
#define PHY_B_PEC_EX_IPG	(1<<2)	/* Bit  2:	Extend Tx IPG Mode */
Lines 981-987 Link Here
981
#define PHY_L_QS_DUP_MOD	(1<<9)	/* Bit  9:	Full/Half Duplex */
998
#define PHY_L_QS_DUP_MOD	(1<<9)	/* Bit  9:	Full/Half Duplex */
982
#define PHY_L_QS_AN			(1<<8)	/* Bit  8:	AutoNeg is On */
999
#define PHY_L_QS_AN			(1<<8)	/* Bit  8:	AutoNeg is On */
983
#define PHY_L_QS_AN_C		(1<<7)	/* Bit  7:	AN is Complete */
1000
#define PHY_L_QS_AN_C		(1<<7)	/* Bit  7:	AN is Complete */
984
#define PHY_L_QS_LLE		(7<<4)	/* Bit  6:	Line Length Estim. */
1001
#define PHY_L_QS_LLE		(7<<4)	/* Bit  6..4:	Line Length Estim. */
985
#define PHY_L_QS_PAUSE		(1<<3)	/* Bit  3:	LP advertised Pause */
1002
#define PHY_L_QS_PAUSE		(1<<3)	/* Bit  3:	LP advertised Pause */
986
#define PHY_L_QS_AS_PAUSE	(1<<2)	/* Bit  2:	LP adv. asym. Pause */
1003
#define PHY_L_QS_AS_PAUSE	(1<<2)	/* Bit  2:	LP adv. asym. Pause */
987
#define PHY_L_QS_ISOLATE	(1<<1)	/* Bit  1:	CIM Isolated */
1004
#define PHY_L_QS_ISOLATE	(1<<1)	/* Bit  1:	CIM Isolated */
Lines 1029-1037 Link Here
1029
									/* Bit  9..0:	not described */
1046
									/* Bit  9..0:	not described */
1030
1047
1031
/*****  PHY_LONE_CIM		16 bit r/o	CIM Reg *****/
1048
/*****  PHY_LONE_CIM		16 bit r/o	CIM Reg *****/
1032
#define PHY_L_CIM_ISOL		(255<<8)/* Bit 15..8:	Isolate Count */
1049
#define PHY_L_CIM_ISOL		(0xff<<8)	/* Bit 15..8:	Isolate Count */
1033
#define PHY_L_CIM_FALSE_CAR	(255<<0)/* Bit  7..0:	False Carrier Count */
1050
#define PHY_L_CIM_FALSE_CAR	0xff		/* Bit  7..0:	False Carrier Count */
1034
1035
1051
1036
/*
1052
/*
1037
 * Pause Bits (PHY_L_AN_ASP and PHY_L_AN_PC) encoding
1053
 * Pause Bits (PHY_L_AN_ASP and PHY_L_AN_PC) encoding
Lines 1041-1047 Link Here
1041
#define PHY_L_P_ASYM_MD		(2<<10)	/* Bit 11..10:	asymmetric Pause Mode */
1057
#define PHY_L_P_ASYM_MD		(2<<10)	/* Bit 11..10:	asymmetric Pause Mode */
1042
#define PHY_L_P_BOTH_MD		(3<<10)	/* Bit 11..10:	both Pause Mode */
1058
#define PHY_L_P_BOTH_MD		(3<<10)	/* Bit 11..10:	both Pause Mode */
1043
1059
1044
1045
/*
1060
/*
1046
 * National-Specific
1061
 * National-Specific
1047
 */
1062
 */
Lines 1086-1107 Link Here
1086
 */
1101
 */
1087
/*****  PHY_MARV_AUNE_ADV	16 bit r/w	Auto-Negotiation Advertisement *****/
1102
/*****  PHY_MARV_AUNE_ADV	16 bit r/w	Auto-Negotiation Advertisement *****/
1088
/*****  PHY_MARV_AUNE_LP	16 bit r/w	Link Part Ability Reg *****/
1103
/*****  PHY_MARV_AUNE_LP	16 bit r/w	Link Part Ability Reg *****/
1089
#define PHY_M_AN_NXT_PG		BIT_15	/* Request Next Page */
1104
#define PHY_M_AN_NXT_PG		BIT_15S	/* Request Next Page */
1090
#define PHY_M_AN_ACK		BIT_14	/* (ro)	Acknowledge Received */
1105
#define PHY_M_AN_ACK		BIT_14S	/* (ro)	Acknowledge Received */
1091
#define PHY_M_AN_RF			BIT_13	/* Remote Fault */
1106
#define PHY_M_AN_RF			BIT_13S	/* Remote Fault */
1092
									/* Bit 12:	reserved */
1107
								/* Bit 12:	reserved */
1093
#define PHY_M_AN_ASP		BIT_11	/* Asymmetric Pause */
1108
#define PHY_M_AN_ASP		BIT_11S	/* Asymmetric Pause */
1094
#define PHY_M_AN_PC			BIT_10	/* MAC Pause implemented */
1109
#define PHY_M_AN_PC			BIT_10S	/* MAC Pause implemented */
1095
#define PHY_M_AN_100_FD		BIT_8	/* Advertise 100Base-TX Full Duplex */
1110
#define PHY_M_AN_100_T4		BIT_9S	/* Not cap. 100Base-T4 (always 0) */
1096
#define PHY_M_AN_100_HD		BIT_7	/* Advertise 100Base-TX Half Duplex */
1111
#define PHY_M_AN_100_FD		BIT_8S	/* Advertise 100Base-TX Full Duplex */
1097
#define PHY_M_AN_10_FD		BIT_6	/* Advertise 10Base-TX Full Duplex */
1112
#define PHY_M_AN_100_HD		BIT_7S	/* Advertise 100Base-TX Half Duplex */
1098
#define PHY_M_AN_10_HD		BIT_5	/* Advertise 10Base-TX Half Duplex */
1113
#define PHY_M_AN_10_FD		BIT_6S	/* Advertise 10Base-TX Full Duplex */
1114
#define PHY_M_AN_10_HD		BIT_5S	/* Advertise 10Base-TX Half Duplex */
1115
#define PHY_M_AN_SEL_MSK	(0x1f<<4)	/* Bit  4.. 0: Selector Field Mask */
1099
1116
1100
/* special defines for FIBER (88E1011S only) */
1117
/* special defines for FIBER (88E1011S only) */
1101
#define PHY_M_AN_ASP_X		BIT_8	/* Asymmetric Pause */
1118
#define PHY_M_AN_ASP_X		BIT_8S	/* Asymmetric Pause */
1102
#define PHY_M_AN_PC_X		BIT_7	/* MAC Pause implemented */
1119
#define PHY_M_AN_PC_X		BIT_7S	/* MAC Pause implemented */
1103
#define PHY_M_AN_1000X_AHD	BIT_6	/* Advertise 10000Base-X Half Duplex */
1120
#define PHY_M_AN_1000X_AHD	BIT_6S	/* Advertise 10000Base-X Half Duplex */
1104
#define PHY_M_AN_1000X_AFD	BIT_5	/* Advertise 10000Base-X Full Duplex */
1121
#define PHY_M_AN_1000X_AFD	BIT_5S	/* Advertise 10000Base-X Full Duplex */
1105
1122
1106
/* Pause Bits (PHY_M_AN_ASP_X and PHY_M_AN_PC_X) encoding */
1123
/* Pause Bits (PHY_M_AN_ASP_X and PHY_M_AN_PC_X) encoding */
1107
#define PHY_M_P_NO_PAUSE_X	(0<<7)	/* Bit  8.. 7:	no Pause Mode */
1124
#define PHY_M_P_NO_PAUSE_X	(0<<7)	/* Bit  8.. 7:	no Pause Mode */
Lines 1111-1215 Link Here
1111
1128
1112
/*****  PHY_MARV_1000T_CTRL	16 bit r/w	1000Base-T Control Reg *****/
1129
/*****  PHY_MARV_1000T_CTRL	16 bit r/w	1000Base-T Control Reg *****/
1113
#define PHY_M_1000C_TEST	(7<<13)	/* Bit 15..13:	Test Modes */
1130
#define PHY_M_1000C_TEST	(7<<13)	/* Bit 15..13:	Test Modes */
1114
#define PHY_M_1000C_MSE		(1<<12)	/* Bit 12:	Manual Master/Slave Enable */
1131
#define PHY_M_1000C_MSE		BIT_12S	/* Manual Master/Slave Enable */
1115
#define PHY_M_1000C_MSC		(1<<11)	/* Bit 11:	M/S Configuration (1=Master) */
1132
#define PHY_M_1000C_MSC		BIT_11S	/* M/S Configuration (1=Master) */
1116
#define PHY_M_1000C_MPD		(1<<10)	/* Bit 10:	Multi-Port Device */
1133
#define PHY_M_1000C_MPD		BIT_10S	/* Multi-Port Device */
1117
#define PHY_M_1000C_AFD		(1<<9)	/* Bit  9:	Advertise Full Duplex */
1134
#define PHY_M_1000C_AFD		BIT_9S	/* Advertise Full Duplex */
1118
#define PHY_M_1000C_AHD		(1<<8)	/* Bit  8:	Advertise Half Duplex */
1135
#define PHY_M_1000C_AHD		BIT_8S	/* Advertise Half Duplex */
1119
									/* Bit  7..0:	reserved */
1136
									/* Bit  7..0:	reserved */
1120
1137
1121
/*****  PHY_MARV_PHY_CTRL	16 bit r/w	PHY Specific Ctrl Reg *****/
1138
/*****  PHY_MARV_PHY_CTRL	16 bit r/w	PHY Specific Ctrl Reg *****/
1122
#define PHY_M_PC_TX_FFD_MSK	(3<<14)	/* Bit 15..14:	Tx FIFO Depth Mask */
1139
#define PHY_M_PC_TX_FFD_MSK	(3<<14)	/* Bit 15..14: Tx FIFO Depth Mask */
1123
#define PHY_M_PC_RX_FFD_MSK	(3<<12)	/* Bit 13..12:	Rx FIFO Depth Mask */
1140
#define PHY_M_PC_RX_FFD_MSK	(3<<12)	/* Bit 13..12: Rx FIFO Depth Mask */
1124
#define PHY_M_PC_ASS_CRS_TX	(1<<11)	/* Bit 11:	Assert CRS on Transmit */
1141
#define PHY_M_PC_ASS_CRS_TX	BIT_11S	/* Assert CRS on Transmit */
1125
#define PHY_M_PC_FL_GOOD	(1<<10)	/* Bit 10:	Force Link Good */
1142
#define PHY_M_PC_FL_GOOD	BIT_10S	/* Force Link Good */
1126
#define PHY_M_PC_EN_DET_MSK	(3<<8)	/* Bit  9.. 8:	Energy Detect Mask */
1143
#define PHY_M_PC_EN_DET_MSK	(3<<8)	/* Bit  9.. 8: Energy Detect Mask */
1127
#define PHY_M_PC_ENA_EXT_D	(1<<7)	/* Bit  7:	Enable Ext. Distance (10BT) */
1144
#define PHY_M_PC_ENA_EXT_D	BIT_7S	/* Enable Ext. Distance (10BT) */
1128
#define PHY_M_PC_MDIX_MSK	(3<<5)	/* Bit  6.. 5:	MDI/MDIX Config. Mask */
1145
#define PHY_M_PC_MDIX_MSK	(3<<5)	/* Bit  6.. 5: MDI/MDIX Config. Mask */
1129
#define PHY_M_PC_DIS_125CLK	(1<<4)	/* Bit  4:	Disable 125 CLK */
1146
#define PHY_M_PC_DIS_125CLK	BIT_4S	/* Disable 125 CLK */
1130
#define PHY_M_PC_MAC_POW_UP	(1<<3)	/* Bit  3:	MAC Power up */
1147
#define PHY_M_PC_MAC_POW_UP	BIT_3S	/* MAC Power up */
1131
#define PHY_M_PC_SQE_T_ENA	(1<<2)	/* Bit  2:	SQE Test Enabled */
1148
#define PHY_M_PC_SQE_T_ENA	BIT_2S	/* SQE Test Enabled */
1132
#define PHY_M_PC_POL_R_DIS	(1<<1)	/* Bit  1:	Polarity Reversal Disabled */
1149
#define PHY_M_PC_POL_R_DIS	BIT_1S	/* Polarity Reversal Disabled */
1133
#define PHY_M_PC_DIS_JABBER	(1<<0)	/* Bit  0:	Disable Jabber */
1150
#define PHY_M_PC_DIS_JABBER	BIT_0S	/* Disable Jabber */
1134
1151
1135
#define PHY_M_PC_EN_DET			SHIFT8(2)	/* Energy Detect (Mode 1) */
1152
#define PHY_M_PC_EN_DET			SHIFT8(2)	/* Energy Detect (Mode 1) */
1136
#define PHY_M_PC_EN_DET_PLUS	SHIFT8(3)	/* Energy Detect Plus (Mode 2) */
1153
#define PHY_M_PC_EN_DET_PLUS	SHIFT8(3)	/* Energy Detect Plus (Mode 2) */
1137
1154
1138
#define PHY_M_PC_MDI_XMODE(x)	SHIFT5(x)	
1155
#define PHY_M_PC_MDI_XMODE(x)	(SHIFT5(x) & PHY_M_PC_MDIX_MSK)	
1139
#define PHY_M_PC_MAN_MDI	0    	/* 00 = Manual MDI configuration */
1156
1157
#define PHY_M_PC_MAN_MDI	0		/* 00 = Manual MDI configuration */
1140
#define PHY_M_PC_MAN_MDIX	1		/* 01 = Manual MDIX configuration */
1158
#define PHY_M_PC_MAN_MDIX	1		/* 01 = Manual MDIX configuration */
1141
#define PHY_M_PC_ENA_AUTO	3		/* 11 = Enable Automatic Crossover */
1159
#define PHY_M_PC_ENA_AUTO	3		/* 11 = Enable Automatic Crossover */
1142
1160
1161
/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */
1162
#define PHY_M_PC_DIS_LINK_P	BIT_15S	/* Disable Link Pulses */
1163
#define PHY_M_PC_DSC_MSK	(7<<12)	/* Bit 14..12:	Downshift Counter */
1164
#define PHY_M_PC_DOWN_S_ENA	BIT_11S	/* Downshift Enable */
1165
									/* !!! Errata in spec. (1 = disable) */
1166
1167
#define PHY_M_PC_DSC(x)			(SHIFT12(x) & PHY_M_PC_DSC_MSK)
1168
										/* 000=1x; 001=2x; 010=3x; 011=4x */
1169
										/* 100=5x; 101=6x; 110=7x; 111=8x */
1170
1171
/* for 10/100 Fast Ethernet PHY (88E3082 only) */
1172
#define PHY_M_PC_ENA_DTE_DT	BIT_15S	/* Enable Data Terminal Equ. (DTE) Detect */
1173
#define PHY_M_PC_ENA_ENE_DT	BIT_14S	/* Enable Energy Detect (sense & pulse) */
1174
#define PHY_M_PC_DIS_NLP_CK	BIT_13S	/* Disable Normal Link Puls (NLP) Check */
1175
#define PHY_M_PC_ENA_LIP_NP	BIT_12S	/* Enable Link Partner Next Page Reg. */
1176
#define PHY_M_PC_DIS_NLP_GN	BIT_11S	/* Disable Normal Link Puls Generation */
1177
1178
#define PHY_M_PC_DIS_SCRAMB	BIT_9S	/* Disable Scrambler */
1179
#define PHY_M_PC_DIS_FEFI	BIT_8S	/* Disable Far End Fault Indic. (FEFI) */
1180
1181
#define PHY_M_PC_SH_TP_SEL	BIT_6S	/* Shielded Twisted Pair Select */
1182
#define PHY_M_PC_RX_FD_MSK	(3<<2)	/* Bit  3.. 2: Rx FIFO Depth Mask */
1183
1143
/*****  PHY_MARV_PHY_STAT	16 bit r/o	PHY Specific Status Reg *****/
1184
/*****  PHY_MARV_PHY_STAT	16 bit r/o	PHY Specific Status Reg *****/
1144
#define PHY_M_PS_SPEED_MSK	(3<<14)	/* Bit 15..14:	Speed Mask */
1185
#define PHY_M_PS_SPEED_MSK	(3<<14)	/* Bit 15..14: Speed Mask */
1145
#define PHY_M_PS_SPEED_1000	(1<<15)	/*       10 = 1000 Mbps */
1186
#define PHY_M_PS_SPEED_1000	BIT_15S	/*		10 = 1000 Mbps */
1146
#define PHY_M_PS_SPEED_100	(1<<14)	/*       01 =  100 Mbps */
1187
#define PHY_M_PS_SPEED_100	BIT_14S	/*		01 =  100 Mbps */
1147
#define PHY_M_PS_SPEED_10	0		/*       00 =   10 Mbps */
1188
#define PHY_M_PS_SPEED_10	0		/*		00 =   10 Mbps */
1148
#define PHY_M_PS_FULL_DUP	(1<<13)	/* Bit 13:	Full Duplex */
1189
#define PHY_M_PS_FULL_DUP	BIT_13S	/* Full Duplex */
1149
#define PHY_M_PS_PAGE_REC	(1<<12)	/* Bit 12:	Page Received */
1190
#define PHY_M_PS_PAGE_REC	BIT_12S	/* Page Received */
1150
#define PHY_M_PS_SPDUP_RES	(1<<11)	/* Bit 11:	Speed & Duplex Resolved */
1191
#define PHY_M_PS_SPDUP_RES	BIT_11S	/* Speed & Duplex Resolved */
1151
#define PHY_M_PS_LINK_UP	(1<<10)	/* Bit 10:	Link Up */
1192
#define PHY_M_PS_LINK_UP	BIT_10S	/* Link Up */
1152
#define PHY_M_PS_CABLE_MSK	(3<<7)	/* Bit  9.. 7:	Cable Length Mask */
1193
#define PHY_M_PS_CABLE_MSK	(7<<7)	/* Bit  9.. 7: Cable Length Mask */
1153
#define PHY_M_PS_MDI_X_STAT	(1<<6)	/* Bit  6:	MDI Crossover Stat (1=MDIX) */
1194
#define PHY_M_PS_MDI_X_STAT	BIT_6S	/* MDI Crossover Stat (1=MDIX) */
1154
#define PHY_M_PS_DOWNS_STAT	(1<<5)	/* Bit  5:	Downshift Status (1=downsh.) */
1195
#define PHY_M_PS_DOWNS_STAT	BIT_5S	/* Downshift Status (1=downsh.) */
1155
#define PHY_M_PS_ENDET_STAT	(1<<4)	/* Bit  4:	Energy Detect Status (1=act) */
1196
#define PHY_M_PS_ENDET_STAT	BIT_4S	/* Energy Detect Status (1=act) */
1156
#define PHY_M_PS_TX_P_EN	(1<<3)	/* Bit  3:	Tx Pause Enabled */
1197
#define PHY_M_PS_TX_P_EN	BIT_3S	/* Tx Pause Enabled */
1157
#define PHY_M_PS_RX_P_EN	(1<<2)	/* Bit  2:	Rx Pause Enabled */
1198
#define PHY_M_PS_RX_P_EN	BIT_2S	/* Rx Pause Enabled */
1158
#define PHY_M_PS_POL_REV	(1<<1)	/* Bit  1:	Polarity Reversed */
1199
#define PHY_M_PS_POL_REV	BIT_1S	/* Polarity Reversed */
1159
#define PHY_M_PC_JABBER		(1<<0)	/* Bit  0:	Jabber */
1200
#define PHY_M_PS_JABBER		BIT_0S	/* Jabber */
1160
1201
1161
#define PHY_M_PS_PAUSE_MSK	(PHY_M_PS_TX_P_EN | PHY_M_PS_RX_P_EN)
1202
#define PHY_M_PS_PAUSE_MSK	(PHY_M_PS_TX_P_EN | PHY_M_PS_RX_P_EN)
1162
1203
1204
/* for 10/100 Fast Ethernet PHY (88E3082 only) */
1205
#define PHY_M_PS_DTE_DETECT	BIT_15S	/* Data Terminal Equipment (DTE) Detected */
1206
#define PHY_M_PS_RES_SPEED	BIT_14S	/* Resolved Speed (1=100 Mbps, 0=10 Mbps */
1207
1163
/*****  PHY_MARV_INT_MASK	16 bit r/w	Interrupt Mask Reg *****/
1208
/*****  PHY_MARV_INT_MASK	16 bit r/w	Interrupt Mask Reg *****/
1164
/*****  PHY_MARV_INT_STAT	16 bit r/o	Interrupt Status Reg *****/
1209
/*****  PHY_MARV_INT_STAT	16 bit r/o	Interrupt Status Reg *****/
1165
#define PHY_M_IS_AN_ERROR	(1<<15)	/* Bit 15:	Auto-Negotiation Error */
1210
#define PHY_M_IS_AN_ERROR	BIT_15S	/* Auto-Negotiation Error */
1166
#define PHY_M_IS_LSP_CHANGE	(1<<14)	/* Bit 14:	Link Speed Changed */
1211
#define PHY_M_IS_LSP_CHANGE	BIT_14S	/* Link Speed Changed */
1167
#define PHY_M_IS_DUP_CHANGE	(1<<13)	/* Bit 13:	Duplex Mode Changed */
1212
#define PHY_M_IS_DUP_CHANGE	BIT_13S	/* Duplex Mode Changed */
1168
#define PHY_M_IS_AN_PR		(1<<12)	/* Bit 12:	Page Received */
1213
#define PHY_M_IS_AN_PR		BIT_12S	/* Page Received */
1169
#define PHY_M_IS_AN_COMPL	(1<<11)	/* Bit 11:	Auto-Negotiation Completed */
1214
#define PHY_M_IS_AN_COMPL	BIT_11S	/* Auto-Negotiation Completed */
1170
#define PHY_M_IS_LST_CHANGE	(1<<10)	/* Bit 10:	Link Status Changed */
1215
#define PHY_M_IS_LST_CHANGE	BIT_10S	/* Link Status Changed */
1171
#define PHY_M_IS_SYMB_ERROR	(1<<9)	/* Bit  9:	Symbol Error */
1216
#define PHY_M_IS_SYMB_ERROR	BIT_9S	/* Symbol Error */
1172
#define PHY_M_IS_FALSE_CARR	(1<<8)	/* Bit  8:	False Carrier */
1217
#define PHY_M_IS_FALSE_CARR	BIT_8S	/* False Carrier */
1173
#define PHY_M_IS_FIFO_ERROR	(1<<7)	/* Bit  7:	FIFO Overflow/Underrun Error */
1218
#define PHY_M_IS_FIFO_ERROR	BIT_7S	/* FIFO Overflow/Underrun Error */
1174
#define PHY_M_IS_MDI_CHANGE	(1<<6)	/* Bit  6:	MDI Crossover Changed */
1219
#define PHY_M_IS_MDI_CHANGE	BIT_6S	/* MDI Crossover Changed */
1175
#define PHY_M_IS_DOWNSH_DET	(1<<5)	/* Bit  5:	Downshift Detected */
1220
#define PHY_M_IS_DOWNSH_DET	BIT_5S	/* Downshift Detected */
1176
#define PHY_M_IS_END_CHANGE	(1<<4)	/* Bit  4:	Energy Detect Changed */
1221
#define PHY_M_IS_END_CHANGE	BIT_4S	/* Energy Detect Changed */
1177
									/* Bit  3..2:	reserved */
1222
								/* Bit   3:	reserved */
1178
#define PHY_M_IS_POL_CHANGE	(1<<1)	/* Bit  1:	Polarity Changed */
1223
#define PHY_M_IS_DTE_CHANGE	BIT_2S	/* DTE Power Det. Status Changed */
1179
#define PHY_M_IS_JABBER		(1<<0)	/* Bit  0:	Jabber */
1224
									/* (88E1111 only) */
1225
#define PHY_M_IS_POL_CHANGE	BIT_1S	/* Polarity Changed */
1226
#define PHY_M_IS_JABBER		BIT_0S	/* Jabber */
1180
1227
1181
#define PHY_M_DEF_MSK		(PHY_M_IS_AN_ERROR | PHY_M_IS_AN_PR | \
1228
#define PHY_M_DEF_MSK		(PHY_M_IS_AN_ERROR | PHY_M_IS_AN_PR | \
1182
							PHY_M_IS_LST_CHANGE | PHY_M_IS_FIFO_ERROR)
1229
							PHY_M_IS_LST_CHANGE | PHY_M_IS_FIFO_ERROR)
1183
1230
1184
/*****  PHY_MARV_EXT_CTRL	16 bit r/w	Ext. PHY Specific Ctrl *****/
1231
/*****  PHY_MARV_EXT_CTRL	16 bit r/w	Ext. PHY Specific Ctrl *****/
1185
#define PHY_M_EC_M_DSC_MSK	(3<<10)	/* Bit 11..10:	Master downshift counter */
1232
#define PHY_M_EC_ENA_BC_EXT	BIT_15S	/* Enable Block Carr. Ext. (88E1111 only) */
1186
#define PHY_M_EC_S_DSC_MSK	(3<<8)	/* Bit  9.. 8:	Slave  downshift counter */
1233
#define PHY_M_EC_ENA_LIN_LB	BIT_14S	/* Enable Line Loopback (88E1111 only) */
1234
								/* Bit 13:	reserved */
1235
#define PHY_M_EC_DIS_LINK_P	BIT_12S	/* Disable Link Pulses (88E1111 only) */
1236
#define PHY_M_EC_M_DSC_MSK	(3<<10)	/* Bit 11..10:	Master Downshift Counter */
1237
									/* (88E1011 only) */
1238
#define PHY_M_EC_S_DSC_MSK	(3<<8)	/* Bit  9.. 8:	Slave  Downshift Counter */
1239
									/* (88E1011 only) */
1240
#define PHY_M_EC_DSC_MSK_2	(7<<9)	/* Bit 11.. 9:	Downshift Counter */
1241
									/* (88E1111 only) */
1242
#define PHY_M_EC_DOWN_S_ENA	BIT_8S	/* Downshift Enable (88E1111 only) */
1243
									/* !!! Errata in spec. (1 = disable) */
1244
#define PHY_M_EC_RX_TIM_CT	BIT_7S	/* RGMII Rx Timing Control*/
1187
#define PHY_M_EC_MAC_S_MSK	(7<<4)	/* Bit  6.. 4:	Def. MAC interface speed */
1245
#define PHY_M_EC_MAC_S_MSK	(7<<4)	/* Bit  6.. 4:	Def. MAC interface speed */
1188
#define PHY_M_EC_FIB_AN_ENA	(1<<3)	/* Bit  3:	Fiber Auto-Neg. Enable */
1246
#define PHY_M_EC_FIB_AN_ENA	BIT_3S	/* Fiber Auto-Neg. Enable (88E1011S only) */
1189
1247
#define PHY_M_EC_DTE_D_ENA	BIT_2S	/* DTE Detect Enable (88E1111 only) */
1190
#define PHY_M_EC_M_DSC(x)		SHIFT10(x)	/* 00=1x; 01=2x; 10=3x; 11=4x */
1248
#define PHY_M_EC_TX_TIM_CT	BIT_1S	/* RGMII Tx Timing Control */
1191
#define PHY_M_EC_S_DSC(x)		SHIFT8(x)	/* 00=dis; 01=1x; 10=2x; 11=3x */
1249
#define PHY_M_EC_TRANS_DIS	BIT_0S	/* Transmitter Disable (88E1111 only) */
1192
#define PHY_M_EC_MAC_S(x)		SHIFT4(x)	/* 01X=0; 110=2.5; 111=25 (MHz) */
1250
1193
1251
#define PHY_M_EC_M_DSC(x)		(SHIFT10(x) & PHY_M_EC_M_DSC_MSK)
1252
									/* 00=1x; 01=2x; 10=3x; 11=4x */
1253
#define PHY_M_EC_S_DSC(x)		(SHIFT8(x) & PHY_M_EC_S_DSC_MSK)
1254
									/* 00=dis; 01=1x; 10=2x; 11=3x */
1255
#define PHY_M_EC_MAC_S(x)		(SHIFT4(x) & PHY_M_EC_MAC_S_MSK)
1256
									/* 01X=0; 110=2.5; 111=25 (MHz) */
1257
1258
#define PHY_M_EC_DSC_2(x)		(SHIFT9(x) & PHY_M_EC_DSC_MSK_2)
1259
									/* 000=1x; 001=2x; 010=3x; 011=4x */
1260
									/* 100=5x; 101=6x; 110=7x; 111=8x */
1194
#define MAC_TX_CLK_0_MHZ	2
1261
#define MAC_TX_CLK_0_MHZ	2
1195
#define MAC_TX_CLK_2_5_MHZ	6
1262
#define MAC_TX_CLK_2_5_MHZ	6
1196
#define MAC_TX_CLK_25_MHZ	7
1263
#define MAC_TX_CLK_25_MHZ	7
1197
1264
1198
/*****  PHY_MARV_LED_CTRL	16 bit r/w	LED Control Reg *****/
1265
/*****  PHY_MARV_LED_CTRL	16 bit r/w	LED Control Reg *****/
1199
#define PHY_M_LEDC_DIS_LED	(1<<15)	/* Bit 15:	Disable LED */
1266
#define PHY_M_LEDC_DIS_LED	BIT_15S	/* Disable LED */
1200
#define PHY_M_LEDC_PULS_MSK	(7<<12)	/* Bit 14..12:  Pulse Stretch Mask */
1267
#define PHY_M_LEDC_PULS_MSK	(7<<12)	/* Bit 14..12: Pulse Stretch Mask */
1201
#define PHY_M_LEDC_F_INT	(1<<11)	/* Bit 11:	Force Interrupt */
1268
#define PHY_M_LEDC_F_INT	BIT_11S	/* Force Interrupt */
1202
#define PHY_M_LEDC_BL_R_MSK	(7<<8)	/* Bit 10.. 8:  Blink Rate Mask */
1269
#define PHY_M_LEDC_BL_R_MSK	(7<<8)	/* Bit 10.. 8: Blink Rate Mask */
1203
									/* Bit  7.. 5:	reserved */
1270
#define PHY_M_LEDC_DP_C_LSB	BIT_7S	/* Duplex Control (LSB, 88E1111 only) */
1204
#define PHY_M_LEDC_LINK_MSK	(3<<3)	/* Bit  4.. 3:	Link Control Mask */
1271
#define PHY_M_LEDC_TX_C_LSB	BIT_6S	/* Tx Control (LSB, 88E1111 only) */
1205
#define PHY_M_LEDC_DP_CTRL	(1<<2)	/* Bit  2:	Duplex Control */
1272
#define PHY_M_LEDC_LK_C_MSK	(7<<3)	/* Bit  5.. 3: Link Control Mask */
1206
#define PHY_M_LEDC_RX_CTRL	(1<<1)	/* Bit  1:	Rx activity / Link */
1273
									/* (88E1111 only) */
1207
#define PHY_M_LEDC_TX_CTRL	(1<<0)	/* Bit  0:	Tx activity / Link */
1274
								/* Bit  7.. 5:	reserved (88E1011 only) */
1275
#define PHY_M_LEDC_LINK_MSK	(3<<3)	/* Bit  4.. 3: Link Control Mask */
1276
									/* (88E1011 only) */
1277
#define PHY_M_LEDC_DP_CTRL	BIT_2S	/* Duplex Control */
1278
#define PHY_M_LEDC_DP_C_MSB	BIT_2S	/* Duplex Control (MSB, 88E1111 only) */
1279
#define PHY_M_LEDC_RX_CTRL	BIT_1S	/* Rx Activity / Link */
1280
#define PHY_M_LEDC_TX_CTRL	BIT_0S	/* Tx Activity / Link */
1281
#define PHY_M_LEDC_TX_C_MSB	BIT_0S	/* Tx Control (MSB, 88E1111 only) */
1208
1282
1209
#define PHY_M_LED_PULS_DUR(x)	SHIFT12(x)	/* Pulse Stretch Duration */
1283
#define PHY_M_LED_PULS_DUR(x)	(SHIFT12(x) & PHY_M_LEDC_PULS_MSK)
1210
1284
1211
#define	PULS_NO_STR		0		/* no pulse stretching */
1285
#define PULS_NO_STR		0		/* no pulse stretching */
1212
#define	PULS_21MS		1		/* 21 ms to 42 ms */
1286
#define PULS_21MS		1		/* 21 ms to 42 ms */
1213
#define PULS_42MS		2		/* 42 ms to 84 ms */
1287
#define PULS_42MS		2		/* 42 ms to 84 ms */
1214
#define PULS_84MS		3		/* 84 ms to 170 ms */
1288
#define PULS_84MS		3		/* 84 ms to 170 ms */
1215
#define PULS_170MS		4		/* 170 ms to 340 ms */
1289
#define PULS_170MS		4		/* 170 ms to 340 ms */
Lines 1217-1223 Link Here
1217
#define PULS_670MS		6		/* 670 ms to 1.3 s */
1291
#define PULS_670MS		6		/* 670 ms to 1.3 s */
1218
#define PULS_1300MS		7		/* 1.3 s to 2.7 s */
1292
#define PULS_1300MS		7		/* 1.3 s to 2.7 s */
1219
1293
1220
#define PHY_M_LED_BLINK_RT(x)	SHIFT8(x)	/* Blink Rate */
1294
#define PHY_M_LED_BLINK_RT(x)	(SHIFT8(x) & PHY_M_LEDC_BL_R_MSK)
1221
1295
1222
#define BLINK_42MS		0		/* 42 ms */
1296
#define BLINK_42MS		0		/* 42 ms */
1223
#define BLINK_84MS		1		/* 84 ms */
1297
#define BLINK_84MS		1		/* 84 ms */
Lines 1227-1232 Link Here
1227
								/* values 5 - 7: reserved */
1301
								/* values 5 - 7: reserved */
1228
1302
1229
/*****  PHY_MARV_LED_OVER	16 bit r/w	Manual LED Override Reg *****/
1303
/*****  PHY_MARV_LED_OVER	16 bit r/w	Manual LED Override Reg *****/
1304
#define PHY_M_LED_MO_SGMII(x)	SHIFT14(x)	/* Bit 15..14:  SGMII AN Timer */
1305
										/* Bit 13..12:	reserved */
1230
#define PHY_M_LED_MO_DUP(x)		SHIFT10(x)	/* Bit 11..10:  Duplex */
1306
#define PHY_M_LED_MO_DUP(x)		SHIFT10(x)	/* Bit 11..10:  Duplex */
1231
#define PHY_M_LED_MO_10(x)		SHIFT8(x)	/* Bit  9.. 8:  Link 10 */
1307
#define PHY_M_LED_MO_10(x)		SHIFT8(x)	/* Bit  9.. 8:  Link 10 */
1232
#define PHY_M_LED_MO_100(x)		SHIFT6(x)	/* Bit  7.. 6:  Link 100 */
1308
#define PHY_M_LED_MO_100(x)		SHIFT6(x)	/* Bit  7.. 6:  Link 100 */
Lines 1240-1269 Link Here
1240
#define MO_LED_ON			3
1316
#define MO_LED_ON			3
1241
1317
1242
/*****  PHY_MARV_EXT_CTRL_2	16 bit r/w	Ext. PHY Specific Ctrl 2 *****/
1318
/*****  PHY_MARV_EXT_CTRL_2	16 bit r/w	Ext. PHY Specific Ctrl 2 *****/
1243
									/* Bit 15.. 7:	reserved */
1319
								/* Bit 15.. 7:	reserved */
1244
#define PHY_M_EC2_FI_IMPED	(1<<6)	/* Bit  6:	Fiber Input  Impedance */
1320
#define PHY_M_EC2_FI_IMPED	BIT_6S	/* Fiber Input  Impedance */
1245
#define PHY_M_EC2_FO_IMPED	(1<<5)	/* Bit  5:	Fiber Output Impedance */
1321
#define PHY_M_EC2_FO_IMPED	BIT_5S	/* Fiber Output Impedance */
1246
#define PHY_M_EC2_FO_M_CLK	(1<<4)	/* Bit  4:	Fiber Mode Clock Enable */
1322
#define PHY_M_EC2_FO_M_CLK	BIT_4S	/* Fiber Mode Clock Enable */
1247
#define PHY_M_EC2_FO_BOOST	(1<<3)	/* Bit  3:	Fiber Output Boost */
1323
#define PHY_M_EC2_FO_BOOST	BIT_3S	/* Fiber Output Boost */
1248
#define PHY_M_EC2_FO_AM_MSK	7		/* Bit  2.. 0:	Fiber Output Amplitude */
1324
#define PHY_M_EC2_FO_AM_MSK	7		/* Bit  2.. 0:	Fiber Output Amplitude */
1249
1325
1250
/*****	PHY_MARV_EXT_P_STAT 16 bit r/w	Ext. PHY Specific Status *****/
1326
/*****  PHY_MARV_EXT_P_STAT 16 bit r/w	Ext. PHY Specific Status *****/
1251
#define PHY_M_FC_AUTO_SEL	(1<<15)	/* Bit 15:	Fiber/Copper Auto Sel. dis. */
1327
#define PHY_M_FC_AUTO_SEL	BIT_15S	/* Fiber/Copper Auto Sel. Dis. */
1252
#define PHY_M_FC_AN_REG_ACC (1<<14) /* Bit 14:	Fiber/Copper Autoneg. reg acc */
1328
#define PHY_M_FC_AN_REG_ACC	BIT_14S	/* Fiber/Copper AN Reg. Access */
1253
#define PHY_M_FC_RESULUTION (1<<13)	/* Bit 13:	Fiber/Copper Resulution */
1329
#define PHY_M_FC_RESOLUTION	BIT_13S	/* Fiber/Copper Resolution */
1254
#define PHY_M_SER_IF_AN_BP  (1<<12) /* Bit 12:	Ser IF autoneg. bypass enable */
1330
#define PHY_M_SER_IF_AN_BP	BIT_12S	/* Ser. IF AN Bypass Enable */
1255
#define PHY_M_SER_IF_BP_ST	(1<<11) /* Bit 11:	Ser IF autoneg. bypass status */
1331
#define PHY_M_SER_IF_BP_ST	BIT_11S	/* Ser. IF AN Bypass Status */
1256
#define PHY_M_IRQ_POLARITY	(1<<10) /* Bit 10:	IRQ polarity */
1332
#define PHY_M_IRQ_POLARITY	BIT_10S	/* IRQ polarity */
1257
									/* Bit 9..4: reserved */
1333
#define PHY_M_DIS_AUT_MED	BIT_9S	/* Disable Aut. Medium Reg. Selection */
1258
#define PHY_M_UNDOC1		(1<< 7) /* undocumented bit !! */
1334
									/* (88E1111 only) */
1259
#define PHY_M_MODE_MASK		(0xf<<0)/* Bit 3..0: copy of HWCFG MODE[3:0] */
1335
								/* Bit  9.. 4: reserved (88E1011 only) */
1260
1336
#define PHY_M_UNDOC1		BIT_7S	/* undocumented bit !! */
1337
#define PHY_M_DTE_POW_STAT	BIT_4S	/* DTE Power Status (88E1111 only) */
1338
#define PHY_M_MODE_MASK		0xf		/* Bit  3.. 0: copy of HWCFG MODE[3:0] */
1261
1339
1262
/*****  PHY_MARV_CABLE_DIAG	16 bit r/o	Cable Diagnostic Reg *****/
1340
/*****  PHY_MARV_CABLE_DIAG	16 bit r/o	Cable Diagnostic Reg *****/
1263
#define PHY_M_CABD_ENA_TEST	(1<<15)	/* Bit 15:	Enable Test */
1341
#define PHY_M_CABD_ENA_TEST	BIT_15S		/* Enable Test (Page 0) */
1264
#define PHY_M_CABD_STAT_MSK	(3<<13)	/* Bit 14..13:	Status */
1342
#define PHY_M_CABD_DIS_WAIT	BIT_15S		/* Disable Waiting Period (Page 1) */
1265
									/* Bit 12.. 8:	reserved */
1343
										/* (88E1111 only) */
1266
#define PHY_M_CABD_DIST_MSK	0xff	/* Bit  7.. 0:	Distance */
1344
#define PHY_M_CABD_STAT_MSK	(3<<13)		/* Bit 14..13: Status Mask */
1345
#define PHY_M_CABD_AMPL_MSK	(0x1f<<8)	/* Bit 12.. 8: Amplitude Mask */
1346
										/* (88E1111 only) */
1347
#define PHY_M_CABD_DIST_MSK	0xff		/* Bit  7.. 0: Distance Mask */
1267
1348
1268
/* values for Cable Diagnostic Status (11=fail; 00=OK; 10=open; 01=short) */
1349
/* values for Cable Diagnostic Status (11=fail; 00=OK; 10=open; 01=short) */
1269
#define CABD_STAT_NORMAL	0
1350
#define CABD_STAT_NORMAL	0
Lines 1271-1276 Link Here
1271
#define CABD_STAT_OPEN		2
1352
#define CABD_STAT_OPEN		2
1272
#define CABD_STAT_FAIL		3
1353
#define CABD_STAT_FAIL		3
1273
1354
1355
/* for 10/100 Fast Ethernet PHY (88E3082 only) */
1356
/*****  PHY_MARV_FE_LED_PAR		16 bit r/w	LED Parallel Select Reg. *****/
1357
									/* Bit 15..12: reserved (used internally) */
1358
#define PHY_M_FELP_LED2_MSK	(0xf<<8)	/* Bit 11.. 8: LED2 Mask (LINK) */
1359
#define PHY_M_FELP_LED1_MSK	(0xf<<4)	/* Bit  7.. 4: LED1 Mask (ACT) */
1360
#define PHY_M_FELP_LED0_MSK	0xf			/* Bit  3.. 0: LED0 Mask (SPEED) */
1361
1362
#define PHY_M_FELP_LED2_CTRL(x)	(SHIFT8(x) & PHY_M_FELP_LED2_MSK)
1363
#define PHY_M_FELP_LED1_CTRL(x)	(SHIFT4(x) & PHY_M_FELP_LED1_MSK)
1364
#define PHY_M_FELP_LED0_CTRL(x)	(SHIFT0(x) & PHY_M_FELP_LED0_MSK)
1365
1366
#define LED_PAR_CTRL_COLX	0x00
1367
#define LED_PAR_CTRL_ERROR	0x01
1368
#define LED_PAR_CTRL_DUPLEX	0x02
1369
#define LED_PAR_CTRL_DP_COL	0x03
1370
#define LED_PAR_CTRL_SPEED	0x04
1371
#define LED_PAR_CTRL_LINK	0x05
1372
#define LED_PAR_CTRL_TX		0x06
1373
#define LED_PAR_CTRL_RX		0x07
1374
#define LED_PAR_CTRL_ACT	0x08
1375
#define LED_PAR_CTRL_LNK_RX	0x09
1376
#define LED_PAR_CTRL_LNK_AC	0x0a
1377
#define LED_PAR_CTRL_ACT_BL	0x0b
1378
#define LED_PAR_CTRL_TX_BL	0x0c
1379
#define LED_PAR_CTRL_RX_BL	0x0d
1380
#define LED_PAR_CTRL_COL_BL	0x0e
1381
#define LED_PAR_CTRL_INACT	0x0f
1382
1383
/*****  PHY_MARV_FE_SPEC_2		16 bit r/w	Specific Control Reg. 2 *****/
1384
#define PHY_M_FESC_DIS_WAIT	BIT_2S		/* Disable TDR Waiting Period */
1385
#define PHY_M_FESC_ENA_MCLK	BIT_1S		/* Enable MAC Rx Clock in sleep mode */
1386
#define PHY_M_FESC_SEL_CL_A	BIT_0S		/* Select Class A driver (100B-TX) */
1387
1388
/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */
1389
/*****  PHY_MARV_PHY_CTRL (page 2)		16 bit r/w	MAC Specific Ctrl *****/
1390
#define PHY_M_MAC_MD_MSK	(7<<7)		/* Bit  9.. 7: Mode Select Mask */
1391
#define PHY_M_MAC_MD_AUTO		3	/* Auto Copper/1000Base-X */
1392
#define PHY_M_MAC_MD_COPPER		5	/* Copper only */
1393
#define PHY_M_MAC_MD_1000BX		7	/* 1000Base-X only */
1394
#define PHY_M_MAC_MODE_SEL(x)	(SHIFT7(x) & PHY_M_MAC_MD_MSK)
1395
1396
/*****  PHY_MARV_PHY_CTRL (page 3)		16 bit r/w	LED Control Reg. *****/
1397
#define PHY_M_LEDC_LOS_MSK	(0xf<<12)	/* Bit 15..12: LOS LED Ctrl. Mask */
1398
#define PHY_M_LEDC_INIT_MSK	(0xf<<8)	/* Bit 11.. 8: INIT LED Ctrl. Mask */
1399
#define PHY_M_LEDC_STA1_MSK	(0xf<<4)	/* Bit  7.. 4: STAT1 LED Ctrl. Mask */
1400
#define PHY_M_LEDC_STA0_MSK	0xf			/* Bit  3.. 0: STAT0 LED Ctrl. Mask */
1401
1402
#define PHY_M_LEDC_LOS_CTRL(x)	(SHIFT12(x) & PHY_M_LEDC_LOS_MSK)
1403
#define PHY_M_LEDC_INIT_CTRL(x)	(SHIFT8(x) & PHY_M_LEDC_INIT_MSK)
1404
#define PHY_M_LEDC_STA1_CTRL(x)	(SHIFT4(x) & PHY_M_LEDC_STA1_MSK)
1405
#define PHY_M_LEDC_STA0_CTRL(x)	(SHIFT0(x) & PHY_M_LEDC_STA0_MSK)
1406
1407
/*****  PHY_MARV_PHY_STAT (page 3)		16 bit r/w	Polarity Control Reg. *****/
1408
#define PHY_M_POLC_LS1M_MSK	(0xf<<12)	/* Bit 15..12: LOS,STAT1 Mix % Mask */
1409
#define PHY_M_POLC_IS0M_MSK	(0xf<<8)	/* Bit 11.. 8: INIT,STAT0 Mix % Mask */
1410
#define PHY_M_POLC_LOS_MSK	(0x3<<6)	/* Bit  7.. 6: LOS Pol. Ctrl. Mask */
1411
#define PHY_M_POLC_INIT_MSK	(0x3<<4)	/* Bit  5.. 4: INIT Pol. Ctrl. Mask */
1412
#define PHY_M_POLC_STA1_MSK	(0x3<<2)	/* Bit  3.. 2: STAT1 Pol. Ctrl. Mask */
1413
#define PHY_M_POLC_STA0_MSK	0x3			/* Bit  1.. 0: STAT0 Pol. Ctrl. Mask */
1414
1415
#define PHY_M_POLC_LS1_P_MIX(x)	(SHIFT12(x) & PHY_M_POLC_LS1M_MSK)
1416
#define PHY_M_POLC_IS0_P_MIX(x)	(SHIFT8(x) & PHY_M_POLC_IS0M_MSK)
1417
#define PHY_M_POLC_LOS_CTRL(x)	(SHIFT6(x) & PHY_M_POLC_LOS_MSK)
1418
#define PHY_M_POLC_INIT_CTRL(x)	(SHIFT4(x) & PHY_M_POLC_INIT_MSK)
1419
#define PHY_M_POLC_STA1_CTRL(x)	(SHIFT2(x) & PHY_M_POLC_STA1_MSK)
1420
#define PHY_M_POLC_STA0_CTRL(x)	(SHIFT0(x) & PHY_M_POLC_STA0_MSK)
1274
1421
1275
/*
1422
/*
1276
 * GMAC registers
1423
 * GMAC registers
Lines 1431-1571 Link Here
1431
 */
1578
 */
1432
1579
1433
/*	GM_GP_STAT	16 bit r/o	General Purpose Status Register */
1580
/*	GM_GP_STAT	16 bit r/o	General Purpose Status Register */
1434
#define GM_GPSR_SPEED		(1<<15) /* Bit 15:	Port Speed (1 = 100 Mbps) */
1581
#define GM_GPSR_SPEED		BIT_15S	/* Port Speed (1 = 100 Mbps) */
1435
#define GM_GPSR_DUPLEX		(1<<14) /* Bit 14:	Duplex Mode (1 = Full) */
1582
#define GM_GPSR_DUPLEX		BIT_14S	/* Duplex Mode (1 = Full) */
1436
#define GM_GPSR_FC_TX_DIS	(1<<13) /* Bit 13:	Tx Flow-Control Mode Disabled */
1583
#define GM_GPSR_FC_TX_DIS	BIT_13S	/* Tx Flow-Control Mode Disabled */
1437
#define GM_GPSR_LINK_UP		(1<<12)	/* Bit 12:	Link Up Status */
1584
#define GM_GPSR_LINK_UP		BIT_12S	/* Link Up Status */
1438
#define GM_GPSR_PAUSE		(1<<11)	/* Bit 11:	Pause State */
1585
#define GM_GPSR_PAUSE		BIT_11S	/* Pause State */
1439
#define GM_GPSR_TX_ACTIVE	(1<<10)	/* Bit 10:	Tx in Progress */
1586
#define GM_GPSR_TX_ACTIVE	BIT_10S	/* Tx in Progress */
1440
#define GM_GPSR_EXC_COL		(1<<9)	/* Bit  9:	Excessive Collisions Occured */
1587
#define GM_GPSR_EXC_COL		BIT_9S	/* Excessive Collisions Occured */
1441
#define GM_GPSR_LAT_COL		(1<<8)	/* Bit  8:	Late Collisions Occured */
1588
#define GM_GPSR_LAT_COL		BIT_8S	/* Late Collisions Occured */
1442
								/* Bit  7..6:	reserved */
1589
								/* Bit   7.. 6:	reserved */
1443
#define GM_GPSR_PHY_ST_CH	(1<<5)	/* Bit  5:	PHY Status Change */
1590
#define GM_GPSR_PHY_ST_CH	BIT_5S	/* PHY Status Change */
1444
#define GM_GPSR_GIG_SPEED	(1<<4)	/* Bit  4:	Gigabit Speed (1 = 1000 Mbps) */
1591
#define GM_GPSR_GIG_SPEED	BIT_4S	/* Gigabit Speed (1 = 1000 Mbps) */
1445
#define GM_GPSR_PART_MODE	(1<<3)	/* Bit  3:	Partition mode */
1592
#define GM_GPSR_PART_MODE	BIT_3S	/* Partition mode */
1446
#define GM_GPSR_FC_RX_DIS	(1<<2)	/* Bit  2:	Rx Flow-Control Mode Disabled */
1593
#define GM_GPSR_FC_RX_DIS	BIT_2S	/* Rx Flow-Control Mode Disabled */
1447
#define GM_GPSR_PROM_EN		(1<<1)	/* Bit  1:	Promiscuous Mode Enabled */
1594
								/* Bit   2.. 0:	reserved */
1448
								/* Bit  0:	reserved */
1595
1449
	
1450
/*	GM_GP_CTRL	16 bit r/w	General Purpose Control Register */
1596
/*	GM_GP_CTRL	16 bit r/w	General Purpose Control Register */
1451
								/* Bit 15:	reserved */
1597
#define GM_GPCR_RMII_PH_ENA	BIT_15S	/* Enable RMII for PHY (Yukon-FE only) */
1452
#define GM_GPCR_PROM_ENA	(1<<14)	/* Bit 14:	Enable Promiscuous Mode */
1598
#define GM_GPCR_RMII_LB_ENA	BIT_14S	/* Enable RMII Loopback (Yukon-FE only) */
1453
#define GM_GPCR_FC_TX_DIS	(1<<13) /* Bit 13:	Disable Tx Flow-Control Mode */
1599
#define GM_GPCR_FC_TX_DIS	BIT_13S	/* Disable Tx Flow-Control Mode */
1454
#define GM_GPCR_TX_ENA		(1<<12) /* Bit 12:	Enable Transmit */
1600
#define GM_GPCR_TX_ENA		BIT_12S	/* Enable Transmit */
1455
#define GM_GPCR_RX_ENA		(1<<11) /* Bit 11:	Enable Receive */
1601
#define GM_GPCR_RX_ENA		BIT_11S	/* Enable Receive */
1456
#define GM_GPCR_BURST_ENA	(1<<10)	/* Bit 10:	Enable Burst Mode */
1602
								/* Bit 10:	reserved */
1457
#define GM_GPCR_LOOP_ENA	(1<<9)	/* Bit  9:	Enable MAC Loopback Mode */
1603
#define GM_GPCR_LOOP_ENA	BIT_9S	/* Enable MAC Loopback Mode */
1458
#define GM_GPCR_PART_ENA	(1<<8)	/* Bit  8:	Enable Partition Mode */
1604
#define GM_GPCR_PART_ENA	BIT_8S	/* Enable Partition Mode */
1459
#define GM_GPCR_GIGS_ENA	(1<<7)	/* Bit  7:	Gigabit Speed (1000 Mbps) */
1605
#define GM_GPCR_GIGS_ENA	BIT_7S	/* Gigabit Speed (1000 Mbps) */
1460
#define GM_GPCR_FL_PASS		(1<<6)	/* Bit  6:	Force Link Pass */
1606
#define GM_GPCR_FL_PASS		BIT_6S	/* Force Link Pass */
1461
#define GM_GPCR_DUP_FULL	(1<<5)	/* Bit  5:	Full Duplex Mode */
1607
#define GM_GPCR_DUP_FULL	BIT_5S	/* Full Duplex Mode */
1462
#define GM_GPCR_FC_RX_DIS	(1<<4)	/* Bit  4:	Disable Rx Flow-Control Mode */
1608
#define GM_GPCR_FC_RX_DIS	BIT_4S	/* Disable Rx Flow-Control Mode */
1463
#define GM_GPCR_SPEED_100	(1<<3)  /* Bit  3:	Port Speed 100 Mbps */
1609
#define GM_GPCR_SPEED_100	BIT_3S	/* Port Speed 100 Mbps */
1464
#define GM_GPCR_AU_DUP_DIS	(1<<2)	/* Bit  2:	Disable Auto-Update Duplex */
1610
#define GM_GPCR_AU_DUP_DIS	BIT_2S	/* Disable Auto-Update Duplex */
1465
#define GM_GPCR_AU_FCT_DIS	(1<<1)	/* Bit  1:	Disable Auto-Update Flow-C. */
1611
#define GM_GPCR_AU_FCT_DIS	BIT_1S	/* Disable Auto-Update Flow-C. */
1466
#define GM_GPCR_AU_SPD_DIS	(1<<0)	/* Bit  0:	Disable Auto-Update Speed */
1612
#define GM_GPCR_AU_SPD_DIS	BIT_0S	/* Disable Auto-Update Speed */
1467
1613
1468
#define GM_GPCR_SPEED_1000	(GM_GPCR_GIGS_ENA | GM_GPCR_SPEED_100)
1614
#define GM_GPCR_SPEED_1000	(GM_GPCR_GIGS_ENA | GM_GPCR_SPEED_100)
1469
#define GM_GPCR_AU_ALL_DIS	(GM_GPCR_AU_DUP_DIS | GM_GPCR_AU_FCT_DIS |\
1615
#define GM_GPCR_AU_ALL_DIS	(GM_GPCR_AU_DUP_DIS | GM_GPCR_AU_FCT_DIS |\
1470
							 GM_GPCR_AU_SPD_DIS)
1616
							 GM_GPCR_AU_SPD_DIS)
1471
	
1617
1472
/*	GM_TX_CTRL				16 bit r/w	Transmit Control Register */
1618
/*	GM_TX_CTRL				16 bit r/w	Transmit Control Register */
1473
#define GM_TXCR_FORCE_JAM	(1<<15)	/* Bit 15:	Force Jam / Flow-Control */
1619
#define GM_TXCR_FORCE_JAM	BIT_15S	/* Force Jam / Flow-Control */
1474
#define GM_TXCR_CRC_DIS		(1<<14)	/* Bit 14:	Disable insertion of CRC */
1620
#define GM_TXCR_CRC_DIS		BIT_14S	/* Disable insertion of CRC */
1475
#define GM_TXCR_PAD_DIS		(1<<13)	/* Bit 13:	Disable padding of packets */
1621
#define GM_TXCR_PAD_DIS		BIT_13S	/* Disable padding of packets */
1476
#define GM_TXCR_COL_THR_MSK	(1<<10)	/* Bit 12..10:	Collision Threshold */
1622
#define GM_TXCR_COL_THR_MSK	(7<<10)	/* Bit 12..10: Collision Threshold Mask */
1623
								/* Bit   9.. 8:	reserved */
1624
#define GM_TXCR_PAD_PAT_MSK	0xff	/* Bit  7.. 0: Padding Pattern Mask */
1625
									/* (Yukon-2 only) */
1477
1626
1478
#define TX_COL_THR(x)		(SHIFT10(x) & GM_TXCR_COL_THR_MSK)
1627
#define TX_COL_THR(x)		(SHIFT10(x) & GM_TXCR_COL_THR_MSK)
1479
1628
1480
#define TX_COL_DEF			0x04
1629
#define TX_COL_DEF			0x04
1481
	
1630
1482
/*	GM_RX_CTRL				16 bit r/w	Receive Control Register */
1631
/*	GM_RX_CTRL				16 bit r/w	Receive Control Register */
1483
#define GM_RXCR_UCF_ENA		(1<<15)	/* Bit 15:	Enable Unicast filtering */
1632
#define GM_RXCR_UCF_ENA		BIT_15S	/* Enable Unicast filtering */
1484
#define GM_RXCR_MCF_ENA		(1<<14)	/* Bit 14:	Enable Multicast filtering */
1633
#define GM_RXCR_MCF_ENA		BIT_14S	/* Enable Multicast filtering */
1485
#define GM_RXCR_CRC_DIS		(1<<13)	/* Bit 13:	Remove 4-byte CRC */
1634
#define GM_RXCR_CRC_DIS		BIT_13S	/* Remove 4-byte CRC */
1486
#define GM_RXCR_PASS_FC		(1<<12)	/* Bit 12:	Pass FC packets to FIFO */
1635
#define GM_RXCR_PASS_FC		BIT_12S	/* Pass FC packets to FIFO (Yukon-1 only) */
1487
	
1636
								/* Bit  11.. 0:	reserved */
1637
1488
/*	GM_TX_PARAM				16 bit r/w	Transmit Parameter Register */
1638
/*	GM_TX_PARAM				16 bit r/w	Transmit Parameter Register */
1489
#define GM_TXPA_JAMLEN_MSK	(0x03<<14)	/* Bit 15..14:	Jam Length */
1639
#define GM_TXPA_JAMLEN_MSK	(3<<14)		/* Bit 15..14: Jam Length Mask */
1490
#define GM_TXPA_JAMIPG_MSK	(0x1f<<9)	/* Bit 13..9:	Jam IPG */
1640
#define GM_TXPA_JAMIPG_MSK	(0x1f<<9)	/* Bit 13.. 9: Jam IPG Mask */
1491
#define GM_TXPA_JAMDAT_MSK	(0x1f<<4)	/* Bit  8..4:	IPG Jam to Data */
1641
#define GM_TXPA_JAMDAT_MSK	(0x1f<<4)	/* Bit  8.. 4: IPG Jam to Data Mask */
1492
								/* Bit  3..0:	reserved */
1642
#define GM_TXPA_BO_LIM_MSK	0x0f		/* Bit  3.. 0: Backoff Limit Mask */
1643
										/* (Yukon-2 only) */
1493
1644
1494
#define TX_JAM_LEN_VAL(x)	(SHIFT14(x) & GM_TXPA_JAMLEN_MSK)
1645
#define TX_JAM_LEN_VAL(x)	(SHIFT14(x) & GM_TXPA_JAMLEN_MSK)
1495
#define TX_JAM_IPG_VAL(x)	(SHIFT9(x) & GM_TXPA_JAMIPG_MSK)
1646
#define TX_JAM_IPG_VAL(x)	(SHIFT9(x) & GM_TXPA_JAMIPG_MSK)
1496
#define TX_IPG_JAM_DATA(x)	(SHIFT4(x) & GM_TXPA_JAMDAT_MSK)
1647
#define TX_IPG_JAM_DATA(x)	(SHIFT4(x) & GM_TXPA_JAMDAT_MSK)
1648
#define TX_BACK_OFF_LIM(x)	((x) & GM_TXPA_BO_LIM_MSK)
1497
1649
1498
#define TX_JAM_LEN_DEF		0x03
1650
#define TX_JAM_LEN_DEF		0x03
1499
#define TX_JAM_IPG_DEF		0x0b
1651
#define TX_JAM_IPG_DEF		0x0b
1500
#define TX_IPG_JAM_DEF		0x1c
1652
#define TX_IPG_JAM_DEF		0x1c
1653
#define TX_BOF_LIM_DEF		0x04
1501
1654
1502
/*	GM_SERIAL_MODE			16 bit r/w	Serial Mode Register */
1655
/*	GM_SERIAL_MODE			16 bit r/w	Serial Mode Register */
1503
#define GM_SMOD_DATABL_MSK	(0x1f<<11)	/* Bit 15..11:	Data Blinder (r/o) */
1656
#define GM_SMOD_DATABL_MSK	(0x1f<<11)	/* Bit 15..11:	Data Blinder */
1504
#define GM_SMOD_LIMIT_4		(1<<10)	/* Bit 10:	4 consecutive Tx trials */
1657
										/* r/o on Yukon, r/w on Yukon-EC */
1505
#define GM_SMOD_VLAN_ENA	(1<<9)	/* Bit  9:	Enable VLAN  (Max. Frame Len) */
1658
#define GM_SMOD_LIMIT_4		BIT_10S	/* 4 consecutive Tx trials */
1506
#define GM_SMOD_JUMBO_ENA	(1<<8)	/* Bit  8:	Enable Jumbo (Max. Frame Len) */
1659
#define GM_SMOD_VLAN_ENA	BIT_9S	/* Enable VLAN  (Max. Frame Len) */
1507
								/* Bit  7..5:	reserved */
1660
#define GM_SMOD_JUMBO_ENA	BIT_8S	/* Enable Jumbo (Max. Frame Len) */
1508
#define GM_SMOD_IPG_MSK		0x1f	/* Bit 4..0:	Inter-Packet Gap (IPG) */
1661
								/* Bit   7.. 5:	reserved */
1509
	
1662
#define GM_SMOD_IPG_MSK		0x1f	/* Bit  4.. 0:	Inter-Packet Gap (IPG) */
1663
1510
#define DATA_BLIND_VAL(x)	(SHIFT11(x) & GM_SMOD_DATABL_MSK)
1664
#define DATA_BLIND_VAL(x)	(SHIFT11(x) & GM_SMOD_DATABL_MSK)
1511
#define DATA_BLIND_DEF		0x04
1665
#define IPG_DATA_VAL(x)		((x) & GM_SMOD_IPG_MSK)
1512
1666
1513
#define IPG_DATA_VAL(x)		(x & GM_SMOD_IPG_MSK)
1667
#define DATA_BLIND_DEF		0x04
1514
#define IPG_DATA_DEF		0x1e
1668
#define IPG_DATA_DEF		0x1e
1515
1669
1516
/*	GM_SMI_CTRL				16 bit r/w	SMI Control Register */
1670
/*	GM_SMI_CTRL				16 bit r/w	SMI Control Register */
1517
#define GM_SMI_CT_PHY_A_MSK	(0x1f<<11)	/* Bit 15..11:	PHY Device Address */
1671
#define GM_SMI_CT_PHY_A_MSK	(0x1f<<11)	/* Bit 15..11:	PHY Device Address */
1518
#define GM_SMI_CT_REG_A_MSK	(0x1f<<6)	/* Bit 10.. 6:	PHY Register Address */
1672
#define GM_SMI_CT_REG_A_MSK	(0x1f<<6)	/* Bit 10.. 6:	PHY Register Address */
1519
#define GM_SMI_CT_OP_RD		(1<<5)	/* Bit  5:	OpCode Read (0=Write)*/
1673
#define GM_SMI_CT_OP_RD		BIT_5S	/* OpCode Read (0=Write)*/
1520
#define GM_SMI_CT_RD_VAL	(1<<4)	/* Bit  4:	Read Valid (Read completed) */
1674
#define GM_SMI_CT_RD_VAL	BIT_4S	/* Read Valid (Read completed) */
1521
#define GM_SMI_CT_BUSY		(1<<3)	/* Bit  3:	Busy (Operation in progress) */
1675
#define GM_SMI_CT_BUSY		BIT_3S	/* Busy (Operation in progress) */
1522
								/* Bit   2..0:	reserved */
1676
								/* Bit   2.. 0:	reserved */
1523
	
1677
1524
#define GM_SMI_CT_PHY_AD(x)	(SHIFT11(x) & GM_SMI_CT_PHY_A_MSK)
1678
#define GM_SMI_CT_PHY_AD(x)	(SHIFT11(x) & GM_SMI_CT_PHY_A_MSK)
1525
#define GM_SMI_CT_REG_AD(x)	(SHIFT6(x) & GM_SMI_CT_REG_A_MSK)
1679
#define GM_SMI_CT_REG_AD(x)	(SHIFT6(x) & GM_SMI_CT_REG_A_MSK)
1526
1680
1527
	/*	GM_PHY_ADDR				16 bit r/w	GPHY Address Register */
1681
	/*	GM_PHY_ADDR				16 bit r/w	GPHY Address Register */
1528
								/* Bit  15..6:	reserved */
1682
								/* Bit  15.. 6:	reserved */
1529
#define GM_PAR_MIB_CLR		(1<<5)	/* Bit  5:	Set MIB Clear Counter Mode */
1683
#define GM_PAR_MIB_CLR		BIT_5S	/* Set MIB Clear Counter Mode */
1530
#define GM_PAR_MIB_TST		(1<<4)	/* Bit  4:	MIB Load Counter (Test Mode) */
1684
#define GM_PAR_MIB_TST		BIT_4S	/* MIB Load Counter (Test Mode) */
1531
								/* Bit   3..0:	reserved */
1685
								/* Bit   3.. 0:	reserved */
1532
	
1686
1533
/* Receive Frame Status Encoding */
1687
/* Receive Frame Status Encoding */
1534
#define GMR_FS_LEN	(0xffffUL<<16)	/* Bit 31..16:	Rx Frame Length */
1688
#define GMR_FS_LEN_MSK	(0xffffUL<<16)	/* Bit 31..16:	Rx Frame Length */
1535
								/* Bit  15..14:	reserved */
1689
								/* Bit  15..14:	reserved */
1536
#define GMR_FS_VLAN		(1L<<13)	/* Bit 13:	VLAN Packet */
1690
#define GMR_FS_VLAN			BIT_13	/* VLAN Packet */
1537
#define GMR_FS_JABBER	(1L<<12)	/* Bit 12:	Jabber Packet */
1691
#define GMR_FS_JABBER		BIT_12	/* Jabber Packet */
1538
#define GMR_FS_UN_SIZE	(1L<<11)	/* Bit 11:	Undersize Packet */
1692
#define GMR_FS_UN_SIZE		BIT_11	/* Undersize Packet */
1539
#define GMR_FS_MC		(1L<<10)	/* Bit 10:	Multicast Packet */
1693
#define GMR_FS_MC			BIT_10	/* Multicast Packet */
1540
#define GMR_FS_BC		(1L<<9)		/* Bit  9:	Broadcast Packet */
1694
#define GMR_FS_BC			BIT_9	/* Broadcast Packet */
1541
#define GMR_FS_RX_OK	(1L<<8)		/* Bit  8:	Receive OK (Good Packet) */
1695
#define GMR_FS_RX_OK		BIT_8	/* Receive OK (Good Packet) */
1542
#define GMR_FS_GOOD_FC	(1L<<7)		/* Bit  7:	Good Flow-Control Packet */
1696
#define GMR_FS_GOOD_FC		BIT_7	/* Good Flow-Control Packet */
1543
#define GMR_FS_BAD_FC	(1L<<6)		/* Bit  6:	Bad  Flow-Control Packet */
1697
#define GMR_FS_BAD_FC		BIT_6	/* Bad  Flow-Control Packet */
1544
#define GMR_FS_MII_ERR	(1L<<5)		/* Bit  5:	MII Error */
1698
#define GMR_FS_MII_ERR		BIT_5	/* MII Error */
1545
#define GMR_FS_LONG_ERR	(1L<<4)		/* Bit  4:	Too Long Packet */
1699
#define GMR_FS_LONG_ERR		BIT_4	/* Too Long Packet */
1546
#define GMR_FS_FRAGMENT	(1L<<3)		/* Bit  3:	Fragment */
1700
#define GMR_FS_FRAGMENT		BIT_3	/* Fragment */
1547
								/* Bit  2:	reserved */
1701
								/* Bit  2:	reserved */
1548
#define GMR_FS_CRC_ERR	(1L<<1)		/* Bit  1:	CRC Error */
1702
#define GMR_FS_CRC_ERR		BIT_1	/* CRC Error */
1549
#define GMR_FS_RX_FF_OV	(1L<<0)		/* Bit  0:	Rx FIFO Overflow */
1703
#define GMR_FS_RX_FF_OV		BIT_0	/* Rx FIFO Overflow */
1704
1705
#define GMR_FS_LEN_SHIFT	16
1550
1706
1551
/*
1707
/*
1552
 * GMR_FS_ANY_ERR (analogous to XMR_FS_ANY_ERR)
1708
 * GMR_FS_ANY_ERR (analogous to XMR_FS_ANY_ERR)
1553
 */
1709
 */
1554
#define GMR_FS_ANY_ERR	(GMR_FS_CRC_ERR | \
1710
#ifdef SK_DIAG
1555
			GMR_FS_LONG_ERR | \
1711
#define GMR_FS_ANY_ERR		( \
1712
			GMR_FS_RX_FF_OV | \
1713
			GMR_FS_CRC_ERR | \
1714
			GMR_FS_FRAGMENT | \
1556
			GMR_FS_MII_ERR | \
1715
			GMR_FS_MII_ERR | \
1557
			GMR_FS_BAD_FC | \
1716
			GMR_FS_BAD_FC | \
1558
			GMR_FS_GOOD_FC | \
1717
			GMR_FS_GOOD_FC | \
1559
			GMR_FS_JABBER)
1718
			GMR_FS_JABBER)
1560
1719
#else
1561
/* Rx GMAC FIFO Flush Mask (default) */
1720
#define GMR_FS_ANY_ERR		( \
1562
#define RX_FF_FL_DEF_MSK	(GMR_FS_CRC_ERR | \
1563
			GMR_FS_RX_FF_OV | \
1721
			GMR_FS_RX_FF_OV | \
1722
			GMR_FS_CRC_ERR | \
1723
			GMR_FS_FRAGMENT | \
1724
			GMR_FS_LONG_ERR | \
1564
			GMR_FS_MII_ERR | \
1725
			GMR_FS_MII_ERR | \
1565
			GMR_FS_BAD_FC | \
1726
			GMR_FS_BAD_FC | \
1566
			GMR_FS_GOOD_FC | \
1727
			GMR_FS_GOOD_FC | \
1567
			GMR_FS_UN_SIZE | \
1728
			GMR_FS_UN_SIZE | \
1568
			GMR_FS_JABBER)
1729
			GMR_FS_JABBER)
1730
#endif
1731
1732
/* Rx GMAC FIFO Flush Mask (default) */
1733
#define RX_FF_FL_DEF_MSK	GMR_FS_ANY_ERR
1569
1734
1570
/* typedefs *******************************************************************/
1735
/* typedefs *******************************************************************/
1571
1736
(-)linux/drivers/net/sk98lin/Makefile (-7 / +57 lines)
Lines 1-6 Link Here
1
#******************************************************************************
1
#
2
#
2
# Makefile for the SysKonnect SK-98xx device driver.
3
# Name:         skge.c
4
# Project:      GEnesis, PCI Gigabit Ethernet Adapter
5
# Version:      $Revision: 1.9 $
6
# Date:         $Date: 2004/07/13 15:54:50 $
7
# Purpose:      The main driver source module
3
#
8
#
9
#******************************************************************************
10
11
#******************************************************************************
12
#
13
#	(C)Copyright 1998-2002 SysKonnect GmbH.
14
#	(C)Copyright 2002-2004 Marvell.
15
#
16
#	Makefile for Marvell Yukon chipset and SysKonnect Gigabit Ethernet 
17
#	Server Adapter driver. (Kernel 2.6)
18
#
19
#	Author: Mirko Lindner (mlindner@syskonnect.de)
20
#		Ralph Roesler (rroesler@syskonnect.de)
21
#
22
#	Address all question to: linux@syskonnect.de
23
#
24
#	This program is free software; you can redistribute it and/or modify
25
#	it under the terms of the GNU General Public License as published by
26
#	the Free Software Foundation; either version 2 of the License, or
27
#	(at your option) any later version.
28
#
29
#	The information in this file is provided "AS IS" without warranty.
30
# 
31
#******************************************************************************
32
33
#******************************************************************************
34
#
35
# History:
36
#
37
#	$Log: Makefile2.6,v $
38
#	Revision 1.9  2004/07/13 15:54:50  rroesler
39
#	Add: file skethtool.c
40
#	Fix: corrected header regarding copyright
41
#	Fix: minor typos corrected
42
#	
43
#	Revision 1.8  2004/06/08 08:39:38  mlindner
44
#	Fix: Add CONFIG_SK98LIN_ZEROCOPY as default
45
#	
46
#	Revision 1.7  2004/06/03 16:06:56  mlindner
47
#	Fix: Added compile flag SK_DIAG_SUPPORT
48
#	
49
#	Revision 1.6  2004/06/02 08:02:59  mlindner
50
#	Add: Changed header information and inserted a GPL statement
51
#	
52
#
53
#******************************************************************************
4
54
5
55
6
#
56
#
Lines 13-26 Link Here
13
obj-$(CONFIG_SK98LIN) += sk98lin.o
63
obj-$(CONFIG_SK98LIN) += sk98lin.o
14
sk98lin-objs    :=	\
64
sk98lin-objs    :=	\
15
		skge.o		\
65
		skge.o		\
66
		sky2.o		\
16
		skethtool.o	\
67
		skethtool.o	\
68
		sky2le.o	\
17
		skdim.o		\
69
		skdim.o		\
18
		skaddr.o	\
70
		skaddr.o	\
19
		skgehwt.o	\
71
		skgehwt.o	\
20
		skgeinit.o	\
72
		skgeinit.o	\
21
		skgepnmi.o	\
73
		skgepnmi.o	\
22
		skgesirq.o	\
74
		skgesirq.o	\
23
		ski2c.o		\
75
		sktwsi.o		\
24
		sklm80.o	\
76
		sklm80.o	\
25
		skqueue.o	\
77
		skqueue.o	\
26
		skrlmt.o	\
78
		skrlmt.o	\
Lines 77-89 Link Here
77
# SK_DBGCAT_DRV_INT_SRC         0x04000000      interrupts sources
129
# SK_DBGCAT_DRV_INT_SRC         0x04000000      interrupts sources
78
# SK_DBGCAT_DRV_EVENT           0x08000000      driver events
130
# SK_DBGCAT_DRV_EVENT           0x08000000      driver events
79
131
80
EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DSK_USE_CSUM -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM)
132
EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_USE_CSUM -DSK_DIAG_SUPPORT \
133
		-DGENESIS -DYUKON -DYUK2 -DCONFIG_SK98LIN_ZEROCOPY \
134
		$(DBGDEF) $(SKPARAM)
81
135
82
clean:
136
clean:
83
	rm -f core *.o *.a *.s
137
	rm -f core *.o *.a *.s
84
138
85
139
86
87
88
89
(-)linux/drivers/net/sk98lin/sk98lin.mod.c (-101 lines)
Lines 1-101 Link Here
1
#include <linux/module.h>
2
#include <linux/vermagic.h>
3
#include <linux/compiler.h>
4
5
MODULE_INFO(vermagic, VERMAGIC_STRING);
6
7
#undef unix
8
struct module __this_module
9
__attribute__((section(".gnu.linkonce.this_module"))) = {
10
 .name = __stringify(KBUILD_MODNAME),
11
 .init = init_module,
12
#ifdef CONFIG_MODULE_UNLOAD
13
 .exit = cleanup_module,
14
#endif
15
};
16
17
static const struct modversion_info ____versions[]
18
__attribute_used__
19
__attribute__((section("__versions"))) = {
20
	{ 0xb15dd091, "struct_module" },
21
	{ 0xa30b0209, "pci_bus_read_config_byte" },
22
	{ 0x7da8156e, "__kmalloc" },
23
	{ 0xee653e63, "__kfree_skb" },
24
	{ 0x7689ace9, "mem_map" },
25
	{ 0x2e12d205, "single_open" },
26
	{ 0x89b301d4, "param_get_int" },
27
	{ 0xc5e33b65, "alloc_etherdev" },
28
	{ 0xf8012df3, "skb_pad" },
29
	{ 0xbf5cb6c2, "smp_processor_id" },
30
	{ 0xbfe97ce1, "single_release" },
31
	{ 0xf9860532, "malloc_sizes" },
32
	{ 0xdfc1663a, "pci_disable_device" },
33
	{ 0x5e2bc61b, "_spin_lock" },
34
	{ 0x806d5133, "param_array_get" },
35
	{ 0x894cb9ee, "seq_printf" },
36
	{ 0x778dda45, "remove_proc_entry" },
37
	{ 0xac030a77, "pci_release_regions" },
38
	{ 0xd8c152cd, "raise_softirq_irqoff" },
39
	{ 0x2d3cf335, "pci_bus_write_config_word" },
40
	{ 0x98bd6f46, "param_set_int" },
41
	{ 0xd10196f6, "_spin_lock_irqsave" },
42
	{ 0x1d26aa98, "sprintf" },
43
	{ 0x89cef6fb, "param_array_set" },
44
	{ 0x489913d6, "seq_read" },
45
	{ 0x7d11c268, "jiffies" },
46
	{ 0x3cfe13fd, "netif_rx" },
47
	{ 0xaa136450, "param_get_charp" },
48
	{ 0xc295091b, "pci_set_master" },
49
	{ 0x6dc41d27, "del_timer_sync" },
50
	{ 0xa9319775, "proc_mkdir" },
51
	{ 0x6458c8ff, "pci_set_dma_mask" },
52
	{ 0xa4f9d734, "proc_net" },
53
	{ 0x1b7d4074, "printk" },
54
	{ 0x85425f4f, "alloc_skb" },
55
	{ 0x7f73ea64, "free_netdev" },
56
	{ 0x2f287f0d, "copy_to_user" },
57
	{ 0x42dc210b, "register_netdev" },
58
	{ 0x488f5945, "dma_free_coherent" },
59
	{ 0x73e20c1c, "strlcpy" },
60
	{ 0xa88536e6, "pci_bus_write_config_dword" },
61
	{ 0xc86fb40a, "_spin_unlock_irqrestore" },
62
	{ 0x6303e385, "mod_timer" },
63
	{ 0xce99d017, "_spin_unlock" },
64
	{ 0x2184b4dd, "dma_alloc_coherent" },
65
	{ 0x8df9f666, "cpu_online_map" },
66
	{ 0xc4f84eb3, "skb_over_panic" },
67
	{ 0x818f318b, "kmem_cache_alloc" },
68
	{ 0x3762cb6e, "ioremap_nocache" },
69
	{ 0xfa8921c7, "pci_bus_read_config_word" },
70
	{ 0xf6501f42, "pci_bus_read_config_dword" },
71
	{ 0x26e96637, "request_irq" },
72
	{ 0x17d59d01, "schedule_timeout" },
73
	{ 0xe79e2be3, "eth_type_trans" },
74
	{ 0x58ab7f41, "create_proc_entry" },
75
	{ 0x605ba4ec, "pci_unregister_driver" },
76
	{ 0xcc5005fe, "msleep_interruptible" },
77
	{ 0x7ecb001b, "__per_cpu_offset" },
78
	{ 0x2cd7da6c, "param_set_charp" },
79
	{ 0x72270e35, "do_gettimeofday" },
80
	{ 0xd1fc6eb5, "pci_bus_write_config_byte" },
81
	{ 0xb9c9a49e, "seq_lseek" },
82
	{ 0x37a0cba, "kfree" },
83
	{ 0x2e60bace, "memcpy" },
84
	{ 0xbc2aef89, "pci_request_regions" },
85
	{ 0xedc03953, "iounmap" },
86
	{ 0x4cbbd171, "__bitmap_weight" },
87
	{ 0x1e43fd7b, "unregister_netdev" },
88
	{ 0x25da070, "snprintf" },
89
	{ 0x9a3de8f8, "csum_partial" },
90
	{ 0x30e20aa1, "pci_enable_device" },
91
	{ 0xd6c963c, "copy_from_user" },
92
	{ 0xf20dabd8, "free_irq" },
93
	{ 0xf2b42a9a, "pci_register_driver" },
94
	{ 0xb091969c, "per_cpu__softnet_data" },
95
};
96
97
static const char __module_depends[]
98
__attribute_used__
99
__attribute__((section(".modinfo"))) =
100
"depends=";
101
(-)linux/drivers/net/sk98lin/skaddr.c (-34 / +45 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skaddr.c
3
 * Name:	skaddr.c
4
 * Project:	Gigabit Ethernet Adapters, ADDR-Module
4
 * Project:	Gigabit Ethernet Adapters, ADDR-Module
5
 * Version:	$Revision: 1.52 $
5
 * Version:	$Revision: 2.4 $
6
 * Date:	$Date: 2003/06/02 13:46:15 $
6
 * Date:	$Date: 2004/11/12 14:03:54 $
7
 * Purpose:	Manage Addresses (Multicast and Unicast) and Promiscuous Mode.
7
 * Purpose:	Manage Addresses (Multicast and Unicast) and Promiscuous Mode.
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 44-50 Link Here
44
44
45
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
45
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
46
static const char SysKonnectFileId[] =
46
static const char SysKonnectFileId[] =
47
	"@(#) $Id: skaddr.c,v 1.52 2003/06/02 13:46:15 tschilli Exp $ (C) Marvell.";
47
	"@(#) $Id: skaddr.c,v 2.4 2004/11/12 14:03:54 mkunz Exp $ (C) Marvell.";
48
#endif /* DEBUG ||!LINT || !SK_SLIM */
48
#endif /* DEBUG ||!LINT || !SK_SLIM */
49
49
50
#define __SKADDR_C
50
#define __SKADDR_C
Lines 79-85 Link Here
79
79
80
/* 64-bit hash values with all bits set. */
80
/* 64-bit hash values with all bits set. */
81
81
82
static const SK_U16	OnesHash[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
82
SK_U16	OnesHash[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
83
83
84
/* local variables ************************************************************/
84
/* local variables ************************************************************/
85
85
Lines 191-201 Link Here
191
		pAC->Addr.Port[pAC->Addr.Net[0].ActivePort].Exact[0] =
191
		pAC->Addr.Port[pAC->Addr.Net[0].ActivePort].Exact[0] =
192
			pAC->Addr.Net[0].CurrentMacAddress;
192
			pAC->Addr.Net[0].CurrentMacAddress;
193
#if SK_MAX_NETS > 1
193
#if SK_MAX_NETS > 1
194
		/* Set logical MAC address for net 2 to (log | 3). */
194
		/* Set logical MAC address for net 2 to. */
195
		if (!pAC->Addr.Net[1].CurrentMacAddressSet) {
195
		if (!pAC->Addr.Net[1].CurrentMacAddressSet) {
196
			pAC->Addr.Net[1].PermanentMacAddress =
196
			pAC->Addr.Net[1].PermanentMacAddress =
197
				pAC->Addr.Net[0].PermanentMacAddress;
197
				pAC->Addr.Net[0].PermanentMacAddress;
198
			pAC->Addr.Net[1].PermanentMacAddress.a[5] |= 3;
198
			pAC->Addr.Net[1].PermanentMacAddress.a[5] += 1;
199
			/* Set the current logical MAC address to the permanent one. */
199
			/* Set the current logical MAC address to the permanent one. */
200
			pAC->Addr.Net[1].CurrentMacAddress =
200
			pAC->Addr.Net[1].CurrentMacAddress =
201
				pAC->Addr.Net[1].PermanentMacAddress;
201
				pAC->Addr.Net[1].PermanentMacAddress;
Lines 213-219 Link Here
213
					pAC->Addr.Net[i].PermanentMacAddress.a[2],
213
					pAC->Addr.Net[i].PermanentMacAddress.a[2],
214
					pAC->Addr.Net[i].PermanentMacAddress.a[3],
214
					pAC->Addr.Net[i].PermanentMacAddress.a[3],
215
					pAC->Addr.Net[i].PermanentMacAddress.a[4],
215
					pAC->Addr.Net[i].PermanentMacAddress.a[4],
216
					pAC->Addr.Net[i].PermanentMacAddress.a[5]))
216
					pAC->Addr.Net[i].PermanentMacAddress.a[5]));
217
			
217
			
218
			SK_DBG_MSG(pAC, SK_DBGMOD_ADDR, SK_DBGCAT_INIT,
218
			SK_DBG_MSG(pAC, SK_DBGMOD_ADDR, SK_DBGCAT_INIT,
219
				("Logical MAC Address (Net%d): %02X %02X %02X %02X %02X %02X\n",
219
				("Logical MAC Address (Net%d): %02X %02X %02X %02X %02X %02X\n",
Lines 223-229 Link Here
223
					pAC->Addr.Net[i].CurrentMacAddress.a[2],
223
					pAC->Addr.Net[i].CurrentMacAddress.a[2],
224
					pAC->Addr.Net[i].CurrentMacAddress.a[3],
224
					pAC->Addr.Net[i].CurrentMacAddress.a[3],
225
					pAC->Addr.Net[i].CurrentMacAddress.a[4],
225
					pAC->Addr.Net[i].CurrentMacAddress.a[4],
226
					pAC->Addr.Net[i].CurrentMacAddress.a[5]))
226
					pAC->Addr.Net[i].CurrentMacAddress.a[5]));
227
		}
227
		}
228
#endif	/* DEBUG */
228
#endif	/* DEBUG */
229
229
Lines 266-272 Link Here
266
					pAPort->PermanentMacAddress.a[2],
266
					pAPort->PermanentMacAddress.a[2],
267
					pAPort->PermanentMacAddress.a[3],
267
					pAPort->PermanentMacAddress.a[3],
268
					pAPort->PermanentMacAddress.a[4],
268
					pAPort->PermanentMacAddress.a[4],
269
					pAPort->PermanentMacAddress.a[5]))
269
					pAPort->PermanentMacAddress.a[5]));
270
			
270
			
271
			SK_DBG_MSG(pAC, SK_DBGMOD_ADDR, SK_DBGCAT_INIT,
271
			SK_DBG_MSG(pAC, SK_DBGMOD_ADDR, SK_DBGCAT_INIT,
272
				("SkAddrInit: Physical MAC Address: %02X %02X %02X %02X %02X %02X\n",
272
				("SkAddrInit: Physical MAC Address: %02X %02X %02X %02X %02X %02X\n",
Lines 275-281 Link Here
275
					pAPort->CurrentMacAddress.a[2],
275
					pAPort->CurrentMacAddress.a[2],
276
					pAPort->CurrentMacAddress.a[3],
276
					pAPort->CurrentMacAddress.a[3],
277
					pAPort->CurrentMacAddress.a[4],
277
					pAPort->CurrentMacAddress.a[4],
278
					pAPort->CurrentMacAddress.a[5]))
278
					pAPort->CurrentMacAddress.a[5]));
279
#endif /* DEBUG */
279
#endif /* DEBUG */
280
		}
280
		}
281
		/* pAC->Addr.InitDone = SK_INIT_IO; */
281
		/* pAC->Addr.InitDone = SK_INIT_IO; */
Lines 339-348 Link Here
339
	}
339
	}
340
	
340
	
341
	if (pAC->GIni.GIGenesis) {
341
	if (pAC->GIni.GIGenesis) {
342
#ifdef GENESIS
342
		ReturnCode = SkAddrXmacMcClear(pAC, IoC, PortNumber, Flags);
343
		ReturnCode = SkAddrXmacMcClear(pAC, IoC, PortNumber, Flags);
344
#endif
343
	}
345
	}
344
	else {
346
	else {
347
#ifdef YUKON
345
		ReturnCode = SkAddrGmacMcClear(pAC, IoC, PortNumber, Flags);
348
		ReturnCode = SkAddrGmacMcClear(pAC, IoC, PortNumber, Flags);
349
#endif
346
	}
350
	}
347
351
348
	return (ReturnCode);
352
	return (ReturnCode);
Lines 352-358 Link Here
352
#endif /* !SK_SLIM */
356
#endif /* !SK_SLIM */
353
357
354
#ifndef SK_SLIM
358
#ifndef SK_SLIM
355
359
#ifdef GENESIS
356
/******************************************************************************
360
/******************************************************************************
357
 *
361
 *
358
 *	SkAddrXmacMcClear - clear the multicast table
362
 *	SkAddrXmacMcClear - clear the multicast table
Lines 404-414 Link Here
404
	return (SK_ADDR_SUCCESS);
408
	return (SK_ADDR_SUCCESS);
405
	
409
	
406
}	/* SkAddrXmacMcClear */
410
}	/* SkAddrXmacMcClear */
407
411
#endif	/* GENESIS */
408
#endif /* !SK_SLIM */
412
#endif /* !SK_SLIM */
409
413
410
#ifndef SK_SLIM
414
#ifndef SK_SLIM
411
415
#ifdef YUKON
412
/******************************************************************************
416
/******************************************************************************
413
 *
417
 *
414
 *	SkAddrGmacMcClear - clear the multicast table
418
 *	SkAddrGmacMcClear - clear the multicast table
Lines 447-453 Link Here
447
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[4],
451
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[4],
448
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[5],
452
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[5],
449
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[6],
453
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[6],
450
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[7]))
454
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[7]));
451
#endif	/* DEBUG */
455
#endif	/* DEBUG */
452
456
453
	/* Clear InexactFilter */
457
	/* Clear InexactFilter */
Lines 489-495 Link Here
489
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[4],
493
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[4],
490
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[5],
494
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[5],
491
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[6],
495
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[6],
492
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[7]))
496
			pAC->Addr.Port[PortNumber].InexactFilter.Bytes[7]));
493
#endif	/* DEBUG */
497
#endif	/* DEBUG */
494
	
498
	
495
	if (!(Flags & SK_MC_SW_ONLY)) {
499
	if (!(Flags & SK_MC_SW_ONLY)) {
Lines 499-507 Link Here
499
	return (SK_ADDR_SUCCESS);
503
	return (SK_ADDR_SUCCESS);
500
504
501
}	/* SkAddrGmacMcClear */
505
}	/* SkAddrGmacMcClear */
506
#endif	/* YUKON */
502
507
503
#ifndef SK_ADDR_CHEAT
508
#ifndef SK_ADDR_CHEAT
504
509
#ifdef GENESIS
505
/******************************************************************************
510
/******************************************************************************
506
 *
511
 *
507
 *	SkXmacMcHash - hash multicast address
512
 *	SkXmacMcHash - hash multicast address
Lines 538-545 Link Here
538
	return (Crc & ((1 << HASH_BITS) - 1));
543
	return (Crc & ((1 << HASH_BITS) - 1));
539
544
540
}	/* SkXmacMcHash */
545
}	/* SkXmacMcHash */
546
#endif	/* GENESIS */
541
547
542
548
#ifdef YUKON
543
/******************************************************************************
549
/******************************************************************************
544
 *
550
 *
545
 *	SkGmacMcHash - hash multicast address
551
 *	SkGmacMcHash - hash multicast address
Lines 597-603 Link Here
597
	return (Crc & ((1 << HASH_BITS) - 1));
603
	return (Crc & ((1 << HASH_BITS) - 1));
598
604
599
}	/* SkGmacMcHash */
605
}	/* SkGmacMcHash */
600
606
#endif	/* YUKON */
601
#endif	/* !SK_ADDR_CHEAT */
607
#endif	/* !SK_ADDR_CHEAT */
602
608
603
/******************************************************************************
609
/******************************************************************************
Lines 638-654 Link Here
638
	}
644
	}
639
	
645
	
640
	if (pAC->GIni.GIGenesis) {
646
	if (pAC->GIni.GIGenesis) {
647
#ifdef GENESIS
641
		ReturnCode = SkAddrXmacMcAdd(pAC, IoC, PortNumber, pMc, Flags);
648
		ReturnCode = SkAddrXmacMcAdd(pAC, IoC, PortNumber, pMc, Flags);
649
#endif
642
	}
650
	}
643
	else {
651
	else {
652
#ifdef YUKON
644
		ReturnCode = SkAddrGmacMcAdd(pAC, IoC, PortNumber, pMc, Flags);
653
		ReturnCode = SkAddrGmacMcAdd(pAC, IoC, PortNumber, pMc, Flags);
654
#endif
645
	}
655
	}
646
656
647
	return (ReturnCode);
657
	return (ReturnCode);
648
658
649
}	/* SkAddrMcAdd */
659
}	/* SkAddrMcAdd */
650
660
651
661
#ifdef GENESIS
652
/******************************************************************************
662
/******************************************************************************
653
 *
663
 *
654
 *	SkAddrXmacMcAdd - add a multicast address to a port
664
 *	SkAddrXmacMcAdd - add a multicast address to a port
Lines 758-765 Link Here
758
	}
768
	}
759
769
760
}	/* SkAddrXmacMcAdd */
770
}	/* SkAddrXmacMcAdd */
771
#endif	/* GENESIS */
761
772
762
773
#ifdef YUKON
763
/******************************************************************************
774
/******************************************************************************
764
 *
775
 *
765
 *	SkAddrGmacMcAdd - add a multicast address to a port
776
 *	SkAddrGmacMcAdd - add a multicast address to a port
Lines 821-827 Link Here
821
			pAC->Addr.Port[PortNumber].InexactRlmtFilter.Bytes[4],
832
			pAC->Addr.Port[PortNumber].InexactRlmtFilter.Bytes[4],
822
			pAC->Addr.Port[PortNumber].InexactRlmtFilter.Bytes[5],
833
			pAC->Addr.Port[PortNumber].InexactRlmtFilter.Bytes[5],
823
			pAC->Addr.Port[PortNumber].InexactRlmtFilter.Bytes[6],
834
			pAC->Addr.Port[PortNumber].InexactRlmtFilter.Bytes[6],
824
			pAC->Addr.Port[PortNumber].InexactRlmtFilter.Bytes[7]))
835
			pAC->Addr.Port[PortNumber].InexactRlmtFilter.Bytes[7]));
825
#endif	/* DEBUG */
836
#endif	/* DEBUG */
826
	}
837
	}
827
	else {	/* not permanent => DRV */
838
	else {	/* not permanent => DRV */
Lines 845-851 Link Here
845
			pAC->Addr.Port[PortNumber].InexactDrvFilter.Bytes[4],
856
			pAC->Addr.Port[PortNumber].InexactDrvFilter.Bytes[4],
846
			pAC->Addr.Port[PortNumber].InexactDrvFilter.Bytes[5],
857
			pAC->Addr.Port[PortNumber].InexactDrvFilter.Bytes[5],
847
			pAC->Addr.Port[PortNumber].InexactDrvFilter.Bytes[6],
858
			pAC->Addr.Port[PortNumber].InexactDrvFilter.Bytes[6],
848
			pAC->Addr.Port[PortNumber].InexactDrvFilter.Bytes[7]))
859
			pAC->Addr.Port[PortNumber].InexactDrvFilter.Bytes[7]));
849
#endif	/* DEBUG */
860
#endif	/* DEBUG */
850
	}
861
	}
851
	
862
	
Lines 860-866 Link Here
860
	return (SK_MC_FILTERING_INEXACT);
871
	return (SK_MC_FILTERING_INEXACT);
861
	
872
	
862
}	/* SkAddrGmacMcAdd */
873
}	/* SkAddrGmacMcAdd */
863
874
#endif	/* YUKON */
864
#endif /* !SK_SLIM */
875
#endif /* !SK_SLIM */
865
876
866
/******************************************************************************
877
/******************************************************************************
Lines 892-898 Link Here
892
SK_IOC	IoC,		/* I/O context */
903
SK_IOC	IoC,		/* I/O context */
893
SK_U32	PortNumber)	/* Port Number */
904
SK_U32	PortNumber)	/* Port Number */
894
{
905
{
895
	int ReturnCode = 0;
906
	int ReturnCode = SK_ADDR_ILLEGAL_PORT;
896
#if (!defined(SK_SLIM) || defined(DEBUG))
907
#if (!defined(SK_SLIM) || defined(DEBUG))
897
	if (PortNumber >= (SK_U32) pAC->GIni.GIMacsFound) {
908
	if (PortNumber >= (SK_U32) pAC->GIni.GIMacsFound) {
898
		return (SK_ADDR_ILLEGAL_PORT);
909
		return (SK_ADDR_ILLEGAL_PORT);
Lines 948-960 Link Here
948
	SK_ADDR_PORT	*pAPort;
959
	SK_ADDR_PORT	*pAPort;
949
960
950
	SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
961
	SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
951
		("SkAddrXmacMcUpdate on Port %u.\n", PortNumber))
962
		("SkAddrXmacMcUpdate on Port %u.\n", PortNumber));
952
	
963
	
953
	pAPort = &pAC->Addr.Port[PortNumber];
964
	pAPort = &pAC->Addr.Port[PortNumber];
954
965
955
#ifdef DEBUG
966
#ifdef DEBUG
956
	SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
967
	SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
957
		("Next0 on Port %d: %d\n", PortNumber, Next0[PortNumber]))
968
		("Next0 on Port %d: %d\n", PortNumber, Next0[PortNumber]));
958
#endif /* DEBUG */
969
#endif /* DEBUG */
959
970
960
	/* Start with 0 to also program the logical MAC address. */
971
	/* Start with 0 to also program the logical MAC address. */
Lines 1043-1049 Link Here
1043
				pAPort->Exact[i].a[2],
1054
				pAPort->Exact[i].a[2],
1044
				pAPort->Exact[i].a[3],
1055
				pAPort->Exact[i].a[3],
1045
				pAPort->Exact[i].a[4],
1056
				pAPort->Exact[i].a[4],
1046
				pAPort->Exact[i].a[5]))
1057
				pAPort->Exact[i].a[5]));
1047
	}
1058
	}
1048
#endif /* DEBUG */
1059
#endif /* DEBUG */
1049
1060
Lines 1095-1107 Link Here
1095
	SK_ADDR_PORT	*pAPort;
1106
	SK_ADDR_PORT	*pAPort;
1096
1107
1097
	SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
1108
	SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
1098
		("SkAddrGmacMcUpdate on Port %u.\n", PortNumber))
1109
		("SkAddrGmacMcUpdate on Port %u.\n", PortNumber));
1099
	
1110
	
1100
	pAPort = &pAC->Addr.Port[PortNumber];
1111
	pAPort = &pAC->Addr.Port[PortNumber];
1101
1112
1102
#ifdef DEBUG
1113
#ifdef DEBUG
1103
	SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
1114
	SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
1104
		("Next0 on Port %d: %d\n", PortNumber, Next0[PortNumber]))
1115
		("Next0 on Port %d: %d\n", PortNumber, Next0[PortNumber]));
1105
#endif /* DEBUG */
1116
#endif /* DEBUG */
1106
	
1117
	
1107
#ifndef SK_SLIM
1118
#ifndef SK_SLIM
Lines 1157-1163 Link Here
1157
			pAPort->Exact[0].a[2],
1168
			pAPort->Exact[0].a[2],
1158
			pAPort->Exact[0].a[3],
1169
			pAPort->Exact[0].a[3],
1159
			pAPort->Exact[0].a[4],
1170
			pAPort->Exact[0].a[4],
1160
			pAPort->Exact[0].a[5]))
1171
			pAPort->Exact[0].a[5]));
1161
	
1172
	
1162
	SK_DBG_MSG(pAC, SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
1173
	SK_DBG_MSG(pAC, SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
1163
		("SkAddrGmacMcUpdate: Physical MAC Address: %02X %02X %02X %02X %02X %02X\n",
1174
		("SkAddrGmacMcUpdate: Physical MAC Address: %02X %02X %02X %02X %02X %02X\n",
Lines 1166-1172 Link Here
1166
			pAPort->CurrentMacAddress.a[2],
1177
			pAPort->CurrentMacAddress.a[2],
1167
			pAPort->CurrentMacAddress.a[3],
1178
			pAPort->CurrentMacAddress.a[3],
1168
			pAPort->CurrentMacAddress.a[4],
1179
			pAPort->CurrentMacAddress.a[4],
1169
			pAPort->CurrentMacAddress.a[5]))
1180
			pAPort->CurrentMacAddress.a[5]));
1170
#endif /* DEBUG */
1181
#endif /* DEBUG */
1171
	
1182
	
1172
#ifndef SK_SLIM
1183
#ifndef SK_SLIM
Lines 1373-1379 Link Here
1373
				pAC->Addr.Net[NetNumber].PermanentMacAddress.a[2],
1384
				pAC->Addr.Net[NetNumber].PermanentMacAddress.a[2],
1374
				pAC->Addr.Net[NetNumber].PermanentMacAddress.a[3],
1385
				pAC->Addr.Net[NetNumber].PermanentMacAddress.a[3],
1375
				pAC->Addr.Net[NetNumber].PermanentMacAddress.a[4],
1386
				pAC->Addr.Net[NetNumber].PermanentMacAddress.a[4],
1376
				pAC->Addr.Net[NetNumber].PermanentMacAddress.a[5]))
1387
				pAC->Addr.Net[NetNumber].PermanentMacAddress.a[5]));
1377
		
1388
		
1378
		SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
1389
		SK_DBG_MSG(pAC,SK_DBGMOD_ADDR, SK_DBGCAT_CTRL,
1379
			("SkAddrOverride: New logical MAC Address: %02X %02X %02X %02X %02X %02X\n",
1390
			("SkAddrOverride: New logical MAC Address: %02X %02X %02X %02X %02X %02X\n",
Lines 1382-1388 Link Here
1382
				pAC->Addr.Net[NetNumber].CurrentMacAddress.a[2],
1393
				pAC->Addr.Net[NetNumber].CurrentMacAddress.a[2],
1383
				pAC->Addr.Net[NetNumber].CurrentMacAddress.a[3],
1394
				pAC->Addr.Net[NetNumber].CurrentMacAddress.a[3],
1384
				pAC->Addr.Net[NetNumber].CurrentMacAddress.a[4],
1395
				pAC->Addr.Net[NetNumber].CurrentMacAddress.a[4],
1385
				pAC->Addr.Net[NetNumber].CurrentMacAddress.a[5]))
1396
				pAC->Addr.Net[NetNumber].CurrentMacAddress.a[5]));
1386
#endif /* DEBUG */
1397
#endif /* DEBUG */
1387
1398
1388
        /* Write address to first exact match entry of active port. */
1399
        /* Write address to first exact match entry of active port. */
Lines 1424-1430 Link Here
1424
SK_U32	PortNumber,		/* port whose promiscuous mode changes */
1435
SK_U32	PortNumber,		/* port whose promiscuous mode changes */
1425
int		NewPromMode)	/* new promiscuous mode */
1436
int		NewPromMode)	/* new promiscuous mode */
1426
{
1437
{
1427
	int ReturnCode = 0;
1438
	int ReturnCode = SK_ADDR_ILLEGAL_PORT;
1428
#if (!defined(SK_SLIM) || defined(DEBUG))
1439
#if (!defined(SK_SLIM) || defined(DEBUG))
1429
	if (PortNumber >= (SK_U32) pAC->GIni.GIMacsFound) {
1440
	if (PortNumber >= (SK_U32) pAC->GIni.GIMacsFound) {
1430
		return (SK_ADDR_ILLEGAL_PORT);
1441
		return (SK_ADDR_ILLEGAL_PORT);
(-)linux/drivers/net/sk98lin/skcsum.c (-3 / +3 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skcsum.c
3
 * Name:	skcsum.c
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.12 $
5
 * Version:	$Revision: 2.1 $
6
 * Date:	$Date: 2003/08/20 13:55:53 $
6
 * Date:	$Date: 2003/10/27 14:16:08 $
7
 * Purpose:	Store/verify Internet checksum in send/receive packets.
7
 * Purpose:	Store/verify Internet checksum in send/receive packets.
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 25-31 Link Here
25
25
26
#ifndef lint
26
#ifndef lint
27
static const char SysKonnectFileId[] =
27
static const char SysKonnectFileId[] =
28
	"@(#) $Id: skcsum.c,v 1.12 2003/08/20 13:55:53 mschmid Exp $ (C) SysKonnect.";
28
	"@(#) $Id: skcsum.c,v 2.1 2003/10/27 14:16:08 amock Exp $ (C) SysKonnect.";
29
#endif	/* !lint */
29
#endif	/* !lint */
30
30
31
/******************************************************************************
31
/******************************************************************************
(-)linux/drivers/net/sk98lin/skdim.c (-686 / +341 lines)
Lines 1-18 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 *
2
 *
3
 * Name:	skdim.c
3
 * Name:        skdim.c
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:     GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.5 $
5
 * Version:     $Revision: 1.5 $
6
 * Date:	$Date: 2003/11/28 12:55:40 $
6
 * Date:        $Date: 2004/07/17 13:28:43 $
7
 * Purpose:	All functions to maintain interrupt moderation
7
 * Purpose:     All functions regardig interrupt moderation
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
10
10
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	Driver for Marvell Yukon/2 chipset and SysKonnect Gigabit Ethernet 
17
 *      Server Adapters.
18
 *
19
 *	Author: Ralph Roesler (rroesler@syskonnect.de)
20
 *	        Mirko Lindner (mlindner@syskonnect.de)
21
 *
22
 *	Address all question to: linux@syskonnect.de
23
 *
24
 *	The technical manual for the adapters is available from SysKonnect's
25
 *	web pages: www.syskonnect.com
26
 *	
16
 *	This program is free software; you can redistribute it and/or modify
27
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
28
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
29
 *	the Free Software Foundation; either version 2 of the License, or
Lines 20-742 Link Here
20
 *
31
 *
21
 *	The information in this file is provided "AS IS" without warranty.
32
 *	The information in this file is provided "AS IS" without warranty.
22
 *
33
 *
23
 ******************************************************************************/
34
 *****************************************************************************/
24
35
25
/******************************************************************************
26
 *
27
 * Description:
28
 *
29
 * This module is intended to manage the dynamic interrupt moderation on both   
30
 * GEnesis and Yukon adapters.
31
 *
32
 * Include File Hierarchy:
33
 *
34
 *	"skdrv1st.h"
35
 *	"skdrv2nd.h"
36
 *
37
 ******************************************************************************/
38
39
#ifndef	lint
40
static const char SysKonnectFileId[] =
41
	"@(#) $Id: skdim.c,v 1.5 2003/11/28 12:55:40 rroesler Exp $ (C) SysKonnect.";
42
#endif
43
44
#define __SKADDR_C
45
46
#ifdef __cplusplus
47
#error C++ is not yet supported.
48
extern "C" {
49
#endif
50
51
/*******************************************************************************
52
**
53
** Includes
54
**
55
*******************************************************************************/
56
57
#ifndef __INC_SKDRV1ST_H
58
#include "h/skdrv1st.h"
36
#include "h/skdrv1st.h"
59
#endif
60
61
#ifndef __INC_SKDRV2ND_H
62
#include "h/skdrv2nd.h"
37
#include "h/skdrv2nd.h"
63
#endif
64
38
65
#include	<linux/kernel_stat.h>
39
/******************************************************************************
66
40
 *
67
/*******************************************************************************
41
 * Local Function Prototypes
68
**
42
 *
69
** Defines
43
 *****************************************************************************/
70
**
71
*******************************************************************************/
72
73
/*******************************************************************************
74
**
75
** Typedefs
76
**
77
*******************************************************************************/
78
44
79
/*******************************************************************************
45
static SK_U64 getIsrCalls(SK_AC *pAC);
80
**
46
static SK_BOOL isIntModEnabled(SK_AC *pAC);
81
** Local function prototypes 
47
static void setCurrIntCtr(SK_AC *pAC);
82
**
48
static void enableIntMod(SK_AC *pAC); 
83
*******************************************************************************/
49
static void disableIntMod(SK_AC *pAC);
84
85
static unsigned int GetCurrentSystemLoad(SK_AC *pAC);
86
static SK_U64       GetIsrCalls(SK_AC *pAC);
87
static SK_BOOL      IsIntModEnabled(SK_AC *pAC);
88
static void         SetCurrIntCtr(SK_AC *pAC);
89
static void         EnableIntMod(SK_AC *pAC); 
90
static void         DisableIntMod(SK_AC *pAC);
91
static void         ResizeDimTimerDuration(SK_AC *pAC);
92
static void         DisplaySelectedModerationType(SK_AC *pAC);
93
static void         DisplaySelectedModerationMask(SK_AC *pAC);
94
static void         DisplayDescrRatio(SK_AC *pAC);
95
50
96
/*******************************************************************************
51
#define M_DIMINFO pAC->DynIrqModInfo
97
**
98
** Global variables
99
**
100
*******************************************************************************/
101
52
102
/*******************************************************************************
53
/******************************************************************************
103
**
54
 *
104
** Local variables
55
 * Global Functions
105
**
56
 *
106
*******************************************************************************/
57
 *****************************************************************************/
107
58
108
/*******************************************************************************
59
/*****************************************************************************
109
**
60
 *
110
** Global functions 
61
 * 	SkDimModerate - Moderates the IRQs depending on the current needs
111
**
62
 *
112
*******************************************************************************/
63
 * Description:
64
 *	Moderation of IRQs depends on the number of occurred IRQs with 
65
 *	respect to the previous moderation cycle.
66
 *
67
 * Returns:	N/A
68
 *
69
 */
70
void SkDimModerate(
71
SK_AC *pAC)  /* pointer to adapter control context */
72
{
73
	SK_U64  IsrCalls = getIsrCalls(pAC);
74
75
	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,("==> SkDimModerate\n"));
76
77
	if (M_DIMINFO.IntModTypeSelect == C_INT_MOD_DYNAMIC) {
78
		if (isIntModEnabled(pAC)) {
79
			if (IsrCalls < M_DIMINFO.MaxModIntsPerSecLowerLimit) {
80
				disableIntMod(pAC);
81
			}
82
		} else {
83
			if (IsrCalls > M_DIMINFO.MaxModIntsPerSecUpperLimit) {
84
				enableIntMod(pAC);
85
			}
86
		}
87
	}
88
	setCurrIntCtr(pAC);
113
89
114
/*******************************************************************************
90
	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,("<== SkDimModerate\n"));
115
** Function     : SkDimModerate
91
}
116
** Description  : Called in every ISR to check if moderation is to be applied
117
**                or not for the current number of interrupts
118
** Programmer   : Ralph Roesler
119
** Last Modified: 22-mar-03
120
** Returns      : void (!)
121
** Notes        : -
122
*******************************************************************************/
123
124
void 
125
SkDimModerate(SK_AC *pAC) {
126
    unsigned int CurrSysLoad    = 0;  /* expressed in percent */
127
    unsigned int LoadIncrease   = 0;  /* expressed in percent */
128
    SK_U64       ThresholdInts  = 0;
129
    SK_U64       IsrCallsPerSec = 0;
130
92
131
#define M_DIMINFO pAC->DynIrqModInfo
93
/*****************************************************************************
94
 *
95
 * 	SkDimStartModerationTimer - Starts the moderation timer
96
 *
97
 * Description:
98
 *	Dynamic interrupt moderation is regularly checked using the
99
 *	so-called moderation timer. This timer is started with this function.
100
 *
101
 * Returns:	N/A
102
 */
103
void SkDimStartModerationTimer(
104
SK_AC *pAC) /* pointer to adapter control context */
105
{
106
	SK_EVPARA   EventParam;   /* Event struct for timer event */
107
 
108
	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
109
			("==> SkDimStartModerationTimer\n"));
132
110
133
    if (!IsIntModEnabled(pAC)) {
111
	if (M_DIMINFO.IntModTypeSelect == C_INT_MOD_DYNAMIC) {
134
        if (M_DIMINFO.IntModTypeSelect == C_INT_MOD_DYNAMIC) {
112
		SK_MEMSET((char *) &EventParam, 0, sizeof(EventParam));
135
            CurrSysLoad = GetCurrentSystemLoad(pAC);
113
		EventParam.Para32[0] = SK_DRV_MODERATION_TIMER;
136
            if (CurrSysLoad > 75) {
114
		SkTimerStart(pAC, pAC->IoBase,
137
                    /* 
115
			&pAC->DynIrqModInfo.ModTimer,
138
                    ** More than 75% total system load! Enable the moderation 
116
			pAC->DynIrqModInfo.DynIrqModSampleInterval * 1000000,
139
                    ** to shield the system against too many interrupts.
117
			SKGE_DRV, SK_DRV_TIMER, EventParam);
140
                    */
118
	}
141
                    EnableIntMod(pAC);
142
            } else if (CurrSysLoad > M_DIMINFO.PrevSysLoad) {
143
                LoadIncrease = (CurrSysLoad - M_DIMINFO.PrevSysLoad);
144
                if (LoadIncrease > ((M_DIMINFO.PrevSysLoad *
145
                                         C_INT_MOD_ENABLE_PERCENTAGE) / 100)) {
146
                    if (CurrSysLoad > 10) {
147
                        /* 
148
                        ** More than 50% increase with respect to the 
149
                        ** previous load of the system. Most likely this 
150
                        ** is due to our ISR-proc...
151
                        */
152
                        EnableIntMod(pAC);
153
                    }
154
                }
155
            } else {
156
                /*
157
                ** Neither too much system load at all nor too much increase
158
                ** with respect to the previous system load. Hence, we can leave
159
                ** the ISR-handling like it is without enabling moderation.
160
                */
161
            }
162
            M_DIMINFO.PrevSysLoad = CurrSysLoad;
163
        }   
164
    } else {
165
        if (M_DIMINFO.IntModTypeSelect == C_INT_MOD_DYNAMIC) {
166
            ThresholdInts  = ((M_DIMINFO.MaxModIntsPerSec *
167
                                   C_INT_MOD_DISABLE_PERCENTAGE) / 100);
168
            IsrCallsPerSec = GetIsrCalls(pAC);
169
            if (IsrCallsPerSec <= ThresholdInts) {
170
                /* 
171
                ** The number of interrupts within the last second is 
172
                ** lower than the disable_percentage of the desried 
173
                ** maxrate. Therefore we can disable the moderation.
174
                */
175
                DisableIntMod(pAC);
176
                M_DIMINFO.MaxModIntsPerSec = 
177
                   (M_DIMINFO.MaxModIntsPerSecUpperLimit +
178
                    M_DIMINFO.MaxModIntsPerSecLowerLimit) / 2;
179
            } else {
180
                /*
181
                ** The number of interrupts per sec is the same as expected.
182
                ** Evalulate the descriptor-ratio. If it has changed, a resize 
183
                ** in the moderation timer might be usefull
184
                */
185
                if (M_DIMINFO.AutoSizing) {
186
                    ResizeDimTimerDuration(pAC);
187
                }
188
            }
189
        }
190
    }
191
192
    /*
193
    ** Some information to the log...
194
    */
195
    if (M_DIMINFO.DisplayStats) {
196
        DisplaySelectedModerationType(pAC);
197
        DisplaySelectedModerationMask(pAC);
198
        DisplayDescrRatio(pAC);
199
    }
200
119
201
    M_DIMINFO.NbrProcessedDescr = 0; 
120
	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
202
    SetCurrIntCtr(pAC);
121
			("<== SkDimStartModerationTimer\n"));
203
}
122
}
204
123
205
/*******************************************************************************
124
/*****************************************************************************
206
** Function     : SkDimStartModerationTimer
125
 *
207
** Description  : Starts the audit-timer for the dynamic interrupt moderation
126
 * 	SkDimEnableModerationIfNeeded - Enables or disables any moderationtype
208
** Programmer   : Ralph Roesler
127
 *
209
** Last Modified: 22-mar-03
128
 * Description:
210
** Returns      : void (!)
129
 *	This function effectively initializes the IRQ moderation of a network
211
** Notes        : -
130
 *	adapter. Depending on the configuration, this might be either static
212
*******************************************************************************/
131
 *	or dynamic. If no moderation is configured, this function will do
213
132
 *	nothing.
214
void 
133
 *
215
SkDimStartModerationTimer(SK_AC *pAC) {
134
 * Returns:	N/A
216
    SK_EVPARA    EventParam;   /* Event struct for timer event */
135
 */
217
 
136
void SkDimEnableModerationIfNeeded(
218
    SK_MEMSET((char *) &EventParam, 0, sizeof(EventParam));
137
SK_AC *pAC)  /* pointer to adapter control context */
219
    EventParam.Para32[0] = SK_DRV_MODERATION_TIMER;
138
{
220
    SkTimerStart(pAC, pAC->IoBase, &pAC->DynIrqModInfo.ModTimer,
139
	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
221
                 SK_DRV_MODERATION_TIMER_LENGTH,
140
			("==> SkDimEnableModerationIfNeeded\n"));
222
                 SKGE_DRV, SK_DRV_TIMER, EventParam);
141
223
}
142
	if (M_DIMINFO.IntModTypeSelect != C_INT_MOD_NONE) {
143
		if (M_DIMINFO.IntModTypeSelect == C_INT_MOD_STATIC) {
144
			enableIntMod(pAC);   
145
		} else { /* must be C_INT_MOD_DYNAMIC */
146
			SkDimStartModerationTimer(pAC);
147
		}
148
	}
224
149
225
/*******************************************************************************
150
	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
226
** Function     : SkDimEnableModerationIfNeeded
151
			("<== SkDimEnableModerationIfNeeded\n"));
227
** Description  : Either enables or disables moderation
228
** Programmer   : Ralph Roesler
229
** Last Modified: 22-mar-03
230
** Returns      : void (!)
231
** Notes        : This function is called when a particular adapter is opened
232
**                There is no Disable function, because when all interrupts 
233
**                might be disable, the moderation timer has no meaning at all
234
******************************************************************************/
235
236
void
237
SkDimEnableModerationIfNeeded(SK_AC *pAC) {
238
239
    if (M_DIMINFO.IntModTypeSelect == C_INT_MOD_STATIC) {
240
        EnableIntMod(pAC);   /* notification print in this function */
241
    } else if (M_DIMINFO.IntModTypeSelect == C_INT_MOD_DYNAMIC) {
242
        SkDimStartModerationTimer(pAC);
243
        if (M_DIMINFO.DisplayStats) {
244
            printk("Dynamic moderation has been enabled\n");
245
        }
246
    } else {
247
        if (M_DIMINFO.DisplayStats) {
248
            printk("No moderation has been enabled\n");
249
        }
250
    }
251
}
152
}
252
153
253
/*******************************************************************************
154
/*****************************************************************************
254
** Function     : SkDimDisplayModerationSettings
155
 *
255
** Description  : Displays the current settings regaring interrupt moderation
156
 * 	SkDimDisableModeration - disables moderation if it is enabled
256
** Programmer   : Ralph Roesler
157
 *
257
** Last Modified: 22-mar-03
158
 * Description:
258
** Returns      : void (!)
159
 *	Disabling of the moderation requires that is enabled already.
259
** Notes        : -
160
 *
260
*******************************************************************************/
161
 * Returns:	N/A
261
162
 */
262
void 
163
void SkDimDisableModeration(
263
SkDimDisplayModerationSettings(SK_AC *pAC) {
164
SK_AC  *pAC,                /* pointer to adapter control context */
264
    DisplaySelectedModerationType(pAC);
165
int     CurrentModeration)  /* type of current moderation         */
265
    DisplaySelectedModerationMask(pAC);
166
{
266
}
167
	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
168
			("==> SkDimDisableModeration\n"));
169
170
	if (M_DIMINFO.IntModTypeSelect != C_INT_MOD_NONE) {
171
		if (CurrentModeration == C_INT_MOD_STATIC) {
172
			disableIntMod(pAC);
173
		} else { /* must be C_INT_MOD_DYNAMIC */
174
			SkTimerStop(pAC, pAC->IoBase, &M_DIMINFO.ModTimer);
175
			disableIntMod(pAC);
176
		}
177
	}
267
178
268
/*******************************************************************************
179
	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
269
**
180
			("<== SkDimDisableModeration\n"));
270
** Local functions 
181
}
271
**
272
*******************************************************************************/
273
182
274
/*******************************************************************************
183
/******************************************************************************
275
** Function     : GetCurrentSystemLoad
184
 *
276
** Description  : Retrieves the current system load of the system. This load
185
 * Local Functions
277
**                is evaluated for all processors within the system.
186
 *
278
** Programmer   : Ralph Roesler
187
 *****************************************************************************/
279
** Last Modified: 22-mar-03
280
** Returns      : unsigned int: load expressed in percentage
281
** Notes        : The possible range being returned is from 0 up to 100.
282
**                Whereas 0 means 'no load at all' and 100 'system fully loaded'
283
**                It is impossible to determine what actually causes the system
284
**                to be in 100%, but maybe that is due to too much interrupts.
285
*******************************************************************************/
286
287
static unsigned int
288
GetCurrentSystemLoad(SK_AC *pAC) {
289
	unsigned long jif         = jiffies;
290
	unsigned int  UserTime    = 0;
291
	unsigned int  SystemTime  = 0;
292
	unsigned int  NiceTime    = 0;
293
	unsigned int  IdleTime    = 0;
294
	unsigned int  TotalTime   = 0;
295
	unsigned int  UsedTime    = 0;
296
	unsigned int  SystemLoad  = 0;
297
188
298
	/* unsigned int  NbrCpu      = 0; */
189
/*****************************************************************************
190
 *
191
 * 	getIsrCalls - evaluate the number of IRQs handled in mod interval
192
 *
193
 * Description:
194
 *	Depending on the selected moderation mask, this function will return
195
 *	the number of interrupts handled in the previous moderation interval.
196
 *	This evaluated number is based on the current number of interrupts
197
 *	stored in PNMI-context and the previous stored interrupts.
198
 *
199
 * Returns:
200
 *	the number of IRQs handled
201
 */
202
static SK_U64 getIsrCalls(
203
SK_AC *pAC)  /* pointer to adapter control context */
204
{
205
	SK_U64   RxPort0IntDiff = 0, RxPort1IntDiff = 0;
206
	SK_U64   TxPort0IntDiff = 0, TxPort1IntDiff = 0;
207
	SK_U64   StatusPort0IntDiff = 0, StatusPort1IntDiff = 0;
208
209
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,("==>getIsrCalls\n"));
210
211
	if (!CHIP_ID_YUKON_2(pAC)) {
212
		if ((M_DIMINFO.MaskIrqModeration == IRQ_MASK_TX_ONLY) ||
213
		    (M_DIMINFO.MaskIrqModeration == IRQ_MASK_SP_TX)) {
214
			if (pAC->GIni.GIMacsFound == 2) {
215
				TxPort1IntDiff = 
216
					pAC->Pnmi.Port[1].TxIntrCts - 
217
					M_DIMINFO.PrevPort1TxIntrCts;
218
			}
219
			TxPort0IntDiff = pAC->Pnmi.Port[0].TxIntrCts - 
220
					M_DIMINFO.PrevPort0TxIntrCts;
221
		} else if ((M_DIMINFO.MaskIrqModeration == IRQ_MASK_RX_ONLY) ||
222
		           (M_DIMINFO.MaskIrqModeration == IRQ_MASK_SP_RX)) {
223
			if (pAC->GIni.GIMacsFound == 2) {
224
				RxPort1IntDiff =
225
					pAC->Pnmi.Port[1].RxIntrCts - 
226
					M_DIMINFO.PrevPort1RxIntrCts;
227
			}
228
			RxPort0IntDiff = pAC->Pnmi.Port[0].RxIntrCts - 
229
					M_DIMINFO.PrevPort0RxIntrCts;
230
		} else {
231
			if (pAC->GIni.GIMacsFound == 2) {
232
				RxPort1IntDiff = 
233
					pAC->Pnmi.Port[1].RxIntrCts - 
234
					M_DIMINFO.PrevPort1RxIntrCts;
235
				TxPort1IntDiff =
236
					pAC->Pnmi.Port[1].TxIntrCts - 
237
					M_DIMINFO.PrevPort1TxIntrCts;
238
			} 
239
			RxPort0IntDiff = pAC->Pnmi.Port[0].RxIntrCts - 
240
					M_DIMINFO.PrevPort0RxIntrCts;
241
			TxPort0IntDiff = pAC->Pnmi.Port[0].TxIntrCts - 
242
					M_DIMINFO.PrevPort0TxIntrCts;
243
		}
244
        	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
245
				("==>getIsrCalls (!CHIP_ID_YUKON_2)\n"));
246
		return (RxPort0IntDiff + RxPort1IntDiff + 
247
		        TxPort0IntDiff + TxPort1IntDiff);
248
	}
299
249
300
	/*
250
	/*
301
	** The following lines have been commented out, because
251
	** We have a Yukon2 compliant chipset if we come up to here
302
	** from kernel 2.5.44 onwards, the kernel-owned structure
303
	**
304
	**      struct kernel_stat kstat
305
	**
306
	** is not marked as an exported symbol in the file
307
	**
252
	**
308
	**      kernel/ksyms.c 
253
	if (pAC->GIni.GIMacsFound == 2) {
309
	**
254
		StatusPort1IntDiff = pAC->Pnmi.Port[1].StatusLeIntrCts - 
310
	** As a consequence, using this driver as KLM is not possible
255
					M_DIMINFO.PrevPort1StatusIntrCts;
311
	** and any access of the structure kernel_stat via the 
256
	}
312
	** dedicated macros kstat_cpu(i).cpustat.xxx is to be avoided.
257
	StatusPort0IntDiff = pAC->Pnmi.Port[0].StatusLeIntrCts - 
313
	**
258
				M_DIMINFO.PrevPort0StatusIntrCts;
314
	** The kstat-information might be added again in future 
315
	** versions of the 2.5.xx kernel, but for the time being, 
316
	** number of interrupts will serve as indication how much 
317
	** load we currently have... 
318
	**
319
	** for (NbrCpu = 0; NbrCpu < num_online_cpus(); NbrCpu++) {
320
	**	UserTime   = UserTime   + kstat_cpu(NbrCpu).cpustat.user;
321
	**	NiceTime   = NiceTime   + kstat_cpu(NbrCpu).cpustat.nice;
322
	**	SystemTime = SystemTime + kstat_cpu(NbrCpu).cpustat.system;
323
	** }
324
	*/
259
	*/
325
	SK_U64 ThresholdInts  = 0;
260
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
326
	SK_U64 IsrCallsPerSec = 0;
261
			("==>getIsrCalls (CHIP_ID_YUKON_2)\n"));
327
262
	return (StatusPort0IntDiff + StatusPort1IntDiff);
328
	ThresholdInts  = ((M_DIMINFO.MaxModIntsPerSec *
263
}
329
			   C_INT_MOD_ENABLE_PERCENTAGE) + 100);
330
	IsrCallsPerSec = GetIsrCalls(pAC);
331
	if (IsrCallsPerSec >= ThresholdInts) {
332
	    /*
333
	    ** We do not know how much the real CPU-load is!
334
	    ** Return 80% as a default in order to activate DIM
335
	    */
336
	    SystemLoad = 80;
337
	    return (SystemLoad);  
338
	} 
339
340
	UsedTime  = UserTime + NiceTime + SystemTime;
341
342
	IdleTime  = jif * num_online_cpus() - UsedTime;
343
	TotalTime = UsedTime + IdleTime;
344
345
	SystemLoad = ( 100 * (UsedTime  - M_DIMINFO.PrevUsedTime) ) /
346
						(TotalTime - M_DIMINFO.PrevTotalTime);
347
264
348
	if (M_DIMINFO.DisplayStats) {
265
/*****************************************************************************
349
		printk("Current system load is: %u\n", SystemLoad);
266
 *
267
 * 	setCurrIntCtr - stores the current number of interrupts
268
 *
269
 * Description:
270
 *	Stores the current number of occurred interrupts in the adapter
271
 *	context. This is needed to evaluate the  umber of interrupts within
272
 *	the moderation interval.
273
 *
274
 * Returns:	N/A
275
 *
276
 */
277
static void setCurrIntCtr(
278
SK_AC *pAC)  /* pointer to adapter control context */
279
{
280
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,("==>setCurrIntCtr\n"));
281
282
	if (!CHIP_ID_YUKON_2(pAC)) {
283
		if (pAC->GIni.GIMacsFound == 2) {
284
			M_DIMINFO.PrevPort1RxIntrCts = pAC->Pnmi.Port[1].RxIntrCts;
285
			M_DIMINFO.PrevPort1TxIntrCts = pAC->Pnmi.Port[1].TxIntrCts;
286
		} 
287
		M_DIMINFO.PrevPort0RxIntrCts = pAC->Pnmi.Port[0].RxIntrCts;
288
		M_DIMINFO.PrevPort0TxIntrCts = pAC->Pnmi.Port[0].TxIntrCts;
289
        	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
290
				("<== setCurrIntCtr (!CHIP_ID_YUKON_2)\n"));
291
		return;
350
	}
292
	}
351
293
352
	M_DIMINFO.PrevTotalTime = TotalTime;
294
	/*
353
	M_DIMINFO.PrevUsedTime  = UsedTime;
295
	** We have a Yukon2 compliant chipset if we come up to here
354
296
	**
355
	return (SystemLoad);
297
	if (pAC->GIni.GIMacsFound == 2) {
298
		M_DIMINFO.PrevPort1StatusIntrCts = pAC->Pnmi.Port[1].StatusLeIntrCts;
299
	} 
300
	M_DIMINFO.PrevPort0StatusIntrCts = pAC->Pnmi.Port[0].StatusLeIntrCts;
301
	*/
302
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
303
			("<== setCurrIntCtr (CHIP_ID_YUKON_2)\n"));
356
}
304
}
357
305
358
/*******************************************************************************
306
/*****************************************************************************
359
** Function     : GetIsrCalls
307
 *
360
** Description  : Depending on the selected moderation mask, this function will
308
 * 	isIntModEnabled - returns the current state of interrupt moderation
361
**                return the number of interrupts handled in the previous time-
309
 *
362
**                frame. This evaluated number is based on the current number 
310
 * Description:
363
**                of interrupts stored in PNMI-context and the previous stored 
311
 *	This function retrieves the current value of the interrupt moderation
364
**                interrupts.
312
 *	command register. Its content determines whether any moderation is 
365
** Programmer   : Ralph Roesler
313
 *	running or not.
366
** Last Modified: 23-mar-03
314
 *
367
** Returns      : int:   the number of interrupts being executed in the last
315
 * Returns:
368
**                       timeframe
316
 *	SK_TRUE : IRQ moderation is currently active
369
** Notes        : It makes only sense to call this function, when dynamic 
317
 *	SK_FALSE: No IRQ moderation is active
370
**                interrupt moderation is applied
318
 */
371
*******************************************************************************/
319
static SK_BOOL isIntModEnabled(
372
320
SK_AC *pAC)  /* pointer to adapter control context */
373
static SK_U64
321
{
374
GetIsrCalls(SK_AC *pAC) {
322
	unsigned long CtrCmd;
375
    SK_U64   RxPort0IntDiff = 0;
323
376
    SK_U64   RxPort1IntDiff = 0;
324
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,("==>isIntModEnabled\n"));
377
    SK_U64   TxPort0IntDiff = 0;
325
378
    SK_U64   TxPort1IntDiff = 0;
326
	SK_IN32(pAC->IoBase, B2_IRQM_CTRL, &CtrCmd);
379
327
	if ((CtrCmd & TIM_START) == TIM_START) {
380
    if (pAC->DynIrqModInfo.MaskIrqModeration == IRQ_MASK_TX_ONLY) {
328
        	SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
381
        if (pAC->GIni.GIMacsFound == 2) {
329
			("<== isIntModEnabled (SK_TRUE)\n"));
382
            TxPort1IntDiff = pAC->Pnmi.Port[1].TxIntrCts - 
330
		return SK_TRUE;
383
                             pAC->DynIrqModInfo.PrevPort1TxIntrCts;
331
	}
384
        }
332
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,
385
        TxPort0IntDiff = pAC->Pnmi.Port[0].TxIntrCts - 
333
			("<== isIntModEnabled (SK_FALSE)\n"));
386
                         pAC->DynIrqModInfo.PrevPort0TxIntrCts;
334
	return SK_FALSE;
387
    } else if (pAC->DynIrqModInfo.MaskIrqModeration == IRQ_MASK_RX_ONLY) {
388
        if (pAC->GIni.GIMacsFound == 2) {
389
            RxPort1IntDiff = pAC->Pnmi.Port[1].RxIntrCts - 
390
                             pAC->DynIrqModInfo.PrevPort1RxIntrCts;
391
        }
392
        RxPort0IntDiff = pAC->Pnmi.Port[0].RxIntrCts - 
393
                         pAC->DynIrqModInfo.PrevPort0RxIntrCts;
394
    } else {
395
        if (pAC->GIni.GIMacsFound == 2) {
396
            RxPort1IntDiff = pAC->Pnmi.Port[1].RxIntrCts - 
397
                             pAC->DynIrqModInfo.PrevPort1RxIntrCts;
398
            TxPort1IntDiff = pAC->Pnmi.Port[1].TxIntrCts - 
399
                             pAC->DynIrqModInfo.PrevPort1TxIntrCts;
400
        } 
401
        RxPort0IntDiff = pAC->Pnmi.Port[0].RxIntrCts - 
402
                         pAC->DynIrqModInfo.PrevPort0RxIntrCts;
403
        TxPort0IntDiff = pAC->Pnmi.Port[0].TxIntrCts - 
404
                         pAC->DynIrqModInfo.PrevPort0TxIntrCts;
405
    }
406
407
    return (RxPort0IntDiff + RxPort1IntDiff + TxPort0IntDiff + TxPort1IntDiff);
408
}
335
}
409
336
410
/*******************************************************************************
337
/*****************************************************************************
411
** Function     : GetRxCalls
338
 *
412
** Description  : This function will return the number of times a receive inter-
339
 * 	enableIntMod - enables the interrupt moderation
413
**                rupt was processed. This is needed to evaluate any resizing 
340
 *
414
**                factor.
341
 * Description:
415
** Programmer   : Ralph Roesler
342
 *	Enabling the interrupt moderation is done by putting the desired
416
** Last Modified: 23-mar-03
343
 *	moderation interval in the B2_IRQM_INI register, specifying the
417
** Returns      : SK_U64: the number of RX-ints being processed
344
 *	desired maks in the B2_IRQM_MSK register and finally starting the
418
** Notes        : It makes only sense to call this function, when dynamic 
345
 *	IRQ moderation timer using the B2_IRQM_CTRL register.
419
**                interrupt moderation is applied
346
 *
420
*******************************************************************************/
347
 * Returns:	N/A
421
348
 *
422
static SK_U64
349
 */
423
GetRxCalls(SK_AC *pAC) {
350
static void enableIntMod(
424
    SK_U64   RxPort0IntDiff = 0;
351
SK_AC *pAC)  /* pointer to adapter control context */
425
    SK_U64   RxPort1IntDiff = 0;
352
{
426
353
	unsigned long ModBase;
427
    if (pAC->GIni.GIMacsFound == 2) {
354
428
        RxPort1IntDiff = pAC->Pnmi.Port[1].RxIntrCts - 
355
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,("==> enableIntMod\n"));
429
                         pAC->DynIrqModInfo.PrevPort1RxIntrCts;
356
430
    }
357
	if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
431
    RxPort0IntDiff = pAC->Pnmi.Port[0].RxIntrCts - 
358
		ModBase = C_CLK_FREQ_GENESIS / M_DIMINFO.MaxModIntsPerSec;
432
                     pAC->DynIrqModInfo.PrevPort0RxIntrCts;
359
	} else if (pAC->GIni.GIChipId == CHIP_ID_YUKON_EC) {
433
360
		ModBase = C_CLK_FREQ_YUKON_EC / M_DIMINFO.MaxModIntsPerSec;
434
    return (RxPort0IntDiff + RxPort1IntDiff);
361
	} else {
435
}
362
		ModBase = C_CLK_FREQ_YUKON / M_DIMINFO.MaxModIntsPerSec;
363
	}
436
364
437
/*******************************************************************************
365
	SK_OUT32(pAC->IoBase, B2_IRQM_INI, ModBase);
438
** Function     : SetCurrIntCtr
366
	SK_OUT32(pAC->IoBase, B2_IRQM_MSK, M_DIMINFO.MaskIrqModeration);
439
** Description  : Will store the current number orf occured interrupts in the 
367
	SK_OUT32(pAC->IoBase, B2_IRQM_CTRL, TIM_START);
440
**                adapter context. This is needed to evaluated the number of 
441
**                interrupts within a current timeframe.
442
** Programmer   : Ralph Roesler
443
** Last Modified: 23-mar-03
444
** Returns      : void (!)
445
** Notes        : -
446
*******************************************************************************/
447
448
static void
449
SetCurrIntCtr(SK_AC *pAC) {
450
    if (pAC->GIni.GIMacsFound == 2) {
451
        pAC->DynIrqModInfo.PrevPort1RxIntrCts = pAC->Pnmi.Port[1].RxIntrCts;
452
        pAC->DynIrqModInfo.PrevPort1TxIntrCts = pAC->Pnmi.Port[1].TxIntrCts;
453
    } 
454
    pAC->DynIrqModInfo.PrevPort0RxIntrCts = pAC->Pnmi.Port[0].RxIntrCts;
455
    pAC->DynIrqModInfo.PrevPort0TxIntrCts = pAC->Pnmi.Port[0].TxIntrCts;
456
}
457
368
458
/*******************************************************************************
369
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,("<== enableIntMod\n"));
459
** Function     : IsIntModEnabled()
460
** Description  : Retrieves the current value of the interrupts moderation
461
**                command register. Its content determines whether any 
462
**                moderation is running or not.
463
** Programmer   : Ralph Roesler
464
** Last Modified: 23-mar-03
465
** Returns      : SK_TRUE  : if mod timer running
466
**                SK_FALSE : if no moderation is being performed
467
** Notes        : -
468
*******************************************************************************/
469
470
static SK_BOOL
471
IsIntModEnabled(SK_AC *pAC) {
472
    unsigned long CtrCmd;
473
474
    SK_IN32(pAC->IoBase, B2_IRQM_CTRL, &CtrCmd);
475
    if ((CtrCmd & TIM_START) == TIM_START) {
476
       return SK_TRUE;
477
    } else {
478
       return SK_FALSE;
479
    }
480
}
370
}
481
371
482
/*******************************************************************************
372
/*****************************************************************************
483
** Function     : EnableIntMod()
373
 *
484
** Description  : Enables the interrupt moderation using the values stored in
374
 * 	disableIntMod - disables the interrupt moderation
485
**                in the pAC->DynIntMod data structure
375
 *
486
** Programmer   : Ralph Roesler
376
 * Description:
487
** Last Modified: 22-mar-03
377
 *	Disabling the interrupt moderation is done by stopping the
488
** Returns      : -
378
 *	IRQ moderation timer using the B2_IRQM_CTRL register.
489
** Notes        : -
379
 *
490
*******************************************************************************/
380
 * Returns:	N/A
491
381
 *
492
static void
382
 */
493
EnableIntMod(SK_AC *pAC) {
383
static void disableIntMod(
494
    unsigned long ModBase;
384
SK_AC *pAC)  /* pointer to adapter control context */
495
385
{
496
    if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
386
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,("==> disableIntMod\n"));
497
       ModBase = C_CLK_FREQ_GENESIS / pAC->DynIrqModInfo.MaxModIntsPerSec;
498
    } else {
499
       ModBase = C_CLK_FREQ_YUKON / pAC->DynIrqModInfo.MaxModIntsPerSec;
500
    }
501
502
    SK_OUT32(pAC->IoBase, B2_IRQM_INI,  ModBase);
503
    SK_OUT32(pAC->IoBase, B2_IRQM_MSK,  pAC->DynIrqModInfo.MaskIrqModeration);
504
    SK_OUT32(pAC->IoBase, B2_IRQM_CTRL, TIM_START);
505
    if (M_DIMINFO.DisplayStats) {
506
        printk("Enabled interrupt moderation (%i ints/sec)\n",
507
               M_DIMINFO.MaxModIntsPerSec);
508
    }
509
}
510
387
511
/*******************************************************************************
388
	SK_OUT32(pAC->IoBase, B2_IRQM_CTRL, TIM_STOP);
512
** Function     : DisableIntMod()
513
** Description  : Disbles the interrupt moderation independent of what inter-
514
**                rupts are running or not
515
** Programmer   : Ralph Roesler
516
** Last Modified: 23-mar-03
517
** Returns      : -
518
** Notes        : -
519
*******************************************************************************/
520
521
static void 
522
DisableIntMod(SK_AC *pAC) {
523
524
    SK_OUT32(pAC->IoBase, B2_IRQM_CTRL, TIM_STOP);
525
    if (M_DIMINFO.DisplayStats) {
526
        printk("Disabled interrupt moderation\n");
527
    }
528
} 
529
389
530
/*******************************************************************************
390
        SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_MSG,("<== disableIntMod\n"));
531
** Function     : ResizeDimTimerDuration();
532
** Description  : Checks the current used descriptor ratio and resizes the 
533
**                duration timer (longer/smaller) if possible. 
534
** Programmer   : Ralph Roesler
535
** Last Modified: 23-mar-03
536
** Returns      : -
537
** Notes        : There are both maximum and minimum timer duration value. 
538
**                This function assumes that interrupt moderation is already
539
**                enabled!
540
*******************************************************************************/
541
542
static void 
543
ResizeDimTimerDuration(SK_AC *pAC) {
544
    SK_BOOL IncreaseTimerDuration;
545
    int     TotalMaxNbrDescr;
546
    int     UsedDescrRatio;
547
    int     RatioDiffAbs;
548
    int     RatioDiffRel;
549
    int     NewMaxModIntsPerSec;
550
    int     ModAdjValue;
551
    long    ModBase;
552
553
    /*
554
    ** Check first if we are allowed to perform any modification
555
    */
556
    if (IsIntModEnabled(pAC)) { 
557
        if (M_DIMINFO.IntModTypeSelect != C_INT_MOD_DYNAMIC) {
558
            return; 
559
        } else {
560
            if (M_DIMINFO.ModJustEnabled) {
561
                M_DIMINFO.ModJustEnabled = SK_FALSE;
562
                return;
563
            }
564
        }
565
    }
566
567
    /*
568
    ** If we got until here, we have to evaluate the amount of the
569
    ** descriptor ratio change...
570
    */
571
    TotalMaxNbrDescr = pAC->RxDescrPerRing * GetRxCalls(pAC);
572
    UsedDescrRatio   = (M_DIMINFO.NbrProcessedDescr * 100) / TotalMaxNbrDescr;
573
574
    if (UsedDescrRatio > M_DIMINFO.PrevUsedDescrRatio) {
575
        RatioDiffAbs = (UsedDescrRatio - M_DIMINFO.PrevUsedDescrRatio);
576
        RatioDiffRel = (RatioDiffAbs * 100) / UsedDescrRatio;
577
        M_DIMINFO.PrevUsedDescrRatio = UsedDescrRatio;
578
        IncreaseTimerDuration = SK_FALSE;  /* in other words: DECREASE */
579
    } else if (UsedDescrRatio < M_DIMINFO.PrevUsedDescrRatio) {
580
        RatioDiffAbs = (M_DIMINFO.PrevUsedDescrRatio - UsedDescrRatio);
581
        RatioDiffRel = (RatioDiffAbs * 100) / M_DIMINFO.PrevUsedDescrRatio;
582
        M_DIMINFO.PrevUsedDescrRatio = UsedDescrRatio;
583
        IncreaseTimerDuration = SK_TRUE;   /* in other words: INCREASE */
584
    } else {
585
        RatioDiffAbs = (M_DIMINFO.PrevUsedDescrRatio - UsedDescrRatio);
586
        RatioDiffRel = (RatioDiffAbs * 100) / M_DIMINFO.PrevUsedDescrRatio;
587
        M_DIMINFO.PrevUsedDescrRatio = UsedDescrRatio;
588
        IncreaseTimerDuration = SK_TRUE;   /* in other words: INCREASE */
589
    }
590
591
    /*
592
    ** Now we can determine the change in percent
593
    */
594
    if ((RatioDiffRel >= 0) && (RatioDiffRel <= 5) ) {
595
       ModAdjValue = 1;  /*  1% change - maybe some other value in future */
596
    } else if ((RatioDiffRel > 5) && (RatioDiffRel <= 10) ) {
597
       ModAdjValue = 1;  /*  1% change - maybe some other value in future */
598
    } else if ((RatioDiffRel > 10) && (RatioDiffRel <= 15) ) {
599
       ModAdjValue = 1;  /*  1% change - maybe some other value in future */
600
    } else {
601
       ModAdjValue = 1;  /*  1% change - maybe some other value in future */
602
    }
603
604
    if (IncreaseTimerDuration) {
605
       NewMaxModIntsPerSec =  M_DIMINFO.MaxModIntsPerSec +
606
                             (M_DIMINFO.MaxModIntsPerSec * ModAdjValue) / 100;
607
    } else {
608
       NewMaxModIntsPerSec =  M_DIMINFO.MaxModIntsPerSec -
609
                             (M_DIMINFO.MaxModIntsPerSec * ModAdjValue) / 100;
610
    }
611
612
    /* 
613
    ** Check if we exceed boundaries...
614
    */
615
    if ( (NewMaxModIntsPerSec > M_DIMINFO.MaxModIntsPerSecUpperLimit) ||
616
         (NewMaxModIntsPerSec < M_DIMINFO.MaxModIntsPerSecLowerLimit)) {
617
        if (M_DIMINFO.DisplayStats) {
618
            printk("Cannot change ModTim from %i to %i ints/sec\n",
619
                   M_DIMINFO.MaxModIntsPerSec, NewMaxModIntsPerSec);
620
        }
621
        return;
622
    } else {
623
        if (M_DIMINFO.DisplayStats) {
624
            printk("Resized ModTim from %i to %i ints/sec\n",
625
                   M_DIMINFO.MaxModIntsPerSec, NewMaxModIntsPerSec);
626
        }
627
    }
628
629
    M_DIMINFO.MaxModIntsPerSec = NewMaxModIntsPerSec;
630
631
    if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
632
        ModBase = C_CLK_FREQ_GENESIS / pAC->DynIrqModInfo.MaxModIntsPerSec;
633
    } else {
634
        ModBase = C_CLK_FREQ_YUKON / pAC->DynIrqModInfo.MaxModIntsPerSec;
635
    }
636
637
    /* 
638
    ** We do not need to touch any other registers
639
    */
640
    SK_OUT32(pAC->IoBase, B2_IRQM_INI, ModBase);
641
} 
391
} 
642
392
643
/*******************************************************************************
393
/*******************************************************************************
644
** Function     : DisplaySelectedModerationType()
394
 *
645
** Description  : Displays what type of moderation we have
395
 * End of file
646
** Programmer   : Ralph Roesler
396
 *
647
** Last Modified: 23-mar-03
397
 ******************************************************************************/
648
** Returns      : void!
649
** Notes        : -
650
*******************************************************************************/
651
652
static void
653
DisplaySelectedModerationType(SK_AC *pAC) {
654
655
    if (pAC->DynIrqModInfo.DisplayStats) {
656
        if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_STATIC) {
657
             printk("Static int moderation runs with %i INTS/sec\n",
658
                    pAC->DynIrqModInfo.MaxModIntsPerSec);
659
        } else if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_DYNAMIC) {
660
             if (IsIntModEnabled(pAC)) {
661
                printk("Dynamic int moderation runs with %i INTS/sec\n",
662
                       pAC->DynIrqModInfo.MaxModIntsPerSec);
663
             } else {
664
                printk("Dynamic int moderation currently not applied\n");
665
             }
666
        } else {
667
             printk("No interrupt moderation selected!\n");
668
        }
669
    }
670
}
671
672
/*******************************************************************************
673
** Function     : DisplaySelectedModerationMask()
674
** Description  : Displays what interrupts are moderated
675
** Programmer   : Ralph Roesler
676
** Last Modified: 23-mar-03
677
** Returns      : void!
678
** Notes        : -
679
*******************************************************************************/
680
681
static void
682
DisplaySelectedModerationMask(SK_AC *pAC) {
683
684
    if (pAC->DynIrqModInfo.DisplayStats) {
685
        if (pAC->DynIrqModInfo.IntModTypeSelect != C_INT_MOD_NONE) {
686
            switch (pAC->DynIrqModInfo.MaskIrqModeration) {
687
                case IRQ_MASK_TX_ONLY: 
688
                   printk("Only Tx-interrupts are moderated\n");
689
                   break;
690
                case IRQ_MASK_RX_ONLY: 
691
                   printk("Only Rx-interrupts are moderated\n");
692
                   break;
693
                case IRQ_MASK_SP_ONLY: 
694
                   printk("Only special-interrupts are moderated\n");
695
                   break;
696
                case IRQ_MASK_TX_RX: 
697
                   printk("Tx- and Rx-interrupts are moderated\n");
698
                   break;
699
                case IRQ_MASK_SP_RX: 
700
                   printk("Special- and Rx-interrupts are moderated\n");
701
                   break;
702
                case IRQ_MASK_SP_TX: 
703
                   printk("Special- and Tx-interrupts are moderated\n");
704
                   break;
705
                case IRQ_MASK_RX_TX_SP:
706
                   printk("All Rx-, Tx and special-interrupts are moderated\n");
707
                   break;
708
                default:
709
                   printk("Don't know what is moderated\n");
710
                   break;
711
            }
712
        } else {
713
            printk("No specific interrupts masked for moderation\n");
714
        }
715
    } 
716
}
717
718
/*******************************************************************************
719
** Function     : DisplayDescrRatio
720
** Description  : Like the name states...
721
** Programmer   : Ralph Roesler
722
** Last Modified: 23-mar-03
723
** Returns      : void!
724
** Notes        : -
725
*******************************************************************************/
726
727
static void
728
DisplayDescrRatio(SK_AC *pAC) {
729
    int TotalMaxNbrDescr = 0;
730
731
    if (pAC->DynIrqModInfo.DisplayStats) {
732
        TotalMaxNbrDescr = pAC->RxDescrPerRing * GetRxCalls(pAC);
733
        printk("Ratio descriptors: %i/%i\n",
734
               M_DIMINFO.NbrProcessedDescr, TotalMaxNbrDescr);
735
    }
736
}
737
738
/*******************************************************************************
739
**
740
** End of file
741
**
742
*******************************************************************************/
(-)linux/drivers/net/sk98lin/skethtool.c (-301 / +1081 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:        skethtool.c
3
 * Name:        skethtool.c
4
 * Project:     GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:     GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:     $Revision: 1.7 $
5
 * Version:     $Revision: 1.3.2.6 $
6
 * Date:        $Date: 2004/09/29 13:32:07 $
6
 * Date:        $Date: 2005/03/30 08:57:58 $
7
 * Purpose:     All functions regarding ethtool handling
7
 * Purpose:     All functions regarding ethtool handling
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 36-45 Link Here
36
#include "h/skdrv1st.h"
36
#include "h/skdrv1st.h"
37
#include "h/skdrv2nd.h"
37
#include "h/skdrv2nd.h"
38
#include "h/skversion.h"
38
#include "h/skversion.h"
39
40
#include <linux/ethtool.h>
39
#include <linux/ethtool.h>
40
#include <linux/module.h>
41
#include <linux/timer.h>
41
#include <linux/timer.h>
42
#include <linux/delay.h>
42
43
/******************************************************************************
44
 *
45
 * External Functions and Data
46
 *
47
 *****************************************************************************/
48
49
extern void SkDimDisableModeration(SK_AC *pAC, int CurrentModeration);
50
extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);
43
51
44
/******************************************************************************
52
/******************************************************************************
45
 *
53
 *
Lines 47-52 Link Here
47
 *
55
 *
48
 *****************************************************************************/
56
 *****************************************************************************/
49
57
58
#ifndef ETHT_STATSTRING_LEN
59
#define ETHT_STATSTRING_LEN 32
60
#endif
61
62
#define SK98LIN_STAT(m)	sizeof(((SK_AC *)0)->m),offsetof(SK_AC, m)
63
50
#define SUPP_COPPER_ALL (SUPPORTED_10baseT_Half  | SUPPORTED_10baseT_Full  | \
64
#define SUPP_COPPER_ALL (SUPPORTED_10baseT_Half  | SUPPORTED_10baseT_Full  | \
51
                         SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | \
65
                         SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | \
52
                         SUPPORTED_1000baseT_Half| SUPPORTED_1000baseT_Full| \
66
                         SUPPORTED_1000baseT_Half| SUPPORTED_1000baseT_Full| \
Lines 65-70 Link Here
65
                         ADVERTISED_FIBRE          | \
79
                         ADVERTISED_FIBRE          | \
66
                         ADVERTISED_Autoneg)
80
                         ADVERTISED_Autoneg)
67
81
82
/******************************************************************************
83
 *
84
 * Local Function Prototypes
85
 *
86
 *****************************************************************************/
87
88
#ifdef ETHTOOL_GSET
89
static void getSettings(SK_AC *pAC, int port, struct ethtool_cmd *ecmd);
90
#endif
91
#ifdef ETHTOOL_SSET
92
static int setSettings(SK_AC *pAC, int port, struct ethtool_cmd *ecmd);
93
#endif
94
#ifdef ETHTOOL_GPAUSEPARAM
95
static void getPauseParams(SK_AC *pAC, int port, struct ethtool_pauseparam *epause);
96
#endif
97
#ifdef ETHTOOL_SPAUSEPARAM
98
static int setPauseParams(SK_AC *pAC, int port, struct ethtool_pauseparam *epause);
99
#endif
100
#ifdef ETHTOOL_GDRVINFO
101
static void getDriverInfo(SK_AC *pAC, int port, struct ethtool_drvinfo *edrvinfo);
102
#endif
103
#ifdef ETHTOOL_PHYS_ID
104
static int startLocateNIC(SK_AC *pAC, int port, struct ethtool_value *blinkSecs);
105
static void toggleLeds(unsigned long ptr);
106
#endif
107
#ifdef ETHTOOL_GCOALESCE
108
static void getModerationParams(SK_AC *pAC, int port, struct ethtool_coalesce *ecoalesc);
109
#endif
110
#ifdef ETHTOOL_SCOALESCE
111
static int setModerationParams(SK_AC *pAC, int port, struct ethtool_coalesce *ecoalesc);
112
#endif
113
#ifdef ETHTOOL_GWOL
114
static void getWOLsettings(SK_AC *pAC, int port, struct ethtool_wolinfo *ewol);
115
#endif
116
#ifdef ETHTOOL_SWOL
117
static int setWOLsettings(SK_AC *pAC, int port, struct ethtool_wolinfo *ewol);
118
#endif
119
120
static int getPortNumber(struct net_device *netdev, struct ifreq *ifr);
121
122
/******************************************************************************
123
 *
124
 * Local Variables
125
 *
126
 *****************************************************************************/
127
128
struct sk98lin_stats {
129
	char stat_string[ETHT_STATSTRING_LEN];
130
	int  sizeof_stat;
131
	int  stat_offset;
132
};
133
134
static struct sk98lin_stats sk98lin_etht_stats_port0[] = {
135
	{ "rx_packets" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxOkCts) },
136
	{ "tx_packets" , SK98LIN_STAT(PnmiStruct.Stat[0].StatTxOkCts) },
137
	{ "rx_bytes" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxOctetsOkCts) },
138
	{ "tx_bytes" , SK98LIN_STAT(PnmiStruct.Stat[0].StatTxOctetsOkCts) },
139
	{ "rx_errors" , SK98LIN_STAT(PnmiStruct.InErrorsCts) },
140
	{ "tx_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatTxSingleCollisionCts) },
141
	{ "rx_dropped" , SK98LIN_STAT(PnmiStruct.RxNoBufCts) },
142
	{ "tx_dropped" , SK98LIN_STAT(PnmiStruct.TxNoBufCts) },
143
	{ "multicasts" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxMulticastOkCts) },
144
	{ "collisions" , SK98LIN_STAT(PnmiStruct.Stat[0].StatTxSingleCollisionCts) },
145
	{ "rx_length_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxRuntCts) },
146
	{ "rx_buffer_overflow_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxFifoOverflowCts) },
147
	{ "rx_crc_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxFcsCts) },
148
	{ "rx_frame_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxFramingCts) },
149
	{ "rx_too_short_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxShortsCts) },
150
	{ "rx_too_long_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxTooLongCts) },
151
	{ "rx_carrier_extension_errors", SK98LIN_STAT(PnmiStruct.Stat[0].StatRxCextCts) },
152
	{ "rx_symbol_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxSymbolCts) },
153
	{ "rx_llc_mac_size_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxIRLengthCts) },
154
	{ "rx_carrier_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxCarrierCts) },
155
	{ "rx_jabber_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxJabberCts) },
156
	{ "rx_missed_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatRxMissedCts) },
157
	{ "tx_abort_collision_errors" , SK98LIN_STAT(stats.tx_aborted_errors) },
158
	{ "tx_carrier_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatTxCarrierCts) },
159
	{ "tx_buffer_underrun_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatTxFifoUnderrunCts) },
160
	{ "tx_heartbeat_errors" , SK98LIN_STAT(PnmiStruct.Stat[0].StatTxCarrierCts) } ,
161
	{ "tx_window_errors" , SK98LIN_STAT(stats.tx_window_errors) }
162
};
163
164
static struct sk98lin_stats sk98lin_etht_stats_port1[] = {
165
	{ "rx_packets" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxOkCts) },
166
	{ "tx_packets" , SK98LIN_STAT(PnmiStruct.Stat[1].StatTxOkCts) },
167
	{ "rx_bytes" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxOctetsOkCts) },
168
	{ "tx_bytes" , SK98LIN_STAT(PnmiStruct.Stat[1].StatTxOctetsOkCts) },
169
	{ "rx_errors" , SK98LIN_STAT(PnmiStruct.InErrorsCts) },
170
	{ "tx_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatTxSingleCollisionCts) },
171
	{ "rx_dropped" , SK98LIN_STAT(PnmiStruct.RxNoBufCts) },
172
	{ "tx_dropped" , SK98LIN_STAT(PnmiStruct.TxNoBufCts) },
173
	{ "multicasts" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxMulticastOkCts) },
174
	{ "collisions" , SK98LIN_STAT(PnmiStruct.Stat[1].StatTxSingleCollisionCts) },
175
	{ "rx_length_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxRuntCts) },
176
	{ "rx_buffer_overflow_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxFifoOverflowCts) },
177
	{ "rx_crc_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxFcsCts) },
178
	{ "rx_frame_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxFramingCts) },
179
	{ "rx_too_short_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxShortsCts) },
180
	{ "rx_too_long_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxTooLongCts) },
181
	{ "rx_carrier_extension_errors", SK98LIN_STAT(PnmiStruct.Stat[1].StatRxCextCts) },
182
	{ "rx_symbol_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxSymbolCts) },
183
	{ "rx_llc_mac_size_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxIRLengthCts) },
184
	{ "rx_carrier_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxCarrierCts) },
185
	{ "rx_jabber_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxJabberCts) },
186
	{ "rx_missed_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatRxMissedCts) },
187
	{ "tx_abort_collision_errors" , SK98LIN_STAT(stats.tx_aborted_errors) },
188
	{ "tx_carrier_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatTxCarrierCts) },
189
	{ "tx_buffer_underrun_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatTxFifoUnderrunCts) },
190
	{ "tx_heartbeat_errors" , SK98LIN_STAT(PnmiStruct.Stat[1].StatTxCarrierCts) } ,
191
	{ "tx_window_errors" , SK98LIN_STAT(stats.tx_window_errors) }
192
};
193
194
#define SK98LIN_STATS_LEN sizeof(sk98lin_etht_stats_port0) / sizeof(struct sk98lin_stats)
195
196
static int nbrBlinkQuarterSeconds;
197
static int currentPortIndex;
198
static SK_BOOL isLocateNICrunning   = SK_FALSE;
199
static SK_BOOL isDualNetCard        = SK_FALSE;
200
static SK_BOOL doSwitchLEDsOn       = SK_FALSE;
201
static SK_BOOL boardWasDown[2]      = { SK_FALSE, SK_FALSE };
202
static struct timer_list locateNICtimer;
203
204
/******************************************************************************
205
 *
206
 * Global Functions
207
 *
208
 *****************************************************************************/
209
210
/*****************************************************************************
211
 *
212
 * 	SkEthIoctl - IOCTL entry point for all ethtool queries
213
 *
214
 * Description:
215
 *	Any IOCTL request that has to deal with the ethtool command tool is
216
 *	dispatched via this function.
217
 *
218
 * Returns:
219
 *	==0:	everything fine, no error
220
 *	!=0:	the return value is the error code of the failure 
221
 */
222
int SkEthIoctl(
223
struct net_device *netdev,  /* the pointer to netdev structure       */
224
struct ifreq      *ifr)     /* what interface the request refers to? */
225
{
226
	DEV_NET             *pNet        = (DEV_NET*) netdev->priv;
227
	SK_AC               *pAC         = pNet->pAC;
228
	void                *pAddr       = ifr->ifr_data;
229
	int                  port        = getPortNumber(netdev, ifr);
230
	SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;
231
	SK_U32               Size        = sizeof(SK_PNMI_STRUCT_DATA);
232
	SK_U32               cmd;
233
	struct sk98lin_stats *sk98lin_etht_stats = 
234
		(port == 0) ? sk98lin_etht_stats_port0 : sk98lin_etht_stats_port1;
235
236
        if (get_user(cmd, (uint32_t *) pAddr)) {
237
                return -EFAULT;
238
	}
239
240
	switch(cmd) {
241
#ifdef ETHTOOL_GSET
242
	case ETHTOOL_GSET: {
243
		struct ethtool_cmd ecmd = { ETHTOOL_GSET };
244
		getSettings(pAC, port, &ecmd);
245
		if(copy_to_user(pAddr, &ecmd, sizeof(ecmd))) {
246
			return -EFAULT;
247
		}
248
		return 0;
249
	}
250
	break;
251
#endif
252
#ifdef ETHTOOL_SSET
253
	case ETHTOOL_SSET: {
254
		struct ethtool_cmd ecmd;
255
		if(copy_from_user(&ecmd, pAddr, sizeof(ecmd))) {
256
			return -EFAULT;
257
		}
258
		return setSettings(pAC, port, &ecmd);
259
	}
260
	break;
261
#endif
262
#ifdef ETHTOOL_GDRVINFO
263
	case ETHTOOL_GDRVINFO: {
264
		struct ethtool_drvinfo drvinfo = { ETHTOOL_GDRVINFO };
265
		getDriverInfo(pAC, port, &drvinfo);
266
		if(copy_to_user(pAddr, &drvinfo, sizeof(drvinfo))) {
267
			return -EFAULT;
268
		}
269
		return 0;
270
	}
271
	break;
272
#endif
273
#ifdef ETHTOOL_GSTRINGS
274
	case ETHTOOL_GSTRINGS: {
275
		struct ethtool_gstrings gstrings = { ETHTOOL_GSTRINGS };
276
		char *strings = NULL;
277
		int err = 0;
278
		if(copy_from_user(&gstrings, pAddr, sizeof(gstrings))) {
279
			return -EFAULT;
280
		}
281
		switch(gstrings.string_set) {
282
#ifdef ETHTOOL_GSTATS
283
			case ETH_SS_STATS: {
284
				int i;
285
				gstrings.len = SK98LIN_STATS_LEN;
286
				if ((strings = kmalloc(SK98LIN_STATS_LEN*ETHT_STATSTRING_LEN,GFP_KERNEL)) == NULL) {
287
					return -ENOMEM;
288
				}
289
				for(i=0; i < SK98LIN_STATS_LEN; i++) {
290
					memcpy(&strings[i * ETHT_STATSTRING_LEN],
291
						&(sk98lin_etht_stats[i].stat_string),
292
						ETHT_STATSTRING_LEN);
293
				}
294
			}
295
			break;
296
#endif
297
			default:
298
				return -EOPNOTSUPP;
299
		}
300
		if(copy_to_user(pAddr, &gstrings, sizeof(gstrings))) {
301
			err = -EFAULT;
302
		}
303
		pAddr = (void *) ((unsigned long int) pAddr + offsetof(struct ethtool_gstrings, data));
304
		if(!err && copy_to_user(pAddr, strings, gstrings.len * ETH_GSTRING_LEN)) {
305
			err = -EFAULT;
306
		}
307
		kfree(strings);
308
		return err;
309
	}
310
#endif
311
#ifdef ETHTOOL_GSTATS
312
	case ETHTOOL_GSTATS: {
313
		struct {
314
			struct ethtool_stats eth_stats;
315
			uint64_t data[SK98LIN_STATS_LEN];
316
		} stats = { {ETHTOOL_GSTATS, SK98LIN_STATS_LEN} };
317
		int i;
318
319
		if (netif_running(pAC->dev[port])) {
320
			SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, port);
321
		}
322
		for(i = 0; i < SK98LIN_STATS_LEN; i++) {
323
			if (netif_running(pAC->dev[port])) {
324
				stats.data[i] = (sk98lin_etht_stats[i].sizeof_stat ==
325
					sizeof(uint64_t)) ?
326
					*(uint64_t *)((char *)pAC +
327
						sk98lin_etht_stats[i].stat_offset) :
328
					*(uint32_t *)((char *)pAC +
329
						sk98lin_etht_stats[i].stat_offset);
330
			} else {
331
				stats.data[i] = (sk98lin_etht_stats[i].sizeof_stat ==
332
					sizeof(uint64_t)) ? (uint64_t) 0 : (uint32_t) 0;
333
			}
334
		}
335
		if(copy_to_user(pAddr, &stats, sizeof(stats))) {
336
			return -EFAULT;
337
		}
338
		return 0;
339
	}
340
#endif
341
#ifdef ETHTOOL_PHYS_ID
342
	case ETHTOOL_PHYS_ID: {
343
		struct ethtool_value blinkSecs;
344
		if(copy_from_user(&blinkSecs, pAddr, sizeof(blinkSecs))) {
345
			return -EFAULT;
346
		}
347
		return startLocateNIC(pAC, port, &blinkSecs);
348
	}
349
#endif
350
#ifdef ETHTOOL_GPAUSEPARAM
351
	case ETHTOOL_GPAUSEPARAM: {
352
		struct ethtool_pauseparam epause = { ETHTOOL_GPAUSEPARAM };
353
		getPauseParams(pAC, port, &epause);
354
		if(copy_to_user(pAddr, &epause, sizeof(epause))) {
355
			return -EFAULT;
356
		}
357
		return 0;
358
	}
359
#endif
360
#ifdef ETHTOOL_SPAUSEPARAM
361
	case ETHTOOL_SPAUSEPARAM: {
362
		struct ethtool_pauseparam epause;
363
		if(copy_from_user(&epause, pAddr, sizeof(epause))) {
364
			return -EFAULT;
365
		}
366
		return setPauseParams(pAC, port, &epause);
367
	}
368
#endif
369
#ifdef ETHTOOL_GSG
370
	case ETHTOOL_GSG: {
371
		struct ethtool_value edata = { ETHTOOL_GSG };
372
		edata.data = (netdev->features & NETIF_F_SG) != 0;
373
		if (copy_to_user(pAddr, &edata, sizeof(edata))) {
374
			return -EFAULT;
375
		}
376
		return 0;
377
	}
378
#endif
379
#ifdef ETHTOOL_SSG
380
	case ETHTOOL_SSG: {
381
		struct ethtool_value edata;
382
		if (copy_from_user(&edata, pAddr, sizeof(edata))) {
383
                        return -EFAULT;
384
		}
385
		if (pAC->ChipsetType) { /* Don't handle if Genesis */
386
			if (edata.data) {
387
				netdev->features |= NETIF_F_SG;
388
			} else {
389
				netdev->features &= ~NETIF_F_SG;
390
			}
391
		}
392
		return 0;
393
	}
394
#endif
395
#ifdef ETHTOOL_GRXCSUM
396
	case ETHTOOL_GRXCSUM: {
397
		struct ethtool_value edata = { ETHTOOL_GRXCSUM };
398
		edata.data = pAC->RxPort[port].UseRxCsum;
399
		if (copy_to_user(pAddr, &edata, sizeof(edata))) {
400
			return -EFAULT;
401
		}
402
		return 0;
403
	}
404
#endif
405
#ifdef ETHTOOL_SRXCSUM
406
	case ETHTOOL_SRXCSUM: {
407
		struct ethtool_value edata;
408
		if (copy_from_user(&edata, pAddr, sizeof(edata))) {
409
			return -EFAULT;
410
		}
411
		pAC->RxPort[port].UseRxCsum = edata.data;
412
                return 0;
413
	}
414
#endif
415
#ifdef ETHTOOL_GTXCSUM
416
	case ETHTOOL_GTXCSUM: {
417
		struct ethtool_value edata = { ETHTOOL_GTXCSUM };
418
		edata.data = ((netdev->features & NETIF_F_IP_CSUM) != 0);
419
		if (copy_to_user(pAddr, &edata, sizeof(edata))) {
420
			return -EFAULT;
421
		}
422
		return 0;
423
	}
424
#endif
425
#ifdef ETHTOOL_STXCSUM
426
	case ETHTOOL_STXCSUM: {
427
		struct ethtool_value edata;
428
		if (copy_from_user(&edata, pAddr, sizeof(edata))) {
429
			return -EFAULT;
430
		}
431
		if (pAC->ChipsetType) { /* Don't handle if Genesis */
432
			if (edata.data) {
433
				netdev->features |= NETIF_F_IP_CSUM;
434
			} else {
435
				netdev->features &= ~NETIF_F_IP_CSUM;
436
			}
437
		}
438
		return 0;
439
	}
440
#endif
441
#ifdef ETHTOOL_NWAY_RST
442
	case ETHTOOL_NWAY_RST: {
443
		if(netif_running(netdev)) {
444
			(*netdev->stop)(netdev);
445
			(*netdev->open)(netdev);
446
		}
447
		return 0;
448
	}
449
#endif
450
#ifdef NETIF_F_TSO
451
#ifdef ETHTOOL_GTSO
452
	case ETHTOOL_GTSO: {
453
		struct ethtool_value edata = { ETHTOOL_GTSO };
454
		edata.data = (netdev->features & NETIF_F_TSO) != 0;
455
		if (copy_to_user(pAddr, &edata, sizeof(edata))) {
456
			return -EFAULT;
457
		}
458
		return 0;
459
	}
460
#endif
461
#ifdef ETHTOOL_STSO
462
	case ETHTOOL_STSO: {
463
		struct ethtool_value edata;
464
		if (CHIP_ID_YUKON_2(pAC)) {
465
			if (copy_from_user(&edata, pAddr, sizeof(edata))) {
466
				return -EFAULT;
467
			}
468
			if (edata.data) {
469
				netdev->features |= NETIF_F_TSO;
470
			} else {
471
				netdev->features &= ~NETIF_F_TSO;
472
			}
473
			return 0;
474
		}
475
                return -EOPNOTSUPP;
476
	}
477
#endif
478
#endif
479
#ifdef ETHTOOL_GCOALESCE
480
	case ETHTOOL_GCOALESCE: {
481
		struct ethtool_coalesce ecoalesc = { ETHTOOL_GCOALESCE };
482
		getModerationParams(pAC, port, &ecoalesc);
483
		if(copy_to_user(pAddr, &ecoalesc, sizeof(ecoalesc))) {
484
			return -EFAULT;
485
		}
486
		return 0;
487
	}
488
#endif
489
#ifdef ETHTOOL_SCOALESCE
490
	case ETHTOOL_SCOALESCE: {
491
		struct ethtool_coalesce ecoalesc;
492
		if(copy_from_user(&ecoalesc, pAddr, sizeof(ecoalesc))) {
493
			return -EFAULT;
494
		}
495
		return setModerationParams(pAC, port, &ecoalesc);
496
	}
497
#endif
498
#ifdef ETHTOOL_GWOL
499
	case ETHTOOL_GWOL: {
500
		struct ethtool_wolinfo ewol = { ETHTOOL_GWOL };
501
		getWOLsettings(pAC, port, &ewol);
502
		if(copy_to_user(pAddr, &ewol, sizeof(ewol))) {
503
			return -EFAULT;
504
		}
505
		return 0;
506
	}
507
#endif
508
#ifdef ETHTOOL_SWOL
509
	case ETHTOOL_SWOL: {
510
		struct ethtool_wolinfo ewol;
511
		if(copy_from_user(&ewol, pAddr, sizeof(ewol))) {
512
			return -EFAULT;
513
		}
514
		return setWOLsettings(pAC, port, &ewol);
515
	}
516
#endif
517
        default:
518
                return -EOPNOTSUPP;
519
        }
520
} /* SkEthIoctl() */
68
521
69
/******************************************************************************
522
/******************************************************************************
70
 *
523
 *
Lines 72-77 Link Here
72
 *
525
 *
73
 *****************************************************************************/
526
 *****************************************************************************/
74
527
528
#ifdef ETHTOOL_GSET
75
/*****************************************************************************
529
/*****************************************************************************
76
 *
530
 *
77
 * 	getSettings - retrieves the current settings of the selected adapter
531
 * 	getSettings - retrieves the current settings of the selected adapter
Lines 81-95 Link Here
81
 *	This configuration involves a)speed, b)duplex and c)autoneg plus
535
 *	This configuration involves a)speed, b)duplex and c)autoneg plus
82
 *	a number of other variables.
536
 *	a number of other variables.
83
 *
537
 *
84
 * Returns:    always 0
538
 * Returns:	N/A
85
 *
539
 *
86
 */
540
 */
87
static int getSettings(struct net_device *dev, struct ethtool_cmd *ecmd)
541
static void getSettings(
542
SK_AC              *pAC,  /* pointer to adapter control context      */
543
int                 port, /* the port of the selected adapter        */
544
struct ethtool_cmd *ecmd) /* mandatory command structure for results */
88
{
545
{
89
	const DEV_NET *pNet = netdev_priv(dev);
546
	SK_GEPORT *pPort = &pAC->GIni.GP[port];
90
	int port = pNet->PortNr;
91
	const SK_AC *pAC = pNet->pAC;
92
	const SK_GEPORT *pPort = &pAC->GIni.GP[port];
93
547
94
	static int DuplexAutoNegConfMap[9][3]= {
548
	static int DuplexAutoNegConfMap[9][3]= {
95
		{ -1                     , -1         , -1              },
549
		{ -1                     , -1         , -1              },
Lines 102-107 Link Here
102
		{ SK_LMODE_AUTOSENSE     , -1         , -1              },
556
		{ SK_LMODE_AUTOSENSE     , -1         , -1              },
103
		{ SK_LMODE_INDETERMINATED, -1         , -1              }
557
		{ SK_LMODE_INDETERMINATED, -1         , -1              }
104
	};
558
	};
559
105
	static int SpeedConfMap[6][2] = {
560
	static int SpeedConfMap[6][2] = {
106
		{ 0                       , -1         },
561
		{ 0                       , -1         },
107
		{ SK_LSPEED_AUTO          , -1         },
562
		{ SK_LSPEED_AUTO          , -1         },
Lines 110-115 Link Here
110
		{ SK_LSPEED_1000MBPS      , SPEED_1000 },
565
		{ SK_LSPEED_1000MBPS      , SPEED_1000 },
111
		{ SK_LSPEED_INDETERMINATED, -1         }
566
		{ SK_LSPEED_INDETERMINATED, -1         }
112
	};
567
	};
568
113
	static int AdvSpeedMap[6][2] = {
569
	static int AdvSpeedMap[6][2] = {
114
		{ 0                       , -1         },
570
		{ 0                       , -1         },
115
		{ SK_LSPEED_AUTO          , -1         },
571
		{ SK_LSPEED_AUTO          , -1         },
Lines 137-148 Link Here
137
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
593
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
138
				ecmd->supported &= ~(SUPPORTED_1000baseT_Half);
594
				ecmd->supported &= ~(SUPPORTED_1000baseT_Half);
139
			} 
595
			} 
140
#ifdef CHIP_ID_YUKON_FE
141
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
596
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
142
				ecmd->supported &= ~(SUPPORTED_1000baseT_Half);
597
				ecmd->supported &= ~(SUPPORTED_1000baseT_Half);
143
				ecmd->supported &= ~(SUPPORTED_1000baseT_Full);
598
				ecmd->supported &= ~(SUPPORTED_1000baseT_Full);
144
			}
599
			}
145
#endif
146
		}
600
		}
147
		if (pAC->GIni.GP[0].PLinkSpeed != SK_LSPEED_AUTO) {
601
		if (pAC->GIni.GP[0].PLinkSpeed != SK_LSPEED_AUTO) {
148
			ecmd->advertising = AdvSpeedMap[pPort->PLinkSpeed][1];
602
			ecmd->advertising = AdvSpeedMap[pPort->PLinkSpeed][1];
Lines 152-177 Link Here
152
		} else {
606
		} else {
153
			ecmd->advertising = ecmd->supported;
607
			ecmd->advertising = ecmd->supported;
154
		}
608
		}
155
609
		if (ecmd->autoneg == AUTONEG_ENABLE) {
156
		if (ecmd->autoneg == AUTONEG_ENABLE) 
157
			ecmd->advertising |= ADVERTISED_Autoneg;
610
			ecmd->advertising |= ADVERTISED_Autoneg;
611
		} 
158
	} else {
612
	} else {
159
		ecmd->port        = PORT_FIBRE;
613
		ecmd->port        = PORT_FIBRE;
160
		ecmd->supported   = SUPP_FIBRE_ALL;
614
		ecmd->supported   = (SUPP_FIBRE_ALL);
161
		ecmd->advertising = ADV_FIBRE_ALL;
615
		ecmd->advertising = (ADV_FIBRE_ALL);
162
	}
616
	}
163
	return 0;
164
}
165
166
/*
167
 * MIB infrastructure uses instance value starting at 1
168
 * based on board and port.
169
 */
170
static inline u32 pnmiInstance(const DEV_NET *pNet)
171
{
172
	return 1 + (pNet->pAC->RlmtNets == 2) + pNet->PortNr;
173
}
617
}
618
#endif
174
619
620
#ifdef ETHTOOL_SSET
175
/*****************************************************************************
621
/*****************************************************************************
176
 *
622
 *
177
 *	setSettings - configures the settings of a selected adapter
623
 *	setSettings - configures the settings of a selected adapter
Lines 181-419 Link Here
181
 *	c)autonegotiation.
627
 *	c)autonegotiation.
182
 *
628
 *
183
 * Returns:
629
 * Returns:
184
 *	0:	everything fine, no error
630
 *	==0:	everything fine, no error
185
 *	<0:	the return value is the error code of the failure 
631
 *	!=0:	the return value is the error code of the failure 
186
 */
632
 */
187
static int setSettings(struct net_device *dev, struct ethtool_cmd *ecmd)
633
static int setSettings(
634
SK_AC              *pAC,  /* pointer to adapter control context    */
635
int                 port, /* the port of the selected adapter      */
636
struct ethtool_cmd *ecmd) /* command structure containing settings */
188
{
637
{
189
	DEV_NET *pNet = netdev_priv(dev);
638
	DEV_NET     *pNet  = (DEV_NET *) pAC->dev[port]->priv;
190
	SK_AC *pAC = pNet->pAC;
639
	SK_U32       Instance;
191
	u32 instance;
640
	char         Buf[4];
192
	char buf[4];
641
	unsigned int Len = 1;
193
	int len = 1;
642
	int Ret;
194
643
195
	if (ecmd->speed != SPEED_10 && ecmd->speed != SPEED_100 
644
	if (port == 0) {
196
	    && ecmd->speed != SPEED_1000)
645
		Instance = (pAC->RlmtNets == 2) ? 1 : 2;
197
		return -EINVAL;
646
	} else {
198
647
		Instance = (pAC->RlmtNets == 2) ? 2 : 3;
199
	if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
648
	}
200
		return -EINVAL;
201
649
202
	if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE)
650
	if (((ecmd->autoneg == AUTONEG_DISABLE) || (ecmd->autoneg == AUTONEG_ENABLE)) &&
203
		return -EINVAL;
651
	    ((ecmd->duplex == DUPLEX_FULL) || (ecmd->duplex == DUPLEX_HALF))) {
652
		if (ecmd->autoneg == AUTONEG_DISABLE) {
653
			if (ecmd->duplex == DUPLEX_FULL) { 
654
				*Buf = (char) SK_LMODE_FULL;
655
			} else {
656
				*Buf = (char) SK_LMODE_HALF;
657
			}
658
		} else {
659
			if (ecmd->duplex == DUPLEX_FULL) { 
660
				*Buf = (char) SK_LMODE_AUTOFULL;
661
			} else {
662
				*Buf = (char) SK_LMODE_AUTOHALF;
663
			}
664
		}
204
665
205
	if (ecmd->autoneg == AUTONEG_DISABLE)
666
		Ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_LINK_MODE, 
206
		*buf = (ecmd->duplex == DUPLEX_FULL) 
667
					&Buf, &Len, Instance, pNet->NetNr);
207
			? SK_LMODE_FULL : SK_LMODE_HALF;
208
	else
209
		*buf = (ecmd->duplex == DUPLEX_FULL) 
210
			? SK_LMODE_AUTOFULL : SK_LMODE_AUTOHALF;
211
	
668
	
212
	instance = pnmiInstance(pNet);
669
		if (Ret != SK_PNMI_ERR_OK) {
213
	if (SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_LINK_MODE, 
670
			return -EINVAL;
214
			   &buf, &len, instance, pNet->NetNr) != SK_PNMI_ERR_OK)
671
		}
215
		return -EINVAL;
216
217
	switch(ecmd->speed) {
218
	case SPEED_1000:
219
		*buf = SK_LSPEED_1000MBPS;
220
		break;
221
	case SPEED_100:
222
		*buf = SK_LSPEED_100MBPS;
223
		break;
224
	case SPEED_10:
225
		*buf = SK_LSPEED_10MBPS;
226
	}
672
	}
227
673
228
	if (SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_SPEED_MODE, 
674
	if ((ecmd->speed == SPEED_1000) ||
229
			 &buf, &len, instance, pNet->NetNr) != SK_PNMI_ERR_OK)
675
	    (ecmd->speed == SPEED_100)  || 
230
		return -EINVAL;
676
	    (ecmd->speed == SPEED_10)) {
677
		if (ecmd->speed == SPEED_1000) {
678
			*Buf = (char) SK_LSPEED_1000MBPS;
679
		} else if (ecmd->speed == SPEED_100) {
680
			*Buf = (char) SK_LSPEED_100MBPS;
681
		} else {
682
			*Buf = (char) SK_LSPEED_10MBPS;
683
		}
231
684
685
		Ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_SPEED_MODE, 
686
					&Buf, &Len, Instance, pNet->NetNr);
687
	
688
		if (Ret != SK_PNMI_ERR_OK) {
689
			return -EINVAL;
690
		}
691
	} else {
692
		return -EINVAL;
693
	}
232
	return 0;
694
	return 0;
233
}
695
}
696
#endif
234
697
698
#ifdef ETHTOOL_GPAUSEPARAM
235
/*****************************************************************************
699
/*****************************************************************************
236
 *
700
 *
237
 * 	getDriverInfo - returns generic driver and adapter information
701
 * 	getPauseParams - retrieves the pause parameters
238
 *
702
 *
239
 * Description:
703
 * Description:
240
 *	Generic driver information is returned via this function, such as
704
 *	All current pause parameters of a selected adapter are placed 
241
 *	the name of the driver, its version and and firmware version.
705
 *	in the passed ethtool_pauseparam structure and are returned.
242
 *	In addition to this, the location of the selected adapter is 
706
 *
243
 *	returned as a bus info string (e.g. '01:05.0').
244
 *	
245
 * Returns:	N/A
707
 * Returns:	N/A
246
 *
708
 *
247
 */
709
 */
248
static void getDriverInfo(struct net_device *dev, struct ethtool_drvinfo *info)
710
static void getPauseParams(
711
SK_AC                     *pAC,    /* pointer to adapter control context */
712
int                        port,   /* the port of the selected adapter   */
713
struct ethtool_pauseparam *epause) /* pause parameter struct for result  */
249
{
714
{
250
	const DEV_NET	*pNet = netdev_priv(dev);
715
	SK_GEPORT *pPort            = &pAC->GIni.GP[port];
251
	const SK_AC *pAC = pNet->pAC;
252
	char vers[32];
253
254
	snprintf(vers, sizeof(vers)-1, VER_STRING "(v%d.%d)",
255
		(pAC->GIni.GIPciHwRev >> 4) & 0xf, pAC->GIni.GIPciHwRev & 0xf);
256
257
	strlcpy(info->driver, DRIVER_FILE_NAME, sizeof(info->driver));
258
	strcpy(info->version, vers);
259
	strcpy(info->fw_version, "N/A");
260
	strlcpy(info->bus_info, pAC->PciDev->slot_name, ETHTOOL_BUSINFO_LEN);
261
}
262
263
/*
264
 * Ethtool statistics support.
265
 */
266
static const char StringsStats[][ETH_GSTRING_LEN] = {
267
	"rx_packets",	"tx_packets",
268
	"rx_bytes",	"tx_bytes",
269
	"rx_errors",	"tx_errors",	
270
	"rx_dropped",	"tx_dropped",
271
	"multicasts",	"collisions",	
272
	"rx_length_errors",		"rx_buffer_overflow_errors",
273
	"rx_crc_errors",		"rx_frame_errors",
274
	"rx_too_short_errors",		"rx_too_long_errors",
275
	"rx_carrier_extension_errors",	"rx_symbol_errors",
276
	"rx_llc_mac_size_errors",	"rx_carrier_errors",	
277
	"rx_jabber_errors",		"rx_missed_errors",
278
	"tx_abort_collision_errors",	"tx_carrier_errors",
279
	"tx_buffer_underrun_errors",	"tx_heartbeat_errors",
280
	"tx_window_errors",
281
};
282
716
283
static int getStatsCount(struct net_device *dev)
717
	epause->rx_pause = 0;
284
{
718
	epause->tx_pause = 0;
285
	return ARRAY_SIZE(StringsStats);
719
720
	if (pPort->PFlowCtrlMode == SK_FLOW_MODE_LOC_SEND) {
721
		epause->tx_pause = 1;
722
	} 
723
	if ((pPort->PFlowCtrlMode == SK_FLOW_MODE_SYMMETRIC) ||
724
	    (pPort->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM)) {
725
		epause->tx_pause = 1;
726
		epause->rx_pause = 1;
727
	}
728
729
	if ((epause->rx_pause == 0) && (epause->tx_pause == 0)) {
730
		epause->autoneg = SK_FALSE;
731
	} else {
732
		epause->autoneg = SK_TRUE;
733
	}
286
}
734
}
735
#endif
287
736
288
static void getStrings(struct net_device *dev, u32 stringset, u8 *data)
737
#ifdef ETHTOOL_SPAUSEPARAM
738
/*****************************************************************************
739
 *
740
 *	setPauseParams - configures the pause parameters of an adapter
741
 *
742
 * Description:
743
 *	This function sets the Rx or Tx pause parameters 
744
 *
745
 * Returns:
746
 *	==0:	everything fine, no error
747
 *	!=0:	the return value is the error code of the failure 
748
 */
749
static int setPauseParams(
750
SK_AC                     *pAC,    /* pointer to adapter control context */
751
int                        port,   /* the port of the selected adapter   */
752
struct ethtool_pauseparam *epause) /* pause parameter struct with params */
289
{
753
{
290
	switch(stringset) {
754
	SK_GEPORT *pPort            = &pAC->GIni.GP[port];
291
	case ETH_SS_STATS:
755
	DEV_NET   *pNet             = (DEV_NET *) pAC->dev[port]->priv;
292
		memcpy(data, *StringsStats, sizeof(StringsStats));
756
	int        PrevSpeedVal     = pPort->PLinkSpeedUsed;
293
		break;
757
758
	SK_U32         Instance;
759
	char           Buf[4];
760
	int            Ret;
761
	SK_BOOL        prevAutonegValue = SK_TRUE;
762
	int            prevTxPause      = 0;
763
	int            prevRxPause      = 0;
764
	unsigned int   Len              = 1;
765
766
        if (port == 0) {
767
                Instance = (pAC->RlmtNets == 2) ? 1 : 2;
768
        } else {
769
                Instance = (pAC->RlmtNets == 2) ? 2 : 3;
770
        }
771
772
	/*
773
	** we have to determine the current settings to see if 
774
	** the operator requested any modification of the flow 
775
	** control parameters...
776
	*/
777
	if (pPort->PFlowCtrlMode == SK_FLOW_MODE_LOC_SEND) {
778
		prevTxPause = 1;
779
	} 
780
	if ((pPort->PFlowCtrlMode == SK_FLOW_MODE_SYMMETRIC) ||
781
	    (pPort->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM)) {
782
		prevTxPause = 1;
783
		prevRxPause = 1;
294
	}
784
	}
295
}
296
785
297
static void getEthtoolStats(struct net_device *dev,
786
	if ((prevRxPause == 0) && (prevTxPause == 0)) {
298
			    struct ethtool_stats *stats, u64 *data)
787
		prevAutonegValue = SK_FALSE;
299
{
788
	}
300
	const DEV_NET	*pNet = netdev_priv(dev);
789
301
	const SK_AC *pAC = pNet->pAC;
790
302
	const SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;
791
	/*
303
792
	** perform modifications regarding the changes 
304
	*data++ = pPnmiStruct->Stat[0].StatRxOkCts;
793
	** requested by the operator
305
	*data++ = pPnmiStruct->Stat[0].StatTxOkCts;
794
	*/
306
	*data++ = pPnmiStruct->Stat[0].StatRxOctetsOkCts;
795
	if (epause->autoneg != prevAutonegValue) {
307
	*data++ = pPnmiStruct->Stat[0].StatTxOctetsOkCts;
796
		if (epause->autoneg == AUTONEG_DISABLE) {
308
	*data++ = pPnmiStruct->InErrorsCts;
797
			*Buf = (char) SK_FLOW_MODE_NONE;
309
	*data++ = pPnmiStruct->Stat[0].StatTxSingleCollisionCts;
798
		} else {
310
	*data++ = pPnmiStruct->RxNoBufCts;
799
			*Buf = (char) SK_FLOW_MODE_SYMMETRIC;
311
	*data++ = pPnmiStruct->TxNoBufCts;
800
		}
312
	*data++ = pPnmiStruct->Stat[0].StatRxMulticastOkCts;
801
	} else {
313
	*data++ = pPnmiStruct->Stat[0].StatTxSingleCollisionCts;
802
		if(epause->rx_pause && epause->tx_pause) {
314
	*data++ = pPnmiStruct->Stat[0].StatRxRuntCts;
803
			*Buf = (char) SK_FLOW_MODE_SYMMETRIC;
315
	*data++ = pPnmiStruct->Stat[0].StatRxFifoOverflowCts;
804
		} else if (epause->rx_pause && !epause->tx_pause) {
316
	*data++ = pPnmiStruct->Stat[0].StatRxFcsCts;
805
			*Buf = (char) SK_FLOW_MODE_SYM_OR_REM;
317
	*data++ = pPnmiStruct->Stat[0].StatRxFramingCts;
806
		} else if(!epause->rx_pause && epause->tx_pause) {
318
	*data++ = pPnmiStruct->Stat[0].StatRxShortsCts;
807
			*Buf = (char) SK_FLOW_MODE_LOC_SEND;
319
	*data++ = pPnmiStruct->Stat[0].StatRxTooLongCts;
808
		} else {
320
	*data++ = pPnmiStruct->Stat[0].StatRxCextCts;
809
			*Buf = (char) SK_FLOW_MODE_NONE;
321
	*data++ = pPnmiStruct->Stat[0].StatRxSymbolCts;
810
		}
322
	*data++ = pPnmiStruct->Stat[0].StatRxIRLengthCts;
811
	}
323
	*data++ = pPnmiStruct->Stat[0].StatRxCarrierCts;
324
	*data++ = pPnmiStruct->Stat[0].StatRxJabberCts;
325
	*data++ = pPnmiStruct->Stat[0].StatRxMissedCts;
326
	*data++ = pAC->stats.tx_aborted_errors;
327
	*data++ = pPnmiStruct->Stat[0].StatTxCarrierCts;
328
	*data++ = pPnmiStruct->Stat[0].StatTxFifoUnderrunCts;
329
	*data++ = pPnmiStruct->Stat[0].StatTxCarrierCts;
330
	*data++ = pAC->stats.tx_window_errors;
331
}
332
812
813
	Ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_FLOWCTRL_MODE,
814
			&Buf, &Len, Instance, pNet->NetNr);
333
815
816
	if (Ret != SK_PNMI_ERR_OK) {
817
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_CTRL,
818
		("ethtool (sk98lin): error changing rx/tx pause (%i)\n", Ret));
819
	}  else {
820
		Len = 1; /* set buffer length to correct value */
821
	}
822
823
	/*
824
	** It may be that autoneg has been disabled! Therefore
825
	** set the speed to the previously used value...
826
	*/
827
	*Buf = (char) PrevSpeedVal;
828
829
	Ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_SPEED_MODE, 
830
			&Buf, &Len, Instance, pNet->NetNr);
831
832
	if (Ret != SK_PNMI_ERR_OK) {
833
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_CTRL,
834
		("ethtool (sk98lin): error setting speed (%i)\n", Ret));
835
	}
836
        return 0;
837
}
838
#endif
839
840
#ifdef ETHTOOL_GCOALESCE
334
/*****************************************************************************
841
/*****************************************************************************
335
 *
842
 *
336
 * 	toggleLeds - Changes the LED state of an adapter
843
 * 	getModerationParams - retrieves the IRQ moderation settings 
337
 *
844
 *
338
 * Description:
845
 * Description:
339
 *	This function changes the current state of all LEDs of an adapter so
846
 *	All current IRQ moderation settings of a selected adapter are placed 
340
 *	that it can be located by a user. 
847
 *	in the passed ethtool_coalesce structure and are returned.
341
 *
848
 *
342
 * Returns:	N/A
849
 * Returns:	N/A
343
 *
850
 *
344
 */
851
 */
345
static void toggleLeds(DEV_NET *pNet, int on)
852
static void getModerationParams(
853
SK_AC                   *pAC,      /* pointer to adapter control context */
854
int                      port,     /* the port of the selected adapter   */
855
struct ethtool_coalesce *ecoalesc) /* IRQ moderation struct for results  */
346
{
856
{
347
	SK_AC *pAC = pNet->pAC;
857
	DIM_INFO *Info = &pAC->DynIrqModInfo;
348
	int port = pNet->PortNr;
858
	SK_BOOL UseTxIrqModeration = SK_FALSE;
349
	void __iomem *io = pAC->IoBase;
859
	SK_BOOL UseRxIrqModeration = SK_FALSE;
350
860
351
	if (pAC->GIni.GIGenesis) {
861
	if (Info->IntModTypeSelect != C_INT_MOD_NONE) {
352
		SK_OUT8(io, MR_ADDR(port,LNK_LED_REG), 
862
		if (CHIP_ID_YUKON_2(pAC)) {
353
			on ? SK_LNK_ON : SK_LNK_OFF);
863
			UseRxIrqModeration = SK_TRUE;
354
		SkGeYellowLED(pAC, io, 
864
			UseTxIrqModeration = SK_TRUE;
355
			      on ? (LED_ON >> 1) : (LED_OFF >> 1));
865
		} else {
356
		SkGeXmitLED(pAC, io, MR_ADDR(port,RX_LED_INI),
866
			if ((Info->MaskIrqModeration == IRQ_MASK_RX_ONLY) ||
357
			    on ? SK_LED_TST : SK_LED_DIS);
867
			    (Info->MaskIrqModeration == IRQ_MASK_SP_RX)   ||
358
868
			    (Info->MaskIrqModeration == IRQ_MASK_RX_TX_SP)) {
359
		if (pAC->GIni.GP[port].PhyType == SK_PHY_BCOM)
869
				UseRxIrqModeration = SK_TRUE;
360
			SkXmPhyWrite(pAC, io, port, PHY_BCOM_P_EXT_CTRL, 
870
			}
361
				     on ? PHY_B_PEC_LED_ON : PHY_B_PEC_LED_OFF);
871
			if ((Info->MaskIrqModeration == IRQ_MASK_TX_ONLY) ||
362
		else if (pAC->GIni.GP[port].PhyType == SK_PHY_LONE)
872
			    (Info->MaskIrqModeration == IRQ_MASK_SP_TX)   ||
363
			SkXmPhyWrite(pAC, io, port, PHY_LONE_LED_CFG,
873
			    (Info->MaskIrqModeration == IRQ_MASK_RX_TX_SP)) {
364
				     on ? 0x0800 : PHY_L_LC_LEDT);
874
				UseTxIrqModeration = SK_TRUE;
365
		else
875
			}
366
			SkGeXmitLED(pAC, io, MR_ADDR(port,TX_LED_INI),
876
		}
367
				    on ? SK_LED_TST : SK_LED_DIS);
368
	} else {
369
		const u16 YukLedOn = (PHY_M_LED_MO_DUP(MO_LED_ON)  |
370
				      PHY_M_LED_MO_10(MO_LED_ON)   |
371
				      PHY_M_LED_MO_100(MO_LED_ON)  |
372
				      PHY_M_LED_MO_1000(MO_LED_ON) | 
373
				      PHY_M_LED_MO_RX(MO_LED_ON));
374
		const u16  YukLedOff = (PHY_M_LED_MO_DUP(MO_LED_OFF)  |
375
					PHY_M_LED_MO_10(MO_LED_OFF)   |
376
					PHY_M_LED_MO_100(MO_LED_OFF)  |
377
					PHY_M_LED_MO_1000(MO_LED_OFF) | 
378
					PHY_M_LED_MO_RX(MO_LED_OFF));
379
	
380
877
381
		SkGmPhyWrite(pAC,io,port,PHY_MARV_LED_CTRL,0);
878
		if (UseRxIrqModeration) {
382
		SkGmPhyWrite(pAC,io,port,PHY_MARV_LED_OVER, 
879
			ecoalesc->rx_coalesce_usecs = 1000000 / Info->MaxModIntsPerSec;
383
			     on ? YukLedOn : YukLedOff);
880
		}
881
		if (UseTxIrqModeration) {
882
			ecoalesc->tx_coalesce_usecs = 1000000 / Info->MaxModIntsPerSec;
883
		}
884
		if (Info->IntModTypeSelect == C_INT_MOD_DYNAMIC) {
885
			ecoalesc->rate_sample_interval = Info->DynIrqModSampleInterval; 
886
			if (UseRxIrqModeration) {
887
				ecoalesc->use_adaptive_rx_coalesce = 1;
888
				ecoalesc->rx_coalesce_usecs_low = 
889
					1000000 / Info->MaxModIntsPerSecLowerLimit;
890
				ecoalesc->rx_coalesce_usecs_high = 
891
					1000000 / Info->MaxModIntsPerSecUpperLimit;
892
			}
893
			if (UseTxIrqModeration) {
894
				ecoalesc->use_adaptive_tx_coalesce = 1;
895
				ecoalesc->tx_coalesce_usecs_low = 
896
					1000000 / Info->MaxModIntsPerSecLowerLimit;
897
				ecoalesc->tx_coalesce_usecs_high = 
898
					1000000 / Info->MaxModIntsPerSecUpperLimit;
899
			}
900
		}
384
	}
901
	}
385
}
902
}
903
#endif
386
904
905
#ifdef ETHTOOL_SCOALESCE
387
/*****************************************************************************
906
/*****************************************************************************
388
 *
907
 *
389
 * 	skGeBlinkTimer - Changes the LED state of an adapter
908
 *	setModerationParams - configures the IRQ moderation of an adapter
390
 *
909
 *
391
 * Description:
910
 * Description:
392
 *	This function changes the current state of all LEDs of an adapter so
911
 *	Depending on the desired IRQ moderation parameters, either a) static,
393
 *	that it can be located by a user. If the requested time interval for
912
 *	b) dynamic or c) no moderation is configured. 
394
 *	this test has elapsed, this function cleans up everything that was 
913
 *
395
 *	temporarily setup during the locate NIC test. This involves of course
914
 * Returns:
396
 *	also closing or opening any adapter so that the initial board state 
915
 *	==0:	everything fine, no error
397
 *	is recovered.
916
 *	!=0:	the return value is the error code of the failure 
917
 *
918
 * Notes:
919
 *	The supported timeframe for the coalesced interrupts ranges from
920
 *	33.333us (30 IntsPerSec) down to 25us (40.000 IntsPerSec).
921
 *	Any requested value that is not in this range will abort the request!
922
 */
923
static int setModerationParams(
924
SK_AC                   *pAC,      /* pointer to adapter control context */
925
int                      port,     /* the port of the selected adapter   */
926
struct ethtool_coalesce *ecoalesc) /* IRQ moderation struct with params  */
927
{
928
	DIM_INFO  *Info             = &pAC->DynIrqModInfo;
929
	int        PrevModeration   = Info->IntModTypeSelect;
930
931
	Info->IntModTypeSelect = C_INT_MOD_NONE; /* initial default */
932
933
	if ((ecoalesc->rx_coalesce_usecs) || (ecoalesc->tx_coalesce_usecs)) {
934
		if (ecoalesc->rx_coalesce_usecs) {
935
			if ((ecoalesc->rx_coalesce_usecs < 25) ||
936
			    (ecoalesc->rx_coalesce_usecs > 33333)) {
937
				return -EINVAL; 
938
			}
939
		}
940
		if (ecoalesc->tx_coalesce_usecs) {
941
			if ((ecoalesc->tx_coalesce_usecs < 25) ||
942
			    (ecoalesc->tx_coalesce_usecs > 33333)) {
943
				return -EINVAL; 
944
			}
945
		}
946
		if (!CHIP_ID_YUKON_2(pAC)) {
947
			if ((Info->MaskIrqModeration == IRQ_MASK_SP_RX) ||
948
			    (Info->MaskIrqModeration == IRQ_MASK_SP_TX) ||
949
			    (Info->MaskIrqModeration == IRQ_MASK_RX_TX_SP)) {
950
				Info->MaskIrqModeration = IRQ_MASK_SP_ONLY;
951
			} 
952
		}
953
		Info->IntModTypeSelect = C_INT_MOD_STATIC;
954
		if (ecoalesc->rx_coalesce_usecs) {
955
			Info->MaxModIntsPerSec = 
956
				1000000 / ecoalesc->rx_coalesce_usecs;
957
			if (!CHIP_ID_YUKON_2(pAC)) {
958
				if (Info->MaskIrqModeration == IRQ_MASK_TX_ONLY) {
959
					Info->MaskIrqModeration = IRQ_MASK_TX_RX;
960
				} 
961
				if (Info->MaskIrqModeration == IRQ_MASK_SP_ONLY) {
962
					Info->MaskIrqModeration = IRQ_MASK_SP_RX;
963
				} 
964
				if (Info->MaskIrqModeration == IRQ_MASK_SP_TX) {
965
					Info->MaskIrqModeration = IRQ_MASK_RX_TX_SP;
966
				}
967
			} else {
968
				Info->MaskIrqModeration = Y2_IRQ_MASK;
969
			}
970
		}
971
		if (ecoalesc->tx_coalesce_usecs) {
972
			Info->MaxModIntsPerSec = 
973
				1000000 / ecoalesc->tx_coalesce_usecs;
974
			if (!CHIP_ID_YUKON_2(pAC)) {
975
				if (Info->MaskIrqModeration == IRQ_MASK_RX_ONLY) {
976
					Info->MaskIrqModeration = IRQ_MASK_TX_RX;
977
				} 
978
				if (Info->MaskIrqModeration == IRQ_MASK_SP_ONLY) {
979
					Info->MaskIrqModeration = IRQ_MASK_SP_TX;
980
				} 
981
				if (Info->MaskIrqModeration == IRQ_MASK_SP_RX) {
982
					Info->MaskIrqModeration = IRQ_MASK_RX_TX_SP;
983
				}
984
			} else {
985
				Info->MaskIrqModeration = Y2_IRQ_MASK;
986
			}
987
		}
988
	}
989
	if ((ecoalesc->rate_sample_interval)  ||
990
	    (ecoalesc->rx_coalesce_usecs_low) ||
991
	    (ecoalesc->tx_coalesce_usecs_low) ||
992
	    (ecoalesc->rx_coalesce_usecs_high)||
993
	    (ecoalesc->tx_coalesce_usecs_high)) {
994
		if (ecoalesc->rate_sample_interval) {
995
			if ((ecoalesc->rate_sample_interval < 1) ||
996
			    (ecoalesc->rate_sample_interval > 10)) {
997
				return -EINVAL; 
998
			}
999
		}
1000
		if (ecoalesc->rx_coalesce_usecs_low) {
1001
			if ((ecoalesc->rx_coalesce_usecs_low < 25) ||
1002
			    (ecoalesc->rx_coalesce_usecs_low > 33333)) {
1003
				return -EINVAL; 
1004
			}
1005
		}
1006
		if (ecoalesc->rx_coalesce_usecs_high) {
1007
			if ((ecoalesc->rx_coalesce_usecs_high < 25) ||
1008
			    (ecoalesc->rx_coalesce_usecs_high > 33333)) {
1009
				return -EINVAL; 
1010
			}
1011
		}
1012
		if (ecoalesc->tx_coalesce_usecs_low) {
1013
			if ((ecoalesc->tx_coalesce_usecs_low < 25) ||
1014
			    (ecoalesc->tx_coalesce_usecs_low > 33333)) {
1015
				return -EINVAL; 
1016
			}
1017
		}
1018
		if (ecoalesc->tx_coalesce_usecs_high) {
1019
			if ((ecoalesc->tx_coalesce_usecs_high < 25) ||
1020
			    (ecoalesc->tx_coalesce_usecs_high > 33333)) {
1021
				return -EINVAL; 
1022
			}
1023
		}
1024
1025
		Info->IntModTypeSelect = C_INT_MOD_DYNAMIC;
1026
		if (ecoalesc->rate_sample_interval) {
1027
			Info->DynIrqModSampleInterval = 
1028
				ecoalesc->rate_sample_interval; 
1029
		}
1030
		if (ecoalesc->rx_coalesce_usecs_low) {
1031
			Info->MaxModIntsPerSecLowerLimit = 
1032
				1000000 / ecoalesc->rx_coalesce_usecs_low;
1033
		}
1034
		if (ecoalesc->tx_coalesce_usecs_low) {
1035
			Info->MaxModIntsPerSecLowerLimit = 
1036
				1000000 / ecoalesc->tx_coalesce_usecs_low;
1037
		}
1038
		if (ecoalesc->rx_coalesce_usecs_high) {
1039
			Info->MaxModIntsPerSecUpperLimit = 
1040
				1000000 / ecoalesc->rx_coalesce_usecs_high;
1041
		}
1042
		if (ecoalesc->tx_coalesce_usecs_high) {
1043
			Info->MaxModIntsPerSecUpperLimit = 
1044
				1000000 / ecoalesc->tx_coalesce_usecs_high;
1045
		}
1046
	}
1047
1048
	if ((PrevModeration         == C_INT_MOD_NONE) &&
1049
	    (Info->IntModTypeSelect != C_INT_MOD_NONE)) {
1050
		SkDimEnableModerationIfNeeded(pAC);
1051
	}
1052
	if (PrevModeration != C_INT_MOD_NONE) {
1053
		SkDimDisableModeration(pAC, PrevModeration);
1054
		if (Info->IntModTypeSelect != C_INT_MOD_NONE) {
1055
			SkDimEnableModerationIfNeeded(pAC);
1056
		}
1057
	}
1058
1059
        return 0;
1060
}
1061
#endif
1062
1063
#ifdef ETHTOOL_GWOL
1064
/*****************************************************************************
1065
 *
1066
 * 	getWOLsettings - retrieves the WOL settings of the selected adapter
1067
 *
1068
 * Description:
1069
 *	All current WOL settings of a selected adapter are placed in the 
1070
 *	passed ethtool_wolinfo structure and are returned to the caller.
398
 *
1071
 *
399
 * Returns:	N/A
1072
 * Returns:	N/A
400
 *
1073
 *
401
 */
1074
 */
402
void SkGeBlinkTimer(unsigned long data)
1075
static void getWOLsettings(
1076
SK_AC                  *pAC,  /* pointer to adapter control context  */
1077
int                     port, /* the port of the selected adapter    */
1078
struct ethtool_wolinfo *ewol) /* mandatory WOL structure for results */
403
{
1079
{
404
	struct net_device *dev = (struct net_device *) data;
1080
	ewol->supported = pAC->WolInfo.SupportedWolOptions;
405
	DEV_NET *pNet = netdev_priv(dev);
1081
	ewol->wolopts   = pAC->WolInfo.ConfiguredWolOptions;
406
	SK_AC *pAC = pNet->pAC;
407
1082
408
	toggleLeds(pNet, pAC->LedsOn);
1083
	return;
1084
}
1085
#endif
409
1086
410
	pAC->LedsOn = !pAC->LedsOn;
1087
#ifdef ETHTOOL_SWOL
411
	mod_timer(&pAC->BlinkTimer, jiffies + HZ/4);
1088
/*****************************************************************************
1089
 *
1090
 *	setWOLsettings - configures the WOL settings of a selected adapter
1091
 *
1092
 * Description:
1093
 *	The WOL settings of a selected adapter are configured regarding
1094
 *	the parameters in the passed ethtool_wolinfo structure.
1095
 *	Note that currently only wake on magic packet is supported!
1096
 *
1097
 * Returns:
1098
 *	==0:	everything fine, no error
1099
 *	!=0:	the return value is the error code of the failure 
1100
 */
1101
static int setWOLsettings(
1102
SK_AC                  *pAC,  /* pointer to adapter control context */
1103
int                     port, /* the port of the selected adapter   */
1104
struct ethtool_wolinfo *ewol) /* WOL structure containing settings  */
1105
{
1106
	if (((ewol->wolopts & WAKE_MAGIC) == WAKE_MAGIC) || (ewol->wolopts == 0)) {
1107
		pAC->WolInfo.ConfiguredWolOptions = ewol->wolopts;
1108
		return 0;
1109
	}
1110
	return -EFAULT;
412
}
1111
}
1112
#endif
413
1113
1114
#ifdef ETHTOOL_GDRVINFO
414
/*****************************************************************************
1115
/*****************************************************************************
415
 *
1116
 *
416
 * 	locateDevice - start the locate NIC feature of the elected adapter 
1117
 * 	getDriverInfo - returns generic driver and adapter information
1118
 *
1119
 * Description:
1120
 *	Generic driver information is returned via this function, such as
1121
 *	the name of the driver, its version and and firmware version.
1122
 *	In addition to this, the location of the selected adapter is 
1123
 *	returned as a bus info string (e.g. '01:05.0').
1124
 *	
1125
 * Returns:	N/A
1126
 *
1127
 */
1128
static void getDriverInfo(
1129
SK_AC                  *pAC,      /* pointer to adapter control context   */
1130
int                     port,     /* the port of the selected adapter     */
1131
struct ethtool_drvinfo *edrvinfo) /* mandatory info structure for results */
1132
{
1133
	char versionString[32];
1134
1135
	snprintf(versionString, 32, "%s (%s)", VER_STRING, PATCHLEVEL);
1136
	strncpy(edrvinfo->driver, DRIVER_FILE_NAME , 32);
1137
	strncpy(edrvinfo->version, versionString , 32);
1138
	strncpy(edrvinfo->fw_version, "N/A", 32);
1139
	strncpy(edrvinfo->bus_info, pAC->PciDev->slot_name, 32);
1140
#ifdef  ETHTOOL_GSTATS
1141
	edrvinfo->n_stats = SK98LIN_STATS_LEN;
1142
#endif
1143
}
1144
#endif
1145
1146
#ifdef ETHTOOL_PHYS_ID
1147
/*****************************************************************************
1148
 *
1149
 * 	startLocateNIC - start the locate NIC feature of the elected adapter 
417
 *
1150
 *
418
 * Description:
1151
 * Description:
419
 *	This function is used if the user want to locate a particular NIC.
1152
 *	This function is used if the user want to locate a particular NIC.
Lines 425-555 Link Here
425
 *	!=0:	one locateNIC test runs already
1158
 *	!=0:	one locateNIC test runs already
426
 *
1159
 *
427
 */
1160
 */
428
static int locateDevice(struct net_device *dev, u32 data)
1161
static int startLocateNIC(
1162
SK_AC                *pAC,        /* pointer to adapter control context        */
1163
int                   port,       /* the port of the selected adapter          */
1164
struct ethtool_value *blinkSecs)  /* how long the LEDs should blink in seconds */
429
{
1165
{
430
	DEV_NET *pNet = netdev_priv(dev);
1166
	struct SK_NET_DEVICE *pDev      = pAC->dev[port];
431
	SK_AC *pAC = pNet->pAC;
1167
	int                   OtherPort = (port) ? 0 : 1;
1168
	struct SK_NET_DEVICE *pOtherDev = pAC->dev[OtherPort];
432
1169
433
	if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
1170
	if (isLocateNICrunning) {
434
		data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
1171
		return -EFAULT;
1172
	}
1173
	isLocateNICrunning = SK_TRUE;
1174
	currentPortIndex = port;
1175
	isDualNetCard = (pDev != pOtherDev) ? SK_TRUE : SK_FALSE;
435
1176
436
	/* start blinking */
1177
	if (netif_running(pAC->dev[port])) {
437
	pAC->LedsOn = 0;
1178
		boardWasDown[0] = SK_FALSE;
438
	mod_timer(&pAC->BlinkTimer, jiffies);
1179
	} else {
439
	msleep_interruptible(data * 1000);
1180
		(*pDev->open)(pDev);
440
1181
		boardWasDown[0] = SK_TRUE;
441
	set_current_state(TASK_INTERRUPTIBLE);
1182
	}
442
	schedule_timeout(data * HZ);
1183
443
	del_timer_sync(&pAC->BlinkTimer);
1184
	if (isDualNetCard) {
444
	toggleLeds(pNet, 0);
1185
		if (netif_running(pAC->dev[OtherPort])) {
1186
			boardWasDown[1] = SK_FALSE;
1187
		} else {
1188
			(*pOtherDev->open)(pOtherDev);
1189
			boardWasDown[1] = SK_TRUE;
1190
		}
1191
	}
1192
1193
	if ((blinkSecs->data < 1) || (blinkSecs->data > 30)) {
1194
		blinkSecs->data = 3; /* three seconds default */
1195
	}
1196
	nbrBlinkQuarterSeconds = 4*blinkSecs->data;
1197
1198
	init_timer(&locateNICtimer);
1199
	locateNICtimer.function = toggleLeds;
1200
	locateNICtimer.data     = (unsigned long) pAC;
1201
	locateNICtimer.expires  = jiffies + HZ; /* initially 1sec */
1202
	add_timer(&locateNICtimer);
445
1203
446
	return 0;
1204
	return 0;
447
}
1205
}
448
1206
449
/*****************************************************************************
1207
/*****************************************************************************
450
 *
1208
 *
451
 * 	getPauseParams - retrieves the pause parameters
1209
 * 	toggleLeds - Changes the LED state of an adapter
452
 *
1210
 *
453
 * Description:
1211
 * Description:
454
 *	All current pause parameters of a selected adapter are placed 
1212
 *	This function changes the current state of all LEDs of an adapter so
455
 *	in the passed ethtool_pauseparam structure and are returned.
1213
 *	that it can be located by a user. If the requested time interval for
1214
 *	this test has elapsed, this function cleans up everything that was 
1215
 *	temporarily setup during the locate NIC test. This involves of course
1216
 *	also closing or opening any adapter so that the initial board state 
1217
 *	is recovered.
456
 *
1218
 *
457
 * Returns:	N/A
1219
 * Returns:	N/A
458
 *
1220
 *
459
 */
1221
 */
460
static void getPauseParams(struct net_device *dev, struct ethtool_pauseparam *epause) 
1222
static void toggleLeds(
1223
unsigned long ptr)  /* holds the pointer to adapter control context */
461
{
1224
{
462
	DEV_NET	*pNet = netdev_priv(dev);
1225
	SK_AC                *pAC       = (SK_AC *) ptr;
463
	SK_AC *pAC = pNet->pAC;
1226
	int                   port      = currentPortIndex;
464
	SK_GEPORT *pPort = &pAC->GIni.GP[pNet->PortNr];
1227
	SK_IOC                IoC       = pAC->IoBase;
1228
	struct SK_NET_DEVICE *pDev      = pAC->dev[port];
1229
	int                   OtherPort = (port) ? 0 : 1;
1230
	struct SK_NET_DEVICE *pOtherDev = pAC->dev[OtherPort];
1231
1232
	SK_U16  YukLedOn = (PHY_M_LED_MO_DUP(MO_LED_ON)  |
1233
			    PHY_M_LED_MO_10(MO_LED_ON)   |
1234
			    PHY_M_LED_MO_100(MO_LED_ON)  |
1235
			    PHY_M_LED_MO_1000(MO_LED_ON) | 
1236
			    PHY_M_LED_MO_RX(MO_LED_ON));
1237
	SK_U16  YukLedOff = (PHY_M_LED_MO_DUP(MO_LED_OFF)  |
1238
			     PHY_M_LED_MO_10(MO_LED_OFF)   |
1239
			     PHY_M_LED_MO_100(MO_LED_OFF)  |
1240
			     PHY_M_LED_MO_1000(MO_LED_OFF) | 
1241
			     PHY_M_LED_MO_RX(MO_LED_OFF));
1242
1243
	nbrBlinkQuarterSeconds--;
1244
	if (nbrBlinkQuarterSeconds <= 0) {
1245
		(*pDev->stop)(pDev);
1246
		if (isDualNetCard) {
1247
			(*pOtherDev->stop)(pOtherDev);
1248
		}
465
1249
466
	epause->rx_pause = (pPort->PFlowCtrlMode == SK_FLOW_MODE_SYMMETRIC) ||
1250
		if (!boardWasDown[0]) {
467
		  (pPort->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM);
1251
			(*pDev->open)(pDev);
1252
		}
1253
		if (isDualNetCard) {
1254
			(*pOtherDev->open)(pOtherDev);
1255
		}
1256
		isDualNetCard      = SK_FALSE;
1257
		isLocateNICrunning = SK_FALSE;
1258
		return;
1259
	}
468
1260
469
	epause->tx_pause = epause->rx_pause || (pPort->PFlowCtrlMode == SK_FLOW_MODE_LOC_SEND);
1261
	doSwitchLEDsOn = (doSwitchLEDsOn) ? SK_FALSE : SK_TRUE;
470
	epause->autoneg = epause->rx_pause || epause->tx_pause;
1262
	if (doSwitchLEDsOn) {
471
}
1263
		if (pAC->GIni.GIGenesis) {
1264
			SK_OUT8(IoC,MR_ADDR(port,LNK_LED_REG),(SK_U8)SK_LNK_ON);
1265
			SkGeYellowLED(pAC,IoC,LED_ON >> 1);
1266
			SkGeXmitLED(pAC,IoC,MR_ADDR(port,RX_LED_INI),SK_LED_TST);
1267
			if (pAC->GIni.GP[port].PhyType == SK_PHY_BCOM) {
1268
				SkXmPhyWrite(pAC,IoC,port,PHY_BCOM_P_EXT_CTRL,PHY_B_PEC_LED_ON);
1269
			} else if (pAC->GIni.GP[port].PhyType == SK_PHY_LONE) {
1270
				SkXmPhyWrite(pAC,IoC,port,PHY_LONE_LED_CFG,0x0800);
1271
			} else {
1272
				SkGeXmitLED(pAC,IoC,MR_ADDR(port,TX_LED_INI),SK_LED_TST);
1273
			}
1274
		} else {
1275
			SkGmPhyWrite(pAC,IoC,port,PHY_MARV_LED_CTRL,0);
1276
			SkGmPhyWrite(pAC,IoC,port,PHY_MARV_LED_OVER,YukLedOn);
1277
		}
1278
	} else {
1279
		if (pAC->GIni.GIGenesis) {
1280
			SK_OUT8(IoC,MR_ADDR(port,LNK_LED_REG),(SK_U8)SK_LNK_OFF);
1281
			SkGeYellowLED(pAC,IoC,LED_OFF >> 1);
1282
			SkGeXmitLED(pAC,IoC,MR_ADDR(port,RX_LED_INI),SK_LED_DIS);
1283
			if (pAC->GIni.GP[port].PhyType == SK_PHY_BCOM) {
1284
				SkXmPhyWrite(pAC,IoC,port,PHY_BCOM_P_EXT_CTRL,PHY_B_PEC_LED_OFF);
1285
			} else if (pAC->GIni.GP[port].PhyType == SK_PHY_LONE) {
1286
				SkXmPhyWrite(pAC,IoC,port,PHY_LONE_LED_CFG,PHY_L_LC_LEDT);
1287
			} else {
1288
				SkGeXmitLED(pAC,IoC,MR_ADDR(port,TX_LED_INI),SK_LED_DIS);
1289
			}
1290
		} else {
1291
			SkGmPhyWrite(pAC,IoC,port,PHY_MARV_LED_CTRL,0);
1292
			SkGmPhyWrite(pAC,IoC,port,PHY_MARV_LED_OVER,YukLedOff);
1293
		}
1294
	}
1295
1296
	locateNICtimer.function = toggleLeds;
1297
	locateNICtimer.data     = (unsigned long) pAC;
1298
	locateNICtimer.expires  = jiffies + (HZ/4); /* 250ms */
1299
	add_timer(&locateNICtimer);
1300
} 
1301
#endif
472
1302
473
/*****************************************************************************
1303
/*****************************************************************************
474
 *
1304
 *
475
 *	setPauseParams - configures the pause parameters of an adapter
1305
 * 	getPortNumber - evaluates the port number of an interface
476
 *
1306
 *
477
 * Description:
1307
 * Description:
478
 *	This function sets the Rx or Tx pause parameters 
1308
 *	It may be that the current interface refers to one which is located
1309
 *	on a dual net adapter. Hence, this function will return the correct
1310
 *	port for further use.
479
 *
1311
 *
480
 * Returns:
1312
 * Returns:
481
 *	==0:	everything fine, no error
1313
 *	the port number that corresponds to the selected adapter
482
 *	!=0:	the return value is the error code of the failure 
1314
 *
483
 */
1315
 */
484
static int setPauseParams(struct net_device *dev , struct ethtool_pauseparam *epause)
1316
static int getPortNumber(
1317
struct net_device *netdev,  /* the pointer to netdev structure       */
1318
struct ifreq      *ifr)     /* what interface the request refers to? */
485
{
1319
{
486
	DEV_NET	*pNet = netdev_priv(dev);
1320
	DEV_NET *pNet = (DEV_NET*) netdev->priv;
487
	SK_AC *pAC = pNet->pAC;
1321
	SK_AC   *pAC  = pNet->pAC;
488
	SK_GEPORT *pPort = &pAC->GIni.GP[pNet->PortNr];
489
	u32	instance = pnmiInstance(pNet);
490
	struct ethtool_pauseparam old;
491
	u8	oldspeed = pPort->PLinkSpeedUsed;
492
	char	buf[4];
493
	int	len = 1;
494
	int ret;
495
1322
496
	/*
1323
	if (pAC->dev[1] != pAC->dev[0]) {
497
	** we have to determine the current settings to see if 
1324
		if (!strcmp(pAC->dev[1]->name, ifr->ifr_name)) {
498
	** the operator requested any modification of the flow 
1325
			return 1; /* port index 1 */
499
	** control parameters...
1326
		}
500
	*/
501
	getPauseParams(dev, &old);
502
503
	/*
504
	** perform modifications regarding the changes 
505
	** requested by the operator
506
	*/
507
	if (epause->autoneg != old.autoneg) 
508
		*buf = epause->autoneg ? SK_FLOW_MODE_NONE : SK_FLOW_MODE_SYMMETRIC;
509
	else {
510
		if (epause->rx_pause && epause->tx_pause) 
511
			*buf = SK_FLOW_MODE_SYMMETRIC;
512
		else if (epause->rx_pause && !epause->tx_pause)
513
			*buf =  SK_FLOW_MODE_SYM_OR_REM;
514
		else if (!epause->rx_pause && epause->tx_pause)
515
			*buf =  SK_FLOW_MODE_LOC_SEND;
516
		else
517
			*buf = SK_FLOW_MODE_NONE;
518
	}
519
520
	ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_FLOWCTRL_MODE,
521
			 &buf, &len, instance, pNet->NetNr);
522
523
	if (ret != SK_PNMI_ERR_OK) {
524
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_CTRL,
525
			   ("ethtool (sk98lin): error changing rx/tx pause (%i)\n", ret));
526
		goto err;
527
	}
1327
	}
1328
	return 0;
1329
}
528
1330
529
	/*
1331
/*******************************************************************************
530
	** It may be that autoneg has been disabled! Therefore
1332
 *
531
	** set the speed to the previously used value...
1333
 * End of file
532
	*/
1334
 *
533
	if (!epause->autoneg) {
1335
 ******************************************************************************/
534
		len = 1;
535
		ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_SPEED_MODE, 
536
				   &oldspeed, &len, instance, pNet->NetNr);
537
		if (ret != SK_PNMI_ERR_OK) 
538
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_CTRL,
539
				   ("ethtool (sk98lin): error setting speed (%i)\n", ret));
540
	}
541
 err:
542
        return ret ? -EIO : 0;
543
}
544
545
struct ethtool_ops SkGeEthtoolOps = {
546
	.get_settings		= getSettings,
547
	.set_settings		= setSettings,
548
	.get_drvinfo		= getDriverInfo,
549
	.get_strings		= getStrings,
550
	.get_stats_count	= getStatsCount,
551
	.get_ethtool_stats	= getEthtoolStats,
552
	.phys_id		= locateDevice,
553
	.get_pauseparam		= getPauseParams,
554
	.set_pauseparam		= setPauseParams,
555
};
(-)linux/drivers/net/sk98lin/skge.c (-1383 / +2418 lines)
Lines 1-25 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 *
2
 *
3
 * Name:	skge.c
3
 * Name:        skge.c
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:     GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.45 $
5
 * Version:     $Revision: 1.60.2.37 $
6
 * Date:       	$Date: 2004/02/12 14:41:02 $
6
 * Date:        $Date: 2005/03/30 12:18:57 $
7
 * Purpose:	The main driver source module
7
 * Purpose:     The main driver source module
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
10
10
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	Driver for Marvell Yukon chipset and SysKonnect Gigabit Ethernet 
16
 *	Driver for Marvell Yukon chipset and SysKonnect Gigabit Ethernet 
17
 *      Server Adapters.
17
 *      Server Adapters.
18
 *
18
 *
19
 *	Created 10-Feb-1999, based on Linux' acenic.c, 3c59x.c and
19
 *	Author: Mirko Lindner (mlindner@syskonnect.de)
20
 *	SysKonnects GEnesis Solaris driver
20
 *	        Ralph Roesler (rroesler@syskonnect.de)
21
 *	Author: Christoph Goos (cgoos@syskonnect.de)
22
 *	        Mirko Lindner (mlindner@syskonnect.de)
23
 *
21
 *
24
 *	Address all question to: linux@syskonnect.de
22
 *	Address all question to: linux@syskonnect.de
25
 *
23
 *
Lines 38-121 Link Here
38
36
39
/******************************************************************************
37
/******************************************************************************
40
 *
38
 *
41
 * Possible compiler options (#define xxx / -Dxxx):
42
 *
43
 *	debugging can be enable by changing SK_DEBUG_CHKMOD and
44
 *	SK_DEBUG_CHKCAT in makefile (described there).
45
 *
46
 ******************************************************************************/
47
48
/******************************************************************************
49
 *
50
 * Description:
39
 * Description:
51
 *
40
 *
52
 *	This is the main module of the Linux GE driver.
41
 *	All source files in this sk98lin directory except of the sk98lin 
53
 *	
42
 *	Linux specific files
54
 *	All source files except skge.c, skdrv1st.h, skdrv2nd.h and sktypes.h
43
 *
55
 *	are part of SysKonnect's COMMON MODULES for the SK-98xx adapters.
44
 *		- skdim.c
56
 *	Those are used for drivers on multiple OS', so some thing may seem
45
 *		- skethtool.c
57
 *	unnecessary complicated on Linux. Please do not try to 'clean up'
46
 *		- skge.c
58
 *	them without VERY good reasons, because this will make it more
47
 *		- skproc.c
59
 *	difficult to keep the Linux driver in synchronisation with the
48
 *		- sky2.c
60
 *	other versions.
49
 *		- Makefile
61
 *
50
 *		- h/skdrv1st.h
62
 * Include file hierarchy:
51
 *		- h/skdrv2nd.h
63
 *
52
 *		- h/sktypes.h
64
 *	<linux/module.h>
53
 *		- h/skversion.h
65
 *
54
 *
66
 *	"h/skdrv1st.h"
55
 *	are part of SysKonnect's common modules for the SK-9xxx adapters.
67
 *		<linux/types.h>
56
 *
68
 *		<linux/kernel.h>
57
 *	Those common module files which are not Linux specific are used to 
69
 *		<linux/string.h>
58
 *	build drivers on different OS' (e.g. Windows, MAC OS) so that those
70
 *		<linux/errno.h>
59
 *	drivers are based on the same set of files
71
 *		<linux/ioport.h>
60
 *
72
 *		<linux/slab.h>
61
 *	At a first glance, this seems to complicate things unnescessarily on 
73
 *		<linux/interrupt.h>
62
 *	Linux, but please do not try to 'clean up' them without VERY good 
74
 *		<linux/pci.h>
63
 *	reasons, because this will make it more difficult to keep the sk98lin
75
 *		<linux/bitops.h>
64
 *	driver for Linux in synchronisation with the other drivers running on
76
 *		<asm/byteorder.h>
65
 *	other operating systems.
77
 *		<asm/io.h>
78
 *		<linux/netdevice.h>
79
 *		<linux/etherdevice.h>
80
 *		<linux/skbuff.h>
81
 *	    those three depending on kernel version used:
82
 *		<linux/bios32.h>
83
 *		<linux/init.h>
84
 *		<asm/uaccess.h>
85
 *		<net/checksum.h>
86
 *
87
 *		"h/skerror.h"
88
 *		"h/skdebug.h"
89
 *		"h/sktypes.h"
90
 *		"h/lm80.h"
91
 *		"h/xmac_ii.h"
92
 *
93
 *      "h/skdrv2nd.h"
94
 *		"h/skqueue.h"
95
 *		"h/skgehwt.h"
96
 *		"h/sktimer.h"
97
 *		"h/ski2c.h"
98
 *		"h/skgepnmi.h"
99
 *		"h/skvpd.h"
100
 *		"h/skgehw.h"
101
 *		"h/skgeinit.h"
102
 *		"h/skaddr.h"
103
 *		"h/skgesirq.h"
104
 *		"h/skcsum.h"
105
 *		"h/skrlmt.h"
106
 *
66
 *
107
 ******************************************************************************/
67
 ******************************************************************************/
108
68
109
#include	"h/skversion.h"
69
#include	"h/skversion.h"
110
70
111
#include	<linux/module.h>
71
#include	<linux/module.h>
112
#include	<linux/moduleparam.h>
113
#include	<linux/init.h>
72
#include	<linux/init.h>
73
#include	<linux/ethtool.h>
74
75
#ifdef CONFIG_PROC_FS
114
#include 	<linux/proc_fs.h>
76
#include 	<linux/proc_fs.h>
77
#endif
115
78
116
#include	"h/skdrv1st.h"
79
#include	"h/skdrv1st.h"
117
#include	"h/skdrv2nd.h"
80
#include	"h/skdrv2nd.h"
118
81
82
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
83
#include	<linux/moduleparam.h>
84
#endif
85
119
/*******************************************************************************
86
/*******************************************************************************
120
 *
87
 *
121
 * Defines
88
 * Defines
Lines 125-186 Link Here
125
/* for debuging on x86 only */
92
/* for debuging on x86 only */
126
/* #define BREAKPOINT() asm(" int $3"); */
93
/* #define BREAKPOINT() asm(" int $3"); */
127
94
128
/* use the transmit hw checksum driver functionality */
129
#define USE_SK_TX_CHECKSUM
130
131
/* use the receive hw checksum driver functionality */
132
#define USE_SK_RX_CHECKSUM
133
134
/* use the scatter-gather functionality with sendfile() */
135
#define SK_ZEROCOPY
136
137
/* use of a transmit complete interrupt */
138
#define USE_TX_COMPLETE
139
140
/*
141
 * threshold for copying small receive frames
142
 * set to 0 to avoid copying, set to 9001 to copy all frames
143
 */
144
#define SK_COPY_THRESHOLD	50
145
146
/* number of adapters that can be configured via command line params */
147
#define SK_MAX_CARD_PARAM	16
148
149
150
151
/*
152
 * use those defines for a compile-in version of the driver instead
153
 * of command line parameters
154
 */
155
// #define LINK_SPEED_A	{"Auto", }
156
// #define LINK_SPEED_B	{"Auto", }
157
// #define AUTO_NEG_A	{"Sense", }
158
// #define AUTO_NEG_B	{"Sense", }
159
// #define DUP_CAP_A	{"Both", }
160
// #define DUP_CAP_B	{"Both", }
161
// #define FLOW_CTRL_A	{"SymOrRem", }
162
// #define FLOW_CTRL_B	{"SymOrRem", }
163
// #define ROLE_A	{"Auto", }
164
// #define ROLE_B	{"Auto", }
165
// #define PREF_PORT	{"A", }
166
// #define CON_TYPE 	{"Auto", }
167
// #define RLMT_MODE	{"CheckLinkState", }
168
169
#define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)
170
#define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb)
171
#define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb)
172
173
95
174
/* Set blink mode*/
96
/* Set blink mode*/
175
#define OEM_CONFIG_VALUE (	SK_ACT_LED_BLINK | \
97
#define OEM_CONFIG_VALUE (	SK_ACT_LED_BLINK | \
176
				SK_DUP_LED_NORMAL | \
98
				SK_DUP_LED_NORMAL | \
177
				SK_LED_LINK100_ON)
99
				SK_LED_LINK100_ON)
178
100
179
101
#define CLEAR_AND_START_RX(Port) SK_OUT8(pAC->IoBase, RxQueueAddr[(Port)]+Q_CSR, CSR_START | CSR_IRQ_CL_F)
180
/* Isr return value */
102
#define CLEAR_TX_IRQ(Port,Prio) SK_OUT8(pAC->IoBase, TxQueueAddr[(Port)][(Prio)]+Q_CSR, CSR_IRQ_CL_F)
181
#define SkIsrRetVar	irqreturn_t
182
#define SkIsrRetNone	IRQ_NONE
183
#define SkIsrRetHandled	IRQ_HANDLED
184
103
185
104
186
/*******************************************************************************
105
/*******************************************************************************
Lines 189-200 Link Here
189
 *
108
 *
190
 ******************************************************************************/
109
 ******************************************************************************/
191
110
111
static int 	__devinit sk98lin_init_device(struct pci_dev *pdev, const struct pci_device_id *ent);
112
static void 	sk98lin_remove_device(struct pci_dev *pdev);
113
#ifdef CONFIG_PM
114
static int	sk98lin_suspend(struct pci_dev *pdev, u32 state);
115
static int	sk98lin_resume(struct pci_dev *pdev);
116
static void	SkEnableWOMagicPacket(SK_AC *pAC, SK_IOC IoC, SK_MAC_ADDR MacAddr);
117
#endif
118
#ifdef Y2_RECOVERY
119
static void	SkGeHandleKernelTimer(unsigned long ptr);
120
void		SkGeCheckTimer(DEV_NET *pNet);
121
#endif
192
static void	FreeResources(struct SK_NET_DEVICE *dev);
122
static void	FreeResources(struct SK_NET_DEVICE *dev);
193
static int	SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC);
123
static int	SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC);
194
static SK_BOOL	BoardAllocMem(SK_AC *pAC);
124
static SK_BOOL	BoardAllocMem(SK_AC *pAC);
195
static void	BoardFreeMem(SK_AC *pAC);
125
static void	BoardFreeMem(SK_AC *pAC);
196
static void	BoardInitMem(SK_AC *pAC);
126
static void	BoardInitMem(SK_AC *pAC);
197
static void	SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**, int*, SK_BOOL);
127
static void	SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**, int*, int*, SK_BOOL);
198
static SkIsrRetVar	SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
128
static SkIsrRetVar	SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
199
static SkIsrRetVar	SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
129
static SkIsrRetVar	SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
200
static int	SkGeOpen(struct SK_NET_DEVICE *dev);
130
static int	SkGeOpen(struct SK_NET_DEVICE *dev);
Lines 210-266 Link Here
210
static void	FreeTxDescriptors(SK_AC*pAC, TX_PORT*);
140
static void	FreeTxDescriptors(SK_AC*pAC, TX_PORT*);
211
static void	FillRxRing(SK_AC*, RX_PORT*);
141
static void	FillRxRing(SK_AC*, RX_PORT*);
212
static SK_BOOL	FillRxDescriptor(SK_AC*, RX_PORT*);
142
static SK_BOOL	FillRxDescriptor(SK_AC*, RX_PORT*);
143
#ifdef CONFIG_SK98LIN_NAPI
144
static int	SkGePoll(struct net_device *dev, int *budget);
145
static void	ReceiveIrq(SK_AC*, RX_PORT*, SK_BOOL, int*, int);
146
#else
213
static void	ReceiveIrq(SK_AC*, RX_PORT*, SK_BOOL);
147
static void	ReceiveIrq(SK_AC*, RX_PORT*, SK_BOOL);
214
static void	ClearAndStartRx(SK_AC*, int);
148
#endif
215
static void	ClearTxIrq(SK_AC*, int, int);
216
static void	ClearRxRing(SK_AC*, RX_PORT*);
149
static void	ClearRxRing(SK_AC*, RX_PORT*);
217
static void	ClearTxRing(SK_AC*, TX_PORT*);
150
static void	ClearTxRing(SK_AC*, TX_PORT*);
218
static int	SkGeChangeMtu(struct SK_NET_DEVICE *dev, int new_mtu);
151
static int	SkGeChangeMtu(struct SK_NET_DEVICE *dev, int new_mtu);
219
static void	PortReInitBmu(SK_AC*, int);
152
static void	PortReInitBmu(SK_AC*, int);
220
static int	SkGeIocMib(DEV_NET*, unsigned int, int);
153
static int	SkGeIocMib(DEV_NET*, unsigned int, int);
221
static int	SkGeInitPCI(SK_AC *pAC);
154
static int	SkGeInitPCI(SK_AC *pAC);
222
static void	StartDrvCleanupTimer(SK_AC *pAC);
223
static void	StopDrvCleanupTimer(SK_AC *pAC);
224
static int	XmitFrameSG(SK_AC*, TX_PORT*, struct sk_buff*);
225
226
#ifdef SK_DIAG_SUPPORT
227
static SK_U32   ParseDeviceNbrFromSlotName(const char *SlotName);
155
static SK_U32   ParseDeviceNbrFromSlotName(const char *SlotName);
228
static int      SkDrvInitAdapter(SK_AC *pAC, int devNbr);
156
static int      SkDrvInitAdapter(SK_AC *pAC, int devNbr);
229
static int      SkDrvDeInitAdapter(SK_AC *pAC, int devNbr);
157
static int      SkDrvDeInitAdapter(SK_AC *pAC, int devNbr);
230
#endif
158
extern void	SkLocalEventQueue(	SK_AC *pAC,
159
					SK_U32 Class,
160
					SK_U32 Event,
161
					SK_U32 Param1,
162
					SK_U32 Param2,
163
					SK_BOOL Flag);
164
extern void	SkLocalEventQueue64(	SK_AC *pAC,
165
					SK_U32 Class,
166
					SK_U32 Event,
167
					SK_U64 Param,
168
					SK_BOOL Flag);
169
170
static int	XmitFrameSG(SK_AC*, TX_PORT*, struct sk_buff*);
231
171
232
/*******************************************************************************
172
/*******************************************************************************
233
 *
173
 *
234
 * Extern Function Prototypes
174
 * Extern Function Prototypes
235
 *
175
 *
236
 ******************************************************************************/
176
 ******************************************************************************/
237
static const char 	SKRootName[] = "sk98lin";
238
static struct		proc_dir_entry *pSkRootDir;
239
extern struct	file_operations sk_proc_fops;
240
241
static inline void SkGeProcCreate(struct net_device *dev)
242
{
243
	struct proc_dir_entry *pe;
244
177
245
	if (pSkRootDir && 
178
extern SK_BOOL SkY2AllocateResources(SK_AC *pAC);
246
	    (pe = create_proc_entry(dev->name, S_IRUGO, pSkRootDir))) {
179
extern void SkY2FreeResources(SK_AC *pAC);
247
		pe->proc_fops = &sk_proc_fops;
180
extern void SkY2AllocateRxBuffers(SK_AC *pAC,SK_IOC IoC,int Port);
248
		pe->data = dev;
181
extern void SkY2FreeRxBuffers(SK_AC *pAC,SK_IOC IoC,int Port);
249
		pe->owner = THIS_MODULE;
182
extern void SkY2FreeTxBuffers(SK_AC *pAC,SK_IOC IoC,int Port);
250
	}
183
extern SkIsrRetVar SkY2Isr(int irq,void *dev_id,struct pt_regs *ptregs);
251
}
184
extern int SkY2Xmit(struct sk_buff *skb,struct SK_NET_DEVICE *dev);
252
 
185
extern void SkY2PortStop(SK_AC *pAC,SK_IOC IoC,int Port,int Dir,int RstMode);
253
static inline void SkGeProcRemove(struct net_device *dev)
186
extern void SkY2PortStart(SK_AC *pAC,SK_IOC IoC,int Port);
254
{
187
extern int SkY2RlmtSend(SK_AC *pAC,int PortNr,struct sk_buff *pMessage);
255
	if (pSkRootDir)
188
extern void SkY2RestartStatusUnit(SK_AC *pAC);
256
		remove_proc_entry(dev->name, pSkRootDir);
189
#ifdef CONFIG_SK98LIN_NAPI
257
}
190
extern int SkY2Poll(struct net_device *dev, int *budget);
191
#endif
258
192
259
extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);	
193
extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);	
260
extern void SkDimDisplayModerationSettings(SK_AC *pAC);
261
extern void SkDimStartModerationTimer(SK_AC *pAC);
194
extern void SkDimStartModerationTimer(SK_AC *pAC);
262
extern void SkDimModerate(SK_AC *pAC);
195
extern void SkDimModerate(SK_AC *pAC);
263
extern void SkGeBlinkTimer(unsigned long data);
196
197
extern int SkEthIoctl(struct net_device *netdev, struct ifreq *ifr);
198
199
#ifdef CONFIG_PROC_FS
200
static const char 	SK_Root_Dir_entry[] = "sk98lin";
201
static struct		proc_dir_entry *pSkRootDir;
202
extern struct	file_operations sk_proc_fops;
203
#endif
264
204
265
#ifdef DEBUG
205
#ifdef DEBUG
266
static void	DumpMsg(struct sk_buff*, char*);
206
static void	DumpMsg(struct sk_buff*, char*);
Lines 269-280 Link Here
269
#endif
209
#endif
270
210
271
/* global variables *********************************************************/
211
/* global variables *********************************************************/
212
static const char *BootString = BOOT_STRING;
213
struct SK_NET_DEVICE *SkGeRootDev = NULL;
272
static SK_BOOL DoPrintInterfaceChange = SK_TRUE;
214
static SK_BOOL DoPrintInterfaceChange = SK_TRUE;
273
extern  struct ethtool_ops SkGeEthtoolOps;
274
215
275
/* local variables **********************************************************/
216
/* local variables **********************************************************/
276
static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
217
static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
277
static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
218
static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
219
static int sk98lin_max_boards_found = 0;
220
221
#ifdef CONFIG_PROC_FS
222
static struct proc_dir_entry	*pSkRootDir;
223
#endif
224
225
226
227
static struct pci_device_id sk98lin_pci_tbl[] __devinitdata = {
228
/*	{ pci_vendor_id, pci_device_id, * SAMPLE ENTRY! *
229
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, */
230
	{ 0x10b7, 0x1700, /* 3Com (10b7), Gigabit Ethernet Adapter */
231
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
232
	{ 0x10b7, 0x80eb, /* 3Com (10b7), 3Com 3C940B Gigabit LOM Ethernet Adapter */
233
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
234
	{ 0x1148, 0x4300, /* SysKonnect (1148), SK-98xx Gigabit Ethernet Server Adapter */
235
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
236
	{ 0x1148, 0x4320, /* SysKonnect (1148), SK-98xx V2.0 Gigabit Ethernet Adapter */
237
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
238
	{ 0x1148, 0x9000, /* SysKonnect (1148), SK-9Sxx 10/100/1000Base-T Server Adapter  */
239
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
240
	{ 0x1148, 0x9E00, /* SysKonnect (1148), SK-9Exx 10/100/1000Base-T Adapter */
241
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
242
	{ 0x1186, 0x4b00, /* D-Link (1186), Gigabit Ethernet Adapter */
243
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
244
	{ 0x1186, 0x4b01, /* D-Link (1186), Gigabit Ethernet Adapter */
245
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
246
	{ 0x1186, 0x4c00, /* D-Link (1186), Gigabit Ethernet Adapter */
247
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
248
	{ 0x11ab, 0x4320, /* Marvell (11ab), Gigabit Ethernet Controller */
249
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
250
	{ 0x11ab, 0x4340, /* Marvell (11ab), Gigabit Ethernet Controller  */
251
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
252
	{ 0x11ab, 0x4341, /* Marvell (11ab), Gigabit Ethernet Controller  */
253
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
254
	{ 0x11ab, 0x4342, /* Marvell (11ab), Gigabit Ethernet Controller  */
255
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
256
	{ 0x11ab, 0x4343, /* Marvell (11ab), Gigabit Ethernet Controller  */
257
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
258
	{ 0x11ab, 0x4344, /* Marvell (11ab), Gigabit Ethernet Controller  */
259
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
260
	{ 0x11ab, 0x4345, /* Marvell (11ab), Gigabit Ethernet Controller  */
261
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
262
	{ 0x11ab, 0x4346, /* Marvell (11ab), Gigabit Ethernet Controller  */
263
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
264
	{ 0x11ab, 0x4347, /* Marvell (11ab), Gigabit Ethernet Controller  */
265
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
266
	{ 0x11ab, 0x4350, /* Marvell (11ab), Fast Ethernet Controller */
267
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
268
	{ 0x11ab, 0x4351, /* Marvell (11ab), Fast Ethernet Controller */
269
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
270
	{ 0x11ab, 0x4360, /* Marvell (11ab), Gigabit Ethernet Controller */
271
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
272
	{ 0x11ab, 0x4361, /* Marvell (11ab), Gigabit Ethernet Controller */
273
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
274
	{ 0x11ab, 0x4362, /* Marvell (11ab), Gigabit Ethernet Controller */
275
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
276
	{ 0x11ab, 0x5005, /* Marvell (11ab), Belkin */
277
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
278
	{ 0x1371, 0x434e, /* CNet (1371), GigaCard Network Adapter */
279
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
280
	{ 0x1737, 0x1032, /* Linksys (1737), Gigabit Network Adapter */
281
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
282
	{ 0x1737, 0x1064, /* Linksys (1737), Gigabit Network Adapter */
283
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
284
	{ 0, }
285
};
286
287
MODULE_DEVICE_TABLE(pci, sk98lin_pci_tbl);
288
289
static struct pci_driver sk98lin_driver = {
290
	.name		= DRIVER_FILE_NAME,
291
	.id_table	= sk98lin_pci_tbl,
292
	.probe		= sk98lin_init_device,
293
	.remove		= __devexit_p(sk98lin_remove_device),
294
#ifdef CONFIG_PM
295
	.suspend	= sk98lin_suspend,
296
	.resume		= sk98lin_resume
297
#endif
298
};
299
300
301
/*****************************************************************************
302
 *
303
 * 	sk98lin_init_device - initialize the adapter
304
 *
305
 * Description:
306
 *	This function initializes the adapter. Resources for
307
 *	the adapter are allocated and the adapter is brought into Init 1
308
 *	state.
309
 *
310
 * Returns:
311
 *	0, if everything is ok
312
 *	!=0, on error
313
 */
314
static int __devinit sk98lin_init_device(struct pci_dev *pdev,
315
				  const struct pci_device_id *ent)
316
317
{
318
	static SK_BOOL 		sk98lin_boot_string = SK_FALSE;
319
	static SK_BOOL 		sk98lin_proc_entry = SK_FALSE;
320
	static int		sk98lin_boards_found = 0;
321
	SK_AC			*pAC;
322
	DEV_NET			*pNet = NULL;
323
	struct SK_NET_DEVICE *dev = NULL;
324
	int			retval;
325
#ifdef CONFIG_PROC_FS
326
	struct proc_dir_entry	*pProcFile;
327
#endif
328
329
	retval = pci_enable_device(pdev);
330
	if (retval) {
331
		printk(KERN_ERR "Cannot enable PCI device, "
332
			"aborting.\n");
333
		return retval;
334
	}
335
336
	dev = NULL;
337
	pNet = NULL;
338
339
340
	/* INSERT * We have to find the power-management capabilities */
341
	/* Find power-management capability. */
342
343
344
345
	/* Configure DMA attributes. */
346
	retval = pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL);
347
	if (!retval) {
348
		retval = pci_set_dma_mask(pdev, (u64) 0xffffffff);
349
		if (retval)
350
			return retval;
351
	} else {
352
		return retval;
353
	}
354
355
356
	if ((dev = alloc_etherdev(sizeof(DEV_NET))) == NULL) {
357
		printk(KERN_ERR "Unable to allocate etherdev "
358
			"structure!\n");
359
		return -ENODEV;
360
	}
361
362
	pNet = dev->priv;
363
	pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
364
	if (pNet->pAC == NULL){
365
		free_netdev(dev);
366
		printk(KERN_ERR "Unable to allocate adapter "
367
			"structure!\n");
368
		return -ENODEV;
369
	}
370
371
372
	/* Print message */
373
	if (!sk98lin_boot_string) {
374
		/* set display flag to TRUE so that */
375
		/* we only display this string ONCE */
376
		sk98lin_boot_string = SK_TRUE;
377
		printk("%s\n", BootString);
378
	}
379
380
	memset(pNet->pAC, 0, sizeof(SK_AC));
381
	pAC = pNet->pAC;
382
	pAC->PciDev = pdev;
383
	pAC->PciDevId = pdev->device;
384
	pAC->dev[0] = dev;
385
	pAC->dev[1] = dev;
386
	sprintf(pAC->Name, "SysKonnect SK-98xx");
387
	pAC->CheckQueue = SK_FALSE;
388
389
	dev->irq = pdev->irq;
390
	retval = SkGeInitPCI(pAC);
391
	if (retval) {
392
		printk("SKGE: PCI setup failed: %i\n", retval);
393
		free_netdev(dev);
394
		return -ENODEV;
395
	}
396
397
	SET_MODULE_OWNER(dev);
398
399
	dev->open =		&SkGeOpen;
400
	dev->stop =		&SkGeClose;
401
	dev->get_stats =	&SkGeStats;
402
	dev->set_multicast_list = &SkGeSetRxMode;
403
	dev->set_mac_address =	&SkGeSetMacAddr;
404
	dev->do_ioctl =		&SkGeIoctl;
405
	dev->change_mtu =	&SkGeChangeMtu;
406
	dev->flags &= 		~IFF_RUNNING;
407
	SET_NETDEV_DEV(dev, &pdev->dev);
408
409
	pAC->Index = sk98lin_boards_found;
410
411
	if (SkGeBoardInit(dev, pAC)) {
412
		free_netdev(dev);
413
		return -ENODEV;
414
	} else {
415
		ProductStr(pAC);
416
	}
417
418
	/* shifter to later moment in time... */
419
	if (CHIP_ID_YUKON_2(pAC)) {
420
		dev->hard_start_xmit =	&SkY2Xmit;
421
	} else {
422
		dev->hard_start_xmit =	&SkGeXmit;
423
	}
424
425
#ifdef NETIF_F_TSO
426
#ifdef USE_SK_TSO_FEATURE	
427
	if (CHIP_ID_YUKON_2(pAC)) {
428
		dev->features |= NETIF_F_TSO;
429
	}
430
#endif
431
#endif
432
#ifdef CONFIG_SK98LIN_ZEROCOPY
433
	if (pAC->GIni.GIChipId != CHIP_ID_GENESIS)
434
		dev->features |= NETIF_F_SG;
435
#endif
436
#ifdef USE_SK_TX_CHECKSUM
437
	if (pAC->GIni.GIChipId != CHIP_ID_GENESIS)
438
		dev->features |= NETIF_F_IP_CSUM;
439
#endif
440
#ifdef USE_SK_RX_CHECKSUM
441
	pAC->RxPort[0].UseRxCsum = SK_TRUE;
442
	if (pAC->GIni.GIMacsFound == 2 ) {
443
		pAC->RxPort[1].UseRxCsum = SK_TRUE;
444
	}
445
#endif
446
447
	/* Save the hardware revision */
448
	pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
449
		(pAC->GIni.GIPciHwRev & 0x0F);
450
451
	/* Set driver globals */
452
	pAC->Pnmi.pDriverFileName    = DRIVER_FILE_NAME;
453
	pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE;
454
455
	SK_MEMSET(&(pAC->PnmiBackup), 0, sizeof(SK_PNMI_STRUCT_DATA));
456
	SK_MEMCPY(&(pAC->PnmiBackup), &(pAC->PnmiStruct), 
457
			sizeof(SK_PNMI_STRUCT_DATA));
458
459
	/* Register net device */
460
	retval = register_netdev(dev);
461
	if (retval) {
462
		printk(KERN_ERR "SKGE: Could not register device.\n");
463
		FreeResources(dev);
464
		free_netdev(dev);
465
		return retval;
466
	}
467
468
	/* Save initial device name */
469
	strcpy(pNet->InitialDevName, dev->name);
470
471
	/* Set network to off */
472
	netif_stop_queue(dev);
473
	netif_carrier_off(dev);
474
475
	/* Print adapter specific string from vpd and config settings */
476
	printk("%s: %s\n", pNet->InitialDevName, pAC->DeviceStr);
477
	printk("      PrefPort:%c  RlmtMode:%s\n",
478
		'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber,
479
		(pAC->RlmtMode==0)  ? "Check Link State" :
480
		((pAC->RlmtMode==1) ? "Check Link State" :
481
		((pAC->RlmtMode==3) ? "Check Local Port" :
482
		((pAC->RlmtMode==7) ? "Check Segmentation" :
483
		((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error")))));
484
485
	SkGeYellowLED(pAC, pAC->IoBase, 1);
486
487
	memcpy((caddr_t) &dev->dev_addr,
488
		(caddr_t) &pAC->Addr.Net[0].CurrentMacAddress, 6);
489
490
	/* First adapter... Create proc and print message */
491
#ifdef CONFIG_PROC_FS
492
	if (!sk98lin_proc_entry) {
493
		sk98lin_proc_entry = SK_TRUE;
494
		SK_MEMCPY(&SK_Root_Dir_entry, BootString,
495
			sizeof(SK_Root_Dir_entry) - 1);
496
497
		/*Create proc (directory)*/
498
		if(!pSkRootDir) {
499
			pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);
500
			if (!pSkRootDir) {
501
				printk(KERN_WARNING "%s: Unable to create /proc/net/%s",
502
					dev->name, SK_Root_Dir_entry);
503
			} else {
504
				pSkRootDir->owner = THIS_MODULE;
505
			}
506
		}
507
	}
508
509
	/* Create proc file */
510
	if (pSkRootDir && 
511
		(pProcFile = create_proc_entry(pNet->InitialDevName, S_IRUGO,
512
			pSkRootDir))) {
513
		pProcFile->proc_fops = &sk_proc_fops;
514
		pProcFile->data      = dev;
515
	}
516
517
#endif
518
519
	pNet->PortNr = 0;
520
	pNet->NetNr  = 0;
521
522
	sk98lin_boards_found++;
523
	pci_set_drvdata(pdev, dev);
524
525
	/* More then one port found */
526
	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
527
		if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) {
528
			printk(KERN_ERR "Unable to allocate etherdev "
529
				"structure!\n");
530
			return -ENODEV;
531
		}
532
533
		pAC->dev[1]   = dev;
534
		pNet          = dev->priv;
535
		pNet->PortNr  = 1;
536
		pNet->NetNr   = 1;
537
		pNet->pAC     = pAC;
538
539
		if (CHIP_ID_YUKON_2(pAC)) {
540
			dev->hard_start_xmit = &SkY2Xmit;
541
		} else {
542
			dev->hard_start_xmit = &SkGeXmit;
543
		}
544
		dev->open               = &SkGeOpen;
545
		dev->stop               = &SkGeClose;
546
		dev->get_stats          = &SkGeStats;
547
		dev->set_multicast_list = &SkGeSetRxMode;
548
		dev->set_mac_address    = &SkGeSetMacAddr;
549
		dev->do_ioctl           = &SkGeIoctl;
550
		dev->change_mtu         = &SkGeChangeMtu;
551
		dev->flags             &= ~IFF_RUNNING;
552
553
#ifdef NETIF_F_TSO
554
#ifdef USE_SK_TSO_FEATURE	
555
		if (CHIP_ID_YUKON_2(pAC)) {
556
			dev->features |= NETIF_F_TSO;
557
		}
558
#endif
559
#endif
560
#ifdef CONFIG_SK98LIN_ZEROCOPY
561
		/* Don't handle if Genesis chipset */
562
		if (pAC->GIni.GIChipId != CHIP_ID_GENESIS)
563
			dev->features |= NETIF_F_SG;
564
#endif
565
#ifdef USE_SK_TX_CHECKSUM
566
		/* Don't handle if Genesis chipset */
567
		if (pAC->GIni.GIChipId != CHIP_ID_GENESIS)
568
			dev->features |= NETIF_F_IP_CSUM;
569
#endif
570
571
		if (register_netdev(dev)) {
572
			printk(KERN_ERR "SKGE: Could not register device.\n");
573
			free_netdev(dev);
574
			pAC->dev[1] = pAC->dev[0];
575
		} else {
576
577
		/* Save initial device name */
578
		strcpy(pNet->InitialDevName, dev->name);
579
580
		/* Set network to off */
581
		netif_stop_queue(dev);
582
		netif_carrier_off(dev);
583
584
585
#ifdef CONFIG_PROC_FS
586
		if (pSkRootDir 
587
		    && (pProcFile = create_proc_entry(pNet->InitialDevName, 
588
						S_IRUGO, pSkRootDir))) {
589
			pProcFile->proc_fops = &sk_proc_fops;
590
			pProcFile->data      = dev;
591
		}
592
#endif
593
594
		memcpy((caddr_t) &dev->dev_addr,
595
		(caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6);
596
	
597
		printk("%s: %s\n", pNet->InitialDevName, pAC->DeviceStr);
598
		printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
599
		}
600
	}
601
602
	pAC->Index = sk98lin_boards_found;
603
	sk98lin_max_boards_found = sk98lin_boards_found;
604
	return 0;
605
}
606
607
278
608
279
/*****************************************************************************
609
/*****************************************************************************
280
 *
610
 *
Lines 299-305 Link Here
299
	dev->mem_start = pci_resource_start (pdev, 0);
629
	dev->mem_start = pci_resource_start (pdev, 0);
300
	pci_set_master(pdev);
630
	pci_set_master(pdev);
301
631
302
	if (pci_request_regions(pdev, pAC->Name) != 0) {
632
	if (pci_request_regions(pdev, DRIVER_FILE_NAME) != 0) {
303
		retval = 2;
633
		retval = 2;
304
		goto out_disable;
634
		goto out_disable;
305
	}
635
	}
Lines 320-326 Link Here
320
	/*
650
	/*
321
	 * Remap the regs into kernel space.
651
	 * Remap the regs into kernel space.
322
	 */
652
	 */
323
	pAC->IoBase = ioremap_nocache(dev->mem_start, 0x4000);
653
	pAC->IoBase = (char*)ioremap_nocache(dev->mem_start, 0x4000);
324
654
325
	if (!pAC->IoBase){
655
	if (!pAC->IoBase){
326
		retval = 3;
656
		retval = 3;
Lines 336-341 Link Here
336
	return retval;
666
	return retval;
337
}
667
}
338
668
669
#ifdef Y2_RECOVERY
670
/*****************************************************************************
671
 *
672
 * 	SkGeHandleKernelTimer - Handle the kernel timer requests
673
 *
674
 * Description:
675
 *	If the requested time interval for the timer has elapsed, 
676
 *	this function checks the link state.
677
 *
678
 * Returns:	N/A
679
 *
680
 */
681
static void SkGeHandleKernelTimer(
682
unsigned long ptr)  /* holds the pointer to adapter control context */
683
{
684
	DEV_NET         *pNet = (DEV_NET*) ptr;
685
686
	pNet->TimerExpired = SK_TRUE;
687
}
688
689
/*****************************************************************************
690
 *
691
 * 	sk98lin_check_timer - Resume the the card
692
 *
693
 * Description:
694
 *	This function checks the kernel timer
695
 *
696
 * Returns: N/A
697
 *	
698
 */
699
void SkGeCheckTimer(
700
DEV_NET *pNet)  /* holds the pointer to adapter control context */
701
{
702
	SK_AC           *pAC = pNet->pAC;
703
	SK_BOOL		StartTimer = SK_TRUE;
704
#ifdef Y2_RX_CHECK
705
	SK_BOOL		ZeroRegister = SK_FALSE;
706
	SK_U8		FifoReadPointer;
707
	SK_U8		FifoReadLevel;
708
	SK_U32		BmuStateMachine;
709
#endif
710
711
	if (pNet->InRecover)
712
		return;
713
714
#define TXPORT pAC->TxPort[pNet->PortNr][TX_PRIO_LOW]
715
#define RXPORT pAC->RxPort[pNet->PortNr]
716
717
	if (	(CHIP_ID_YUKON_2(pAC)) &&
718
		(netif_running(pAC->dev[pNet->PortNr]))) {
719
		
720
#ifdef Y2_RX_CHECK
721
		/* Check the receiver only if link is up*/
722
		if (	(netif_carrier_ok(pAC->dev[pNet->PortNr])) &&
723
			(pNet->LastJiffies == pAC->dev[pNet->PortNr]->last_rx)) {
724
725
			/* Nothing received */
726
			/* Get the register values */
727
			SK_IN8(pAC->IoBase, 0x0448, &FifoReadPointer);
728
			SK_IN8(pAC->IoBase, 0x044a, &FifoReadLevel);
729
			SK_IN32(pAC->IoBase, 0x043c, &BmuStateMachine);
730
731
			/* Check the register values */
732
			if 	((pNet->FifoReadPointer != FifoReadPointer) ||
733
				(pNet->FifoReadLevel != FifoReadLevel)      ||
734
				(pNet->BmuStateMachine != BmuStateMachine)) {
735
736
				/* Check the values */
737
				if 	((pNet->FifoReadPointer) ||
738
					(pNet->FifoReadLevel)	||
739
					(pNet->BmuStateMachine)) {
740
741
					/* Check the jiffies again */
742
					if (pNet->LastJiffies == 
743
						pAC->dev[pNet->PortNr]->last_rx) {
744
						/* Still nothing received */
745
						SkLocalEventQueue(pAC, SKGE_DRV, 
746
							SK_DRV_RECOVER,pNet->PortNr,-1,SK_FALSE);
747
					} else {
748
						ZeroRegister = SK_TRUE;
749
					}
750
				} else {
751
					pNet->FifoReadPointer = FifoReadPointer;
752
					pNet->FifoReadLevel = FifoReadLevel;
753
					pNet->BmuStateMachine = BmuStateMachine;
754
					
755
				}
756
			} else {
757
				if ((FifoReadLevel != 0) && 
758
					(FifoReadPointer > 0)) {
759
					/* Check the jiffies again */
760
					if (pNet->LastJiffies == 
761
						pAC->dev[pNet->PortNr]->last_rx) {
762
						/* Still nothing received */
763
						SkLocalEventQueue(pAC, SKGE_DRV, 
764
							SK_DRV_RECOVER,pNet->PortNr,-1,SK_FALSE);
765
					} else {
766
						ZeroRegister = SK_TRUE;
767
					}
768
				} else {
769
					ZeroRegister = SK_TRUE;
770
				}
771
			}
772
		} else {
773
			/* Clear the values */
774
			if 	((pNet->FifoReadPointer) ||
775
				(pNet->FifoReadLevel)	||
776
				(pNet->BmuStateMachine)) {
777
					ZeroRegister = SK_TRUE;
778
			}
779
			pNet->LastJiffies = 
780
				pAC->dev[pNet->PortNr]->last_rx;
781
		}
782
783
		/* Clear the register values */
784
		if (ZeroRegister) {
785
			pNet->FifoReadPointer = 0; 
786
			pNet->FifoReadLevel   = 0;
787
			pNet->BmuStateMachine = 0;
788
		}
789
#endif
790
791
		/* Checkthe transmitter */
792
		if (!(IS_Q_EMPTY(&TXPORT.TxAQ_working))) {
793
			if (TXPORT.LastDone != TXPORT.TxALET.Done) {
794
				TXPORT.LastDone = TXPORT.TxALET.Done;
795
				pNet->TransmitTimeoutTimer = 0;
796
			} else {
797
				pNet->TransmitTimeoutTimer++;
798
				if (pNet->TransmitTimeoutTimer >= 10) {
799
					pNet->TransmitTimeoutTimer = 0;
800
#ifdef CHECK_TRANSMIT_TIMEOUT
801
					StartTimer =  SK_FALSE;
802
					SkLocalEventQueue(pAC, SKGE_DRV, 
803
						SK_DRV_RECOVER,pNet->PortNr,-1,SK_FALSE);
804
#endif
805
				}
806
			} 
807
		} 
808
809
#ifdef CHECK_TRANSMIT_TIMEOUT
810
		pNet->KernelTimer.expires = jiffies + (HZ/4); /* 250ms */
811
		add_timer(&pNet->KernelTimer);
812
		pNet->TimerExpired = SK_FALSE;
813
#endif
814
	}
815
}
816
#endif
817
818
819
#ifdef CONFIG_PM
820
/*****************************************************************************
821
 *
822
 * 	sk98lin_resume - Resume the the card
823
 *
824
 * Description:
825
 *	This function resumes the card into the D0 state
826
 *
827
 * Returns: N/A
828
 *	
829
 */
830
static int sk98lin_resume(
831
struct pci_dev *pdev)   /* the device that is to resume */
832
{
833
	struct net_device   *dev  = pci_get_drvdata(pdev);
834
	DEV_NET		    *pNet = (DEV_NET*) dev->priv;
835
	SK_AC		    *pAC  = pNet->pAC;
836
	SK_U16		     PmCtlSts;
837
838
	/* Set the power state to D0 */
839
	pci_set_power_state(pdev, 0);
840
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
841
	pci_restore_state(pdev);
842
#else
843
	pci_restore_state(pdev, pAC->PciState);
844
#endif
845
846
	/* Set the adapter power state to D0 */
847
	SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
848
	PmCtlSts &= ~(PCI_PM_STATE_D3);	/* reset all DState bits */
849
	PmCtlSts |= PCI_PM_STATE_D0;
850
	SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PmCtlSts);
851
852
	/* Reinit the adapter and start the port again */
853
	pAC->BoardLevel = SK_INIT_DATA;
854
	SkDrvLeaveDiagMode(pAC);
855
856
	netif_device_attach(dev);
857
	netif_start_queue(dev);
858
	return 0;
859
}
860
 
861
/*****************************************************************************
862
 *
863
 * 	sk98lin_suspend - Suspend the card
864
 *
865
 * Description:
866
 *	This function suspends the card into a defined state
867
 *
868
 * Returns: N/A
869
 *	
870
 */
871
static int sk98lin_suspend(
872
struct pci_dev	*pdev,   /* pointer to the device that is to suspend */
873
u32		state)  /* what power state is desired by Linux?    */
874
{
875
	struct net_device   *dev  = pci_get_drvdata(pdev);
876
	DEV_NET		    *pNet = (DEV_NET*) dev->priv;
877
	SK_AC		    *pAC  = pNet->pAC;
878
	SK_U16		     PciPMControlStatus;
879
	SK_U16		     PciPMCapabilities;
880
	SK_MAC_ADDR	     MacAddr;
881
	int		     i;
882
883
	/* GEnesis and first yukon revs do not support power management */
884
	if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
885
		if (pAC->GIni.GIChipRev == 0) {
886
			return 0; /* power management not supported */
887
		}
888
	} 
889
890
	if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
891
		return 0; /* not supported for this chipset */
892
	}
893
894
	if (pAC->WolInfo.ConfiguredWolOptions == 0) {
895
		return 0; /* WOL possible, but disabled via ethtool */
896
	}
897
898
	if(netif_running(dev)) {
899
		netif_stop_queue(dev); /* stop device if running */
900
	}
901
902
	netif_device_detach(dev);
903
	
904
	/* read the PM control/status register from the PCI config space */
905
	SK_IN16(pAC->IoBase, PCI_C(pAC, PCI_PM_CTL_STS), &PciPMControlStatus);
906
907
	/* read the power management capabilities from the config space */
908
	SK_IN16(pAC->IoBase, PCI_C(pAC, PCI_PM_CAP_REG), &PciPMCapabilities);
909
910
	/* Enable WakeUp with Magic Packet - get MAC address from adapter */
911
	for (i = 0; i < SK_MAC_ADDR_LEN; i++) {
912
		/* virtual address: will be used for data */
913
		SK_IN8(pAC->IoBase, (B2_MAC_1 + i), &MacAddr.a[i]);
914
	}
915
916
	SkDrvEnterDiagMode(pAC);
917
	SkEnableWOMagicPacket(pAC, pAC->IoBase, MacAddr);
918
919
	pci_enable_wake(pdev, 3, 1);
920
	pci_enable_wake(pdev, 4, 1);	/* 4 == D3 cold */
921
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
922
	pci_save_state(pdev);
923
#else
924
	pci_save_state(pdev, pAC->PciState);
925
#endif
926
	pci_set_power_state(pdev, state); /* set the state */
927
928
	return 0;
929
}
930
931
932
/******************************************************************************
933
 *
934
 *	SkEnableWOMagicPacket - Enable Wake on Magic Packet on the adapter
935
 *
936
 * Context:
937
 *	init, pageable
938
 *	the adapter should be de-initialized before calling this function
939
 *
940
 * Returns:
941
 *	nothing
942
 */
943
944
static void SkEnableWOMagicPacket(
945
SK_AC         *pAC,      /* Adapter Control Context          */
946
SK_IOC         IoC,      /* I/O control context              */
947
SK_MAC_ADDR    MacAddr)  /* MacAddr expected in magic packet */
948
{
949
	SK_U16	Word;
950
	SK_U32	DWord;
951
	int 	i;
952
	int	HwPortIndex;
953
	int	Port = 0;
954
955
	/* use Port 0 as long as we do not have any dual port cards which support WOL */
956
	HwPortIndex = 0;
957
	DWord = 0;
958
959
	SK_OUT16(IoC, 0x0004, 0x0002);	/* clear S/W Reset */
960
	SK_OUT16(IoC, 0x0f10, 0x0002);	/* clear Link Reset */
961
962
	/*
963
	 * PHY Configuration:
964
	 * Autonegotioation is enalbed, advertise 10 HD, 10 FD,
965
	 * 100 HD, and 100 FD.
966
	 */
967
	if ((pAC->GIni.GIChipId == CHIP_ID_YUKON_EC) ||
968
		(pAC->GIni.GIChipId == CHIP_ID_YUKON) ||
969
		(pAC->GIni.GIChipId == CHIP_ID_YUKON_LITE)) {
970
971
		SK_OUT16(IoC, 0x0004, 0x0800);			/* enable CLK_RUN */
972
		SK_OUT8(IoC, 0x0007, 0xa9);			/* enable VAUX */
973
974
		/* WA code for COMA mode */
975
		/* Only for yukon plus based chipsets rev A3 */
976
		if (pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
977
			SK_IN32(IoC, B2_GP_IO, &DWord);
978
			DWord |= GP_DIR_9;			/* set to output */
979
			DWord &= ~GP_IO_9;			/* clear PHY reset (active high) */
980
			SK_OUT32(IoC, B2_GP_IO, DWord);		/* clear PHY reset */
981
		}
982
983
		if ((pAC->GIni.GIChipId == CHIP_ID_YUKON_LITE) ||
984
			(pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
985
			SK_OUT32(IoC, 0x0f04, 0x01f04001);	/* set PHY reset */
986
			SK_OUT32(IoC, 0x0f04, 0x01f04002);	/* clear PHY reset */
987
		} else {
988
			SK_OUT8(IoC, 0x0f04, 0x02);		/* clear PHY reset */
989
		}
990
991
		SK_OUT8(IoC, 0x0f00, 0x02);			/* clear MAC reset */
992
		SkGmPhyWrite(pAC, IoC, Port, 4, 0x01e1);	/* advertise 10/100 HD/FD */
993
		SkGmPhyWrite(pAC, IoC, Port, 9, 0x0000);	/* do not advertise 1000 HD/FD */
994
		SkGmPhyWrite(pAC, IoC, Port, 00, 0xB300);	/* 100 MBit, disable Autoneg */
995
	} else if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
996
		SK_OUT8(IoC, 0x0007, 0xa9);			/* enable VAUX */
997
		SK_OUT8(IoC, 0x0f04, 0x02);			/* clear PHY reset */
998
		SK_OUT8(IoC, 0x0f00, 0x02);			/* clear MAC reset */
999
		SkGmPhyWrite(pAC, IoC, Port, 16, 0x0130);	/* Enable Automatic Crossover */
1000
		SkGmPhyWrite(pAC, IoC, Port, 00, 0xB300);	/* 100 MBit, disable Autoneg */
1001
	}
1002
1003
1004
	/*
1005
	 * MAC Configuration:
1006
	 * Set the MAC to 100 HD and enable the auto update features
1007
	 * for Speed, Flow Control and Duplex Mode.
1008
	 * If autonegotiation completes successfully the
1009
	 * MAC takes the link parameters from the PHY.
1010
	 * If the link partner doesn't support autonegotiation
1011
	 * the MAC can receive magic packets if the link partner
1012
	 * uses 100 HD.
1013
	 */
1014
	SK_OUT16(IoC, 0x2804, 0x3832);
1015
   
1016
1017
	/*
1018
	 * Set Up Magic Packet parameters
1019
	 */
1020
	for (i = 0; i < 6; i+=2) {		/* set up magic packet MAC address */
1021
		SK_IN16(IoC, 0x100 + i, &Word);
1022
		SK_OUT16(IoC, 0xf24 + i, Word);
1023
	}
1024
1025
	SK_OUT16(IoC, 0x0f20, 0x0208);		/* enable PME on magic packet */
1026
						/* and on wake up frame */
1027
1028
	/*
1029
	 * Set up PME generation
1030
	 */
1031
	/* set PME legacy mode */
1032
	/* Only for PCI express based chipsets */
1033
	if ((pAC->GIni.GIChipId == CHIP_ID_YUKON_EC) ||
1034
		(pAC->GIni.GIChipId == CHIP_ID_YUKON_FE)) {
1035
		SkPciReadCfgDWord(pAC, 0x40, &DWord);
1036
		DWord |= 0x8000;
1037
		SkPciWriteCfgDWord(pAC, 0x40, DWord);
1038
	}
1039
1040
	/* clear PME status and switch adapter to DState */
1041
	SkPciReadCfgWord(pAC, 0x4c, &Word);
1042
	Word |= 0x103;
1043
	SkPciWriteCfgWord(pAC, 0x4c, Word);
1044
}	/* SkEnableWOMagicPacket */
1045
#endif
1046
339
1047
340
/*****************************************************************************
1048
/*****************************************************************************
341
 *
1049
 *
Lines 354-373 Link Here
354
DEV_NET		*pNet;
1062
DEV_NET		*pNet;
355
SK_AC		*pAC;
1063
SK_AC		*pAC;
356
1064
357
	pNet = netdev_priv(dev);
1065
	if (dev->priv) {
358
	pAC = pNet->pAC;
1066
		pNet = (DEV_NET*) dev->priv;
359
	AllocFlag = pAC->AllocFlag;
1067
		pAC = pNet->pAC;
360
	if (pAC->PciDev) {
1068
		AllocFlag = pAC->AllocFlag;
361
		pci_release_regions(pAC->PciDev);
1069
		if (pAC->PciDev) {
362
	}
1070
			pci_release_regions(pAC->PciDev);
363
	if (AllocFlag & SK_ALLOC_IRQ) {
1071
		}
364
		free_irq(dev->irq, dev);
1072
		if (AllocFlag & SK_ALLOC_IRQ) {
365
	}
1073
			free_irq(dev->irq, dev);
366
	if (pAC->IoBase) {
1074
		}
367
		iounmap(pAC->IoBase);
1075
		if (pAC->IoBase) {
368
	}
1076
			iounmap(pAC->IoBase);
369
	if (pAC->pDescrMem) {
1077
		}
370
		BoardFreeMem(pAC);
1078
		if (CHIP_ID_YUKON_2(pAC)) {
1079
			SkY2FreeResources(pAC);
1080
		} else {
1081
			BoardFreeMem(pAC);
1082
		}
371
	}
1083
	}
372
	
1084
	
373
} /* FreeResources */
1085
} /* FreeResources */
Lines 376-381 Link Here
376
MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver");
1088
MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver");
377
MODULE_LICENSE("GPL");
1089
MODULE_LICENSE("GPL");
378
1090
1091
379
#ifdef LINK_SPEED_A
1092
#ifdef LINK_SPEED_A
380
static char *Speed_A[SK_MAX_CARD_PARAM] = LINK_SPEED;
1093
static char *Speed_A[SK_MAX_CARD_PARAM] = LINK_SPEED;
381
#else
1094
#else
Lines 457-465 Link Here
457
static int   IntsPerSec[SK_MAX_CARD_PARAM];
1170
static int   IntsPerSec[SK_MAX_CARD_PARAM];
458
static char *Moderation[SK_MAX_CARD_PARAM];
1171
static char *Moderation[SK_MAX_CARD_PARAM];
459
static char *ModerationMask[SK_MAX_CARD_PARAM];
1172
static char *ModerationMask[SK_MAX_CARD_PARAM];
460
static char *AutoSizing[SK_MAX_CARD_PARAM];
461
static char *Stats[SK_MAX_CARD_PARAM];
462
1173
1174
static char *LowLatency[SK_MAX_CARD_PARAM];
1175
1176
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
463
module_param_array(Speed_A, charp, NULL, 0);
1177
module_param_array(Speed_A, charp, NULL, 0);
464
module_param_array(Speed_B, charp, NULL, 0);
1178
module_param_array(Speed_B, charp, NULL, 0);
465
module_param_array(AutoNeg_A, charp, NULL, 0);
1179
module_param_array(AutoNeg_A, charp, NULL, 0);
Lines 476-484 Link Here
476
/* used for interrupt moderation */
1190
/* used for interrupt moderation */
477
module_param_array(IntsPerSec, int, NULL, 0);
1191
module_param_array(IntsPerSec, int, NULL, 0);
478
module_param_array(Moderation, charp, NULL, 0);
1192
module_param_array(Moderation, charp, NULL, 0);
479
module_param_array(Stats, charp, NULL, 0);
480
module_param_array(ModerationMask, charp, NULL, 0);
1193
module_param_array(ModerationMask, charp, NULL, 0);
481
module_param_array(AutoSizing, charp, NULL, 0);
1194
module_param_array(LowLatency, charp, NULL, 0);
1195
#else
1196
MODULE_PARM(Speed_A,    "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1197
MODULE_PARM(Speed_B,    "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1198
MODULE_PARM(AutoNeg_A,  "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1199
MODULE_PARM(AutoNeg_B,  "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1200
MODULE_PARM(DupCap_A,   "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1201
MODULE_PARM(DupCap_B,   "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1202
MODULE_PARM(FlowCtrl_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1203
MODULE_PARM(FlowCtrl_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1204
MODULE_PARM(Role_A,	"1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1205
MODULE_PARM(Role_B,	"1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1206
MODULE_PARM(ConType,	"1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1207
MODULE_PARM(PrefPort,   "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1208
MODULE_PARM(RlmtMode,   "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1209
MODULE_PARM(IntsPerSec,     "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "i");
1210
MODULE_PARM(Moderation,     "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1211
MODULE_PARM(ModerationMask, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1212
MODULE_PARM(LowLatency, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
1213
#endif
1214
1215
1216
/*****************************************************************************
1217
 *
1218
 * 	sk98lin_remove_device - device deinit function
1219
 *
1220
 * Description:
1221
 *	Disable adapter if it is still running, free resources,
1222
 *	free device struct.
1223
 *
1224
 * Returns: N/A
1225
 */
1226
1227
static void sk98lin_remove_device(struct pci_dev *pdev)
1228
{
1229
DEV_NET		*pNet;
1230
SK_AC		*pAC;
1231
struct SK_NET_DEVICE *next;
1232
unsigned long Flags;
1233
struct net_device *dev = pci_get_drvdata(pdev);
1234
1235
1236
	/* Device not available. Return. */
1237
	if (!dev)
1238
		return;
1239
1240
	pNet = (DEV_NET*) dev->priv;
1241
	pAC = pNet->pAC;
1242
	next = pAC->Next;
1243
1244
	netif_stop_queue(dev);
1245
	SkGeYellowLED(pAC, pAC->IoBase, 0);
1246
1247
	if(pAC->BoardLevel == SK_INIT_RUN) {
1248
		/* board is still alive */
1249
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1250
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP,
1251
					0, -1, SK_FALSE);
1252
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP,
1253
					1, -1, SK_TRUE);
1254
1255
		/* disable interrupts */
1256
		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
1257
		SkGeDeInit(pAC, pAC->IoBase);
1258
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1259
		pAC->BoardLevel = SK_INIT_DATA;
1260
		/* We do NOT check here, if IRQ was pending, of course*/
1261
	}
1262
1263
	if(pAC->BoardLevel == SK_INIT_IO) {
1264
		/* board is still alive */
1265
		SkGeDeInit(pAC, pAC->IoBase);
1266
		pAC->BoardLevel = SK_INIT_DATA;
1267
	}
1268
1269
	if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2){
1270
		unregister_netdev(pAC->dev[1]);
1271
		free_netdev(pAC->dev[1]);
1272
	}
1273
1274
	FreeResources(dev);
1275
1276
#ifdef CONFIG_PROC_FS
1277
	/* Remove the sk98lin procfs device entries */
1278
	if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2){
1279
		remove_proc_entry(pAC->dev[1]->name, pSkRootDir);
1280
	}
1281
	remove_proc_entry(pNet->InitialDevName, pSkRootDir);
1282
#endif
1283
1284
	dev->get_stats = NULL;
1285
	/*
1286
	 * otherwise unregister_netdev calls get_stats with
1287
	 * invalid IO ...  :-(
1288
	 */
1289
	unregister_netdev(dev);
1290
	free_netdev(dev);
1291
	kfree(pAC);
1292
	sk98lin_max_boards_found--;
1293
1294
#ifdef CONFIG_PROC_FS
1295
	/* Remove all Proc entries if last device */
1296
	if (sk98lin_max_boards_found == 0) {
1297
		/* clear proc-dir */
1298
		remove_proc_entry(pSkRootDir->name, proc_net);
1299
	}
1300
#endif
1301
1302
}
1303
482
1304
483
/*****************************************************************************
1305
/*****************************************************************************
484
 *
1306
 *
Lines 516-527 Link Here
516
		spin_lock_init(&pAC->TxPort[i][0].TxDesRingLock);
1338
		spin_lock_init(&pAC->TxPort[i][0].TxDesRingLock);
517
		spin_lock_init(&pAC->RxPort[i].RxDesRingLock);
1339
		spin_lock_init(&pAC->RxPort[i].RxDesRingLock);
518
	}
1340
	}
519
	spin_lock_init(&pAC->SlowPathLock);
520
1341
521
	/* setup phy_id blink timer */
1342
	spin_lock_init(&pAC->SlowPathLock);
522
	pAC->BlinkTimer.function = SkGeBlinkTimer;
1343
	spin_lock_init(&pAC->TxQueueLock);	/* for Yukon2 chipsets */
523
	pAC->BlinkTimer.data = (unsigned long) dev;
1344
	spin_lock_init(&pAC->SetPutIndexLock);	/* for Yukon2 chipsets */
524
	init_timer(&pAC->BlinkTimer);
525
1345
526
	/* level 0 init common modules here */
1346
	/* level 0 init common modules here */
527
	
1347
	
Lines 545-554 Link Here
545
	SK_PNMI_SET_DRIVER_DESCR(pAC, DescrString);
1365
	SK_PNMI_SET_DRIVER_DESCR(pAC, DescrString);
546
	SK_PNMI_SET_DRIVER_VER(pAC, VerStr);
1366
	SK_PNMI_SET_DRIVER_VER(pAC, VerStr);
547
1367
548
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
549
550
	/* level 1 init common modules here (HW init) */
1368
	/* level 1 init common modules here (HW init) */
551
	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
552
	if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
1369
	if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
553
		printk("sk98lin: HWInit (1) failed.\n");
1370
		printk("sk98lin: HWInit (1) failed.\n");
554
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1371
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
Lines 560-610 Link Here
560
	SkAddrInit( pAC, pAC->IoBase, SK_INIT_IO);
1377
	SkAddrInit( pAC, pAC->IoBase, SK_INIT_IO);
561
	SkRlmtInit( pAC, pAC->IoBase, SK_INIT_IO);
1378
	SkRlmtInit( pAC, pAC->IoBase, SK_INIT_IO);
562
	SkTimerInit(pAC, pAC->IoBase, SK_INIT_IO);
1379
	SkTimerInit(pAC, pAC->IoBase, SK_INIT_IO);
1380
#ifdef Y2_RECOVERY
1381
	/* mark entries invalid */
1382
	pAC->LastPort = 3;
1383
	pAC->LastOpc = 0xFF;
1384
#endif
563
1385
564
	/* Set chipset type support */
1386
	/* Set chipset type support */
565
	pAC->ChipsetType = 0;
566
	if ((pAC->GIni.GIChipId == CHIP_ID_YUKON) ||
1387
	if ((pAC->GIni.GIChipId == CHIP_ID_YUKON) ||
567
		(pAC->GIni.GIChipId == CHIP_ID_YUKON_LITE)) {
1388
		(pAC->GIni.GIChipId == CHIP_ID_YUKON_LITE) ||
568
		pAC->ChipsetType = 1;
1389
		(pAC->GIni.GIChipId == CHIP_ID_YUKON_LP)) {
1390
		pAC->ChipsetType = 1;	/* Yukon chipset (descriptor logic) */
1391
	} else if (CHIP_ID_YUKON_2(pAC)) {
1392
		pAC->ChipsetType = 2;	/* Yukon2 chipset (list logic) */
1393
	} else {
1394
		pAC->ChipsetType = 0;	/* Genesis chipset (descriptor logic) */
569
	}
1395
	}
570
1396
1397
	/* wake on lan support */
1398
	pAC->WolInfo.SupportedWolOptions = 0;
1399
#if defined (ETHTOOL_GWOL) && defined (ETHTOOL_SWOL)
1400
	if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) {
1401
		pAC->WolInfo.SupportedWolOptions  = WAKE_MAGIC;
1402
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
1403
			if (pAC->GIni.GIChipRev == 0) {
1404
				pAC->WolInfo.SupportedWolOptions = 0;
1405
			}
1406
		} 
1407
	}
1408
#endif
1409
	pAC->WolInfo.ConfiguredWolOptions = pAC->WolInfo.SupportedWolOptions;
1410
571
	GetConfiguration(pAC);
1411
	GetConfiguration(pAC);
572
	if (pAC->RlmtNets == 2) {
1412
	if (pAC->RlmtNets == 2) {
573
		pAC->GIni.GIPortUsage = SK_MUL_LINK;
1413
 		pAC->GIni.GIPortUsage = SK_MUL_LINK;
574
	}
1414
	}
575
1415
576
	pAC->BoardLevel = SK_INIT_IO;
1416
	pAC->BoardLevel = SK_INIT_IO;
577
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1417
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
578
1418
579
	if (pAC->GIni.GIMacsFound == 2) {
1419
	if (!CHIP_ID_YUKON_2(pAC)) {
580
		 Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev);
1420
#ifdef CONFIG_SK98LIN_NAPI
581
	} else if (pAC->GIni.GIMacsFound == 1) {
1421
		dev->poll =  &SkGePoll;
582
		Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ,
1422
		dev->weight = 64;
583
			pAC->Name, dev);
1423
#endif
584
	} else {
1424
		if (pAC->GIni.GIMacsFound == 2) {
585
		printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n",
1425
			Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, dev->name, dev);
586
		       pAC->GIni.GIMacsFound);
1426
		} else if (pAC->GIni.GIMacsFound == 1) {
587
		return -EAGAIN;
1427
			Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, dev->name, dev);
1428
		} else {
1429
			printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n",
1430
				pAC->GIni.GIMacsFound);
1431
			return -EAGAIN;
1432
		}
1433
	}
1434
	else {
1435
		Ret = request_irq(dev->irq, SkY2Isr, SA_SHIRQ, dev->name, dev);
1436
#ifdef CONFIG_SK98LIN_NAPI
1437
		dev->poll =  &SkY2Poll;
1438
		dev->weight = 64;
1439
#endif
588
	}
1440
	}
589
1441
590
	if (Ret) {
1442
	if (Ret) {
591
		printk(KERN_WARNING "sk98lin: Requested IRQ %d is busy.\n",
1443
		printk(KERN_WARNING "sk98lin: Requested IRQ %d is busy.\n",
592
		       dev->irq);
1444
			dev->irq);
593
		return -EAGAIN;
1445
		return -EAGAIN;
594
	}
1446
	}
595
	pAC->AllocFlag |= SK_ALLOC_IRQ;
1447
	pAC->AllocFlag |= SK_ALLOC_IRQ;
596
1448
597
	/* Alloc memory for this board (Mem for RxD/TxD) : */
1449
	/* 
598
	if(!BoardAllocMem(pAC)) {
1450
	** Alloc descriptor/LETable memory for this board (both RxD/TxD)
599
		printk("No memory for descriptor rings.\n");
1451
	*/
600
       		return(-EAGAIN);
1452
	if (CHIP_ID_YUKON_2(pAC)) {
1453
		if (!SkY2AllocateResources(pAC)) {
1454
			printk("No memory for Yukon2 settings\n");
1455
			return(-EAGAIN);
1456
		}
1457
	} else {
1458
		if(!BoardAllocMem(pAC)) {
1459
			printk("No memory for descriptor rings.\n");
1460
			return(-EAGAIN);
1461
		}
601
	}
1462
	}
602
1463
1464
#ifdef SK_USE_CSUM
603
	SkCsSetReceiveFlags(pAC,
1465
	SkCsSetReceiveFlags(pAC,
604
		SKCS_PROTO_IP | SKCS_PROTO_TCP | SKCS_PROTO_UDP,
1466
		SKCS_PROTO_IP | SKCS_PROTO_TCP | SKCS_PROTO_UDP,
605
		&pAC->CsOfs1, &pAC->CsOfs2, 0);
1467
		&pAC->CsOfs1, &pAC->CsOfs2, 0);
606
	pAC->CsOfs = (pAC->CsOfs2 << 16) | pAC->CsOfs1;
1468
	pAC->CsOfs = (pAC->CsOfs2 << 16) | pAC->CsOfs1;
1469
#endif
607
1470
1471
	/*
1472
	** Function BoardInitMem() for Yukon dependent settings...
1473
	*/
608
	BoardInitMem(pAC);
1474
	BoardInitMem(pAC);
609
	/* tschilling: New common function with minimum size check. */
1475
	/* tschilling: New common function with minimum size check. */
610
	DualNet = SK_FALSE;
1476
	DualNet = SK_FALSE;
Lines 616-626 Link Here
616
		pAC,
1482
		pAC,
617
		pAC->ActivePort,
1483
		pAC->ActivePort,
618
		DualNet)) {
1484
		DualNet)) {
619
		BoardFreeMem(pAC);
1485
		if (CHIP_ID_YUKON_2(pAC)) {
1486
			SkY2FreeResources(pAC);
1487
		} else {
1488
			BoardFreeMem(pAC);
1489
		}
1490
620
		printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
1491
		printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
621
		return(-EAGAIN);
1492
		return(-EAGAIN);
622
	}
1493
	}
623
1494
1495
	/*
1496
	 * Register the device here
1497
	 */
1498
	pAC->Next = SkGeRootDev;
1499
	SkGeRootDev = dev;
1500
624
	return (0);
1501
	return (0);
625
} /* SkGeBoardInit */
1502
} /* SkGeBoardInit */
626
1503
Lines 710-725 Link Here
710
1587
711
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1588
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
712
		("BoardFreeMem\n"));
1589
		("BoardFreeMem\n"));
1590
1591
	if (pAC->pDescrMem) {
1592
713
#if (BITS_PER_LONG == 32)
1593
#if (BITS_PER_LONG == 32)
714
	AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound + 8;
1594
		AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound + 8;
715
#else
1595
#else
716
	AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound
1596
		AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound
717
		+ RX_RING_SIZE + 8;
1597
			+ RX_RING_SIZE + 8;
718
#endif
1598
#endif
719
1599
720
	pci_free_consistent(pAC->PciDev, AllocLength,
1600
		pci_free_consistent(pAC->PciDev, AllocLength,
721
			    pAC->pDescrMem, pAC->pDescrMemDMA);
1601
			    pAC->pDescrMem, pAC->pDescrMemDMA);
722
	pAC->pDescrMem = NULL;
1602
		pAC->pDescrMem = NULL;
1603
	}
723
} /* BoardFreeMem */
1604
} /* BoardFreeMem */
724
1605
725
1606
Lines 728-734 Link Here
728
 * 	BoardInitMem - initiate the descriptor rings
1609
 * 	BoardInitMem - initiate the descriptor rings
729
 *
1610
 *
730
 * Description:
1611
 * Description:
731
 *	This function sets the descriptor rings up in memory.
1612
 *	This function sets the descriptor rings or LETables up in memory.
732
 *	The adapter is initialized with the descriptor start addresses.
1613
 *	The adapter is initialized with the descriptor start addresses.
733
 *
1614
 *
734
 * Returns:	N/A
1615
 * Returns:	N/A
Lines 743-776 Link Here
743
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1624
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
744
		("BoardInitMem\n"));
1625
		("BoardInitMem\n"));
745
1626
746
	RxDescrSize = (((sizeof(RXD) - 1) / DESCR_ALIGN) + 1) * DESCR_ALIGN;
1627
	if (!pAC->GIni.GIYukon2) {
747
	pAC->RxDescrPerRing = RX_RING_SIZE / RxDescrSize;
1628
		RxDescrSize = (((sizeof(RXD) - 1) / DESCR_ALIGN) + 1) * DESCR_ALIGN;
748
	TxDescrSize = (((sizeof(TXD) - 1) / DESCR_ALIGN) + 1) * DESCR_ALIGN;
1629
		pAC->RxDescrPerRing = RX_RING_SIZE / RxDescrSize;
749
	pAC->TxDescrPerRing = TX_RING_SIZE / RxDescrSize;
1630
		TxDescrSize = (((sizeof(TXD) - 1) / DESCR_ALIGN) + 1) * DESCR_ALIGN;
1631
		pAC->TxDescrPerRing = TX_RING_SIZE / RxDescrSize;
750
	
1632
	
751
	for (i=0; i<pAC->GIni.GIMacsFound; i++) {
1633
		for (i=0; i<pAC->GIni.GIMacsFound; i++) {
752
		SetupRing(
1634
			SetupRing(
753
			pAC,
1635
				pAC,
754
			pAC->TxPort[i][0].pTxDescrRing,
1636
				pAC->TxPort[i][0].pTxDescrRing,
755
			pAC->TxPort[i][0].VTxDescrRing,
1637
				pAC->TxPort[i][0].VTxDescrRing,
756
			(RXD**)&pAC->TxPort[i][0].pTxdRingHead,
1638
				(RXD**)&pAC->TxPort[i][0].pTxdRingHead,
757
			(RXD**)&pAC->TxPort[i][0].pTxdRingTail,
1639
				(RXD**)&pAC->TxPort[i][0].pTxdRingTail,
758
			(RXD**)&pAC->TxPort[i][0].pTxdRingPrev,
1640
				(RXD**)&pAC->TxPort[i][0].pTxdRingPrev,
759
			&pAC->TxPort[i][0].TxdRingFree,
1641
				&pAC->TxPort[i][0].TxdRingFree,
760
			SK_TRUE);
1642
				&pAC->TxPort[i][0].TxdRingPrevFree,
761
		SetupRing(
1643
				SK_TRUE);
762
			pAC,
1644
			SetupRing(
763
			pAC->RxPort[i].pRxDescrRing,
1645
				pAC,
764
			pAC->RxPort[i].VRxDescrRing,
1646
				pAC->RxPort[i].pRxDescrRing,
765
			&pAC->RxPort[i].pRxdRingHead,
1647
				pAC->RxPort[i].VRxDescrRing,
766
			&pAC->RxPort[i].pRxdRingTail,
1648
				&pAC->RxPort[i].pRxdRingHead,
767
			&pAC->RxPort[i].pRxdRingPrev,
1649
				&pAC->RxPort[i].pRxdRingTail,
768
			&pAC->RxPort[i].RxdRingFree,
1650
				&pAC->RxPort[i].pRxdRingPrev,
769
			SK_FALSE);
1651
				&pAC->RxPort[i].RxdRingFree,
1652
				&pAC->RxPort[i].RxdRingFree,
1653
				SK_FALSE);
1654
		}
770
	}
1655
	}
771
} /* BoardInitMem */
1656
} /* BoardInitMem */
772
1657
773
774
/*****************************************************************************
1658
/*****************************************************************************
775
 *
1659
 *
776
 * 	SetupRing - create one descriptor ring
1660
 * 	SetupRing - create one descriptor ring
Lines 790-795 Link Here
790
RXD		**ppRingTail,	/* address where the tail should be written */
1674
RXD		**ppRingTail,	/* address where the tail should be written */
791
RXD		**ppRingPrev,	/* address where the tail should be written */
1675
RXD		**ppRingPrev,	/* address where the tail should be written */
792
int		*pRingFree,	/* address where the # of free descr. goes */
1676
int		*pRingFree,	/* address where the # of free descr. goes */
1677
int		*pRingPrevFree,	/* address where the # of free descr. goes */
793
SK_BOOL		IsTx)		/* flag: is this a tx ring */
1678
SK_BOOL		IsTx)		/* flag: is this a tx ring */
794
{
1679
{
795
int	i;		/* loop counter */
1680
int	i;		/* loop counter */
Lines 832-842 Link Here
832
	}
1717
	}
833
	pPrevDescr->pNextRxd = (RXD*) pMemArea;
1718
	pPrevDescr->pNextRxd = (RXD*) pMemArea;
834
	pPrevDescr->VNextRxd = VMemArea;
1719
	pPrevDescr->VNextRxd = VMemArea;
835
	pDescr = (RXD*) pMemArea;
1720
	pDescr               = (RXD*) pMemArea;
836
	*ppRingHead = (RXD*) pMemArea;
1721
	*ppRingHead          = (RXD*) pMemArea;
837
	*ppRingTail = *ppRingHead;
1722
	*ppRingTail          = *ppRingHead;
838
	*ppRingPrev = pPrevDescr;
1723
	*ppRingPrev          = pPrevDescr;
839
	*pRingFree = DescrNum;
1724
	*pRingFree           = DescrNum;
1725
	*pRingPrevFree       = DescrNum;
840
} /* SetupRing */
1726
} /* SetupRing */
841
1727
842
1728
Lines 901-907 Link Here
901
SK_AC		*pAC;
1787
SK_AC		*pAC;
902
SK_U32		IntSrc;		/* interrupts source register contents */	
1788
SK_U32		IntSrc;		/* interrupts source register contents */	
903
1789
904
	pNet = netdev_priv(dev);
1790
	pNet = (DEV_NET*) dev->priv;
905
	pAC = pNet->pAC;
1791
	pAC = pNet->pAC;
906
	
1792
	
907
	/*
1793
	/*
Lines 912-917 Link Here
912
		return SkIsrRetNone;
1798
		return SkIsrRetNone;
913
	}
1799
	}
914
1800
1801
#ifdef CONFIG_SK98LIN_NAPI
1802
	if (netif_rx_schedule_prep(dev)) {
1803
		pAC->GIni.GIValIrqMask &= ~(NAPI_DRV_IRQS);
1804
		SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
1805
		__netif_rx_schedule(dev);
1806
	}
1807
1808
#ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1809
	if (IntSrc & IS_XA1_F) {
1810
		CLEAR_TX_IRQ(0, TX_PRIO_LOW);
1811
	}
1812
	if (IntSrc & IS_XA2_F) {
1813
		CLEAR_TX_IRQ(1, TX_PRIO_LOW);
1814
	}
1815
#endif
1816
1817
1818
#else
915
	while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
1819
	while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
916
#if 0 /* software irq currently not used */
1820
#if 0 /* software irq currently not used */
917
		if (IntSrc & IS_IRQ_SW) {
1821
		if (IntSrc & IS_IRQ_SW) {
Lines 925-930 Link Here
925
				SK_DBGCAT_DRV_INT_SRC,
1829
				SK_DBGCAT_DRV_INT_SRC,
926
				("EOF RX1 IRQ\n"));
1830
				("EOF RX1 IRQ\n"));
927
			ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1831
			ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1832
			CLEAR_AND_START_RX(0);
928
			SK_PNMI_CNT_RX_INTR(pAC, 0);
1833
			SK_PNMI_CNT_RX_INTR(pAC, 0);
929
		}
1834
		}
930
		if (IntSrc & IS_R2_F) {
1835
		if (IntSrc & IS_R2_F) {
Lines 932-937 Link Here
932
				SK_DBGCAT_DRV_INT_SRC,
1837
				SK_DBGCAT_DRV_INT_SRC,
933
				("EOF RX2 IRQ\n"));
1838
				("EOF RX2 IRQ\n"));
934
			ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1839
			ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1840
			CLEAR_AND_START_RX(1);
935
			SK_PNMI_CNT_RX_INTR(pAC, 1);
1841
			SK_PNMI_CNT_RX_INTR(pAC, 1);
936
		}
1842
		}
937
#ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1843
#ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
Lines 939-944 Link Here
939
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1845
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
940
				SK_DBGCAT_DRV_INT_SRC,
1846
				SK_DBGCAT_DRV_INT_SRC,
941
				("EOF AS TX1 IRQ\n"));
1847
				("EOF AS TX1 IRQ\n"));
1848
			CLEAR_TX_IRQ(0, TX_PRIO_LOW);
942
			SK_PNMI_CNT_TX_INTR(pAC, 0);
1849
			SK_PNMI_CNT_TX_INTR(pAC, 0);
943
			spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
1850
			spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
944
			FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]);
1851
			FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]);
Lines 948-953 Link Here
948
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1855
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
949
				SK_DBGCAT_DRV_INT_SRC,
1856
				SK_DBGCAT_DRV_INT_SRC,
950
				("EOF AS TX2 IRQ\n"));
1857
				("EOF AS TX2 IRQ\n"));
1858
			CLEAR_TX_IRQ(1, TX_PRIO_LOW);
951
			SK_PNMI_CNT_TX_INTR(pAC, 1);
1859
			SK_PNMI_CNT_TX_INTR(pAC, 1);
952
			spin_lock(&pAC->TxPort[1][TX_PRIO_LOW].TxDesRingLock);
1860
			spin_lock(&pAC->TxPort[1][TX_PRIO_LOW].TxDesRingLock);
953
			FreeTxDescriptors(pAC, &pAC->TxPort[1][TX_PRIO_LOW]);
1861
			FreeTxDescriptors(pAC, &pAC->TxPort[1][TX_PRIO_LOW]);
Lines 958-995 Link Here
958
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1866
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
959
				SK_DBGCAT_DRV_INT_SRC,
1867
				SK_DBGCAT_DRV_INT_SRC,
960
				("EOF SY TX1 IRQ\n"));
1868
				("EOF SY TX1 IRQ\n"));
1869
			CLEAR_TX_IRQ(0, TX_PRIO_HIGH);
961
			SK_PNMI_CNT_TX_INTR(pAC, 1);
1870
			SK_PNMI_CNT_TX_INTR(pAC, 1);
962
			spin_lock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
1871
			spin_lock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
963
			FreeTxDescriptors(pAC, 0, TX_PRIO_HIGH);
1872
			FreeTxDescriptors(pAC, 0, TX_PRIO_HIGH);
964
			spin_unlock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
1873
			spin_unlock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
965
			ClearTxIrq(pAC, 0, TX_PRIO_HIGH);
966
		}
1874
		}
967
		if (IntSrc & IS_XS2_F) {
1875
		if (IntSrc & IS_XS2_F) {
968
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1876
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
969
				SK_DBGCAT_DRV_INT_SRC,
1877
				SK_DBGCAT_DRV_INT_SRC,
970
				("EOF SY TX2 IRQ\n"));
1878
				("EOF SY TX2 IRQ\n"));
1879
			CLEAR_TX_IRQ(1, TX_PRIO_HIGH);
971
			SK_PNMI_CNT_TX_INTR(pAC, 1);
1880
			SK_PNMI_CNT_TX_INTR(pAC, 1);
972
			spin_lock(&pAC->TxPort[1][TX_PRIO_HIGH].TxDesRingLock);
1881
			spin_lock(&pAC->TxPort[1][TX_PRIO_HIGH].TxDesRingLock);
973
			FreeTxDescriptors(pAC, 1, TX_PRIO_HIGH);
1882
			FreeTxDescriptors(pAC, 1, TX_PRIO_HIGH);
974
			spin_unlock(&pAC->TxPort[1][TX_PRIO_HIGH].TxDesRingLock);
1883
			spin_unlock(&pAC->TxPort[1][TX_PRIO_HIGH].TxDesRingLock);
975
			ClearTxIrq(pAC, 1, TX_PRIO_HIGH);
976
		}
1884
		}
977
#endif
1885
#endif
978
#endif
1886
#endif
979
1887
980
		/* do all IO at once */
981
		if (IntSrc & IS_R1_F)
982
			ClearAndStartRx(pAC, 0);
983
		if (IntSrc & IS_R2_F)
984
			ClearAndStartRx(pAC, 1);
985
#ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
986
		if (IntSrc & IS_XA1_F)
987
			ClearTxIrq(pAC, 0, TX_PRIO_LOW);
988
		if (IntSrc & IS_XA2_F)
989
			ClearTxIrq(pAC, 1, TX_PRIO_LOW);
990
#endif
991
		SK_IN32(pAC->IoBase, B0_ISRC, &IntSrc);
1888
		SK_IN32(pAC->IoBase, B0_ISRC, &IntSrc);
992
	} /* while (IntSrc & IRQ_MASK != 0) */
1889
	} /* while (IntSrc & IRQ_MASK != 0) */
1890
#endif
993
1891
994
	IntSrc &= pAC->GIni.GIValIrqMask;
1892
	IntSrc &= pAC->GIni.GIValIrqMask;
995
	if ((IntSrc & SPECIAL_IRQS) || pAC->CheckQueue) {
1893
	if ((IntSrc & SPECIAL_IRQS) || pAC->CheckQueue) {
Lines 1003-1020 Link Here
1003
		SkEventDispatcher(pAC, pAC->IoBase);
1901
		SkEventDispatcher(pAC, pAC->IoBase);
1004
		spin_unlock(&pAC->SlowPathLock);
1902
		spin_unlock(&pAC->SlowPathLock);
1005
	}
1903
	}
1006
	/*
1904
1007
	 * do it all again is case we cleared an interrupt that
1905
#ifndef CONFIG_SK98LIN_NAPI
1008
	 * came in after handling the ring (OUTs may be delayed
1906
	/* Handle interrupts */
1009
	 * in hardware buffers, but are through after IN)
1010
	 *
1011
	 * rroesler: has been commented out and shifted to
1012
	 *           SkGeDrvEvent(), because it is timer
1013
	 *           guarded now
1014
	 *
1015
	ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1907
	ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1016
	ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1908
	ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1017
	 */
1909
#endif
1018
1910
1019
	if (pAC->CheckQueue) {
1911
	if (pAC->CheckQueue) {
1020
		pAC->CheckQueue = SK_FALSE;
1912
		pAC->CheckQueue = SK_FALSE;
Lines 1050-1056 Link Here
1050
SK_AC		*pAC;
1942
SK_AC		*pAC;
1051
SK_U32		IntSrc;		/* interrupts source register contents */	
1943
SK_U32		IntSrc;		/* interrupts source register contents */	
1052
1944
1053
	pNet = netdev_priv(dev);
1945
	pNet = (DEV_NET*) dev->priv;
1054
	pAC = pNet->pAC;
1946
	pAC = pNet->pAC;
1055
	
1947
	
1056
	/*
1948
	/*
Lines 1061-1066 Link Here
1061
		return SkIsrRetNone;
1953
		return SkIsrRetNone;
1062
	}
1954
	}
1063
	
1955
	
1956
#ifdef CONFIG_SK98LIN_NAPI
1957
	if (netif_rx_schedule_prep(dev)) {
1958
		// CLEAR_AND_START_RX(0);
1959
		// CLEAR_TX_IRQ(0, TX_PRIO_LOW);
1960
		pAC->GIni.GIValIrqMask &= ~(NAPI_DRV_IRQS);
1961
		SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
1962
		__netif_rx_schedule(dev);
1963
	} 
1964
1965
#ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1966
	if (IntSrc & IS_XA1_F) {
1967
		CLEAR_TX_IRQ(0, TX_PRIO_LOW);
1968
	}
1969
#endif
1970
#else
1064
	while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
1971
	while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
1065
#if 0 /* software irq currently not used */
1972
#if 0 /* software irq currently not used */
1066
		if (IntSrc & IS_IRQ_SW) {
1973
		if (IntSrc & IS_IRQ_SW) {
Lines 1074-1079 Link Here
1074
				SK_DBGCAT_DRV_INT_SRC,
1981
				SK_DBGCAT_DRV_INT_SRC,
1075
				("EOF RX1 IRQ\n"));
1982
				("EOF RX1 IRQ\n"));
1076
			ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1983
			ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1984
			CLEAR_AND_START_RX(0);
1077
			SK_PNMI_CNT_RX_INTR(pAC, 0);
1985
			SK_PNMI_CNT_RX_INTR(pAC, 0);
1078
		}
1986
		}
1079
#ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1987
#ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
Lines 1081-1086 Link Here
1081
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1989
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1082
				SK_DBGCAT_DRV_INT_SRC,
1990
				SK_DBGCAT_DRV_INT_SRC,
1083
				("EOF AS TX1 IRQ\n"));
1991
				("EOF AS TX1 IRQ\n"));
1992
			CLEAR_TX_IRQ(0, TX_PRIO_LOW);
1084
			SK_PNMI_CNT_TX_INTR(pAC, 0);
1993
			SK_PNMI_CNT_TX_INTR(pAC, 0);
1085
			spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
1994
			spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
1086
			FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]);
1995
			FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]);
Lines 1091-1114 Link Here
1091
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2000
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1092
				SK_DBGCAT_DRV_INT_SRC,
2001
				SK_DBGCAT_DRV_INT_SRC,
1093
				("EOF SY TX1 IRQ\n"));
2002
				("EOF SY TX1 IRQ\n"));
2003
			CLEAR_TX_IRQ(0, TX_PRIO_HIGH);
1094
			SK_PNMI_CNT_TX_INTR(pAC, 0);
2004
			SK_PNMI_CNT_TX_INTR(pAC, 0);
1095
			spin_lock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
2005
			spin_lock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
1096
			FreeTxDescriptors(pAC, 0, TX_PRIO_HIGH);
2006
			FreeTxDescriptors(pAC, 0, TX_PRIO_HIGH);
1097
			spin_unlock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
2007
			spin_unlock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
1098
			ClearTxIrq(pAC, 0, TX_PRIO_HIGH);
1099
		}
2008
		}
1100
#endif
2009
#endif
1101
#endif
2010
#endif
1102
2011
1103
		/* do all IO at once */
1104
		if (IntSrc & IS_R1_F)
1105
			ClearAndStartRx(pAC, 0);
1106
#ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1107
		if (IntSrc & IS_XA1_F)
1108
			ClearTxIrq(pAC, 0, TX_PRIO_LOW);
1109
#endif
1110
		SK_IN32(pAC->IoBase, B0_ISRC, &IntSrc);
2012
		SK_IN32(pAC->IoBase, B0_ISRC, &IntSrc);
1111
	} /* while (IntSrc & IRQ_MASK != 0) */
2013
	} /* while (IntSrc & IRQ_MASK != 0) */
2014
#endif
1112
	
2015
	
1113
	IntSrc &= pAC->GIni.GIValIrqMask;
2016
	IntSrc &= pAC->GIni.GIValIrqMask;
1114
	if ((IntSrc & SPECIAL_IRQS) || pAC->CheckQueue) {
2017
	if ((IntSrc & SPECIAL_IRQS) || pAC->CheckQueue) {
Lines 1122-1138 Link Here
1122
		SkEventDispatcher(pAC, pAC->IoBase);
2025
		SkEventDispatcher(pAC, pAC->IoBase);
1123
		spin_unlock(&pAC->SlowPathLock);
2026
		spin_unlock(&pAC->SlowPathLock);
1124
	}
2027
	}
1125
	/*
2028
1126
	 * do it all again is case we cleared an interrupt that
2029
#ifndef CONFIG_SK98LIN_NAPI
1127
	 * came in after handling the ring (OUTs may be delayed
1128
	 * in hardware buffers, but are through after IN)
1129
	 *
1130
	 * rroesler: has been commented out and shifted to
1131
	 *           SkGeDrvEvent(), because it is timer
1132
	 *           guarded now
1133
	 *
1134
	ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
2030
	ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1135
	 */
2031
#endif
1136
2032
1137
	/* IRQ is processed - Enable IRQs again*/
2033
	/* IRQ is processed - Enable IRQs again*/
1138
	SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
2034
	SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
Lines 1140-1164 Link Here
1140
		return SkIsrRetHandled;
2036
		return SkIsrRetHandled;
1141
} /* SkGeIsrOnePort */
2037
} /* SkGeIsrOnePort */
1142
2038
1143
#ifdef CONFIG_NET_POLL_CONTROLLER
1144
/****************************************************************************
1145
 *
1146
 * 	SkGePollController - polling receive, for netconsole
1147
 *
1148
 * Description:
1149
 *	Polling receive - used by netconsole and other diagnostic tools
1150
 *	to allow network i/o with interrupts disabled.
1151
 *
1152
 * Returns: N/A
1153
 */
1154
static void SkGePollController(struct net_device *dev)
1155
{
1156
	disable_irq(dev->irq);
1157
	SkGeIsr(dev->irq, dev, NULL);
1158
	enable_irq(dev->irq);
1159
}
1160
#endif
1161
1162
/****************************************************************************
2039
/****************************************************************************
1163
 *
2040
 *
1164
 *	SkGeOpen - handle start of initialized adapter
2041
 *	SkGeOpen - handle start of initialized adapter
Lines 1176-1202 Link Here
1176
 *	!= 0 on error
2053
 *	!= 0 on error
1177
 */
2054
 */
1178
static int SkGeOpen(
2055
static int SkGeOpen(
1179
struct SK_NET_DEVICE	*dev)
2056
struct SK_NET_DEVICE *dev)  /* the device that is to be opened */
1180
{
2057
{
1181
	DEV_NET			*pNet;
2058
	DEV_NET        *pNet = (DEV_NET*) dev->priv;
1182
	SK_AC			*pAC;
2059
	SK_AC          *pAC  = pNet->pAC;
1183
	unsigned long	Flags;		/* for spin lock */
2060
	unsigned long   Flags;    /* for the spin locks    */
1184
	int				i;
2061
	int             CurrMac;  /* loop ctr for ports    */
1185
	SK_EVPARA		EvPara;		/* an event parameter union */
1186
2062
1187
	pNet = netdev_priv(dev);
1188
	pAC = pNet->pAC;
1189
	
1190
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
2063
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1191
		("SkGeOpen: pAC=0x%lX:\n", (unsigned long)pAC));
2064
		("SkGeOpen: pAC=0x%lX:\n", (unsigned long)pAC));
1192
2065
1193
#ifdef SK_DIAG_SUPPORT
1194
	if (pAC->DiagModeActive == DIAG_ACTIVE) {
2066
	if (pAC->DiagModeActive == DIAG_ACTIVE) {
1195
		if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) {
2067
		if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) {
1196
			return (-1);   /* still in use by diag; deny actions */
2068
			return (-1);   /* still in use by diag; deny actions */
1197
		} 
2069
		} 
1198
	}
2070
	}
1199
#endif
2071
2072
	if (!try_module_get(THIS_MODULE)) {
2073
		return (-1);	/* increase of usage count not possible */
2074
	}
1200
2075
1201
	/* Set blink mode */
2076
	/* Set blink mode */
1202
	if ((pAC->PciDev->vendor == 0x1186) || (pAC->PciDev->vendor == 0x11ab ))
2077
	if ((pAC->PciDev->vendor == 0x1186) || (pAC->PciDev->vendor == 0x11ab ))
Lines 1205-1210 Link Here
1205
	if (pAC->BoardLevel == SK_INIT_DATA) {
2080
	if (pAC->BoardLevel == SK_INIT_DATA) {
1206
		/* level 1 init common modules here */
2081
		/* level 1 init common modules here */
1207
		if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
2082
		if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
2083
			module_put(THIS_MODULE); /* decrease usage count */
1208
			printk("%s: HWInit (1) failed.\n", pAC->dev[pNet->PortNr]->name);
2084
			printk("%s: HWInit (1) failed.\n", pAC->dev[pNet->PortNr]->name);
1209
			return (-1);
2085
			return (-1);
1210
		}
2086
		}
Lines 1215-1225 Link Here
1215
		SkRlmtInit	(pAC, pAC->IoBase, SK_INIT_IO);
2091
		SkRlmtInit	(pAC, pAC->IoBase, SK_INIT_IO);
1216
		SkTimerInit	(pAC, pAC->IoBase, SK_INIT_IO);
2092
		SkTimerInit	(pAC, pAC->IoBase, SK_INIT_IO);
1217
		pAC->BoardLevel = SK_INIT_IO;
2093
		pAC->BoardLevel = SK_INIT_IO;
2094
#ifdef Y2_RECOVERY
2095
		/* mark entries invalid */
2096
		pAC->LastPort = 3;
2097
		pAC->LastOpc = 0xFF;
2098
#endif
1218
	}
2099
	}
1219
2100
1220
	if (pAC->BoardLevel != SK_INIT_RUN) {
2101
	if (pAC->BoardLevel != SK_INIT_RUN) {
1221
		/* tschilling: Level 2 init modules here, check return value. */
2102
		/* tschilling: Level 2 init modules here, check return value. */
1222
		if (SkGeInit(pAC, pAC->IoBase, SK_INIT_RUN) != 0) {
2103
		if (SkGeInit(pAC, pAC->IoBase, SK_INIT_RUN) != 0) {
2104
			module_put(THIS_MODULE); /* decrease usage count */
1223
			printk("%s: HWInit (2) failed.\n", pAC->dev[pNet->PortNr]->name);
2105
			printk("%s: HWInit (2) failed.\n", pAC->dev[pNet->PortNr]->name);
1224
			return (-1);
2106
			return (-1);
1225
		}
2107
		}
Lines 1230-1249 Link Here
1230
		SkRlmtInit	(pAC, pAC->IoBase, SK_INIT_RUN);
2112
		SkRlmtInit	(pAC, pAC->IoBase, SK_INIT_RUN);
1231
		SkTimerInit	(pAC, pAC->IoBase, SK_INIT_RUN);
2113
		SkTimerInit	(pAC, pAC->IoBase, SK_INIT_RUN);
1232
		pAC->BoardLevel = SK_INIT_RUN;
2114
		pAC->BoardLevel = SK_INIT_RUN;
2115
2116
#ifdef SK_YUKON2
2117
#if 0
2118
		for (CurrMac=0; CurrMac<pAC->GIni.GIMacsFound; CurrMac++) {
2119
			if (CHIP_ID_YUKON_2(pAC)) {
2120
				if (pPrt->PState >= SK_PRT_INIT) {
2121
				SkY2PortStart(pAC, pAC->IoBase, CurrMac);
2122
				}
2123
			} else {
2124
				/* Enable transmit descriptor polling. */
2125
				SkGePollTxD(pAC, pAC->IoBase, CurrMac, SK_TRUE);
2126
				FillRxRing(pAC, &pAC->RxPort[CurrMac]);
2127
				SkMacRxTxEnable(pAC, pAC->IoBase, pNet->PortNr);
2128
			}
2129
		}
2130
#endif
2131
#endif
2132
1233
	}
2133
	}
1234
2134
1235
	for (i=0; i<pAC->GIni.GIMacsFound; i++) {
2135
	for (CurrMac=0; CurrMac<pAC->GIni.GIMacsFound; CurrMac++) {
1236
		/* Enable transmit descriptor polling. */
2136
#ifdef SK_YUKON2
1237
		SkGePollTxD(pAC, pAC->IoBase, i, SK_TRUE);
2137
#if 0
1238
		FillRxRing(pAC, &pAC->RxPort[i]);
2138
		if (CHIP_ID_YUKON_2(pAC)) {
2139
			if (pAC->GIni.GP[CurrMac].PState < SK_PRT_INIT) {
2140
				printk("SkGeOpen: will start port %i\n", CurrMac);
2141
				SkY2PortStart(pAC, pAC->IoBase, CurrMac);
2142
			} else {
2143
				printk("SkGeOpen: Port %i already started->skipped!\n", CurrMac);
2144
			}
2145
		} else {
2146
#endif
2147
#endif
2148
		if (!CHIP_ID_YUKON_2(pAC)) {
2149
			/* Enable transmit descriptor polling. */
2150
			SkGePollTxD(pAC, pAC->IoBase, CurrMac, SK_TRUE);
2151
			FillRxRing(pAC, &pAC->RxPort[CurrMac]);
2152
			SkMacRxTxEnable(pAC, pAC->IoBase, pNet->PortNr);
2153
		}
1239
	}
2154
	}
1240
	SkGeYellowLED(pAC, pAC->IoBase, 1);
1241
2155
1242
	StartDrvCleanupTimer(pAC);
2156
	SkGeYellowLED(pAC, pAC->IoBase, 1);
1243
	SkDimEnableModerationIfNeeded(pAC);	
2157
	SkDimEnableModerationIfNeeded(pAC);	
1244
	SkDimDisplayModerationSettings(pAC);
1245
2158
1246
	pAC->GIni.GIValIrqMask &= IRQ_MASK;
2159
	if (!CHIP_ID_YUKON_2(pAC)) {
2160
		/*
2161
		** Has been setup already at SkGeInit(SK_INIT_IO),
2162
		** but additional masking added for Genesis & Yukon
2163
		** chipsets -> modify it...
2164
		*/
2165
		pAC->GIni.GIValIrqMask &= IRQ_MASK;
2166
#ifndef USE_TX_COMPLETE
2167
		pAC->GIni.GIValIrqMask &= ~(TX_COMPL_IRQS);
2168
#endif
2169
	}
1247
2170
1248
	/* enable Interrupts */
2171
	/* enable Interrupts */
1249
	SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
2172
	SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
Lines 1252-1276 Link Here
1252
	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
2175
	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1253
2176
1254
	if ((pAC->RlmtMode != 0) && (pAC->MaxPorts == 0)) {
2177
	if ((pAC->RlmtMode != 0) && (pAC->MaxPorts == 0)) {
1255
		EvPara.Para32[0] = pAC->RlmtNets;
2178
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_SET_NETS,
1256
		EvPara.Para32[1] = -1;
2179
					pAC->RlmtNets, -1, SK_FALSE);
1257
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_SET_NETS,
2180
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_MODE_CHANGE,
1258
			EvPara);
2181
					pAC->RlmtMode, 0, SK_FALSE);
1259
		EvPara.Para32[0] = pAC->RlmtMode;
1260
		EvPara.Para32[1] = 0;
1261
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_MODE_CHANGE,
1262
			EvPara);
1263
	}
2182
	}
1264
2183
1265
	EvPara.Para32[0] = pNet->NetNr;
2184
	SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_START,
1266
	EvPara.Para32[1] = -1;
2185
				pNet->NetNr, -1, SK_TRUE);
1267
	SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
1268
	SkEventDispatcher(pAC, pAC->IoBase);
1269
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
2186
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1270
2187
1271
	pAC->MaxPorts++;
2188
#ifdef Y2_RECOVERY
1272
	pNet->Up = 1;
2189
	pNet->InRecover = SK_FALSE;
1273
2190
2191
	/* Initialize the kernel timer */
2192
	init_timer(&pNet->KernelTimer);
2193
	pNet->KernelTimer.function	= SkGeHandleKernelTimer;
2194
	pNet->KernelTimer.data		= (unsigned long) pNet;
2195
	pNet->KernelTimer.expires	= jiffies + (HZ/4); /* initially 250ms */
2196
	pNet->TimerExpired = SK_FALSE;
2197
	add_timer(&pNet->KernelTimer);
2198
#endif
2199
2200
	pAC->MaxPorts++;
1274
2201
1275
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
2202
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1276
		("SkGeOpen suceeded\n"));
2203
		("SkGeOpen suceeded\n"));
Lines 1291-1322 Link Here
1291
 *	error code - on error
2218
 *	error code - on error
1292
 */
2219
 */
1293
static int SkGeClose(
2220
static int SkGeClose(
1294
struct SK_NET_DEVICE	*dev)
2221
struct SK_NET_DEVICE *dev)  /* the device that is to be closed */
1295
{
2222
{
1296
	DEV_NET		*pNet;
2223
	DEV_NET         *pNet = (DEV_NET*) dev->priv;
1297
	DEV_NET		*newPtrNet;
2224
	SK_AC           *pAC  = pNet->pAC;
1298
	SK_AC		*pAC;
2225
	DEV_NET         *newPtrNet;
1299
2226
	unsigned long    Flags;        /* for the spin locks           */
1300
	unsigned long	Flags;		/* for spin lock */
2227
	int              CurrMac;      /* loop ctr for the current MAC */
1301
	int		i;
2228
	int              PortIdx;
1302
	int		PortIdx;
2229
#ifdef CONFIG_SK98LIN_NAPI
1303
	SK_EVPARA	EvPara;
2230
	int              WorkToDo = 1; /* min(*budget, dev->quota);    */
1304
2231
	int              WorkDone = 0;
2232
#endif
1305
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
2233
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1306
		("SkGeClose: pAC=0x%lX ", (unsigned long)pAC));
2234
		("SkGeClose: pAC=0x%lX ", (unsigned long)pAC));
1307
2235
1308
	pNet = netdev_priv(dev);
2236
#ifdef Y2_RECOVERY
1309
	pAC = pNet->pAC;
2237
	del_timer(&pNet->KernelTimer);
2238
#endif
1310
2239
1311
#ifdef SK_DIAG_SUPPORT
1312
	if (pAC->DiagModeActive == DIAG_ACTIVE) {
2240
	if (pAC->DiagModeActive == DIAG_ACTIVE) {
1313
		if (pAC->DiagFlowCtrl == SK_FALSE) {
2241
		if (pAC->DiagFlowCtrl == SK_FALSE) {
2242
			module_put(THIS_MODULE);
1314
			/* 
2243
			/* 
1315
			** notify that the interface which has been closed
2244
			** notify that the interface which has been closed
1316
			** by operator interaction must not be started up 
2245
			** by operator interaction must not be started up 
1317
			** again when the DIAG has finished. 
2246
			** again when the DIAG has finished. 
1318
			*/
2247
			*/
1319
			newPtrNet = netdev_priv(pAC->dev[0]);
2248
			newPtrNet = (DEV_NET *) pAC->dev[0]->priv;
1320
			if (newPtrNet == pNet) {
2249
			if (newPtrNet == pNet) {
1321
				pAC->WasIfUp[0] = SK_FALSE;
2250
				pAC->WasIfUp[0] = SK_FALSE;
1322
			} else {
2251
			} else {
Lines 1327-1333 Link Here
1327
			pAC->DiagFlowCtrl = SK_FALSE;
2256
			pAC->DiagFlowCtrl = SK_FALSE;
1328
		}
2257
		}
1329
	}
2258
	}
1330
#endif
1331
2259
1332
	netif_stop_queue(dev);
2260
	netif_stop_queue(dev);
1333
2261
Lines 1336-1343 Link Here
1336
	else
2264
	else
1337
		PortIdx = pNet->NetNr;
2265
		PortIdx = pNet->NetNr;
1338
2266
1339
        StopDrvCleanupTimer(pAC);
1340
1341
	/*
2267
	/*
1342
	 * Clear multicast table, promiscuous mode ....
2268
	 * Clear multicast table, promiscuous mode ....
1343
	 */
2269
	 */
Lines 1349-1394 Link Here
1349
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
2275
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1350
		/* disable interrupts */
2276
		/* disable interrupts */
1351
		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
2277
		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
1352
		EvPara.Para32[0] = pNet->NetNr;
2278
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP,
1353
		EvPara.Para32[1] = -1;
2279
					pNet->NetNr, -1, SK_TRUE);
1354
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
1355
		SkEventDispatcher(pAC, pAC->IoBase);
1356
		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
2280
		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
1357
		/* stop the hardware */
2281
		/* stop the hardware */
1358
		SkGeDeInit(pAC, pAC->IoBase);
2282
		/* SkGeDeInit(pAC, pAC->IoBase);	*/
1359
		pAC->BoardLevel = SK_INIT_DATA;
2283
		/* pAC->BoardLevel = SK_INIT_DATA;	*/
2284
		if (CHIP_ID_YUKON_2(pAC)) {
2285
			SkY2PortStop(	pAC, 
2286
					pAC->IoBase,
2287
					pNet->NetNr,
2288
					SK_STOP_ALL,
2289
					SK_HARD_RST
2290
					);
2291
		}
2292
		else {
2293
			SkGeStopPort(	pAC,
2294
					pAC->IoBase,
2295
					pNet->NetNr,
2296
					SK_STOP_ALL,
2297
					SK_HARD_RST);
2298
		}
1360
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
2299
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1361
	} else {
2300
	} else {
1362
2301
1363
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
2302
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1364
		EvPara.Para32[0] = pNet->NetNr;
2303
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP,
1365
		EvPara.Para32[1] = -1;
2304
					pNet->NetNr, -1, SK_FALSE);
1366
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
2305
		SkLocalEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_XMAC_RESET,
1367
		SkPnmiEvent(pAC, pAC->IoBase, SK_PNMI_EVT_XMAC_RESET, EvPara);
2306
					pNet->NetNr, -1, SK_TRUE);
1368
		SkEventDispatcher(pAC, pAC->IoBase);
1369
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
2307
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1370
		
2308
		
1371
		/* Stop port */
2309
		/* Stop port */
1372
		spin_lock_irqsave(&pAC->TxPort[pNet->PortNr]
2310
		spin_lock_irqsave(&pAC->TxPort[pNet->PortNr]
1373
			[TX_PRIO_LOW].TxDesRingLock, Flags);
2311
			[TX_PRIO_LOW].TxDesRingLock, Flags);
1374
		SkGeStopPort(pAC, pAC->IoBase, pNet->PortNr,
2312
		if (CHIP_ID_YUKON_2(pAC)) {
1375
			SK_STOP_ALL, SK_HARD_RST);
2313
			SkY2PortStop(pAC, pAC->IoBase, pNet->PortNr,
2314
				SK_STOP_ALL, SK_HARD_RST);
2315
		}
2316
		else {
2317
			SkGeStopPort(pAC, pAC->IoBase, pNet->PortNr,
2318
				SK_STOP_ALL, SK_HARD_RST);
2319
		}
1376
		spin_unlock_irqrestore(&pAC->TxPort[pNet->PortNr]
2320
		spin_unlock_irqrestore(&pAC->TxPort[pNet->PortNr]
1377
			[TX_PRIO_LOW].TxDesRingLock, Flags);
2321
			[TX_PRIO_LOW].TxDesRingLock, Flags);
1378
	}
2322
	}
1379
2323
1380
	if (pAC->RlmtNets == 1) {
2324
	if (pAC->RlmtNets == 1) {
1381
		/* clear all descriptor rings */
2325
		/* clear all descriptor rings */
1382
		for (i=0; i<pAC->GIni.GIMacsFound; i++) {
2326
		for (CurrMac=0; CurrMac<pAC->GIni.GIMacsFound; CurrMac++) {
1383
			ReceiveIrq(pAC, &pAC->RxPort[i], SK_TRUE);
2327
			if (!CHIP_ID_YUKON_2(pAC)) {
1384
			ClearRxRing(pAC, &pAC->RxPort[i]);
2328
#ifdef CONFIG_SK98LIN_NAPI
1385
			ClearTxRing(pAC, &pAC->TxPort[i][TX_PRIO_LOW]);
2329
				WorkToDo = 1;
2330
				ReceiveIrq(pAC,&pAC->RxPort[CurrMac],
2331
						SK_TRUE,&WorkDone,WorkToDo);
2332
#else
2333
				ReceiveIrq(pAC,&pAC->RxPort[CurrMac],SK_TRUE);
2334
#endif
2335
				ClearRxRing(pAC, &pAC->RxPort[CurrMac]);
2336
				ClearTxRing(pAC, &pAC->TxPort[CurrMac][TX_PRIO_LOW]);
2337
			} else {
2338
				SkY2FreeRxBuffers(pAC, pAC->IoBase, CurrMac);
2339
				SkY2FreeTxBuffers(pAC, pAC->IoBase, CurrMac);
2340
			}
1386
		}
2341
		}
1387
	} else {
2342
	} else {
1388
		/* clear port descriptor rings */
2343
		/* clear port descriptor rings */
1389
		ReceiveIrq(pAC, &pAC->RxPort[pNet->PortNr], SK_TRUE);
2344
		if (!CHIP_ID_YUKON_2(pAC)) {
1390
		ClearRxRing(pAC, &pAC->RxPort[pNet->PortNr]);
2345
#ifdef CONFIG_SK98LIN_NAPI
1391
		ClearTxRing(pAC, &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW]);
2346
			WorkToDo = 1;
2347
			ReceiveIrq(pAC, &pAC->RxPort[pNet->PortNr], SK_TRUE, &WorkDone, WorkToDo);
2348
#else
2349
			ReceiveIrq(pAC, &pAC->RxPort[pNet->PortNr], SK_TRUE);
2350
#endif
2351
			ClearRxRing(pAC, &pAC->RxPort[pNet->PortNr]);
2352
			ClearTxRing(pAC, &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW]);
2353
		}
2354
		else {
2355
			SkY2FreeRxBuffers(pAC, pAC->IoBase, pNet->PortNr);
2356
			SkY2FreeTxBuffers(pAC, pAC->IoBase, pNet->PortNr);
2357
		}
1392
	}
2358
	}
1393
2359
1394
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
2360
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
Lines 1399-1406 Link Here
1399
			sizeof(SK_PNMI_STRUCT_DATA));
2365
			sizeof(SK_PNMI_STRUCT_DATA));
1400
2366
1401
	pAC->MaxPorts--;
2367
	pAC->MaxPorts--;
1402
	pNet->Up = 0;
2368
	module_put(THIS_MODULE);
1403
1404
	return (0);
2369
	return (0);
1405
} /* SkGeClose */
2370
} /* SkGeClose */
1406
2371
Lines 1426-1432 Link Here
1426
SK_AC		*pAC;
2391
SK_AC		*pAC;
1427
int			Rc;	/* return code of XmitFrame */
2392
int			Rc;	/* return code of XmitFrame */
1428
2393
1429
	pNet = netdev_priv(dev);
2394
	pNet = (DEV_NET*) dev->priv;
1430
	pAC = pNet->pAC;
2395
	pAC = pNet->pAC;
1431
2396
1432
	if ((!skb_shinfo(skb)->nr_frags) ||
2397
	if ((!skb_shinfo(skb)->nr_frags) ||
Lines 1458-1466 Link Here
1458
	}
2423
	}
1459
2424
1460
	/* Transmitter out of resources? */
2425
	/* Transmitter out of resources? */
2426
#ifdef USE_TX_COMPLETE
1461
	if (Rc <= 0) {
2427
	if (Rc <= 0) {
1462
		netif_stop_queue(dev);
2428
		netif_stop_queue(dev);
1463
	}
2429
	}
2430
#endif
1464
2431
1465
	/* If not taken, give buffer ownership back to the
2432
	/* If not taken, give buffer ownership back to the
1466
	 * queueing layer.
2433
	 * queueing layer.
Lines 1472-1477 Link Here
1472
	return (0);
2439
	return (0);
1473
} /* SkGeXmit */
2440
} /* SkGeXmit */
1474
2441
2442
#ifdef CONFIG_SK98LIN_NAPI
2443
/*****************************************************************************
2444
 *
2445
 * 	SkGePoll - NAPI Rx polling callback for GEnesis and Yukon chipsets
2446
 *
2447
 * Description:
2448
 *	Called by the Linux system in case NAPI polling is activated
2449
 *
2450
 * Returns:
2451
 *	The number of work data still to be handled
2452
 */
2453
static int SkGePoll(struct net_device *dev, int *budget) 
2454
{
2455
SK_AC	*pAC = ((DEV_NET*)(dev->priv))->pAC; /* pointer to adapter context */
2456
int	WorkToDo = min(*budget, dev->quota);
2457
int	WorkDone = 0;
2458
2459
	if (pAC->dev[0] != pAC->dev[1]) {
2460
#ifdef USE_TX_COMPLETE
2461
		spin_lock(&pAC->TxPort[1][TX_PRIO_LOW].TxDesRingLock);
2462
		FreeTxDescriptors(pAC, &pAC->TxPort[1][TX_PRIO_LOW]);
2463
		spin_unlock(&pAC->TxPort[1][TX_PRIO_LOW].TxDesRingLock);
2464
#endif
2465
		ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE, &WorkDone, WorkToDo);
2466
		CLEAR_AND_START_RX(1);
2467
	}
2468
#ifdef USE_TX_COMPLETE
2469
	spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
2470
	FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]);
2471
	spin_unlock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
2472
#endif
2473
	ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE, &WorkDone, WorkToDo);
2474
	CLEAR_AND_START_RX(0);
2475
2476
	*budget -= WorkDone;
2477
	dev->quota -= WorkDone;
2478
2479
	if(WorkDone < WorkToDo) {
2480
		netif_rx_complete(dev);
2481
		/* enable interrupts again */
2482
		pAC->GIni.GIValIrqMask |= (NAPI_DRV_IRQS);
2483
#ifndef USE_TX_COMPLETE
2484
		pAC->GIni.GIValIrqMask &= ~(TX_COMPL_IRQS);
2485
#endif
2486
		SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
2487
	}
2488
	return (WorkDone >= WorkToDo);
2489
} /* SkGePoll */
2490
#endif
1475
2491
1476
/*****************************************************************************
2492
/*****************************************************************************
1477
 *
2493
 *
Lines 1496-1502 Link Here
1496
 *	< 0 - on failure: other problems ( -> return failure to upper layers)
2512
 *	< 0 - on failure: other problems ( -> return failure to upper layers)
1497
 */
2513
 */
1498
static int XmitFrame(
2514
static int XmitFrame(
1499
SK_AC 		*pAC,		/* pointer to adapter context           */
2515
SK_AC 		*pAC,		/* pointer to adapter context	        */
1500
TX_PORT		*pTxPort,	/* pointer to struct of port to send to */
2516
TX_PORT		*pTxPort,	/* pointer to struct of port to send to */
1501
struct sk_buff	*pMessage)	/* pointer to send-message              */
2517
struct sk_buff	*pMessage)	/* pointer to send-message              */
1502
{
2518
{
Lines 1512-1522 Link Here
1512
2528
1513
	spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
2529
	spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
1514
#ifndef USE_TX_COMPLETE
2530
#ifndef USE_TX_COMPLETE
1515
	FreeTxDescriptors(pAC, pTxPort);
2531
	if ((pTxPort->TxdRingPrevFree - pTxPort->TxdRingFree) > 6)  {
2532
		FreeTxDescriptors(pAC, pTxPort);
2533
		pTxPort->TxdRingPrevFree = pTxPort->TxdRingFree;
2534
	}
1516
#endif
2535
#endif
1517
	if (pTxPort->TxdRingFree == 0) {
2536
	if (pTxPort->TxdRingFree == 0) {
1518
		/* 
2537
		/* 
1519
		** no enough free descriptors in ring at the moment.
2538
		** not enough free descriptors in ring at the moment.
1520
		** Maybe free'ing some old one help?
2539
		** Maybe free'ing some old one help?
1521
		*/
2540
		*/
1522
		FreeTxDescriptors(pAC, pTxPort);
2541
		FreeTxDescriptors(pAC, pTxPort);
Lines 1602-1608 Link Here
1602
				   BMU_IRQ_EOF |
2621
				   BMU_IRQ_EOF |
1603
#endif
2622
#endif
1604
				   pMessage->len;
2623
				   pMessage->len;
1605
        } else {
2624
	} else {
1606
		pTxd->TBControl = BMU_OWN | BMU_STF | BMU_CHECK | 
2625
		pTxd->TBControl = BMU_OWN | BMU_STF | BMU_CHECK | 
1607
				  BMU_SW  | BMU_EOF |
2626
				  BMU_SW  | BMU_EOF |
1608
#ifdef USE_TX_COMPLETE
2627
#ifdef USE_TX_COMPLETE
Lines 2022-2054 Link Here
2022
 * Returns:	N/A
3041
 * Returns:	N/A
2023
 */
3042
 */
2024
static void ReceiveIrq(
3043
static void ReceiveIrq(
2025
	SK_AC		*pAC,			/* pointer to adapter context */
3044
#ifdef CONFIG_SK98LIN_NAPI
2026
	RX_PORT		*pRxPort,		/* pointer to receive port struct */
3045
SK_AC    *pAC,          /* pointer to adapter context          */
2027
	SK_BOOL		SlowPathLock)	/* indicates if SlowPathLock is needed */
3046
RX_PORT  *pRxPort,      /* pointer to receive port struct      */
2028
{
3047
SK_BOOL   SlowPathLock, /* indicates if SlowPathLock is needed */
2029
RXD				*pRxd;			/* pointer to receive descriptors */
3048
int      *WorkDone,
2030
SK_U32			Control;		/* control field of descriptor */
3049
int       WorkToDo)
2031
struct sk_buff	*pMsg;			/* pointer to message holding frame */
3050
#else
2032
struct sk_buff	*pNewMsg;		/* pointer to a new message for copying frame */
3051
SK_AC    *pAC,          /* pointer to adapter context          */
2033
int				FrameLength;	/* total length of received frame */
3052
RX_PORT  *pRxPort,      /* pointer to receive port struct      */
2034
int				IpFrameLength;
3053
SK_BOOL   SlowPathLock) /* indicates if SlowPathLock is needed */
2035
SK_MBUF			*pRlmtMbuf;		/* ptr to a buffer for giving a frame to rlmt */
3054
#endif
2036
SK_EVPARA		EvPara;			/* an event parameter union */	
3055
{
2037
unsigned long	Flags;			/* for spin lock */
3056
	RXD             *pRxd;          /* pointer to receive descriptors         */
2038
int				PortIndex = pRxPort->PortIndex;
3057
	struct sk_buff  *pMsg;          /* pointer to message holding frame       */
2039
unsigned int	Offset;
3058
	struct sk_buff  *pNewMsg;       /* pointer to new message for frame copy  */
2040
unsigned int	NumBytes;
3059
	SK_MBUF         *pRlmtMbuf;     /* ptr to buffer for giving frame to RLMT */
2041
unsigned int	ForRlmt;
3060
	SK_EVPARA        EvPara;        /* an event parameter union        */	
2042
SK_BOOL			IsBc;
3061
	SK_U32           Control;       /* control field of descriptor     */
2043
SK_BOOL			IsMc;
3062
	unsigned long    Flags;         /* for spin lock handling          */
2044
SK_BOOL  IsBadFrame; 			/* Bad frame */
3063
	int              PortIndex = pRxPort->PortIndex;
2045
3064
	int              FrameLength;   /* total length of received frame  */
2046
SK_U32			FrameStat;
3065
	int              IpFrameLength; /* IP length of the received frame */
2047
unsigned short	Csum1;
3066
	unsigned int     Offset;
2048
unsigned short	Csum2;
3067
	unsigned int     NumBytes;
2049
unsigned short	Type;
3068
	unsigned int     RlmtNotifier;
2050
int				Result;
3069
	SK_BOOL          IsBc;          /* we received a broadcast packet  */
2051
SK_U64			PhysAddr;
3070
	SK_BOOL          IsMc;          /* we received a multicast packet  */
3071
	SK_BOOL          IsBadFrame;    /* the frame received is bad!      */
3072
	SK_U32           FrameStat;
3073
	unsigned short   Csum1;
3074
	unsigned short   Csum2;
3075
	unsigned short   Type;
3076
	int              Result;
3077
	SK_U64           PhysAddr;
2052
3078
2053
rx_start:	
3079
rx_start:	
2054
	/* do forever; exit if BMU_OWN found */
3080
	/* do forever; exit if BMU_OWN found */
Lines 2070-2075 Link Here
2070
3096
2071
		Control = pRxd->RBControl;
3097
		Control = pRxd->RBControl;
2072
	
3098
	
3099
#ifdef CONFIG_SK98LIN_NAPI
3100
		if (*WorkDone >= WorkToDo) {
3101
			break;
3102
		}
3103
		(*WorkDone)++;
3104
#endif
3105
2073
		/* check if this descriptor is ready */
3106
		/* check if this descriptor is ready */
2074
		if ((Control & BMU_OWN) != 0) {
3107
		if ((Control & BMU_OWN) != 0) {
2075
			/* this descriptor is not yet ready */
3108
			/* this descriptor is not yet ready */
Lines 2078-2084 Link Here
2078
			FillRxRing(pAC, pRxPort);
3111
			FillRxRing(pAC, pRxPort);
2079
			return;
3112
			return;
2080
		}
3113
		}
2081
                pAC->DynIrqModInfo.NbrProcessedDescr++;
2082
3114
2083
		/* get length of frame and check it */
3115
		/* get length of frame and check it */
2084
		FrameLength = Control & BMU_BBC;
3116
		FrameLength = Control & BMU_BBC;
Lines 2097-2104 Link Here
2097
		FrameStat = pRxd->FrameStat;
3129
		FrameStat = pRxd->FrameStat;
2098
3130
2099
		/* check for frame length mismatch */
3131
		/* check for frame length mismatch */
2100
#define XMR_FS_LEN_SHIFT        18
3132
#define XMR_FS_LEN_SHIFT	18
2101
#define GMR_FS_LEN_SHIFT        16
3133
#define GMR_FS_LEN_SHIFT	16
2102
		if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
3134
		if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
2103
			if (FrameLength != (SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT)) {
3135
			if (FrameLength != (SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT)) {
2104
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
3136
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
Lines 2108-2115 Link Here
2108
					(SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT)));
3140
					(SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT)));
2109
				goto rx_failed;
3141
				goto rx_failed;
2110
			}
3142
			}
2111
		}
3143
		} else {
2112
		else {
2113
			if (FrameLength != (SK_U32) (FrameStat >> GMR_FS_LEN_SHIFT)) {
3144
			if (FrameLength != (SK_U32) (FrameStat >> GMR_FS_LEN_SHIFT)) {
2114
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
3145
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2115
					SK_DBGCAT_DRV_RX_PROGRESS,
3146
					SK_DBGCAT_DRV_RX_PROGRESS,
Lines 2152-2157 Link Here
2152
				"Control: %x\nRxStat: %x\n",
3183
				"Control: %x\nRxStat: %x\n",
2153
				Control, FrameStat));
3184
				Control, FrameStat));
2154
3185
3186
			PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
3187
			PhysAddr |= (SK_U64) pRxd->VDataLow;
3188
3189
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
3190
			pci_dma_sync_single(pAC->PciDev,
3191
						(dma_addr_t) PhysAddr,
3192
						FrameLength,
3193
						PCI_DMA_FROMDEVICE);
3194
#else
3195
			pci_dma_sync_single_for_cpu(pAC->PciDev,
3196
						(dma_addr_t) PhysAddr,
3197
						FrameLength,
3198
						PCI_DMA_FROMDEVICE);
3199
#endif
2155
			ReQueueRxBuffer(pAC, pRxPort, pMsg,
3200
			ReQueueRxBuffer(pAC, pRxPort, pMsg,
2156
				pRxd->VDataHigh, pRxd->VDataLow);
3201
				pRxd->VDataHigh, pRxd->VDataLow);
2157
3202
Lines 2171-2199 Link Here
2171
			skb_put(pNewMsg, FrameLength);
3216
			skb_put(pNewMsg, FrameLength);
2172
			PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
3217
			PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
2173
			PhysAddr |= (SK_U64) pRxd->VDataLow;
3218
			PhysAddr |= (SK_U64) pRxd->VDataLow;
3219
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
3220
			pci_dma_sync_single(pAC->PciDev,
3221
						(dma_addr_t) PhysAddr,
3222
						FrameLength,
3223
						PCI_DMA_FROMDEVICE);
3224
#else
3225
			pci_dma_sync_single_for_device(pAC->PciDev,
3226
						(dma_addr_t) PhysAddr,
3227
						FrameLength,
3228
						PCI_DMA_FROMDEVICE);
3229
#endif
2174
3230
2175
			pci_dma_sync_single_for_cpu(pAC->PciDev,
2176
						    (dma_addr_t) PhysAddr,
2177
						    FrameLength,
2178
						    PCI_DMA_FROMDEVICE);
2179
			eth_copy_and_sum(pNewMsg, pMsg->data,
3231
			eth_copy_and_sum(pNewMsg, pMsg->data,
2180
				FrameLength, 0);
3232
				FrameLength, 0);
2181
			pci_dma_sync_single_for_device(pAC->PciDev,
2182
						       (dma_addr_t) PhysAddr,
2183
						       FrameLength,
2184
						       PCI_DMA_FROMDEVICE);
2185
			ReQueueRxBuffer(pAC, pRxPort, pMsg,
3233
			ReQueueRxBuffer(pAC, pRxPort, pMsg,
2186
				pRxd->VDataHigh, pRxd->VDataLow);
3234
				pRxd->VDataHigh, pRxd->VDataLow);
2187
3235
2188
			pMsg = pNewMsg;
3236
			pMsg = pNewMsg;
2189
3237
2190
		}
3238
		} else {
2191
		else {
2192
			/*
3239
			/*
2193
			 * if large frame, or SKB allocation failed, pass
3240
			 * if large frame, or SKB allocation failed, pass
2194
			 * the SKB directly to the networking
3241
			 * the SKB directly to the networking
2195
			 */
3242
			 */
2196
2197
			PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
3243
			PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
2198
			PhysAddr |= (SK_U64) pRxd->VDataLow;
3244
			PhysAddr |= (SK_U64) pRxd->VDataLow;
2199
3245
Lines 2202-2320 Link Here
2202
					 PhysAddr,
3248
					 PhysAddr,
2203
					 pAC->RxBufSize - 2,
3249
					 pAC->RxBufSize - 2,
2204
					 PCI_DMA_FROMDEVICE);
3250
					 PCI_DMA_FROMDEVICE);
3251
			skb_put(pMsg, FrameLength); /* set message len */
3252
			pMsg->ip_summed = CHECKSUM_NONE; /* initial default */
2205
3253
2206
			/* set length in message */
3254
			if (pRxPort->UseRxCsum) {
2207
			skb_put(pMsg, FrameLength);
3255
				Type = ntohs(*((short*)&pMsg->data[12]));
2208
			/* hardware checksum */
3256
				if (Type == 0x800) {
2209
			Type = ntohs(*((short*)&pMsg->data[12]));
3257
					IpFrameLength = (int) ntohs((unsigned short)
2210
3258
							((unsigned short *) pMsg->data)[8]);
2211
#ifdef USE_SK_RX_CHECKSUM
3259
					if ((FrameLength - IpFrameLength) == 0xe) {
2212
			if (Type == 0x800) {
3260
						Csum1=le16_to_cpu(pRxd->TcpSums & 0xffff);
2213
				Csum1=le16_to_cpu(pRxd->TcpSums & 0xffff);
3261
						Csum2=le16_to_cpu((pRxd->TcpSums >> 16) & 0xffff);
2214
				Csum2=le16_to_cpu((pRxd->TcpSums >> 16) & 0xffff);
3262
						if ((((Csum1 & 0xfffe) && (Csum2 & 0xfffe)) &&
2215
				IpFrameLength = (int) ntohs((unsigned short)
3263
							(pAC->GIni.GIChipId == CHIP_ID_GENESIS)) ||
2216
								((unsigned short *) pMsg->data)[8]);
3264
							(pAC->ChipsetType)) {
2217
3265
							Result = SkCsGetReceiveInfo(pAC, &pMsg->data[14],
2218
				/*
3266
								Csum1, Csum2, PortIndex);
2219
				 * Test: If frame is padded, a check is not possible!
3267
							if ((Result == SKCS_STATUS_IP_FRAGMENT) ||
2220
				 * Frame not padded? Length difference must be 14 (0xe)!
3268
							    (Result == SKCS_STATUS_IP_CSUM_OK)  ||
2221
				 */
3269
							    (Result == SKCS_STATUS_TCP_CSUM_OK) ||
2222
				if ((FrameLength - IpFrameLength) != 0xe) {
3270
							    (Result == SKCS_STATUS_UDP_CSUM_OK)) {
2223
				/* Frame padded => TCP offload not possible! */
3271
								pMsg->ip_summed = CHECKSUM_UNNECESSARY;
2224
					pMsg->ip_summed = CHECKSUM_NONE;
3272
							} else if ((Result == SKCS_STATUS_TCP_CSUM_ERROR)    ||
2225
				} else {
3273
							           (Result == SKCS_STATUS_UDP_CSUM_ERROR)    ||
2226
				/* Frame not padded => TCP offload! */
3274
							           (Result == SKCS_STATUS_IP_CSUM_ERROR_UDP) ||
2227
					if ((((Csum1 & 0xfffe) && (Csum2 & 0xfffe)) &&
3275
							           (Result == SKCS_STATUS_IP_CSUM_ERROR_TCP) ||
2228
						(pAC->GIni.GIChipId == CHIP_ID_GENESIS)) ||
3276
							           (Result == SKCS_STATUS_IP_CSUM_ERROR)) {
2229
						(pAC->ChipsetType)) {
3277
								/* HW Checksum error */
2230
						Result = SkCsGetReceiveInfo(pAC,
3278
								SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2231
							&pMsg->data[14],
3279
								SK_DBGCAT_DRV_RX_PROGRESS,
2232
							Csum1, Csum2, pRxPort->PortIndex);
3280
								("skge: CRC error. Frame dropped!\n"));
2233
						if (Result ==
3281
								goto rx_failed;
2234
							SKCS_STATUS_IP_FRAGMENT ||
3282
							} else {
2235
							Result ==
3283
								pMsg->ip_summed = CHECKSUM_NONE;
2236
							SKCS_STATUS_IP_CSUM_OK ||
3284
							}
2237
							Result ==
3285
						}/* checksumControl calculation valid */
2238
							SKCS_STATUS_TCP_CSUM_OK ||
3286
					} /* Frame length check */
2239
							Result ==
3287
				} /* IP frame */
2240
							SKCS_STATUS_UDP_CSUM_OK) {
3288
			} /* pRxPort->UseRxCsum */
2241
								pMsg->ip_summed =
2242
								CHECKSUM_UNNECESSARY;
2243
						}
2244
						else if (Result ==
2245
							SKCS_STATUS_TCP_CSUM_ERROR ||
2246
							Result ==
2247
							SKCS_STATUS_UDP_CSUM_ERROR ||
2248
							Result ==
2249
							SKCS_STATUS_IP_CSUM_ERROR_UDP ||
2250
							Result ==
2251
							SKCS_STATUS_IP_CSUM_ERROR_TCP ||
2252
							Result ==
2253
							SKCS_STATUS_IP_CSUM_ERROR ) {
2254
							/* HW Checksum error */
2255
							SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2256
							SK_DBGCAT_DRV_RX_PROGRESS,
2257
							("skge: CRC error. Frame dropped!\n"));
2258
							goto rx_failed;
2259
						} else {
2260
								pMsg->ip_summed =
2261
								CHECKSUM_NONE;
2262
						}
2263
					}/* checksumControl calculation valid */
2264
				} /* Frame length check */
2265
			} /* IP frame */
2266
#else
2267
			pMsg->ip_summed = CHECKSUM_NONE;	
2268
#endif
2269
		} /* frame > SK_COPY_TRESHOLD */
3289
		} /* frame > SK_COPY_TRESHOLD */
2270
		
3290
		
2271
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV,	1,("V"));
3291
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV,	1,("V"));
2272
		ForRlmt = SK_RLMT_RX_PROTOCOL;
3292
		RlmtNotifier = SK_RLMT_RX_PROTOCOL;
2273
#if 0
2274
		IsBc = (FrameStat & XMR_FS_BC)==XMR_FS_BC;
2275
#endif
2276
		SK_RLMT_PRE_LOOKAHEAD(pAC, PortIndex, FrameLength,
3293
		SK_RLMT_PRE_LOOKAHEAD(pAC, PortIndex, FrameLength,
2277
			IsBc, &Offset, &NumBytes);
3294
					IsBc, &Offset, &NumBytes);
2278
		if (NumBytes != 0) {
3295
		if (NumBytes != 0) {
2279
#if 0
3296
			SK_RLMT_LOOKAHEAD(pAC,PortIndex,&pMsg->data[Offset],
2280
			IsMc = (FrameStat & XMR_FS_MC)==XMR_FS_MC;
3297
						IsBc,IsMc,&RlmtNotifier);
2281
#endif
2282
			SK_RLMT_LOOKAHEAD(pAC, PortIndex,
2283
				&pMsg->data[Offset],
2284
				IsBc, IsMc, &ForRlmt);
2285
		}
3298
		}
2286
		if (ForRlmt == SK_RLMT_RX_PROTOCOL) {
3299
		if (RlmtNotifier == SK_RLMT_RX_PROTOCOL) {
2287
					SK_DBG_MSG(NULL, SK_DBGMOD_DRV,	1,("W"));
3300
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,	1,("W"));
2288
			/* send up only frames from active port */
3301
			/* send up only frames from active port */
2289
			if ((PortIndex == pAC->ActivePort) ||
3302
			if ((PortIndex == pAC->ActivePort)||(pAC->RlmtNets == 2)) {
2290
				(pAC->RlmtNets == 2)) {
2291
				/* frame for upper layer */
2292
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("U"));
3303
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("U"));
2293
#ifdef xDEBUG
3304
#ifdef xDEBUG
2294
				DumpMsg(pMsg, "Rx");
3305
				DumpMsg(pMsg, "Rx");
2295
#endif
3306
#endif
2296
				SK_PNMI_CNT_RX_OCTETS_DELIVERED(pAC,
3307
				SK_PNMI_CNT_RX_OCTETS_DELIVERED(pAC,FrameLength,PortIndex);
2297
					FrameLength, pRxPort->PortIndex);
3308
				pMsg->dev = pAC->dev[PortIndex];
2298
3309
				pMsg->protocol = eth_type_trans(pMsg,pAC->dev[PortIndex]);
2299
				pMsg->dev = pAC->dev[pRxPort->PortIndex];
3310
				netif_rx(pMsg); /* frame for upper layer */
2300
				pMsg->protocol = eth_type_trans(pMsg,
3311
				pAC->dev[PortIndex]->last_rx = jiffies;
2301
					pAC->dev[pRxPort->PortIndex]);
3312
			} else {
2302
				netif_rx(pMsg);
2303
				pAC->dev[pRxPort->PortIndex]->last_rx = jiffies;
2304
			}
2305
			else {
2306
				/* drop frame */
2307
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
3313
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2308
					SK_DBGCAT_DRV_RX_PROGRESS,
3314
					SK_DBGCAT_DRV_RX_PROGRESS,("D"));
2309
					("D"));
3315
				DEV_KFREE_SKB(pMsg); /* drop frame */
2310
				DEV_KFREE_SKB(pMsg);
2311
			}
3316
			}
2312
			
3317
		} else { /* packet for RLMT stack */
2313
		} /* if not for rlmt */
2314
		else {
2315
			/* packet for rlmt */
2316
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
3318
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2317
				SK_DBGCAT_DRV_RX_PROGRESS, ("R"));
3319
				SK_DBGCAT_DRV_RX_PROGRESS,("R"));
2318
			pRlmtMbuf = SkDrvAllocRlmtMbuf(pAC,
3320
			pRlmtMbuf = SkDrvAllocRlmtMbuf(pAC,
2319
				pAC->IoBase, FrameLength);
3321
				pAC->IoBase, FrameLength);
2320
			if (pRlmtMbuf != NULL) {
3322
			if (pRlmtMbuf != NULL) {
Lines 2342-2373 Link Here
2342
				}
3344
				}
2343
3345
2344
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
3346
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2345
					SK_DBGCAT_DRV_RX_PROGRESS,
3347
					SK_DBGCAT_DRV_RX_PROGRESS,("Q"));
2346
					("Q"));
2347
			}
3348
			}
2348
			if ((pAC->dev[pRxPort->PortIndex]->flags &
3349
			if ((pAC->dev[PortIndex]->flags & (IFF_PROMISC | IFF_ALLMULTI)) ||
2349
				(IFF_PROMISC | IFF_ALLMULTI)) != 0 ||
3350
			    (RlmtNotifier & SK_RLMT_RX_PROTOCOL)) {
2350
				(ForRlmt & SK_RLMT_RX_PROTOCOL) ==
3351
				pMsg->dev = pAC->dev[PortIndex];
2351
				SK_RLMT_RX_PROTOCOL) {
3352
				pMsg->protocol = eth_type_trans(pMsg,pAC->dev[PortIndex]);
2352
				pMsg->dev = pAC->dev[pRxPort->PortIndex];
2353
				pMsg->protocol = eth_type_trans(pMsg,
2354
					pAC->dev[pRxPort->PortIndex]);
2355
				netif_rx(pMsg);
3353
				netif_rx(pMsg);
2356
				pAC->dev[pRxPort->PortIndex]->last_rx = jiffies;
3354
				pAC->dev[PortIndex]->last_rx = jiffies;
2357
			}
3355
			} else {
2358
			else {
2359
				DEV_KFREE_SKB(pMsg);
3356
				DEV_KFREE_SKB(pMsg);
2360
			}
3357
			}
2361
3358
		} /* if packet for RLMT stack */
2362
		} /* if packet for rlmt */
2363
	} /* for ... scanning the RXD ring */
3359
	} /* for ... scanning the RXD ring */
2364
3360
2365
	/* RXD ring is empty -> fill and restart */
3361
	/* RXD ring is empty -> fill and restart */
2366
	FillRxRing(pAC, pRxPort);
3362
	FillRxRing(pAC, pRxPort);
2367
	/* do not start if called from Close */
2368
	if (pAC->BoardLevel > SK_INIT_DATA) {
2369
		ClearAndStartRx(pAC, PortIndex);
2370
	}
2371
	return;
3363
	return;
2372
3364
2373
rx_failed:
3365
rx_failed:
Lines 2391-2439 Link Here
2391
3383
2392
} /* ReceiveIrq */
3384
} /* ReceiveIrq */
2393
3385
2394
2395
/*****************************************************************************
2396
 *
2397
 * 	ClearAndStartRx - give a start receive command to BMU, clear IRQ
2398
 *
2399
 * Description:
2400
 *	This function sends a start command and a clear interrupt
2401
 *	command for one receive queue to the BMU.
2402
 *
2403
 * Returns: N/A
2404
 *	none
2405
 */
2406
static void ClearAndStartRx(
2407
SK_AC	*pAC,		/* pointer to the adapter context */
2408
int	PortIndex)	/* index of the receive port (XMAC) */
2409
{
2410
	SK_OUT8(pAC->IoBase,
2411
		RxQueueAddr[PortIndex]+Q_CSR,
2412
		CSR_START | CSR_IRQ_CL_F);
2413
} /* ClearAndStartRx */
2414
2415
2416
/*****************************************************************************
2417
 *
2418
 * 	ClearTxIrq - give a clear transmit IRQ command to BMU
2419
 *
2420
 * Description:
2421
 *	This function sends a clear tx IRQ command for one
2422
 *	transmit queue to the BMU.
2423
 *
2424
 * Returns: N/A
2425
 */
2426
static void ClearTxIrq(
2427
SK_AC	*pAC,		/* pointer to the adapter context */
2428
int	PortIndex,	/* index of the transmit port (XMAC) */
2429
int	Prio)		/* priority or normal queue */
2430
{
2431
	SK_OUT8(pAC->IoBase, 
2432
		TxQueueAddr[PortIndex][Prio]+Q_CSR,
2433
		CSR_IRQ_CL_F);
2434
} /* ClearTxIrq */
2435
2436
2437
/*****************************************************************************
3386
/*****************************************************************************
2438
 *
3387
 *
2439
 * 	ClearRxRing - remove all buffers from the receive ring
3388
 * 	ClearRxRing - remove all buffers from the receive ring
Lines 2522-2552 Link Here
2522
static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p)
3471
static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p)
2523
{
3472
{
2524
3473
2525
DEV_NET *pNet = netdev_priv(dev);
3474
DEV_NET *pNet = (DEV_NET*) dev->priv;
2526
SK_AC	*pAC = pNet->pAC;
3475
SK_AC	*pAC = pNet->pAC;
3476
int	Ret;
2527
3477
2528
struct sockaddr	*addr = p;
3478
struct sockaddr	*addr = p;
2529
unsigned long	Flags;
3479
unsigned long	Flags;
2530
	
3480
	
2531
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3481
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
2532
		("SkGeSetMacAddr starts now...\n"));
3482
		("SkGeSetMacAddr starts now...\n"));
2533
	if(netif_running(dev))
2534
		return -EBUSY;
2535
3483
2536
	memcpy(dev->dev_addr, addr->sa_data,dev->addr_len);
3484
	memcpy(dev->dev_addr, addr->sa_data,dev->addr_len);
2537
	
3485
	
2538
	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3486
	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
2539
3487
2540
	if (pAC->RlmtNets == 2)
3488
	if (pAC->RlmtNets == 2)
2541
		SkAddrOverride(pAC, pAC->IoBase, pNet->NetNr,
3489
		Ret = SkAddrOverride(pAC, pAC->IoBase, pNet->NetNr,
2542
			(SK_MAC_ADDR*)dev->dev_addr, SK_ADDR_VIRTUAL_ADDRESS);
3490
			(SK_MAC_ADDR*)dev->dev_addr, SK_ADDR_VIRTUAL_ADDRESS);
2543
	else
3491
	else
2544
		SkAddrOverride(pAC, pAC->IoBase, pAC->ActivePort,
3492
		Ret = SkAddrOverride(pAC, pAC->IoBase, pAC->ActivePort,
2545
			(SK_MAC_ADDR*)dev->dev_addr, SK_ADDR_VIRTUAL_ADDRESS);
3493
			(SK_MAC_ADDR*)dev->dev_addr, SK_ADDR_VIRTUAL_ADDRESS);
2546
2547
	
2548
	
3494
	
2549
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3495
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3496
3497
	if (Ret != SK_ADDR_OVERRIDE_SUCCESS)
3498
		return -EBUSY;
3499
2550
	return 0;
3500
	return 0;
2551
} /* SkGeSetMacAddr */
3501
} /* SkGeSetMacAddr */
2552
3502
Lines 2579-2585 Link Here
2579
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3529
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
2580
		("SkGeSetRxMode starts now... "));
3530
		("SkGeSetRxMode starts now... "));
2581
3531
2582
	pNet = netdev_priv(dev);
3532
	pNet = (DEV_NET*) dev->priv;
2583
	pAC = pNet->pAC;
3533
	pAC = pNet->pAC;
2584
	if (pAC->RlmtNets == 1)
3534
	if (pAC->RlmtNets == 1)
2585
		PortIdx = pAC->ActivePort;
3535
		PortIdx = pAC->ActivePort;
Lines 2641-2657 Link Here
2641
 */
3591
 */
2642
static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu)
3592
static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu)
2643
{
3593
{
2644
DEV_NET		*pNet;
3594
DEV_NET			*pNet;
2645
DEV_NET		*pOtherNet;
3595
struct net_device 	*otherdev; 
2646
SK_AC		*pAC;
3596
SK_AC			*pAC;
2647
unsigned long	Flags;
3597
unsigned long		Flags;
2648
int		i;
3598
int			i;
2649
SK_EVPARA 	EvPara;
3599
SK_U8			Speed[SK_MAX_MACS];
3600
SK_U8			LinkMode[SK_MAX_MACS];
3601
SK_U8			FlowCtrl[SK_MAX_MACS];
3602
SK_U8			MSMode[SK_MAX_MACS];
3603
SK_BOOL			LinkStatus[SK_MAX_MACS];
3604
#ifdef CONFIG_SK98LIN_NAPI
3605
int			WorkToDo = 1; // min(*budget, dev->quota);
3606
int			WorkDone = 0;
3607
#endif
2650
3608
2651
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3609
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
2652
		("SkGeChangeMtu starts now...\n"));
3610
		("SkGeChangeMtu starts now...\n"));
2653
3611
2654
	pNet = netdev_priv(dev);
3612
	pNet = (DEV_NET*) dev->priv;
2655
	pAC  = pNet->pAC;
3613
	pAC  = pNet->pAC;
2656
3614
2657
	if ((NewMtu < 68) || (NewMtu > SK_JUMBO_MTU)) {
3615
	if ((NewMtu < 68) || (NewMtu > SK_JUMBO_MTU)) {
Lines 2662-2668 Link Here
2662
		return -EINVAL;
3620
		return -EINVAL;
2663
	}
3621
	}
2664
3622
2665
#ifdef SK_DIAG_SUPPORT
2666
	if (pAC->DiagModeActive == DIAG_ACTIVE) {
3623
	if (pAC->DiagModeActive == DIAG_ACTIVE) {
2667
		if (pAC->DiagFlowCtrl == SK_FALSE) {
3624
		if (pAC->DiagFlowCtrl == SK_FALSE) {
2668
			return -1; /* still in use, deny any actions of MTU */
3625
			return -1; /* still in use, deny any actions of MTU */
Lines 2670-2684 Link Here
2670
			pAC->DiagFlowCtrl = SK_FALSE;
3627
			pAC->DiagFlowCtrl = SK_FALSE;
2671
		}
3628
		}
2672
	}
3629
	}
2673
#endif
2674
3630
2675
	pNet->Mtu = NewMtu;
3631
	otherdev = pAC->dev[1 - pNet->NetNr];
2676
	pOtherNet = netdev_priv(pAC->dev[1 - pNet->NetNr]);
3632
	if (NewMtu <= 1500 && otherdev != dev
2677
	if ((pOtherNet->Mtu>1500) && (NewMtu<=1500) && (pOtherNet->Up==1)) {
3633
		&& netif_running(otherdev) && otherdev->mtu > 1500)
2678
		return(0);
3634
		return 0;
2679
	}
2680
3635
2681
	pAC->RxBufSize = NewMtu + 32;
3636
	pAC->RxBufSize = NewMtu + 32;
3637
	while (pAC->RxBufSize % 8) { /* RxBufSize must be a multiple of 8 */
3638
		pAC->RxBufSize = pAC->RxBufSize + 1;
3639
	}
2682
	dev->mtu = NewMtu;
3640
	dev->mtu = NewMtu;
2683
3641
2684
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3642
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
Lines 2694-2719 Link Here
2694
	/* 
3652
	/* 
2695
	** Notify RLMT that any ports are to be stopped
3653
	** Notify RLMT that any ports are to be stopped
2696
	*/
3654
	*/
2697
	EvPara.Para32[0] =  0;
3655
2698
	EvPara.Para32[1] = -1;
2699
	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
3656
	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
2700
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
3657
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP,
2701
		EvPara.Para32[0] =  1;
3658
					0, -1, SK_FALSE);
2702
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
3659
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP,
3660
					1, -1, SK_TRUE);
2703
	} else {
3661
	} else {
2704
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
3662
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP,
3663
					0, -1, SK_TRUE);
2705
	}
3664
	}
2706
3665
2707
	/*
2708
	** After calling the SkEventDispatcher(), RLMT is aware about
2709
	** the stopped ports -> configuration can take place!
2710
	*/
2711
	SkEventDispatcher(pAC, pAC->IoBase);
2712
2713
	for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3666
	for (i=0; i<pAC->GIni.GIMacsFound; i++) {
2714
		spin_lock(&pAC->TxPort[i][TX_PRIO_LOW].TxDesRingLock);
3667
		spin_lock(&pAC->TxPort[i][TX_PRIO_LOW].TxDesRingLock);
2715
		netif_stop_queue(pAC->dev[i]);
3668
		if (netif_running(pAC->dev[i])) {
3669
			LinkStatus[i] = SK_TRUE;
3670
			netif_stop_queue(pAC->dev[i]);
3671
		} else {
3672
			LinkStatus[i] = SK_FALSE;
3673
		}
2716
3674
3675
		/* Save the config data */
3676
		Speed[i] = pAC->GIni.GP[i].PLinkSpeed;
3677
		LinkMode[i] = pAC->GIni.GP[i].PLinkModeConf;
3678
		FlowCtrl[i] = pAC->GIni.GP[i].PFlowCtrlMode;
3679
		MSMode[i] = pAC->GIni.GP[i].PMSMode;
2717
	}
3680
	}
2718
3681
2719
	/*
3682
	/*
Lines 2762-2768 Link Here
2762
	** enable/disable hardware support for long frames
3725
	** enable/disable hardware support for long frames
2763
	*/
3726
	*/
2764
	if (NewMtu > 1500) {
3727
	if (NewMtu > 1500) {
2765
// pAC->JumboActivated = SK_TRUE; /* is never set back !!! */
2766
		pAC->GIni.GIPortUsage = SK_JUMBO_LINK;
3728
		pAC->GIni.GIPortUsage = SK_JUMBO_LINK;
2767
	} else {
3729
	} else {
2768
	    if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
3730
	    if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
Lines 2779-2790 Link Here
2779
	SkAddrInit( pAC, pAC->IoBase, SK_INIT_IO);
3741
	SkAddrInit( pAC, pAC->IoBase, SK_INIT_IO);
2780
	SkRlmtInit( pAC, pAC->IoBase, SK_INIT_IO);
3742
	SkRlmtInit( pAC, pAC->IoBase, SK_INIT_IO);
2781
	SkTimerInit(pAC, pAC->IoBase, SK_INIT_IO);
3743
	SkTimerInit(pAC, pAC->IoBase, SK_INIT_IO);
2782
	
3744
2783
	/*
3745
	/*
2784
	** tschilling:
2785
	** Speed and others are set back to default in level 1 init!
3746
	** Speed and others are set back to default in level 1 init!
2786
	*/
3747
	*/
2787
	GetConfiguration(pAC);
3748
	for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3749
		pAC->GIni.GP[i].PLinkSpeed = Speed[i];
3750
		pAC->GIni.GP[i].PLinkModeConf = LinkMode[i];
3751
		pAC->GIni.GP[i].PFlowCtrlMode = FlowCtrl[i];
3752
		pAC->GIni.GP[i].PMSMode = MSMode[i];
3753
	}
2788
	
3754
	
2789
	SkGeInit(   pAC, pAC->IoBase, SK_INIT_RUN);
3755
	SkGeInit(   pAC, pAC->IoBase, SK_INIT_RUN);
2790
	SkI2cInit(  pAC, pAC->IoBase, SK_INIT_RUN);
3756
	SkI2cInit(  pAC, pAC->IoBase, SK_INIT_RUN);
Lines 2795-2820 Link Here
2795
	SkTimerInit(pAC, pAC->IoBase, SK_INIT_RUN);
3761
	SkTimerInit(pAC, pAC->IoBase, SK_INIT_RUN);
2796
3762
2797
	/*
3763
	/*
2798
	** clear and reinit the rx rings here
3764
	** clear and reinit the rx rings here, because of new MTU size
2799
	*/
3765
	*/
2800
	for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3766
	for (i=0; i<pAC->GIni.GIMacsFound; i++) {
2801
		ReceiveIrq(pAC, &pAC->RxPort[i], SK_TRUE);
3767
		if (LinkStatus[i]) {
2802
		ClearRxRing(pAC, &pAC->RxPort[i]);
3768
		if (CHIP_ID_YUKON_2(pAC)) {
2803
		FillRxRing(pAC, &pAC->RxPort[i]);
3769
			SkY2FreeRxBuffers(pAC, pAC->IoBase, i);
3770
			SkY2FreeTxBuffers(pAC, pAC->IoBase, i);
3771
			SkY2AllocateRxBuffers(pAC, pAC->IoBase, i);
3772
			SkY2RestartStatusUnit(pAC);
3773
			SkY2PortStart(pAC, pAC->IoBase, i);
3774
		} else {
3775
#ifdef CONFIG_SK98LIN_NAPI
3776
			WorkToDo = 1;
3777
			ReceiveIrq(pAC, &pAC->RxPort[i], SK_TRUE, &WorkDone, WorkToDo);
3778
#else
3779
			ReceiveIrq(pAC, &pAC->RxPort[i], SK_TRUE);
3780
#endif
3781
			ClearRxRing(pAC, &pAC->RxPort[i]);
3782
			FillRxRing(pAC, &pAC->RxPort[i]);
2804
3783
2805
		/* 
3784
			/* 
2806
		** Enable transmit descriptor polling
3785
			** Enable transmit descriptor polling
2807
		*/
3786
			*/
2808
		SkGePollTxD(pAC, pAC->IoBase, i, SK_TRUE);
3787
			SkGePollTxD(pAC, pAC->IoBase, i, SK_TRUE);
2809
		FillRxRing(pAC, &pAC->RxPort[i]);
3788
			FillRxRing(pAC, &pAC->RxPort[i]);
2810
	};
3789
		}
3790
		}
3791
	}
2811
3792
2812
	SkGeYellowLED(pAC, pAC->IoBase, 1);
3793
	SkGeYellowLED(pAC, pAC->IoBase, 1);
2813
	SkDimEnableModerationIfNeeded(pAC);	
3794
	SkDimEnableModerationIfNeeded(pAC);	
2814
	SkDimDisplayModerationSettings(pAC);
2815
3795
2816
	netif_start_queue(pAC->dev[pNet->PortNr]);
2817
	for (i=pAC->GIni.GIMacsFound-1; i>=0; i--) {
3796
	for (i=pAC->GIni.GIMacsFound-1; i>=0; i--) {
3797
		if (LinkStatus[i]) {
3798
			netif_start_queue(pAC->dev[pNet->PortNr]);
3799
		}
2818
		spin_unlock(&pAC->TxPort[i][TX_PRIO_LOW].TxDesRingLock);
3800
		spin_unlock(&pAC->TxPort[i][TX_PRIO_LOW].TxDesRingLock);
2819
	}
3801
	}
2820
3802
Lines 2824-2867 Link Here
2824
	SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
3806
	SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
2825
	SK_OUT32(pAC->IoBase, B0_HWE_IMSK, IRQ_HWE_MASK);
3807
	SK_OUT32(pAC->IoBase, B0_HWE_IMSK, IRQ_HWE_MASK);
2826
3808
2827
	SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
2828
	SkEventDispatcher(pAC, pAC->IoBase);
2829
2830
	/* 
3809
	/* 
2831
	** Notify RLMT about the changing and restarting one (or more) ports
3810
	** Notify RLMT about the changing and restarting one (or more) ports
2832
	*/
3811
	*/
2833
	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
3812
	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
2834
		EvPara.Para32[0] = pAC->RlmtNets;
3813
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_SET_NETS,
2835
		EvPara.Para32[1] = -1;
3814
					pAC->RlmtNets, -1, SK_FALSE);
2836
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_SET_NETS, EvPara);
3815
		if (otherdev != dev && netif_running(otherdev)) {
2837
		EvPara.Para32[0] = pNet->PortNr;
3816
			DEV_NET	*pOtherNet = 
2838
		EvPara.Para32[1] = -1;
3817
				(DEV_NET*)pAC->dev[1 - pNet->NetNr]->priv;
2839
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
3818
			SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_START,
2840
			
3819
						pNet->PortNr, -1, SK_FALSE);
2841
		if (pOtherNet->Up) {
3820
			SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_START,
2842
			EvPara.Para32[0] = pOtherNet->PortNr;
3821
						pOtherNet->PortNr, -1, SK_TRUE);
2843
			SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
3822
		} else {
3823
			SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_START,
3824
						pNet->PortNr, -1, SK_TRUE);
2844
		}
3825
		}
2845
	} else {
3826
	} else {
2846
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
3827
		SkLocalEventQueue(pAC, SKGE_RLMT, SK_RLMT_START,
3828
					0, -1, SK_TRUE);
2847
	}
3829
	}
2848
3830
2849
	SkEventDispatcher(pAC, pAC->IoBase);
2850
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3831
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
2851
	
3832
	return 0;
2852
	/*
2853
	** While testing this driver with latest kernel 2.5 (2.5.70), it 
2854
	** seems as if upper layers have a problem to handle a successful
2855
	** return value of '0'. If such a zero is returned, the complete 
2856
	** system hangs for several minutes (!), which is in acceptable.
2857
	**
2858
	** Currently it is not clear, what the exact reason for this problem
2859
	** is. The implemented workaround for 2.5 is to return the desired 
2860
	** new MTU size if all needed changes for the new MTU size where 
2861
	** performed. In kernels 2.2 and 2.4, a zero value is returned,
2862
	** which indicates the successful change of the mtu-size.
2863
	*/
2864
	return NewMtu;
2865
3833
2866
} /* SkGeChangeMtu */
3834
} /* SkGeChangeMtu */
2867
3835
Lines 2879-2922 Link Here
2879
 */
3847
 */
2880
static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev)
3848
static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev)
2881
{
3849
{
2882
DEV_NET *pNet = netdev_priv(dev);
3850
DEV_NET *pNet = (DEV_NET*) dev->priv;
2883
SK_AC	*pAC = pNet->pAC;
3851
SK_AC	*pAC = pNet->pAC;
2884
SK_PNMI_STRUCT_DATA *pPnmiStruct;       /* structure for all Pnmi-Data */
3852
SK_PNMI_STRUCT_DATA *pPnmiStruct;	/* structure for all Pnmi-Data */
2885
SK_PNMI_STAT    *pPnmiStat;             /* pointer to virtual XMAC stat. data */
3853
SK_PNMI_STAT    *pPnmiStat;		/* pointer to virtual XMAC stat. data */
2886
SK_PNMI_CONF    *pPnmiConf;             /* pointer to virtual link config. */
3854
SK_PNMI_CONF    *pPnmiConf;		/* pointer to virtual link config. */
2887
unsigned int    Size;                   /* size of pnmi struct */
3855
unsigned int    Size;			/* size of pnmi struct */
2888
unsigned long	Flags;			/* for spin lock */
3856
unsigned long	Flags;			/* for spin lock */
2889
3857
2890
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3858
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
2891
		("SkGeStats starts now...\n"));
3859
		("SkGeStats starts now...\n"));
2892
	pPnmiStruct = &pAC->PnmiStruct;
3860
	pPnmiStruct = &pAC->PnmiStruct;
2893
3861
2894
#ifdef SK_DIAG_SUPPORT
3862
	if ((pAC->DiagModeActive == DIAG_NOTACTIVE) &&
2895
        if ((pAC->DiagModeActive == DIAG_NOTACTIVE) &&
3863
		(pAC->BoardLevel == SK_INIT_RUN)) {
2896
                (pAC->BoardLevel == SK_INIT_RUN)) {
3864
		SK_MEMSET(pPnmiStruct, 0, sizeof(SK_PNMI_STRUCT_DATA));
2897
#endif
3865
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
2898
        SK_MEMSET(pPnmiStruct, 0, sizeof(SK_PNMI_STRUCT_DATA));
3866
		Size = SK_PNMI_STRUCT_SIZE;
2899
        spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3867
			SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
2900
        Size = SK_PNMI_STRUCT_SIZE;
3868
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
2901
		SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
2902
        spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
2903
#ifdef SK_DIAG_SUPPORT
2904
	}
3869
	}
2905
#endif
2906
3870
2907
        pPnmiStat = &pPnmiStruct->Stat[0];
3871
	pPnmiStat = &pPnmiStruct->Stat[0];
2908
        pPnmiConf = &pPnmiStruct->Conf[0];
3872
	pPnmiConf = &pPnmiStruct->Conf[0];
2909
3873
2910
	pAC->stats.rx_packets = (SK_U32) pPnmiStruct->RxDeliveredCts & 0xFFFFFFFF;
3874
	pAC->stats.rx_packets = (SK_U32) pPnmiStruct->RxDeliveredCts & 0xFFFFFFFF;
2911
	pAC->stats.tx_packets = (SK_U32) pPnmiStat->StatTxOkCts & 0xFFFFFFFF;
3875
	pAC->stats.tx_packets = (SK_U32) pPnmiStat->StatTxOkCts & 0xFFFFFFFF;
2912
	pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts;
3876
	pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts;
2913
	pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts;
3877
	pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts;
2914
	
3878
	
2915
        if (pNet->Mtu <= 1500) {
3879
	if (dev->mtu <= 1500) {
2916
                pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF;
3880
		pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF;
2917
        } else {
3881
	} else {
2918
                pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts -
3882
		pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts -
2919
                        pPnmiStat->StatRxTooLongCts) & 0xFFFFFFFF);
3883
			pPnmiStat->StatRxTooLongCts) & 0xFFFFFFFF);
2920
	}
3884
	}
2921
3885
2922
3886
Lines 2961-2992 Link Here
2961
 *	0, if everything is ok
3925
 *	0, if everything is ok
2962
 *	!=0, on error
3926
 *	!=0, on error
2963
 */
3927
 */
2964
static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd)
3928
static int SkGeIoctl(
2965
{
3929
struct SK_NET_DEVICE *dev,  /* the device the IOCTL is to be performed on   */
2966
DEV_NET		*pNet;
3930
struct ifreq         *rq,   /* additional request structure containing data */
2967
SK_AC		*pAC;
3931
int                   cmd)  /* requested IOCTL command number               */
2968
void		*pMemBuf;
3932
{
2969
struct pci_dev  *pdev = NULL;
3933
	DEV_NET          *pNet = (DEV_NET*) dev->priv;
2970
SK_GE_IOCTL	Ioctl;
3934
	SK_AC            *pAC  = pNet->pAC;
2971
unsigned int	Err = 0;
3935
	struct pci_dev   *pdev = NULL;
2972
int		Size = 0;
3936
	void             *pMemBuf;
2973
int             Ret = 0;
3937
	SK_GE_IOCTL       Ioctl;
2974
unsigned int	Length = 0;
3938
	unsigned long     Flags; /* for spin lock */
2975
int		HeaderLength = sizeof(SK_U32) + sizeof(SK_U32);
3939
	unsigned int      Err = 0;
3940
	unsigned int      Length = 0;
3941
	int               HeaderLength = sizeof(SK_U32) + sizeof(SK_U32);
3942
	int               Size = 0;
3943
	int               Ret = 0;
2976
3944
2977
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3945
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
2978
		("SkGeIoctl starts now...\n"));
3946
		("SkGeIoctl starts now...\n"));
2979
3947
2980
	pNet = netdev_priv(dev);
2981
	pAC = pNet->pAC;
2982
	
2983
	if(copy_from_user(&Ioctl, rq->ifr_data, sizeof(SK_GE_IOCTL))) {
3948
	if(copy_from_user(&Ioctl, rq->ifr_data, sizeof(SK_GE_IOCTL))) {
2984
		return -EFAULT;
3949
		return -EFAULT;
2985
	}
3950
	}
2986
3951
2987
	switch(cmd) {
3952
	switch(cmd) {
2988
	case SK_IOCTL_SETMIB:
3953
	case SIOCETHTOOL:
2989
	case SK_IOCTL_PRESETMIB:
3954
		return SkEthIoctl(dev, rq);
3955
	case SK_IOCTL_SETMIB:     /* FALL THRU */
3956
	case SK_IOCTL_PRESETMIB:  /* FALL THRU (if capable!) */
2990
		if (!capable(CAP_NET_ADMIN)) return -EPERM;
3957
		if (!capable(CAP_NET_ADMIN)) return -EPERM;
2991
 	case SK_IOCTL_GETMIB:
3958
 	case SK_IOCTL_GETMIB:
2992
		if(copy_from_user(&pAC->PnmiStruct, Ioctl.pData,
3959
		if(copy_from_user(&pAC->PnmiStruct, Ioctl.pData,
Lines 3013-3018 Link Here
3013
		if (NULL == (pMemBuf = kmalloc(Length, GFP_KERNEL))) {
3980
		if (NULL == (pMemBuf = kmalloc(Length, GFP_KERNEL))) {
3014
			return -ENOMEM;
3981
			return -ENOMEM;
3015
		}
3982
		}
3983
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3016
		if(copy_from_user(pMemBuf, Ioctl.pData, Length)) {
3984
		if(copy_from_user(pMemBuf, Ioctl.pData, Length)) {
3017
			Err = -EFAULT;
3985
			Err = -EFAULT;
3018
			goto fault_gen;
3986
			goto fault_gen;
Lines 3031-3040 Link Here
3031
			goto fault_gen;
3999
			goto fault_gen;
3032
		}
4000
		}
3033
fault_gen:
4001
fault_gen:
4002
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3034
		kfree(pMemBuf); /* cleanup everything */
4003
		kfree(pMemBuf); /* cleanup everything */
3035
		break;
4004
		break;
3036
#ifdef SK_DIAG_SUPPORT
4005
	case SK_IOCTL_DIAG:
3037
       case SK_IOCTL_DIAG:
3038
		if (!capable(CAP_NET_ADMIN)) return -EPERM;
4006
		if (!capable(CAP_NET_ADMIN)) return -EPERM;
3039
		if (Ioctl.Len < (sizeof(pAC->PnmiStruct) + HeaderLength)) {
4007
		if (Ioctl.Len < (sizeof(pAC->PnmiStruct) + HeaderLength)) {
3040
			Length = Ioctl.Len;
4008
			Length = Ioctl.Len;
Lines 3071-3077 Link Here
3071
fault_diag:
4039
fault_diag:
3072
		kfree(pMemBuf); /* cleanup everything */
4040
		kfree(pMemBuf); /* cleanup everything */
3073
		break;
4041
		break;
3074
#endif
3075
	default:
4042
	default:
3076
		Err = -EOPNOTSUPP;
4043
		Err = -EOPNOTSUPP;
3077
	}
4044
	}
Lines 3103-3114 Link Here
3103
unsigned int	Size,	/* length of ioctl data */
4070
unsigned int	Size,	/* length of ioctl data */
3104
int		mode)	/* flag for set/preset */
4071
int		mode)	/* flag for set/preset */
3105
{
4072
{
3106
unsigned long	Flags;	/* for spin lock */
4073
	SK_AC		*pAC = pNet->pAC;
3107
SK_AC		*pAC;
4074
	unsigned long	Flags;  /* for spin lock */
3108
4075
3109
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
4076
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3110
		("SkGeIocMib starts now...\n"));
4077
		("SkGeIocMib starts now...\n"));
3111
	pAC = pNet->pAC;
4078
3112
	/* access MIB */
4079
	/* access MIB */
3113
	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
4080
	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3114
	switch(mode) {
4081
	switch(mode) {
Lines 3151-3167 Link Here
3151
SK_I32	Port;		/* preferred port */
4118
SK_I32	Port;		/* preferred port */
3152
SK_BOOL	AutoSet;
4119
SK_BOOL	AutoSet;
3153
SK_BOOL DupSet;
4120
SK_BOOL DupSet;
3154
int	LinkSpeed          = SK_LSPEED_AUTO;	/* Link speed */
4121
int	LinkSpeed		= SK_LSPEED_AUTO;	/* Link speed */
3155
int	AutoNeg            = 1;			/* autoneg off (0) or on (1) */
4122
int	AutoNeg			= 1;			/* autoneg off (0) or on (1) */
3156
int	DuplexCap          = 0;			/* 0=both,1=full,2=half */
4123
int	DuplexCap		= 0;			/* 0=both,1=full,2=half */
3157
int	FlowCtrl           = SK_FLOW_MODE_SYM_OR_REM;	/* FlowControl  */
4124
int	FlowCtrl		= SK_FLOW_MODE_SYM_OR_REM;	/* FlowControl  */
3158
int	MSMode             = SK_MS_MODE_AUTO;	/* master/slave mode    */
4125
int	MSMode			= SK_MS_MODE_AUTO;	/* master/slave mode    */
3159
4126
int	IrqModMaskOffset	= 6;			/* all ints moderated=default */
3160
SK_BOOL IsConTypeDefined   = SK_TRUE;
4127
3161
SK_BOOL IsLinkSpeedDefined = SK_TRUE;
4128
SK_BOOL IsConTypeDefined	= SK_TRUE;
3162
SK_BOOL IsFlowCtrlDefined  = SK_TRUE;
4129
SK_BOOL IsLinkSpeedDefined	= SK_TRUE;
3163
SK_BOOL IsRoleDefined      = SK_TRUE;
4130
SK_BOOL IsFlowCtrlDefined	= SK_TRUE;
3164
SK_BOOL IsModeDefined      = SK_TRUE;
4131
SK_BOOL IsRoleDefined		= SK_TRUE;
4132
SK_BOOL IsModeDefined		= SK_TRUE;
3165
/*
4133
/*
3166
 *	The two parameters AutoNeg. and DuplexCap. map to one configuration
4134
 *	The two parameters AutoNeg. and DuplexCap. map to one configuration
3167
 *	parameter. The mapping is described by this table:
4135
 *	parameter. The mapping is described by this table:
Lines 3179-3184 Link Here
3179
		  {SK_LMODE_AUTOBOTH , SK_LMODE_AUTOFULL , SK_LMODE_AUTOHALF },
4147
		  {SK_LMODE_AUTOBOTH , SK_LMODE_AUTOFULL , SK_LMODE_AUTOHALF },
3180
		  {SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE} };
4148
		  {SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE} };
3181
4149
4150
SK_U32	IrqModMask[7][2] =
4151
		{ { IRQ_MASK_RX_ONLY , Y2_DRIVER_IRQS  },
4152
		  { IRQ_MASK_TX_ONLY , Y2_DRIVER_IRQS  },
4153
		  { IRQ_MASK_SP_ONLY , Y2_SPECIAL_IRQS },
4154
		  { IRQ_MASK_SP_RX   , Y2_IRQ_MASK     },
4155
		  { IRQ_MASK_TX_RX   , Y2_DRIVER_IRQS  },
4156
		  { IRQ_MASK_SP_TX   , Y2_IRQ_MASK     },
4157
		  { IRQ_MASK_RX_TX_SP, Y2_IRQ_MASK     } };
4158
3182
#define DC_BOTH	0
4159
#define DC_BOTH	0
3183
#define DC_FULL 1
4160
#define DC_FULL 1
3184
#define DC_HALF 2
4161
#define DC_HALF 2
Lines 3218-3224 Link Here
3218
	** 
4195
	** 
3219
	** This ConType parameter is used for all ports of the adapter!
4196
	** This ConType parameter is used for all ports of the adapter!
3220
	*/
4197
	*/
3221
        if ( (ConType != NULL)                && 
4198
	if ( (ConType != NULL)                && 
3222
	     (pAC->Index < SK_MAX_CARD_PARAM) &&
4199
	     (pAC->Index < SK_MAX_CARD_PARAM) &&
3223
	     (ConType[pAC->Index] != NULL) ) {
4200
	     (ConType[pAC->Index] != NULL) ) {
3224
4201
Lines 3244-3283 Link Here
3244
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
4221
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
3245
			M_CurrPort.PLinkSpeed    = SK_LSPEED_AUTO;
4222
			M_CurrPort.PLinkSpeed    = SK_LSPEED_AUTO;
3246
		    }
4223
		    }
3247
                } else if (strcmp(ConType[pAC->Index],"100FD")==0) {
4224
		} else if (strcmp(ConType[pAC->Index],"100FD")==0) {
3248
		    for (Port = 0; Port < SK_MAX_MACS; Port++) {
4225
		    for (Port = 0; Port < SK_MAX_MACS; Port++) {
3249
			M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_FULL];
4226
			M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_FULL];
3250
			M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE;
4227
			M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE;
3251
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
4228
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
3252
			M_CurrPort.PLinkSpeed    = SK_LSPEED_100MBPS;
4229
			M_CurrPort.PLinkSpeed    = SK_LSPEED_100MBPS;
3253
		    }
4230
		    }
3254
                } else if (strcmp(ConType[pAC->Index],"100HD")==0) {
4231
		} else if (strcmp(ConType[pAC->Index],"100HD")==0) {
3255
		    for (Port = 0; Port < SK_MAX_MACS; Port++) {
4232
		    for (Port = 0; Port < SK_MAX_MACS; Port++) {
3256
			M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_HALF];
4233
			M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_HALF];
3257
			M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE;
4234
			M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE;
3258
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
4235
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
3259
			M_CurrPort.PLinkSpeed    = SK_LSPEED_100MBPS;
4236
			M_CurrPort.PLinkSpeed    = SK_LSPEED_100MBPS;
3260
		    }
4237
		    }
3261
                } else if (strcmp(ConType[pAC->Index],"10FD")==0) {
4238
		} else if (strcmp(ConType[pAC->Index],"10FD")==0) {
3262
		    for (Port = 0; Port < SK_MAX_MACS; Port++) {
4239
		    for (Port = 0; Port < SK_MAX_MACS; Port++) {
3263
			M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_FULL];
4240
			M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_FULL];
3264
			M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE;
4241
			M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE;
3265
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
4242
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
3266
			M_CurrPort.PLinkSpeed    = SK_LSPEED_10MBPS;
4243
			M_CurrPort.PLinkSpeed    = SK_LSPEED_10MBPS;
3267
		    }
4244
		    }
3268
                } else if (strcmp(ConType[pAC->Index],"10HD")==0) {
4245
		} else if (strcmp(ConType[pAC->Index],"10HD")==0) {
3269
		    for (Port = 0; Port < SK_MAX_MACS; Port++) {
4246
		    for (Port = 0; Port < SK_MAX_MACS; Port++) {
3270
			M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_HALF];
4247
			M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_HALF];
3271
			M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE;
4248
			M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE;
3272
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
4249
			M_CurrPort.PMSMode       = SK_MS_MODE_AUTO;
3273
			M_CurrPort.PLinkSpeed    = SK_LSPEED_10MBPS;
4250
			M_CurrPort.PLinkSpeed    = SK_LSPEED_10MBPS;
3274
		    }
4251
		    }
3275
                } else { 
4252
		} else { 
3276
		    printk("sk98lin: Illegal value \"%s\" for ConType\n", 
4253
		    printk("sk98lin: Illegal value \"%s\" for ConType\n", 
3277
			ConType[pAC->Index]);
4254
			ConType[pAC->Index]);
3278
		    IsConTypeDefined = SK_FALSE; /* Wrong ConType defined */
4255
		    IsConTypeDefined = SK_FALSE; /* Wrong ConType defined */
3279
		}
4256
		}
3280
        } else {
4257
	} else {
3281
	    IsConTypeDefined = SK_FALSE; /* No ConType defined */
4258
	    IsConTypeDefined = SK_FALSE; /* No ConType defined */
3282
	}
4259
	}
3283
4260
Lines 3296-3309 Link Here
3296
		} else if (strcmp(Speed_A[pAC->Index],"100")==0) {
4273
		} else if (strcmp(Speed_A[pAC->Index],"100")==0) {
3297
		    LinkSpeed = SK_LSPEED_100MBPS;
4274
		    LinkSpeed = SK_LSPEED_100MBPS;
3298
		} else if (strcmp(Speed_A[pAC->Index],"1000")==0) {
4275
		} else if (strcmp(Speed_A[pAC->Index],"1000")==0) {
3299
		    LinkSpeed = SK_LSPEED_1000MBPS;
4276
		    if ((pAC->PciDev->vendor == 0x11ab ) &&
4277
		    	(pAC->PciDev->device == 0x4350)) {
4278
				LinkSpeed = SK_LSPEED_100MBPS;
4279
				printk("sk98lin: Illegal value \"%s\" for Speed_A.\n"
4280
					"Gigabit speed not possible with this chip revision!",
4281
					Speed_A[pAC->Index]);
4282
			} else {
4283
				LinkSpeed = SK_LSPEED_1000MBPS;
4284
		    }
3300
		} else {
4285
		} else {
3301
		    printk("sk98lin: Illegal value \"%s\" for Speed_A\n",
4286
		    printk("sk98lin: Illegal value \"%s\" for Speed_A\n",
3302
			Speed_A[pAC->Index]);
4287
			Speed_A[pAC->Index]);
3303
		    IsLinkSpeedDefined = SK_FALSE;
4288
		    IsLinkSpeedDefined = SK_FALSE;
3304
		}
4289
		}
3305
	} else {
4290
	} else {
3306
	    IsLinkSpeedDefined = SK_FALSE;
4291
		if ((pAC->PciDev->vendor == 0x11ab ) && 
4292
			(pAC->PciDev->device == 0x4350)) {
4293
			/* Gigabit speed not supported
4294
			 * Swith to speed 100
4295
			 */
4296
			LinkSpeed = SK_LSPEED_100MBPS;
4297
		} else {
4298
			IsLinkSpeedDefined = SK_FALSE;
4299
		}
3307
	}
4300
	}
3308
4301
3309
	/* 
4302
	/* 
Lines 3398-3406 Link Here
3398
	}
4391
	}
3399
	
4392
	
3400
	if (!AutoSet && DupSet) {
4393
	if (!AutoSet && DupSet) {
3401
		printk("sk98lin: Port A: Duplex setting not"
3402
			" possible in\n    default AutoNegotiation mode"
3403
			" (Sense).\n    Using AutoNegotiation On\n");
3404
		AutoNeg = AN_ON;
4394
		AutoNeg = AN_ON;
3405
	}
4395
	}
3406
	
4396
	
Lines 3428-3434 Link Here
3428
		    FlowCtrl = SK_FLOW_MODE_NONE;
4418
		    FlowCtrl = SK_FLOW_MODE_NONE;
3429
		} else {
4419
		} else {
3430
		    printk("sk98lin: Illegal value \"%s\" for FlowCtrl_A\n",
4420
		    printk("sk98lin: Illegal value \"%s\" for FlowCtrl_A\n",
3431
                        FlowCtrl_A[pAC->Index]);
4421
			FlowCtrl_A[pAC->Index]);
3432
		    IsFlowCtrlDefined = SK_FALSE;
4422
		    IsFlowCtrlDefined = SK_FALSE;
3433
		}
4423
		}
3434
	} else {
4424
	} else {
Lines 3520-3526 Link Here
3520
	** Decide whether to set new config value if somethig valid has
4510
	** Decide whether to set new config value if somethig valid has
3521
	** been received.
4511
	** been received.
3522
	*/
4512
	*/
3523
        if (IsLinkSpeedDefined) {
4513
	if (IsLinkSpeedDefined) {
3524
	    pAC->GIni.GP[1].PLinkSpeed = LinkSpeed;
4514
	    pAC->GIni.GP[1].PLinkSpeed = LinkSpeed;
3525
	}
4515
	}
3526
4516
Lines 3596-3604 Link Here
3596
	}
4586
	}
3597
	
4587
	
3598
	if (!AutoSet && DupSet) {
4588
	if (!AutoSet && DupSet) {
3599
		printk("sk98lin: Port B: Duplex setting not"
3600
			" possible in\n    default AutoNegotiation mode"
3601
			" (Sense).\n    Using AutoNegotiation On\n");
3602
		AutoNeg = AN_ON;
4589
		AutoNeg = AN_ON;
3603
	}
4590
	}
3604
4591
Lines 3738-3747 Link Here
3738
	} else {
4725
	} else {
3739
		pAC->RlmtMode = 0;
4726
		pAC->RlmtMode = 0;
3740
	}
4727
	}
3741
	
4728
4729
#ifdef SK_YUKON2
4730
	/*
4731
	** use dualnet config per default
4732
	*
4733
	pAC->RlmtMode = SK_RLMT_CHECK_LINK;
4734
	pAC->RlmtNets = 2;
4735
	*/
4736
#endif
4737
4738
4739
	/*
4740
	** Check the LowLatance parameters
4741
	*/
4742
	pAC->LowLatency = SK_FALSE;
4743
	if (LowLatency[pAC->Index] != NULL) {
4744
		if (strcmp(LowLatency[pAC->Index], "On") == 0) {
4745
			pAC->LowLatency = SK_TRUE;
4746
		}
4747
	}
4748
4749
3742
	/*
4750
	/*
3743
	** Check the interrupt moderation parameters
4751
	** Check the interrupt moderation parameters
3744
	*/
4752
	*/
4753
	pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
3745
	if (Moderation[pAC->Index] != NULL) {
4754
	if (Moderation[pAC->Index] != NULL) {
3746
		if (strcmp(Moderation[pAC->Index], "") == 0) {
4755
		if (strcmp(Moderation[pAC->Index], "") == 0) {
3747
			pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
4756
			pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
Lines 3755-3824 Link Here
3755
	   		printk("sk98lin: Illegal value \"%s\" for Moderation.\n"
4764
	   		printk("sk98lin: Illegal value \"%s\" for Moderation.\n"
3756
				"      Disable interrupt moderation.\n",
4765
				"      Disable interrupt moderation.\n",
3757
				Moderation[pAC->Index]);
4766
				Moderation[pAC->Index]);
3758
			pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
3759
		}
3760
	} else {
3761
		pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
3762
	}
3763
3764
	if (Stats[pAC->Index] != NULL) {
3765
		if (strcmp(Stats[pAC->Index], "Yes") == 0) {
3766
			pAC->DynIrqModInfo.DisplayStats = SK_TRUE;
3767
		} else {
3768
			pAC->DynIrqModInfo.DisplayStats = SK_FALSE;
3769
		}
4767
		}
3770
	} else {
4768
	} else {
3771
		pAC->DynIrqModInfo.DisplayStats = SK_FALSE;
4769
/* Set interrupt moderation if wished */
4770
#ifdef CONFIG_SK98LIN_STATINT
4771
		pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_STATIC;
4772
#endif
3772
	}
4773
	}
3773
4774
3774
	if (ModerationMask[pAC->Index] != NULL) {
4775
	if (ModerationMask[pAC->Index] != NULL) {
3775
		if (strcmp(ModerationMask[pAC->Index], "Rx") == 0) {
4776
		if (strcmp(ModerationMask[pAC->Index], "Rx") == 0) {
3776
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_ONLY;
4777
			IrqModMaskOffset = 0;
3777
		} else if (strcmp(ModerationMask[pAC->Index], "Tx") == 0) {
4778
		} else if (strcmp(ModerationMask[pAC->Index], "Tx") == 0) {
3778
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_ONLY;
4779
			IrqModMaskOffset = 1;
3779
		} else if (strcmp(ModerationMask[pAC->Index], "Sp") == 0) {
4780
		} else if (strcmp(ModerationMask[pAC->Index], "Sp") == 0) {
3780
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_ONLY;
4781
			IrqModMaskOffset = 2;
3781
		} else if (strcmp(ModerationMask[pAC->Index], "RxSp") == 0) {
4782
		} else if (strcmp(ModerationMask[pAC->Index], "RxSp") == 0) {
3782
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_RX;
4783
			IrqModMaskOffset = 3;
3783
		} else if (strcmp(ModerationMask[pAC->Index], "SpRx") == 0) {
4784
		} else if (strcmp(ModerationMask[pAC->Index], "SpRx") == 0) {
3784
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_RX;
4785
			IrqModMaskOffset = 3;
3785
		} else if (strcmp(ModerationMask[pAC->Index], "RxTx") == 0) {
4786
		} else if (strcmp(ModerationMask[pAC->Index], "RxTx") == 0) {
3786
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX;
4787
			IrqModMaskOffset = 4;
3787
		} else if (strcmp(ModerationMask[pAC->Index], "TxRx") == 0) {
4788
		} else if (strcmp(ModerationMask[pAC->Index], "TxRx") == 0) {
3788
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX;
4789
			IrqModMaskOffset = 4;
3789
		} else if (strcmp(ModerationMask[pAC->Index], "TxSp") == 0) {
4790
		} else if (strcmp(ModerationMask[pAC->Index], "TxSp") == 0) {
3790
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_TX;
4791
			IrqModMaskOffset = 5;
3791
		} else if (strcmp(ModerationMask[pAC->Index], "SpTx") == 0) {
4792
		} else if (strcmp(ModerationMask[pAC->Index], "SpTx") == 0) {
3792
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_TX;
4793
			IrqModMaskOffset = 5;
3793
		} else if (strcmp(ModerationMask[pAC->Index], "RxTxSp") == 0) {
4794
		} else { /* some rubbish stated */
3794
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
4795
			// IrqModMaskOffset = 6; ->has been initialized
3795
		} else if (strcmp(ModerationMask[pAC->Index], "RxSpTx") == 0) {
4796
			// already at the begin of this function...
3796
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
3797
		} else if (strcmp(ModerationMask[pAC->Index], "TxRxSp") == 0) {
3798
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
3799
		} else if (strcmp(ModerationMask[pAC->Index], "TxSpRx") == 0) {
3800
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
3801
		} else if (strcmp(ModerationMask[pAC->Index], "SpTxRx") == 0) {
3802
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
3803
		} else if (strcmp(ModerationMask[pAC->Index], "SpRxTx") == 0) {
3804
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
3805
		} else { /* some rubbish */
3806
			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_ONLY;
3807
		}
3808
	} else {  /* operator has stated nothing */
3809
		pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX;
3810
	}
3811
3812
	if (AutoSizing[pAC->Index] != NULL) {
3813
		if (strcmp(AutoSizing[pAC->Index], "On") == 0) {
3814
			pAC->DynIrqModInfo.AutoSizing = SK_FALSE;
3815
		} else {
3816
			pAC->DynIrqModInfo.AutoSizing = SK_FALSE;
3817
		}
4797
		}
3818
	} else {  /* operator has stated nothing */
4798
	}
3819
		pAC->DynIrqModInfo.AutoSizing = SK_FALSE;
4799
	if (!CHIP_ID_YUKON_2(pAC)) {
4800
		pAC->DynIrqModInfo.MaskIrqModeration = IrqModMask[IrqModMaskOffset][0];
4801
	} else {
4802
		pAC->DynIrqModInfo.MaskIrqModeration = IrqModMask[IrqModMaskOffset][1];
3820
	}
4803
	}
3821
4804
4805
	if (!CHIP_ID_YUKON_2(pAC)) {
4806
		pAC->DynIrqModInfo.MaxModIntsPerSec = C_INTS_PER_SEC_DEFAULT;
4807
	} else {
4808
		pAC->DynIrqModInfo.MaxModIntsPerSec = C_Y2_INTS_PER_SEC_DEFAULT;
4809
	}
3822
	if (IntsPerSec[pAC->Index] != 0) {
4810
	if (IntsPerSec[pAC->Index] != 0) {
3823
		if ((IntsPerSec[pAC->Index]< C_INT_MOD_IPS_LOWER_RANGE) || 
4811
		if ((IntsPerSec[pAC->Index]< C_INT_MOD_IPS_LOWER_RANGE) || 
3824
			(IntsPerSec[pAC->Index] > C_INT_MOD_IPS_UPPER_RANGE)) {
4812
			(IntsPerSec[pAC->Index] > C_INT_MOD_IPS_UPPER_RANGE)) {
Lines 3827-3854 Link Here
3827
				IntsPerSec[pAC->Index],
4815
				IntsPerSec[pAC->Index],
3828
				C_INT_MOD_IPS_LOWER_RANGE,
4816
				C_INT_MOD_IPS_LOWER_RANGE,
3829
				C_INT_MOD_IPS_UPPER_RANGE,
4817
				C_INT_MOD_IPS_UPPER_RANGE,
3830
				C_INTS_PER_SEC_DEFAULT);
4818
				pAC->DynIrqModInfo.MaxModIntsPerSec);
3831
			pAC->DynIrqModInfo.MaxModIntsPerSec = C_INTS_PER_SEC_DEFAULT;
3832
		} else {
4819
		} else {
3833
			pAC->DynIrqModInfo.MaxModIntsPerSec = IntsPerSec[pAC->Index];
4820
			pAC->DynIrqModInfo.MaxModIntsPerSec = IntsPerSec[pAC->Index];
3834
		}
4821
		}
3835
	} else {
4822
	} 
3836
		pAC->DynIrqModInfo.MaxModIntsPerSec = C_INTS_PER_SEC_DEFAULT;
3837
	}
3838
4823
3839
	/*
4824
	/*
3840
	** Evaluate upper and lower moderation threshold
4825
	** Evaluate upper and lower moderation threshold
3841
	*/
4826
	*/
3842
	pAC->DynIrqModInfo.MaxModIntsPerSecUpperLimit =
4827
	pAC->DynIrqModInfo.MaxModIntsPerSecUpperLimit =
3843
		pAC->DynIrqModInfo.MaxModIntsPerSec +
4828
		pAC->DynIrqModInfo.MaxModIntsPerSec +
3844
		(pAC->DynIrqModInfo.MaxModIntsPerSec / 2);
4829
		(pAC->DynIrqModInfo.MaxModIntsPerSec / 5);
3845
4830
3846
	pAC->DynIrqModInfo.MaxModIntsPerSecLowerLimit =
4831
	pAC->DynIrqModInfo.MaxModIntsPerSecLowerLimit =
3847
		pAC->DynIrqModInfo.MaxModIntsPerSec -
4832
		pAC->DynIrqModInfo.MaxModIntsPerSec -
3848
		(pAC->DynIrqModInfo.MaxModIntsPerSec / 2);
4833
		(pAC->DynIrqModInfo.MaxModIntsPerSec / 5);
3849
3850
	pAC->DynIrqModInfo.PrevTimeVal = jiffies;  /* initial value */
3851
4834
4835
	pAC->DynIrqModInfo.DynIrqModSampleInterval = 
4836
		SK_DRV_MODERATION_TIMER_LENGTH;
3852
4837
3853
} /* GetConfiguration */
4838
} /* GetConfiguration */
3854
4839
Lines 3884-3928 Link Here
3884
	}
4869
	}
3885
} /* ProductStr */
4870
} /* ProductStr */
3886
4871
3887
/*****************************************************************************
3888
 *
3889
 *      StartDrvCleanupTimer - Start timer to check for descriptors which
3890
 *                             might be placed in descriptor ring, but
3891
 *                             havent been handled up to now
3892
 *
3893
 * Description:
3894
 *      This function requests a HW-timer fo the Yukon card. The actions to
3895
 *      perform when this timer expires, are located in the SkDrvEvent().
3896
 *
3897
 * Returns: N/A
3898
 */
3899
static void
3900
StartDrvCleanupTimer(SK_AC *pAC) {
3901
    SK_EVPARA    EventParam;   /* Event struct for timer event */
3902
3903
    SK_MEMSET((char *) &EventParam, 0, sizeof(EventParam));
3904
    EventParam.Para32[0] = SK_DRV_RX_CLEANUP_TIMER;
3905
    SkTimerStart(pAC, pAC->IoBase, &pAC->DrvCleanupTimer,
3906
                 SK_DRV_RX_CLEANUP_TIMER_LENGTH,
3907
                 SKGE_DRV, SK_DRV_TIMER, EventParam);
3908
}
3909
3910
/*****************************************************************************
3911
 *
3912
 *      StopDrvCleanupTimer - Stop timer to check for descriptors
3913
 *
3914
 * Description:
3915
 *      This function requests a HW-timer fo the Yukon card. The actions to
3916
 *      perform when this timer expires, are located in the SkDrvEvent().
3917
 *
3918
 * Returns: N/A
3919
 */
3920
static void
3921
StopDrvCleanupTimer(SK_AC *pAC) {
3922
    SkTimerStop(pAC, pAC->IoBase, &pAC->DrvCleanupTimer);
3923
    SK_MEMSET((char *) &pAC->DrvCleanupTimer, 0, sizeof(SK_TIMER));
3924
}
3925
3926
/****************************************************************************/
4872
/****************************************************************************/
3927
/* functions for common modules *********************************************/
4873
/* functions for common modules *********************************************/
3928
/****************************************************************************/
4874
/****************************************************************************/
Lines 4011-4017 Link Here
4011
SK_U64 SkOsGetTime(SK_AC *pAC)
4957
SK_U64 SkOsGetTime(SK_AC *pAC)
4012
{
4958
{
4013
	SK_U64	PrivateJiffies;
4959
	SK_U64	PrivateJiffies;
4960
4014
	SkOsGetTimeCurrent(pAC, &PrivateJiffies);
4961
	SkOsGetTimeCurrent(pAC, &PrivateJiffies);
4962
4015
	return PrivateJiffies;
4963
	return PrivateJiffies;
4016
} /* SkOsGetTime */
4964
} /* SkOsGetTime */
4017
4965
Lines 4166-4194 Link Here
4166
 *	
5114
 *	
4167
 */
5115
 */
4168
int SkDrvEvent(
5116
int SkDrvEvent(
4169
SK_AC *pAC,		/* pointer to adapter context */
5117
SK_AC     *pAC,    /* pointer to adapter context */
4170
SK_IOC IoC,		/* io-context */
5118
SK_IOC     IoC,    /* IO control context         */
4171
SK_U32 Event,		/* event-id */
5119
SK_U32     Event,  /* event-id                   */
4172
SK_EVPARA Param)	/* event-parameter */
5120
SK_EVPARA  Param)  /* event-parameter            */
4173
{
5121
{
4174
SK_MBUF		*pRlmtMbuf;	/* pointer to a rlmt-mbuf structure */
5122
	SK_MBUF         *pRlmtMbuf;   /* pointer to a rlmt-mbuf structure   */
4175
struct sk_buff	*pMsg;		/* pointer to a message block */
5123
	struct sk_buff  *pMsg;        /* pointer to a message block         */
4176
int		FromPort;	/* the port from which we switch away */
5124
	SK_BOOL          DualNet;
4177
int		ToPort;		/* the port we switch to */
5125
	SK_U32           Reason;
4178
SK_EVPARA	NewPara;	/* parameter for further events */
5126
	unsigned long    Flags;
4179
int		Stat;
5127
	int              FromPort;    /* the port from which we switch away */
4180
unsigned long	Flags;
5128
	int              ToPort;      /* the port we switch to              */
4181
SK_BOOL		DualNet;
5129
	int              Stat;
5130
	DEV_NET 	*pNet = NULL;
5131
#ifdef CONFIG_SK98LIN_NAPI
5132
	int              WorkToDo = 1; /* min(*budget, dev->quota); */
5133
	int              WorkDone = 0;
5134
#endif
4182
5135
4183
	switch (Event) {
5136
	switch (Event) {
4184
	case SK_DRV_ADAP_FAIL:
4185
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4186
			("ADAPTER FAIL EVENT\n"));
4187
		printk("%s: Adapter failed.\n", pAC->dev[0]->name);
4188
		/* disable interrupts */
4189
		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
4190
		/* cgoos */
4191
		break;
4192
	case SK_DRV_PORT_FAIL:
5137
	case SK_DRV_PORT_FAIL:
4193
		FromPort = Param.Para32[0];
5138
		FromPort = Param.Para32[0];
4194
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5139
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
Lines 4198-4408 Link Here
4198
		} else {
5143
		} else {
4199
			printk("%s: Port B failed.\n", pAC->dev[1]->name);
5144
			printk("%s: Port B failed.\n", pAC->dev[1]->name);
4200
		}
5145
		}
4201
		/* cgoos */
4202
		break;
5146
		break;
4203
	case SK_DRV_PORT_RESET:	 /* SK_U32 PortIdx */
5147
	case SK_DRV_PORT_RESET:
4204
		/* action list 4 */
4205
		FromPort = Param.Para32[0];
5148
		FromPort = Param.Para32[0];
4206
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5149
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4207
			("PORT RESET EVENT, Port: %d ", FromPort));
5150
			("PORT RESET EVENT, Port: %d ", FromPort));
4208
		NewPara.Para64 = FromPort;
5151
		SkLocalEventQueue64(pAC, SKGE_PNMI, SK_PNMI_EVT_XMAC_RESET,
4209
		SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_XMAC_RESET, NewPara);
5152
					FromPort, SK_FALSE);
4210
		spin_lock_irqsave(
5153
		spin_lock_irqsave(
4211
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5154
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4212
			Flags);
5155
			Flags);
4213
5156
		if (CHIP_ID_YUKON_2(pAC)) {
4214
		SkGeStopPort(pAC, IoC, FromPort, SK_STOP_ALL, SK_HARD_RST);
5157
			SkY2PortStop(pAC, IoC, FromPort, SK_STOP_ALL, SK_HARD_RST);
5158
		} else {
5159
			SkGeStopPort(pAC, IoC, FromPort, SK_STOP_ALL, SK_HARD_RST);
5160
		}
4215
		pAC->dev[Param.Para32[0]]->flags &= ~IFF_RUNNING;
5161
		pAC->dev[Param.Para32[0]]->flags &= ~IFF_RUNNING;
4216
		spin_unlock_irqrestore(
5162
		spin_unlock_irqrestore(
4217
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5163
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4218
			Flags);
5164
			Flags);
4219
		
5165
		
4220
		/* clear rx ring from received frames */
5166
		if (!CHIP_ID_YUKON_2(pAC)) {
4221
		ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE);
5167
#ifdef CONFIG_SK98LIN_NAPI
4222
		
5168
			WorkToDo = 1;
4223
		ClearTxRing(pAC, &pAC->TxPort[FromPort][TX_PRIO_LOW]);
5169
			ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE, &WorkDone, WorkToDo);
5170
#else
5171
			ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE);
5172
#endif
5173
			ClearTxRing(pAC, &pAC->TxPort[FromPort][TX_PRIO_LOW]);
5174
		}
4224
		spin_lock_irqsave(
5175
		spin_lock_irqsave(
4225
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5176
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4226
			Flags);
5177
			Flags);
4227
		
5178
4228
		/* tschilling: Handling of return value inserted. */
5179
#ifdef USE_TIST_FOR_RESET
4229
		if (SkGeInitPort(pAC, IoC, FromPort)) {
5180
                if (pAC->GIni.GIYukon2) {
4230
			if (FromPort == 0) {
5181
#ifdef Y2_RECOVERY
4231
				printk("%s: SkGeInitPort A failed.\n", pAC->dev[0]->name);
5182
			/* for Yukon II we want to have tist enabled all the time */
5183
			if (!SK_ADAPTER_WAITING_FOR_TIST(pAC)) {
5184
				Y2_ENABLE_TIST(pAC->IoBase);
5185
			}
5186
#else
5187
			/* make sure that we do not accept any status LEs from now on */
5188
			if (SK_ADAPTER_WAITING_FOR_TIST(pAC)) {
5189
#endif
5190
				/* port already waiting for tist */
5191
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
5192
					("Port %c is now waiting for specific Tist\n",
5193
					'A' +  FromPort));
5194
				SK_SET_WAIT_BIT_FOR_PORT(
5195
					pAC,
5196
					SK_PSTATE_WAITING_FOR_SPECIFIC_TIST,
5197
					FromPort);
5198
				/* get current timestamp */
5199
				Y2_GET_TIST_LOW_VAL(pAC->IoBase, &pAC->MinTistLo);
5200
				pAC->MinTistHi = pAC->GIni.GITimeStampCnt;
5201
#ifndef Y2_RECOVERY
4232
			} else {
5202
			} else {
4233
				printk("%s: SkGeInitPort B failed.\n", pAC->dev[1]->name);
5203
				/* nobody is waiting yet */
5204
				SK_SET_WAIT_BIT_FOR_PORT(
5205
					pAC,
5206
					SK_PSTATE_WAITING_FOR_ANY_TIST,
5207
					FromPort);
5208
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
5209
					("Port %c is now waiting for any Tist (0x%X)\n",
5210
					'A' +  FromPort, pAC->AdapterResetState));
5211
				/* start tist */
5212
				Y2_ENABLE_TIST(pAC-IoBase);
5213
			}
5214
#endif
5215
		}
5216
#endif
5217
5218
#ifdef Y2_LE_CHECK
5219
		/* mark entries invalid */
5220
		pAC->LastPort = 3;
5221
		pAC->LastOpc = 0xFF;
5222
#endif
5223
		if (CHIP_ID_YUKON_2(pAC)) {
5224
			SkY2PortStart(pAC, IoC, FromPort);
5225
		} else {
5226
			/* tschilling: Handling of return value inserted. */
5227
			if (SkGeInitPort(pAC, IoC, FromPort)) {
5228
				if (FromPort == 0) {
5229
					printk("%s: SkGeInitPort A failed.\n", pAC->dev[0]->name);
5230
				} else {
5231
					printk("%s: SkGeInitPort B failed.\n", pAC->dev[1]->name);
5232
				}
4234
			}
5233
			}
5234
			SkAddrMcUpdate(pAC,IoC, FromPort);
5235
			PortReInitBmu(pAC, FromPort);
5236
			SkGePollTxD(pAC, IoC, FromPort, SK_TRUE);
5237
			CLEAR_AND_START_RX(FromPort);
4235
		}
5238
		}
4236
		SkAddrMcUpdate(pAC,IoC, FromPort);
4237
		PortReInitBmu(pAC, FromPort);
4238
		SkGePollTxD(pAC, IoC, FromPort, SK_TRUE);
4239
		ClearAndStartRx(pAC, FromPort);
4240
		spin_unlock_irqrestore(
5239
		spin_unlock_irqrestore(
4241
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5240
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4242
			Flags);
5241
			Flags);
4243
		break;
5242
		break;
4244
	case SK_DRV_NET_UP:	 /* SK_U32 PortIdx */
5243
	case SK_DRV_NET_UP:
4245
		/* action list 5 */
4246
		FromPort = Param.Para32[0];
5244
		FromPort = Param.Para32[0];
4247
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5245
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4248
			("NET UP EVENT, Port: %d ", Param.Para32[0]));
5246
			("NET UP EVENT, Port: %d ", FromPort));
4249
		/* Mac update */
5247
		SkAddrMcUpdate(pAC,IoC, FromPort); /* Mac update */
4250
		SkAddrMcUpdate(pAC,IoC, FromPort);
4251
4252
		if (DoPrintInterfaceChange) {
5248
		if (DoPrintInterfaceChange) {
4253
		printk("%s: network connection up using"
5249
			printk("%s: network connection up using port %c\n",
4254
			" port %c\n", pAC->dev[Param.Para32[0]]->name, 'A'+Param.Para32[0]);
5250
				pAC->dev[FromPort]->name, 'A'+FromPort);
4255
5251
4256
		/* tschilling: Values changed according to LinkSpeedUsed. */
5252
			/* tschilling: Values changed according to LinkSpeedUsed. */
4257
		Stat = pAC->GIni.GP[FromPort].PLinkSpeedUsed;
5253
			Stat = pAC->GIni.GP[FromPort].PLinkSpeedUsed;
4258
		if (Stat == SK_LSPEED_STAT_10MBPS) {
5254
			if (Stat == SK_LSPEED_STAT_10MBPS) {
4259
			printk("    speed:           10\n");
5255
				printk("    speed:           10\n");
4260
		} else if (Stat == SK_LSPEED_STAT_100MBPS) {
5256
			} else if (Stat == SK_LSPEED_STAT_100MBPS) {
4261
			printk("    speed:           100\n");
5257
				printk("    speed:           100\n");
4262
		} else if (Stat == SK_LSPEED_STAT_1000MBPS) {
5258
			} else if (Stat == SK_LSPEED_STAT_1000MBPS) {
4263
			printk("    speed:           1000\n");
5259
				printk("    speed:           1000\n");
4264
		} else {
5260
			} else {
4265
			printk("    speed:           unknown\n");
5261
				printk("    speed:           unknown\n");
4266
		}
5262
			}
4267
5263
5264
			Stat = pAC->GIni.GP[FromPort].PLinkModeStatus;
5265
			if ((Stat == SK_LMODE_STAT_AUTOHALF) ||
5266
			    (Stat == SK_LMODE_STAT_AUTOFULL)) {
5267
				printk("    autonegotiation: yes\n");
5268
			} else {
5269
				printk("    autonegotiation: no\n");
5270
			}
4268
5271
4269
		Stat = pAC->GIni.GP[FromPort].PLinkModeStatus;
5272
			if ((Stat == SK_LMODE_STAT_AUTOHALF) ||
4270
		if (Stat == SK_LMODE_STAT_AUTOHALF ||
5273
			    (Stat == SK_LMODE_STAT_HALF)) {
4271
			Stat == SK_LMODE_STAT_AUTOFULL) {
5274
				printk("    duplex mode:     half\n");
4272
			printk("    autonegotiation: yes\n");
5275
			} else {
4273
		}
5276
				printk("    duplex mode:     full\n");
4274
		else {
4275
			printk("    autonegotiation: no\n");
4276
		}
4277
		if (Stat == SK_LMODE_STAT_AUTOHALF ||
4278
			Stat == SK_LMODE_STAT_HALF) {
4279
			printk("    duplex mode:     half\n");
4280
		}
4281
		else {
4282
			printk("    duplex mode:     full\n");
4283
		}
4284
		Stat = pAC->GIni.GP[FromPort].PFlowCtrlStatus;
4285
		if (Stat == SK_FLOW_STAT_REM_SEND ) {
4286
			printk("    flowctrl:        remote send\n");
4287
		}
4288
		else if (Stat == SK_FLOW_STAT_LOC_SEND ){
4289
			printk("    flowctrl:        local send\n");
4290
		}
4291
		else if (Stat == SK_FLOW_STAT_SYMMETRIC ){
4292
			printk("    flowctrl:        symmetric\n");
4293
		}
4294
		else {
4295
			printk("    flowctrl:        none\n");
4296
		}
4297
		
4298
		/* tschilling: Check against CopperType now. */
4299
		if ((pAC->GIni.GICopperType == SK_TRUE) &&
4300
			(pAC->GIni.GP[FromPort].PLinkSpeedUsed ==
4301
			SK_LSPEED_STAT_1000MBPS)) {
4302
			Stat = pAC->GIni.GP[FromPort].PMSStatus;
4303
			if (Stat == SK_MS_STAT_MASTER ) {
4304
				printk("    role:            master\n");
4305
			}
5277
			}
4306
			else if (Stat == SK_MS_STAT_SLAVE ) {
5278
4307
				printk("    role:            slave\n");
5279
			Stat = pAC->GIni.GP[FromPort].PFlowCtrlStatus;
5280
			if (Stat == SK_FLOW_STAT_REM_SEND ) {
5281
				printk("    flowctrl:        remote send\n");
5282
			} else if (Stat == SK_FLOW_STAT_LOC_SEND ) {
5283
				printk("    flowctrl:        local send\n");
5284
			} else if (Stat == SK_FLOW_STAT_SYMMETRIC ) {
5285
				printk("    flowctrl:        symmetric\n");
5286
			} else {
5287
				printk("    flowctrl:        none\n");
4308
			}
5288
			}
4309
			else {
5289
		
4310
				printk("    role:            ???\n");
5290
			/* tschilling: Check against CopperType now. */
5291
			if ((pAC->GIni.GICopperType == SK_TRUE) &&
5292
				(pAC->GIni.GP[FromPort].PLinkSpeedUsed ==
5293
				SK_LSPEED_STAT_1000MBPS)) {
5294
				Stat = pAC->GIni.GP[FromPort].PMSStatus;
5295
				if (Stat == SK_MS_STAT_MASTER ) {
5296
					printk("    role:            master\n");
5297
				} else if (Stat == SK_MS_STAT_SLAVE ) {
5298
					printk("    role:            slave\n");
5299
				} else {
5300
					printk("    role:            ???\n");
5301
				}
4311
			}
5302
			}
4312
		}
4313
5303
4314
		/* 
5304
			/* Display interrupt moderation informations */
4315
		   Display dim (dynamic interrupt moderation) 
5305
			if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_STATIC) {
4316
		   informations
5306
				printk("    irq moderation:  static (%d ints/sec)\n",
4317
		 */
4318
		if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_STATIC)
4319
			printk("    irq moderation:  static (%d ints/sec)\n",
4320
					pAC->DynIrqModInfo.MaxModIntsPerSec);
5307
					pAC->DynIrqModInfo.MaxModIntsPerSec);
4321
		else if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_DYNAMIC)
5308
			} else if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_DYNAMIC) {
4322
			printk("    irq moderation:  dynamic (%d ints/sec)\n",
5309
				printk("    irq moderation:  dynamic (%d ints/sec)\n",
4323
					pAC->DynIrqModInfo.MaxModIntsPerSec);
5310
					pAC->DynIrqModInfo.MaxModIntsPerSec);
4324
		else
5311
			} else {
4325
			printk("    irq moderation:  disabled\n");
5312
				printk("    irq moderation:  disabled\n");
5313
			}
5314
	
5315
#ifdef NETIF_F_TSO
5316
			if (CHIP_ID_YUKON_2(pAC)) {
5317
				if (pAC->dev[FromPort]->features & NETIF_F_TSO) {
5318
					printk("    tcp offload:     enabled\n");
5319
				} else {
5320
					printk("    tcp offload:     disabled\n");
5321
				}
5322
			}
5323
#endif
4326
5324
5325
			if (pAC->dev[FromPort]->features & NETIF_F_SG) {
5326
				printk("    scatter-gather:  enabled\n");
5327
			} else {
5328
				printk("    scatter-gather:  disabled\n");
5329
			}
4327
5330
4328
#ifdef SK_ZEROCOPY
5331
			if (pAC->dev[FromPort]->features & NETIF_F_IP_CSUM) {
4329
		if (pAC->ChipsetType)
5332
				printk("    tx-checksum:     enabled\n");
4330
#ifdef USE_SK_TX_CHECKSUM
5333
			} else {
4331
			printk("    scatter-gather:  enabled\n");
5334
				printk("    tx-checksum:     disabled\n");
4332
#else
5335
			}
4333
			printk("    tx-checksum:     disabled\n");
4334
#endif
4335
		else
4336
			printk("    scatter-gather:  disabled\n");
4337
#else
4338
			printk("    scatter-gather:  disabled\n");
4339
#endif
4340
5336
4341
#ifndef USE_SK_RX_CHECKSUM
5337
			if (pAC->RxPort[FromPort].UseRxCsum) {
4342
			printk("    rx-checksum:     disabled\n");
5338
				printk("    rx-checksum:     enabled\n");
5339
			} else {
5340
				printk("    rx-checksum:     disabled\n");
5341
			}
5342
#ifdef CONFIG_SK98LIN_NAPI
5343
			printk("    rx-polling:      enabled\n");
4343
#endif
5344
#endif
4344
5345
			if (pAC->LowLatency) {
5346
				printk("    low latency:     enabled\n");
5347
			}
4345
		} else {
5348
		} else {
4346
                        DoPrintInterfaceChange = SK_TRUE;
5349
			DoPrintInterfaceChange = SK_TRUE;
4347
                }
5350
		}
4348
	
5351
	
4349
		if ((Param.Para32[0] != pAC->ActivePort) &&
5352
		if ((FromPort != pAC->ActivePort)&&(pAC->RlmtNets == 1)) {
4350
			(pAC->RlmtNets == 1)) {
5353
			SkLocalEventQueue(pAC, SKGE_DRV, SK_DRV_SWITCH_INTERN,
4351
			NewPara.Para32[0] = pAC->ActivePort;
5354
						pAC->ActivePort, FromPort, SK_FALSE);
4352
			NewPara.Para32[1] = Param.Para32[0];
4353
			SkEventQueue(pAC, SKGE_DRV, SK_DRV_SWITCH_INTERN,
4354
				NewPara);
4355
		}
5355
		}
4356
5356
4357
		/* Inform the world that link protocol is up. */
5357
		/* Inform the world that link protocol is up. */
4358
		pAC->dev[Param.Para32[0]]->flags |= IFF_RUNNING;
5358
		netif_wake_queue(pAC->dev[FromPort]);
4359
5359
		netif_carrier_on(pAC->dev[FromPort]);
5360
		pAC->dev[FromPort]->flags |= IFF_RUNNING;
4360
		break;
5361
		break;
4361
	case SK_DRV_NET_DOWN:	 /* SK_U32 Reason */
5362
	case SK_DRV_NET_DOWN:	
4362
		/* action list 7 */
5363
		Reason   = Param.Para32[0];
5364
		FromPort = Param.Para32[1];
4363
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5365
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4364
			("NET DOWN EVENT "));
5366
			("NET DOWN EVENT "));
5367
5368
		/* Stop queue and carrier */
5369
		netif_stop_queue(pAC->dev[FromPort]);
5370
		netif_carrier_off(pAC->dev[FromPort]);
5371
5372
		/* Print link change */
4365
		if (DoPrintInterfaceChange) {
5373
		if (DoPrintInterfaceChange) {
4366
			printk("%s: network connection down\n", 
5374
			if (pAC->dev[FromPort]->flags & IFF_RUNNING) {
4367
				pAC->dev[Param.Para32[1]]->name);
5375
				printk("%s: network connection down\n", 
5376
					pAC->dev[FromPort]->name);
5377
			}
4368
		} else {
5378
		} else {
4369
			DoPrintInterfaceChange = SK_TRUE;
5379
			DoPrintInterfaceChange = SK_TRUE;
4370
		}
5380
		}
4371
		pAC->dev[Param.Para32[1]]->flags &= ~IFF_RUNNING;
5381
		pAC->dev[FromPort]->flags &= ~IFF_RUNNING;
4372
		break;
5382
		break;
4373
	case SK_DRV_SWITCH_HARD: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
5383
	case SK_DRV_SWITCH_HARD:   /* FALL THRU */
4374
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5384
	case SK_DRV_SWITCH_SOFT:   /* FALL THRU */
4375
			("PORT SWITCH HARD "));
5385
	case SK_DRV_SWITCH_INTERN: 
4376
	case SK_DRV_SWITCH_SOFT: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4377
	/* action list 6 */
4378
		printk("%s: switching to port %c\n", pAC->dev[0]->name,
4379
			'A'+Param.Para32[1]);
4380
	case SK_DRV_SWITCH_INTERN: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4381
		FromPort = Param.Para32[0];
5386
		FromPort = Param.Para32[0];
4382
		ToPort = Param.Para32[1];
5387
		ToPort   = Param.Para32[1];
5388
		printk("%s: switching from port %c to port %c\n",
5389
			pAC->dev[0]->name, 'A'+FromPort, 'A'+ToPort);
4383
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5390
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4384
			("PORT SWITCH EVENT, From: %d  To: %d (Pref %d) ",
5391
			("PORT SWITCH EVENT, From: %d  To: %d (Pref %d) ",
4385
			FromPort, ToPort, pAC->Rlmt.Net[0].PrefPort));
5392
			FromPort, ToPort, pAC->Rlmt.Net[0].PrefPort));
4386
		NewPara.Para64 = FromPort;
5393
		SkLocalEventQueue64(pAC, SKGE_PNMI, SK_PNMI_EVT_XMAC_RESET,
4387
		SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_XMAC_RESET, NewPara);
5394
					FromPort, SK_FALSE);
4388
		NewPara.Para64 = ToPort;
5395
		SkLocalEventQueue64(pAC, SKGE_PNMI, SK_PNMI_EVT_XMAC_RESET,
4389
		SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_XMAC_RESET, NewPara);
5396
					ToPort, SK_FALSE);
4390
		spin_lock_irqsave(
5397
		spin_lock_irqsave(
4391
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5398
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4392
			Flags);
5399
			Flags);
4393
		spin_lock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock);
5400
		spin_lock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock);
4394
		SkGeStopPort(pAC, IoC, FromPort, SK_STOP_ALL, SK_SOFT_RST);
5401
		if (CHIP_ID_YUKON_2(pAC)) {
4395
		SkGeStopPort(pAC, IoC, ToPort, SK_STOP_ALL, SK_SOFT_RST);
5402
			SkY2PortStop(pAC, IoC, FromPort, SK_STOP_ALL, SK_SOFT_RST);
5403
			SkY2PortStop(pAC, IoC, ToPort, SK_STOP_ALL, SK_SOFT_RST);
5404
		}
5405
		else {
5406
			SkGeStopPort(pAC, IoC, FromPort, SK_STOP_ALL, SK_SOFT_RST);
5407
			SkGeStopPort(pAC, IoC, ToPort, SK_STOP_ALL, SK_SOFT_RST);
5408
		}
4396
		spin_unlock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock);
5409
		spin_unlock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock);
4397
		spin_unlock_irqrestore(
5410
		spin_unlock_irqrestore(
4398
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5411
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4399
			Flags);
5412
			Flags);
4400
5413
4401
		ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE); /* clears rx ring */
4402
		ReceiveIrq(pAC, &pAC->RxPort[ToPort], SK_FALSE); /* clears rx ring */
4403
		
5414
		
4404
		ClearTxRing(pAC, &pAC->TxPort[FromPort][TX_PRIO_LOW]);
5415
		if (!CHIP_ID_YUKON_2(pAC)) {
4405
		ClearTxRing(pAC, &pAC->TxPort[ToPort][TX_PRIO_LOW]);
5416
#ifdef CONFIG_SK98LIN_NAPI
5417
			WorkToDo = 1;
5418
			ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE, &WorkDone, WorkToDo);
5419
			ReceiveIrq(pAC, &pAC->RxPort[ToPort], SK_FALSE, &WorkDone, WorkToDo);
5420
#else
5421
			ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE); /* clears rx ring */
5422
			ReceiveIrq(pAC, &pAC->RxPort[ToPort], SK_FALSE); /* clears rx ring */
5423
#endif
5424
			ClearTxRing(pAC, &pAC->TxPort[FromPort][TX_PRIO_LOW]);
5425
			ClearTxRing(pAC, &pAC->TxPort[ToPort][TX_PRIO_LOW]);
5426
		} 
5427
4406
		spin_lock_irqsave(
5428
		spin_lock_irqsave(
4407
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5429
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4408
			Flags);
5430
			Flags);
Lines 4429-4503 Link Here
4429
			break;
5451
			break;
4430
		}
5452
		}
4431
#endif
5453
#endif
4432
		/* tschilling: Handling of return values inserted. */
5454
		if (!CHIP_ID_YUKON_2(pAC)) {
4433
		if (SkGeInitPort(pAC, IoC, FromPort) ||
5455
			/* tschilling: Handling of return values inserted. */
4434
			SkGeInitPort(pAC, IoC, ToPort)) {
5456
			if (SkGeInitPort(pAC, IoC, FromPort) ||
4435
			printk("%s: SkGeInitPort failed.\n", pAC->dev[0]->name);
5457
				SkGeInitPort(pAC, IoC, ToPort)) {
5458
				printk("%s: SkGeInitPort failed.\n", pAC->dev[0]->name);
5459
			}
4436
		}
5460
		}
4437
		if (Event == SK_DRV_SWITCH_SOFT) {
5461
		if (!CHIP_ID_YUKON_2(pAC)) {
4438
			SkMacRxTxEnable(pAC, IoC, FromPort);
5462
			if (Event == SK_DRV_SWITCH_SOFT) {
5463
				SkMacRxTxEnable(pAC, IoC, FromPort);
5464
			}
5465
			SkMacRxTxEnable(pAC, IoC, ToPort);
4439
		}
5466
		}
4440
		SkMacRxTxEnable(pAC, IoC, ToPort);
5467
4441
		SkAddrSwap(pAC, IoC, FromPort, ToPort);
5468
		SkAddrSwap(pAC, IoC, FromPort, ToPort);
4442
		SkAddrMcUpdate(pAC, IoC, FromPort);
5469
		SkAddrMcUpdate(pAC, IoC, FromPort);
4443
		SkAddrMcUpdate(pAC, IoC, ToPort);
5470
		SkAddrMcUpdate(pAC, IoC, ToPort);
4444
		PortReInitBmu(pAC, FromPort);
5471
4445
		PortReInitBmu(pAC, ToPort);
5472
#ifdef USE_TIST_FOR_RESET
4446
		SkGePollTxD(pAC, IoC, FromPort, SK_TRUE);
5473
                if (pAC->GIni.GIYukon2) {
4447
		SkGePollTxD(pAC, IoC, ToPort, SK_TRUE);
5474
			/* make sure that we do not accept any status LEs from now on */
4448
		ClearAndStartRx(pAC, FromPort);
5475
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
4449
		ClearAndStartRx(pAC, ToPort);
5476
				("both Ports now waiting for specific Tist\n"));
5477
			SK_SET_WAIT_BIT_FOR_PORT(
5478
				pAC,
5479
				SK_PSTATE_WAITING_FOR_ANY_TIST,
5480
				0);
5481
			SK_SET_WAIT_BIT_FOR_PORT(
5482
				pAC,
5483
				SK_PSTATE_WAITING_FOR_ANY_TIST,
5484
				1);
5485
5486
			/* start tist */
5487
			Y2_ENABLE_TIST(pAC->IoBase);
5488
		}
5489
#endif
5490
		if (!CHIP_ID_YUKON_2(pAC)) {
5491
			PortReInitBmu(pAC, FromPort);
5492
			PortReInitBmu(pAC, ToPort);
5493
			SkGePollTxD(pAC, IoC, FromPort, SK_TRUE);
5494
			SkGePollTxD(pAC, IoC, ToPort, SK_TRUE);
5495
			CLEAR_AND_START_RX(FromPort);
5496
			CLEAR_AND_START_RX(ToPort);
5497
		} else {
5498
			SkY2PortStart(pAC, IoC, FromPort);
5499
			SkY2PortStart(pAC, IoC, ToPort);
5500
#ifdef SK_YUKON2
5501
			/* in yukon-II always port 0 has to be started first */
5502
			// SkY2PortStart(pAC, IoC, 0);
5503
			// SkY2PortStart(pAC, IoC, 1);
5504
#endif
5505
		}
4450
		spin_unlock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock);
5506
		spin_unlock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock);
4451
		spin_unlock_irqrestore(
5507
		spin_unlock_irqrestore(
4452
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5508
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4453
			Flags);
5509
			Flags);
4454
		break;
5510
		break;
4455
	case SK_DRV_RLMT_SEND:	 /* SK_MBUF *pMb */
5511
	case SK_DRV_RLMT_SEND:	 /* SK_MBUF *pMb */
4456
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5512
		SK_DBG_MSG(NULL,SK_DBGMOD_DRV,SK_DBGCAT_DRV_EVENT,("RLS "));
4457
			("RLS "));
5513
		pRlmtMbuf = (SK_MBUF*) Param.pParaPtr;
4458
		pRlmtMbuf = (SK_MBUF*) Param.pParaPtr;
5514
		pMsg = (struct sk_buff*) pRlmtMbuf->pOs;
4459
		pMsg = (struct sk_buff*) pRlmtMbuf->pOs;
5515
		skb_put(pMsg, pRlmtMbuf->Length);
4460
		skb_put(pMsg, pRlmtMbuf->Length);
5516
		if (!CHIP_ID_YUKON_2(pAC)) {
4461
		if (XmitFrame(pAC, &pAC->TxPort[pRlmtMbuf->PortIdx][TX_PRIO_LOW],
5517
			if (XmitFrame(pAC, &pAC->TxPort[pRlmtMbuf->PortIdx][TX_PRIO_LOW],
4462
			pMsg) < 0)
5518
				pMsg) < 0) {
5519
				DEV_KFREE_SKB_ANY(pMsg);
5520
			}
5521
		} else {
5522
			if (SkY2RlmtSend(pAC, pRlmtMbuf->PortIdx, pMsg) < 0) {
5523
				DEV_KFREE_SKB_ANY(pMsg);
5524
			}
5525
		}
5526
		break;
5527
	case SK_DRV_TIMER:
5528
		if (Param.Para32[0] == SK_DRV_MODERATION_TIMER) {
5529
			/* check what IRQs are to be moderated */
5530
			SkDimStartModerationTimer(pAC);
5531
			SkDimModerate(pAC);
5532
		} else {
5533
			printk("Expiration of unknown timer\n");
5534
		}
5535
		break;
5536
	case SK_DRV_ADAP_FAIL:
5537
#if (!defined (Y2_RECOVERY) && !defined (Y2_LE_CHECK))
5538
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5539
			("ADAPTER FAIL EVENT\n"));
5540
		printk("%s: Adapter failed.\n", pAC->dev[0]->name);
5541
		SK_OUT32(pAC->IoBase, B0_IMSK, 0); /* disable interrupts */
5542
		break;
5543
#endif
5544
5545
#if (defined (Y2_RECOVERY) || defined (Y2_LE_CHECK))
5546
	case SK_DRV_RECOVER:
5547
		pNet = (DEV_NET *) pAC->dev[0]->priv;
5548
5549
		/* Recover already in progress */
5550
		if (pNet->InRecover) {
5551
			break;
5552
		}
5553
5554
		netif_stop_queue(pAC->dev[0]); /* stop device if running */
5555
		pNet->InRecover = SK_TRUE;
5556
5557
		FromPort = Param.Para32[0];
5558
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5559
			("PORT RESET EVENT, Port: %d ", FromPort));
5560
5561
		/* Disable interrupts */
5562
		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
5563
		SK_OUT32(pAC->IoBase, B0_HWE_IMSK, 0);
5564
5565
		SkLocalEventQueue64(pAC, SKGE_PNMI, SK_PNMI_EVT_XMAC_RESET,
5566
					FromPort, SK_FALSE);
5567
		spin_lock_irqsave(
5568
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5569
			Flags);
5570
		if (CHIP_ID_YUKON_2(pAC)) {
5571
			if (pAC->GIni.GIMacsFound > 1) {
5572
				SkY2PortStop(pAC, IoC, 0, SK_STOP_ALL, SK_SOFT_RST);
5573
				SkY2PortStop(pAC, IoC, 1, SK_STOP_ALL, SK_SOFT_RST);
5574
			} else {
5575
				SkY2PortStop(pAC, IoC, FromPort, SK_STOP_ALL, SK_SOFT_RST);
5576
			}
5577
		} else {
5578
			SkGeStopPort(pAC, IoC, FromPort, SK_STOP_ALL, SK_SOFT_RST);
5579
		}
5580
		pAC->dev[Param.Para32[0]]->flags &= ~IFF_RUNNING;
5581
		spin_unlock_irqrestore(
5582
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5583
			Flags);
5584
		
5585
		if (!CHIP_ID_YUKON_2(pAC)) {
5586
#ifdef CONFIG_SK98LIN_NAPI
5587
			WorkToDo = 1;
5588
			ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE, &WorkDone, WorkToDo);
5589
#else
5590
			ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE);
5591
#endif
5592
			ClearTxRing(pAC, &pAC->TxPort[FromPort][TX_PRIO_LOW]);
5593
		}
5594
		spin_lock_irqsave(
5595
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5596
			Flags);
5597
5598
#ifdef USE_TIST_FOR_RESET
5599
		if (pAC->GIni.GIYukon2) {
5600
#if 0
5601
			/* make sure that we do not accept any status LEs from now on */
5602
			Y2_ENABLE_TIST(pAC->IoBase);
5603
5604
			/* get current timestamp */
5605
			Y2_GET_TIST_LOW_VAL(pAC->IoBase, &pAC->MinTistLo);
5606
			pAC->MinTistHi = pAC->GIni.GITimeStampCnt;
5607
5608
			SK_SET_WAIT_BIT_FOR_PORT(
5609
				pAC,
5610
				SK_PSTATE_WAITING_FOR_SPECIFIC_TIST,
5611
				FromPort);
5612
#endif
5613
			if (pAC->GIni.GIMacsFound > 1) {
5614
				SK_SET_WAIT_BIT_FOR_PORT(
5615
					pAC,
5616
					SK_PSTATE_WAITING_FOR_ANY_TIST,
5617
					0);
5618
				SK_SET_WAIT_BIT_FOR_PORT(
5619
					pAC,
5620
					SK_PSTATE_WAITING_FOR_ANY_TIST,
5621
					1);
5622
			} else {
5623
				SK_SET_WAIT_BIT_FOR_PORT(
5624
					pAC,
5625
					SK_PSTATE_WAITING_FOR_ANY_TIST,
5626
					FromPort);
5627
			}
5628
5629
			/* start tist */
5630
                        Y2_ENABLE_TIST(pAC->IoBase);
5631
		}
5632
#endif
5633
5634
5635
5636
#ifdef Y2_LE_CHECK
5637
		/* mark entries invalid */
5638
		pAC->LastPort = 3;
5639
		pAC->LastOpc = 0xFF;
5640
#endif
5641
5642
#endif
5643
		/* Restart ports but do not initialize PHY. */
5644
		if (CHIP_ID_YUKON_2(pAC)) {
5645
			if (pAC->GIni.GIMacsFound > 1) {
5646
				SkY2PortStart(pAC, IoC, 0);
5647
				SkY2PortStart(pAC, IoC, 1);
5648
			} else {
5649
				SkY2PortStart(pAC, IoC, FromPort);
5650
			}
5651
		} else {
5652
			/* tschilling: Handling of return value inserted. */
5653
			if (SkGeInitPort(pAC, IoC, FromPort)) {
5654
				if (FromPort == 0) {
5655
					printk("%s: SkGeInitPort A failed.\n", pAC->dev[0]->name);
5656
				} else {
5657
					printk("%s: SkGeInitPort B failed.\n", pAC->dev[1]->name);
5658
				}
5659
			}
5660
			SkAddrMcUpdate(pAC,IoC, FromPort);
5661
			PortReInitBmu(pAC, FromPort);
5662
			SkGePollTxD(pAC, IoC, FromPort, SK_TRUE);
5663
			CLEAR_AND_START_RX(FromPort);
5664
		}
5665
		spin_unlock_irqrestore(
5666
			&pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
5667
			Flags);
4463
5668
4464
			DEV_KFREE_SKB_ANY(pMsg);
5669
#if 0
4465
		break;
5670
		/* restart the kernel timer */
4466
	case SK_DRV_TIMER:
5671
		pNet = (DEV_NET *) pAC->dev[FromPort]->priv;
4467
		if (Param.Para32[0] == SK_DRV_MODERATION_TIMER) {
5672
		if (!timer_pending(&pNet->KernelTimer)) {
4468
			/*
5673
			pNet->KernelTimer.expires =
4469
			** expiration of the moderation timer implies that
5674
				jiffies + (HZ/4);	/* 250ms */
4470
			** dynamic moderation is to be applied
5675
			add_timer(&pNet->KernelTimer);
4471
			*/
4472
			SkDimStartModerationTimer(pAC);
4473
			SkDimModerate(pAC);
4474
                        if (pAC->DynIrqModInfo.DisplayStats) {
4475
			    SkDimDisplayModerationSettings(pAC);
4476
                        }
4477
                } else if (Param.Para32[0] == SK_DRV_RX_CLEANUP_TIMER) {
4478
			/*
4479
			** check if we need to check for descriptors which
4480
			** haven't been handled the last millisecs
4481
			*/
4482
			StartDrvCleanupTimer(pAC);
4483
			if (pAC->GIni.GIMacsFound == 2) {
4484
				ReceiveIrq(pAC, &pAC->RxPort[1], SK_FALSE);
4485
			}
4486
			ReceiveIrq(pAC, &pAC->RxPort[0], SK_FALSE);
4487
		} else {
4488
			printk("Expiration of unknown timer\n");
4489
		}
5676
		}
5677
#endif
5678
		pNet->InRecover = SK_FALSE;
5679
		/* enable Interrupts */
5680
		SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
5681
		SK_OUT32(pAC->IoBase, B0_HWE_IMSK, IRQ_HWE_MASK);
5682
		netif_wake_queue(pAC->dev[0]);
4490
		break;
5683
		break;
4491
	default:
5684
	default:
4492
		break;
5685
		break;
4493
	}
5686
	}
4494
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
5687
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4495
		("END EVENT "));
5688
		("END EVENT "));
4496
	
5689
4497
	return (0);
5690
	return (0);
4498
} /* SkDrvEvent */
5691
} /* SkDrvEvent */
4499
5692
4500
5693
5694
/******************************************************************************
5695
 *
5696
 *	SkLocalEventQueue()	-	add event to queue
5697
 *
5698
 * Description:
5699
 *	This function adds an event to the event queue and run the
5700
 *	SkEventDispatcher. At least Init Level 1 is required to queue events,
5701
 *	but will be scheduled add Init Level 2.
5702
 *
5703
 * returns:
5704
 *	nothing
5705
 */
5706
void SkLocalEventQueue(
5707
SK_AC *pAC,		/* Adapters context */
5708
SK_U32 Class,		/* Event Class */
5709
SK_U32 Event,		/* Event to be queued */
5710
SK_U32 Param1,		/* Event parameter 1 */
5711
SK_U32 Param2,		/* Event parameter 2 */
5712
SK_BOOL Dispatcher)	/* Dispatcher flag:
5713
			 *	TRUE == Call SkEventDispatcher
5714
			 *	FALSE == Don't execute SkEventDispatcher
5715
			 */
5716
{
5717
	SK_EVPARA 	EvPara;
5718
	EvPara.Para32[0] = Param1;
5719
	EvPara.Para32[1] = Param2;
5720
	
5721
5722
	if (Class == SKGE_PNMI) {
5723
		SkPnmiEvent(	pAC,
5724
				pAC->IoBase,
5725
				Event,
5726
				EvPara);
5727
	} else {
5728
		SkEventQueue(	pAC,
5729
				Class,
5730
				Event,
5731
				EvPara);
5732
	}
5733
5734
	/* Run the dispatcher */
5735
	if (Dispatcher) {
5736
		SkEventDispatcher(pAC, pAC->IoBase);
5737
	}
5738
5739
}
5740
5741
/******************************************************************************
5742
 *
5743
 *	SkLocalEventQueue64()	-	add event to queue (64bit version)
5744
 *
5745
 * Description:
5746
 *	This function adds an event to the event queue and run the
5747
 *	SkEventDispatcher. At least Init Level 1 is required to queue events,
5748
 *	but will be scheduled add Init Level 2.
5749
 *
5750
 * returns:
5751
 *	nothing
5752
 */
5753
void SkLocalEventQueue64(
5754
SK_AC *pAC,		/* Adapters context */
5755
SK_U32 Class,		/* Event Class */
5756
SK_U32 Event,		/* Event to be queued */
5757
SK_U64 Param,		/* Event parameter */
5758
SK_BOOL Dispatcher)	/* Dispatcher flag:
5759
			 *	TRUE == Call SkEventDispatcher
5760
			 *	FALSE == Don't execute SkEventDispatcher
5761
			 */
5762
{
5763
	SK_EVPARA 	EvPara;
5764
	EvPara.Para64 = Param;
5765
5766
5767
	if (Class == SKGE_PNMI) {
5768
		SkPnmiEvent(	pAC,
5769
				pAC->IoBase,
5770
				Event,
5771
				EvPara);
5772
	} else {
5773
		SkEventQueue(	pAC,
5774
				Class,
5775
				Event,
5776
				EvPara);
5777
	}
5778
5779
	/* Run the dispatcher */
5780
	if (Dispatcher) {
5781
		SkEventDispatcher(pAC, pAC->IoBase);
5782
	}
5783
5784
}
5785
5786
4501
/*****************************************************************************
5787
/*****************************************************************************
4502
 *
5788
 *
4503
 *	SkErrorLog - log errors
5789
 *	SkErrorLog - log errors
Lines 4547-4554 Link Here
4547
5833
4548
} /* SkErrorLog */
5834
} /* SkErrorLog */
4549
5835
4550
#ifdef SK_DIAG_SUPPORT
4551
4552
/*****************************************************************************
5836
/*****************************************************************************
4553
 *
5837
 *
4554
 *	SkDrvEnterDiagMode - handles DIAG attach request
5838
 *	SkDrvEnterDiagMode - handles DIAG attach request
Lines 4563-4577 Link Here
4563
int SkDrvEnterDiagMode(
5847
int SkDrvEnterDiagMode(
4564
SK_AC   *pAc)   /* pointer to adapter context */
5848
SK_AC   *pAc)   /* pointer to adapter context */
4565
{
5849
{
4566
	DEV_NET *pNet = netdev_priv(pAc->dev[0]);
5850
	SK_AC   *pAC  = NULL;
4567
	SK_AC   *pAC  = pNet->pAC;
5851
	DEV_NET *pNet = NULL;
5852
5853
	pNet = (DEV_NET *) pAc->dev[0]->priv;
5854
	pAC = pNet->pAC;
4568
5855
4569
	SK_MEMCPY(&(pAc->PnmiBackup), &(pAc->PnmiStruct), 
5856
	SK_MEMCPY(&(pAc->PnmiBackup), &(pAc->PnmiStruct), 
4570
			sizeof(SK_PNMI_STRUCT_DATA));
5857
			sizeof(SK_PNMI_STRUCT_DATA));
4571
5858
4572
	pAC->DiagModeActive = DIAG_ACTIVE;
5859
	pAC->DiagModeActive = DIAG_ACTIVE;
4573
	if (pAC->BoardLevel > SK_INIT_DATA) {
5860
	if (pAC->BoardLevel > SK_INIT_DATA) {
4574
		if (pNet->Up) {
5861
		if (netif_running(pAC->dev[0])) {
4575
			pAC->WasIfUp[0] = SK_TRUE;
5862
			pAC->WasIfUp[0] = SK_TRUE;
4576
			pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose      */
5863
			pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose      */
4577
			DoPrintInterfaceChange = SK_FALSE;
5864
			DoPrintInterfaceChange = SK_FALSE;
Lines 4579-4587 Link Here
4579
		} else {
5866
		} else {
4580
			pAC->WasIfUp[0] = SK_FALSE;
5867
			pAC->WasIfUp[0] = SK_FALSE;
4581
		}
5868
		}
4582
		if (pNet != netdev_priv(pAC->dev[1])) {
5869
4583
			pNet = netdev_priv(pAC->dev[1]);
5870
		if (pNet != (DEV_NET *) pAc->dev[1]->priv) {
4584
			if (pNet->Up) {
5871
			pNet = (DEV_NET *) pAc->dev[1]->priv;
5872
			if (netif_running(pAC->dev[1])) {
4585
				pAC->WasIfUp[1] = SK_TRUE;
5873
				pAC->WasIfUp[1] = SK_TRUE;
4586
				pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
5874
				pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
4587
				DoPrintInterfaceChange = SK_FALSE;
5875
				DoPrintInterfaceChange = SK_FALSE;
Lines 4613-4628 Link Here
4613
			sizeof(SK_PNMI_STRUCT_DATA));
5901
			sizeof(SK_PNMI_STRUCT_DATA));
4614
	pAc->DiagModeActive    = DIAG_NOTACTIVE;
5902
	pAc->DiagModeActive    = DIAG_NOTACTIVE;
4615
	pAc->Pnmi.DiagAttached = SK_DIAG_IDLE;
5903
	pAc->Pnmi.DiagAttached = SK_DIAG_IDLE;
4616
        if (pAc->WasIfUp[0] == SK_TRUE) {
5904
	if (pAc->WasIfUp[0] == SK_TRUE) {
4617
                pAc->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
5905
		pAc->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
4618
		DoPrintInterfaceChange = SK_FALSE;
5906
		DoPrintInterfaceChange = SK_FALSE;
4619
                SkDrvInitAdapter(pAc, 0);    /* first device  */
5907
		SkDrvInitAdapter(pAc, 0);    /* first device  */
4620
        }
5908
	}
4621
        if (pAc->WasIfUp[1] == SK_TRUE) {
5909
	if (pAc->WasIfUp[1] == SK_TRUE) {
4622
                pAc->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
5910
		pAc->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
4623
		DoPrintInterfaceChange = SK_FALSE;
5911
		DoPrintInterfaceChange = SK_FALSE;
4624
                SkDrvInitAdapter(pAc, 1);    /* second device */
5912
		SkDrvInitAdapter(pAc, 1);    /* second device */
4625
        }
5913
	}
4626
	return(0);
5914
	return(0);
4627
}
5915
}
4628
5916
Lines 4702-4712 Link Here
4702
5990
4703
	dev = pAC->dev[devNbr];
5991
	dev = pAC->dev[devNbr];
4704
5992
4705
	/* On Linux 2.6 the network driver does NOT mess with reference
5993
	/*
4706
	** counts.  The driver MUST be able to be unloaded at any time
5994
	** Function SkGeClose() uses MOD_DEC_USE_COUNT (2.2/2.4)
4707
	** due to the possibility of hotplug.
5995
	** or module_put() (2.6) to decrease the number of users for
5996
	** a device, but if a device is to be put under control of 
5997
	** the DIAG, that count is OK already and does not need to 
5998
	** be adapted! Hence the opposite MOD_INC_USE_COUNT or 
5999
	** try_module_get() needs to be used again to correct that.
4708
	*/
6000
	*/
6001
	if (!try_module_get(THIS_MODULE)) {
6002
		return (-1);
6003
	}
6004
4709
	if (SkGeClose(dev) != 0) {
6005
	if (SkGeClose(dev) != 0) {
6006
		module_put(THIS_MODULE);
4710
		return (-1);
6007
		return (-1);
4711
	}
6008
	}
4712
	return (0);
6009
	return (0);
Lines 4735-4740 Link Here
4735
6032
4736
	if (SkGeOpen(dev) != 0) {
6033
	if (SkGeOpen(dev) != 0) {
4737
		return (-1);
6034
		return (-1);
6035
	} else {
6036
		/*
6037
		** Function SkGeOpen() uses MOD_INC_USE_COUNT (2.2/2.4) 
6038
		** or try_module_get() (2.6) to increase the number of 
6039
		** users for a device, but if a device was just under 
6040
		** control of the DIAG, that count is OK already and 
6041
		** does not need to be adapted! Hence the opposite 
6042
		** MOD_DEC_USE_COUNT or module_put() needs to be used 
6043
		** again to correct that.
6044
		*/
6045
		module_put(THIS_MODULE);
4738
	}
6046
	}
4739
6047
4740
	/*
6048
	/*
Lines 4747-4760 Link Here
4747
6055
4748
} /* SkDrvInitAdapter */
6056
} /* SkDrvInitAdapter */
4749
6057
4750
#endif
6058
static int __init sk98lin_init(void)
6059
{
6060
	return pci_module_init(&sk98lin_driver);
6061
}
6062
6063
static void __exit sk98lin_cleanup(void)
6064
{
6065
	pci_unregister_driver(&sk98lin_driver);
6066
}
6067
6068
module_init(sk98lin_init);
6069
module_exit(sk98lin_cleanup);
6070
4751
6071
4752
#ifdef DEBUG
6072
#ifdef DEBUG
4753
/****************************************************************************/
6073
/****************************************************************************/
4754
/* "debug only" section *****************************************************/
6074
/* "debug only" section *****************************************************/
4755
/****************************************************************************/
6075
/****************************************************************************/
4756
6076
4757
4758
/*****************************************************************************
6077
/*****************************************************************************
4759
 *
6078
 *
4760
 *	DumpMsg - print a frame
6079
 *	DumpMsg - print a frame
Lines 4765-4773 Link Here
4765
 * Returns: N/A
6084
 * Returns: N/A
4766
 *	
6085
 *	
4767
 */
6086
 */
4768
static void DumpMsg(struct sk_buff *skb, char *str)
6087
static void DumpMsg(
6088
struct sk_buff *skb,  /* linux' socket buffer  */
6089
char           *str)  /* additional msg string */
4769
{
6090
{
4770
	int	msglen;
6091
	int msglen = (skb->len > 64) ? 64 : skb->len;
4771
6092
4772
	if (skb == NULL) {
6093
	if (skb == NULL) {
4773
		printk("DumpMsg(): NULL-Message\n");
6094
		printk("DumpMsg(): NULL-Message\n");
Lines 4779-4797 Link Here
4779
		return;
6100
		return;
4780
	}
6101
	}
4781
6102
4782
	msglen = skb->len;
6103
	printk("DumpMsg: PhysPage: %p\n", 
4783
	if (msglen > 64)
6104
		page_address(virt_to_page(skb->data)));
4784
		msglen = 64;
6105
	printk("--- Begin of message from %s , len %d (from %d) ----\n", 
4785
6106
		str, msglen, skb->len);
4786
	printk("--- Begin of message from %s , len %d (from %d) ----\n", str, msglen, skb->len);
4787
4788
	DumpData((char *)skb->data, msglen);
6107
	DumpData((char *)skb->data, msglen);
4789
4790
	printk("------- End of message ---------\n");
6108
	printk("------- End of message ---------\n");
4791
} /* DumpMsg */
6109
} /* DumpMsg */
4792
6110
4793
4794
4795
/*****************************************************************************
6111
/*****************************************************************************
4796
 *
6112
 *
4797
 *	DumpData - print a data area
6113
 *	DumpData - print a data area
Lines 4803-4825 Link Here
4803
 * Returns: N/A
6119
 * Returns: N/A
4804
 *	
6120
 *	
4805
 */
6121
 */
4806
static void DumpData(char *p, int size)
6122
static void DumpData(
4807
{
6123
char  *p,     /* pointer to area containing the data */
4808
register int    i;
6124
int    size)  /* the size of that data area in bytes */
4809
int	haddr, addr;
6125
{
4810
char	hex_buffer[180];
6126
	register int  i;
4811
char	asc_buffer[180];
6127
	int           haddr = 0, addr = 0;
4812
char	HEXCHAR[] = "0123456789ABCDEF";
6128
	char          hex_buffer[180] = { '\0' };
4813
6129
	char          asc_buffer[180] = { '\0' };
4814
	addr = 0;
6130
	char          HEXCHAR[] = "0123456789ABCDEF";
4815
	haddr = 0;
6131
4816
	hex_buffer[0] = 0;
4817
	asc_buffer[0] = 0;
4818
	for (i=0; i < size; ) {
6132
	for (i=0; i < size; ) {
4819
		if (*p >= '0' && *p <='z')
6133
		if (*p >= '0' && *p <='z') {
4820
			asc_buffer[addr] = *p;
6134
			asc_buffer[addr] = *p;
4821
		else
6135
		} else {
4822
			asc_buffer[addr] = '.';
6136
			asc_buffer[addr] = '.';
6137
		}
4823
		addr++;
6138
		addr++;
4824
		asc_buffer[addr] = 0;
6139
		asc_buffer[addr] = 0;
4825
		hex_buffer[haddr] = HEXCHAR[(*p & 0xf0) >> 4];
6140
		hex_buffer[haddr] = HEXCHAR[(*p & 0xf0) >> 4];
Lines 4845-4871 Link Here
4845
 *	DumpLong - print a data area as long values
6160
 *	DumpLong - print a data area as long values
4846
 *
6161
 *
4847
 * Description:
6162
 * Description:
4848
 *	This function prints a area of data to the system logfile/to the
6163
 *	This function prints a long variable to the system logfile/to the
4849
 *	console.
6164
 *	console.
4850
 *
6165
 *
4851
 * Returns: N/A
6166
 * Returns: N/A
4852
 *	
6167
 *	
4853
 */
6168
 */
4854
static void DumpLong(char *pc, int size)
6169
static void DumpLong(
4855
{
6170
char  *pc,    /* location of the variable to print */
4856
register int    i;
6171
int    size)  /* how large is the variable?        */
4857
int	haddr, addr;
6172
{
4858
char	hex_buffer[180];
6173
	register int   i;
4859
char	asc_buffer[180];
6174
	int            haddr = 0, addr = 0;
4860
char	HEXCHAR[] = "0123456789ABCDEF";
6175
	char           hex_buffer[180] = { '\0' };
4861
long	*p;
6176
	char           asc_buffer[180] = { '\0' };
4862
int	l;
6177
	char           HEXCHAR[] = "0123456789ABCDEF";
4863
6178
	long          *p = (long*) pc;
4864
	addr = 0;
6179
	int            l;
4865
	haddr = 0;
6180
4866
	hex_buffer[0] = 0;
4867
	asc_buffer[0] = 0;
4868
	p = (long*) pc;
4869
	for (i=0; i < size; ) {
6181
	for (i=0; i < size; ) {
4870
		l = (long) *p;
6182
		l = (long) *p;
4871
		hex_buffer[haddr] = HEXCHAR[(l >> 28) & 0xf];
6183
		hex_buffer[haddr] = HEXCHAR[(l >> 28) & 0xf];
Lines 4899-5184 Link Here
4899
6211
4900
#endif
6212
#endif
4901
6213
4902
static int __devinit skge_probe_one(struct pci_dev *pdev,
6214
/*******************************************************************************
4903
		const struct pci_device_id *ent)
6215
 *
4904
{
6216
 * End of file
4905
	SK_AC			*pAC;
6217
 *
4906
	DEV_NET			*pNet = NULL;
6218
 ******************************************************************************/
4907
	struct net_device	*dev = NULL;
4908
	static int boards_found = 0;
4909
	int error = -ENODEV;
4910
4911
	if (pci_enable_device(pdev))
4912
		goto out;
4913
 
4914
	/* Configure DMA attributes. */
4915
	if (pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL) &&
4916
	    pci_set_dma_mask(pdev, (u64) 0xffffffff))
4917
		goto out_disable_device;
4918
4919
4920
	if ((dev = alloc_etherdev(sizeof(DEV_NET))) == NULL) {
4921
		printk(KERN_ERR "Unable to allocate etherdev "
4922
		       "structure!\n");
4923
		goto out_disable_device;
4924
	}
4925
4926
	pNet = netdev_priv(dev);
4927
	pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
4928
	if (!pNet->pAC) {
4929
		printk(KERN_ERR "Unable to allocate adapter "
4930
		       "structure!\n");
4931
		goto out_free_netdev;
4932
	}
4933
4934
	memset(pNet->pAC, 0, sizeof(SK_AC));
4935
	pAC = pNet->pAC;
4936
	pAC->PciDev = pdev;
4937
	pAC->PciDevId = pdev->device;
4938
	pAC->dev[0] = dev;
4939
	pAC->dev[1] = dev;
4940
	sprintf(pAC->Name, "SysKonnect SK-98xx");
4941
	pAC->CheckQueue = SK_FALSE;
4942
4943
	pNet->Mtu = 1500;
4944
	pNet->Up = 0;
4945
	dev->irq = pdev->irq;
4946
	error = SkGeInitPCI(pAC);
4947
	if (error) {
4948
		printk("SKGE: PCI setup failed: %i\n", error);
4949
		goto out_free_netdev;
4950
	}
4951
4952
	SET_MODULE_OWNER(dev);
4953
	dev->open =		&SkGeOpen;
4954
	dev->stop =		&SkGeClose;
4955
	dev->hard_start_xmit =	&SkGeXmit;
4956
	dev->get_stats =	&SkGeStats;
4957
	dev->set_multicast_list = &SkGeSetRxMode;
4958
	dev->set_mac_address =	&SkGeSetMacAddr;
4959
	dev->do_ioctl =		&SkGeIoctl;
4960
	dev->change_mtu =	&SkGeChangeMtu;
4961
#ifdef CONFIG_NET_POLL_CONTROLLER
4962
	dev->poll_controller =	&SkGePollController;
4963
#endif
4964
	dev->flags &= 		~IFF_RUNNING;
4965
	SET_NETDEV_DEV(dev, &pdev->dev);
4966
	SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
4967
4968
#ifdef SK_ZEROCOPY
4969
#ifdef USE_SK_TX_CHECKSUM
4970
	if (pAC->ChipsetType) {
4971
		/* Use only if yukon hardware */
4972
		/* SK and ZEROCOPY - fly baby... */
4973
		dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
4974
	}
4975
#endif
4976
#endif
4977
4978
	pAC->Index = boards_found++;
4979
4980
	if (SkGeBoardInit(dev, pAC))
4981
		goto out_free_netdev;
4982
4983
	/* Register net device */
4984
	if (register_netdev(dev)) {
4985
		printk(KERN_ERR "SKGE: Could not register device.\n");
4986
		goto out_free_resources;
4987
	}
4988
4989
	/* Print adapter specific string from vpd */
4990
	ProductStr(pAC);
4991
	printk("%s: %s\n", dev->name, pAC->DeviceStr);
4992
4993
	/* Print configuration settings */
4994
	printk("      PrefPort:%c  RlmtMode:%s\n",
4995
		'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber,
4996
		(pAC->RlmtMode==0)  ? "Check Link State" :
4997
		((pAC->RlmtMode==1) ? "Check Link State" :
4998
		((pAC->RlmtMode==3) ? "Check Local Port" :
4999
		((pAC->RlmtMode==7) ? "Check Segmentation" :
5000
		((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error")))));
5001
5002
	SkGeYellowLED(pAC, pAC->IoBase, 1);
5003
5004
5005
	memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
5006
5007
	SkGeProcCreate(dev);
5008
5009
	pNet->PortNr = 0;
5010
	pNet->NetNr  = 0;
5011
5012
	boards_found++;
5013
5014
	/* More then one port found */
5015
	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
5016
		if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) {
5017
			printk(KERN_ERR "Unable to allocate etherdev "
5018
				"structure!\n");
5019
			goto out;
5020
		}
5021
5022
		pAC->dev[1]   = dev;
5023
		pNet          = netdev_priv(dev);
5024
		pNet->PortNr  = 1;
5025
		pNet->NetNr   = 1;
5026
		pNet->pAC     = pAC;
5027
		pNet->Mtu     = 1500;
5028
		pNet->Up      = 0;
5029
5030
		dev->open               = &SkGeOpen;
5031
		dev->stop               = &SkGeClose;
5032
		dev->hard_start_xmit    = &SkGeXmit;
5033
		dev->get_stats          = &SkGeStats;
5034
		dev->set_multicast_list = &SkGeSetRxMode;
5035
		dev->set_mac_address    = &SkGeSetMacAddr;
5036
		dev->do_ioctl           = &SkGeIoctl;
5037
		dev->change_mtu         = &SkGeChangeMtu;
5038
		dev->flags             &= ~IFF_RUNNING;
5039
		SET_NETDEV_DEV(dev, &pdev->dev);
5040
		SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
5041
5042
#ifdef SK_ZEROCOPY
5043
#ifdef USE_SK_TX_CHECKSUM
5044
		if (pAC->ChipsetType) {
5045
			/* SG and ZEROCOPY - fly baby... */
5046
			dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
5047
		}
5048
#endif
5049
#endif
5050
5051
		if (register_netdev(dev)) {
5052
			printk(KERN_ERR "SKGE: Could not register device.\n");
5053
			free_netdev(dev);
5054
			pAC->dev[1] = pAC->dev[0];
5055
		} else {
5056
			SkGeProcCreate(dev);
5057
			memcpy(&dev->dev_addr,
5058
					&pAC->Addr.Net[1].CurrentMacAddress, 6);
5059
	
5060
			printk("%s: %s\n", dev->name, pAC->DeviceStr);
5061
			printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
5062
		}
5063
	}
5064
5065
	/* Save the hardware revision */
5066
	pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
5067
		(pAC->GIni.GIPciHwRev & 0x0F);
5068
5069
	/* Set driver globals */
5070
	pAC->Pnmi.pDriverFileName    = DRIVER_FILE_NAME;
5071
	pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE;
5072
5073
	memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA));
5074
	memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA));
5075
5076
	pci_set_drvdata(pdev, dev);
5077
	return 0;
5078
5079
 out_free_resources:
5080
	FreeResources(dev);
5081
 out_free_netdev:
5082
	free_netdev(dev);
5083
 out_disable_device:
5084
	pci_disable_device(pdev);
5085
 out:
5086
	return error;
5087
}
5088
5089
static void __devexit skge_remove_one(struct pci_dev *pdev)
5090
{
5091
	struct net_device *dev = pci_get_drvdata(pdev);
5092
	DEV_NET *pNet = netdev_priv(dev);
5093
	SK_AC *pAC = pNet->pAC;
5094
	struct net_device *otherdev = pAC->dev[1];
5095
5096
	SkGeProcRemove(dev);
5097
	unregister_netdev(dev);
5098
	if (otherdev != dev)
5099
		SkGeProcRemove(otherdev);
5100
5101
	SkGeYellowLED(pAC, pAC->IoBase, 0);
5102
5103
	if (pAC->BoardLevel == SK_INIT_RUN) {
5104
		SK_EVPARA EvPara;
5105
		unsigned long Flags;
5106
5107
		/* board is still alive */
5108
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
5109
		EvPara.Para32[0] = 0;
5110
		EvPara.Para32[1] = -1;
5111
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
5112
		EvPara.Para32[0] = 1;
5113
		EvPara.Para32[1] = -1;
5114
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
5115
		SkEventDispatcher(pAC, pAC->IoBase);
5116
		/* disable interrupts */
5117
		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
5118
		SkGeDeInit(pAC, pAC->IoBase);
5119
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
5120
		pAC->BoardLevel = SK_INIT_DATA;
5121
		/* We do NOT check here, if IRQ was pending, of course*/
5122
	}
5123
5124
	if (pAC->BoardLevel == SK_INIT_IO) {
5125
		/* board is still alive */
5126
		SkGeDeInit(pAC, pAC->IoBase);
5127
		pAC->BoardLevel = SK_INIT_DATA;
5128
	}
5129
5130
	FreeResources(dev);
5131
	free_netdev(dev);
5132
	if (otherdev != dev)
5133
		free_netdev(otherdev);
5134
	kfree(pAC);
5135
}
5136
5137
static struct pci_device_id skge_pci_tbl[] = {
5138
	{ PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5139
	{ PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5140
	{ PCI_VENDOR_ID_SYSKONNECT, 0x4300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5141
	{ PCI_VENDOR_ID_SYSKONNECT, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5142
	{ PCI_VENDOR_ID_DLINK, 0x4c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5143
	{ PCI_VENDOR_ID_MARVELL, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5144
#if 0	/* don't handle Yukon2 cards at the moment -- mlindner@syskonnect.de */
5145
	{ PCI_VENDOR_ID_MARVELL, 0x4360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5146
	{ PCI_VENDOR_ID_MARVELL, 0x4361, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5147
#endif
5148
	{ PCI_VENDOR_ID_MARVELL, 0x5005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5149
	{ PCI_VENDOR_ID_CNET, 0x434e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5150
	{ PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5151
	{ PCI_VENDOR_ID_LINKSYS, 0x1064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5152
	{ 0, }
5153
};
5154
5155
static struct pci_driver skge_driver = {
5156
	.name		= "skge",
5157
	.id_table	= skge_pci_tbl,
5158
	.probe		= skge_probe_one,
5159
	.remove		= __devexit_p(skge_remove_one),
5160
};
5161
5162
static int __init skge_init(void)
5163
{
5164
	int error;
5165
5166
	pSkRootDir = proc_mkdir(SKRootName, proc_net);
5167
	if (pSkRootDir) 
5168
		pSkRootDir->owner = THIS_MODULE;
5169
	
5170
	error = pci_register_driver(&skge_driver);
5171
	if (error)
5172
		proc_net_remove(SKRootName);
5173
	return error;
5174
}
5175
5176
static void __exit skge_exit(void)
5177
{
5178
	pci_unregister_driver(&skge_driver);
5179
	proc_net_remove(SKRootName);
5180
5181
}
5182
6219
5183
module_init(skge_init);
5184
module_exit(skge_exit);
(-)linux/drivers/net/sk98lin/skgehwt.c (-29 / +23 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skgehwt.c
3
 * Name:	skgehwt.c
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
5
 * Version:	$Revision: 1.15 $
5
 * Version:	$Revision: 2.2 $
6
 * Date:	$Date: 2003/09/16 13:41:23 $
6
 * Date:	$Date: 2004/05/28 13:39:04 $
7
 * Purpose:	Hardware Timer
7
 * Purpose:	Hardware Timer
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-17 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
Lines 27-33 Link Here
27
 */
27
 */
28
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
28
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
29
static const char SysKonnectFileId[] =
29
static const char SysKonnectFileId[] =
30
	"@(#) $Id: skgehwt.c,v 1.15 2003/09/16 13:41:23 rschmidt Exp $ (C) Marvell.";
30
	"@(#) $Id: skgehwt.c,v 2.2 2004/05/28 13:39:04 rschmidt Exp $ (C) Marvell.";
31
#endif
31
#endif
32
32
33
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
33
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
Lines 44-53 Link Here
44
/*
44
/*
45
 * Prototypes of local functions.
45
 * Prototypes of local functions.
46
 */
46
 */
47
#define	SK_HWT_MAX	(65000)
47
#define	SK_HWT_MAX	65000UL * 160		/* ca. 10 sec. */
48
48
49
/* correction factor */
49
/* correction factor */
50
#define	SK_HWT_FAC	(1000 * (SK_U32)pAC->GIni.GIHstClkFact / 100)
50
#define	SK_HWT_FAC	(10 * (SK_U32)pAC->GIni.GIHstClkFact / 16)
51
51
52
/*
52
/*
53
 * Initialize hardware timer.
53
 * Initialize hardware timer.
Lines 73-101 Link Here
73
void	SkHwtStart(
73
void	SkHwtStart(
74
SK_AC	*pAC,	/* Adapters context */
74
SK_AC	*pAC,	/* Adapters context */
75
SK_IOC	Ioc,	/* IoContext */
75
SK_IOC	Ioc,	/* IoContext */
76
SK_U32	Time)	/* Time in units of 16us to load the timer with. */
76
SK_U32	Time)	/* Time in usec to load the timer */
77
{
77
{
78
	SK_U32	Cnt;
79
80
	if (Time > SK_HWT_MAX)
78
	if (Time > SK_HWT_MAX)
81
		Time = SK_HWT_MAX;
79
		Time = SK_HWT_MAX;
82
80
83
	pAC->Hwt.TStart = Time;
81
	pAC->Hwt.TStart = Time;
84
	pAC->Hwt.TStop = 0L;
82
	pAC->Hwt.TStop = 0L;
85
83
86
	Cnt = Time;
84
	if (!Time) {
87
85
		Time = 1L;
88
	/*
89
	 * if time < 16 us
90
	 *	time = 16 us
91
	 */
92
	if (!Cnt) {
93
		Cnt++;
94
	}
86
	}
95
87
96
	SK_OUT32(Ioc, B2_TI_INI, Cnt * SK_HWT_FAC);
88
	SK_OUT32(Ioc, B2_TI_INI, Time * SK_HWT_FAC);
97
	
89
98
	SK_OUT16(Ioc, B2_TI_CTRL, TIM_START);	/* Start timer. */
90
	SK_OUT16(Ioc, B2_TI_CTRL, TIM_START);	/* Start timer */
99
91
100
	pAC->Hwt.TActive = SK_TRUE;
92
	pAC->Hwt.TActive = SK_TRUE;
101
}
93
}
Lines 109-121 Link Here
109
SK_IOC	Ioc)	/* IoContext */
101
SK_IOC	Ioc)	/* IoContext */
110
{
102
{
111
	SK_OUT16(Ioc, B2_TI_CTRL, TIM_STOP);
103
	SK_OUT16(Ioc, B2_TI_CTRL, TIM_STOP);
112
	
104
113
	SK_OUT16(Ioc, B2_TI_CTRL, TIM_CLR_IRQ);
105
	SK_OUT16(Ioc, B2_TI_CTRL, TIM_CLR_IRQ);
114
106
115
	pAC->Hwt.TActive = SK_FALSE;
107
	pAC->Hwt.TActive = SK_FALSE;
116
}
108
}
117
109
118
119
/*
110
/*
120
 *	Stop hardware timer and read time elapsed since last start.
111
 *	Stop hardware timer and read time elapsed since last start.
121
 *
112
 *
Lines 129-134 Link Here
129
{
120
{
130
	SK_U32	TRead;
121
	SK_U32	TRead;
131
	SK_U32	IStatus;
122
	SK_U32	IStatus;
123
	SK_U32	TimerInt;
124
125
	TimerInt = CHIP_ID_YUKON_2(pAC) ? Y2_IS_TIMINT : IS_TIMINT;
132
126
133
	if (pAC->Hwt.TActive) {
127
	if (pAC->Hwt.TActive) {
134
		
128
		
Lines 139-153 Link Here
139
133
140
		SK_IN32(Ioc, B0_ISRC, &IStatus);
134
		SK_IN32(Ioc, B0_ISRC, &IStatus);
141
135
142
		/* Check if timer expired (or wraped around) */
136
		/* Check if timer expired (or wrapped around) */
143
		if ((TRead > pAC->Hwt.TStart) || (IStatus & IS_TIMINT)) {
137
		if ((TRead > pAC->Hwt.TStart) || ((IStatus & TimerInt) != 0)) {
144
			
138
145
			SkHwtStop(pAC, Ioc);
139
			SkHwtStop(pAC, Ioc);
146
			
140
147
			pAC->Hwt.TStop = pAC->Hwt.TStart;
141
			pAC->Hwt.TStop = pAC->Hwt.TStart;
148
		}
142
		}
149
		else {
143
		else {
150
			
144
151
			pAC->Hwt.TStop = pAC->Hwt.TStart - TRead;
145
			pAC->Hwt.TStop = pAC->Hwt.TStart - TRead;
152
		}
146
		}
153
	}
147
	}
Lines 162-170 Link Here
162
SK_IOC	Ioc)	/* IoContext */
156
SK_IOC	Ioc)	/* IoContext */
163
{
157
{
164
	SkHwtStop(pAC, Ioc);
158
	SkHwtStop(pAC, Ioc);
165
	
159
166
	pAC->Hwt.TStop = pAC->Hwt.TStart;
160
	pAC->Hwt.TStop = pAC->Hwt.TStart;
167
	
161
168
	SkTimerDone(pAC, Ioc);
162
	SkTimerDone(pAC, Ioc);
169
}
163
}
170
164
(-)linux/drivers/net/sk98lin/skgeinit.c (-465 / +1218 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skgeinit.c
3
 * Name:	skgeinit.c
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.97 $
5
 * Version:	$Revision: 2.71 $
6
 * Date:	$Date: 2003/10/02 16:45:31 $
6
 * Date:	$Date: 2005/03/03 15:53:18 $
7
 * Purpose:	Contains functions to initialize the adapter
7
 * Purpose:	Contains functions to initialize the adapter
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-23 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2005 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
22
 *
21
 *
23
 ******************************************************************************/
22
 ******************************************************************************/
Lines 31-37 Link Here
31
30
32
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
31
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
33
static const char SysKonnectFileId[] =
32
static const char SysKonnectFileId[] =
34
	"@(#) $Id: skgeinit.c,v 1.97 2003/10/02 16:45:31 rschmidt Exp $ (C) Marvell.";
33
	"@(#) $Id: skgeinit.c,v 2.71 2005/03/03 15:53:18 rschmidt Exp $ (C) Marvell.";
35
#endif
34
#endif
36
35
37
struct s_QOffTab {
36
struct s_QOffTab {
Lines 59-64 Link Here
59
58
60
/******************************************************************************
59
/******************************************************************************
61
 *
60
 *
61
 *	SkGePortVlan() -	Enable / Disable VLAN support
62
 *
63
 * Description:
64
 *	Enable or disable the VLAN support of the selected port.
65
 *	The new configuration is *not* saved over any SkGeStopPort() and
66
 *	SkGeInitPort() calls.
67
 *	Currently this function is only supported on Yukon-2/EC adapters.
68
 *
69
 * Returns:
70
 *	nothing
71
 */
72
void SkGePortVlan(
73
SK_AC	*pAC,	/* Adapter Context */
74
SK_IOC	IoC,	/* I/O Context */
75
int		Port,	/* Port number */
76
SK_BOOL	Enable)	/* Flag */
77
{
78
	if (CHIP_ID_YUKON_2(pAC)) {
79
		if (Enable) {
80
			SK_OUT32(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), RX_VLAN_STRIP_ON);
81
			SK_OUT32(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), TX_VLAN_TAG_ON);
82
		}
83
		else {
84
			SK_OUT32(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), RX_VLAN_STRIP_OFF);
85
			SK_OUT32(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), TX_VLAN_TAG_OFF);
86
		}
87
	}
88
}
89
90
91
/******************************************************************************
92
 *
93
 *	SkGeRxRss() -	Enable / Disable RSS Hash Calculation
94
 *
95
 * Description:
96
 *	Enable or disable the RSS hash calculation of the selected port.
97
 *	The new configuration is *not* saved over any SkGeStopPort() and
98
 *	SkGeInitPort() calls.
99
 *	Currently this function is only supported on Yukon-2/EC adapters.
100
 *
101
 * Returns:
102
 *	nothing
103
 */
104
void SkGeRxRss(
105
SK_AC	*pAC,	/* Adapter Context */
106
SK_IOC	IoC,	/* I/O Context */
107
int		Port,	/* Port number */
108
SK_BOOL	Enable)	/* Flag */
109
{
110
	if (CHIP_ID_YUKON_2(pAC)) {
111
		if (Enable) {
112
			SK_OUT32(IoC, Q_ADDR(pAC->GIni.GP[Port].PRxQOff, Q_CSR),
113
				BMU_ENA_RX_RSS_HASH);
114
		}
115
		else {
116
			SK_OUT32(IoC, Q_ADDR(pAC->GIni.GP[Port].PRxQOff, Q_CSR),
117
				BMU_DIS_RX_RSS_HASH);
118
		}
119
	}
120
}
121
122
/******************************************************************************
123
 *
124
 *	SkGeRxCsum() -	Enable / Disable Receive Checksum
125
 *
126
 * Description:
127
 *	Enable or disable the checksum of the selected port.
128
 *	The new configuration is *not* saved over any SkGeStopPort() and
129
 *	SkGeInitPort() calls.
130
 *	Currently this function is only supported on Yukon-2/EC adapters.
131
 *
132
 * Returns:
133
 *	nothing
134
 */
135
void SkGeRxCsum(
136
SK_AC	*pAC,	/* Adapter Context */
137
SK_IOC	IoC,	/* I/O Context */
138
int		Port,	/* Port number */
139
SK_BOOL	Enable)	/* Flag */
140
{
141
	if (CHIP_ID_YUKON_2(pAC)) {
142
		if (Enable) {
143
			SK_OUT32(IoC, Q_ADDR(pAC->GIni.GP[Port].PRxQOff, Q_CSR),
144
				BMU_ENA_RX_CHKSUM);
145
		}
146
		else {
147
			SK_OUT32(IoC, Q_ADDR(pAC->GIni.GP[Port].PRxQOff, Q_CSR),
148
				BMU_DIS_RX_CHKSUM);
149
		}
150
	}
151
}
152
153
154
/******************************************************************************
155
 *
62
 *	SkGePollRxD() - Enable / Disable Descriptor Polling of RxD Ring
156
 *	SkGePollRxD() - Enable / Disable Descriptor Polling of RxD Ring
63
 *
157
 *
64
 * Description:
158
 * Description:
Lines 71-78 Link Here
71
 *	nothing
165
 *	nothing
72
 */
166
 */
73
void SkGePollRxD(
167
void SkGePollRxD(
74
SK_AC	*pAC,		/* adapter context */
168
SK_AC	*pAC,		/* Adapter Context */
75
SK_IOC	IoC,		/* IO context */
169
SK_IOC	IoC,		/* I/O Context */
76
int		Port,		/* Port Index (MAC_1 + n) */
170
int		Port,		/* Port Index (MAC_1 + n) */
77
SK_BOOL PollRxD)	/* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
171
SK_BOOL PollRxD)	/* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
78
{
172
{
Lines 80-87 Link Here
80
174
81
	pPrt = &pAC->GIni.GP[Port];
175
	pPrt = &pAC->GIni.GP[Port];
82
176
83
	SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), (PollRxD) ?
177
	SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), (SK_U32)((PollRxD) ?
84
		CSR_ENA_POL : CSR_DIS_POL);
178
		CSR_ENA_POL : CSR_DIS_POL));
85
}	/* SkGePollRxD */
179
}	/* SkGePollRxD */
86
180
87
181
Lines 99-106 Link Here
99
 *	nothing
193
 *	nothing
100
 */
194
 */
101
void SkGePollTxD(
195
void SkGePollTxD(
102
SK_AC	*pAC,		/* adapter context */
196
SK_AC	*pAC,		/* Adapter Context */
103
SK_IOC	IoC,		/* IO context */
197
SK_IOC	IoC,		/* I/O Context */
104
int		Port,		/* Port Index (MAC_1 + n) */
198
int		Port,		/* Port Index (MAC_1 + n) */
105
SK_BOOL PollTxD)	/* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
199
SK_BOOL PollTxD)	/* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
106
{
200
{
Lines 114-120 Link Here
114
	if (pPrt->PXSQSize != 0) {
208
	if (pPrt->PXSQSize != 0) {
115
		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), DWord);
209
		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), DWord);
116
	}
210
	}
117
	
211
118
	if (pPrt->PXAQSize != 0) {
212
	if (pPrt->PXAQSize != 0) {
119
		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), DWord);
213
		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), DWord);
120
	}
214
	}
Lines 135-151 Link Here
135
 *	nothing
229
 *	nothing
136
 */
230
 */
137
void SkGeYellowLED(
231
void SkGeYellowLED(
138
SK_AC	*pAC,		/* adapter context */
232
SK_AC	*pAC,		/* Adapter Context */
139
SK_IOC	IoC,		/* IO context */
233
SK_IOC	IoC,		/* I/O Context */
140
int		State)		/* yellow LED state, 0 = OFF, 0 != ON */
234
int		State)		/* yellow LED state, 0 = OFF, 0 != ON */
141
{
235
{
236
	int	LedReg;
237
238
	if (CHIP_ID_YUKON_2(pAC)) {
239
		/* different mapping on Yukon-2 */
240
		LedReg = B0_CTST + 1;
241
	}
242
	else {
243
		LedReg = B0_LED;
244
	}
245
142
	if (State == 0) {
246
	if (State == 0) {
143
		/* Switch yellow LED OFF */
247
		/* Switch state LED OFF */
144
		SK_OUT8(IoC, B0_LED, LED_STAT_OFF);
248
		SK_OUT8(IoC, LedReg, LED_STAT_OFF);
145
	}
249
	}
146
	else {
250
	else {
147
		/* Switch yellow LED ON */
251
		/* Switch state LED ON */
148
		SK_OUT8(IoC, B0_LED, LED_STAT_ON);
252
		SK_OUT8(IoC, LedReg, LED_STAT_ON);
149
	}
253
	}
150
}	/* SkGeYellowLED */
254
}	/* SkGeYellowLED */
151
255
Lines 169-176 Link Here
169
 *	nothing
273
 *	nothing
170
 */
274
 */
171
void SkGeXmitLED(
275
void SkGeXmitLED(
172
SK_AC	*pAC,		/* adapter context */
276
SK_AC	*pAC,		/* Adapter Context */
173
SK_IOC	IoC,		/* IO context */
277
SK_IOC	IoC,		/* I/O Context */
174
int		Led,		/* offset to the LED Init Value register */
278
int		Led,		/* offset to the LED Init Value register */
175
int		Mode)		/* Mode may be SK_LED_DIS, SK_LED_ENA, SK_LED_TST */
279
int		Mode)		/* Mode may be SK_LED_DIS, SK_LED_ENA, SK_LED_TST */
176
{
280
{
Lines 197-209 Link Here
197
		SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_OFF);
301
		SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_OFF);
198
		break;
302
		break;
199
	}
303
	}
200
			
304
201
	/*
305
	/*
202
	 * 1000BT: The Transmit LED is driven by the PHY.
306
	 * 1000BT: the Transmit LED is driven by the PHY.
203
	 * But the default LED configuration is used for
307
	 * But the default LED configuration is used for
204
	 * Level One and Broadcom PHYs.
308
	 * Level One and Broadcom PHYs.
205
	 * (Broadcom: It may be that PHY_B_PEC_EN_LTR has to be set.)
309
	 * (Broadcom: It may be that PHY_B_PEC_EN_LTR has to be set.
206
	 * (In this case it has to be added here. But we will see. XXX)
310
	 * In this case it has to be added here.)
207
	 */
311
	 */
208
}	/* SkGeXmitLED */
312
}	/* SkGeXmitLED */
209
#endif	/* !SK_SLIM || GENESIS */
313
#endif	/* !SK_SLIM || GENESIS */
Lines 227-233 Link Here
227
 *	1:	configuration error
331
 *	1:	configuration error
228
 */
332
 */
229
static int DoCalcAddr(
333
static int DoCalcAddr(
230
SK_AC		*pAC, 				/* adapter context */
334
SK_AC		*pAC, 				/* Adapter Context */
231
SK_GEPORT	SK_FAR *pPrt,		/* port index */
335
SK_GEPORT	SK_FAR *pPrt,		/* port index */
232
int			QuSize,				/* size of the queue to configure in kB */
336
int			QuSize,				/* size of the queue to configure in kB */
233
SK_U32		SK_FAR *StartVal,	/* start value for address calculation */
337
SK_U32		SK_FAR *StartVal,	/* start value for address calculation */
Lines 264-275 Link Here
264
368
265
/******************************************************************************
369
/******************************************************************************
266
 *
370
 *
371
 *	SkGeRoundQueueSize() - Round the given queue size to the adpaters QZ units
372
 *
373
 * Description:
374
 *	This function rounds the given queue size in kBs to adapter specific
375
 *	queue size units (Genesis and Yukon: 8 kB, Yukon-2/EC: 1 kB).
376
 *
377
 * Returns:
378
 *	the rounded queue size in kB	
379
 */
380
static int SkGeRoundQueueSize(
381
SK_AC	*pAC,		/* Adapter Context */
382
int	QueueSizeKB)	/* Queue size in kB */
383
{
384
	int QueueSizeSteps;
385
386
	QueueSizeSteps = (CHIP_ID_YUKON_2(pAC)) ? QZ_STEP_Y2 : QZ_STEP;
387
388
	return((QueueSizeKB + QueueSizeSteps - 1) & ~(QueueSizeSteps - 1));
389
}	/* SkGeRoundQueueSize */
390
391
392
/******************************************************************************
393
 *
267
 *	SkGeInitAssignRamToQueues() - allocate default queue sizes
394
 *	SkGeInitAssignRamToQueues() - allocate default queue sizes
268
 *
395
 *
269
 * Description:
396
 * Description:
270
 *	This function assigns the memory to the different queues and ports.
397
 *	This function assigns the memory to the different queues and ports.
271
 *	When DualNet is set to SK_TRUE all ports get the same amount of memory.
398
 *	When DualNet is set to SK_TRUE all ports get the same amount of memory.
272
 *  Otherwise the first port gets most of the memory and all the
399
 *	Otherwise the first port gets most of the memory and all the
273
 *	other ports just the required minimum.
400
 *	other ports just the required minimum.
274
 *	This function can only be called when pAC->GIni.GIRamSize and
401
 *	This function can only be called when pAC->GIni.GIRamSize and
275
 *	pAC->GIni.GIMacsFound have been initialized, usually this happens
402
 *	pAC->GIni.GIMacsFound have been initialized, usually this happens
Lines 282-383 Link Here
282
 */
409
 */
283
410
284
int SkGeInitAssignRamToQueues(
411
int SkGeInitAssignRamToQueues(
285
SK_AC	*pAC,			/* Adapter context */
412
SK_AC	*pAC,			/* Adapter Context */
286
int		ActivePort,		/* Active Port in RLMT mode */
413
int		ActivePort,		/* Active Port in RLMT mode */
287
SK_BOOL	DualNet)		/* adapter context */
414
SK_BOOL	DualNet)		/* Dual Net active */
288
{
415
{
289
	int	i;
416
	int	i;
290
	int	UsedKilobytes;			/* memory already assigned */
417
	int	UsedKilobytes;			/* memory already assigned */
291
	int	ActivePortKilobytes;	/* memory available for active port */
418
	int	ActivePortKilobytes;	/* memory available for active port */
292
	SK_GEPORT *pGePort;
419
	int	MinQueueSize;			/* min. memory for queues */
293
420
	int	TotalRamSize;			/* total memory for queues */
294
	UsedKilobytes = 0;
421
	SK_BOOL	DualPortYukon2;
422
	SK_GEPORT *pPrt;
295
423
296
	if (ActivePort >= pAC->GIni.GIMacsFound) {
424
	if (ActivePort >= pAC->GIni.GIMacsFound) {
425
297
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
426
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
298
			("SkGeInitAssignRamToQueues: ActivePort (%d) invalid\n",
427
			("SkGeInitAssignRamToQueues: ActivePort (%d) invalid\n",
299
			ActivePort));
428
			ActivePort));
300
		return(1);
429
		return(1);
301
	}
430
	}
302
	if (((pAC->GIni.GIMacsFound * (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE)) +
431
303
		((RAM_QUOTA_SYNC == 0) ? 0 : SK_MIN_TXQ_SIZE)) > pAC->GIni.GIRamSize) {
432
	DualPortYukon2 = (CHIP_ID_YUKON_2(pAC) && pAC->GIni.GIMacsFound == 2);
433
434
	TotalRamSize = pAC->GIni.GIRamSize;
435
436
	if (DualPortYukon2) {
437
		TotalRamSize *= 2;
438
	}
439
440
	MinQueueSize = SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE;
441
442
	if (MinQueueSize > pAC->GIni.GIRamSize) {
443
		MinQueueSize = pAC->GIni.GIRamSize;
444
	}
445
446
	if ((pAC->GIni.GIMacsFound * MinQueueSize +
447
		 RAM_QUOTA_SYNC * SK_MIN_TXQ_SIZE) > TotalRamSize) {
448
304
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
449
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
305
			("SkGeInitAssignRamToQueues: Not enough memory (%d)\n",
450
			("SkGeInitAssignRamToQueues: Not enough memory (%d)\n",
306
			 pAC->GIni.GIRamSize));
451
			TotalRamSize));
307
		return(2);
452
		return(2);
308
	}
453
	}
309
454
310
	if (DualNet) {
455
	if (DualNet) {
311
		/* every port gets the same amount of memory */
456
		/* every port gets the same amount of memory */
312
		ActivePortKilobytes = pAC->GIni.GIRamSize / pAC->GIni.GIMacsFound;
457
		ActivePortKilobytes = TotalRamSize / pAC->GIni.GIMacsFound;
458
313
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
459
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
314
460
315
			pGePort = &pAC->GIni.GP[i];
461
			pPrt = &pAC->GIni.GP[i];
316
			
462
463
			if (DualPortYukon2) {
464
				ActivePortKilobytes = pAC->GIni.GIRamSize;
465
			}
317
			/* take away the minimum memory for active queues */
466
			/* take away the minimum memory for active queues */
318
			ActivePortKilobytes -= (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE);
467
			ActivePortKilobytes -= MinQueueSize;
319
468
320
			/* receive queue gets the minimum + 80% of the rest */
469
			/* receive queue gets the minimum + 80% of the rest */
321
			pGePort->PRxQSize = (int) (ROUND_QUEUE_SIZE_KB((
470
			pPrt->PRxQSize = SkGeRoundQueueSize(pAC,
322
				ActivePortKilobytes * (unsigned long) RAM_QUOTA_RX) / 100))
471
				(int)((long)ActivePortKilobytes * RAM_QUOTA_RX) / 100)
323
				+ SK_MIN_RXQ_SIZE;
472
				+ SK_MIN_RXQ_SIZE;
324
473
325
			ActivePortKilobytes -= (pGePort->PRxQSize - SK_MIN_RXQ_SIZE);
474
			ActivePortKilobytes -= (pPrt->PRxQSize - SK_MIN_RXQ_SIZE);
326
475
327
			/* synchronous transmit queue */
476
			/* synchronous transmit queue */
328
			pGePort->PXSQSize = 0;
477
			pPrt->PXSQSize = 0;
329
478
330
			/* asynchronous transmit queue */
479
			/* asynchronous transmit queue */
331
			pGePort->PXAQSize = (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes +
480
			pPrt->PXAQSize = SkGeRoundQueueSize(pAC,
332
				SK_MIN_TXQ_SIZE);
481
				ActivePortKilobytes + SK_MIN_TXQ_SIZE);
333
		}
482
		}
334
	}
483
	}
335
	else {	
484
	else {	/* RLMT Mode or single link adapter */
336
		/* Rlmt Mode or single link adapter */
337
485
338
		/* Set standby queue size defaults for all standby ports */
486
		UsedKilobytes = 0;
487
488
		/* set standby queue size defaults for all standby ports */
339
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
489
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
340
490
341
			if (i != ActivePort) {
491
			if (i != ActivePort) {
342
				pGePort = &pAC->GIni.GP[i];
492
				pPrt = &pAC->GIni.GP[i];
343
493
344
				pGePort->PRxQSize = SK_MIN_RXQ_SIZE;
494
				if (DualPortYukon2) {
345
				pGePort->PXAQSize = SK_MIN_TXQ_SIZE;
495
					pPrt->PRxQSize = SkGeRoundQueueSize(pAC,
346
				pGePort->PXSQSize = 0;
496
						(int)((long)pAC->GIni.GIRamSize * RAM_QUOTA_RX) / 100);
497
					pPrt->PXAQSize = pAC->GIni.GIRamSize - pPrt->PRxQSize;
498
				}
499
				else {
500
					pPrt->PRxQSize = SK_MIN_RXQ_SIZE;
501
					pPrt->PXAQSize = SK_MIN_TXQ_SIZE;
502
				}
503
				pPrt->PXSQSize = 0;
347
504
348
				/* Count used RAM */
505
				/* Count used RAM */
349
				UsedKilobytes += pGePort->PRxQSize + pGePort->PXAQSize;
506
				UsedKilobytes += pPrt->PRxQSize + pPrt->PXAQSize;
350
			}
507
			}
351
		}
508
		}
352
		/* what's left? */
509
		/* what's left? */
353
		ActivePortKilobytes = pAC->GIni.GIRamSize - UsedKilobytes;
510
		ActivePortKilobytes = TotalRamSize - UsedKilobytes;
354
511
355
		/* assign it to the active port */
512
		/* assign it to the active port */
356
		/* first take away the minimum memory */
513
		/* first take away the minimum memory */
357
		ActivePortKilobytes -= (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE);
514
		ActivePortKilobytes -= MinQueueSize;
358
		pGePort = &pAC->GIni.GP[ActivePort];
515
		pPrt = &pAC->GIni.GP[ActivePort];
359
516
360
		/* receive queue get's the minimum + 80% of the rest */
517
		/* receive queue get's the minimum + 80% of the rest */
361
		pGePort->PRxQSize = (int) (ROUND_QUEUE_SIZE_KB((ActivePortKilobytes *
518
		pPrt->PRxQSize = SkGeRoundQueueSize(pAC,
362
			(unsigned long) RAM_QUOTA_RX) / 100)) + SK_MIN_RXQ_SIZE;
519
			(int)((long)ActivePortKilobytes * RAM_QUOTA_RX) / 100) +
520
			MinQueueSize/2;
363
521
364
		ActivePortKilobytes -= (pGePort->PRxQSize - SK_MIN_RXQ_SIZE);
522
		ActivePortKilobytes -= (pPrt->PRxQSize - MinQueueSize/2);
365
523
366
		/* synchronous transmit queue */
524
		/* synchronous transmit queue */
367
		pGePort->PXSQSize = 0;
525
		pPrt->PXSQSize = 0;
368
526
369
		/* asynchronous transmit queue */
527
		/* asynchronous transmit queue */
370
		pGePort->PXAQSize = (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes) +
528
		pPrt->PXAQSize = SkGeRoundQueueSize(pAC, ActivePortKilobytes) +
371
			SK_MIN_TXQ_SIZE;
529
			MinQueueSize/2;
372
	}
530
	}
373
#ifdef VCPU
531
374
	VCPUprintf(0, "PRxQSize=%u, PXSQSize=%u, PXAQSize=%u\n",
532
#ifdef DEBUG
375
		pGePort->PRxQSize, pGePort->PXSQSize, pGePort->PXAQSize);
533
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
376
#endif /* VCPU */
534
535
		pPrt = &pAC->GIni.GP[i];
536
537
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
538
			("Port %d: RxQSize=%u, TxAQSize=%u, TxSQSize=%u\n",
539
			i, pPrt->PRxQSize, pPrt->PXAQSize, pPrt->PXSQSize));
540
	}
541
#endif /* DEBUG */
377
542
378
	return(0);
543
	return(0);
379
}	/* SkGeInitAssignRamToQueues */
544
}	/* SkGeInitAssignRamToQueues */
380
545
546
381
/******************************************************************************
547
/******************************************************************************
382
 *
548
 *
383
 *	SkGeCheckQSize() - Checks the Adapters Queue Size Configuration
549
 *	SkGeCheckQSize() - Checks the Adapters Queue Size Configuration
Lines 388-399 Link Here
388
 *	used ports.
554
 *	used ports.
389
 *	This requirements must be fullfilled to have a valid configuration:
555
 *	This requirements must be fullfilled to have a valid configuration:
390
 *		- The size of all queues must not exceed GIRamSize.
556
 *		- The size of all queues must not exceed GIRamSize.
391
 *		- The queue sizes must be specified in units of 8 kB.
557
 *		- The queue sizes must be specified in units of 8 kB (Genesis & Yukon).
392
 *		- The size of Rx queues of available ports must not be
558
 *		- The size of Rx queues of available ports must not be
393
 *		  smaller than 16 kB.
559
 *		  smaller than 16 kB (Genesis & Yukon) resp. 10 kB (Yukon-2).
394
 *		- The size of at least one Tx queue (synch. or asynch.)
560
 *		- The size of at least one Tx queue (synch. or asynch.)
395
 *        of available ports must not be smaller than 16 kB
561
 *		  of available ports must not be smaller than 16 kB (Genesis & Yukon),
396
 *        when Jumbo Frames are used.
562
 *		  resp. 10 kB (Yukon-2) when Jumbo Frames are used.
397
 *		- The RAM start and end addresses must not be changed
563
 *		- The RAM start and end addresses must not be changed
398
 *		  for ports which are already initialized.
564
 *		  for ports which are already initialized.
399
 *	Furthermore SkGeCheckQSize() defines the Start and End Addresses
565
 *	Furthermore SkGeCheckQSize() defines the Start and End Addresses
Lines 404-410 Link Here
404
 *	1:	Queue Size Configuration invalid
570
 *	1:	Queue Size Configuration invalid
405
 */
571
 */
406
static int SkGeCheckQSize(
572
static int SkGeCheckQSize(
407
SK_AC	 *pAC,		/* adapter context */
573
SK_AC	 *pAC,		/* Adapter Context */
408
int		 Port)		/* port index */
574
int		 Port)		/* port index */
409
{
575
{
410
	SK_GEPORT *pPrt;
576
	SK_GEPORT *pPrt;
Lines 414-457 Link Here
414
	SK_U32	StartAddr;
580
	SK_U32	StartAddr;
415
#ifndef SK_SLIM
581
#ifndef SK_SLIM
416
	int	UsedMem;	/* total memory used (max. found ports) */
582
	int	UsedMem;	/* total memory used (max. found ports) */
417
#endif	
583
#endif
418
584
419
	Rtv = 0;
585
	Rtv = 0;
420
	
586
421
#ifndef SK_SLIM
587
#ifndef SK_SLIM
422
588
423
	UsedMem = 0;
589
	UsedMem = 0;
590
	Rtv = 0;
424
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
591
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
425
		pPrt = &pAC->GIni.GP[i];
592
		pPrt = &pAC->GIni.GP[i];
426
593
427
		if ((pPrt->PRxQSize & QZ_UNITS) != 0 ||
594
		if (CHIP_ID_YUKON_2(pAC)) {
428
			(pPrt->PXSQSize & QZ_UNITS) != 0 ||
595
			UsedMem = 0;
429
			(pPrt->PXAQSize & QZ_UNITS) != 0) {
596
		}
597
		else if (((pPrt->PRxQSize & QZ_UNITS) != 0 ||
598
				  (pPrt->PXSQSize & QZ_UNITS) != 0 ||
599
				  (pPrt->PXAQSize & QZ_UNITS) != 0)) {
430
600
431
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);
601
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);
432
			return(1);
602
			return(1);
433
		}
603
		}
434
604
435
		if (i == Port && pPrt->PRxQSize < SK_MIN_RXQ_SIZE) {
605
#ifndef SK_DIAG
606
		if (i == Port && pAC->GIni.GIRamSize > SK_MIN_RXQ_SIZE &&
607
			pPrt->PRxQSize < SK_MIN_RXQ_SIZE) {
436
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E011, SKERR_HWI_E011MSG);
608
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E011, SKERR_HWI_E011MSG);
437
			return(1);
609
			return(1);
438
		}
610
		}
439
		
611
440
		/*
612
		/*
441
		 * the size of at least one Tx queue (synch. or asynch.) has to be > 0.
613
		 * the size of at least one Tx queue (synch. or asynch.) has to be > 0.
442
		 * if Jumbo Frames are used, this size has to be >= 16 kB.
614
		 * if Jumbo Frames are used, this size has to be >= 16 kB.
443
		 */
615
		 */
444
		if ((i == Port && pPrt->PXSQSize == 0 && pPrt->PXAQSize == 0) ||
616
		if ((i == Port && pPrt->PXSQSize == 0 && pPrt->PXAQSize == 0) ||
445
			(pAC->GIni.GIPortUsage == SK_JUMBO_LINK &&
617
			(pAC->GIni.GIPortUsage == SK_JUMBO_LINK &&
446
            ((pPrt->PXSQSize > 0 && pPrt->PXSQSize < SK_MIN_TXQ_SIZE) ||
618
			((pPrt->PXSQSize > 0 && pPrt->PXSQSize < SK_MIN_TXQ_SIZE) ||
447
			 (pPrt->PXAQSize > 0 && pPrt->PXAQSize < SK_MIN_TXQ_SIZE)))) {
619
			 (pPrt->PXAQSize > 0 && pPrt->PXAQSize < SK_MIN_TXQ_SIZE)))) {
448
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E023, SKERR_HWI_E023MSG);
620
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E023, SKERR_HWI_E023MSG);
449
				return(1);
621
				return(1);
450
		}
622
		}
451
		
623
#endif /* !SK_DIAG */
624
452
		UsedMem += pPrt->PRxQSize + pPrt->PXSQSize + pPrt->PXAQSize;
625
		UsedMem += pPrt->PRxQSize + pPrt->PXSQSize + pPrt->PXAQSize;
453
	}
626
	}
454
	
627
455
	if (UsedMem > pAC->GIni.GIRamSize) {
628
	if (UsedMem > pAC->GIni.GIRamSize) {
456
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);
629
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);
457
		return(1);
630
		return(1);
Lines 461-468 Link Here
461
	/* Now start address calculation */
634
	/* Now start address calculation */
462
	StartAddr = pAC->GIni.GIRamOffs;
635
	StartAddr = pAC->GIni.GIRamOffs;
463
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
636
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
637
464
		pPrt = &pAC->GIni.GP[i];
638
		pPrt = &pAC->GIni.GP[i];
465
639
640
		if (CHIP_ID_YUKON_2(pAC)) {
641
			StartAddr = 0;
642
		}
643
466
		/* Calculate/Check values for the receive queue */
644
		/* Calculate/Check values for the receive queue */
467
		Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PRxQSize, &StartAddr,
645
		Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PRxQSize, &StartAddr,
468
			&pPrt->PRxQRamStart, &pPrt->PRxQRamEnd);
646
			&pPrt->PRxQRamStart, &pPrt->PRxQRamEnd);
Lines 502-509 Link Here
502
 *	nothing
680
 *	nothing
503
 */
681
 */
504
static void SkGeInitMacArb(
682
static void SkGeInitMacArb(
505
SK_AC	*pAC,		/* adapter context */
683
SK_AC	*pAC,		/* Adapter Context */
506
SK_IOC	IoC)		/* IO context */
684
SK_IOC	IoC)		/* I/O Context */
507
{
685
{
508
	/* release local reset */
686
	/* release local reset */
509
	SK_OUT16(IoC, B3_MA_TO_CTRL, MA_RST_CLR);
687
	SK_OUT16(IoC, B3_MA_TO_CTRL, MA_RST_CLR);
Lines 542-549 Link Here
542
 *	nothing
720
 *	nothing
543
 */
721
 */
544
static void SkGeInitPktArb(
722
static void SkGeInitPktArb(
545
SK_AC	*pAC,		/* adapter context */
723
SK_AC	*pAC,		/* Adapter Context */
546
SK_IOC	IoC)		/* IO context */
724
SK_IOC	IoC)		/* I/O Context */
547
{
725
{
548
	/* release local reset */
726
	/* release local reset */
549
	SK_OUT16(IoC, B3_PA_CTRL, PA_RST_CLR);
727
	SK_OUT16(IoC, B3_PA_CTRL, PA_RST_CLR);
Lines 582-595 Link Here
582
 *	nothing
760
 *	nothing
583
 */
761
 */
584
static void SkGeInitMacFifo(
762
static void SkGeInitMacFifo(
585
SK_AC	*pAC,		/* adapter context */
763
SK_AC	*pAC,		/* Adapter Context */
586
SK_IOC	IoC,		/* IO context */
764
SK_IOC	IoC,		/* I/O Context */
587
int		Port)		/* Port Index (MAC_1 + n) */
765
int		Port)		/* Port Index (MAC_1 + n) */
588
{
766
{
589
	SK_U16	Word;
767
	SK_U16	Word;
590
#ifdef VCPU
591
	SK_U32	DWord;
592
#endif /* VCPU */
593
	/*
768
	/*
594
	 * For each FIFO:
769
	 * For each FIFO:
595
	 *	- release local reset
770
	 *	- release local reset
Lines 597-627 Link Here
597
	 *	- setup defaults for the control register
772
	 *	- setup defaults for the control register
598
	 *	- enable the FIFO
773
	 *	- enable the FIFO
599
	 */
774
	 */
600
	
775
601
#ifdef GENESIS
776
#ifdef GENESIS
602
	if (pAC->GIni.GIGenesis) {
777
	if (pAC->GIni.GIGenesis) {
603
		/* Configure Rx MAC FIFO */
778
		/* configure Rx MAC FIFO */
604
		SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_CLR);
779
		SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_CLR);
605
		SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_RX_CTRL_DEF);
780
		SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_RX_CTRL_DEF);
606
		SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_ENA_OP_MD);
781
		SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_ENA_OP_MD);
607
	
782
608
		/* Configure Tx MAC FIFO */
783
		/* Configure Tx MAC FIFO */
609
		SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_RST_CLR);
784
		SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_RST_CLR);
610
		SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_TX_CTRL_DEF);
785
		SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_TX_CTRL_DEF);
611
		SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_ENA_OP_MD);
786
		SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_ENA_OP_MD);
612
	
787
613
		/* Enable frame flushing if jumbo frames used */
788
		/* enable frame flushing if jumbo frames used */
614
		if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK) {
789
		if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK) {
615
			SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_ENA_FLUSH);
790
			SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_ENA_FLUSH);
616
		}
791
		}
617
	}
792
	}
618
#endif /* GENESIS */
793
#endif /* GENESIS */
619
	
794
620
#ifdef YUKON
795
#ifdef YUKON
621
	if (pAC->GIni.GIYukon) {
796
	if (pAC->GIni.GIYukon) {
622
		/* set Rx GMAC FIFO Flush Mask */
797
623
		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_MSK), (SK_U16)RX_FF_FL_DEF_MSK);
624
		
625
		Word = (SK_U16)GMF_RX_CTRL_DEF;
798
		Word = (SK_U16)GMF_RX_CTRL_DEF;
626
799
627
		/* disable Rx GMAC FIFO Flush for YUKON-Lite Rev. A0 only */
800
		/* disable Rx GMAC FIFO Flush for YUKON-Lite Rev. A0 only */
Lines 629-651 Link Here
629
802
630
			Word &= ~GMF_RX_F_FL_ON;
803
			Word &= ~GMF_RX_F_FL_ON;
631
		}
804
		}
632
		
805
633
		/* Configure Rx MAC FIFO */
806
		/* Configure Rx GMAC FIFO */
634
		SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);
807
		SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);
635
		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), Word);
808
		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), Word);
636
		
809
637
		/* set Rx GMAC FIFO Flush Threshold (default: 0x0a -> 56 bytes) */
810
		Word = RX_FF_FL_DEF_MSK;
638
		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF);
811
639
		
812
#ifndef SK_DIAG
640
		/* Configure Tx MAC FIFO */
813
		if (HW_FEATURE(pAC, HWF_WA_DEV_4115)) {
814
			/*
815
			 * Flushing must be enabled (needed for ASF see dev 4.29),
816
			 * but the flushing mask should be disabled (see dev 4.115)
817
			 */
818
			Word = 0;
819
		}
820
#endif /* !SK_DIAG */
821
822
		/* set Rx GMAC FIFO Flush Mask (after clearing reset) */
823
		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_MSK), Word);
824
825
		/* default: 0x0a -> 56 bytes on Yukon-1 and 64 bytes on Yukon-2 */
826
		Word = (SK_U16)RX_GMF_FL_THR_DEF;
827
828
		if (CHIP_ID_YUKON_2(pAC)) {
829
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_EC &&
830
				pAC->GIni.GIAsfEnabled) {
831
				/* WA for dev. #4.30 (reduce to 0x08 -> 48 bytes) */
832
				Word -= 2;
833
			}
834
		}
835
		else {
836
			/*
837
			* because Pause Packet Truncation in GMAC is not working
838
			* we have to increase the Flush Threshold to 64 bytes
839
			* in order to flush pause packets in Rx FIFO on Yukon-1
840
			*/
841
			Word++;
842
		}
843
844
		/* set Rx GMAC FIFO Flush Threshold (after clearing reset) */
845
		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_THR), Word);
846
847
		/* Configure Tx GMAC FIFO */
641
		SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);
848
		SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);
642
		SK_OUT16(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U16)GMF_TX_CTRL_DEF);
849
		SK_OUT16(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U16)GMF_TX_CTRL_DEF);
643
		
850
644
#ifdef VCPU
645
		SK_IN32(IoC, MR_ADDR(Port, RX_GMF_AF_THR), &DWord);
646
		SK_IN32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), &DWord);
647
#endif /* VCPU */
648
		
649
		/* set Tx GMAC FIFO Almost Empty Threshold */
851
		/* set Tx GMAC FIFO Almost Empty Threshold */
650
/*		SK_OUT32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), 0); */
852
/*		SK_OUT32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), 0); */
651
	}
853
	}
Lines 653-659 Link Here
653
855
654
}	/* SkGeInitMacFifo */
856
}	/* SkGeInitMacFifo */
655
857
656
#ifdef	SK_LNK_SYNC_CNT
858
#ifdef SK_LNK_SYNC_CNT
657
/******************************************************************************
859
/******************************************************************************
658
 *
860
 *
659
 *	SkGeLoadLnkSyncCnt() - Load the Link Sync Counter and starts counting
861
 *	SkGeLoadLnkSyncCnt() - Load the Link Sync Counter and starts counting
Lines 674-681 Link Here
674
 *	nothing
876
 *	nothing
675
 */
877
 */
676
void SkGeLoadLnkSyncCnt(
878
void SkGeLoadLnkSyncCnt(
677
SK_AC	*pAC,		/* adapter context */
879
SK_AC	*pAC,		/* Adapter Context */
678
SK_IOC	IoC,		/* IO context */
880
SK_IOC	IoC,		/* I/O Context */
679
int		Port,		/* Port Index (MAC_1 + n) */
881
int		Port,		/* Port Index (MAC_1 + n) */
680
SK_U32	CntVal)		/* Counter value */
882
SK_U32	CntVal)		/* Counter value */
681
{
883
{
Lines 685-691 Link Here
685
	SK_BOOL	IrqPend;
887
	SK_BOOL	IrqPend;
686
888
687
	/* stop counter */
889
	/* stop counter */
688
	SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_STOP);
890
	SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LNK_STOP);
689
891
690
	/*
892
	/*
691
	 * ASIC problem:
893
	 * ASIC problem:
Lines 698-703 Link Here
698
	IrqPend = SK_FALSE;
900
	IrqPend = SK_FALSE;
699
	SK_IN32(IoC, B0_ISRC, &ISrc);
901
	SK_IN32(IoC, B0_ISRC, &ISrc);
700
	SK_IN32(IoC, B0_IMSK, &OrgIMsk);
902
	SK_IN32(IoC, B0_IMSK, &OrgIMsk);
903
	
701
	if (Port == MAC_1) {
904
	if (Port == MAC_1) {
702
		NewIMsk = OrgIMsk & ~IS_LNK_SYNC_M1;
905
		NewIMsk = OrgIMsk & ~IS_LNK_SYNC_M1;
703
		if ((ISrc & IS_LNK_SYNC_M1) != 0) {
906
		if ((ISrc & IS_LNK_SYNC_M1) != 0) {
Lines 710-715 Link Here
710
			IrqPend = SK_TRUE;
913
			IrqPend = SK_TRUE;
711
		}
914
		}
712
	}
915
	}
916
713
	if (!IrqPend) {
917
	if (!IrqPend) {
714
		SK_OUT32(IoC, B0_IMSK, NewIMsk);
918
		SK_OUT32(IoC, B0_IMSK, NewIMsk);
715
	}
919
	}
Lines 718-732 Link Here
718
	SK_OUT32(IoC, MR_ADDR(Port, LNK_SYNC_INI), CntVal);
922
	SK_OUT32(IoC, MR_ADDR(Port, LNK_SYNC_INI), CntVal);
719
923
720
	/* start counter */
924
	/* start counter */
721
	SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_START);
925
	SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LNK_START);
722
926
723
	if (!IrqPend) {
927
	if (!IrqPend) {
724
		/* clear the unexpected IRQ, and restore the interrupt mask */
928
		/* clear the unexpected IRQ */
725
		SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_CLR_IRQ);
929
		SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LNK_CLR_IRQ);
930
		
931
		/* restore the interrupt mask */
726
		SK_OUT32(IoC, B0_IMSK, OrgIMsk);
932
		SK_OUT32(IoC, B0_IMSK, OrgIMsk);
727
	}
933
	}
728
}	/* SkGeLoadLnkSyncCnt*/
934
}	/* SkGeLoadLnkSyncCnt*/
729
#endif	/* SK_LNK_SYNC_CNT */
935
#endif /* SK_LNK_SYNC_CNT */
730
936
731
#if defined(SK_DIAG) || defined(SK_CFG_SYNC)
937
#if defined(SK_DIAG) || defined(SK_CFG_SYNC)
732
/******************************************************************************
938
/******************************************************************************
Lines 758-765 Link Here
758
 *		synchronous queue is configured
964
 *		synchronous queue is configured
759
 */
965
 */
760
int SkGeCfgSync(
966
int SkGeCfgSync(
761
SK_AC	*pAC,		/* adapter context */
967
SK_AC	*pAC,		/* Adapter Context */
762
SK_IOC	IoC,		/* IO context */
968
SK_IOC	IoC,		/* I/O Context */
763
int		Port,		/* Port Index (MAC_1 + n) */
969
int		Port,		/* Port Index (MAC_1 + n) */
764
SK_U32	IntTime,	/* Interval Timer Value in units of 8ns */
970
SK_U32	IntTime,	/* Interval Timer Value in units of 8ns */
765
SK_U32	LimCount,	/* Number of bytes to transfer during IntTime */
971
SK_U32	LimCount,	/* Number of bytes to transfer during IntTime */
Lines 777-792 Link Here
777
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);
983
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);
778
		return(1);
984
		return(1);
779
	}
985
	}
780
	
986
781
	if (pAC->GIni.GP[Port].PXSQSize == 0) {
987
	if (pAC->GIni.GP[Port].PXSQSize == 0) {
782
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E009, SKERR_HWI_E009MSG);
988
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E009, SKERR_HWI_E009MSG);
783
		return(2);
989
		return(2);
784
	}
990
	}
785
	
991
786
	/* calculate register values */
992
	/* calculate register values */
787
	IntTime = (IntTime / 2) * pAC->GIni.GIHstClkFact / 100;
993
	IntTime = (IntTime / 2) * pAC->GIni.GIHstClkFact / 100;
788
	LimCount = LimCount / 8;
994
	LimCount = LimCount / 8;
789
	
995
790
	if (IntTime > TXA_MAX_VAL || LimCount > TXA_MAX_VAL) {
996
	if (IntTime > TXA_MAX_VAL || LimCount > TXA_MAX_VAL) {
791
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);
997
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);
792
		return(1);
998
		return(1);
Lines 804-816 Link Here
804
	 */
1010
	 */
805
	SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
1011
	SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
806
		TXA_ENA_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
1012
		TXA_ENA_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
807
	
1013
808
	SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), IntTime);
1014
	SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), IntTime);
809
	SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), LimCount);
1015
	SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), LimCount);
810
	
1016
811
	SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
1017
	SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
812
		(SK_U8)(SyncMode & (TXA_ENA_ALLOC | TXA_DIS_ALLOC)));
1018
		(SK_U8)(SyncMode & (TXA_ENA_ALLOC | TXA_DIS_ALLOC)));
813
	
1019
814
	if (IntTime != 0 || LimCount != 0) {
1020
	if (IntTime != 0 || LimCount != 0) {
815
		SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_DIS_FSYNC | TXA_START_RC);
1021
		SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_DIS_FSYNC | TXA_START_RC);
816
	}
1022
	}
Lines 831-840 Link Here
831
 * Returns:
1037
 * Returns:
832
 *	nothing
1038
 *	nothing
833
 */
1039
 */
834
static void DoInitRamQueue(
1040
void DoInitRamQueue(
835
SK_AC	*pAC,			/* adapter context */
1041
SK_AC	*pAC,			/* Adapter Context */
836
SK_IOC	IoC,			/* IO context */
1042
SK_IOC	IoC,			/* I/O Context */
837
int		QuIoOffs,		/* Queue IO Address Offset */
1043
int		QuIoOffs,		/* Queue I/O Address Offset */
838
SK_U32	QuStartAddr,	/* Queue Start Address */
1044
SK_U32	QuStartAddr,	/* Queue Start Address */
839
SK_U32	QuEndAddr,		/* Queue End Address */
1045
SK_U32	QuEndAddr,		/* Queue End Address */
840
int		QuType)			/* Queue Type (SK_RX_SRAM_Q|SK_RX_BRAM_Q|SK_TX_RAM_Q) */
1046
int		QuType)			/* Queue Type (SK_RX_SRAM_Q|SK_RX_BRAM_Q|SK_TX_RAM_Q) */
Lines 867-874 Link Here
867
1073
868
			/* continue with SK_RX_BRAM_Q */
1074
			/* continue with SK_RX_BRAM_Q */
869
		case SK_RX_BRAM_Q:
1075
		case SK_RX_BRAM_Q:
870
			/* write threshold for Rx Queue */
1076
			/* write threshold for Rx Queue (Pause packets) */
871
872
			SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_UTPP), RxUpThresVal);
1077
			SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_UTPP), RxUpThresVal);
873
			SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_LTPP), RxLoThresVal);
1078
			SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_LTPP), RxLoThresVal);
874
1079
Lines 911-918 Link Here
911
 *	nothing
1116
 *	nothing
912
 */
1117
 */
913
static void SkGeInitRamBufs(
1118
static void SkGeInitRamBufs(
914
SK_AC	*pAC,		/* adapter context */
1119
SK_AC	*pAC,		/* Adapter Context */
915
SK_IOC	IoC,		/* IO context */
1120
SK_IOC	IoC,		/* I/O Context */
916
int		Port)		/* Port Index (MAC_1 + n) */
1121
int		Port)		/* Port Index (MAC_1 + n) */
917
{
1122
{
918
	SK_GEPORT *pPrt;
1123
	SK_GEPORT *pPrt;
Lines 920-926 Link Here
920
1125
921
	pPrt = &pAC->GIni.GP[Port];
1126
	pPrt = &pAC->GIni.GP[Port];
922
1127
923
	if (pPrt->PRxQSize == SK_MIN_RXQ_SIZE) {
1128
	if (pPrt->PRxQSize <= SK_MIN_RXQ_SIZE) {
924
		RxQType = SK_RX_SRAM_Q; 	/* small Rx Queue */
1129
		RxQType = SK_RX_SRAM_Q; 	/* small Rx Queue */
925
	}
1130
	}
926
	else {
1131
	else {
Lines 929-938 Link Here
929
1134
930
	DoInitRamQueue(pAC, IoC, pPrt->PRxQOff, pPrt->PRxQRamStart,
1135
	DoInitRamQueue(pAC, IoC, pPrt->PRxQOff, pPrt->PRxQRamStart,
931
		pPrt->PRxQRamEnd, RxQType);
1136
		pPrt->PRxQRamEnd, RxQType);
932
	
1137
933
	DoInitRamQueue(pAC, IoC, pPrt->PXsQOff, pPrt->PXsQRamStart,
1138
	DoInitRamQueue(pAC, IoC, pPrt->PXsQOff, pPrt->PXsQRamStart,
934
		pPrt->PXsQRamEnd, SK_TX_RAM_Q);
1139
		pPrt->PXsQRamEnd, SK_TX_RAM_Q);
935
	
1140
936
	DoInitRamQueue(pAC, IoC, pPrt->PXaQOff, pPrt->PXaQRamStart,
1141
	DoInitRamQueue(pAC, IoC, pPrt->PXaQOff, pPrt->PXaQRamStart,
937
		pPrt->PXaQRamEnd, SK_TX_RAM_Q);
1142
		pPrt->PXaQRamEnd, SK_TX_RAM_Q);
938
1143
Lines 953-978 Link Here
953
 *	nothing
1158
 *	nothing
954
 */
1159
 */
955
void SkGeInitRamIface(
1160
void SkGeInitRamIface(
956
SK_AC	*pAC,		/* adapter context */
1161
SK_AC	*pAC,		/* Adapter Context */
957
SK_IOC	IoC)		/* IO context */
1162
SK_IOC	IoC)		/* I/O Context */
958
{
1163
{
959
	/* release local reset */
1164
	int i;
960
	SK_OUT16(IoC, B3_RI_CTRL, RI_RST_CLR);
1165
	int RamBuffers;
961
1166
962
	/* configure timeout values */
1167
	if (CHIP_ID_YUKON_2(pAC)) {
963
	SK_OUT8(IoC, B3_RI_WTO_R1, SK_RI_TO_53);
1168
		RamBuffers = pAC->GIni.GIMacsFound;
964
	SK_OUT8(IoC, B3_RI_WTO_XA1, SK_RI_TO_53);
1169
	}
965
	SK_OUT8(IoC, B3_RI_WTO_XS1, SK_RI_TO_53);
1170
	else {
966
	SK_OUT8(IoC, B3_RI_RTO_R1, SK_RI_TO_53);
1171
		RamBuffers = 1;
967
	SK_OUT8(IoC, B3_RI_RTO_XA1, SK_RI_TO_53);
1172
	}
968
	SK_OUT8(IoC, B3_RI_RTO_XS1, SK_RI_TO_53);
1173
	
969
	SK_OUT8(IoC, B3_RI_WTO_R2, SK_RI_TO_53);
1174
	for (i = 0; i < RamBuffers; i++) {
970
	SK_OUT8(IoC, B3_RI_WTO_XA2, SK_RI_TO_53);
1175
		/* release local reset */
971
	SK_OUT8(IoC, B3_RI_WTO_XS2, SK_RI_TO_53);
1176
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_CTRL), (SK_U8)RI_RST_CLR);
972
	SK_OUT8(IoC, B3_RI_RTO_R2, SK_RI_TO_53);
973
	SK_OUT8(IoC, B3_RI_RTO_XA2, SK_RI_TO_53);
974
	SK_OUT8(IoC, B3_RI_RTO_XS2, SK_RI_TO_53);
975
1177
1178
		/* configure timeout values */
1179
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_WTO_R1), SK_RI_TO_53);
1180
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_WTO_XA1), SK_RI_TO_53);
1181
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_WTO_XS1), SK_RI_TO_53);
1182
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_RTO_R1), SK_RI_TO_53);
1183
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_RTO_XA1), SK_RI_TO_53);
1184
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_RTO_XS1), SK_RI_TO_53);
1185
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_WTO_R2), SK_RI_TO_53);
1186
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_WTO_XA2), SK_RI_TO_53);
1187
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_WTO_XS2), SK_RI_TO_53);
1188
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_RTO_R2), SK_RI_TO_53);
1189
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_RTO_XA2), SK_RI_TO_53);
1190
		SK_OUT8(IoC, SELECT_RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53);
1191
	}
976
}	/* SkGeInitRamIface */
1192
}	/* SkGeInitRamIface */
977
1193
978
1194
Lines 987-994 Link Here
987
 *	nothing
1203
 *	nothing
988
 */
1204
 */
989
static void SkGeInitBmu(
1205
static void SkGeInitBmu(
990
SK_AC	*pAC,		/* adapter context */
1206
SK_AC	*pAC,		/* Adapter Context */
991
SK_IOC	IoC,		/* IO context */
1207
SK_IOC	IoC,		/* I/O Context */
992
int		Port)		/* Port Index (MAC_1 + n) */
1208
int		Port)		/* Port Index (MAC_1 + n) */
993
{
1209
{
994
	SK_GEPORT	*pPrt;
1210
	SK_GEPORT	*pPrt;
Lines 999-1027 Link Here
999
1215
1000
	RxWm = SK_BMU_RX_WM;
1216
	RxWm = SK_BMU_RX_WM;
1001
	TxWm = SK_BMU_TX_WM;
1217
	TxWm = SK_BMU_TX_WM;
1002
	
1003
	if (!pAC->GIni.GIPciSlot64 && !pAC->GIni.GIPciClock66) {
1004
		/* for better performance */
1005
		RxWm /= 2;
1006
		TxWm /= 2;
1007
	}
1008
1218
1009
	/* Rx Queue: Release all local resets and set the watermark */
1219
	if (CHIP_ID_YUKON_2(pAC)) {
1010
	SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_CLR_RESET);
1011
	SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_F), RxWm);
1012
1220
1013
	/*
1221
		if (pAC->GIni.GIPciBus == SK_PEX_BUS) {
1014
	 * Tx Queue: Release all local resets if the queue is used !
1222
			/* for better performance set it to 128 */
1015
	 * 		set watermark
1223
			RxWm = SK_BMU_RX_WM_PEX;		
1016
	 */
1224
		}
1017
	if (pPrt->PXSQSize != 0) {
1225
1018
		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_CLR_RESET);
1226
		/* Rx Queue: Release all local resets and set the watermark */
1019
		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_F), TxWm);
1227
		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), BMU_CLR_RESET);
1228
		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), BMU_OPER_INIT);
1229
		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), BMU_FIFO_OP_ON);
1230
		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_WM), RxWm);
1231
1232
		/*
1233
		 * Tx Queue: Release all local resets if the queue is used !
1234
		 * 		set watermark
1235
		 */
1236
		if (pPrt->PXSQSize != 0 && HW_SYNC_TX_SUPPORTED(pAC)) {
1237
			/* Yukon-EC doesn't have a synchronous Tx queue */
1238
			SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), BMU_CLR_RESET);
1239
			SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), BMU_OPER_INIT);
1240
			SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), BMU_FIFO_OP_ON);
1241
			SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_WM), TxWm);
1242
		}
1243
		
1244
		if (pPrt->PXAQSize != 0) {
1245
			SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), BMU_CLR_RESET);
1246
			SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), BMU_OPER_INIT);
1247
			SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), BMU_FIFO_OP_ON);
1248
			SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_WM), TxWm);
1249
		}
1020
	}
1250
	}
1021
	
1251
	else {
1022
	if (pPrt->PXAQSize != 0) {
1252
		if (!pAC->GIni.GIPciSlot64 && !pAC->GIni.GIPciClock66) {
1023
		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_CLR_RESET);
1253
			/* for better performance */
1024
		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_F), TxWm);
1254
			RxWm /= 2;
1255
			TxWm /= 2;
1256
		}
1257
1258
		/* Rx Queue: Release all local resets and set the watermark */
1259
		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_CLR_RESET);
1260
		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_F), RxWm);
1261
1262
		/*
1263
		 * Tx Queue: Release all local resets if the queue is used !
1264
		 * 		set watermark
1265
		 */
1266
		if (pPrt->PXSQSize != 0) {
1267
			SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_CLR_RESET);
1268
			SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_F), TxWm);
1269
		}
1270
1271
		if (pPrt->PXAQSize != 0) {
1272
			SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_CLR_RESET);
1273
			SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_F), TxWm);
1274
		}
1025
	}
1275
	}
1026
	/*
1276
	/*
1027
	 * Do NOT enable the descriptor poll timers here, because
1277
	 * Do NOT enable the descriptor poll timers here, because
Lines 1045-1064 Link Here
1045
 */
1295
 */
1046
static SK_U32 TestStopBit(
1296
static SK_U32 TestStopBit(
1047
SK_AC	*pAC,		/* Adapter Context */
1297
SK_AC	*pAC,		/* Adapter Context */
1048
SK_IOC	IoC,		/* IO Context */
1298
SK_IOC	IoC,		/* I/O Context */
1049
int		QuIoOffs)	/* Queue IO Address Offset */
1299
int		QuIoOffs)	/* Queue I/O Address Offset */
1050
{
1300
{
1051
	SK_U32	QuCsr;	/* CSR contents */
1301
	SK_U32	QuCsr;	/* CSR contents */
1052
1302
1053
	SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);
1303
	SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);
1054
	
1304
	
1055
	if ((QuCsr & (CSR_STOP | CSR_SV_IDLE)) == 0) {
1305
	if (CHIP_ID_YUKON_2(pAC)) {
1056
		/* Stop Descriptor overridden by start command */
1306
		if ((QuCsr & (BMU_STOP | BMU_IDLE)) == 0) {
1057
		SK_OUT32(IoC, Q_ADDR(QuIoOffs, Q_CSR), CSR_STOP);
1307
			/* Stop Descriptor overridden by start command */
1308
			SK_OUT32(IoC, Q_ADDR(QuIoOffs, Q_CSR), BMU_STOP);
1058
1309
1059
		SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);
1310
			SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);
1311
		}
1312
	}
1313
	else {
1314
		if ((QuCsr & (CSR_STOP | CSR_SV_IDLE)) == 0) {
1315
			/* Stop Descriptor overridden by start command */
1316
			SK_OUT32(IoC, Q_ADDR(QuIoOffs, Q_CSR), CSR_STOP);
1317
1318
			SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);
1319
		}
1060
	}
1320
	}
1061
	
1062
	return(QuCsr);
1321
	return(QuCsr);
1063
}	/* TestStopBit */
1322
}	/* TestStopBit */
1064
1323
Lines 1142-1197 Link Here
1142
 *	  SWITCH_PORT.
1401
 *	  SWITCH_PORT.
1143
 */
1402
 */
1144
void SkGeStopPort(
1403
void SkGeStopPort(
1145
SK_AC	*pAC,	/* adapter context */
1404
SK_AC	*pAC,	/* Adapter Context */
1146
SK_IOC	IoC,	/* I/O context */
1405
SK_IOC	IoC,	/* I/O Context */
1147
int		Port,	/* port to stop (MAC_1 + n) */
1406
int		Port,	/* Port to stop (MAC_1 + n) */
1148
int		Dir,	/* Direction to Stop (SK_STOP_RX, SK_STOP_TX, SK_STOP_ALL) */
1407
int		Dir,	/* Direction to Stop (SK_STOP_RX, SK_STOP_TX, SK_STOP_ALL) */
1149
int		RstMode)/* Reset Mode (SK_SOFT_RST, SK_HARD_RST) */
1408
int		RstMode)/* Reset Mode (SK_SOFT_RST, SK_HARD_RST) */
1150
{
1409
{
1151
#ifndef SK_DIAG
1152
	SK_EVPARA Para;
1153
#endif /* !SK_DIAG */
1154
	SK_GEPORT *pPrt;
1410
	SK_GEPORT *pPrt;
1155
	SK_U32	DWord;
1411
	SK_U32	RxCsr;
1156
	SK_U32	XsCsr;
1412
	SK_U32	XsCsr;
1157
	SK_U32	XaCsr;
1413
	SK_U32	XaCsr;
1158
	SK_U64	ToutStart;
1414
	SK_U64	ToutStart;
1415
	SK_U32	CsrStart;
1416
	SK_U32	CsrStop;
1417
	SK_U32	CsrIdle;
1418
	SK_U32	CsrTest;
1419
	SK_U8 	rsl;	/* FIFO read shadow level */
1420
	SK_U8	rl;		/* FIFO read level */
1159
	int		i;
1421
	int		i;
1160
	int		ToutCnt;
1422
	int		ToutCnt;
1161
1423
1162
	pPrt = &pAC->GIni.GP[Port];
1424
	pPrt = &pAC->GIni.GP[Port];
1163
1425
1426
	/* set the proper values of Q_CSR register layout depending on the chip id */
1427
	if (CHIP_ID_YUKON_2(pAC)) {
1428
		CsrStart = BMU_START;
1429
		CsrStop = BMU_STOP;
1430
		CsrIdle = BMU_IDLE;
1431
		CsrTest = BMU_IDLE;
1432
	}
1433
	else {
1434
		CsrStart = CSR_START;
1435
		CsrStop = CSR_STOP;
1436
		CsrIdle = CSR_SV_IDLE;
1437
		CsrTest = CSR_SV_IDLE | CSR_STOP;
1438
	}
1439
1164
	if ((Dir & SK_STOP_TX) != 0) {
1440
	if ((Dir & SK_STOP_TX) != 0) {
1165
		/* disable receiver and transmitter */
1441
1166
		SkMacRxTxDisable(pAC, IoC, Port);
1442
		if (!pAC->GIni.GIAsfEnabled) {
1167
		
1443
			/* disable receiver and transmitter */
1444
			SkMacRxTxDisable(pAC, IoC, Port);
1445
		}
1446
1168
		/* stop both transmit queues */
1447
		/* stop both transmit queues */
1169
		/*
1448
		/*
1170
		 * If the BMU is in the reset state CSR_STOP will terminate
1449
		 * If the BMU is in the reset state CSR_STOP will terminate
1171
		 * immediately.
1450
		 * immediately.
1172
		 */
1451
		 */
1173
		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_STOP);
1452
		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CsrStop);
1174
		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_STOP);
1453
		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CsrStop);
1175
1454
1176
		ToutStart = SkOsGetTime(pAC);
1455
		ToutStart = SkOsGetTime(pAC);
1177
		ToutCnt = 0;
1456
		ToutCnt = 0;
1178
		do {
1457
		do {
1179
			/*
1458
#ifdef GENESIS
1180
			 * Clear packet arbiter timeout to make sure
1459
			if (pAC->GIni.GIGenesis) {
1181
			 * this loop will terminate.
1460
				/* clear Tx packet arbiter timeout IRQ */
1182
			 */
1461
				SK_OUT16(IoC, B3_PA_CTRL, (SK_U16)((Port == MAC_1) ?
1183
			SK_OUT16(IoC, B3_PA_CTRL, (SK_U16)((Port == MAC_1) ?
1462
					PA_CLR_TO_TX1 : PA_CLR_TO_TX2));
1184
				PA_CLR_TO_TX1 : PA_CLR_TO_TX2));
1463
				/*
1185
1464
				 * If the transfer stucks at the MAC the STOP command will not
1186
			/*
1465
				 * terminate if we don't flush the XMAC's transmit FIFO !
1187
			 * If the transfer stucks at the MAC the STOP command will not
1466
				 */
1188
			 * terminate if we don't flush the XMAC's transmit FIFO !
1467
				SkMacFlushTxFifo(pAC, IoC, Port);
1189
			 */
1468
			}
1190
			SkMacFlushTxFifo(pAC, IoC, Port);
1469
#endif /* GENESIS */
1191
1470
			
1192
			XsCsr = TestStopBit(pAC, IoC, pPrt->PXsQOff);
1193
			XaCsr = TestStopBit(pAC, IoC, pPrt->PXaQOff);
1471
			XaCsr = TestStopBit(pAC, IoC, pPrt->PXaQOff);
1194
1472
1473
			if (HW_SYNC_TX_SUPPORTED(pAC)) {
1474
				XsCsr = TestStopBit(pAC, IoC, pPrt->PXsQOff);
1475
			}
1476
			else {
1477
				XsCsr = XaCsr;
1478
			}
1479
1195
			if (SkOsGetTime(pAC) - ToutStart > (SK_TICKS_PER_SEC / 18)) {
1480
			if (SkOsGetTime(pAC) - ToutStart > (SK_TICKS_PER_SEC / 18)) {
1196
				/*
1481
				/*
1197
				 * Timeout of 1/18 second reached.
1482
				 * Timeout of 1/18 second reached.
Lines 1199-1265 Link Here
1199
				 */
1484
				 */
1200
				ToutCnt++;
1485
				ToutCnt++;
1201
				if (ToutCnt > 1) {
1486
				if (ToutCnt > 1) {
1202
					/* Might be a problem when the driver event handler
1487
					/*
1203
					 * calls StopPort again. XXX.
1488
					 * If BMU stop doesn't terminate, we assume
1489
					 * we have a stable state and can reset the
1490
					 * BMU, Pref Unit, and RAM buffer now.
1204
					 */
1491
					 */
1205
1492
					break;				/* ====> leave do/while loop here */
1206
					/* Fatal Error, Loop aborted */
1207
					SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E018,
1208
						SKERR_HWI_E018MSG);
1209
#ifndef SK_DIAG
1210
					Para.Para64 = Port;
1211
					SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
1212
#endif /* !SK_DIAG */
1213
					return;
1214
				}
1493
				}
1215
				/*
1494
				/*
1216
				 * Cache incoherency workaround: Assume a start command
1495
				 * Cache incoherency workaround: assume a start command
1217
				 * has been lost while sending the frame.
1496
				 * has been lost while sending the frame.
1218
				 */
1497
				 */
1219
				ToutStart = SkOsGetTime(pAC);
1498
				ToutStart = SkOsGetTime(pAC);
1220
1499
1221
				if ((XsCsr & CSR_STOP) != 0) {
1500
				if ((XsCsr & CsrStop) != 0) {
1222
					SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_START);
1501
					SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CsrStart);
1223
				}
1502
				}
1224
				if ((XaCsr & CSR_STOP) != 0) {
1503
				if ((XaCsr & CsrStop) != 0) {
1225
					SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_START);
1504
					SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CsrStart);
1226
				}
1505
				}
1227
			}
1228
1506
1507
				/*
1508
				 * After the previous operations the X(s|a)Csr does no
1509
				 * longer contain the proper values
1510
				 */
1511
				XaCsr = TestStopBit(pAC, IoC, pPrt->PXaQOff);
1512
1513
				if (HW_SYNC_TX_SUPPORTED(pAC)) {
1514
					XsCsr = TestStopBit(pAC, IoC, pPrt->PXsQOff);
1515
				}
1516
				else {
1517
					XsCsr = XaCsr;
1518
				}
1519
			}
1229
			/*
1520
			/*
1230
			 * Because of the ASIC problem report entry from 21.08.1998 it is
1521
			 * Because of the ASIC problem report entry from 21.08.1998 it is
1231
			 * required to wait until CSR_STOP is reset and CSR_SV_IDLE is set.
1522
			 * required to wait until CSR_STOP is reset and CSR_SV_IDLE is set.
1523
			 * (valid for GENESIS only)
1232
			 */
1524
			 */
1233
		} while ((XsCsr & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE ||
1525
		} while (((XsCsr & CsrTest) != CsrIdle ||
1234
				 (XaCsr & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE);
1526
				  (XaCsr & CsrTest) != CsrIdle));
1527
1528
		if (pAC->GIni.GIAsfEnabled) {
1235
1529
1236
		/* Reset the MAC depending on the RstMode */
1530
			pPrt->PState = (RstMode == SK_SOFT_RST) ? SK_PRT_STOP :
1237
		if (RstMode == SK_SOFT_RST) {
1531
				SK_PRT_RESET;
1238
			SkMacSoftRst(pAC, IoC, Port);
1239
		}
1532
		}
1240
		else {
1533
		else {
1241
			SkMacHardRst(pAC, IoC, Port);
1534
			/* Reset the MAC depending on the RstMode */
1535
			if (RstMode == SK_SOFT_RST) {
1536
1537
				SkMacSoftRst(pAC, IoC, Port);
1538
			}
1539
			else {
1540
				if (HW_FEATURE(pAC, HWF_WA_DEV_472) && Port == MAC_1 &&
1541
					pAC->GIni.GP[MAC_2].PState == SK_PRT_RUN) {
1542
1543
					pAC->GIni.GP[MAC_1].PState = SK_PRT_RESET;
1544
1545
					/* set GPHY Control reset */
1546
					SK_OUT8(IoC, MR_ADDR(MAC_1, GPHY_CTRL), (SK_U8)GPC_RST_SET);
1547
				}
1548
				else {
1549
1550
					SkMacHardRst(pAC, IoC, Port);
1551
				}
1552
			}
1242
		}
1553
		}
1243
 		
1554
1244
		/* Disable Force Sync bit and Enable Alloc bit */
1555
		/* disable Force Sync bit and Enable Alloc bit */
1245
		SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
1556
		SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),
1246
			TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
1557
			TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
1247
		
1558
1248
		/* Stop Interval Timer and Limit Counter of Tx Arbiter */
1559
		/* Stop Interval Timer and Limit Counter of Tx Arbiter */
1249
		SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), 0L);
1560
		SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), 0L);
1250
		SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), 0L);
1561
		SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), 0L);
1251
1562
1252
		/* Perform a local reset of the port's Tx path */
1563
		/* Perform a local reset of the port's Tx path */
1564
		if (CHIP_ID_YUKON_2(pAC)) {
1565
			/* Reset the PCI FIFO of the async Tx queue */
1566
			SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR),
1567
				BMU_RST_SET | BMU_FIFO_RST);
1568
			/* Reset the PCI FIFO of the sync Tx queue */
1569
			SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR),
1570
				BMU_RST_SET | BMU_FIFO_RST);
1571
			/* Reset the Tx prefetch units */
1572
			SK_OUT32(IoC, Y2_PREF_Q_ADDR(pPrt->PXaQOff, PREF_UNIT_CTRL_REG),
1573
				PREF_UNIT_RST_SET);
1574
			SK_OUT32(IoC, Y2_PREF_Q_ADDR(pPrt->PXsQOff, PREF_UNIT_CTRL_REG),
1575
				PREF_UNIT_RST_SET);
1576
		}
1577
		else {
1578
			/* Reset the PCI FIFO of the async Tx queue */
1579
			SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_SET_RESET);
1580
			/* Reset the PCI FIFO of the sync Tx queue */
1581
			SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_SET_RESET);
1582
		}
1253
1583
1254
		/* Reset the PCI FIFO of the async Tx queue */
1255
		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_SET_RESET);
1256
		/* Reset the PCI FIFO of the sync Tx queue */
1257
		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_SET_RESET);
1258
		/* Reset the RAM Buffer async Tx queue */
1584
		/* Reset the RAM Buffer async Tx queue */
1259
		SK_OUT8(IoC, RB_ADDR(pPrt->PXaQOff, RB_CTRL), RB_RST_SET);
1585
		SK_OUT8(IoC, RB_ADDR(pPrt->PXaQOff, RB_CTRL), RB_RST_SET);
1260
		/* Reset the RAM Buffer sync Tx queue */
1586
		/* Reset the RAM Buffer sync Tx queue */
1261
		SK_OUT8(IoC, RB_ADDR(pPrt->PXsQOff, RB_CTRL), RB_RST_SET);
1587
		SK_OUT8(IoC, RB_ADDR(pPrt->PXsQOff, RB_CTRL), RB_RST_SET);
1262
		
1588
1263
		/* Reset Tx MAC FIFO */
1589
		/* Reset Tx MAC FIFO */
1264
#ifdef GENESIS
1590
#ifdef GENESIS
1265
		if (pAC->GIni.GIGenesis) {
1591
		if (pAC->GIni.GIGenesis) {
Lines 1271-1341 Link Here
1271
			SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_DIS);
1597
			SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_DIS);
1272
		}
1598
		}
1273
#endif /* GENESIS */
1599
#endif /* GENESIS */
1274
	
1600
1275
#ifdef YUKON
1601
#ifdef YUKON
1276
		if (pAC->GIni.GIYukon) {
1602
		if (pAC->GIni.GIYukon && !pAC->GIni.GIAsfEnabled) {
1277
			/* Reset TX MAC FIFO */
1603
			/* Reset Tx MAC FIFO */
1278
			SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U8)GMF_RST_SET);
1604
			SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U8)GMF_RST_SET);
1279
		}
1605
		}
1606
1607
		/* set Pause Off */
1608
		SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_PAUSE_OFF);
1280
#endif /* YUKON */
1609
#endif /* YUKON */
1281
	}
1610
	}
1282
1611
1283
	if ((Dir & SK_STOP_RX) != 0) {
1612
	if ((Dir & SK_STOP_RX) != 0) {
1284
		/*
1285
		 * The RX Stop Command will not terminate if no buffers
1286
		 * are queued in the RxD ring. But it will always reach
1287
		 * the Idle state. Therefore we can use this feature to
1288
		 * stop the transfer of received packets.
1289
		 */
1290
		/* stop the port's receive queue */
1291
		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_STOP);
1292
		
1613
		
1293
		i = 100;
1614
		if (CHIP_ID_YUKON_2(pAC)) {
1294
		do {
1295
			/*
1615
			/*
1296
			 * Clear packet arbiter timeout to make sure
1616
			 * The RX Stop command will not work for Yukon-2 if the BMU does not
1297
			 * this loop will terminate
1617
			 * reach the end of packet and since we can't make sure that we have
1618
			 * incoming data, we must reset the BMU while it is not during a DMA
1619
			 * transfer. Since it is possible that the RX path is still active,
1620
			 * the RX RAM buffer will be stopped first, so any possible incoming
1621
			 * data will not trigger a DMA. After the RAM buffer is stopped, the
1622
			 * BMU is polled until any DMA in progress is ended and only then it
1623
			 * will be reset.
1298
			 */
1624
			 */
1299
			SK_OUT16(IoC, B3_PA_CTRL, (SK_U16)((Port == MAC_1) ?
1300
				PA_CLR_TO_RX1 : PA_CLR_TO_RX2));
1301
1625
1302
			DWord = TestStopBit(pAC, IoC, pPrt->PRxQOff);
1626
			/* disable the RAM Buffer receive queue */
1627
			SK_OUT8(IoC, RB_ADDR(pPrt->PRxQOff, RB_CTRL), RB_DIS_OP_MD);
1303
1628
1304
			/* timeout if i==0 (bug fix for #10748) */
1629
			i = 0xffff;
1305
			if (--i == 0) {
1630
			while (--i) {
1306
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E024,
1631
				SK_IN8(IoC, RB_ADDR(pPrt->PRxQOff, Q_RSL), &rsl);
1307
					SKERR_HWI_E024MSG);
1632
				SK_IN8(IoC, RB_ADDR(pPrt->PRxQOff, Q_RL), &rl);
1308
				break;
1633
				
1634
				if (rsl == rl) {
1635
					break;
1636
				}
1309
			}
1637
			}
1638
1310
			/*
1639
			/*
1311
			 * because of the ASIC problem report entry from 21.08.98
1640
			 * If the Rx side is blocked, the above loop cannot terminate.
1312
			 * it is required to wait until CSR_STOP is reset and
1641
			 * But, if there was any traffic it should be terminated, now.
1313
			 * CSR_SV_IDLE is set.
1642
			 * However, stop the RX BMU and prefetch unit !
1314
			 */
1643
			 */
1315
		} while ((DWord & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE);
1644
			SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR),
1645
				BMU_RST_SET | BMU_FIFO_RST);
1646
			/* reset the Rx prefetch unit */
1647
			SK_OUT32(IoC, Y2_PREF_Q_ADDR(pPrt->PRxQOff, PREF_UNIT_CTRL_REG),
1648
				PREF_UNIT_RST_SET);
1649
		}
1650
		else {
1651
			/*
1652
			 * The RX Stop Command will not terminate if no buffers
1653
			 * are queued in the RxD ring. But it will always reach
1654
			 * the Idle state. Therefore we can use this feature to
1655
			 * stop the transfer of received packets.
1656
			 */
1657
			/* stop the port's receive queue */
1658
			SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CsrStop);
1316
1659
1317
		/* The path data transfer activity is fully stopped now */
1660
			i = 100;
1661
			do {
1662
#ifdef GENESIS
1663
				if (pAC->GIni.GIGenesis) {
1664
					/* clear Rx packet arbiter timeout IRQ */
1665
					SK_OUT16(IoC, B3_PA_CTRL, (SK_U16)((Port == MAC_1) ?
1666
						PA_CLR_TO_RX1 : PA_CLR_TO_RX2));
1667
				}
1668
#endif /* GENESIS */
1318
1669
1319
		/* Perform a local reset of the port's Rx path */
1670
				RxCsr = TestStopBit(pAC, IoC, pPrt->PRxQOff);
1671
1672
				/* timeout if i==0 (bug fix for #10748) */
1673
				if (--i == 0) {
1674
					SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E024,
1675
						SKERR_HWI_E024MSG);
1676
					break;
1677
				}
1678
			/*
1679
			 * Because of the ASIC problem report entry from 21.08.1998 it is
1680
			 * required to wait until CSR_STOP is reset and CSR_SV_IDLE is set.
1681
			 * (valid for GENESIS only)
1682
			 */
1683
			} while ((RxCsr & CsrTest) != CsrIdle);
1684
			/* The path data transfer activity is fully stopped now */
1685
1686
			/* Perform a local reset of the port's Rx path */
1687
			/*	Reset the PCI FIFO of the Rx queue */
1688
			SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_SET_RESET);
1689
		}
1320
1690
1321
		 /*	Reset the PCI FIFO of the Rx queue */
1322
		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_SET_RESET);
1323
		/* Reset the RAM Buffer receive queue */
1691
		/* Reset the RAM Buffer receive queue */
1324
		SK_OUT8(IoC, RB_ADDR(pPrt->PRxQOff, RB_CTRL), RB_RST_SET);
1692
		SK_OUT8(IoC, RB_ADDR(pPrt->PRxQOff, RB_CTRL), RB_RST_SET);
1325
1693
1326
		/* Reset Rx MAC FIFO */
1694
		/* Reset Rx MAC FIFO */
1327
#ifdef GENESIS
1695
#ifdef GENESIS
1328
		if (pAC->GIni.GIGenesis) {
1696
		if (pAC->GIni.GIGenesis) {
1329
			
1697
1330
			SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_SET);
1698
			SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_SET);
1331
1699
1332
			/* switch Rx LED off, stop the LED counter */
1700
			/* switch Rx LED off, stop the LED counter */
1333
			SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_DIS);
1701
			SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_DIS);
1334
		}
1702
		}
1335
#endif /* GENESIS */
1703
#endif /* GENESIS */
1336
	
1704
1337
#ifdef YUKON
1705
#ifdef YUKON
1338
		if (pAC->GIni.GIYukon) {
1706
		if (pAC->GIni.GIYukon && !pAC->GIni.GIAsfEnabled) {
1339
			/* Reset Rx MAC FIFO */
1707
			/* Reset Rx MAC FIFO */
1340
			SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_SET);
1708
			SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_SET);
1341
		}
1709
		}
Lines 1355-1362 Link Here
1355
 *	nothing
1723
 *	nothing
1356
 */
1724
 */
1357
static void SkGeInit0(
1725
static void SkGeInit0(
1358
SK_AC	*pAC,		/* adapter context */
1726
SK_AC	*pAC,		/* Adapter Context */
1359
SK_IOC	IoC)		/* IO context */
1727
SK_IOC	IoC)		/* I/O Context */
1360
{
1728
{
1361
	int i;
1729
	int i;
1362
	SK_GEPORT *pPrt;
1730
	SK_GEPORT *pPrt;
Lines 1393-1416 Link Here
1393
		pPrt->PLipaAutoNeg = (SK_U8)SK_LIPA_UNKNOWN;
1761
		pPrt->PLipaAutoNeg = (SK_U8)SK_LIPA_UNKNOWN;
1394
		pPrt->PAutoNegFail = SK_FALSE;
1762
		pPrt->PAutoNegFail = SK_FALSE;
1395
		pPrt->PHWLinkUp = SK_FALSE;
1763
		pPrt->PHWLinkUp = SK_FALSE;
1396
		pPrt->PLinkBroken = SK_TRUE; /* See WA code */
1764
		pPrt->PLinkBroken = SK_TRUE;	/* See WA code */
1397
		pPrt->PPhyPowerState = PHY_PM_OPERATIONAL_MODE;
1765
		pPrt->PPhyPowerState = PHY_PM_OPERATIONAL_MODE;
1398
		pPrt->PMacColThres = TX_COL_DEF;
1766
		pPrt->PMacColThres = TX_COL_DEF;
1399
		pPrt->PMacJamLen = TX_JAM_LEN_DEF;
1767
		pPrt->PMacJamLen = TX_JAM_LEN_DEF;
1400
		pPrt->PMacJamIpgVal	= TX_JAM_IPG_DEF;
1768
		pPrt->PMacJamIpgVal	= TX_JAM_IPG_DEF;
1401
		pPrt->PMacJamIpgData = TX_IPG_JAM_DEF;
1769
		pPrt->PMacJamIpgData = TX_IPG_JAM_DEF;
1770
		pPrt->PMacBackOffLim = TX_BOF_LIM_DEF;
1771
		pPrt->PMacDataBlind = DATA_BLIND_DEF;
1402
		pPrt->PMacIpgData = IPG_DATA_DEF;
1772
		pPrt->PMacIpgData = IPG_DATA_DEF;
1403
		pPrt->PMacLimit4 = SK_FALSE;
1773
		pPrt->PMacLimit4 = SK_FALSE;
1404
	}
1774
	}
1405
1775
1406
	pAC->GIni.GIPortUsage = SK_RED_LINK;
1776
	pAC->GIni.GIPortUsage = SK_RED_LINK;
1407
	pAC->GIni.GILedBlinkCtrl = (SK_U16)OemConfig.Value;
1777
	pAC->GIni.GILedBlinkCtrl = (SK_U16)OemConfig.Value;
1408
	pAC->GIni.GIValIrqMask = IS_ALL_MSK;
1778
	pAC->GIni.GIChipCap = 0;
1779
1780
	for (i = 0; i < 4; i++) {
1781
		pAC->GIni.HwF.Features[i]= 0x00000000;
1782
		pAC->GIni.HwF.OnMask[i]	 = 0x00000000;
1783
		pAC->GIni.HwF.OffMask[i] = 0x00000000;
1784
	}
1409
1785
1410
}	/* SkGeInit0*/
1786
}	/* SkGeInit0*/
1411
1787
1412
#ifdef SK_PCI_RESET
1788
#ifdef SK_PCI_RESET
1413
1414
/******************************************************************************
1789
/******************************************************************************
1415
 *
1790
 *
1416
 *	SkGePciReset() - Reset PCI interface
1791
 *	SkGePciReset() - Reset PCI interface
Lines 1426-1433 Link Here
1426
 *	1:	Power state could not be changed to 3.
1801
 *	1:	Power state could not be changed to 3.
1427
 */
1802
 */
1428
static int SkGePciReset(
1803
static int SkGePciReset(
1429
SK_AC	*pAC,		/* adapter context */
1804
SK_AC	*pAC,		/* Adapter Context */
1430
SK_IOC	IoC)		/* IO context */
1805
SK_IOC	IoC)		/* I/O Context */
1431
{
1806
{
1432
	int		i;
1807
	int		i;
1433
	SK_U16	PmCtlSts;
1808
	SK_U16	PmCtlSts;
Lines 1450-1456 Link Here
1450
	/* We know the RAM Interface Arbiter is enabled. */
1825
	/* We know the RAM Interface Arbiter is enabled. */
1451
	SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D3);
1826
	SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D3);
1452
	SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
1827
	SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
1453
	
1828
1454
	if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D3) {
1829
	if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D3) {
1455
		return(1);
1830
		return(1);
1456
	}
1831
	}
Lines 1460-1466 Link Here
1460
1835
1461
	/* Check for D0 state. */
1836
	/* Check for D0 state. */
1462
	SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
1837
	SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
1463
	
1838
1464
	if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D0) {
1839
	if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D0) {
1465
		return(1);
1840
		return(1);
1466
	}
1841
	}
Lines 1469-1479 Link Here
1469
	SkPciReadCfgWord(pAC, PCI_COMMAND, &PciCmd);
1844
	SkPciReadCfgWord(pAC, PCI_COMMAND, &PciCmd);
1470
	SkPciReadCfgByte(pAC, PCI_CACHE_LSZ, &Cls);
1845
	SkPciReadCfgByte(pAC, PCI_CACHE_LSZ, &Cls);
1471
	SkPciReadCfgDWord(pAC, PCI_BASE_1ST, &Bp1);
1846
	SkPciReadCfgDWord(pAC, PCI_BASE_1ST, &Bp1);
1472
	SkPciReadCfgDWord(pAC, PCI_BASE_2ND, &Bp2);
1847
1848
	/*
1849
	 * Compute the location in PCI config space of BAR2
1850
	 * relativ to the location of BAR1
1851
	 */
1852
	if ((Bp1 & PCI_MEM_TYP_MSK) == PCI_MEM64BIT) {
1853
		/* BAR1 is 64 bits wide */
1854
		i = 8;
1855
	}
1856
	else {
1857
		i = 4;
1858
	}
1859
1860
	SkPciReadCfgDWord(pAC, PCI_BASE_1ST + i, &Bp2);
1473
	SkPciReadCfgByte(pAC, PCI_LAT_TIM, &Lat);
1861
	SkPciReadCfgByte(pAC, PCI_LAT_TIM, &Lat);
1474
	
1862
1475
	if (PciCmd != 0 || Cls != (SK_U8)0 || Lat != (SK_U8)0 ||
1863
	if (PciCmd != 0 || Cls != 0 || (Bp1 & 0xfffffff0L) != 0 || Bp2 != 1 ||
1476
		(Bp1 & 0xfffffff0L) != 0 || Bp2 != 1) {
1864
		Lat != 0) {
1477
		return(1);
1865
		return(1);
1478
	}
1866
	}
1479
1867
Lines 1484-1492 Link Here
1484
1872
1485
	return(0);
1873
	return(0);
1486
}	/* SkGePciReset */
1874
}	/* SkGePciReset */
1487
1488
#endif /* SK_PCI_RESET */
1875
#endif /* SK_PCI_RESET */
1489
1876
1877
1878
/******************************************************************************
1879
 *
1880
 *	SkGeSetUpSupFeatures() - Collect Feature List for HW_FEATURE Macro
1881
 *
1882
 * Description:
1883
 *	This function collects the available features and required
1884
 *	deviation services of the Adapter and provides these
1885
 *	information in the GIHwF struct. This information is used as
1886
 *	default value and may be overritten by the driver using the
1887
 *	SET_HW_FEATURE_MASK() macro in its Init0 phase.
1888
 *
1889
 * Notice:
1890
 *	Using the On and Off mask: Never switch on the same bit in both
1891
 *	masks simultaneously. However, if doing the Off mask will win.
1892
 *
1893
 * Returns:
1894
 *	nothing
1895
 */
1896
static void SkGeSetUpSupFeatures(
1897
SK_AC	*pAC,		/* Adapter Context */
1898
SK_IOC	IoC)		/* I/O Context */
1899
{
1900
	int i;
1901
1902
	switch (pAC->GIni.GIChipId) {
1903
	case CHIP_ID_YUKON_EC:
1904
		if (pAC->GIni.GIChipRev == CHIP_REV_YU_EC_A1) {
1905
			/* A0/A1 */
1906
			pAC->GIni.HwF.Features[HW_DEV_LIST] =
1907
				HWF_WA_DEV_42  | HWF_WA_DEV_46 | HWF_WA_DEV_43_418 |
1908
				HWF_WA_DEV_420 | HWF_WA_DEV_423 |
1909
				HWF_WA_DEV_424 | HWF_WA_DEV_425 | HWF_WA_DEV_427 |
1910
				HWF_WA_DEV_428 | HWF_WA_DEV_483 | HWF_WA_DEV_4109;
1911
		}
1912
		else {
1913
			/* A2/A3 */
1914
			pAC->GIni.HwF.Features[HW_DEV_LIST] =
1915
				HWF_WA_DEV_424 | HWF_WA_DEV_425 | HWF_WA_DEV_427 |
1916
				HWF_WA_DEV_428 | HWF_WA_DEV_483 | HWF_WA_DEV_4109;
1917
		}
1918
		break;
1919
	case CHIP_ID_YUKON_FE:
1920
		pAC->GIni.HwF.Features[HW_DEV_LIST] = HWF_WA_DEV_427 | HWF_WA_DEV_4109;
1921
		break;
1922
	case CHIP_ID_YUKON_XL:
1923
		/* still needed for Diag */
1924
		if (pAC->GIni.GIChipRev == 0) {
1925
			pAC->GIni.HwF.Features[HW_DEV_LIST] =
1926
				HWF_WA_DEV_427 | HWF_WA_DEV_463 | HWF_WA_DEV_472 |
1927
				HWF_WA_DEV_479 | HWF_WA_DEV_483 | HWF_WA_DEV_4115;
1928
		}
1929
		else {
1930
			pAC->GIni.HwF.Features[HW_DEV_LIST] =
1931
				HWF_WA_DEV_427 | HWF_WA_DEV_483 | HWF_WA_DEV_4109 |
1932
				HWF_WA_DEV_4115;
1933
		}
1934
		break;
1935
	}
1936
1937
	for (i = 0; i < 4; i++) {
1938
		pAC->GIni.HwF.Features[i] =
1939
			(pAC->GIni.HwF.Features[i] | pAC->GIni.HwF.OnMask[i]) &
1940
				~pAC->GIni.HwF.OffMask[i];
1941
	}
1942
}	/* SkGeSetUpSupFeatures */
1943
1944
1490
/******************************************************************************
1945
/******************************************************************************
1491
 *
1946
 *
1492
 *	SkGeInit1() - Level 1 Initialization
1947
 *	SkGeInit1() - Level 1 Initialization
Lines 1509-1581 Link Here
1509
 *	6:	HW self test failed
1964
 *	6:	HW self test failed
1510
 */
1965
 */
1511
static int SkGeInit1(
1966
static int SkGeInit1(
1512
SK_AC	*pAC,		/* adapter context */
1967
SK_AC	*pAC,		/* Adapter Context */
1513
SK_IOC	IoC)		/* IO context */
1968
SK_IOC	IoC)		/* I/O Context */
1514
{
1969
{
1515
	SK_U8	Byte;
1970
	SK_U8	Byte;
1516
	SK_U16	Word;
1971
	SK_U16	Word;
1517
	SK_U16	CtrlStat;
1972
	SK_U32	CtrlStat;
1973
	SK_U32	VauxAvail;
1518
	SK_U32	DWord;
1974
	SK_U32	DWord;
1975
	SK_U32	PowerDownBit;
1976
	SK_GEPORT *pPrt;
1519
	int	RetVal;
1977
	int	RetVal;
1520
	int	i;
1978
	int	i;
1521
1979
1522
	RetVal = 0;
1980
	RetVal = 0;
1523
1981
1524
	/* save CLK_RUN bits (YUKON-Lite) */
1982
	/* save CLK_RUN & ASF_ENABLE bits (YUKON-Lite, YUKON-EC) */
1525
	SK_IN16(IoC, B0_CTST, &CtrlStat);
1983
	SK_IN32(IoC, B0_CTST, &CtrlStat);
1526
1984
1527
#ifdef SK_PCI_RESET
1985
#ifdef SK_PCI_RESET
1528
	(void)SkGePciReset(pAC, IoC);
1986
	(void)SkGePciReset(pAC, IoC);
1529
#endif /* SK_PCI_RESET */
1987
#endif /* SK_PCI_RESET */
1530
1988
1531
	/* do the SW-reset */
1532
	SK_OUT8(IoC, B0_CTST, CS_RST_SET);
1533
1534
	/* release the SW-reset */
1989
	/* release the SW-reset */
1990
	/* Important: SW-reset has to be cleared here, to ensure
1991
	 * the CHIP_ID can be read IO-mapped based, too -
1992
	 * remember the RAP register can only be written if
1993
	 * SW-reset is cleared.
1994
	 */
1535
	SK_OUT8(IoC, B0_CTST, CS_RST_CLR);
1995
	SK_OUT8(IoC, B0_CTST, CS_RST_CLR);
1536
1996
1997
	/* read Chip Identification Number */
1998
	SK_IN8(IoC, B2_CHIP_ID, &Byte);
1999
	pAC->GIni.GIChipId = Byte;
2000
2001
	pAC->GIni.GIAsfEnabled = SK_FALSE;
2002
2003
	/* ASF support only for Yukon-2 */
2004
	if ((pAC->GIni.GIChipId >= CHIP_ID_YUKON_XL) &&
2005
		(pAC->GIni.GIChipId <= CHIP_ID_YUKON_EC)) {
2006
#ifdef SK_ASF
2007
		if ((CtrlStat & Y2_ASF_ENABLE) != 0) {
2008
			/* do the SW-reset only if ASF is not enabled */
2009
			pAC->GIni.GIAsfEnabled = SK_TRUE;
2010
		}
2011
#else /* !SK_ASF */
2012
2013
		SK_IN8(IoC, B28_Y2_ASF_STAT_CMD, &Byte);
2014
2015
		pAC->GIni.GIAsfRunning = Byte & Y2_ASF_RUNNING;
2016
2017
		/* put ASF system in reset state */
2018
		SK_OUT8(IoC, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
2019
2020
		/* disable ASF Unit */
2021
		SK_OUT16(IoC, B0_CTST, Y2_ASF_DISABLE);
2022
#endif /* !SK_ASF */
2023
	}
2024
2025
	if (!pAC->GIni.GIAsfEnabled) {
2026
		/* Yukon-2: required for Diag and Power Management */
2027
		/* set the SW-reset */
2028
		SK_OUT8(IoC, B0_CTST, CS_RST_SET);
2029
2030
		/* release the SW-reset */
2031
		SK_OUT8(IoC, B0_CTST, CS_RST_CLR);
2032
	}
2033
1537
	/* reset all error bits in the PCI STATUS register */
2034
	/* reset all error bits in the PCI STATUS register */
1538
	/*
2035
	/*
1539
	 * Note: PCI Cfg cycles cannot be used, because they are not
2036
	 * Note: PCI Cfg cycles cannot be used, because they are not
1540
	 *		 available on some platforms after 'boot time'.
2037
	 *		 available on some platforms after 'boot time'.
1541
	 */
2038
	 */
1542
	SK_IN16(IoC, PCI_C(PCI_STATUS), &Word);
2039
	SK_IN16(IoC, PCI_C(pAC, PCI_STATUS), &Word);
1543
	
2040
1544
	SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2041
	SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
1545
	SK_OUT16(IoC, PCI_C(PCI_STATUS), (SK_U16)(Word | PCI_ERRBITS));
2042
1546
	SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2043
	SK_OUT16(IoC, PCI_C(pAC, PCI_STATUS), Word | (SK_U16)PCI_ERRBITS);
1547
2044
1548
	/* release Master Reset */
2045
	/* release Master Reset */
1549
	SK_OUT8(IoC, B0_CTST, CS_MRST_CLR);
2046
	SK_OUT8(IoC, B0_CTST, CS_MRST_CLR);
1550
2047
1551
#ifdef CLK_RUN
2048
#ifdef CLK_RUN
1552
	CtrlStat |= CS_CLK_RUN_ENA;
2049
	CtrlStat |= CS_CLK_RUN_ENA;
1553
#endif /* CLK_RUN */
1554
2050
1555
	/* restore CLK_RUN bits */
2051
	/* restore CLK_RUN bits */
1556
	SK_OUT16(IoC, B0_CTST, (SK_U16)(CtrlStat &
2052
	SK_OUT16(IoC, B0_CTST, (SK_U16)(CtrlStat &
1557
		(CS_CLK_RUN_HOT | CS_CLK_RUN_RST | CS_CLK_RUN_ENA)));
2053
		(CS_CLK_RUN_HOT | CS_CLK_RUN_RST | CS_CLK_RUN_ENA)));
2054
#endif /* CLK_RUN */
2055
2056
	if ((pAC->GIni.GIChipId >= CHIP_ID_YUKON_XL) &&
2057
		(pAC->GIni.GIChipId <= CHIP_ID_YUKON_FE)) {
2058
2059
		pAC->GIni.GIYukon2 = SK_TRUE;
2060
		pAC->GIni.GIValIrqMask = Y2_IS_ALL_MSK;
2061
		pAC->GIni.GIValHwIrqMask = Y2_HWE_ALL_MSK;
2062
2063
		VauxAvail = Y2_VAUX_AVAIL;
2064
2065
		SK_IN32(IoC, PCI_C(pAC, PCI_OUR_STATUS), &DWord);
2066
2067
		if ((DWord & PCI_OS_PCI_X) != 0) {
2068
			/* this is a PCI / PCI-X bus */
2069
			if ((DWord & PCI_OS_PCIX) != 0) {
2070
				/* this is a PCI-X bus */
2071
				pAC->GIni.GIPciBus = SK_PCIX_BUS;
2072
2073
				/* PCI-X is always 64-bit wide */
2074
				pAC->GIni.GIPciSlot64 = SK_TRUE;
2075
2076
				pAC->GIni.GIPciMode = (SK_U8)(PCI_OS_SPEED(DWord));
2077
			}
2078
			else {
2079
				/* this is a conventional PCI bus */
2080
				pAC->GIni.GIPciBus = SK_PCI_BUS;
2081
2082
				SK_IN16(IoC, PCI_C(pAC, PCI_OUR_REG_2), &Word);
2083
2084
				/* check if 64-bit width is used */
2085
				pAC->GIni.GIPciSlot64 = (SK_BOOL)
2086
					(((DWord & PCI_OS_PCI64B) != 0) &&
2087
					((Word & PCI_USEDATA64) != 0));
2088
2089
				/* check if 66 MHz PCI Clock is active */
2090
				pAC->GIni.GIPciClock66 = (SK_BOOL)((DWord & PCI_OS_PCI66M) != 0);
2091
			}
2092
		}
2093
		else {
2094
			/* this is a PEX bus */
2095
			pAC->GIni.GIPciBus = SK_PEX_BUS;
2096
2097
			/* clear any PEX errors */
2098
			SK_OUT32(IoC, PCI_C(pAC, PEX_UNC_ERR_STAT), 0xffffffffUL);
2099
2100
			SK_IN16(IoC, PCI_C(pAC, PEX_LNK_STAT), &Word);
2101
2102
			pAC->GIni.GIPexWidth = (SK_U8)((Word & PEX_LS_LINK_WI_MSK) >> 4);
2103
		}
2104
		/*
2105
		 * Yukon-2 chips family has a different way of providing
2106
		 * the number of MACs available
2107
		 */
2108
		pAC->GIni.GIMacsFound = 1;
2109
2110
		SK_IN8(IoC, B2_Y2_HW_RES, &Byte);
2111
2112
		if (CHIP_ID_YUKON_2(pAC)) {
2113
			/*
2114
			 * OEM config value is overwritten and should not
2115
			 * be used for Yukon-2
2116
			 */
2117
			pAC->GIni.GILedBlinkCtrl |= SK_ACT_LED_BLINK;
2118
2119
			if (CFG_LED_MODE(Byte) == CFG_LED_DUAL_ACT_LNK) {
2120
2121
				pAC->GIni.GILedBlinkCtrl |= SK_DUAL_LED_ACT_LNK;
2122
			}
2123
		}
2124
2125
		if ((Byte & CFG_DUAL_MAC_MSK) == CFG_DUAL_MAC_MSK) {
2126
2127
			SK_IN8(IoC, B2_Y2_CLK_GATE, &Byte);
2128
2129
			if (!(Byte & Y2_STATUS_LNK2_INAC)) {
2130
				/* Link 2 activ */
2131
				pAC->GIni.GIMacsFound++;
2132
			}
2133
		}
2134
2135
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) {
2136
#ifdef XXX
2137
			if (pAC->GIni.GIPciBus != SK_PEX_BUS) {
2138
				/* enable Core Clock Division */
2139
				SK_OUT32(IoC, B2_Y2_CLK_CTRL, Y2_CLK_DIV_VAL_2(0) |
2140
					Y2_CLK_DIV_ENA);
2141
			}
2142
#endif /* XXX */
2143
#ifdef VCPU
2144
		/* temporary WA for reported number of links */
2145
			pAC->GIni.GIMacsFound = 2;
2146
#endif /* VCPU */
2147
		}
2148
2149
		/* read Chip Revision */
2150
		SK_IN8(IoC, B2_MAC_CFG, &Byte);
2151
2152
		pAC->GIni.GIChipCap = Byte & 0x0f;
2153
	}
2154
	else {
2155
		pAC->GIni.GIYukon2 = SK_FALSE;
2156
		pAC->GIni.GIValIrqMask = IS_ALL_MSK;
2157
		pAC->GIni.GIValHwIrqMask = 0;	/* not activated */
2158
2159
		VauxAvail = CS_VAUX_AVAIL;
2160
2161
		/* read number of MACs and Chip Revision */
2162
		SK_IN8(IoC, B2_MAC_CFG, &Byte);
2163
2164
		pAC->GIni.GIMacsFound = (Byte & CFG_SNG_MAC) ? 1 : 2;
2165
	}
1558
2166
1559
	/* read Chip Identification Number */
1560
	SK_IN8(IoC, B2_CHIP_ID, &Byte);
1561
	pAC->GIni.GIChipId = Byte;
1562
	
1563
	/* read number of MACs */
1564
	SK_IN8(IoC, B2_MAC_CFG, &Byte);
1565
	pAC->GIni.GIMacsFound = (Byte & CFG_SNG_MAC) ? 1 : 2;
1566
	
1567
	/* get Chip Revision Number */
2167
	/* get Chip Revision Number */
1568
	pAC->GIni.GIChipRev = (SK_U8)((Byte & CFG_CHIP_R_MSK) >> 4);
2168
	pAC->GIni.GIChipRev = (SK_U8)((Byte & CFG_CHIP_R_MSK) >> 4);
1569
2169
1570
	/* get diff. PCI parameters */
2170
#ifndef SK_DIAG
1571
	SK_IN16(IoC, B0_CTST, &CtrlStat);
2171
	if (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL && pAC->GIni.GIChipRev == 0) {
1572
	
2172
		/* Yukon-2 Chip Rev. A0 */
2173
		return(6);
2174
	}
2175
#endif /* !SK_DIAG */
2176
1573
	/* read the adapters RAM size */
2177
	/* read the adapters RAM size */
1574
	SK_IN8(IoC, B2_E_0, &Byte);
2178
	SK_IN8(IoC, B2_E_0, &Byte);
1575
	
2179
1576
	pAC->GIni.GIGenesis = SK_FALSE;
2180
	pAC->GIni.GIGenesis = SK_FALSE;
1577
	pAC->GIni.GIYukon = SK_FALSE;
2181
	pAC->GIni.GIYukon = SK_FALSE;
1578
	pAC->GIni.GIYukonLite = SK_FALSE;
2182
	pAC->GIni.GIYukonLite = SK_FALSE;
2183
	pAC->GIni.GIVauxAvail = SK_FALSE;
1579
2184
1580
#ifdef GENESIS
2185
#ifdef GENESIS
1581
	if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
2186
	if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
Lines 1591-1647 Link Here
1591
			pAC->GIni.GIRamSize = (int)Byte * 512;
2196
			pAC->GIni.GIRamSize = (int)Byte * 512;
1592
			pAC->GIni.GIRamOffs = 0;
2197
			pAC->GIni.GIRamOffs = 0;
1593
		}
2198
		}
1594
		/* all GE adapters work with 53.125 MHz host clock */
2199
		/* all GENESIS adapters work with 53.125 MHz host clock */
1595
		pAC->GIni.GIHstClkFact = SK_FACT_53;
2200
		pAC->GIni.GIHstClkFact = SK_FACT_53;
1596
		
2201
1597
		/* set Descr. Poll Timer Init Value to 250 ms */
2202
		/* set Descr. Poll Timer Init Value to 250 ms */
1598
		pAC->GIni.GIPollTimerVal =
2203
		pAC->GIni.GIPollTimerVal =
1599
			SK_DPOLL_DEF * (SK_U32)pAC->GIni.GIHstClkFact / 100;
2204
			SK_DPOLL_DEF * (SK_U32)pAC->GIni.GIHstClkFact / 100;
1600
	}
2205
	}
1601
#endif /* GENESIS */
2206
#endif /* GENESIS */
1602
	
2207
1603
#ifdef YUKON
2208
#ifdef YUKON
1604
	if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) {
2209
	if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) {
1605
		
2210
1606
		pAC->GIni.GIYukon = SK_TRUE;
2211
		pAC->GIni.GIYukon = SK_TRUE;
1607
		
2212
1608
		pAC->GIni.GIRamSize = (Byte == (SK_U8)0) ? 128 : (int)Byte * 4;
2213
		pAC->GIni.GIRamSize = (Byte == (SK_U8)0) ? 128 : (int)Byte * 4;
1609
		
2214
1610
		pAC->GIni.GIRamOffs = 0;
2215
		pAC->GIni.GIRamOffs = 0;
1611
		
2216
1612
		/* WA for chip Rev. A */
2217
		/* WA for Yukon chip Rev. A */
1613
		pAC->GIni.GIWolOffs = (pAC->GIni.GIChipId == CHIP_ID_YUKON &&
2218
		pAC->GIni.GIWolOffs = (pAC->GIni.GIChipId == CHIP_ID_YUKON &&
1614
			pAC->GIni.GIChipRev == 0) ? WOL_REG_OFFS : 0;
2219
			pAC->GIni.GIChipRev == 0) ? WOL_REG_OFFS : 0;
1615
		
2220
1616
		/* get PM Capabilities of PCI config space */
2221
		/* get PM Capabilities of PCI config space */
1617
		SK_IN16(IoC, PCI_C(PCI_PM_CAP_REG), &Word);
2222
		SK_IN16(IoC, PCI_C(pAC, PCI_PM_CAP_REG), &Word);
1618
2223
1619
		/* check if VAUX is available */
2224
		/* check if VAUX is available */
1620
		if (((CtrlStat & CS_VAUX_AVAIL) != 0) &&
2225
		if (((CtrlStat & VauxAvail) != 0) &&
1621
			/* check also if PME from D3cold is set */
2226
			/* check also if PME from D3cold is set */
1622
			((Word & PCI_PME_D3C_SUP) != 0)) {
2227
			((Word & PCI_PME_D3C_SUP) != 0)) {
1623
			/* set entry in GE init struct */
2228
			/* set entry in GE init struct */
1624
			pAC->GIni.GIVauxAvail = SK_TRUE;
2229
			pAC->GIni.GIVauxAvail = SK_TRUE;
1625
		}
2230
		}
1626
		
1627
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON_LITE) {
1628
			/* this is Rev. A1 */
1629
			pAC->GIni.GIYukonLite = SK_TRUE;
1630
		}
1631
		else {
1632
			/* save Flash-Address Register */
1633
			SK_IN32(IoC, B2_FAR, &DWord);
1634
2231
1635
			/* test Flash-Address Register */
2232
		if (!CHIP_ID_YUKON_2(pAC)) {
1636
			SK_OUT8(IoC, B2_FAR + 3, 0xff);
1637
			SK_IN8(IoC, B2_FAR + 3, &Byte);
1638
2233
1639
			if (Byte != 0) {
2234
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_LITE) {
1640
				/* this is Rev. A0 */
2235
				/* this is Rev. A1 */
1641
				pAC->GIni.GIYukonLite = SK_TRUE;
2236
				pAC->GIni.GIYukonLite = SK_TRUE;
2237
			}
2238
			else {
2239
				/* save Flash-Address Register */
2240
				SK_IN32(IoC, B2_FAR, &DWord);
2241
2242
				/* test Flash-Address Register */
2243
				SK_OUT8(IoC, B2_FAR + 3, 0xff);
2244
				SK_IN8(IoC, B2_FAR + 3, &Byte);
2245
2246
				if (Byte != 0) {
2247
					/* this is Rev. A0 */
2248
					pAC->GIni.GIYukonLite = SK_TRUE;
1642
2249
1643
				/* restore Flash-Address Register */
2250
					/* restore Flash-Address Register */
1644
				SK_OUT32(IoC, B2_FAR, DWord);
2251
					SK_OUT32(IoC, B2_FAR, DWord);
2252
				}
2253
			}
2254
		}
2255
		else {
2256
			/* Check for CLS = 0 (Dev. 4.55) */
2257
			if (pAC->GIni.GIPciBus != SK_PEX_BUS) {
2258
				/* PCI and PCI-X */
2259
				SK_IN8(IoC, PCI_C(pAC, PCI_CACHE_LSZ), &Byte);
2260
				if (Byte == 0) {
2261
					/* set CLS to 2 if configured to 0 */
2262
					SK_OUT8(IoC, PCI_C(pAC, PCI_CACHE_LSZ), 2);
2263
				}
2264
				if (pAC->GIni.GIPciBus == SK_PCIX_BUS) {
2265
					SK_IN32(IoC, PCI_C(pAC, PCI_OUR_REG_1), &DWord);
2266
					DWord |= PCI_CLS_OPT;
2267
					SK_OUT32(IoC, PCI_C(pAC, PCI_OUR_REG_1), DWord);
2268
				}
1645
			}
2269
			}
1646
		}
2270
		}
1647
2271
Lines 1649-1718 Link Here
1649
		SK_OUT8(IoC, B0_POWER_CTRL, (SK_U8)(PC_VAUX_ENA | PC_VCC_ENA |
2273
		SK_OUT8(IoC, B0_POWER_CTRL, (SK_U8)(PC_VAUX_ENA | PC_VCC_ENA |
1650
			PC_VAUX_OFF | PC_VCC_ON));
2274
			PC_VAUX_OFF | PC_VCC_ON));
1651
2275
1652
		/* read the Interrupt source */
2276
		if (!pAC->GIni.GIAsfEnabled) {
1653
		SK_IN32(IoC, B0_ISRC, &DWord);
2277
1654
		
2278
			for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
1655
		if ((DWord & IS_HW_ERR) != 0) {
2279
				/* set GMAC Link Control reset */
1656
			/* read the HW Error Interrupt source */
2280
				SK_OUT8(IoC, MR_ADDR(i, GMAC_LINK_CTRL), (SK_U8)GMLC_RST_SET);
1657
			SK_IN32(IoC, B0_HWE_ISRC, &DWord);
2281
1658
			
2282
				/* clear GMAC Link Control reset */
1659
			if ((DWord & IS_IRQ_SENSOR) != 0) {
2283
				SK_OUT8(IoC, MR_ADDR(i, GMAC_LINK_CTRL), (SK_U8)GMLC_RST_CLR);
1660
				/* disable HW Error IRQ */
1661
				pAC->GIni.GIValIrqMask &= ~IS_HW_ERR;
1662
			}
2284
			}
1663
		}
2285
		}
1664
		
1665
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
1666
			/* set GMAC Link Control reset */
1667
			SK_OUT16(IoC, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_SET);
1668
2286
1669
			/* clear GMAC Link Control reset */
2287
		if (CHIP_ID_YUKON_2(pAC)) {
1670
			SK_OUT16(IoC, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_CLR);
2288
			/* PEX adapters work with different host clock */
2289
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_EC) {
2290
				/* Yukon-EC works with 125 MHz host clock */
2291
				pAC->GIni.GIHstClkFact = SK_FACT_125;
2292
			}
2293
			else if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
2294
				/* Yukon-FE works with 100 MHz host clock */
2295
				pAC->GIni.GIHstClkFact = SK_FACT_100;
2296
			}
2297
			else {
2298
				/* all Yukon-2 adapters work with 156 MHz host clock */
2299
				pAC->GIni.GIHstClkFact = 2 * SK_FACT_78;
2300
			}
2301
2302
			pAC->GIni.GIPollTimerVal =
2303
				SK_DPOLL_DEF_Y2 * (SK_U32)pAC->GIni.GIHstClkFact / 100;
2304
2305
			/* set power down bit */
2306
			PowerDownBit = PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD;
2307
2308
			/* disable Core Clock Division, set Clock Select to 0 (Yukon-2) */
2309
			SK_OUT32(IoC, B2_Y2_CLK_CTRL, Y2_CLK_DIV_DIS);
2310
2311
			/* turn on Core Clock */
2312
			SK_OUT8(IoC, B2_Y2_CLK_GATE, 0);
1671
		}
2313
		}
1672
		/* all YU chips work with 78.125 MHz host clock */
2314
		else {
1673
		pAC->GIni.GIHstClkFact = SK_FACT_78;
2315
			/* YUKON adapters work with 78 MHz host clock */
1674
		
2316
			pAC->GIni.GIHstClkFact = SK_FACT_78;
1675
		pAC->GIni.GIPollTimerVal = SK_DPOLL_MAX;	/* 215 ms */
2317
2318
			pAC->GIni.GIPollTimerVal = SK_DPOLL_MAX;	/* 215 ms */
2319
2320
			/* read the Interrupt source */
2321
			SK_IN32(IoC, B0_ISRC, &DWord);
2322
2323
			if ((DWord & IS_HW_ERR) != 0) {
2324
				/* read the HW Error Interrupt source */
2325
				SK_IN32(IoC, B0_HWE_ISRC, &DWord);
2326
2327
				if ((DWord & IS_IRQ_SENSOR) != 0) {
2328
					/* disable HW Error IRQ */
2329
					pAC->GIni.GIValIrqMask &= ~IS_HW_ERR;
2330
				}
2331
			}
2332
			/* set power down bit */
2333
			PowerDownBit = PCI_PHY_COMA;
2334
		}
2335
2336
#ifdef SK_PHY_LP_MODE_DEEP_SLEEP
2337
2338
		SK_IN32(IoC, PCI_C(pAC, PCI_OUR_REG_1), &DWord);
2339
2340
		/* Release PHY from PowerDown/COMA Mode */
2341
		SK_OUT32(IoC, PCI_C(pAC, PCI_OUR_REG_1), DWord & ~PowerDownBit);
2342
#endif
1676
	}
2343
	}
1677
#endif /* YUKON */
2344
#endif /* YUKON */
1678
2345
1679
	/* check if 64-bit PCI Slot is present */
2346
	SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
1680
	pAC->GIni.GIPciSlot64 = (SK_BOOL)((CtrlStat & CS_BUS_SLOT_SZ) != 0);
2347
1681
	
2348
	if (!CHIP_ID_YUKON_2(pAC)) {
1682
	/* check if 66 MHz PCI Clock is active */
2349
		/* this is a conventional PCI bus */
1683
	pAC->GIni.GIPciClock66 = (SK_BOOL)((CtrlStat & CS_BUS_CLOCK) != 0);
2350
		pAC->GIni.GIPciBus = SK_PCI_BUS;
2351
2352
		/* check if 64-bit PCI Slot is present */
2353
		pAC->GIni.GIPciSlot64 = (SK_BOOL)((CtrlStat & CS_BUS_SLOT_SZ) != 0);
2354
2355
		/* check if 66 MHz PCI Clock is active */
2356
		pAC->GIni.GIPciClock66 = (SK_BOOL)((CtrlStat & CS_BUS_CLOCK) != 0);
2357
	}
1684
2358
1685
	/* read PCI HW Revision Id. */
2359
	/* read PCI HW Revision Id. */
1686
	SK_IN8(IoC, PCI_C(PCI_REV_ID), &Byte);
2360
	SK_IN8(IoC, PCI_C(pAC, PCI_REV_ID), &Byte);
1687
	pAC->GIni.GIPciHwRev = Byte;
2361
	pAC->GIni.GIPciHwRev = Byte;
1688
2362
2363
	/* read connector type */
2364
	SK_IN8(IoC, B2_CONN_TYP, &pAC->GIni.GIConTyp);
2365
1689
	/* read the PMD type */
2366
	/* read the PMD type */
1690
	SK_IN8(IoC, B2_PMD_TYP, &Byte);
2367
	SK_IN8(IoC, B2_PMD_TYP, &Byte);
1691
	pAC->GIni.GICopperType = (SK_U8)(Byte == 'T');
1692
2368
1693
	/* read the PHY type */
2369
	pAC->GIni.GIPmdTyp = Byte;
2370
2371
	pAC->GIni.GICopperType = (SK_BOOL)(Byte == 'T' || Byte == '1' ||
2372
		(pAC->GIni.GIYukon2 && !(Byte == 'L' || Byte == 'S')));
2373
2374
	/* read the PHY type (Yukon and Genesis) */
1694
	SK_IN8(IoC, B2_E_1, &Byte);
2375
	SK_IN8(IoC, B2_E_1, &Byte);
1695
2376
1696
	Byte &= 0x0f;	/* the PHY type is stored in the lower nibble */
2377
	Byte &= 0x0f;	/* the PHY type is stored in the lower nibble */
1697
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2378
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
1698
		
2379
2380
		pPrt = &pAC->GIni.GP[i];
2381
1699
#ifdef GENESIS
2382
#ifdef GENESIS
1700
		if (pAC->GIni.GIGenesis) {
2383
		if (pAC->GIni.GIGenesis) {
1701
			switch (Byte) {
2384
			switch (Byte) {
1702
			case SK_PHY_XMAC:
2385
			case SK_PHY_XMAC:
1703
				pAC->GIni.GP[i].PhyAddr = PHY_ADDR_XMAC;
2386
				pPrt->PhyAddr = PHY_ADDR_XMAC;
1704
				break;
2387
				break;
1705
			case SK_PHY_BCOM:
2388
			case SK_PHY_BCOM:
1706
				pAC->GIni.GP[i].PhyAddr = PHY_ADDR_BCOM;
2389
				pPrt->PhyAddr = PHY_ADDR_BCOM;
1707
				pAC->GIni.GP[i].PMSCap = (SK_U8)(SK_MS_CAP_AUTO |
2390
				pPrt->PMSCap = (SK_U8)(SK_MS_CAP_AUTO |
1708
					SK_MS_CAP_MASTER | SK_MS_CAP_SLAVE);
2391
					SK_MS_CAP_MASTER | SK_MS_CAP_SLAVE);
1709
				break;
2392
				break;
1710
#ifdef OTHER_PHY
2393
#ifdef OTHER_PHY
1711
			case SK_PHY_LONE:
2394
			case SK_PHY_LONE:
1712
				pAC->GIni.GP[i].PhyAddr = PHY_ADDR_LONE;
2395
				pPrt->PhyAddr = PHY_ADDR_LONE;
1713
				break;
2396
				break;
1714
			case SK_PHY_NAT:
2397
			case SK_PHY_NAT:
1715
				pAC->GIni.GP[i].PhyAddr = PHY_ADDR_NAT;
2398
				pPrt->PhyAddr = PHY_ADDR_NAT;
1716
				break;
2399
				break;
1717
#endif /* OTHER_PHY */
2400
#endif /* OTHER_PHY */
1718
			default:
2401
			default:
Lines 1722-1786 Link Here
1722
			}
2405
			}
1723
		}
2406
		}
1724
#endif /* GENESIS */
2407
#endif /* GENESIS */
1725
	
2408
1726
#ifdef YUKON
2409
#ifdef YUKON
1727
		if (pAC->GIni.GIYukon) {
2410
		if (pAC->GIni.GIYukon) {
1728
			
2411
1729
			if (Byte < (SK_U8)SK_PHY_MARV_COPPER) {
2412
			if ((Byte < (SK_U8)SK_PHY_MARV_COPPER) &&
2413
				pAC->GIni.GIPmdTyp != 'L' && pAC->GIni.GIPmdTyp != 'S') {
1730
				/* if this field is not initialized */
2414
				/* if this field is not initialized */
1731
				Byte = (SK_U8)SK_PHY_MARV_COPPER;
2415
				Byte = (SK_U8)SK_PHY_MARV_COPPER;
1732
				
2416
1733
				pAC->GIni.GICopperType = SK_TRUE;
2417
				pAC->GIni.GICopperType = SK_TRUE;
1734
			}
2418
			}
1735
			
2419
1736
			pAC->GIni.GP[i].PhyAddr = PHY_ADDR_MARV;
2420
			pPrt->PhyAddr = PHY_ADDR_MARV;
1737
			
2421
1738
			if (pAC->GIni.GICopperType) {
2422
			if (pAC->GIni.GICopperType) {
1739
2423
1740
				pAC->GIni.GP[i].PLinkSpeedCap = (SK_U8)(SK_LSPEED_CAP_AUTO |
2424
				if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE ||
1741
					SK_LSPEED_CAP_10MBPS | SK_LSPEED_CAP_100MBPS |
2425
					(pAC->GIni.GIChipId == CHIP_ID_YUKON_EC &&
1742
					SK_LSPEED_CAP_1000MBPS);
2426
					pAC->GIni.GIChipCap == 2)) {
1743
				
2427
1744
				pAC->GIni.GP[i].PLinkSpeed = (SK_U8)SK_LSPEED_AUTO;
2428
					pPrt->PLinkSpeedCap = (SK_U8)(SK_LSPEED_CAP_100MBPS |
1745
				
2429
						SK_LSPEED_CAP_10MBPS);
1746
				pAC->GIni.GP[i].PMSCap = (SK_U8)(SK_MS_CAP_AUTO |
2430
2431
					pAC->GIni.GIRamSize = 4;
2432
				}
2433
				else {
2434
					pPrt->PLinkSpeedCap = (SK_U8)(SK_LSPEED_CAP_1000MBPS |
2435
						SK_LSPEED_CAP_100MBPS | SK_LSPEED_CAP_10MBPS |
2436
						SK_LSPEED_CAP_AUTO);
2437
				}
2438
2439
				pPrt->PLinkSpeed = (SK_U8)SK_LSPEED_AUTO;
2440
2441
				pPrt->PMSCap = (SK_U8)(SK_MS_CAP_AUTO |
1747
					SK_MS_CAP_MASTER | SK_MS_CAP_SLAVE);
2442
					SK_MS_CAP_MASTER | SK_MS_CAP_SLAVE);
1748
			}
2443
			}
1749
			else {
2444
			else {
1750
				Byte = (SK_U8)SK_PHY_MARV_FIBER;
2445
				Byte = (SK_U8)SK_PHY_MARV_FIBER;
1751
			}
2446
			}
1752
		}
2447
		}
2448
2449
		/* clear TWSI IRQ */
2450
		SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
2451
1753
#endif /* YUKON */
2452
#endif /* YUKON */
1754
		
2453
1755
		pAC->GIni.GP[i].PhyType = (int)Byte;
2454
		pPrt->PhyType = (int)Byte;
1756
		
2455
1757
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
2456
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
1758
			("PHY type: %d  PHY addr: %04x\n", Byte,
2457
			("PHY type: %d  PHY addr: %04x\n",
1759
			pAC->GIni.GP[i].PhyAddr));
2458
			Byte, pPrt->PhyAddr));
1760
	}
2459
	}
1761
	
2460
1762
	/* get MAC Type & set function pointers dependent on */
2461
	/* get MAC Type & set function pointers dependent on */
1763
#ifdef GENESIS
2462
#ifdef GENESIS
1764
	if (pAC->GIni.GIGenesis) {
2463
	if (pAC->GIni.GIGenesis) {
1765
		
2464
1766
		pAC->GIni.GIMacType = SK_MAC_XMAC;
2465
		pAC->GIni.GIMacType = SK_MAC_XMAC;
1767
2466
1768
		pAC->GIni.GIFunc.pFnMacUpdateStats	= SkXmUpdateStats;
2467
		pAC->GIni.GIFunc.pFnMacUpdateStats	= SkXmUpdateStats;
1769
		pAC->GIni.GIFunc.pFnMacStatistic	= SkXmMacStatistic;
2468
		pAC->GIni.GIFunc.pFnMacStatistic	= SkXmMacStatistic;
1770
		pAC->GIni.GIFunc.pFnMacResetCounter	= SkXmResetCounter;
2469
		pAC->GIni.GIFunc.pFnMacResetCounter	= SkXmResetCounter;
1771
		pAC->GIni.GIFunc.pFnMacOverflow		= SkXmOverflowStatus;
2470
		pAC->GIni.GIFunc.pFnMacOverflow		= SkXmOverflowStatus;
2471
#ifdef SK_DIAG
2472
		pAC->GIni.GIFunc.pFnMacPhyRead		= SkXmPhyRead;
2473
		pAC->GIni.GIFunc.pFnMacPhyWrite		= SkXmPhyWrite;
2474
#else	/* SK_DIAG */
2475
		pAC->GIni.GIFunc.pSkGeSirqIsr		= SkGeYuSirqIsr;
2476
#endif /* !SK_DIAG */
1772
	}
2477
	}
1773
#endif /* GENESIS */
2478
#endif /* GENESIS */
1774
	
2479
1775
#ifdef YUKON
2480
#ifdef YUKON
1776
	if (pAC->GIni.GIYukon) {
2481
	if (pAC->GIni.GIYukon) {
1777
		
2482
1778
		pAC->GIni.GIMacType = SK_MAC_GMAC;
2483
		pAC->GIni.GIMacType = SK_MAC_GMAC;
1779
2484
1780
		pAC->GIni.GIFunc.pFnMacUpdateStats	= SkGmUpdateStats;
2485
		pAC->GIni.GIFunc.pFnMacUpdateStats	= SkGmUpdateStats;
1781
		pAC->GIni.GIFunc.pFnMacStatistic	= SkGmMacStatistic;
2486
		pAC->GIni.GIFunc.pFnMacStatistic	= SkGmMacStatistic;
1782
		pAC->GIni.GIFunc.pFnMacResetCounter	= SkGmResetCounter;
2487
		pAC->GIni.GIFunc.pFnMacResetCounter	= SkGmResetCounter;
1783
		pAC->GIni.GIFunc.pFnMacOverflow		= SkGmOverflowStatus;
2488
		pAC->GIni.GIFunc.pFnMacOverflow		= SkGmOverflowStatus;
2489
#ifdef SK_DIAG
2490
		pAC->GIni.GIFunc.pFnMacPhyRead		= SkGmPhyRead;
2491
		pAC->GIni.GIFunc.pFnMacPhyWrite		= SkGmPhyWrite;
2492
#else	/* SK_DIAG */
2493
		if (CHIP_ID_YUKON_2(pAC)) {
2494
			pAC->GIni.GIFunc.pSkGeSirqIsr	= SkYuk2SirqIsr;
2495
		}
2496
		else {
2497
			pAC->GIni.GIFunc.pSkGeSirqIsr	= SkGeYuSirqIsr;
2498
		}
2499
#endif /* !SK_DIAG */
1784
2500
1785
#ifdef SPECIAL_HANDLING
2501
#ifdef SPECIAL_HANDLING
1786
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
2502
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
Lines 1793-1799 Link Here
1793
#endif
2509
#endif
1794
	}
2510
	}
1795
#endif /* YUKON */
2511
#endif /* YUKON */
1796
	
2512
2513
	SkGeSetUpSupFeatures(pAC, IoC);
2514
1797
	return(RetVal);
2515
	return(RetVal);
1798
}	/* SkGeInit1 */
2516
}	/* SkGeInit1 */
1799
2517
Lines 1814-1822 Link Here
1814
 *	nothing
2532
 *	nothing
1815
 */
2533
 */
1816
static void SkGeInit2(
2534
static void SkGeInit2(
1817
SK_AC	*pAC,		/* adapter context */
2535
SK_AC	*pAC,		/* Adapter Context */
1818
SK_IOC	IoC)		/* IO context */
2536
SK_IOC	IoC)		/* I/O Context */
1819
{
2537
{
2538
#ifdef YUKON
2539
	SK_U16	Word;
2540
#endif /* YUKON */
1820
#ifdef GENESIS
2541
#ifdef GENESIS
1821
	SK_U32	DWord;
2542
	SK_U32	DWord;
1822
#endif /* GENESIS */
2543
#endif /* GENESIS */
Lines 1850-1862 Link Here
1850
		SkGeInitPktArb(pAC, IoC);
2571
		SkGeInitPktArb(pAC, IoC);
1851
	}
2572
	}
1852
#endif /* GENESIS */
2573
#endif /* GENESIS */
1853
	
2574
1854
#ifdef YUKON
2575
#ifdef xSK_DIAG
1855
	if (pAC->GIni.GIYukon) {
2576
	if (pAC->GIni.GIYukon) {
1856
		/* start Time Stamp Timer */
2577
		/* start Time Stamp Timer */
1857
		SK_OUT8(IoC, GMAC_TI_ST_CTRL, (SK_U8)GMT_ST_START);
2578
		SK_OUT8(IoC, GMAC_TI_ST_CTRL, (SK_U8)GMT_ST_START);
1858
	}
2579
	}
1859
#endif /* YUKON */
2580
#endif /* SK_DIAG */
1860
2581
1861
	/* enable the Tx Arbiters */
2582
	/* enable the Tx Arbiters */
1862
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2583
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
Lines 1866-1873 Link Here
1866
	/* enable the RAM Interface Arbiter */
2587
	/* enable the RAM Interface Arbiter */
1867
	SkGeInitRamIface(pAC, IoC);
2588
	SkGeInitRamIface(pAC, IoC);
1868
2589
2590
#ifdef YUKON
2591
	if (CHIP_ID_YUKON_2(pAC)) {
2592
2593
		if (pAC->GIni.GIPciBus == SK_PEX_BUS) {
2594
2595
			SK_IN16(IoC, PCI_C(pAC, PEX_DEV_CTRL), &Word);
2596
2597
			/* change Max. Read Request Size to 2048 bytes */
2598
			Word &= ~PEX_DC_MAX_RRS_MSK;
2599
			Word |= PEX_DC_MAX_RD_RQ_SIZE(4);
2600
2601
			SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2602
2603
			SK_OUT16(IoC, PCI_C(pAC, PEX_DEV_CTRL), Word);
2604
2605
			SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2606
		}
2607
2608
		/*
2609
		 * Writing the HW Error Mask Reg. will not generate an IRQ
2610
		 * as long as the B0_IMSK is not set by the driver.
2611
		 */
2612
		SK_OUT32(IoC, B0_HWE_IMSK, pAC->GIni.GIValHwIrqMask);
2613
	}
2614
#endif /* YUKON */
1869
}	/* SkGeInit2 */
2615
}	/* SkGeInit2 */
1870
2616
2617
1871
/******************************************************************************
2618
/******************************************************************************
1872
 *
2619
 *
1873
 *	SkGeInit() - Initialize the GE Adapter with the specified level.
2620
 *	SkGeInit() - Initialize the GE Adapter with the specified level.
Lines 1889-1895 Link Here
1889
 *				if Number of MACs > SK_MAX_MACS
2636
 *				if Number of MACs > SK_MAX_MACS
1890
 *
2637
 *
1891
 *			After returning from Level 0 the adapter
2638
 *			After returning from Level 0 the adapter
1892
 *			may be accessed with IO operations.
2639
 *			may be accessed with I/O operations.
1893
 *
2640
 *
1894
 *	Level	2:	start the Blink Source Counter
2641
 *	Level	2:	start the Blink Source Counter
1895
 *
2642
 *
Lines 1898-1911 Link Here
1898
 *	1:	Number of MACs exceeds SK_MAX_MACS	(after level 1)
2645
 *	1:	Number of MACs exceeds SK_MAX_MACS	(after level 1)
1899
 *	2:	Adapter not present or not accessible
2646
 *	2:	Adapter not present or not accessible
1900
 *	3:	Illegal initialization level
2647
 *	3:	Illegal initialization level
1901
 *	4:	Initialization Level 1 Call missing
2648
 *	4:	Initialization level 1 call missing
1902
 *	5:	Unexpected PHY type detected
2649
 *	5:	Unexpected PHY type detected
1903
 *	6:	HW self test failed
2650
 *	6:	HW self test failed
1904
 */
2651
 */
1905
int	SkGeInit(
2652
int	SkGeInit(
1906
SK_AC	*pAC,		/* adapter context */
2653
SK_AC	*pAC,		/* Adapter Context */
1907
SK_IOC	IoC,		/* IO context */
2654
SK_IOC	IoC,		/* I/O Context */
1908
int		Level)		/* initialization level */
2655
int		Level)		/* Initialization Level */
1909
{
2656
{
1910
	int		RetVal;		/* return value */
2657
	int		RetVal;		/* return value */
1911
	SK_U32	DWord;
2658
	SK_U32	DWord;
Lines 1920-1926 Link Here
1920
		SkGeInit0(pAC, IoC);
2667
		SkGeInit0(pAC, IoC);
1921
		pAC->GIni.GILevel = SK_INIT_DATA;
2668
		pAC->GIni.GILevel = SK_INIT_DATA;
1922
		break;
2669
		break;
1923
	
2670
1924
	case SK_INIT_IO:
2671
	case SK_INIT_IO:
1925
		/* Initialization Level 1 */
2672
		/* Initialization Level 1 */
1926
		RetVal = SkGeInit1(pAC, IoC);
2673
		RetVal = SkGeInit1(pAC, IoC);
Lines 1932-1953 Link Here
1932
		SK_OUT32(IoC, B2_IRQM_INI, SK_TEST_VAL);
2679
		SK_OUT32(IoC, B2_IRQM_INI, SK_TEST_VAL);
1933
		SK_IN32(IoC, B2_IRQM_INI, &DWord);
2680
		SK_IN32(IoC, B2_IRQM_INI, &DWord);
1934
		SK_OUT32(IoC, B2_IRQM_INI, 0L);
2681
		SK_OUT32(IoC, B2_IRQM_INI, 0L);
1935
		
2682
1936
		if (DWord != SK_TEST_VAL) {
2683
		if (DWord != SK_TEST_VAL) {
1937
			RetVal = 2;
2684
			RetVal = 2;
1938
			break;
2685
			break;
1939
		}
2686
		}
1940
2687
2688
#ifdef DEBUG
1941
		/* check if the number of GIMacsFound matches SK_MAX_MACS */
2689
		/* check if the number of GIMacsFound matches SK_MAX_MACS */
1942
		if (pAC->GIni.GIMacsFound > SK_MAX_MACS) {
2690
		if (pAC->GIni.GIMacsFound > SK_MAX_MACS) {
1943
			RetVal = 1;
2691
			RetVal = 1;
1944
			break;
2692
			break;
1945
		}
2693
		}
2694
#endif /* DEBUG */
1946
2695
1947
		/* Level 1 successfully passed */
2696
		/* Level 1 successfully passed */
1948
		pAC->GIni.GILevel = SK_INIT_IO;
2697
		pAC->GIni.GILevel = SK_INIT_IO;
1949
		break;
2698
		break;
1950
	
2699
1951
	case SK_INIT_RUN:
2700
	case SK_INIT_RUN:
1952
		/* Initialization Level 2 */
2701
		/* Initialization Level 2 */
1953
		if (pAC->GIni.GILevel != SK_INIT_IO) {
2702
		if (pAC->GIni.GILevel != SK_INIT_IO) {
Lines 1957-1968 Link Here
1957
			RetVal = 4;
2706
			RetVal = 4;
1958
			break;
2707
			break;
1959
		}
2708
		}
2709
1960
		SkGeInit2(pAC, IoC);
2710
		SkGeInit2(pAC, IoC);
1961
2711
1962
		/* Level 2 successfully passed */
2712
		/* Level 2 successfully passed */
1963
		pAC->GIni.GILevel = SK_INIT_RUN;
2713
		pAC->GIni.GILevel = SK_INIT_RUN;
1964
		break;
2714
		break;
1965
	
2715
1966
	default:
2716
	default:
1967
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E003, SKERR_HWI_E003MSG);
2717
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E003, SKERR_HWI_E003MSG);
1968
		RetVal = 3;
2718
		RetVal = 3;
Lines 1985-2061 Link Here
1985
 *	nothing
2735
 *	nothing
1986
 */
2736
 */
1987
void SkGeDeInit(
2737
void SkGeDeInit(
1988
SK_AC	*pAC,		/* adapter context */
2738
SK_AC	*pAC,		/* Adapter Context */
1989
SK_IOC	IoC)		/* IO context */
2739
SK_IOC	IoC)		/* I/O Context */
1990
{
2740
{
1991
	int	i;
2741
	int	i;
1992
	SK_U16	Word;
2742
	SK_U16	Word;
1993
2743
1994
#ifdef SK_PHY_LP_MODE
2744
#ifdef SK_PHY_LP_MODE_DEEP_SLEEP
1995
	SK_U8	Byte;
1996
	SK_U16	PmCtlSts;
2745
	SK_U16	PmCtlSts;
1997
#endif /* SK_PHY_LP_MODE */
2746
#endif
1998
2747
1999
#if (!defined(SK_SLIM) && !defined(VCPU))
2748
#if (!defined(SK_SLIM) && !defined(VCPU))
2000
	/* ensure I2C is ready */
2749
	/* ensure I2C is ready */
2001
	SkI2cWaitIrq(pAC, IoC);
2750
	SkI2cWaitIrq(pAC, IoC);
2002
#endif	
2751
#endif
2003
2004
	/* stop all current transfer activity */
2005
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2006
		if (pAC->GIni.GP[i].PState != SK_PRT_STOP &&
2007
			pAC->GIni.GP[i].PState != SK_PRT_RESET) {
2008
2009
			SkGeStopPort(pAC, IoC, i, SK_STOP_ALL, SK_HARD_RST);
2010
		}
2011
	}
2012
2752
2013
#ifdef SK_PHY_LP_MODE
2753
#ifdef SK_PHY_LP_MODE_DEEP_SLEEP
2014
    /*
2754
	/*
2015
	 * for power saving purposes within mobile environments
2755
	 * for power saving purposes within mobile environments
2016
	 * we set the PHY to coma mode and switch to D3 power state.
2756
	 * we set the PHY to coma mode.
2017
	 */
2757
	 */
2018
	if (pAC->GIni.GIYukonLite &&
2758
#ifndef SK_DIAG
2019
		pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
2759
	if (pAC->GIni.GIVauxAvail) {
2760
		/* switch power to VAUX */
2761
		SK_OUT8(IoC, B0_POWER_CTRL, (SK_U8)(PC_VAUX_ENA | PC_VCC_ENA |
2762
			PC_VAUX_ON | PC_VCC_OFF));
2763
	}
2764
#endif /* SK_DIAG */
2765
2766
	if (CHIP_ID_YUKON_2(pAC) && pAC->GIni.GIMacsFound == 1 &&
2767
		!pAC->GIni.GIAsfEnabled
2768
#ifdef XXX
2769
		|| (pAC->GIni.GIYukonLite && pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3)
2770
#endif
2771
		) {
2020
2772
2021
		/* for all ports switch PHY to coma mode */
2773
		/* for all ports switch PHY to coma mode */
2022
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2774
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2023
			
2024
			SkGmEnterLowPowerMode(pAC, IoC, i, PHY_PM_DEEP_SLEEP);
2025
		}
2026
2775
2027
		if (pAC->GIni.GIVauxAvail) {
2776
			(void)SkGmEnterLowPowerMode(pAC, IoC, i, PHY_PM_DEEP_SLEEP);
2028
			/* switch power to VAUX */
2029
			Byte = PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_ON | PC_VCC_OFF;
2030
2031
			SK_OUT8(IoC, B0_POWER_CTRL, Byte);
2032
		}
2777
		}
2033
		
2778
	}
2034
		/* switch to D3 state */
2779
#else /* !SK_PHY_LP_MODE_DEEP_SLEEP */
2035
		SK_IN16(IoC, PCI_C(PCI_PM_CTL_STS), &PmCtlSts);
2036
2037
		PmCtlSts |= PCI_PM_STATE_D3;
2038
2780
2039
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2781
	if (!pAC->GIni.GIAsfEnabled) {
2782
		/* stop all current transfer activity */
2783
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2784
			if (pAC->GIni.GP[i].PState != SK_PRT_STOP &&
2785
				pAC->GIni.GP[i].PState != SK_PRT_RESET) {
2040
2786
2041
		SK_OUT16(IoC, PCI_C(PCI_PM_CTL_STS), PmCtlSts);
2787
				SkGeStopPort(pAC, IoC, i, SK_STOP_ALL, SK_HARD_RST);
2788
			}
2789
		}
2042
	}
2790
	}
2043
#endif /* SK_PHY_LP_MODE */
2044
2791
2045
	/* Reset all bits in the PCI STATUS register */
2792
	/* reset all bits in the PCI STATUS register */
2046
	/*
2793
	/*
2047
	 * Note: PCI Cfg cycles cannot be used, because they are not
2794
	 * Note: PCI Cfg cycles cannot be used, because they are not
2048
	 *	 available on some platforms after 'boot time'.
2795
	 *	 available on some platforms after 'boot time'.
2049
	 */
2796
	 */
2050
	SK_IN16(IoC, PCI_C(PCI_STATUS), &Word);
2797
	SK_IN16(IoC, PCI_C(pAC, PCI_STATUS), &Word);
2051
	
2798
2052
	SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2799
	SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2053
	SK_OUT16(IoC, PCI_C(PCI_STATUS), (SK_U16)(Word | PCI_ERRBITS));
2800
2801
	SK_OUT16(IoC, PCI_C(pAC, PCI_STATUS), Word | (SK_U16)PCI_ERRBITS);
2802
2054
	SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2803
	SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2055
2804
2056
	/* do the reset, all LEDs are switched off now */
2805
	if (!pAC->GIni.GIAsfEnabled) {
2057
	SK_OUT8(IoC, B0_CTST, CS_RST_SET);
2806
		/* set the SW-reset */
2058
	
2807
		SK_OUT8(IoC, B0_CTST, CS_RST_SET);
2808
	}
2809
#endif /* !SK_PHY_LP_MODE_DEEP_SLEEP */
2810
2059
	pAC->GIni.GILevel = SK_INIT_DATA;
2811
	pAC->GIni.GILevel = SK_INIT_DATA;
2060
}	/* SkGeDeInit */
2812
}	/* SkGeDeInit */
2061
2813
Lines 2089-2096 Link Here
2089
 *	2:	The port has to be stopped before it can be initialized again.
2841
 *	2:	The port has to be stopped before it can be initialized again.
2090
 */
2842
 */
2091
int SkGeInitPort(
2843
int SkGeInitPort(
2092
SK_AC	*pAC,		/* adapter context */
2844
SK_AC	*pAC,		/* Adapter Context */
2093
SK_IOC	IoC,		/* IO context */
2845
SK_IOC	IoC,		/* I/O Context */
2094
int		Port)		/* Port to configure */
2846
int		Port)		/* Port to configure */
2095
{
2847
{
2096
	SK_GEPORT *pPrt;
2848
	SK_GEPORT *pPrt;
Lines 2101-2108 Link Here
2101
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E004, SKERR_HWI_E004MSG);
2853
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E004, SKERR_HWI_E004MSG);
2102
		return(1);
2854
		return(1);
2103
	}
2855
	}
2104
	
2856
2105
	if (pPrt->PState == SK_PRT_INIT || pPrt->PState == SK_PRT_RUN) {
2857
	if (pPrt->PState >= SK_PRT_INIT) {
2106
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E005, SKERR_HWI_E005MSG);
2858
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E005, SKERR_HWI_E005MSG);
2107
		return(2);
2859
		return(2);
2108
	}
2860
	}
Lines 2119-2147 Link Here
2119
		SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA);
2871
		SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA);
2120
		SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_ENA);
2872
		SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_ENA);
2121
		/* The Link LED is initialized by RLMT or Diagnostics itself */
2873
		/* The Link LED is initialized by RLMT or Diagnostics itself */
2122
		
2874
2123
		SkXmInitMac(pAC, IoC, Port);
2875
		SkXmInitMac(pAC, IoC, Port);
2124
	}
2876
	}
2125
#endif /* GENESIS */
2877
#endif /* GENESIS */
2126
	
2878
2127
#ifdef YUKON
2879
#ifdef YUKON
2128
	if (pAC->GIni.GIYukon) {
2880
	if (pAC->GIni.GIYukon) {
2129
2881
2130
		SkGmInitMac(pAC, IoC, Port);
2882
		SkGmInitMac(pAC, IoC, Port);
2131
	}
2883
	}
2132
#endif /* YUKON */
2884
#endif /* YUKON */
2133
	
2885
2134
	/* do NOT initialize the Link Sync Counter */
2886
	/* do NOT initialize the Link Sync Counter */
2135
2887
2136
	SkGeInitMacFifo(pAC, IoC, Port);
2888
	SkGeInitMacFifo(pAC, IoC, Port);
2137
	
2889
2138
	SkGeInitRamBufs(pAC, IoC, Port);
2890
	SkGeInitRamBufs(pAC, IoC, Port);
2139
	
2891
2140
	if (pPrt->PXSQSize != 0) {
2892
	if (pPrt->PXSQSize != 0) {
2141
		/* enable Force Sync bit if synchronous queue available */
2893
		/* enable Force Sync bit if synchronous queue available */
2142
		SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_ENA_FSYNC);
2894
		SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_ENA_FSYNC);
2143
	}
2895
	}
2144
	
2896
2145
	SkGeInitBmu(pAC, IoC, Port);
2897
	SkGeInitBmu(pAC, IoC, Port);
2146
2898
2147
	/* mark port as initialized */
2899
	/* mark port as initialized */
Lines 2149-2151 Link Here
2149
2901
2150
	return(0);
2902
	return(0);
2151
}	/* SkGeInitPort */
2903
}	/* SkGeInitPort */
2904
(-)linux/drivers/net/sk98lin/skgemib.c (-2 / +184 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skgemib.c
3
 * Name:	skgemib.c
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.11 $
5
 * Version:	$Revision: 2.7 $
6
 * Date:	$Date: 2003/09/15 13:38:12 $
6
 * Date:	$Date: 2004/10/26 12:42:18 $
7
 * Purpose:	Private Network Management Interface Management Database
7
 * Purpose:	Private Network Management Interface Management Database
8
 *
8
 *
9
 ****************************************************************************/
9
 ****************************************************************************/
Lines 251-256 Link Here
251
		0,
251
		0,
252
		SK_PNMI_RW, DiagActions, 0},
252
		SK_PNMI_RW, DiagActions, 0},
253
#endif /* SK_DIAG_SUPPORT */
253
#endif /* SK_DIAG_SUPPORT */
254
#ifdef SK_ASF
255
    {OID_SKGE_ASF,
256
        0,
257
        0,
258
        0,
259
        SK_PNMI_RW, Asf, 0},
260
    {OID_SKGE_ASF_STORE_CONFIG,
261
        0,
262
        0,
263
        0,
264
        SK_PNMI_RW, Asf, 0},
265
    {OID_SKGE_ASF_ENA,
266
        0,
267
        0,
268
        0,
269
        SK_PNMI_RW, Asf, 0},
270
    {OID_SKGE_ASF_RETRANS,
271
        0,
272
        0,
273
        0,
274
        SK_PNMI_RW, Asf, 0},
275
    {OID_SKGE_ASF_RETRANS_INT,
276
        0,
277
        0,
278
        0,
279
        SK_PNMI_RW, Asf, 0},
280
    {OID_SKGE_ASF_HB_ENA,
281
        0,
282
        0,
283
        0,
284
        SK_PNMI_RW, Asf, 0},
285
    {OID_SKGE_ASF_HB_INT,
286
        0,
287
        0,
288
        0,
289
        SK_PNMI_RW, Asf, 0},
290
    {OID_SKGE_ASF_WD_ENA,
291
        0,
292
        0,
293
        0,
294
        SK_PNMI_RW, Asf, 0},
295
    {OID_SKGE_ASF_WD_TIME,
296
        0,
297
        0,
298
        0,
299
        SK_PNMI_RW, Asf, 0},
300
    {OID_SKGE_ASF_IP_SOURCE,
301
        0,
302
        0,
303
        0,
304
        SK_PNMI_RW, Asf, 0},
305
    {OID_SKGE_ASF_MAC_SOURCE,
306
        0,
307
        0,
308
        0,
309
        SK_PNMI_RW, Asf, 0},
310
    {OID_SKGE_ASF_IP_DEST,
311
        0,
312
        0,
313
        0,
314
        SK_PNMI_RW, Asf, 0},
315
    {OID_SKGE_ASF_MAC_DEST,
316
        0,
317
        0,
318
        0,
319
        SK_PNMI_RW, Asf, 0},
320
    {OID_SKGE_ASF_COMMUNITY_NAME,
321
        0,
322
        0,
323
        0,
324
        SK_PNMI_RW, Asf, 0},
325
    {OID_SKGE_ASF_RSP_ENA,
326
        0,
327
        0,
328
        0,
329
        SK_PNMI_RW, Asf, 0},
330
    {OID_SKGE_ASF_RETRANS_COUNT_MIN,
331
        0,
332
        0,
333
        0,
334
        SK_PNMI_RW, Asf, 0},
335
    {OID_SKGE_ASF_RETRANS_COUNT_MAX,
336
        0,
337
        0,
338
        0,
339
        SK_PNMI_RW, Asf, 0},
340
    {OID_SKGE_ASF_RETRANS_INT_MIN,
341
        0,
342
        0,
343
        0,
344
        SK_PNMI_RW, Asf, 0},
345
    {OID_SKGE_ASF_RETRANS_INT_MAX,
346
        0,
347
        0,
348
        0,
349
        SK_PNMI_RW, Asf, 0},
350
    {OID_SKGE_ASF_HB_INT_MIN,
351
        0,
352
        0,
353
        0,
354
        SK_PNMI_RW, Asf, 0},
355
    {OID_SKGE_ASF_HB_INT_MAX,
356
        0,
357
        0,
358
        0,
359
        SK_PNMI_RW, Asf, 0},
360
    {OID_SKGE_ASF_WD_TIME_MIN,
361
        0,
362
        0,
363
        0,
364
        SK_PNMI_RW, Asf, 0},
365
    {OID_SKGE_ASF_WD_TIME_MAX,
366
        0,
367
        0,
368
        0,
369
        SK_PNMI_RW, Asf, 0},
370
    {OID_SKGE_ASF_HB_CAP,
371
        0,
372
        0,
373
        0,
374
        SK_PNMI_RW, Asf, 0},
375
    {OID_SKGE_ASF_WD_TIMER_RES,
376
        0,
377
        0,
378
        0,
379
        SK_PNMI_RW, Asf, 0},
380
    {OID_SKGE_ASF_GUID,
381
        0,
382
        0,
383
        0,
384
        SK_PNMI_RW, Asf, 0},
385
    {OID_SKGE_ASF_KEY_OP,
386
        0,
387
        0,
388
        0,
389
        SK_PNMI_RW, Asf, 0},
390
    {OID_SKGE_ASF_KEY_ADM,
391
        0,
392
        0,
393
        0,
394
        SK_PNMI_RW, Asf, 0},
395
    {OID_SKGE_ASF_KEY_GEN,
396
        0,
397
        0,
398
        0,
399
        SK_PNMI_RW, Asf, 0},
400
    {OID_SKGE_ASF_CAP,
401
        0,
402
        0,
403
        0,
404
        SK_PNMI_RW, Asf, 0},
405
    {OID_SKGE_ASF_PAR_1,
406
        0,
407
        0,
408
        0,
409
        SK_PNMI_RW, Asf, 0},
410
    {OID_SKGE_ASF_OVERALL_OID,
411
        0,
412
        0,
413
        0,
414
        SK_PNMI_RW, Asf, 0},
415
    {OID_SKGE_ASF_FWVER_OID,
416
        0,
417
        0,
418
        0,
419
        SK_PNMI_RO, Asf, 0},
420
    {OID_SKGE_ASF_ACPI_OID,
421
        0,
422
        0,
423
        0,
424
        SK_PNMI_RO, Asf, 0},
425
    {OID_SKGE_ASF_SMBUS_OID,
426
        0,
427
        0,
428
        0,
429
        SK_PNMI_RO, Asf, 0},
430
#endif /* SK_ASF */
254
	{OID_SKGE_MDB_VERSION,
431
	{OID_SKGE_MDB_VERSION,
255
		1,
432
		1,
256
		0,
433
		0,
Lines 1073-1078 Link Here
1073
		0,
1250
		0,
1074
		0,
1251
		0,
1075
		SK_PNMI_RO, Vct, 0},
1252
		SK_PNMI_RO, Vct, 0},
1253
	{OID_SKGE_VCT_CAPABILITIES,
1254
		0,
1255
		0,
1256
		0,
1257
		SK_PNMI_RO, Vct, 0},
1076
	{OID_SKGE_BOARDLEVEL,
1258
	{OID_SKGE_BOARDLEVEL,
1077
		0,
1259
		0,
1078
		0,
1260
		0,
(-)linux/drivers/net/sk98lin/skgepnmi.c (-1181 / +1101 lines)
Lines 1-9 Link Here
1
/*****************************************************************************
1
/*****************************************************************************
2
 *
2
 *
3
 * Name:	skgepnmi.c
3
 * Name:	skgepnmi.c
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	Gigabit Ethernet Adapters, PNMI-Module
5
 * Version:	$Revision: 1.111 $
5
 * Version:	$Revision: 2.19 $
6
 * Date:	$Date: 2003/09/15 13:35:35 $
6
 * Date:	$Date: 2004/10/29 09:09:43 $
7
 * Purpose:	Private Network Management Interface
7
 * Purpose:	Private Network Management Interface
8
 *
8
 *
9
 ****************************************************************************/
9
 ****************************************************************************/
Lines 22-32 Link Here
22
 *
22
 *
23
 ******************************************************************************/
23
 ******************************************************************************/
24
24
25
25
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
26
#ifndef _lint
27
static const char SysKonnectFileId[] =
26
static const char SysKonnectFileId[] =
28
	"@(#) $Id: skgepnmi.c,v 1.111 2003/09/15 13:35:35 tschilli Exp $ (C) Marvell.";
27
	"@(#) $Id: skgepnmi.c,v 2.19 2004/10/29 09:09:43 tschilli Exp $ (C) Marvell.";
29
#endif /* !_lint */
28
#endif
30
29
31
#include "h/skdrv1st.h"
30
#include "h/skdrv1st.h"
32
#include "h/sktypes.h"
31
#include "h/sktypes.h"
Lines 38-49 Link Here
38
#include "h/skcsum.h"
37
#include "h/skcsum.h"
39
#include "h/skvpd.h"
38
#include "h/skvpd.h"
40
#include "h/skgehw.h"
39
#include "h/skgehw.h"
40
#include "h/sky2le.h"
41
#include "h/skgeinit.h"
41
#include "h/skgeinit.h"
42
#include "h/skdrv2nd.h"
42
#include "h/skdrv2nd.h"
43
#include "h/skgepnm2.h"
43
#include "h/skgepnm2.h"
44
#ifdef SK_POWER_MGMT
44
#ifdef SK_POWER_MGMT
45
#include "h/skgepmgt.h"
45
#include "h/skgepmgt.h"
46
#endif
46
#endif /* SK_POWER_MGMT */
47
47
/* defines *******************************************************************/
48
/* defines *******************************************************************/
48
49
49
#ifndef DEBUG
50
#ifndef DEBUG
Lines 72-78 Link Here
72
int SkPnmiGenIoctl(SK_AC *pAC, SK_IOC IoC, void * pBuf,
73
int SkPnmiGenIoctl(SK_AC *pAC, SK_IOC IoC, void * pBuf,
73
	unsigned int * pLen, SK_U32 NetIndex);
74
	unsigned int * pLen, SK_U32 NetIndex);
74
75
75
76
/*
76
/*
77
 * Private Function prototypes
77
 * Private Function prototypes
78
 */
78
 */
Lines 112-117 Link Here
112
PNMI_STATIC int Vct(SK_AC *pAC, SK_IOC IoC, int Action, SK_U32 Id, char *pBuf,
112
PNMI_STATIC int Vct(SK_AC *pAC, SK_IOC IoC, int Action, SK_U32 Id, char *pBuf,
113
	unsigned int *pLen, SK_U32 Instance, unsigned int TableIndex, SK_U32 NetIndex);
113
	unsigned int *pLen, SK_U32 Instance, unsigned int TableIndex, SK_U32 NetIndex);
114
PNMI_STATIC void CheckVctStatus(SK_AC *, SK_IOC, char *, SK_U32, SK_U32);
114
PNMI_STATIC void CheckVctStatus(SK_AC *, SK_IOC, char *, SK_U32, SK_U32);
115
PNMI_STATIC void VctGetResults(SK_AC *, SK_IOC, SK_U32);
116
#ifdef SK_ASF
117
PNMI_STATIC int Asf(SK_AC *pAC, SK_IOC IoC, int action, SK_U32 Id,
118
    char *pBuf, unsigned int *pLen, SK_U32 Instance,
119
    unsigned int TableIndex, SK_U32 NetIndex);
120
#endif /* SK_ASF */
115
121
116
/*
122
/*
117
 * Table to correlate OID with handler function and index to
123
 * Table to correlate OID with handler function and index to
Lines 353-369 Link Here
353
 *	Always 0
359
 *	Always 0
354
 */
360
 */
355
int SkPnmiInit(
361
int SkPnmiInit(
356
SK_AC *pAC,		/* Pointer to adapter context */
362
SK_AC	*pAC,		/* Pointer to adapter context */
357
SK_IOC IoC,		/* IO context handle */
363
SK_IOC	IoC,		/* IO context handle */
358
int Level)		/* Initialization level */
364
int		Level)		/* Initialization level */
359
{
365
{
360
	unsigned int	PortMax;	/* Number of ports */
366
	unsigned int	PortMax;	/* Number of ports */
361
	unsigned int	PortIndex;	/* Current port index in loop */
367
	unsigned int	PortIndex;	/* Current port index in loop */
362
	SK_U16		Val16;		/* Multiple purpose 16 bit variable */
368
	SK_EVPARA		EventParam;	/* Event struct for timer event */
363
	SK_U8		Val8;		/* Mulitple purpose 8 bit variable */
364
	SK_EVPARA	EventParam;	/* Event struct for timer event */
365
	SK_PNMI_VCT	*pVctBackupData;
366
367
369
368
	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
370
	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
369
		("PNMI: SkPnmiInit: Called, level=%d\n", Level));
371
		("PNMI: SkPnmiInit: Called, level=%d\n", Level));
Lines 372-380 Link Here
372
374
373
	case SK_INIT_DATA:
375
	case SK_INIT_DATA:
374
		SK_MEMSET((char *)&pAC->Pnmi, 0, sizeof(pAC->Pnmi));
376
		SK_MEMSET((char *)&pAC->Pnmi, 0, sizeof(pAC->Pnmi));
377
		
375
		pAC->Pnmi.TrapBufFree = SK_PNMI_TRAP_QUEUE_LEN;
378
		pAC->Pnmi.TrapBufFree = SK_PNMI_TRAP_QUEUE_LEN;
376
		pAC->Pnmi.StartUpTime = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC));
379
		pAC->Pnmi.StartUpTime = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC));
377
		pAC->Pnmi.RlmtChangeThreshold = SK_PNMI_DEF_RLMT_CHG_THRES;
380
		pAC->Pnmi.RlmtChangeThreshold = SK_PNMI_DEF_RLMT_CHG_THRES;
381
		
378
		for (PortIndex = 0; PortIndex < SK_MAX_MACS; PortIndex ++) {
382
		for (PortIndex = 0; PortIndex < SK_MAX_MACS; PortIndex ++) {
379
383
380
			pAC->Pnmi.Port[PortIndex].ActiveFlag = SK_FALSE;
384
			pAC->Pnmi.Port[PortIndex].ActiveFlag = SK_FALSE;
Lines 408-458 Link Here
408
		break;
412
		break;
409
413
410
	case SK_INIT_IO:
414
	case SK_INIT_IO:
411
		/*
415
412
		 * Reset MAC counters
416
		/* Reset MAC counters. */
413
		 */
414
		PortMax = pAC->GIni.GIMacsFound;
417
		PortMax = pAC->GIni.GIMacsFound;
415
418
416
		for (PortIndex = 0; PortIndex < PortMax; PortIndex ++) {
419
		for (PortIndex = 0; PortIndex < PortMax; PortIndex ++) {
417
420
418
			pAC->GIni.GIFunc.pFnMacResetCounter(pAC, IoC, PortIndex);
421
			pAC->GIni.GIFunc.pFnMacResetCounter(pAC, IoC, PortIndex);
419
		}
422
		}
420
		
423
421
		/* Initialize DSP variables for Vct() to 0xff => Never written! */		
424
		/* Initialize DSP variables for Vct() to 0xff => Never written! */		
422
		for (PortIndex = 0; PortIndex < PortMax; PortIndex ++) {
425
		for (PortIndex = 0; PortIndex < PortMax; PortIndex ++) {
423
			pAC->GIni.GP[PortIndex].PCableLen = 0xff;
426
			pAC->GIni.GP[PortIndex].PCableLen = 0xff;
424
			pVctBackupData = &pAC->Pnmi.VctBackup[PortIndex];
427
			pAC->Pnmi.VctBackup[PortIndex].CableLen = 0xff;
425
			pVctBackupData->PCableLen = 0xff;
426
		}
428
		}
427
		
428
		/*
429
		 * Get pci bus speed
430
		 */
431
		SK_IN16(IoC, B0_CTST, &Val16);
432
		if ((Val16 & CS_BUS_CLOCK) == 0) {
433
429
434
			pAC->Pnmi.PciBusSpeed = 33;
430
		/* Get PCI bus speed. */
431
		if (pAC->GIni.GIPciClock66) {
432
433
			pAC->Pnmi.PciBusSpeed = 66;
435
		}
434
		}
436
		else {
435
		else {
437
			pAC->Pnmi.PciBusSpeed = 66;
436
			pAC->Pnmi.PciBusSpeed = 33;
438
		}
437
		}
439
438
440
		/*
439
		/* Get PCI bus width. */
441
		 * Get pci bus width
440
		if (pAC->GIni.GIPciSlot64) {
442
		 */
443
		SK_IN16(IoC, B0_CTST, &Val16);
444
		if ((Val16 & CS_BUS_SLOT_SZ) == 0) {
445
441
446
			pAC->Pnmi.PciBusWidth = 32;
442
			pAC->Pnmi.PciBusWidth = 64;
447
		}
443
		}
448
		else {
444
		else {
449
			pAC->Pnmi.PciBusWidth = 64;
445
			pAC->Pnmi.PciBusWidth = 32;
450
		}
446
		}
451
447
452
		/*
448
		/* Get chipset. */
453
		 * Get chipset
454
		 */
455
		switch (pAC->GIni.GIChipId) {
449
		switch (pAC->GIni.GIChipId) {
450
		
456
		case CHIP_ID_GENESIS:
451
		case CHIP_ID_GENESIS:
457
			pAC->Pnmi.Chipset = SK_PNMI_CHIPSET_XMAC;
452
			pAC->Pnmi.Chipset = SK_PNMI_CHIPSET_XMAC;
458
			break;
453
			break;
Lines 465-517 Link Here
465
			break;
460
			break;
466
		}
461
		}
467
462
468
		/*
463
		/* Get PMD and Device Type. */
469
		 * Get PMD and DeviceType
464
		switch (pAC->GIni.GIPmdTyp) {
470
		 */
465
		
471
		SK_IN8(IoC, B2_PMD_TYP, &Val8);
472
		switch (Val8) {
473
		case 'S':
466
		case 'S':
474
			pAC->Pnmi.PMD = 3;
467
			pAC->Pnmi.PMD = 3;
475
			if (pAC->GIni.GIMacsFound > 1) {
468
			pAC->Pnmi.DeviceType = 0x00020001;
476
477
				pAC->Pnmi.DeviceType = 0x00020002;
478
			}
479
			else {
480
				pAC->Pnmi.DeviceType = 0x00020001;
481
			}
482
			break;
469
			break;
483
470
484
		case 'L':
471
		case 'L':
485
			pAC->Pnmi.PMD = 2;
472
			pAC->Pnmi.PMD = 2;
486
			if (pAC->GIni.GIMacsFound > 1) {
473
			pAC->Pnmi.DeviceType = 0x00020003;
487
488
				pAC->Pnmi.DeviceType = 0x00020004;
489
			}
490
			else {
491
				pAC->Pnmi.DeviceType = 0x00020003;
492
			}
493
			break;
474
			break;
494
475
495
		case 'C':
476
		case 'C':
496
			pAC->Pnmi.PMD = 4;
477
			pAC->Pnmi.PMD = 4;
497
			if (pAC->GIni.GIMacsFound > 1) {
478
			pAC->Pnmi.DeviceType = 0x00020005;
498
499
				pAC->Pnmi.DeviceType = 0x00020006;
500
			}
501
			else {
502
				pAC->Pnmi.DeviceType = 0x00020005;
503
			}
504
			break;
479
			break;
505
480
506
		case 'T':
481
		case 'T':
507
			pAC->Pnmi.PMD = 5;
482
			pAC->Pnmi.PMD = 5;
508
			if (pAC->GIni.GIMacsFound > 1) {
483
			pAC->Pnmi.DeviceType = 0x00020007;
509
510
				pAC->Pnmi.DeviceType = 0x00020008;
511
			}
512
			else {
513
				pAC->Pnmi.DeviceType = 0x00020007;
514
			}
515
			break;
484
			break;
516
485
517
		default :
486
		default :
Lines 520-530 Link Here
520
			break;
489
			break;
521
		}
490
		}
522
491
523
		/*
492
		if (pAC->GIni.GIMacsFound > 1) {
524
		 * Get connector
493
525
		 */
494
			pAC->Pnmi.DeviceType++;
526
		SK_IN8(IoC, B2_CONN_TYP, &Val8);
495
		}
527
		switch (Val8) {
496
		
497
		/* Get connector type. */
498
		switch (pAC->GIni.GIConTyp) {
499
		
528
		case 'C':
500
		case 'C':
529
			pAC->Pnmi.Connector = 2;
501
			pAC->Pnmi.Connector = 2;
530
			break;
502
			break;
Lines 552-568 Link Here
552
		break;
524
		break;
553
525
554
	case SK_INIT_RUN:
526
	case SK_INIT_RUN:
555
		/*
527
556
		 * Start timer for RLMT change counter
528
		/* Start timer for RLMT change counter. */
557
		 */
558
		SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
529
		SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
530
		
559
		SkTimerStart(pAC, IoC, &pAC->Pnmi.RlmtChangeEstimate.EstTimer,
531
		SkTimerStart(pAC, IoC, &pAC->Pnmi.RlmtChangeEstimate.EstTimer,
560
			28125000, SKGE_PNMI, SK_PNMI_EVT_CHG_EST_TIMER,
532
			SK_PNMI_EVT_TIMER_CHECK, SKGE_PNMI, SK_PNMI_EVT_CHG_EST_TIMER,
561
			EventParam);
533
			EventParam);
562
		break;
534
		break;
563
535
564
	default:
536
	default:
565
		break; /* Nothing todo */
537
		break; /* Nothing to do. */
566
	}
538
	}
567
539
568
	return (0);
540
	return (0);
Lines 642-648 Link Here
642
		("PNMI: SkPnmiPreSetVar: Called, Id=0x%x, BufLen=%d, Instance=%d, NetIndex=%d\n",
614
		("PNMI: SkPnmiPreSetVar: Called, Id=0x%x, BufLen=%d, Instance=%d, NetIndex=%d\n",
643
			Id, *pLen, Instance, NetIndex));
615
			Id, *pLen, Instance, NetIndex));
644
616
645
646
	return (PnmiVar(pAC, IoC, SK_PNMI_PRESET, Id, (char *)pBuf, pLen,
617
	return (PnmiVar(pAC, IoC, SK_PNMI_PRESET, Id, (char *)pBuf, pLen,
647
		Instance, NetIndex));
618
		Instance, NetIndex));
648
}
619
}
Lines 724-730 Link Here
724
	unsigned int	TmpLen;
695
	unsigned int	TmpLen;
725
	char		KeyArr[SK_PNMI_VPD_ENTRIES][SK_PNMI_VPD_KEY_SIZE];
696
	char		KeyArr[SK_PNMI_VPD_ENTRIES][SK_PNMI_VPD_KEY_SIZE];
726
697
727
728
	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
698
	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
729
		("PNMI: SkPnmiGetStruct: Called, BufLen=%d, NetIndex=%d\n",
699
		("PNMI: SkPnmiGetStruct: Called, BufLen=%d, NetIndex=%d\n",
730
			*pLen, NetIndex));
700
			*pLen, NetIndex));
Lines 733-754 Link Here
733
703
734
		if (*pLen >= SK_PNMI_MIN_STRUCT_SIZE) {
704
		if (*pLen >= SK_PNMI_MIN_STRUCT_SIZE) {
735
705
736
			SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_TOO_SHORT,
706
			SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_TOO_SHORT, (SK_U32)(-1));
737
				(SK_U32)(-1));
738
		}
707
		}
739
708
740
		*pLen = SK_PNMI_STRUCT_SIZE;
709
		*pLen = SK_PNMI_STRUCT_SIZE;
741
		return (SK_PNMI_ERR_TOO_SHORT);
710
		return (SK_PNMI_ERR_TOO_SHORT);
742
	}
711
	}
743
712
744
    /*
713
	/* Check NetIndex. */
745
     * Check NetIndex
746
     */
747
	if (NetIndex >= pAC->Rlmt.NumNets) {
714
	if (NetIndex >= pAC->Rlmt.NumNets) {
748
		return (SK_PNMI_ERR_UNKNOWN_NET);
715
		return (SK_PNMI_ERR_UNKNOWN_NET);
749
	}
716
	}
750
717
751
	/* Update statistic */
718
	/* Update statistics. */
752
	SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On call");
719
	SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On call");
753
720
754
	if ((Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1)) !=
721
	if ((Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1)) !=
Lines 773-787 Link Here
773
		return (Ret);
740
		return (Ret);
774
	}
741
	}
775
742
776
	/*
743
	/* Increment semaphores to indicate that an update was already done. */
777
	 * Increment semaphores to indicate that an update was
778
	 * already done
779
	 */
780
	pAC->Pnmi.MacUpdatedFlag ++;
744
	pAC->Pnmi.MacUpdatedFlag ++;
781
	pAC->Pnmi.RlmtUpdatedFlag ++;
745
	pAC->Pnmi.RlmtUpdatedFlag ++;
782
	pAC->Pnmi.SirqUpdatedFlag ++;
746
	pAC->Pnmi.SirqUpdatedFlag ++;
783
747
784
	/* Get vpd keys for instance calculation */
748
	/* Get VPD keys for instance calculation. */
785
	Ret = GetVpdKeyArr(pAC, IoC, &KeyArr[0][0], sizeof(KeyArr), &TmpLen);
749
	Ret = GetVpdKeyArr(pAC, IoC, &KeyArr[0][0], sizeof(KeyArr), &TmpLen);
786
	if (Ret != SK_PNMI_ERR_OK) {
750
	if (Ret != SK_PNMI_ERR_OK) {
787
751
Lines 795-807 Link Here
795
		return (SK_PNMI_ERR_GENERAL);
759
		return (SK_PNMI_ERR_GENERAL);
796
	}
760
	}
797
761
798
	/* Retrieve values */
762
	/* Retrieve values. */
799
	SK_MEMSET((char *)pBuf, 0, SK_PNMI_STRUCT_SIZE);
763
	SK_MEMSET((char *)pBuf, 0, SK_PNMI_STRUCT_SIZE);
764
	
800
	for (TableIndex = 0; TableIndex < ID_TABLE_SIZE; TableIndex ++) {
765
	for (TableIndex = 0; TableIndex < ID_TABLE_SIZE; TableIndex ++) {
801
766
802
		InstanceNo = IdTable[TableIndex].InstanceNo;
767
		InstanceNo = IdTable[TableIndex].InstanceNo;
803
		for (InstanceCnt = 1; InstanceCnt <= InstanceNo;
768
		for (InstanceCnt = 1; InstanceCnt <= InstanceNo; InstanceCnt ++) {
804
			InstanceCnt ++) {
805
769
806
			DstOffset = IdTable[TableIndex].Offset +
770
			DstOffset = IdTable[TableIndex].Offset +
807
				(InstanceCnt - 1) *
771
				(InstanceCnt - 1) *
Lines 998-1004 Link Here
998
	unsigned int	PhysPortIndex;
962
	unsigned int	PhysPortIndex;
999
    unsigned int	MaxNetNumber;
963
    unsigned int	MaxNetNumber;
1000
	int			CounterIndex;
964
	int			CounterIndex;
1001
	int			Ret;
1002
	SK_U16		MacStatus;
965
	SK_U16		MacStatus;
1003
	SK_U64		OverflowStatus;
966
	SK_U64		OverflowStatus;
1004
	SK_U64		Mask;
967
	SK_U64		Mask;
Lines 1012-1023 Link Here
1012
	SK_U64		Delta;
975
	SK_U64		Delta;
1013
	SK_PNMI_ESTIMATE *pEst;
976
	SK_PNMI_ESTIMATE *pEst;
1014
	SK_U32		NetIndex;
977
	SK_U32		NetIndex;
1015
	SK_GEPORT	*pPrt;
1016
	SK_PNMI_VCT	*pVctBackupData;
1017
	SK_U32		RetCode;
978
	SK_U32		RetCode;
1018
	int		i;
1019
	SK_U32		CableLength;
1020
1021
979
1022
#ifdef DEBUG
980
#ifdef DEBUG
1023
	if (Event != SK_PNMI_EVT_XMAC_RESET) {
981
	if (Event != SK_PNMI_EVT_XMAC_RESET) {
Lines 1048-1056 Link Here
1048
#endif /* DEBUG */
1006
#endif /* DEBUG */
1049
		OverflowStatus = 0;
1007
		OverflowStatus = 0;
1050
1008
1051
		/*
1009
		/* Check which source caused an overflow interrupt. */
1052
		 * Check which source caused an overflow interrupt.
1053
		 */
1054
		if ((pAC->GIni.GIFunc.pFnMacOverflow(pAC, IoC, PhysPortIndex,
1010
		if ((pAC->GIni.GIFunc.pFnMacOverflow(pAC, IoC, PhysPortIndex,
1055
				MacStatus, &OverflowStatus) != 0) ||
1011
				MacStatus, &OverflowStatus) != 0) ||
1056
			(OverflowStatus == 0)) {
1012
			(OverflowStatus == 0)) {
Lines 1068-1074 Link Here
1068
1024
1069
			Mask = (SK_U64)1 << CounterIndex;
1025
			Mask = (SK_U64)1 << CounterIndex;
1070
			if ((OverflowStatus & Mask) == 0) {
1026
			if ((OverflowStatus & Mask) == 0) {
1071
1072
				continue;
1027
				continue;
1073
			}
1028
			}
1074
1029
Lines 1100-1108 Link Here
1100
			case SK_PNMI_HRX_IRLENGTH:
1055
			case SK_PNMI_HRX_IRLENGTH:
1101
			case SK_PNMI_HRX_RESERVED:
1056
			case SK_PNMI_HRX_RESERVED:
1102
			
1057
			
1103
			/*
1058
			/* The following counters aren't be handled (id > 63). */
1104
			 * the following counters aren't be handled (id > 63)
1105
			 */
1106
			case SK_PNMI_HTX_SYNC:
1059
			case SK_PNMI_HTX_SYNC:
1107
			case SK_PNMI_HTX_SYNC_OCTET:
1060
			case SK_PNMI_HTX_SYNC_OCTET:
1108
				break;
1061
				break;
Lines 1189-1195 Link Here
1189
		if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) {
1142
		if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) {
1190
1143
1191
			SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
1144
			SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
1192
				("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_SEN_ERR_UPP parameter wrong, SensorIndex=%d\n",
1145
				("PNMI: ERR: SK_PNMI_EVT_SEN_ERR_UPP parameter wrong, SensorIndex=%d\n",
1193
				(unsigned int)Param.Para64));
1146
				(unsigned int)Param.Para64));
1194
			return (0);
1147
			return (0);
1195
		}
1148
		}
Lines 1208-1223 Link Here
1208
	case SK_PNMI_EVT_CHG_EST_TIMER:
1161
	case SK_PNMI_EVT_CHG_EST_TIMER:
1209
		/*
1162
		/*
1210
		 * Calculate port switch average on a per hour basis
1163
		 * Calculate port switch average on a per hour basis
1211
		 *   Time interval for check       : 28125 ms
1164
		 *   Time interval for check       : 28125 ms (SK_PNMI_EVT_TIMER_CHECK)
1212
		 *   Number of values for average  : 8
1165
		 *   Number of values for average  : 8
1213
		 *
1166
		 *
1214
		 * Be careful in changing these values, on change check
1167
		 * Be careful in changing these values, on change check
1215
		 *   - typedef of SK_PNMI_ESTIMATE (Size of EstValue
1168
		 *   - typedef of SK_PNMI_ESTIMATE (Size of EstValue
1216
		 *     array one less than value number)
1169
		 *     array one less than value number)
1217
		 *   - Timer initialization SkTimerStart() in SkPnmiInit
1170
		 *   - Timer initialization SkTimerStart() in SkPnmiInit
1218
		 *   - Delta value below must be multiplicated with
1171
		 *   - Delta value below must be multiplicated with power of 2
1219
		 *     power of 2
1220
		 *
1221
		 */
1172
		 */
1222
		pEst = &pAC->Pnmi.RlmtChangeEstimate;
1173
		pEst = &pAC->Pnmi.RlmtChangeEstimate;
1223
		CounterIndex = pEst->EstValueIndex + 1;
1174
		CounterIndex = pEst->EstValueIndex + 1;
Lines 1240-1246 Link Here
1240
			Delta = NewestValue - OldestValue;
1191
			Delta = NewestValue - OldestValue;
1241
		}
1192
		}
1242
		else {
1193
		else {
1243
			/* Overflow situation */
1194
			/* Overflow situation. */
1244
			Delta = (SK_U64)(0 - OldestValue) + NewestValue;
1195
			Delta = (SK_U64)(0 - OldestValue) + NewestValue;
1245
		}
1196
		}
1246
1197
Lines 1266-1273 Link Here
1266
		}
1217
		}
1267
1218
1268
		SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
1219
		SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
1220
		
1269
		SkTimerStart(pAC, IoC, &pAC->Pnmi.RlmtChangeEstimate.EstTimer,
1221
		SkTimerStart(pAC, IoC, &pAC->Pnmi.RlmtChangeEstimate.EstTimer,
1270
			28125000, SKGE_PNMI, SK_PNMI_EVT_CHG_EST_TIMER,
1222
			SK_PNMI_EVT_TIMER_CHECK, SKGE_PNMI, SK_PNMI_EVT_CHG_EST_TIMER,
1271
			EventParam);
1223
			EventParam);
1272
		break;
1224
		break;
1273
1225
Lines 1311-1339 Link Here
1311
				(unsigned int)Param.Para64));
1263
				(unsigned int)Param.Para64));
1312
			return (0);
1264
			return (0);
1313
		}
1265
		}
1314
#endif
1266
#endif /* DEBUG */
1267
1315
		PhysPortIndex = (unsigned int)Param.Para64;
1268
		PhysPortIndex = (unsigned int)Param.Para64;
1316
1269
1317
		/*
1270
		/* Update XMAC statistic to get fresh values. */
1318
		 * Update XMAC statistic to get fresh values
1271
		if (MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1) !=
1319
		 */
1272
			SK_PNMI_ERR_OK) {
1320
		Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1);
1321
		if (Ret != SK_PNMI_ERR_OK) {
1322
1273
1323
			SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return");
1274
			SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return");
1324
			return (0);
1275
			return (0);
1325
		}
1276
		}
1326
		/*
1277
1327
		 * Increment semaphore to indicate that an update was
1278
		/* Increment semaphore to indicate that an update was already done. */
1328
		 * already done
1329
		 */
1330
		pAC->Pnmi.MacUpdatedFlag ++;
1279
		pAC->Pnmi.MacUpdatedFlag ++;
1331
1280
1332
		for (CounterIndex = 0; CounterIndex < SK_PNMI_MAX_IDX;
1281
		for (CounterIndex = 0; CounterIndex < SK_PNMI_MAX_IDX;
1333
			CounterIndex ++) {
1282
			CounterIndex ++) {
1334
1283
1335
			if (!StatAddr[CounterIndex][MacType].GetOffset) {
1284
			if (!StatAddr[CounterIndex][MacType].GetOffset) {
1336
1337
				continue;
1285
				continue;
1338
			}
1286
			}
1339
1287
Lines 1366-1379 Link Here
1366
		QueueRlmtPortTrap(pAC, OID_SKGE_TRAP_RLMT_PORT_UP, PhysPortIndex);
1314
		QueueRlmtPortTrap(pAC, OID_SKGE_TRAP_RLMT_PORT_UP, PhysPortIndex);
1367
		(void)SK_DRIVER_SENDEVENT(pAC, IoC);
1315
		(void)SK_DRIVER_SENDEVENT(pAC, IoC);
1368
1316
1369
		/* Bugfix for XMAC errata (#10620)*/
1317
		/* Bugfix for XMAC errata (#10620). */
1370
		if (MacType == SK_MAC_XMAC) {
1318
		if (MacType == SK_MAC_XMAC) {
1371
			/* Add incremental difference to offset (#10620)*/
1319
			/* Add incremental difference to offset (#10620). */
1372
			(void)pAC->GIni.GIFunc.pFnMacStatistic(pAC, IoC, PhysPortIndex,
1320
			(void)pAC->GIni.GIFunc.pFnMacStatistic(pAC, IoC, PhysPortIndex,
1373
				XM_RXE_SHT_ERR, &Val32);
1321
				XM_RXE_SHT_ERR, &Val32);
1374
			
1322
			
1375
			Value = (((SK_U64)pAC->Pnmi.Port[PhysPortIndex].
1323
			Value = (((SK_U64)pAC->Pnmi.Port[PhysPortIndex].
1376
				 CounterHigh[SK_PNMI_HRX_SHORTS] << 32) | (SK_U64)Val32);
1324
				 CounterHigh[SK_PNMI_HRX_SHORTS] << 32) | (SK_U64)Val32);
1325
			
1377
			pAC->Pnmi.Port[PhysPortIndex].CounterOffset[SK_PNMI_HRX_SHORTS] +=
1326
			pAC->Pnmi.Port[PhysPortIndex].CounterOffset[SK_PNMI_HRX_SHORTS] +=
1378
				Value - pAC->Pnmi.Port[PhysPortIndex].RxShortZeroMark;
1327
				Value - pAC->Pnmi.Port[PhysPortIndex].RxShortZeroMark;
1379
		}
1328
		}
Lines 1403-1409 Link Here
1403
		QueueRlmtPortTrap(pAC, OID_SKGE_TRAP_RLMT_PORT_DOWN, PhysPortIndex);
1352
		QueueRlmtPortTrap(pAC, OID_SKGE_TRAP_RLMT_PORT_DOWN, PhysPortIndex);
1404
		(void)SK_DRIVER_SENDEVENT(pAC, IoC);
1353
		(void)SK_DRIVER_SENDEVENT(pAC, IoC);
1405
1354
1406
		/* Bugfix #10620 - get zero level for incremental difference */
1355
		/* Bugfix #10620 - get zero level for incremental difference. */
1407
		if (MacType == SK_MAC_XMAC) {
1356
		if (MacType == SK_MAC_XMAC) {
1408
1357
1409
			(void)pAC->GIni.GIFunc.pFnMacStatistic(pAC, IoC, PhysPortIndex,
1358
			(void)pAC->GIni.GIFunc.pFnMacStatistic(pAC, IoC, PhysPortIndex,
Lines 1435-1451 Link Here
1435
		}
1384
		}
1436
#endif /* DEBUG */
1385
#endif /* DEBUG */
1437
1386
1438
		/*
1387
		/* For now, ignore event if NetIndex != 0. */
1439
		 * For now, ignore event if NetIndex != 0.
1440
		 */
1441
		if (Param.Para32[1] != 0) {
1388
		if (Param.Para32[1] != 0) {
1442
1389
1443
			return (0);
1390
			return (0);
1444
		}
1391
		}
1445
1392
1446
		/*
1393
		/* Nothing to do if port is already inactive. */
1447
		 * Nothing to do if port is already inactive
1448
		 */
1449
		if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
1394
		if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
1450
1395
1451
			return (0);
1396
			return (0);
Lines 1476-1482 Link Here
1476
			CounterIndex ++) {
1421
			CounterIndex ++) {
1477
1422
1478
			if (!StatAddr[CounterIndex][MacType].GetOffset) {
1423
			if (!StatAddr[CounterIndex][MacType].GetOffset) {
1479
1480
				continue;
1424
				continue;
1481
			}
1425
			}
1482
1426
Lines 1485-1493 Link Here
1485
			pAC->Pnmi.VirtualCounterOffset[CounterIndex] += Value;
1429
			pAC->Pnmi.VirtualCounterOffset[CounterIndex] += Value;
1486
		}
1430
		}
1487
1431
1488
		/*
1432
		/* Set port to inactive. */
1489
		 * Set port to inactive
1490
		 */
1491
		pAC->Pnmi.Port[PhysPortIndex].ActiveFlag = SK_FALSE;
1433
		pAC->Pnmi.Port[PhysPortIndex].ActiveFlag = SK_FALSE;
1492
1434
1493
		pAC->Pnmi.MacUpdatedFlag --;
1435
		pAC->Pnmi.MacUpdatedFlag --;
Lines 1513-1537 Link Here
1513
		}
1455
		}
1514
#endif /* DEBUG */
1456
#endif /* DEBUG */
1515
1457
1516
		/*
1458
		/* For now, ignore event if NetIndex != 0. */
1517
		 * For now, ignore event if NetIndex != 0.
1518
		 */
1519
		if (Param.Para32[1] != 0) {
1459
		if (Param.Para32[1] != 0) {
1520
1460
1521
			return (0);
1461
			return (0);
1522
		}
1462
		}
1523
1463
1524
		/*
1464
		/* Nothing to do if port is already inactive. */
1525
		 * Nothing to do if port is already active
1526
		 */
1527
		if (pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
1465
		if (pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
1528
1466
1529
			return (0);
1467
			return (0);
1530
		}
1468
		}
1531
1469
1532
		/*
1470
		/* Statistic maintenance. */
1533
		 * Statistic maintenance
1534
		 */
1535
		pAC->Pnmi.RlmtChangeCts ++;
1471
		pAC->Pnmi.RlmtChangeCts ++;
1536
		pAC->Pnmi.RlmtChangeTime = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC));
1472
		pAC->Pnmi.RlmtChangeTime = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC));
1537
1473
Lines 1565-1571 Link Here
1565
			CounterIndex ++) {
1501
			CounterIndex ++) {
1566
1502
1567
			if (!StatAddr[CounterIndex][MacType].GetOffset) {
1503
			if (!StatAddr[CounterIndex][MacType].GetOffset) {
1568
1569
				continue;
1504
				continue;
1570
			}
1505
			}
1571
1506
Lines 1574-1589 Link Here
1574
			pAC->Pnmi.VirtualCounterOffset[CounterIndex] -= Value;
1509
			pAC->Pnmi.VirtualCounterOffset[CounterIndex] -= Value;
1575
		}
1510
		}
1576
1511
1577
		/* Set port to active */
1512
		/* Set port to active. */
1578
		pAC->Pnmi.Port[PhysPortIndex].ActiveFlag = SK_TRUE;
1513
		pAC->Pnmi.Port[PhysPortIndex].ActiveFlag = SK_TRUE;
1579
1514
1580
		pAC->Pnmi.MacUpdatedFlag --;
1515
		pAC->Pnmi.MacUpdatedFlag --;
1581
		break;
1516
		break;
1582
1517
1583
	case SK_PNMI_EVT_RLMT_SEGMENTATION:
1518
	case SK_PNMI_EVT_RLMT_SEGMENTATION:
1584
		/*
1519
		/* Para.Para32[0] contains the NetIndex. */
1585
		 * Para.Para32[0] contains the NetIndex.
1586
		 */
1587
1520
1588
		/*
1521
		/*
1589
		 * Store a trap message in the trap buffer and generate an event for
1522
		 * Store a trap message in the trap buffer and generate an event for
Lines 1598-1668 Link Here
1598
		 *  Param.Para32[0] contains the number of Nets.
1531
		 *  Param.Para32[0] contains the number of Nets.
1599
		 *  Param.Para32[1] is reserved, contains -1.
1532
		 *  Param.Para32[1] is reserved, contains -1.
1600
		 */
1533
		 */
1601
	    /*
1534
	    /* Check number of nets. */
1602
    	 * Check number of nets
1603
		 */
1604
		MaxNetNumber = pAC->GIni.GIMacsFound;
1535
		MaxNetNumber = pAC->GIni.GIMacsFound;
1605
		if (((unsigned int)Param.Para32[0] < 1)
1536
		
1606
			|| ((unsigned int)Param.Para32[0] > MaxNetNumber)) {
1537
		if (((unsigned int)Param.Para32[0] < 1) ||
1538
			((unsigned int)Param.Para32[0] > MaxNetNumber)) {
1539
			
1607
			return (SK_PNMI_ERR_UNKNOWN_NET);
1540
			return (SK_PNMI_ERR_UNKNOWN_NET);
1608
		}
1541
		}
1609
1542
1610
        if ((unsigned int)Param.Para32[0] == 1) { /* single net mode */
1543
        if ((unsigned int)Param.Para32[0] == 1) { /* SingleNet mode. */
1611
        	pAC->Pnmi.DualNetActiveFlag = SK_FALSE;
1544
        	pAC->Pnmi.DualNetActiveFlag = SK_FALSE;
1612
        }
1545
        }
1613
        else { /* dual net mode */
1546
        else { /* DualNet mode. */
1614
        	pAC->Pnmi.DualNetActiveFlag = SK_TRUE;
1547
        	pAC->Pnmi.DualNetActiveFlag = SK_TRUE;
1615
        }
1548
        }
1616
        break;
1549
        break;
1617
1550
1618
    case SK_PNMI_EVT_VCT_RESET:
1551
    case SK_PNMI_EVT_VCT_RESET:
1619
		PhysPortIndex = Param.Para32[0];
1552
		PhysPortIndex = Param.Para32[0];
1620
		pPrt = &pAC->GIni.GP[PhysPortIndex];
1621
		pVctBackupData = &pAC->Pnmi.VctBackup[PhysPortIndex];
1622
		
1553
		
1623
		if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_PENDING) {
1554
		if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_PENDING) {
1555
			
1624
			RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_FALSE);
1556
			RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_FALSE);
1557
			
1625
			if (RetCode == 2) {
1558
			if (RetCode == 2) {
1626
				/*
1559
				/*
1627
				 * VCT test is still running.
1560
				 * VCT test is still running.
1628
				 * Start VCT timer counter again.
1561
				 * Start VCT timer counter again.
1629
				 */
1562
				 */
1630
				SK_MEMSET((char *) &Param, 0, sizeof(Param));
1563
				SK_MEMSET((char *)&Param, 0, sizeof(Param));
1564
				
1631
				Param.Para32[0] = PhysPortIndex;
1565
				Param.Para32[0] = PhysPortIndex;
1632
				Param.Para32[1] = -1;
1566
				Param.Para32[1] = -1;
1633
				SkTimerStart(pAC, IoC,
1567
				
1634
					&pAC->Pnmi.VctTimeout[PhysPortIndex].VctTimer,
1568
				SkTimerStart(pAC, IoC, &pAC->Pnmi.VctTimeout[PhysPortIndex],
1635
				4000000, SKGE_PNMI, SK_PNMI_EVT_VCT_RESET, Param);
1569
					SK_PNMI_VCT_TIMER_CHECK, SKGE_PNMI, SK_PNMI_EVT_VCT_RESET, Param);
1570
				
1636
				break;
1571
				break;
1637
			}
1572
			}
1638
			pAC->Pnmi.VctStatus[PhysPortIndex] &= ~SK_PNMI_VCT_PENDING;
1639
			pAC->Pnmi.VctStatus[PhysPortIndex] |=
1640
				(SK_PNMI_VCT_NEW_VCT_DATA | SK_PNMI_VCT_TEST_DONE);
1641
			
1573
			
1642
			/* Copy results for later use to PNMI struct. */
1574
			VctGetResults(pAC, IoC, PhysPortIndex);
1643
			for (i = 0; i < 4; i++)  {
1644
				if (pPrt->PMdiPairSts[i] == SK_PNMI_VCT_NORMAL_CABLE) {
1645
					if ((pPrt->PMdiPairLen[i] > 35) &&
1646
						(pPrt->PMdiPairLen[i] < 0xff)) {
1647
						pPrt->PMdiPairSts[i] = SK_PNMI_VCT_IMPEDANCE_MISMATCH;
1648
					}
1649
				}
1650
				if ((pPrt->PMdiPairLen[i] > 35) &&
1651
					(pPrt->PMdiPairLen[i] != 0xff)) {
1652
					CableLength = 1000 *
1653
						(((175 * pPrt->PMdiPairLen[i]) / 210) - 28);
1654
				}
1655
				else {
1656
					CableLength = 0;
1657
				}
1658
				pVctBackupData->PMdiPairLen[i] = CableLength;
1659
				pVctBackupData->PMdiPairSts[i] = pPrt->PMdiPairSts[i];
1660
			}
1661
			
1575
			
1662
			Param.Para32[0] = PhysPortIndex;
1576
			EventParam.Para32[0] = PhysPortIndex;
1663
			Param.Para32[1] = -1;
1577
			EventParam.Para32[1] = -1;
1664
			SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, Param);
1578
			SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, EventParam);
1665
			SkEventDispatcher(pAC, IoC);
1579
1580
			/* SkEventDispatcher(pAC, IoC); */
1666
		}
1581
		}
1667
		
1582
		
1668
		break;
1583
		break;
Lines 1710-1723 Link Here
1710
	unsigned int	TableIndex;
1625
	unsigned int	TableIndex;
1711
	int		Ret;
1626
	int		Ret;
1712
1627
1713
1714
	if ((TableIndex = LookupId(Id)) == (unsigned int)(-1)) {
1628
	if ((TableIndex = LookupId(Id)) == (unsigned int)(-1)) {
1715
1629
1716
		*pLen = 0;
1630
		*pLen = 0;
1717
		return (SK_PNMI_ERR_UNKNOWN_OID);
1631
		return (SK_PNMI_ERR_UNKNOWN_OID);
1718
	}
1632
	}
1719
	
1633
	
1720
    /* Check NetIndex */
1634
    /* Check NetIndex. */
1721
	if (NetIndex >= pAC->Rlmt.NumNets) {
1635
	if (NetIndex >= pAC->Rlmt.NumNets) {
1722
		return (SK_PNMI_ERR_UNKNOWN_NET);
1636
		return (SK_PNMI_ERR_UNKNOWN_NET);
1723
	}
1637
	}
Lines 1767-1788 Link Here
1767
	SK_U32		Instance;
1681
	SK_U32		Instance;
1768
	SK_U32		Id;
1682
	SK_U32		Id;
1769
1683
1770
1684
	/* Check if the passed buffer has the right size. */
1771
	/* Check if the passed buffer has the right size */
1772
	if (*pLen < SK_PNMI_STRUCT_SIZE) {
1685
	if (*pLen < SK_PNMI_STRUCT_SIZE) {
1773
1686
1774
		/* Check if we can return the error within the buffer */
1687
		/* Check if we can return the error within the buffer. */
1775
		if (*pLen >= SK_PNMI_MIN_STRUCT_SIZE) {
1688
		if (*pLen >= SK_PNMI_MIN_STRUCT_SIZE) {
1776
1689
1777
			SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_TOO_SHORT,
1690
			SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_TOO_SHORT, (SK_U32)(-1));
1778
				(SK_U32)(-1));
1779
		}
1691
		}
1780
1692
1781
		*pLen = SK_PNMI_STRUCT_SIZE;
1693
		*pLen = SK_PNMI_STRUCT_SIZE;
1782
		return (SK_PNMI_ERR_TOO_SHORT);
1694
		return (SK_PNMI_ERR_TOO_SHORT);
1783
	}
1695
	}
1784
	
1696
	
1785
    /* Check NetIndex */
1697
    /* Check NetIndex. */
1786
	if (NetIndex >= pAC->Rlmt.NumNets) {
1698
	if (NetIndex >= pAC->Rlmt.NumNets) {
1787
		return (SK_PNMI_ERR_UNKNOWN_NET);
1699
		return (SK_PNMI_ERR_UNKNOWN_NET);
1788
	}
1700
	}
Lines 1810-1821 Link Here
1810
	pAC->Pnmi.RlmtUpdatedFlag ++;
1722
	pAC->Pnmi.RlmtUpdatedFlag ++;
1811
	pAC->Pnmi.SirqUpdatedFlag ++;
1723
	pAC->Pnmi.SirqUpdatedFlag ++;
1812
1724
1813
	/* Preset/Set values */
1725
	/* PRESET/SET values. */
1814
	for (TableIndex = 0; TableIndex < ID_TABLE_SIZE; TableIndex ++) {
1726
	for (TableIndex = 0; TableIndex < ID_TABLE_SIZE; TableIndex ++) {
1815
1727
1816
		if ((IdTable[TableIndex].Access != SK_PNMI_RW) &&
1728
		if ((IdTable[TableIndex].Access != SK_PNMI_RW) &&
1817
			(IdTable[TableIndex].Access != SK_PNMI_WO)) {
1729
			(IdTable[TableIndex].Access != SK_PNMI_WO)) {
1818
1819
			continue;
1730
			continue;
1820
		}
1731
		}
1821
1732
Lines 1826-1833 Link Here
1826
			InstanceCnt ++) {
1737
			InstanceCnt ++) {
1827
1738
1828
			DstOffset = IdTable[TableIndex].Offset +
1739
			DstOffset = IdTable[TableIndex].Offset +
1829
				(InstanceCnt - 1) *
1740
				(InstanceCnt - 1) * IdTable[TableIndex].StructSize;
1830
				IdTable[TableIndex].StructSize;
1831
1741
1832
			/*
1742
			/*
1833
			 * Because VPD multiple instance variables are
1743
			 * Because VPD multiple instance variables are
Lines 1837-1845 Link Here
1837
			 */
1747
			 */
1838
			Instance = (SK_U32)InstanceCnt;
1748
			Instance = (SK_U32)InstanceCnt;
1839
1749
1840
			/*
1750
			/* Evaluate needed buffer length. */
1841
			 * Evaluate needed buffer length
1842
			 */
1843
			Len = 0;
1751
			Len = 0;
1844
			Ret = IdTable[TableIndex].Func(pAC, IoC,
1752
			Ret = IdTable[TableIndex].Func(pAC, IoC,
1845
				SK_PNMI_GET, IdTable[TableIndex].Id,
1753
				SK_PNMI_GET, IdTable[TableIndex].Id,
Lines 1855-1862 Link Here
1855
				pAC->Pnmi.SirqUpdatedFlag --;
1763
				pAC->Pnmi.SirqUpdatedFlag --;
1856
1764
1857
				SK_PNMI_CHECKFLAGS("PnmiStruct: On return");
1765
				SK_PNMI_CHECKFLAGS("PnmiStruct: On return");
1858
				SK_PNMI_SET_STAT(pBuf,
1766
				SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_GENERAL, DstOffset);
1859
					SK_PNMI_ERR_GENERAL, DstOffset);
1860
				*pLen = SK_PNMI_MIN_STRUCT_SIZE;
1767
				*pLen = SK_PNMI_MIN_STRUCT_SIZE;
1861
				return (SK_PNMI_ERR_GENERAL);
1768
				return (SK_PNMI_ERR_GENERAL);
1862
			}
1769
			}
Lines 1878-1884 Link Here
1878
				}
1785
				}
1879
			}
1786
			}
1880
1787
1881
			/* Call the OID handler function */
1788
			/* Call the OID handler function. */
1882
			Ret = IdTable[TableIndex].Func(pAC, IoC, Action,
1789
			Ret = IdTable[TableIndex].Func(pAC, IoC, Action,
1883
				IdTable[TableIndex].Id, pBuf + DstOffset,
1790
				IdTable[TableIndex].Id, pBuf + DstOffset,
1884
				&Len, Instance, TableIndex, NetIndex);
1791
				&Len, Instance, TableIndex, NetIndex);
Lines 1889-1896 Link Here
1889
				pAC->Pnmi.SirqUpdatedFlag --;
1796
				pAC->Pnmi.SirqUpdatedFlag --;
1890
1797
1891
				SK_PNMI_CHECKFLAGS("PnmiStruct: On return");
1798
				SK_PNMI_CHECKFLAGS("PnmiStruct: On return");
1892
				SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_BAD_VALUE,
1799
				SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_BAD_VALUE, DstOffset);
1893
					DstOffset);
1894
				*pLen = SK_PNMI_MIN_STRUCT_SIZE;
1800
				*pLen = SK_PNMI_MIN_STRUCT_SIZE;
1895
				return (SK_PNMI_ERR_BAD_VALUE);
1801
				return (SK_PNMI_ERR_BAD_VALUE);
1896
			}
1802
			}
Lines 1924-1930 Link Here
1924
1830
1925
		if (IdTable[i].Id == Id) {
1831
		if (IdTable[i].Id == Id) {
1926
1832
1927
			return i;
1833
			return (i);
1928
		}
1834
		}
1929
	}
1835
	}
1930
1836
Lines 1965-1980 Link Here
1965
{
1871
{
1966
	if (Id != OID_SKGE_ALL_DATA) {
1872
	if (Id != OID_SKGE_ALL_DATA) {
1967
1873
1968
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR003,
1874
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR003, SK_PNMI_ERR003MSG);
1969
			SK_PNMI_ERR003MSG);
1970
1875
1971
		*pLen = 0;
1876
		*pLen = 0;
1972
		return (SK_PNMI_ERR_GENERAL);
1877
		return (SK_PNMI_ERR_GENERAL);
1973
	}
1878
	}
1974
1879
1975
	/*
1880
	/* Check instance. We only handle single instance variables. */
1976
	 * Check instance. We only handle single instance variables
1977
	 */
1978
	if (Instance != (SK_U32)(-1) && Instance != 1) {
1881
	if (Instance != (SK_U32)(-1) && Instance != 1) {
1979
1882
1980
		*pLen = 0;
1883
		*pLen = 0;
Lines 2033-2042 Link Here
2033
	int	Ret;
1936
	int	Ret;
2034
	SK_U32	ActionOp;
1937
	SK_U32	ActionOp;
2035
1938
2036
1939
	/* Check instance. We only handle single instance variables. */
2037
	/*
2038
	 * Check instance. We only handle single instance variables
2039
	 */
2040
	if (Instance != (SK_U32)(-1) && Instance != 1) {
1940
	if (Instance != (SK_U32)(-1) && Instance != 1) {
2041
1941
2042
		*pLen = 0;
1942
		*pLen = 0;
Lines 2049-2058 Link Here
2049
		return (SK_PNMI_ERR_TOO_SHORT);
1949
		return (SK_PNMI_ERR_TOO_SHORT);
2050
	}
1950
	}
2051
1951
2052
	/* Check if a get should be performed */
1952
	/* Check if a GET should be performed. */
2053
	if (Action == SK_PNMI_GET) {
1953
	if (Action == SK_PNMI_GET) {
2054
1954
2055
		/* A get is easy. We always return the same value */
1955
		/* A GET is easy. We always return the same value. */
2056
		ActionOp = (SK_U32)SK_PNMI_ACT_IDLE;
1956
		ActionOp = (SK_U32)SK_PNMI_ACT_IDLE;
2057
		SK_PNMI_STORE_U32(pBuf, ActionOp);
1957
		SK_PNMI_STORE_U32(pBuf, ActionOp);
2058
		*pLen = sizeof(SK_U32);
1958
		*pLen = sizeof(SK_U32);
Lines 2060-2072 Link Here
2060
		return (SK_PNMI_ERR_OK);
1960
		return (SK_PNMI_ERR_OK);
2061
	}
1961
	}
2062
1962
2063
	/* Continue with PRESET/SET action */
1963
	/* Continue with PRESET/SET action. */
2064
	if (*pLen > sizeof(SK_U32)) {
1964
	if (*pLen > sizeof(SK_U32)) {
2065
1965
2066
		return (SK_PNMI_ERR_BAD_VALUE);
1966
		return (SK_PNMI_ERR_BAD_VALUE);
2067
	}
1967
	}
2068
1968
2069
	/* Check if the command is a known one */
1969
	/* Check if the command is a known one. */
2070
	SK_PNMI_READ_U32(pBuf, ActionOp);
1970
	SK_PNMI_READ_U32(pBuf, ActionOp);
2071
	if (*pLen > sizeof(SK_U32) ||
1971
	if (*pLen > sizeof(SK_U32) ||
2072
		(ActionOp != SK_PNMI_ACT_IDLE &&
1972
		(ActionOp != SK_PNMI_ACT_IDLE &&
Lines 2078-2084 Link Here
2078
		return (SK_PNMI_ERR_BAD_VALUE);
1978
		return (SK_PNMI_ERR_BAD_VALUE);
2079
	}
1979
	}
2080
1980
2081
	/* A preset ends here */
1981
	/* A PRESET ends here. */
2082
	if (Action == SK_PNMI_PRESET) {
1982
	if (Action == SK_PNMI_PRESET) {
2083
1983
2084
		return (SK_PNMI_ERR_OK);
1984
		return (SK_PNMI_ERR_OK);
Lines 2087-2105 Link Here
2087
	switch (ActionOp) {
1987
	switch (ActionOp) {
2088
1988
2089
	case SK_PNMI_ACT_IDLE:
1989
	case SK_PNMI_ACT_IDLE:
2090
		/* Nothing to do */
1990
		/* Nothing to do. */
2091
		break;
1991
		break;
2092
1992
2093
	case SK_PNMI_ACT_RESET:
1993
	case SK_PNMI_ACT_RESET:
2094
		/*
1994
		/* Perform a driver reset or something that comes near to this. */
2095
		 * Perform a driver reset or something that comes near
2096
		 * to this.
2097
		 */
2098
		Ret = SK_DRIVER_RESET(pAC, IoC);
1995
		Ret = SK_DRIVER_RESET(pAC, IoC);
2099
		if (Ret != 0) {
1996
		if (Ret != 0) {
2100
1997
2101
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR005,
1998
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR005, SK_PNMI_ERR005MSG);
2102
				SK_PNMI_ERR005MSG);
2103
1999
2104
			return (SK_PNMI_ERR_GENERAL);
2000
			return (SK_PNMI_ERR_GENERAL);
2105
		}
2001
		}
Lines 2116-2128 Link Here
2116
		break;
2012
		break;
2117
2013
2118
	case SK_PNMI_ACT_RESETCNT:
2014
	case SK_PNMI_ACT_RESETCNT:
2119
		/* Set all counters and timestamps to zero */
2015
		/* Set all counters and timestamps to zero. */
2120
		ResetCounter(pAC, IoC, NetIndex);
2016
		ResetCounter(pAC, IoC, NetIndex);
2121
		break;
2017
		break;
2122
2018
2123
	default:
2019
	default:
2124
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR006,
2020
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR006, SK_PNMI_ERR006MSG);
2125
			SK_PNMI_ERR006MSG);
2126
2021
2127
		return (SK_PNMI_ERR_GENERAL);
2022
		return (SK_PNMI_ERR_GENERAL);
2128
	}
2023
	}
Lines 2166-2190 Link Here
2166
	SK_U32  StatVal32;
2061
	SK_U32  StatVal32;
2167
	SK_BOOL Is64BitReq = SK_FALSE;
2062
	SK_BOOL Is64BitReq = SK_FALSE;
2168
2063
2169
	/*
2064
	/* Only the active MAC is returned. */
2170
	 * Only the active Mac is returned
2171
	 */
2172
	if (Instance != (SK_U32)(-1) && Instance != 1) {
2065
	if (Instance != (SK_U32)(-1) && Instance != 1) {
2173
2066
2174
		*pLen = 0;
2067
		*pLen = 0;
2175
		return (SK_PNMI_ERR_UNKNOWN_INST);
2068
		return (SK_PNMI_ERR_UNKNOWN_INST);
2176
	}
2069
	}
2177
2070
2178
	/*
2071
	/* Check action type. */
2179
	 * Check action type
2180
	 */
2181
	if (Action != SK_PNMI_GET) {
2072
	if (Action != SK_PNMI_GET) {
2182
2073
2183
		*pLen = 0;
2074
		*pLen = 0;
2184
		return (SK_PNMI_ERR_READ_ONLY);
2075
		return (SK_PNMI_ERR_READ_ONLY);
2185
	}
2076
	}
2186
2077
2187
	/* Check length */
2078
	/* Check length. */
2188
	switch (Id) {
2079
	switch (Id) {
2189
2080
2190
	case OID_802_3_PERMANENT_ADDRESS:
2081
	case OID_802_3_PERMANENT_ADDRESS:
Lines 2205-2216 Link Here
2205
2096
2206
#else /* SK_NDIS_64BIT_CTR */
2097
#else /* SK_NDIS_64BIT_CTR */
2207
2098
2208
		/* for compatibility, at least 32bit are required for OID */
2099
		/* For compatibility, at least 32 bits are required for OID. */
2209
		if (*pLen < sizeof(SK_U32)) {
2100
		if (*pLen < sizeof(SK_U32)) {
2210
			/*
2101
			/*
2211
			* but indicate handling for 64bit values,
2102
			 * Indicate handling for 64 bit values,
2212
			* if insufficient space is provided
2103
			 * if insufficient space is provided.
2213
			*/
2104
			 */
2214
			*pLen = sizeof(SK_U64);
2105
			*pLen = sizeof(SK_U64);
2215
			return (SK_PNMI_ERR_TOO_SHORT);
2106
			return (SK_PNMI_ERR_TOO_SHORT);
2216
		}
2107
		}
Lines 2226-2241 Link Here
2226
	 * to indicate that an update was already done.
2117
	 * to indicate that an update was already done.
2227
	 */
2118
	 */
2228
	Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1);
2119
	Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1);
2229
	if ( Ret != SK_PNMI_ERR_OK) {
2120
	if (Ret != SK_PNMI_ERR_OK) {
2230
2121
2231
		*pLen = 0;
2122
		*pLen = 0;
2232
		return (Ret);
2123
		return (Ret);
2233
	}
2124
	}
2234
	pAC->Pnmi.MacUpdatedFlag ++;
2125
	pAC->Pnmi.MacUpdatedFlag ++;
2235
2126
2236
	/*
2127
	/* Get value (MAC index 0 identifies the virtual MAC). */
2237
	 * Get value (MAC Index 0 identifies the virtual MAC)
2238
	 */
2239
	switch (Id) {
2128
	switch (Id) {
2240
2129
2241
	case OID_802_3_PERMANENT_ADDRESS:
2130
	case OID_802_3_PERMANENT_ADDRESS:
Lines 2251-2257 Link Here
2251
	default:
2140
	default:
2252
		StatVal = GetStatVal(pAC, IoC, 0, IdTable[TableIndex].Param, NetIndex);
2141
		StatVal = GetStatVal(pAC, IoC, 0, IdTable[TableIndex].Param, NetIndex);
2253
2142
2254
		/* by default 32bit values are evaluated */
2143
		/* By default 32 bit values are evaluated. */
2255
		if (!Is64BitReq) {
2144
		if (!Is64BitReq) {
2256
			StatVal32 = (SK_U32)StatVal;
2145
			StatVal32 = (SK_U32)StatVal;
2257
			SK_PNMI_STORE_U32(pBuf, StatVal32);
2146
			SK_PNMI_STORE_U32(pBuf, StatVal32);
Lines 2305-2325 Link Here
2305
	int				MacType;
2194
	int				MacType;
2306
	int				Ret;
2195
	int				Ret;
2307
	SK_U64			StatVal;
2196
	SK_U64			StatVal;
2308
	
2309
	
2310
2197
2311
	/* Calculate instance if wished. MAC index 0 is the virtual MAC */
2198
	/* Calculate instance if wished. MAC index 0 is the virtual MAC. */
2312
	PhysPortMax = pAC->GIni.GIMacsFound;
2199
	PhysPortMax = pAC->GIni.GIMacsFound;
2313
	LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
2200
	LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
2314
	
2201
	
2315
	MacType = pAC->GIni.GIMacType;
2202
	MacType = pAC->GIni.GIMacType;
2316
2203
2317
	if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* Dual net mode */
2204
	if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* DualNet mode. */
2318
		LogPortMax--;
2205
		LogPortMax--;
2319
	}
2206
	}
2320
2207
2321
	if ((Instance != (SK_U32)(-1))) { /* Only one specific instance is queried */
2208
	if ((Instance != (SK_U32)(-1))) { /* Only one specific instance is queried. */
2322
		/* Check instance range */
2209
		/* Check instance range. */
2323
		if ((Instance < 1) || (Instance > LogPortMax)) {
2210
		if ((Instance < 1) || (Instance > LogPortMax)) {
2324
2211
2325
			*pLen = 0;
2212
			*pLen = 0;
Lines 2329-2348 Link Here
2329
		Limit = LogPortIndex + 1;
2216
		Limit = LogPortIndex + 1;
2330
	}
2217
	}
2331
2218
2332
	else { /* Instance == (SK_U32)(-1), get all Instances of that OID */
2219
	else { /* Instance == (SK_U32)(-1), get all Instances of that OID. */
2333
2220
2334
		LogPortIndex = 0;
2221
		LogPortIndex = 0;
2335
		Limit = LogPortMax;
2222
		Limit = LogPortMax;
2336
	}
2223
	}
2337
2224
2338
	/* Check action */
2225
	/* Check action. */
2339
	if (Action != SK_PNMI_GET) {
2226
	if (Action != SK_PNMI_GET) {
2340
2227
2341
		*pLen = 0;
2228
		*pLen = 0;
2342
		return (SK_PNMI_ERR_READ_ONLY);
2229
		return (SK_PNMI_ERR_READ_ONLY);
2343
	}
2230
	}
2344
2231
2345
	/* Check length */
2232
	/* Check length. */
2346
	if (*pLen < (Limit - LogPortIndex) * sizeof(SK_U64)) {
2233
	if (*pLen < (Limit - LogPortIndex) * sizeof(SK_U64)) {
2347
2234
2348
		*pLen = (Limit - LogPortIndex) * sizeof(SK_U64);
2235
		*pLen = (Limit - LogPortIndex) * sizeof(SK_U64);
Lines 2361-2367 Link Here
2361
	}
2248
	}
2362
	pAC->Pnmi.MacUpdatedFlag ++;
2249
	pAC->Pnmi.MacUpdatedFlag ++;
2363
2250
2364
	/* Get value */
2251
	/* Get value. */
2365
	Offset = 0;
2252
	Offset = 0;
2366
	for (; LogPortIndex < Limit; LogPortIndex ++) {
2253
	for (; LogPortIndex < Limit; LogPortIndex ++) {
2367
2254
Lines 2467-2485 Link Here
2467
	unsigned int	Limit;
2354
	unsigned int	Limit;
2468
	unsigned int	Offset = 0;
2355
	unsigned int	Offset = 0;
2469
2356
2470
	/*
2357
	/* Calculate instance if wished. MAC index 0 is the virtual MAC. */
2471
	 * Calculate instance if wished. MAC index 0 is the virtual
2472
	 * MAC.
2473
	 */
2474
	PhysPortMax = pAC->GIni.GIMacsFound;
2358
	PhysPortMax = pAC->GIni.GIMacsFound;
2475
	LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
2359
	LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
2476
2360
2477
	if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* Dual net mode */
2361
	if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* DualNet mode. */
2478
		LogPortMax--;
2362
		LogPortMax--;
2479
	}
2363
	}
2480
2364
2481
	if ((Instance != (SK_U32)(-1))) { /* Only one specific instance is queried */
2365
	if ((Instance != (SK_U32)(-1))) { /* Only one specific instance is queried. */
2482
		/* Check instance range */
2366
		/* Check instance range. */
2483
		if ((Instance < 1) || (Instance > LogPortMax)) {
2367
		if ((Instance < 1) || (Instance > LogPortMax)) {
2484
2368
2485
			*pLen = 0;
2369
			*pLen = 0;
Lines 2488-2514 Link Here
2488
		LogPortIndex = SK_PNMI_PORT_INST2LOG(Instance);
2372
		LogPortIndex = SK_PNMI_PORT_INST2LOG(Instance);
2489
		Limit = LogPortIndex + 1;
2373
		Limit = LogPortIndex + 1;
2490
	}
2374
	}
2491
	else { /* Instance == (SK_U32)(-1), get all Instances of that OID */
2375
	else { /* Instance == (SK_U32)(-1), get all Instances of that OID. */
2492
2376
2493
		LogPortIndex = 0;
2377
		LogPortIndex = 0;
2494
		Limit = LogPortMax;
2378
		Limit = LogPortMax;
2495
	}
2379
	}
2496
2380
2497
	/*
2381
	/* Perform action. */
2498
	 * Perform Action
2499
	 */
2500
	if (Action == SK_PNMI_GET) {
2382
	if (Action == SK_PNMI_GET) {
2501
2383
2502
		/* Check length */
2384
		/* Check length. */
2503
		if (*pLen < (Limit - LogPortIndex) * 6) {
2385
		if (*pLen < (Limit - LogPortIndex) * 6) {
2504
2386
2505
			*pLen = (Limit - LogPortIndex) * 6;
2387
			*pLen = (Limit - LogPortIndex) * 6;
2506
			return (SK_PNMI_ERR_TOO_SHORT);
2388
			return (SK_PNMI_ERR_TOO_SHORT);
2507
		}
2389
		}
2508
2390
2509
		/*
2391
		/* Get value. */
2510
		 * Get value
2511
		 */
2512
		for (; LogPortIndex < Limit; LogPortIndex ++) {
2392
		for (; LogPortIndex < Limit; LogPortIndex ++) {
2513
2393
2514
			switch (Id) {
2394
			switch (Id) {
Lines 2532-2539 Link Here
2532
						&pAC->Addr.Net[NetIndex].PermanentMacAddress);
2412
						&pAC->Addr.Net[NetIndex].PermanentMacAddress);
2533
				}
2413
				}
2534
				else {
2414
				else {
2535
					PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
2415
					PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
2536
						pAC, LogPortIndex);
2537
2416
2538
					CopyMac(pBuf + Offset,
2417
					CopyMac(pBuf + Offset,
2539
						&pAC->Addr.Port[PhysPortIndex].PermanentMacAddress);
2418
						&pAC->Addr.Port[PhysPortIndex].PermanentMacAddress);
Lines 2542-2549 Link Here
2542
				break;
2421
				break;
2543
2422
2544
			default:
2423
			default:
2545
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR008,
2424
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR008, SK_PNMI_ERR008MSG);
2546
					SK_PNMI_ERR008MSG);
2547
2425
2548
				*pLen = 0;
2426
				*pLen = 0;
2549
				return (SK_PNMI_ERR_GENERAL);
2427
				return (SK_PNMI_ERR_GENERAL);
Lines 2554-2561 Link Here
2554
	}
2432
	}
2555
	else {
2433
	else {
2556
		/*
2434
		/*
2557
		 * The logical MAC address may not be changed only
2435
		 * The logical MAC address may not be changed,
2558
		 * the physical ones
2436
		 * only the physical ones.
2559
		 */
2437
		 */
2560
		if (Id == OID_SKGE_PHYS_FAC_ADDR) {
2438
		if (Id == OID_SKGE_PHYS_FAC_ADDR) {
2561
2439
Lines 2563-2581 Link Here
2563
			return (SK_PNMI_ERR_READ_ONLY);
2441
			return (SK_PNMI_ERR_READ_ONLY);
2564
		}
2442
		}
2565
2443
2566
		/*
2444
		/* Only the current address may be changed. */
2567
		 * Only the current address may be changed
2568
		 */
2569
		if (Id != OID_SKGE_PHYS_CUR_ADDR) {
2445
		if (Id != OID_SKGE_PHYS_CUR_ADDR) {
2570
2446
2571
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR009,
2447
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR009, SK_PNMI_ERR009MSG);
2572
				SK_PNMI_ERR009MSG);
2573
2448
2574
			*pLen = 0;
2449
			*pLen = 0;
2575
			return (SK_PNMI_ERR_GENERAL);
2450
			return (SK_PNMI_ERR_GENERAL);
2576
		}
2451
		}
2577
2452
2578
		/* Check length */
2453
		/* Check length. */
2579
		if (*pLen < (Limit - LogPortIndex) * 6) {
2454
		if (*pLen < (Limit - LogPortIndex) * 6) {
2580
2455
2581
			*pLen = (Limit - LogPortIndex) * 6;
2456
			*pLen = (Limit - LogPortIndex) * 6;
Lines 2587-2618 Link Here
2587
			return (SK_PNMI_ERR_BAD_VALUE);
2462
			return (SK_PNMI_ERR_BAD_VALUE);
2588
		}
2463
		}
2589
2464
2590
		/*
2465
		/* Check action. */
2591
		 * Check Action
2592
		 */
2593
		if (Action == SK_PNMI_PRESET) {
2466
		if (Action == SK_PNMI_PRESET) {
2594
2467
2595
			*pLen = 0;
2468
			*pLen = 0;
2596
			return (SK_PNMI_ERR_OK);
2469
			return (SK_PNMI_ERR_OK);
2597
		}
2470
		}
2598
2471
2599
		/*
2472
		/* Set OID_SKGE_MAC_CUR_ADDR.  */
2600
		 * Set OID_SKGE_MAC_CUR_ADDR
2601
		 */
2602
		for (; LogPortIndex < Limit; LogPortIndex ++, Offset += 6) {
2473
		for (; LogPortIndex < Limit; LogPortIndex ++, Offset += 6) {
2603
2474
2604
			/*
2475
			/*
2605
			 * A set to virtual port and set of broadcast
2476
			 * A set to virtual port and set of broadcast
2606
			 * address will be ignored
2477
			 * address will be ignored.
2607
			 */
2478
			 */
2608
			if (LogPortIndex == 0 || SK_MEMCMP(pBuf + Offset,
2479
			if (LogPortIndex == 0 || SK_MEMCMP(pBuf + Offset,
2609
				"\xff\xff\xff\xff\xff\xff", 6) == 0) {
2480
				"\xff\xff\xff\xff\xff\xff", 6) == 0) {
2610
2611
				continue;
2481
				continue;
2612
			}
2482
			}
2613
2483
2614
			PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC,
2484
			PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
2615
				LogPortIndex);
2616
2485
2617
			Ret = SkAddrOverride(pAC, IoC, PhysPortIndex,
2486
			Ret = SkAddrOverride(pAC, IoC, PhysPortIndex,
2618
				(SK_MAC_ADDR *)(pBuf + Offset),
2487
				(SK_MAC_ADDR *)(pBuf + Offset),
Lines 2665-2674 Link Here
2665
	unsigned int	Offset = 0;
2534
	unsigned int	Offset = 0;
2666
	SK_U64		StatVal;
2535
	SK_U64		StatVal;
2667
2536
2668
2537
	/* Calculate instance if wished. */
2669
	/*
2670
	 * Calculate instance if wished
2671
	 */
2672
	if (Instance != (SK_U32)(-1)) {
2538
	if (Instance != (SK_U32)(-1)) {
2673
2539
2674
		if ((Instance < 1) || (Instance > SKCS_NUM_PROTOCOLS)) {
2540
		if ((Instance < 1) || (Instance > SKCS_NUM_PROTOCOLS)) {
Lines 2684-2708 Link Here
2684
		Limit = SKCS_NUM_PROTOCOLS;
2550
		Limit = SKCS_NUM_PROTOCOLS;
2685
	}
2551
	}
2686
2552
2687
	/*
2553
	/* Check action. */
2688
	 * Check action
2689
	 */
2690
	if (Action != SK_PNMI_GET) {
2554
	if (Action != SK_PNMI_GET) {
2691
2555
2692
		*pLen = 0;
2556
		*pLen = 0;
2693
		return (SK_PNMI_ERR_READ_ONLY);
2557
		return (SK_PNMI_ERR_READ_ONLY);
2694
	}
2558
	}
2695
2559
2696
	/* Check length */
2560
	/* Check length. */
2697
	if (*pLen < (Limit - Index) * sizeof(SK_U64)) {
2561
	if (*pLen < (Limit - Index) * sizeof(SK_U64)) {
2698
2562
2699
		*pLen = (Limit - Index) * sizeof(SK_U64);
2563
		*pLen = (Limit - Index) * sizeof(SK_U64);
2700
		return (SK_PNMI_ERR_TOO_SHORT);
2564
		return (SK_PNMI_ERR_TOO_SHORT);
2701
	}
2565
	}
2702
2566
2703
	/*
2567
	/* Get value. */
2704
	 * Get value
2705
	 */
2706
	for (; Index < Limit; Index ++) {
2568
	for (; Index < Limit; Index ++) {
2707
2569
2708
		switch (Id) {
2570
		switch (Id) {
Lines 2728-2735 Link Here
2728
			break;
2590
			break;
2729
2591
2730
		default:
2592
		default:
2731
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR010,
2593
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR010, SK_PNMI_ERR010MSG);
2732
				SK_PNMI_ERR010MSG);
2733
2594
2734
			*pLen = 0;
2595
			*pLen = 0;
2735
			return (SK_PNMI_ERR_GENERAL);
2596
			return (SK_PNMI_ERR_GENERAL);
Lines 2739-2747 Link Here
2739
		Offset += sizeof(SK_U64);
2600
		Offset += sizeof(SK_U64);
2740
	}
2601
	}
2741
2602
2742
	/*
2603
	/* Store used buffer space. */
2743
	 * Store used buffer space
2744
	 */
2745
	*pLen = Offset;
2604
	*pLen = Offset;
2746
2605
2747
	return (SK_PNMI_ERR_OK);
2606
	return (SK_PNMI_ERR_OK);
Lines 2784-2793 Link Here
2784
	SK_U32		Val32;
2643
	SK_U32		Val32;
2785
	SK_U64		Val64;
2644
	SK_U64		Val64;
2786
2645
2787
2646
	/* Calculate instance if wished. */
2788
	/*
2789
	 * Calculate instance if wished
2790
	 */
2791
	if ((Instance != (SK_U32)(-1))) {
2647
	if ((Instance != (SK_U32)(-1))) {
2792
2648
2793
		if ((Instance < 1) || (Instance > (SK_U32)pAC->I2c.MaxSens)) {
2649
		if ((Instance < 1) || (Instance > (SK_U32)pAC->I2c.MaxSens)) {
Lines 2804-2819 Link Here
2804
		Limit = (unsigned int) pAC->I2c.MaxSens;
2660
		Limit = (unsigned int) pAC->I2c.MaxSens;
2805
	}
2661
	}
2806
2662
2807
	/*
2663
	/* Check action. */
2808
	 * Check action
2809
	 */
2810
	if (Action != SK_PNMI_GET) {
2664
	if (Action != SK_PNMI_GET) {
2811
2665
2812
		*pLen = 0;
2666
		*pLen = 0;
2813
		return (SK_PNMI_ERR_READ_ONLY);
2667
		return (SK_PNMI_ERR_READ_ONLY);
2814
	}
2668
	}
2815
2669
2816
	/* Check length */
2670
	/* Check length. */
2817
	switch (Id) {
2671
	switch (Id) {
2818
2672
2819
	case OID_SKGE_SENSOR_VALUE:
2673
	case OID_SKGE_SENSOR_VALUE:
Lines 2872-2909 Link Here
2872
		break;
2726
		break;
2873
2727
2874
	default:
2728
	default:
2875
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR012,
2729
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR012, SK_PNMI_ERR012MSG);
2876
			SK_PNMI_ERR012MSG);
2877
2730
2878
		*pLen = 0;
2731
		*pLen = 0;
2879
		return (SK_PNMI_ERR_GENERAL);
2732
		return (SK_PNMI_ERR_GENERAL);
2880
2733
2881
	}
2734
	}
2882
2735
2883
	/*
2736
	/* Get value. */
2884
	 * Get value
2885
	 */
2886
	for (Offset = 0; Index < Limit; Index ++) {
2737
	for (Offset = 0; Index < Limit; Index ++) {
2887
2738
2888
		switch (Id) {
2739
		switch (Id) {
2889
2740
2890
		case OID_SKGE_SENSOR_INDEX:
2741
		case OID_SKGE_SENSOR_INDEX:
2891
			*(pBuf + Offset) = (char)Index;
2742
			*(pBuf + Offset) = (char)Index;
2892
			Offset += sizeof(char);
2743
			Offset ++;
2893
			break;
2744
			break;
2894
2745
2895
		case OID_SKGE_SENSOR_DESCR:
2746
		case OID_SKGE_SENSOR_DESCR:
2896
			Len = SK_STRLEN(pAC->I2c.SenTable[Index].SenDesc);
2747
			Len = SK_STRLEN(pAC->I2c.SenTable[Index].SenDesc);
2897
			SK_MEMCPY(pBuf + Offset + 1,
2748
			SK_MEMCPY(pBuf + Offset + 1, pAC->I2c.SenTable[Index].SenDesc, Len);
2898
				pAC->I2c.SenTable[Index].SenDesc, Len);
2899
			*(pBuf + Offset) = (char)Len;
2749
			*(pBuf + Offset) = (char)Len;
2900
			Offset += Len + 1;
2750
			Offset += Len + 1;
2901
			break;
2751
			break;
2902
2752
2903
		case OID_SKGE_SENSOR_TYPE:
2753
		case OID_SKGE_SENSOR_TYPE:
2904
			*(pBuf + Offset) =
2754
			*(pBuf + Offset) = (char)pAC->I2c.SenTable[Index].SenType;
2905
				(char)pAC->I2c.SenTable[Index].SenType;
2755
			Offset ++;
2906
			Offset += sizeof(char);
2907
			break;
2756
			break;
2908
2757
2909
		case OID_SKGE_SENSOR_VALUE:
2758
		case OID_SKGE_SENSOR_VALUE:
Lines 2940-2948 Link Here
2940
			break;
2789
			break;
2941
2790
2942
		case OID_SKGE_SENSOR_STATUS:
2791
		case OID_SKGE_SENSOR_STATUS:
2943
			*(pBuf + Offset) =
2792
			*(pBuf + Offset) = (char)pAC->I2c.SenTable[Index].SenErrFlag;
2944
				(char)pAC->I2c.SenTable[Index].SenErrFlag;
2793
			Offset ++;
2945
			Offset += sizeof(char);
2946
			break;
2794
			break;
2947
2795
2948
		case OID_SKGE_SENSOR_WAR_CTS:
2796
		case OID_SKGE_SENSOR_WAR_CTS:
Lines 2979-2987 Link Here
2979
		}
2827
		}
2980
	}
2828
	}
2981
2829
2982
	/*
2830
	/* Store used buffer space. */
2983
	 * Store used buffer space
2984
	 */
2985
	*pLen = Offset;
2831
	*pLen = Offset;
2986
2832
2987
	return (SK_PNMI_ERR_OK);
2833
	return (SK_PNMI_ERR_OK);
Lines 3035-3043 Link Here
3035
	int		Ret;
2881
	int		Ret;
3036
	SK_U32		Val32;
2882
	SK_U32		Val32;
3037
2883
3038
	/*
2884
	/* Get array of all currently stored VPD keys. */
3039
	 * Get array of all currently stored VPD keys
3040
	 */
3041
	Ret = GetVpdKeyArr(pAC, IoC, &KeyArr[0][0], sizeof(KeyArr), &KeyNo);
2885
	Ret = GetVpdKeyArr(pAC, IoC, &KeyArr[0][0], sizeof(KeyArr), &KeyNo);
3042
	if (Ret != SK_PNMI_ERR_OK) {
2886
	if (Ret != SK_PNMI_ERR_OK) {
3043
		*pLen = 0;
2887
		*pLen = 0;
Lines 3082-3102 Link Here
3082
		}
2926
		}
3083
	}
2927
	}
3084
2928
3085
	/*
2929
	/* Get value, if a query should be performed. */
3086
	 * Get value, if a query should be performed
3087
	 */
3088
	if (Action == SK_PNMI_GET) {
2930
	if (Action == SK_PNMI_GET) {
3089
2931
3090
		switch (Id) {
2932
		switch (Id) {
3091
2933
3092
		case OID_SKGE_VPD_FREE_BYTES:
2934
		case OID_SKGE_VPD_FREE_BYTES:
3093
			/* Check length of buffer */
2935
			/* Check length of buffer. */
3094
			if (*pLen < sizeof(SK_U32)) {
2936
			if (*pLen < sizeof(SK_U32)) {
3095
2937
3096
				*pLen = sizeof(SK_U32);
2938
				*pLen = sizeof(SK_U32);
3097
				return (SK_PNMI_ERR_TOO_SHORT);
2939
				return (SK_PNMI_ERR_TOO_SHORT);
3098
			}
2940
			}
3099
			/* Get number of free bytes */
2941
			/* Get number of free bytes. */
3100
			pVpdStatus = VpdStat(pAC, IoC);
2942
			pVpdStatus = VpdStat(pAC, IoC);
3101
			if (pVpdStatus == NULL) {
2943
			if (pVpdStatus == NULL) {
3102
2944
Lines 3121-3127 Link Here
3121
			break;
2963
			break;
3122
2964
3123
		case OID_SKGE_VPD_ENTRIES_LIST:
2965
		case OID_SKGE_VPD_ENTRIES_LIST:
3124
			/* Check length */
2966
			/* Check length. */
3125
			for (Len = 0, Index = 0; Index < KeyNo; Index ++) {
2967
			for (Len = 0, Index = 0; Index < KeyNo; Index ++) {
3126
2968
3127
				Len += SK_STRLEN(KeyArr[Index]) + 1;
2969
				Len += SK_STRLEN(KeyArr[Index]) + 1;
Lines 3132-3138 Link Here
3132
				return (SK_PNMI_ERR_TOO_SHORT);
2974
				return (SK_PNMI_ERR_TOO_SHORT);
3133
			}
2975
			}
3134
2976
3135
			/* Get value */
2977
			/* Get value. */
3136
			*(pBuf) = (char)Len - 1;
2978
			*(pBuf) = (char)Len - 1;
3137
			for (Offset = 1, Index = 0; Index < KeyNo; Index ++) {
2979
			for (Offset = 1, Index = 0; Index < KeyNo; Index ++) {
3138
2980
Lines 3151-3157 Link Here
3151
			break;
2993
			break;
3152
2994
3153
		case OID_SKGE_VPD_ENTRIES_NUMBER:
2995
		case OID_SKGE_VPD_ENTRIES_NUMBER:
3154
			/* Check length */
2996
			/* Check length. */
3155
			if (*pLen < sizeof(SK_U32)) {
2997
			if (*pLen < sizeof(SK_U32)) {
3156
2998
3157
				*pLen = sizeof(SK_U32);
2999
				*pLen = sizeof(SK_U32);
Lines 3164-3170 Link Here
3164
			break;
3006
			break;
3165
3007
3166
		case OID_SKGE_VPD_KEY:
3008
		case OID_SKGE_VPD_KEY:
3167
			/* Check buffer length, if it is large enough */
3009
			/* Check buffer length, if it is large enough. */
3168
			for (Len = 0, Index = FirstIndex;
3010
			for (Len = 0, Index = FirstIndex;
3169
				Index < LastIndex; Index ++) {
3011
				Index < LastIndex; Index ++) {
3170
3012
Lines 3180-3210 Link Here
3180
			 * Get the key to an intermediate buffer, because
3022
			 * Get the key to an intermediate buffer, because
3181
			 * we have to prepend a length byte.
3023
			 * we have to prepend a length byte.
3182
			 */
3024
			 */
3183
			for (Offset = 0, Index = FirstIndex;
3025
			for (Offset = 0, Index = FirstIndex; Index < LastIndex; Index ++) {
3184
				Index < LastIndex; Index ++) {
3185
3026
3186
				Len = SK_STRLEN(KeyArr[Index]);
3027
				Len = SK_STRLEN(KeyArr[Index]);
3187
3028
3188
				*(pBuf + Offset) = (char)Len;
3029
				*(pBuf + Offset) = (char)Len;
3189
				SK_MEMCPY(pBuf + Offset + 1, KeyArr[Index],
3030
				SK_MEMCPY(pBuf + Offset + 1, KeyArr[Index], Len);
3190
					Len);
3191
				Offset += Len + 1;
3031
				Offset += Len + 1;
3192
			}
3032
			}
3193
			*pLen = Offset;
3033
			*pLen = Offset;
3194
			break;
3034
			break;
3195
3035
3196
		case OID_SKGE_VPD_VALUE:
3036
		case OID_SKGE_VPD_VALUE:
3197
			/* Check the buffer length if it is large enough */
3037
			/* Check the buffer length if it is large enough. */
3198
			for (Offset = 0, Index = FirstIndex;
3038
			for (Offset = 0, Index = FirstIndex; Index < LastIndex; Index ++) {
3199
				Index < LastIndex; Index ++) {
3200
3039
3201
				BufLen = 256;
3040
				BufLen = 256;
3202
				if (VpdRead(pAC, IoC, KeyArr[Index], Buf,
3041
				if (VpdRead(pAC, IoC, KeyArr[Index], Buf,
3203
					(int *)&BufLen) > 0 ||
3042
					(int *)&BufLen) > 0 ||
3204
					BufLen >= SK_PNMI_VPD_DATALEN) {
3043
					BufLen >= SK_PNMI_VPD_DATALEN) {
3205
3044
3206
					SK_ERR_LOG(pAC, SK_ERRCL_SW,
3045
					SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR021,
3207
						SK_PNMI_ERR021,
3208
						SK_PNMI_ERR021MSG);
3046
						SK_PNMI_ERR021MSG);
3209
3047
3210
					return (SK_PNMI_ERR_GENERAL);
3048
					return (SK_PNMI_ERR_GENERAL);
Lines 3221-3236 Link Here
3221
			 * Get the value to an intermediate buffer, because
3059
			 * Get the value to an intermediate buffer, because
3222
			 * we have to prepend a length byte.
3060
			 * we have to prepend a length byte.
3223
			 */
3061
			 */
3224
			for (Offset = 0, Index = FirstIndex;
3062
			for (Offset = 0, Index = FirstIndex; Index < LastIndex; Index ++) {
3225
				Index < LastIndex; Index ++) {
3226
3063
3227
				BufLen = 256;
3064
				BufLen = 256;
3228
				if (VpdRead(pAC, IoC, KeyArr[Index], Buf,
3065
				if (VpdRead(pAC, IoC, KeyArr[Index], Buf,
3229
					(int *)&BufLen) > 0 ||
3066
					(int *)&BufLen) > 0 ||
3230
					BufLen >= SK_PNMI_VPD_DATALEN) {
3067
					BufLen >= SK_PNMI_VPD_DATALEN) {
3231
3068
3232
					SK_ERR_LOG(pAC, SK_ERRCL_SW,
3069
					SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR022,
3233
						SK_PNMI_ERR022,
3234
						SK_PNMI_ERR022MSG);
3070
						SK_PNMI_ERR022MSG);
3235
3071
3236
					*pLen = 0;
3072
					*pLen = 0;
Lines 3251-3258 Link Here
3251
				return (SK_PNMI_ERR_TOO_SHORT);
3087
				return (SK_PNMI_ERR_TOO_SHORT);
3252
			}
3088
			}
3253
3089
3254
			for (Offset = 0, Index = FirstIndex;
3090
			for (Offset = 0, Index = FirstIndex; Index < LastIndex; Index ++) {
3255
				Index < LastIndex; Index ++) {
3256
3091
3257
				if (VpdMayWrite(KeyArr[Index])) {
3092
				if (VpdMayWrite(KeyArr[Index])) {
3258
3093
Lines 3278-3292 Link Here
3278
			break;
3113
			break;
3279
3114
3280
		default:
3115
		default:
3281
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR023,
3116
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR023, SK_PNMI_ERR023MSG);
3282
				SK_PNMI_ERR023MSG);
3283
3117
3284
			*pLen = 0;
3118
			*pLen = 0;
3285
			return (SK_PNMI_ERR_GENERAL);
3119
			return (SK_PNMI_ERR_GENERAL);
3286
		}
3120
		}
3287
	}
3121
	}
3288
	else {
3122
	else {
3289
		/* The only OID which can be set is VPD_ACTION */
3123
		/* The only OID which can be set is VPD_ACTION. */
3290
		if (Id != OID_SKGE_VPD_ACTION) {
3124
		if (Id != OID_SKGE_VPD_ACTION) {
3291
3125
3292
			if (Id == OID_SKGE_VPD_FREE_BYTES ||
3126
			if (Id == OID_SKGE_VPD_FREE_BYTES ||
Lines 3300-3307 Link Here
3300
				return (SK_PNMI_ERR_READ_ONLY);
3134
				return (SK_PNMI_ERR_READ_ONLY);
3301
			}
3135
			}
3302
3136
3303
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR024,
3137
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR024, SK_PNMI_ERR024MSG);
3304
				SK_PNMI_ERR024MSG);
3305
3138
3306
			*pLen = 0;
3139
			*pLen = 0;
3307
			return (SK_PNMI_ERR_GENERAL);
3140
			return (SK_PNMI_ERR_GENERAL);
Lines 3317-3330 Link Here
3317
			return (SK_PNMI_ERR_TOO_SHORT);
3150
			return (SK_PNMI_ERR_TOO_SHORT);
3318
		}
3151
		}
3319
3152
3320
		/*
3153
		/* The first byte contains the VPD action type we should perform. */
3321
		 * The first byte contains the VPD action type we should
3322
		 * perform.
3323
		 */
3324
		switch (*pBuf) {
3154
		switch (*pBuf) {
3325
3155
3326
		case SK_PNMI_VPD_IGNORE:
3156
		case SK_PNMI_VPD_IGNORE:
3327
			/* Nothing to do */
3157
			/* Nothing to do. */
3328
			break;
3158
			break;
3329
3159
3330
		case SK_PNMI_VPD_CREATE:
3160
		case SK_PNMI_VPD_CREATE:
Lines 3356-3368 Link Here
3356
			SK_MEMCPY(Buf, pBuf + 4, Offset);
3186
			SK_MEMCPY(Buf, pBuf + 4, Offset);
3357
			Buf[Offset] = 0;
3187
			Buf[Offset] = 0;
3358
3188
3359
			/* A preset ends here */
3189
			/* A PRESET ends here. */
3360
			if (Action == SK_PNMI_PRESET) {
3190
			if (Action == SK_PNMI_PRESET) {
3361
3191
3362
				return (SK_PNMI_ERR_OK);
3192
				return (SK_PNMI_ERR_OK);
3363
			}
3193
			}
3364
3194
3365
			/* Write the new entry or modify an existing one */
3195
			/* Write the new entry or modify an existing one .*/
3366
			Ret = VpdWrite(pAC, IoC, KeyStr, Buf);
3196
			Ret = VpdWrite(pAC, IoC, KeyStr, Buf);
3367
			if (Ret == SK_PNMI_VPD_NOWRITE ) {
3197
			if (Ret == SK_PNMI_VPD_NOWRITE ) {
3368
3198
Lines 3394-3400 Link Here
3394
			break;
3224
			break;
3395
3225
3396
		case SK_PNMI_VPD_DELETE:
3226
		case SK_PNMI_VPD_DELETE:
3397
			/* Check if the buffer size is plausible */
3227
			/* Check if the buffer size is plausible. */
3398
			if (*pLen < 3) {
3228
			if (*pLen < 3) {
3399
3229
3400
				*pLen = 3;
3230
				*pLen = 3;
Lines 3409-3415 Link Here
3409
			KeyStr[1] = pBuf[2];
3239
			KeyStr[1] = pBuf[2];
3410
			KeyStr[2] = 0;
3240
			KeyStr[2] = 0;
3411
3241
3412
			/* Find the passed key in the array */
3242
			/* Find the passed key in the array. */
3413
			for (Index = 0; Index < KeyNo; Index ++) {
3243
			for (Index = 0; Index < KeyNo; Index ++) {
3414
3244
3415
				if (SK_STRCMP(KeyStr, KeyArr[Index]) == 0) {
3245
				if (SK_STRCMP(KeyStr, KeyArr[Index]) == 0) {
Lines 3417-3422 Link Here
3417
					break;
3247
					break;
3418
				}
3248
				}
3419
			}
3249
			}
3250
3420
			/*
3251
			/*
3421
			 * If we cannot find the key it is wrong, so we
3252
			 * If we cannot find the key it is wrong, so we
3422
			 * return an appropriate error value.
3253
			 * return an appropriate error value.
Lines 3432-3438 Link Here
3432
				return (SK_PNMI_ERR_OK);
3263
				return (SK_PNMI_ERR_OK);
3433
			}
3264
			}
3434
3265
3435
			/* Ok, you wanted it and you will get it */
3266
			/* Ok, you wanted it and you will get it. */
3436
			Ret = VpdDelete(pAC, IoC, KeyStr);
3267
			Ret = VpdDelete(pAC, IoC, KeyStr);
3437
			if (Ret != SK_PNMI_VPD_OK) {
3268
			if (Ret != SK_PNMI_VPD_OK) {
3438
3269
Lines 3505-3527 Link Here
3505
	SK_U32		Val32;
3336
	SK_U32		Val32;
3506
	SK_U64		Val64;
3337
	SK_U64		Val64;
3507
	SK_U64		Val64RxHwErrs = 0;
3338
	SK_U64		Val64RxHwErrs = 0;
3339
	SK_U64		Val64RxRunt = 0;
3340
	SK_U64		Val64RxFcs = 0;
3508
	SK_U64		Val64TxHwErrs = 0;
3341
	SK_U64		Val64TxHwErrs = 0;
3509
	SK_BOOL		Is64BitReq = SK_FALSE;
3342
	SK_BOOL		Is64BitReq = SK_FALSE;
3510
	char		Buf[256];
3343
	char		Buf[256];
3511
	int			MacType;
3344
	int			MacType;
3512
3345
3513
	/*
3346
	/* Check instance. We only handle single instance variables. */
3514
	 * Check instance. We only handle single instance variables.
3515
	 */
3516
	if (Instance != (SK_U32)(-1) && Instance != 1) {
3347
	if (Instance != (SK_U32)(-1) && Instance != 1) {
3517
3348
3518
		*pLen = 0;
3349
		*pLen = 0;
3519
		return (SK_PNMI_ERR_UNKNOWN_INST);
3350
		return (SK_PNMI_ERR_UNKNOWN_INST);
3520
	}
3351
	}
3521
3352
3522
	/*
3353
	/* Check action. We only allow get requests. */
3523
	 * Check action. We only allow get requests.
3524
	 */
3525
	if (Action != SK_PNMI_GET) {
3354
	if (Action != SK_PNMI_GET) {
3526
3355
3527
		*pLen = 0;
3356
		*pLen = 0;
Lines 3530-3538 Link Here
3530
	
3359
	
3531
	MacType = pAC->GIni.GIMacType;
3360
	MacType = pAC->GIni.GIMacType;
3532
	
3361
	
3533
	/*
3362
	/* Check length for the various supported OIDs. */
3534
	 * Check length for the various supported OIDs
3535
	 */
3536
	switch (Id) {
3363
	switch (Id) {
3537
3364
3538
	case OID_GEN_XMIT_ERROR:
3365
	case OID_GEN_XMIT_ERROR:
Lines 3546-3559 Link Here
3546
3373
3547
#else /* SK_NDIS_64BIT_CTR */
3374
#else /* SK_NDIS_64BIT_CTR */
3548
3375
3549
		/*
3376
		/* For compatibility, at least 32bit are required for OID. */
3550
		 * for compatibility, at least 32bit are required for oid
3551
		 */
3552
		if (*pLen < sizeof(SK_U32)) {
3377
		if (*pLen < sizeof(SK_U32)) {
3553
			/*
3378
			/*
3554
			* but indicate handling for 64bit values,
3379
			 * Indicate handling for 64bit values,
3555
			* if insufficient space is provided
3380
			 * if insufficient space is provided.
3556
			*/
3381
			 */
3557
			*pLen = sizeof(SK_U64);
3382
			*pLen = sizeof(SK_U64);
3558
			return (SK_PNMI_ERR_TOO_SHORT);
3383
			return (SK_PNMI_ERR_TOO_SHORT);
3559
		}
3384
		}
Lines 3624-3634 Link Here
3624
		break;
3449
		break;
3625
3450
3626
	default:
3451
	default:
3627
		/* Checked later */
3452
		/* Checked later. */
3628
		break;
3453
		break;
3629
	}
3454
	}
3630
3455
3631
	/* Update statistic */
3456
	/* Update statistics. */
3632
	if (Id == OID_SKGE_RX_HW_ERROR_CTS ||
3457
	if (Id == OID_SKGE_RX_HW_ERROR_CTS ||
3633
		Id == OID_SKGE_TX_HW_ERROR_CTS ||
3458
		Id == OID_SKGE_TX_HW_ERROR_CTS ||
3634
		Id == OID_SKGE_IN_ERRORS_CTS ||
3459
		Id == OID_SKGE_IN_ERRORS_CTS ||
Lines 3636-3642 Link Here
3636
		Id == OID_GEN_XMIT_ERROR ||
3461
		Id == OID_GEN_XMIT_ERROR ||
3637
		Id == OID_GEN_RCV_ERROR) {
3462
		Id == OID_GEN_RCV_ERROR) {
3638
3463
3639
		/* Force the XMAC to update its statistic counters and
3464
		/*
3465
		 * Force the XMAC to update its statistic counters and
3640
		 * Increment semaphore to indicate that an update was
3466
		 * Increment semaphore to indicate that an update was
3641
		 * already done.
3467
		 * already done.
3642
		 */
3468
		 */
Lines 3667-3677 Link Here
3667
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_IRLENGTH, NetIndex) +
3493
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_IRLENGTH, NetIndex) +
3668
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_SYMBOL, NetIndex) +
3494
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_SYMBOL, NetIndex) +
3669
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_SHORTS, NetIndex) +
3495
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_SHORTS, NetIndex) +
3670
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_RUNT, NetIndex) +
3671
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_TOO_LONG, NetIndex) +
3496
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_TOO_LONG, NetIndex) +
3672
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_FCS, NetIndex) +
3673
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_CEXT, NetIndex);
3497
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_CEXT, NetIndex);
3674
	        break;
3498
3499
3500
			/*
3501
			* In some cases the runt and fcs counters are incremented when collisions
3502
			* occur. We have to correct those counters here.
3503
			*/
3504
			Val64RxRunt = GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_RUNT, NetIndex);
3505
			Val64RxFcs = GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_FCS, NetIndex);
3506
3507
			if (Val64RxRunt > Val64RxFcs) {
3508
				Val64RxRunt -= Val64RxFcs;
3509
				Val64RxHwErrs += Val64RxRunt;
3510
			}
3511
			else {
3512
				Val64RxFcs -= Val64RxRunt;
3513
				Val64RxHwErrs += Val64RxFcs;
3514
			}
3515
			break;
3675
3516
3676
		case OID_SKGE_TX_HW_ERROR_CTS:
3517
		case OID_SKGE_TX_HW_ERROR_CTS:
3677
		case OID_SKGE_OUT_ERROR_CTS:
3518
		case OID_SKGE_OUT_ERROR_CTS:
Lines 3685-3693 Link Here
3685
		}
3526
		}
3686
	}
3527
	}
3687
3528
3688
	/*
3529
	/* Retrieve value. */
3689
	 * Retrieve value
3690
	 */
3691
	switch (Id) {
3530
	switch (Id) {
3692
3531
3693
	case OID_SKGE_SUPPORTED_LIST:
3532
	case OID_SKGE_SUPPORTED_LIST:
Lines 3697-3707 Link Here
3697
			*pLen = Len;
3536
			*pLen = Len;
3698
			return (SK_PNMI_ERR_TOO_SHORT);
3537
			return (SK_PNMI_ERR_TOO_SHORT);
3699
		}
3538
		}
3700
		for (Offset = 0, Index = 0; Offset < Len;
3539
		for (Offset = 0, Index = 0; Offset < Len; Index ++) {
3701
			Offset += sizeof(SK_U32), Index ++) {
3702
3540
3703
			Val32 = (SK_U32)IdTable[Index].Id;
3541
			Val32 = (SK_U32)IdTable[Index].Id;
3704
			SK_PNMI_STORE_U32(pBuf + Offset, Val32);
3542
			SK_PNMI_STORE_U32(pBuf + Offset, Val32);
3543
			Offset += sizeof(SK_U32);
3705
		}
3544
		}
3706
		*pLen = Len;
3545
		*pLen = Len;
3707
		break;
3546
		break;
Lines 3727-3734 Link Here
3727
	case OID_SKGE_DRIVER_DESCR:
3566
	case OID_SKGE_DRIVER_DESCR:
3728
		if (pAC->Pnmi.pDriverDescription == NULL) {
3567
		if (pAC->Pnmi.pDriverDescription == NULL) {
3729
3568
3730
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR007,
3569
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR007, SK_PNMI_ERR007MSG);
3731
				SK_PNMI_ERR007MSG);
3732
3570
3733
			*pLen = 0;
3571
			*pLen = 0;
3734
			return (SK_PNMI_ERR_GENERAL);
3572
			return (SK_PNMI_ERR_GENERAL);
Lines 3737-3744 Link Here
3737
		Len = SK_STRLEN(pAC->Pnmi.pDriverDescription) + 1;
3575
		Len = SK_STRLEN(pAC->Pnmi.pDriverDescription) + 1;
3738
		if (Len > SK_PNMI_STRINGLEN1) {
3576
		if (Len > SK_PNMI_STRINGLEN1) {
3739
3577
3740
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR029,
3578
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR029, SK_PNMI_ERR029MSG);
3741
				SK_PNMI_ERR029MSG);
3742
3579
3743
			*pLen = 0;
3580
			*pLen = 0;
3744
			return (SK_PNMI_ERR_GENERAL);
3581
			return (SK_PNMI_ERR_GENERAL);
Lines 3757-3764 Link Here
3757
	case OID_SKGE_DRIVER_VERSION:
3594
	case OID_SKGE_DRIVER_VERSION:
3758
		if (pAC->Pnmi.pDriverVersion == NULL) {
3595
		if (pAC->Pnmi.pDriverVersion == NULL) {
3759
3596
3760
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR030,
3597
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR030, SK_PNMI_ERR030MSG);
3761
				SK_PNMI_ERR030MSG);
3762
3598
3763
			*pLen = 0;
3599
			*pLen = 0;
3764
			return (SK_PNMI_ERR_GENERAL);
3600
			return (SK_PNMI_ERR_GENERAL);
Lines 3767-3774 Link Here
3767
		Len = SK_STRLEN(pAC->Pnmi.pDriverVersion) + 1;
3603
		Len = SK_STRLEN(pAC->Pnmi.pDriverVersion) + 1;
3768
		if (Len > SK_PNMI_STRINGLEN1) {
3604
		if (Len > SK_PNMI_STRINGLEN1) {
3769
3605
3770
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR031,
3606
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR031, SK_PNMI_ERR031MSG);
3771
				SK_PNMI_ERR031MSG);
3772
3607
3773
			*pLen = 0;
3608
			*pLen = 0;
3774
			return (SK_PNMI_ERR_GENERAL);
3609
			return (SK_PNMI_ERR_GENERAL);
Lines 3787-3794 Link Here
3787
	case OID_SKGE_DRIVER_RELDATE:
3622
	case OID_SKGE_DRIVER_RELDATE:
3788
		if (pAC->Pnmi.pDriverReleaseDate == NULL) {
3623
		if (pAC->Pnmi.pDriverReleaseDate == NULL) {
3789
3624
3790
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR030,
3625
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR053, SK_PNMI_ERR053MSG);
3791
				SK_PNMI_ERR053MSG);
3792
3626
3793
			*pLen = 0;
3627
			*pLen = 0;
3794
			return (SK_PNMI_ERR_GENERAL);
3628
			return (SK_PNMI_ERR_GENERAL);
Lines 3797-3804 Link Here
3797
		Len = SK_STRLEN(pAC->Pnmi.pDriverReleaseDate) + 1;
3631
		Len = SK_STRLEN(pAC->Pnmi.pDriverReleaseDate) + 1;
3798
		if (Len > SK_PNMI_STRINGLEN1) {
3632
		if (Len > SK_PNMI_STRINGLEN1) {
3799
3633
3800
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR031,
3634
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR054, SK_PNMI_ERR054MSG);
3801
				SK_PNMI_ERR054MSG);
3802
3635
3803
			*pLen = 0;
3636
			*pLen = 0;
3804
			return (SK_PNMI_ERR_GENERAL);
3637
			return (SK_PNMI_ERR_GENERAL);
Lines 3817-3824 Link Here
3817
	case OID_SKGE_DRIVER_FILENAME:
3650
	case OID_SKGE_DRIVER_FILENAME:
3818
		if (pAC->Pnmi.pDriverFileName == NULL) {
3651
		if (pAC->Pnmi.pDriverFileName == NULL) {
3819
3652
3820
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR030,
3653
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR055, SK_PNMI_ERR055MSG);
3821
				SK_PNMI_ERR055MSG);
3822
3654
3823
			*pLen = 0;
3655
			*pLen = 0;
3824
			return (SK_PNMI_ERR_GENERAL);
3656
			return (SK_PNMI_ERR_GENERAL);
Lines 3827-3834 Link Here
3827
		Len = SK_STRLEN(pAC->Pnmi.pDriverFileName) + 1;
3659
		Len = SK_STRLEN(pAC->Pnmi.pDriverFileName) + 1;
3828
		if (Len > SK_PNMI_STRINGLEN1) {
3660
		if (Len > SK_PNMI_STRINGLEN1) {
3829
3661
3830
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR031,
3662
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR056, SK_PNMI_ERR056MSG);
3831
				SK_PNMI_ERR056MSG);
3832
3663
3833
			*pLen = 0;
3664
			*pLen = 0;
3834
			return (SK_PNMI_ERR_GENERAL);
3665
			return (SK_PNMI_ERR_GENERAL);
Lines 3854-3861 Link Here
3854
		Len = 256;
3685
		Len = 256;
3855
		if (VpdRead(pAC, IoC, VPD_NAME, Buf, (int *)&Len) > 0) {
3686
		if (VpdRead(pAC, IoC, VPD_NAME, Buf, (int *)&Len) > 0) {
3856
3687
3857
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR032,
3688
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR032, SK_PNMI_ERR032MSG);
3858
				SK_PNMI_ERR032MSG);
3859
3689
3860
			*pLen = 0;
3690
			*pLen = 0;
3861
			return (SK_PNMI_ERR_GENERAL);
3691
			return (SK_PNMI_ERR_GENERAL);
Lines 3863-3870 Link Here
3863
		Len ++;
3693
		Len ++;
3864
		if (Len > SK_PNMI_STRINGLEN1) {
3694
		if (Len > SK_PNMI_STRINGLEN1) {
3865
3695
3866
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR033,
3696
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR033, SK_PNMI_ERR033MSG);
3867
				SK_PNMI_ERR033MSG);
3868
3697
3869
			*pLen = 0;
3698
			*pLen = 0;
3870
			return (SK_PNMI_ERR_GENERAL);
3699
			return (SK_PNMI_ERR_GENERAL);
Lines 3880-3886 Link Here
3880
		break;
3709
		break;
3881
3710
3882
	case OID_SKGE_HW_VERSION:
3711
	case OID_SKGE_HW_VERSION:
3883
		/* Oh, I love to do some string manipulation */
3884
		if (*pLen < 5) {
3712
		if (*pLen < 5) {
3885
3713
3886
			*pLen = 5;
3714
			*pLen = 5;
Lines 3889-3897 Link Here
3889
		Val8 = (SK_U8)pAC->GIni.GIPciHwRev;
3717
		Val8 = (SK_U8)pAC->GIni.GIPciHwRev;
3890
		pBuf[0] = 4;
3718
		pBuf[0] = 4;
3891
		pBuf[1] = 'v';
3719
		pBuf[1] = 'v';
3892
		pBuf[2] = (char)(0x30 | ((Val8 >> 4) & 0x0F));
3720
		pBuf[2] = (char)('0' | ((Val8 >> 4) & 0x0f));
3893
		pBuf[3] = '.';
3721
		pBuf[3] = '.';
3894
		pBuf[4] = (char)(0x30 | (Val8 & 0x0F));
3722
		pBuf[4] = (char)('0' | (Val8 & 0x0f));
3895
		*pLen = 5;
3723
		*pLen = 5;
3896
		break;
3724
		break;
3897
3725
Lines 3914-3925 Link Here
3914
		break;
3742
		break;
3915
3743
3916
	case OID_SKGE_VAUXAVAIL:
3744
	case OID_SKGE_VAUXAVAIL:
3917
		*pBuf = (char) pAC->GIni.GIVauxAvail;
3745
		*pBuf = (char)pAC->GIni.GIVauxAvail;
3918
		*pLen = sizeof(char);
3746
		*pLen = sizeof(char);
3919
		break;
3747
		break;
3920
3748
3921
	case OID_SKGE_BUS_TYPE:
3749
	case OID_SKGE_BUS_TYPE:
3922
		*pBuf = (char) SK_PNMI_BUS_PCI;
3750
		*pBuf = (char)SK_PNMI_BUS_PCI;
3923
		*pLen = sizeof(char);
3751
		*pLen = sizeof(char);
3924
		break;
3752
		break;
3925
3753
Lines 3968-3998 Link Here
3968
		break;
3796
		break;
3969
3797
3970
	case OID_SKGE_RLMT_MONITOR_NUMBER:
3798
	case OID_SKGE_RLMT_MONITOR_NUMBER:
3971
/* XXX Not yet implemented by RLMT therefore we return zero elements */
3799
		/* Not yet implemented by RLMT, therefore we return zero elements. */
3972
		Val32 = 0;
3800
		Val32 = 0;
3973
		SK_PNMI_STORE_U32(pBuf, Val32);
3801
		SK_PNMI_STORE_U32(pBuf, Val32);
3974
		*pLen = sizeof(SK_U32);
3802
		*pLen = sizeof(SK_U32);
3975
		break;
3803
		break;
3976
3804
3977
	case OID_SKGE_TX_SW_QUEUE_LEN:
3805
	case OID_SKGE_TX_SW_QUEUE_LEN:
3978
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
3806
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
3979
		if (MacType == SK_MAC_XMAC) {
3807
		if (MacType == SK_MAC_XMAC) {
3980
			/* Dual net mode */
3808
			/* DualNet mode. */
3981
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3809
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3982
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxSwQueueLen;
3810
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxSwQueueLen;
3983
			}
3811
			}
3984
			/* Single net mode */
3812
			/* SingleNet mode. */
3985
			else {
3813
			else {
3986
				Val64 = pAC->Pnmi.BufPort[0].TxSwQueueLen +
3814
				Val64 = pAC->Pnmi.BufPort[0].TxSwQueueLen +
3987
					pAC->Pnmi.BufPort[1].TxSwQueueLen;
3815
					pAC->Pnmi.BufPort[1].TxSwQueueLen;
3988
			}			
3816
			}			
3989
		}
3817
		}
3990
		else {
3818
		else {
3991
			/* Dual net mode */
3819
			/* DualNet mode. */
3992
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3820
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3993
				Val64 = pAC->Pnmi.Port[NetIndex].TxSwQueueLen;
3821
				Val64 = pAC->Pnmi.Port[NetIndex].TxSwQueueLen;
3994
			}
3822
			}
3995
			/* Single net mode */
3823
			/* SingleNet mode. */
3996
			else {
3824
			else {
3997
				Val64 = pAC->Pnmi.Port[0].TxSwQueueLen +
3825
				Val64 = pAC->Pnmi.Port[0].TxSwQueueLen +
3998
					pAC->Pnmi.Port[1].TxSwQueueLen;
3826
					pAC->Pnmi.Port[1].TxSwQueueLen;
Lines 4004-4027 Link Here
4004
3832
4005
3833
4006
	case OID_SKGE_TX_SW_QUEUE_MAX:
3834
	case OID_SKGE_TX_SW_QUEUE_MAX:
4007
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
3835
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4008
		if (MacType == SK_MAC_XMAC) {
3836
		if (MacType == SK_MAC_XMAC) {
4009
			/* Dual net mode */
3837
			/* DualNet mode. */
4010
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3838
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4011
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxSwQueueMax;
3839
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxSwQueueMax;
4012
			}
3840
			}
4013
			/* Single net mode */
3841
			/* SingleNet mode. */
4014
			else {
3842
			else {
4015
				Val64 = pAC->Pnmi.BufPort[0].TxSwQueueMax +
3843
				Val64 = pAC->Pnmi.BufPort[0].TxSwQueueMax +
4016
					pAC->Pnmi.BufPort[1].TxSwQueueMax;
3844
					pAC->Pnmi.BufPort[1].TxSwQueueMax;
4017
			}
3845
			}
4018
		}
3846
		}
4019
		else {
3847
		else {
4020
			/* Dual net mode */
3848
			/* DualNet mode. */
4021
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3849
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4022
				Val64 = pAC->Pnmi.Port[NetIndex].TxSwQueueMax;
3850
				Val64 = pAC->Pnmi.Port[NetIndex].TxSwQueueMax;
4023
			}
3851
			}
4024
			/* Single net mode */
3852
			/* SingleNet mode. */
4025
			else {
3853
			else {
4026
				Val64 = pAC->Pnmi.Port[0].TxSwQueueMax +
3854
				Val64 = pAC->Pnmi.Port[0].TxSwQueueMax +
4027
					pAC->Pnmi.Port[1].TxSwQueueMax;
3855
					pAC->Pnmi.Port[1].TxSwQueueMax;
Lines 4032-4055 Link Here
4032
		break;
3860
		break;
4033
3861
4034
	case OID_SKGE_TX_RETRY:
3862
	case OID_SKGE_TX_RETRY:
4035
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
3863
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4036
		if (MacType == SK_MAC_XMAC) {
3864
		if (MacType == SK_MAC_XMAC) {
4037
			/* Dual net mode */
3865
			/* DualNet mode. */
4038
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3866
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4039
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxRetryCts;
3867
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxRetryCts;
4040
			}
3868
			}
4041
			/* Single net mode */
3869
			/* SingleNet mode. */
4042
			else {
3870
			else {
4043
				Val64 = pAC->Pnmi.BufPort[0].TxRetryCts +
3871
				Val64 = pAC->Pnmi.BufPort[0].TxRetryCts +
4044
					pAC->Pnmi.BufPort[1].TxRetryCts;
3872
					pAC->Pnmi.BufPort[1].TxRetryCts;
4045
			}
3873
			}
4046
		}
3874
		}
4047
		else {
3875
		else {
4048
			/* Dual net mode */
3876
			/* DualNet mode. */
4049
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3877
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4050
				Val64 = pAC->Pnmi.Port[NetIndex].TxRetryCts;
3878
				Val64 = pAC->Pnmi.Port[NetIndex].TxRetryCts;
4051
			}
3879
			}
4052
			/* Single net mode */
3880
			/* SingleNet mode. */
4053
			else {
3881
			else {
4054
				Val64 = pAC->Pnmi.Port[0].TxRetryCts +
3882
				Val64 = pAC->Pnmi.Port[0].TxRetryCts +
4055
					pAC->Pnmi.Port[1].TxRetryCts;
3883
					pAC->Pnmi.Port[1].TxRetryCts;
Lines 4060-4083 Link Here
4060
		break;
3888
		break;
4061
3889
4062
	case OID_SKGE_RX_INTR_CTS:
3890
	case OID_SKGE_RX_INTR_CTS:
4063
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
3891
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4064
		if (MacType == SK_MAC_XMAC) {
3892
		if (MacType == SK_MAC_XMAC) {
4065
			/* Dual net mode */
3893
			/* DualNet mode. */
4066
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3894
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4067
				Val64 = pAC->Pnmi.BufPort[NetIndex].RxIntrCts;
3895
				Val64 = pAC->Pnmi.BufPort[NetIndex].RxIntrCts;
4068
			}
3896
			}
4069
			/* Single net mode */
3897
			/* SingleNet mode. */
4070
			else {
3898
			else {
4071
				Val64 = pAC->Pnmi.BufPort[0].RxIntrCts +
3899
				Val64 = pAC->Pnmi.BufPort[0].RxIntrCts +
4072
					pAC->Pnmi.BufPort[1].RxIntrCts;
3900
					pAC->Pnmi.BufPort[1].RxIntrCts;
4073
			}
3901
			}
4074
		}
3902
		}
4075
		else {
3903
		else {
4076
			/* Dual net mode */
3904
			/* DualNet mode. */
4077
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3905
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4078
				Val64 = pAC->Pnmi.Port[NetIndex].RxIntrCts;
3906
				Val64 = pAC->Pnmi.Port[NetIndex].RxIntrCts;
4079
			}
3907
			}
4080
			/* Single net mode */
3908
			/* SingleNet mode. */
4081
			else {
3909
			else {
4082
				Val64 = pAC->Pnmi.Port[0].RxIntrCts +
3910
				Val64 = pAC->Pnmi.Port[0].RxIntrCts +
4083
					pAC->Pnmi.Port[1].RxIntrCts;
3911
					pAC->Pnmi.Port[1].RxIntrCts;
Lines 4088-4111 Link Here
4088
		break;
3916
		break;
4089
3917
4090
	case OID_SKGE_TX_INTR_CTS:
3918
	case OID_SKGE_TX_INTR_CTS:
4091
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
3919
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4092
		if (MacType == SK_MAC_XMAC) {
3920
		if (MacType == SK_MAC_XMAC) {
4093
			/* Dual net mode */
3921
			/* DualNet mode. */
4094
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3922
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4095
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxIntrCts;
3923
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxIntrCts;
4096
			}
3924
			}
4097
			/* Single net mode */
3925
			/* SingleNet mode. */
4098
			else {
3926
			else {
4099
				Val64 = pAC->Pnmi.BufPort[0].TxIntrCts +
3927
				Val64 = pAC->Pnmi.BufPort[0].TxIntrCts +
4100
					pAC->Pnmi.BufPort[1].TxIntrCts;
3928
					pAC->Pnmi.BufPort[1].TxIntrCts;
4101
			}
3929
			}
4102
		}
3930
		}
4103
		else {
3931
		else {
4104
			/* Dual net mode */
3932
			/* DualNet mode. */
4105
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3933
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4106
				Val64 = pAC->Pnmi.Port[NetIndex].TxIntrCts;
3934
				Val64 = pAC->Pnmi.Port[NetIndex].TxIntrCts;
4107
			}
3935
			}
4108
			/* Single net mode */
3936
			/* SingleNet mode. */
4109
			else {
3937
			else {
4110
				Val64 = pAC->Pnmi.Port[0].TxIntrCts +
3938
				Val64 = pAC->Pnmi.Port[0].TxIntrCts +
4111
					pAC->Pnmi.Port[1].TxIntrCts;
3939
					pAC->Pnmi.Port[1].TxIntrCts;
Lines 4116-4139 Link Here
4116
		break;
3944
		break;
4117
3945
4118
	case OID_SKGE_RX_NO_BUF_CTS:
3946
	case OID_SKGE_RX_NO_BUF_CTS:
4119
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
3947
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4120
		if (MacType == SK_MAC_XMAC) {
3948
		if (MacType == SK_MAC_XMAC) {
4121
			/* Dual net mode */
3949
			/* DualNet mode. */
4122
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3950
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4123
				Val64 = pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
3951
				Val64 = pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
4124
			}
3952
			}
4125
			/* Single net mode */
3953
			/* SingleNet mode. */
4126
			else {
3954
			else {
4127
				Val64 = pAC->Pnmi.BufPort[0].RxNoBufCts +
3955
				Val64 = pAC->Pnmi.BufPort[0].RxNoBufCts +
4128
					pAC->Pnmi.BufPort[1].RxNoBufCts;
3956
					pAC->Pnmi.BufPort[1].RxNoBufCts;
4129
			}
3957
			}
4130
		}
3958
		}
4131
		else {
3959
		else {
4132
			/* Dual net mode */
3960
			/* DualNet mode. */
4133
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3961
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4134
				Val64 = pAC->Pnmi.Port[NetIndex].RxNoBufCts;
3962
				Val64 = pAC->Pnmi.Port[NetIndex].RxNoBufCts;
4135
			}
3963
			}
4136
			/* Single net mode */
3964
			/* SingleNet mode. */
4137
			else {
3965
			else {
4138
				Val64 = pAC->Pnmi.Port[0].RxNoBufCts +
3966
				Val64 = pAC->Pnmi.Port[0].RxNoBufCts +
4139
					pAC->Pnmi.Port[1].RxNoBufCts;
3967
					pAC->Pnmi.Port[1].RxNoBufCts;
Lines 4144-4167 Link Here
4144
		break;
3972
		break;
4145
3973
4146
	case OID_SKGE_TX_NO_BUF_CTS:
3974
	case OID_SKGE_TX_NO_BUF_CTS:
4147
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
3975
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4148
		if (MacType == SK_MAC_XMAC) {
3976
		if (MacType == SK_MAC_XMAC) {
4149
			/* Dual net mode */
3977
			/* DualNet mode. */
4150
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3978
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4151
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxNoBufCts;
3979
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxNoBufCts;
4152
			}
3980
			}
4153
			/* Single net mode */
3981
			/* SingleNet mode. */
4154
			else {
3982
			else {
4155
				Val64 = pAC->Pnmi.BufPort[0].TxNoBufCts +
3983
				Val64 = pAC->Pnmi.BufPort[0].TxNoBufCts +
4156
					pAC->Pnmi.BufPort[1].TxNoBufCts;
3984
					pAC->Pnmi.BufPort[1].TxNoBufCts;
4157
			}
3985
			}
4158
		}
3986
		}
4159
		else {
3987
		else {
4160
			/* Dual net mode */
3988
			/* DualNet mode. */
4161
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
3989
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4162
				Val64 = pAC->Pnmi.Port[NetIndex].TxNoBufCts;
3990
				Val64 = pAC->Pnmi.Port[NetIndex].TxNoBufCts;
4163
			}
3991
			}
4164
			/* Single net mode */
3992
			/* SingleNet mode. */
4165
			else {
3993
			else {
4166
				Val64 = pAC->Pnmi.Port[0].TxNoBufCts +
3994
				Val64 = pAC->Pnmi.Port[0].TxNoBufCts +
4167
					pAC->Pnmi.Port[1].TxNoBufCts;
3995
					pAC->Pnmi.Port[1].TxNoBufCts;
Lines 4172-4195 Link Here
4172
		break;
4000
		break;
4173
4001
4174
	case OID_SKGE_TX_USED_DESCR_NO:
4002
	case OID_SKGE_TX_USED_DESCR_NO:
4175
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
4003
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4176
		if (MacType == SK_MAC_XMAC) {
4004
		if (MacType == SK_MAC_XMAC) {
4177
			/* Dual net mode */
4005
			/* DualNet mode. */
4178
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4006
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4179
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxUsedDescrNo;
4007
				Val64 = pAC->Pnmi.BufPort[NetIndex].TxUsedDescrNo;
4180
			}
4008
			}
4181
			/* Single net mode */
4009
			/* SingleNet mode. */
4182
			else {
4010
			else {
4183
				Val64 = pAC->Pnmi.BufPort[0].TxUsedDescrNo +
4011
				Val64 = pAC->Pnmi.BufPort[0].TxUsedDescrNo +
4184
					pAC->Pnmi.BufPort[1].TxUsedDescrNo;
4012
					pAC->Pnmi.BufPort[1].TxUsedDescrNo;
4185
			}
4013
			}
4186
		}
4014
		}
4187
		else {
4015
		else {
4188
			/* Dual net mode */
4016
			/* DualNet mode. */
4189
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4017
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4190
				Val64 = pAC->Pnmi.Port[NetIndex].TxUsedDescrNo;
4018
				Val64 = pAC->Pnmi.Port[NetIndex].TxUsedDescrNo;
4191
			}
4019
			}
4192
			/* Single net mode */
4020
			/* SingleNet mode. */
4193
			else {
4021
			else {
4194
				Val64 = pAC->Pnmi.Port[0].TxUsedDescrNo +
4022
				Val64 = pAC->Pnmi.Port[0].TxUsedDescrNo +
4195
					pAC->Pnmi.Port[1].TxUsedDescrNo;
4023
					pAC->Pnmi.Port[1].TxUsedDescrNo;
Lines 4200-4223 Link Here
4200
		break;
4028
		break;
4201
4029
4202
	case OID_SKGE_RX_DELIVERED_CTS:
4030
	case OID_SKGE_RX_DELIVERED_CTS:
4203
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
4031
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4204
		if (MacType == SK_MAC_XMAC) {
4032
		if (MacType == SK_MAC_XMAC) {
4205
			/* Dual net mode */
4033
			/* DualNet mode. */
4206
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4034
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4207
				Val64 = pAC->Pnmi.BufPort[NetIndex].RxDeliveredCts;
4035
				Val64 = pAC->Pnmi.BufPort[NetIndex].RxDeliveredCts;
4208
			}
4036
			}
4209
			/* Single net mode */
4037
			/* SingleNet mode. */
4210
			else {
4038
			else {
4211
				Val64 = pAC->Pnmi.BufPort[0].RxDeliveredCts +
4039
				Val64 = pAC->Pnmi.BufPort[0].RxDeliveredCts +
4212
					pAC->Pnmi.BufPort[1].RxDeliveredCts;
4040
					pAC->Pnmi.BufPort[1].RxDeliveredCts;
4213
			}
4041
			}
4214
		}
4042
		}
4215
		else {
4043
		else {
4216
			/* Dual net mode */
4044
			/* DualNet mode. */
4217
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4045
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4218
				Val64 = pAC->Pnmi.Port[NetIndex].RxDeliveredCts;
4046
				Val64 = pAC->Pnmi.Port[NetIndex].RxDeliveredCts;
4219
			}
4047
			}
4220
			/* Single net mode */
4048
			/* SingleNet mode. */
4221
			else {
4049
			else {
4222
				Val64 = pAC->Pnmi.Port[0].RxDeliveredCts +
4050
				Val64 = pAC->Pnmi.Port[0].RxDeliveredCts +
4223
					pAC->Pnmi.Port[1].RxDeliveredCts;
4051
					pAC->Pnmi.Port[1].RxDeliveredCts;
Lines 4228-4251 Link Here
4228
		break;
4056
		break;
4229
4057
4230
	case OID_SKGE_RX_OCTETS_DELIV_CTS:
4058
	case OID_SKGE_RX_OCTETS_DELIV_CTS:
4231
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
4059
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4232
		if (MacType == SK_MAC_XMAC) {
4060
		if (MacType == SK_MAC_XMAC) {
4233
			/* Dual net mode */
4061
			/* DualNet mode. */
4234
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4062
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4235
				Val64 = pAC->Pnmi.BufPort[NetIndex].RxOctetsDeliveredCts;
4063
				Val64 = pAC->Pnmi.BufPort[NetIndex].RxOctetsDeliveredCts;
4236
			}
4064
			}
4237
			/* Single net mode */
4065
			/* SingleNet mode. */
4238
			else {
4066
			else {
4239
				Val64 = pAC->Pnmi.BufPort[0].RxOctetsDeliveredCts +
4067
				Val64 = pAC->Pnmi.BufPort[0].RxOctetsDeliveredCts +
4240
					pAC->Pnmi.BufPort[1].RxOctetsDeliveredCts;
4068
					pAC->Pnmi.BufPort[1].RxOctetsDeliveredCts;
4241
			}
4069
			}
4242
		}
4070
		}
4243
		else {
4071
		else {
4244
			/* Dual net mode */
4072
			/* DualNet mode. */
4245
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4073
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4246
				Val64 = pAC->Pnmi.Port[NetIndex].RxOctetsDeliveredCts;
4074
				Val64 = pAC->Pnmi.Port[NetIndex].RxOctetsDeliveredCts;
4247
			}
4075
			}
4248
			/* Single net mode */
4076
			/* SingleNet mode. */
4249
			else {
4077
			else {
4250
				Val64 = pAC->Pnmi.Port[0].RxOctetsDeliveredCts +
4078
				Val64 = pAC->Pnmi.Port[0].RxOctetsDeliveredCts +
4251
					pAC->Pnmi.Port[1].RxOctetsDeliveredCts;
4079
					pAC->Pnmi.Port[1].RxOctetsDeliveredCts;
Lines 4266-4278 Link Here
4266
		break;
4094
		break;
4267
4095
4268
	case OID_SKGE_IN_ERRORS_CTS:
4096
	case OID_SKGE_IN_ERRORS_CTS:
4269
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
4097
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4270
		if (MacType == SK_MAC_XMAC) {
4098
		if (MacType == SK_MAC_XMAC) {
4271
			/* Dual net mode */
4099
			/* DualNet mode. */
4272
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4100
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4273
				Val64 = Val64RxHwErrs + pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
4101
				Val64 = Val64RxHwErrs + pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
4274
			}
4102
			}
4275
			/* Single net mode */
4103
			/* SingleNet mode. */
4276
			else {
4104
			else {
4277
				Val64 = Val64RxHwErrs +
4105
				Val64 = Val64RxHwErrs +
4278
					pAC->Pnmi.BufPort[0].RxNoBufCts +
4106
					pAC->Pnmi.BufPort[0].RxNoBufCts +
Lines 4280-4290 Link Here
4280
			}
4108
			}
4281
		}
4109
		}
4282
		else {
4110
		else {
4283
			/* Dual net mode */
4111
			/* DualNet mode. */
4284
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4112
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4285
				Val64 = Val64RxHwErrs + pAC->Pnmi.Port[NetIndex].RxNoBufCts;
4113
				Val64 = Val64RxHwErrs + pAC->Pnmi.Port[NetIndex].RxNoBufCts;
4286
			}
4114
			}
4287
			/* Single net mode */
4115
			/* SingleNet mode. */
4288
			else {
4116
			else {
4289
				Val64 = Val64RxHwErrs +
4117
				Val64 = Val64RxHwErrs +
4290
					pAC->Pnmi.Port[0].RxNoBufCts +
4118
					pAC->Pnmi.Port[0].RxNoBufCts +
Lines 4296-4308 Link Here
4296
		break;
4124
		break;
4297
4125
4298
	case OID_SKGE_OUT_ERROR_CTS:
4126
	case OID_SKGE_OUT_ERROR_CTS:
4299
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
4127
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4300
		if (MacType == SK_MAC_XMAC) {
4128
		if (MacType == SK_MAC_XMAC) {
4301
			/* Dual net mode */
4129
			/* DualNet mode. */
4302
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4130
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4303
				Val64 = Val64TxHwErrs + pAC->Pnmi.BufPort[NetIndex].TxNoBufCts;
4131
				Val64 = Val64TxHwErrs + pAC->Pnmi.BufPort[NetIndex].TxNoBufCts;
4304
			}
4132
			}
4305
			/* Single net mode */
4133
			/* SingleNet mode. */
4306
			else {
4134
			else {
4307
				Val64 = Val64TxHwErrs +
4135
				Val64 = Val64TxHwErrs +
4308
					pAC->Pnmi.BufPort[0].TxNoBufCts +
4136
					pAC->Pnmi.BufPort[0].TxNoBufCts +
Lines 4310-4320 Link Here
4310
			}
4138
			}
4311
		}
4139
		}
4312
		else {
4140
		else {
4313
			/* Dual net mode */
4141
			/* DualNet mode. */
4314
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4142
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4315
				Val64 = Val64TxHwErrs + pAC->Pnmi.Port[NetIndex].TxNoBufCts;
4143
				Val64 = Val64TxHwErrs + pAC->Pnmi.Port[NetIndex].TxNoBufCts;
4316
			}
4144
			}
4317
			/* Single net mode */
4145
			/* SingleNet mode. */
4318
			else {
4146
			else {
4319
				Val64 = Val64TxHwErrs +
4147
				Val64 = Val64TxHwErrs +
4320
					pAC->Pnmi.Port[0].TxNoBufCts +
4148
					pAC->Pnmi.Port[0].TxNoBufCts +
Lines 4326-4349 Link Here
4326
		break;
4154
		break;
4327
4155
4328
	case OID_SKGE_ERR_RECOVERY_CTS:
4156
	case OID_SKGE_ERR_RECOVERY_CTS:
4329
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
4157
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4330
		if (MacType == SK_MAC_XMAC) {
4158
		if (MacType == SK_MAC_XMAC) {
4331
			/* Dual net mode */
4159
			/* DualNet mode. */
4332
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4160
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4333
				Val64 = pAC->Pnmi.BufPort[NetIndex].ErrRecoveryCts;
4161
				Val64 = pAC->Pnmi.BufPort[NetIndex].ErrRecoveryCts;
4334
			}
4162
			}
4335
			/* Single net mode */
4163
			/* SingleNet mode. */
4336
			else {
4164
			else {
4337
				Val64 = pAC->Pnmi.BufPort[0].ErrRecoveryCts +
4165
				Val64 = pAC->Pnmi.BufPort[0].ErrRecoveryCts +
4338
					pAC->Pnmi.BufPort[1].ErrRecoveryCts;
4166
					pAC->Pnmi.BufPort[1].ErrRecoveryCts;
4339
			}
4167
			}
4340
		}
4168
		}
4341
		else {
4169
		else {
4342
			/* Dual net mode */
4170
			/* DualNet mode. */
4343
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4171
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4344
				Val64 = pAC->Pnmi.Port[NetIndex].ErrRecoveryCts;
4172
				Val64 = pAC->Pnmi.Port[NetIndex].ErrRecoveryCts;
4345
			}
4173
			}
4346
			/* Single net mode */
4174
			/* SingleNet mode. */
4347
			else {
4175
			else {
4348
				Val64 = pAC->Pnmi.Port[0].ErrRecoveryCts +
4176
				Val64 = pAC->Pnmi.Port[0].ErrRecoveryCts +
4349
					pAC->Pnmi.Port[1].ErrRecoveryCts;
4177
					pAC->Pnmi.Port[1].ErrRecoveryCts;
Lines 4367-4373 Link Here
4367
		break;
4195
		break;
4368
4196
4369
	case OID_GEN_RCV_ERROR:
4197
	case OID_GEN_RCV_ERROR:
4370
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
4198
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4371
		if (MacType == SK_MAC_XMAC) {
4199
		if (MacType == SK_MAC_XMAC) {
4372
			Val64 = Val64RxHwErrs + pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
4200
			Val64 = Val64RxHwErrs + pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
4373
		}
4201
		}
Lines 4376-4382 Link Here
4376
		}
4204
		}
4377
4205
4378
		/*
4206
		/*
4379
		 * by default 32bit values are evaluated
4207
		 * By default 32bit values are evaluated.
4380
		 */
4208
		 */
4381
		if (!Is64BitReq) {
4209
		if (!Is64BitReq) {
4382
			Val32 = (SK_U32)Val64;
4210
			Val32 = (SK_U32)Val64;
Lines 4390-4396 Link Here
4390
		break;
4218
		break;
4391
4219
4392
	case OID_GEN_XMIT_ERROR:
4220
	case OID_GEN_XMIT_ERROR:
4393
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
4221
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4394
		if (MacType == SK_MAC_XMAC) {
4222
		if (MacType == SK_MAC_XMAC) {
4395
			Val64 = Val64TxHwErrs + pAC->Pnmi.BufPort[NetIndex].TxNoBufCts;
4223
			Val64 = Val64TxHwErrs + pAC->Pnmi.BufPort[NetIndex].TxNoBufCts;
4396
		}
4224
		}
Lines 4399-4405 Link Here
4399
		}
4227
		}
4400
4228
4401
		/*
4229
		/*
4402
		 * by default 32bit values are evaluated
4230
		 * By default 32bit values are evaluated.
4403
		 */
4231
		 */
4404
		if (!Is64BitReq) {
4232
		if (!Is64BitReq) {
4405
			Val32 = (SK_U32)Val64;
4233
			Val32 = (SK_U32)Val64;
Lines 4413-4428 Link Here
4413
		break;
4241
		break;
4414
4242
4415
	case OID_GEN_RCV_NO_BUFFER:
4243
	case OID_GEN_RCV_NO_BUFFER:
4416
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
4244
		/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
4417
		if (MacType == SK_MAC_XMAC) {
4245
		if (MacType == SK_MAC_XMAC) {
4418
			Val64 = pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
4246
			Val64 = pAC->Pnmi.BufPort[NetIndex].RxNoBufCts + 
4247
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_OVERFLOW, NetIndex);
4248
4419
		}
4249
		}
4420
		else {
4250
		else {
4421
			Val64 = pAC->Pnmi.Port[NetIndex].RxNoBufCts;
4251
			Val64 = pAC->Pnmi.Port[NetIndex].RxNoBufCts +
4252
				GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_OVERFLOW, NetIndex);
4422
		}
4253
		}
4423
4254
4424
		/*
4255
		/*
4425
		 * by default 32bit values are evaluated
4256
		 * By default 32bit values are evaluated.
4426
		 */
4257
		 */
4427
		if (!Is64BitReq) {
4258
		if (!Is64BitReq) {
4428
			Val32 = (SK_U32)Val64;
4259
			Val32 = (SK_U32)Val64;
Lines 4442-4449 Link Here
4442
		break;
4273
		break;
4443
4274
4444
	default:
4275
	default:
4445
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR034,
4276
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR034, SK_PNMI_ERR034MSG);
4446
			SK_PNMI_ERR034MSG);
4447
4277
4448
		*pLen = 0;
4278
		*pLen = 0;
4449
		return (SK_PNMI_ERR_GENERAL);
4279
		return (SK_PNMI_ERR_GENERAL);
Lines 4500-4524 Link Here
4500
	SK_U32		Val32;
4330
	SK_U32		Val32;
4501
	SK_U64		Val64;
4331
	SK_U64		Val64;
4502
4332
4503
4333
	/* Check instance. Only single instance OIDs are allowed here. */
4504
	/*
4505
	 * Check instance. Only single instance OIDs are allowed here.
4506
	 */
4507
	if (Instance != (SK_U32)(-1) && Instance != 1) {
4334
	if (Instance != (SK_U32)(-1) && Instance != 1) {
4508
4335
4509
		*pLen = 0;
4336
		*pLen = 0;
4510
		return (SK_PNMI_ERR_UNKNOWN_INST);
4337
		return (SK_PNMI_ERR_UNKNOWN_INST);
4511
	}
4338
	}
4512
4339
4513
	/*
4340
	/* Perform the requested action. */
4514
	 * Perform the requested action.
4515
	 */
4516
	if (Action == SK_PNMI_GET) {
4341
	if (Action == SK_PNMI_GET) {
4517
4342
4518
		/*
4343
		/* Check if the buffer length is large enough. */
4519
		 * Check if the buffer length is large enough.
4520
		 */
4521
4522
		switch (Id) {
4344
		switch (Id) {
4523
4345
4524
		case OID_SKGE_RLMT_MODE:
4346
		case OID_SKGE_RLMT_MODE:
Lines 4551-4558 Link Here
4551
			break;
4373
			break;
4552
4374
4553
		default:
4375
		default:
4554
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR035,
4376
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR035, SK_PNMI_ERR035MSG);
4555
				SK_PNMI_ERR035MSG);
4556
4377
4557
			*pLen = 0;
4378
			*pLen = 0;
4558
			return (SK_PNMI_ERR_GENERAL);
4379
			return (SK_PNMI_ERR_GENERAL);
Lines 4571-4579 Link Here
4571
		}
4392
		}
4572
		pAC->Pnmi.RlmtUpdatedFlag ++;
4393
		pAC->Pnmi.RlmtUpdatedFlag ++;
4573
4394
4574
		/*
4395
		/* Retrieve value. */
4575
		 * Retrieve Value
4576
		*/
4577
		switch (Id) {
4396
		switch (Id) {
4578
4397
4579
		case OID_SKGE_RLMT_MODE:
4398
		case OID_SKGE_RLMT_MODE:
Lines 4651-4667 Link Here
4651
		pAC->Pnmi.RlmtUpdatedFlag --;
4470
		pAC->Pnmi.RlmtUpdatedFlag --;
4652
	}
4471
	}
4653
	else {
4472
	else {
4654
		/* Perform a preset or set */
4473
		/* Perform a PRESET or SET. */
4655
		switch (Id) {
4474
		switch (Id) {
4656
4475
4657
		case OID_SKGE_RLMT_MODE:
4476
		case OID_SKGE_RLMT_MODE:
4658
			/* Check if the buffer length is plausible */
4477
			/* Check if the buffer length is plausible. */
4659
			if (*pLen < sizeof(char)) {
4478
			if (*pLen < sizeof(char)) {
4660
4479
4661
				*pLen = sizeof(char);
4480
				*pLen = sizeof(char);
4662
				return (SK_PNMI_ERR_TOO_SHORT);
4481
				return (SK_PNMI_ERR_TOO_SHORT);
4663
			}
4482
			}
4664
			/* Check if the value range is correct */
4483
			/* Check if the value range is correct. */
4665
			if (*pLen != sizeof(char) ||
4484
			if (*pLen != sizeof(char) ||
4666
				(*pBuf & SK_PNMI_RLMT_MODE_CHK_LINK) == 0 ||
4485
				(*pBuf & SK_PNMI_RLMT_MODE_CHK_LINK) == 0 ||
4667
				*(SK_U8 *)pBuf > 15) {
4486
				*(SK_U8 *)pBuf > 15) {
Lines 4669-4689 Link Here
4669
				*pLen = 0;
4488
				*pLen = 0;
4670
				return (SK_PNMI_ERR_BAD_VALUE);
4489
				return (SK_PNMI_ERR_BAD_VALUE);
4671
			}
4490
			}
4672
			/* The preset ends here */
4491
			/* The PRESET ends here. */
4673
			if (Action == SK_PNMI_PRESET) {
4492
			if (Action == SK_PNMI_PRESET) {
4674
4493
4675
				*pLen = 0;
4494
				*pLen = 0;
4676
				return (SK_PNMI_ERR_OK);
4495
				return (SK_PNMI_ERR_OK);
4677
			}
4496
			}
4678
			/* Send an event to RLMT to change the mode */
4497
			/* Send an event to RLMT to change the mode. */
4679
			SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
4498
			SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
4499
			
4680
			EventParam.Para32[0] |= (SK_U32)(*pBuf);
4500
			EventParam.Para32[0] |= (SK_U32)(*pBuf);
4681
			EventParam.Para32[1] = 0;
4501
			EventParam.Para32[1] = 0;
4682
			if (SkRlmtEvent(pAC, IoC, SK_RLMT_MODE_CHANGE,
4502
			if (SkRlmtEvent(pAC, IoC, SK_RLMT_MODE_CHANGE,
4683
				EventParam) > 0) {
4503
				EventParam) > 0) {
4684
4504
4685
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR037,
4505
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR037, SK_PNMI_ERR037MSG);
4686
					SK_PNMI_ERR037MSG);
4687
4506
4688
				*pLen = 0;
4507
				*pLen = 0;
4689
				return (SK_PNMI_ERR_GENERAL);
4508
				return (SK_PNMI_ERR_GENERAL);
Lines 4691-4710 Link Here
4691
			break;
4510
			break;
4692
4511
4693
		case OID_SKGE_RLMT_PORT_PREFERRED:
4512
		case OID_SKGE_RLMT_PORT_PREFERRED:
4694
			/* Check if the buffer length is plausible */
4513
			/* PRESET/SET action makes no sense in Dual Net mode. */
4514
			if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4515
				break;
4516
			}
4517
			
4518
			/* Check if the buffer length is plausible. */
4695
			if (*pLen < sizeof(char)) {
4519
			if (*pLen < sizeof(char)) {
4696
4520
4697
				*pLen = sizeof(char);
4521
				*pLen = sizeof(char);
4698
				return (SK_PNMI_ERR_TOO_SHORT);
4522
				return (SK_PNMI_ERR_TOO_SHORT);
4699
			}
4523
			}
4700
			/* Check if the value range is correct */
4524
			/* Check if the value range is correct. */
4701
			if (*pLen != sizeof(char) || *(SK_U8 *)pBuf >
4525
			if (*pLen != sizeof(char) || *(SK_U8 *)pBuf >
4702
				(SK_U8)pAC->GIni.GIMacsFound) {
4526
				(SK_U8)pAC->GIni.GIMacsFound) {
4703
4527
4704
				*pLen = 0;
4528
				*pLen = 0;
4705
				return (SK_PNMI_ERR_BAD_VALUE);
4529
				return (SK_PNMI_ERR_BAD_VALUE);
4706
			}
4530
			}
4707
			/* The preset ends here */
4531
			/* The PRESET ends here. */
4708
			if (Action == SK_PNMI_PRESET) {
4532
			if (Action == SK_PNMI_PRESET) {
4709
4533
4710
				*pLen = 0;
4534
				*pLen = 0;
Lines 4717-4729 Link Here
4717
			 * make the decision which is the preferred port.
4541
			 * make the decision which is the preferred port.
4718
			 */
4542
			 */
4719
			SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
4543
			SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
4544
			
4720
			EventParam.Para32[0] = (SK_U32)(*pBuf) - 1;
4545
			EventParam.Para32[0] = (SK_U32)(*pBuf) - 1;
4721
			EventParam.Para32[1] = NetIndex;
4546
			EventParam.Para32[1] = NetIndex;
4722
			if (SkRlmtEvent(pAC, IoC, SK_RLMT_PREFPORT_CHANGE,
4547
			if (SkRlmtEvent(pAC, IoC, SK_RLMT_PREFPORT_CHANGE,
4723
				EventParam) > 0) {
4548
				EventParam) > 0) {
4724
4549
4725
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR038,
4550
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR038, SK_PNMI_ERR038MSG);
4726
					SK_PNMI_ERR038MSG);
4727
4551
4728
				*pLen = 0;
4552
				*pLen = 0;
4729
				return (SK_PNMI_ERR_GENERAL);
4553
				return (SK_PNMI_ERR_GENERAL);
Lines 4731-4752 Link Here
4731
			break;
4555
			break;
4732
4556
4733
		case OID_SKGE_RLMT_CHANGE_THRES:
4557
		case OID_SKGE_RLMT_CHANGE_THRES:
4734
			/* Check if the buffer length is plausible */
4558
			/* Check if the buffer length is plausible. */
4735
			if (*pLen < sizeof(SK_U64)) {
4559
			if (*pLen < sizeof(SK_U64)) {
4736
4560
4737
				*pLen = sizeof(SK_U64);
4561
				*pLen = sizeof(SK_U64);
4738
				return (SK_PNMI_ERR_TOO_SHORT);
4562
				return (SK_PNMI_ERR_TOO_SHORT);
4739
			}
4563
			}
4740
			/*
4564
			
4741
			 * There are not many restrictions to the
4565
			/* There are not many restrictions to the value range. */
4742
			 * value range.
4743
			 */
4744
			if (*pLen != sizeof(SK_U64)) {
4566
			if (*pLen != sizeof(SK_U64)) {
4745
4567
4746
				*pLen = 0;
4568
				*pLen = 0;
4747
				return (SK_PNMI_ERR_BAD_VALUE);
4569
				return (SK_PNMI_ERR_BAD_VALUE);
4748
			}
4570
			}
4749
			/* A preset ends here */
4571
			/* The PRESET ends here. */
4750
			if (Action == SK_PNMI_PRESET) {
4572
			if (Action == SK_PNMI_PRESET) {
4751
4573
4752
				*pLen = 0;
4574
				*pLen = 0;
Lines 4761-4767 Link Here
4761
			break;
4583
			break;
4762
4584
4763
		default:
4585
		default:
4764
			/* The other OIDs are not be able for set */
4586
			/* The other OIDs are not be able for set. */
4765
			*pLen = 0;
4587
			*pLen = 0;
4766
			return (SK_PNMI_ERR_READ_ONLY);
4588
			return (SK_PNMI_ERR_READ_ONLY);
4767
		}
4589
		}
Lines 4806-4859 Link Here
4806
	SK_U32		Val32;
4628
	SK_U32		Val32;
4807
	SK_U64		Val64;
4629
	SK_U64		Val64;
4808
4630
4809
	/*
4631
4810
	 * Calculate the port indexes from the instance.
4632
	/* Calculate the port indexes from the instance. */
4811
	 */
4812
	PhysPortMax = pAC->GIni.GIMacsFound;
4633
	PhysPortMax = pAC->GIni.GIMacsFound;
4813
4634
4814
	if ((Instance != (SK_U32)(-1))) {
4635
	if ((Instance != (SK_U32)(-1))) {
4815
		/* Check instance range */
4636
		/* Check instance range. */
4816
		if ((Instance < 1) || (Instance > PhysPortMax)) {
4637
		if ((Instance < 1) || (Instance > PhysPortMax)) {
4817
4638
4818
			*pLen = 0;
4639
			*pLen = 0;
4819
			return (SK_PNMI_ERR_UNKNOWN_INST);
4640
			return (SK_PNMI_ERR_UNKNOWN_INST);
4820
		}
4641
		}
4821
4642
4822
		/* Single net mode */
4643
		/* SingleNet mode. */
4823
		PhysPortIndex = Instance - 1;
4644
		PhysPortIndex = Instance - 1;
4824
4645
4825
		/* Dual net mode */
4646
		/* DualNet mode. */
4826
		if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4647
		if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4827
			PhysPortIndex = NetIndex;
4648
			PhysPortIndex = NetIndex;
4828
		}
4649
		}
4829
4650
4830
		/* Both net modes */
4651
		/* Both net modes. */
4831
		Limit = PhysPortIndex + 1;
4652
		Limit = PhysPortIndex + 1;
4832
	}
4653
	}
4833
	else {
4654
	else {
4834
		/* Single net mode */
4655
		/* SingleNet mode. */
4835
		PhysPortIndex = 0;
4656
		PhysPortIndex = 0;
4836
		Limit = PhysPortMax;
4657
		Limit = PhysPortMax;
4837
4658
4838
		/* Dual net mode */
4659
		/* DualNet mode. */
4839
		if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4660
		if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
4840
			PhysPortIndex = NetIndex;
4661
			PhysPortIndex = NetIndex;
4841
			Limit = PhysPortIndex + 1;
4662
			Limit = PhysPortIndex + 1;
4842
		}
4663
		}
4843
	}
4664
	}
4844
4665
4845
	/*
4666
	/* Currently only GET requests are allowed. */
4846
	 * Currently only get requests are allowed.
4847
	 */
4848
	if (Action != SK_PNMI_GET) {
4667
	if (Action != SK_PNMI_GET) {
4849
4668
4850
		*pLen = 0;
4669
		*pLen = 0;
4851
		return (SK_PNMI_ERR_READ_ONLY);
4670
		return (SK_PNMI_ERR_READ_ONLY);
4852
	}
4671
	}
4853
4672
4854
	/*
4673
	/* Check if the buffer length is large enough. */
4855
	 * Check if the buffer length is large enough.
4856
	 */
4857
	switch (Id) {
4674
	switch (Id) {
4858
4675
4859
	case OID_SKGE_RLMT_PORT_INDEX:
4676
	case OID_SKGE_RLMT_PORT_INDEX:
Lines 4877-4884 Link Here
4877
		break;
4694
		break;
4878
4695
4879
	default:
4696
	default:
4880
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR039,
4697
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR039, SK_PNMI_ERR039MSG);
4881
			SK_PNMI_ERR039MSG);
4882
4698
4883
		*pLen = 0;
4699
		*pLen = 0;
4884
		return (SK_PNMI_ERR_GENERAL);
4700
		return (SK_PNMI_ERR_GENERAL);
Lines 4896-4904 Link Here
4896
	}
4712
	}
4897
	pAC->Pnmi.RlmtUpdatedFlag ++;
4713
	pAC->Pnmi.RlmtUpdatedFlag ++;
4898
4714
4899
	/*
4715
	/* Get value. */
4900
	 * Get value
4901
	 */
4902
	Offset = 0;
4716
	Offset = 0;
4903
	for (; PhysPortIndex < Limit; PhysPortIndex ++) {
4717
	for (; PhysPortIndex < Limit; PhysPortIndex ++) {
4904
4718
Lines 5011-5029 Link Here
5011
	int			Ret;
4825
	int			Ret;
5012
	SK_EVPARA	EventParam;
4826
	SK_EVPARA	EventParam;
5013
	SK_U32		Val32;
4827
	SK_U32		Val32;
4828
#ifdef SK_PHY_LP_MODE
4829
	SK_U8	CurrentPhyPowerState;
4830
#endif /* SK_PHY_LP_MODE */
5014
4831
5015
	/*
4832
5016
	 * Calculate instance if wished. MAC index 0 is the virtual MAC.
4833
	/* Calculate instance if wished. MAC index 0 is the virtual MAC. */
5017
	 */
5018
	PhysPortMax = pAC->GIni.GIMacsFound;
4834
	PhysPortMax = pAC->GIni.GIMacsFound;
5019
	LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
4835
	LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
5020
4836
5021
	if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* Dual net mode */
4837
	if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* DualNet mode. */
5022
		LogPortMax--;
4838
		LogPortMax--;
5023
	}
4839
	}
5024
4840
5025
	if ((Instance != (SK_U32)(-1))) { /* Only one specific instance is queried */
4841
	if ((Instance != (SK_U32)(-1))) { /* Only one specific instance is queried. */
5026
		/* Check instance range */
4842
		/* Check instance range. */
5027
		if ((Instance < 1) || (Instance > LogPortMax)) {
4843
		if ((Instance < 1) || (Instance > LogPortMax)) {
5028
4844
5029
			*pLen = 0;
4845
			*pLen = 0;
Lines 5033-5050 Link Here
5033
		Limit = LogPortIndex + 1;
4849
		Limit = LogPortIndex + 1;
5034
	}
4850
	}
5035
4851
5036
	else { /* Instance == (SK_U32)(-1), get all Instances of that OID */
4852
	else { /* Instance == (SK_U32)(-1), get all Instances of that OID. */
5037
4853
5038
		LogPortIndex = 0;
4854
		LogPortIndex = 0;
5039
		Limit = LogPortMax;
4855
		Limit = LogPortMax;
5040
	}
4856
	}
5041
4857
5042
	/*
4858
	/* Perform action. */
5043
	 * Perform action
5044
	 */
5045
	if (Action == SK_PNMI_GET) {
4859
	if (Action == SK_PNMI_GET) {
5046
4860
5047
		/* Check length */
4861
		/* Check length. */
5048
		switch (Id) {
4862
		switch (Id) {
5049
4863
5050
		case OID_SKGE_PMD:
4864
		case OID_SKGE_PMD:
Lines 5082-5089 Link Here
5082
			break;
4896
			break;
5083
4897
5084
		default:
4898
		default:
5085
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR041,
4899
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR041, SK_PNMI_ERR041MSG);
5086
				SK_PNMI_ERR041MSG);
5087
			*pLen = 0;
4900
			*pLen = 0;
5088
			return (SK_PNMI_ERR_GENERAL);
4901
			return (SK_PNMI_ERR_GENERAL);
5089
		}
4902
		}
Lines 5099-5107 Link Here
5099
		}
4912
		}
5100
		pAC->Pnmi.SirqUpdatedFlag ++;
4913
		pAC->Pnmi.SirqUpdatedFlag ++;
5101
4914
5102
		/*
4915
		/* Get value. */
5103
		 * Get value
5104
		 */
5105
		Offset = 0;
4916
		Offset = 0;
5106
		for (; LogPortIndex < Limit; LogPortIndex ++) {
4917
		for (; LogPortIndex < Limit; LogPortIndex ++) {
5107
4918
Lines 5111-5217 Link Here
5111
4922
5112
			case OID_SKGE_PMD:
4923
			case OID_SKGE_PMD:
5113
				*pBufPtr = pAC->Pnmi.PMD;
4924
				*pBufPtr = pAC->Pnmi.PMD;
5114
				Offset += sizeof(char);
4925
				Offset ++;
5115
				break;
4926
				break;
5116
4927
5117
			case OID_SKGE_CONNECTOR:
4928
			case OID_SKGE_CONNECTOR:
5118
				*pBufPtr = pAC->Pnmi.Connector;
4929
				*pBufPtr = pAC->Pnmi.Connector;
5119
				Offset += sizeof(char);
4930
				Offset ++;
5120
				break;
4931
				break;
5121
4932
5122
			case OID_SKGE_PHY_TYPE:
4933
			case OID_SKGE_PHY_TYPE:
5123
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
4934
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5124
					if (LogPortIndex == 0) {
4935
					if (LogPortIndex == 0) {
5125
						continue;
4936
						continue;
5126
					}
4937
					}
5127
					else {
4938
					/* Get value for physical port. */
5128
						/* Get value for physical ports */
4939
					PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
5129
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
4940
					Val32 = pAC->GIni.GP[PhysPortIndex].PhyType;
5130
							pAC, LogPortIndex);
5131
						Val32 = pAC->GIni.GP[PhysPortIndex].PhyType;
5132
						SK_PNMI_STORE_U32(pBufPtr, Val32);
5133
					}
5134
				}
4941
				}
5135
				else { /* DualNetMode */
4942
				else { /* DualNet mode. */
5136
					
4943
					
5137
					Val32 = pAC->GIni.GP[NetIndex].PhyType;
4944
					Val32 = pAC->GIni.GP[NetIndex].PhyType;
5138
					SK_PNMI_STORE_U32(pBufPtr, Val32);
5139
				}
4945
				}
4946
				SK_PNMI_STORE_U32(pBufPtr, Val32);
5140
				Offset += sizeof(SK_U32);
4947
				Offset += sizeof(SK_U32);
5141
				break;
4948
				break;
5142
4949
5143
#ifdef SK_PHY_LP_MODE
4950
#ifdef SK_PHY_LP_MODE
5144
			case OID_SKGE_PHY_LP_MODE:
4951
			case OID_SKGE_PHY_LP_MODE:
5145
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
4952
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5146
					if (LogPortIndex == 0) {
4953
					if (LogPortIndex == 0) {
5147
						continue;
4954
						continue;
5148
					}
4955
					}
5149
					else {
4956
					/* Get value for physical port. */
5150
						/* Get value for physical ports */
4957
					PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
5151
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
4958
					*pBufPtr = (SK_U8)pAC->GIni.GP[PhysPortIndex].PPhyPowerState;
5152
						Val8 = (SK_U8) pAC->GIni.GP[PhysPortIndex].PPhyPowerState;
5153
						*pBufPtr = Val8;
5154
					}
5155
				}
4959
				}
5156
				else { /* DualNetMode */
4960
				else { /* DualNet mode. */
5157
					
4961
					
5158
					Val8 = (SK_U8) pAC->GIni.GP[PhysPortIndex].PPhyPowerState;
4962
					*pBufPtr = (SK_U8)pAC->GIni.GP[NetIndex].PPhyPowerState;
5159
					*pBufPtr = Val8;
5160
				}
4963
				}
5161
				Offset += sizeof(SK_U8);
4964
				Offset += sizeof(SK_U8);
5162
				break;
4965
				break;
5163
#endif
4966
#endif
5164
4967
5165
			case OID_SKGE_LINK_CAP:
4968
			case OID_SKGE_LINK_CAP:
5166
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
4969
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5167
					if (LogPortIndex == 0) {
4970
					if (LogPortIndex == 0) {
5168
						/* Get value for virtual port */
4971
						/* Get value for virtual port. */
5169
						VirtualConf(pAC, IoC, Id, pBufPtr);
4972
						VirtualConf(pAC, IoC, Id, pBufPtr);
5170
					}
4973
					}
5171
					else {
4974
					else {
5172
						/* Get value for physical ports */
4975
						/* Get value for physical port. */
5173
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
4976
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5174
							pAC, LogPortIndex);
4977
							pAC, LogPortIndex);
5175
4978
5176
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkCap;
4979
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkCap;
5177
					}
4980
					}
5178
				}
4981
				}
5179
				else { /* DualNetMode */
4982
				else { /* DualNet mode. */
5180
					
4983
					
5181
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkCap;
4984
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkCap;
5182
				}
4985
				}
5183
				Offset += sizeof(char);
4986
				Offset ++;
5184
				break;
4987
				break;
5185
4988
5186
			case OID_SKGE_LINK_MODE:
4989
			case OID_SKGE_LINK_MODE:
5187
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
4990
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5188
					if (LogPortIndex == 0) {
4991
					if (LogPortIndex == 0) {
5189
						/* Get value for virtual port */
4992
						/* Get value for virtual port. */
5190
						VirtualConf(pAC, IoC, Id, pBufPtr);
4993
						VirtualConf(pAC, IoC, Id, pBufPtr);
5191
					}
4994
					}
5192
					else {
4995
					else {
5193
						/* Get value for physical ports */
4996
						/* Get value for physical port. */
5194
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
4997
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5195
							pAC, LogPortIndex);
4998
							pAC, LogPortIndex);
5196
4999
5197
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkModeConf;
5000
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkModeConf;
5198
					}
5001
					}
5199
				}
5002
				}
5200
				else { /* DualNetMode */
5003
				else { /* DualNet mode. */
5201
				
5004
				
5202
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkModeConf;
5005
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkModeConf;
5203
				}
5006
				}
5204
				Offset += sizeof(char);
5007
				Offset ++;
5205
				break;
5008
				break;
5206
5009
5207
			case OID_SKGE_LINK_MODE_STATUS:
5010
			case OID_SKGE_LINK_MODE_STATUS:
5208
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5011
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5209
					if (LogPortIndex == 0) {
5012
					if (LogPortIndex == 0) {
5210
						/* Get value for virtual port */
5013
						/* Get value for virtual port. */
5211
						VirtualConf(pAC, IoC, Id, pBufPtr);
5014
						VirtualConf(pAC, IoC, Id, pBufPtr);
5212
					}
5015
					}
5213
					else {
5016
					else {
5214
						/* Get value for physical port */
5017
						/* Get value for physical port. */
5215
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5018
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5216
							pAC, LogPortIndex);
5019
							pAC, LogPortIndex);
5217
5020
Lines 5219-5365 Link Here
5219
							CalculateLinkModeStatus(pAC, IoC, PhysPortIndex);
5022
							CalculateLinkModeStatus(pAC, IoC, PhysPortIndex);
5220
					}
5023
					}
5221
				}
5024
				}
5222
				else { /* DualNetMode */
5025
				else { /* DualNet mode. */
5223
					
5026
					
5224
					*pBufPtr = CalculateLinkModeStatus(pAC, IoC, NetIndex);
5027
					*pBufPtr = CalculateLinkModeStatus(pAC, IoC, NetIndex);
5225
				}
5028
				}
5226
				Offset += sizeof(char);
5029
				Offset ++;
5227
				break;
5030
				break;
5228
5031
5229
			case OID_SKGE_LINK_STATUS:
5032
			case OID_SKGE_LINK_STATUS:
5230
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5033
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5231
					if (LogPortIndex == 0) {
5034
					if (LogPortIndex == 0) {
5232
						/* Get value for virtual port */
5035
						/* Get value for virtual port. */
5233
						VirtualConf(pAC, IoC, Id, pBufPtr);
5036
						VirtualConf(pAC, IoC, Id, pBufPtr);
5234
					}
5037
					}
5235
					else {
5038
					else {
5236
						/* Get value for physical ports */
5039
						/* Get value for physical port. */
5237
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5040
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5238
							pAC, LogPortIndex);
5041
							pAC, LogPortIndex);
5239
	
5042
	
5240
						*pBufPtr = CalculateLinkStatus(pAC, IoC, PhysPortIndex);
5043
						*pBufPtr = CalculateLinkStatus(pAC, IoC, PhysPortIndex);
5241
					}
5044
					}
5242
				}
5045
				}
5243
				else { /* DualNetMode */
5046
				else { /* DualNet mode. */
5244
5047
5245
					*pBufPtr = CalculateLinkStatus(pAC, IoC, NetIndex);
5048
					*pBufPtr = CalculateLinkStatus(pAC, IoC, NetIndex);
5246
				}
5049
				}
5247
				Offset += sizeof(char);
5050
				Offset ++;
5248
				break;
5051
				break;
5249
5052
5250
			case OID_SKGE_FLOWCTRL_CAP:
5053
			case OID_SKGE_FLOWCTRL_CAP:
5251
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5054
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5252
					if (LogPortIndex == 0) {
5055
					if (LogPortIndex == 0) {
5253
						/* Get value for virtual port */
5056
						/* Get value for virtual port. */
5254
						VirtualConf(pAC, IoC, Id, pBufPtr);
5057
						VirtualConf(pAC, IoC, Id, pBufPtr);
5255
					}
5058
					}
5256
					else {
5059
					else {
5257
						/* Get value for physical ports */
5060
						/* Get value for physical port. */
5258
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5061
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5259
							pAC, LogPortIndex);
5062
							pAC, LogPortIndex);
5260
	
5063
	
5261
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PFlowCtrlCap;
5064
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PFlowCtrlCap;
5262
					}
5065
					}
5263
				}
5066
				}
5264
				else { /* DualNetMode */
5067
				else { /* DualNet mode. */
5265
				
5068
				
5266
					*pBufPtr = pAC->GIni.GP[NetIndex].PFlowCtrlCap;
5069
					*pBufPtr = pAC->GIni.GP[NetIndex].PFlowCtrlCap;
5267
				}
5070
				}
5268
				Offset += sizeof(char);
5071
				Offset ++;
5269
				break;
5072
				break;
5270
5073
5271
			case OID_SKGE_FLOWCTRL_MODE:
5074
			case OID_SKGE_FLOWCTRL_MODE:
5272
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5075
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5273
					if (LogPortIndex == 0) {
5076
					if (LogPortIndex == 0) {
5274
						/* Get value for virtual port */
5077
						/* Get value for virtual port. */
5275
						VirtualConf(pAC, IoC, Id, pBufPtr);
5078
						VirtualConf(pAC, IoC, Id, pBufPtr);
5276
					}
5079
					}
5277
					else {
5080
					else {
5278
						/* Get value for physical port */
5081
						/* Get value for physical port. */
5279
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5082
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5280
							pAC, LogPortIndex);
5083
							pAC, LogPortIndex);
5281
	
5084
	
5282
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PFlowCtrlMode;
5085
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PFlowCtrlMode;
5283
					}
5086
					}
5284
				}
5087
				}
5285
				else { /* DualNetMode */
5088
				else { /* DualNet mode. */
5286
5089
5287
					*pBufPtr = pAC->GIni.GP[NetIndex].PFlowCtrlMode;
5090
					*pBufPtr = pAC->GIni.GP[NetIndex].PFlowCtrlMode;
5288
				}
5091
				}
5289
				Offset += sizeof(char);
5092
				Offset ++;
5290
				break;
5093
				break;
5291
5094
5292
			case OID_SKGE_FLOWCTRL_STATUS:
5095
			case OID_SKGE_FLOWCTRL_STATUS:
5293
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5096
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5294
					if (LogPortIndex == 0) {
5097
					if (LogPortIndex == 0) {
5295
						/* Get value for virtual port */
5098
						/* Get value for virtual port. */
5296
						VirtualConf(pAC, IoC, Id, pBufPtr);
5099
						VirtualConf(pAC, IoC, Id, pBufPtr);
5297
					}
5100
					}
5298
					else {
5101
					else {
5299
						/* Get value for physical port */
5102
						/* Get value for physical port. */
5300
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5103
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5301
							pAC, LogPortIndex);
5104
							pAC, LogPortIndex);
5302
	
5105
	
5303
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PFlowCtrlStatus;
5106
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PFlowCtrlStatus;
5304
					}
5107
					}
5305
				}
5108
				}
5306
				else { /* DualNetMode */
5109
				else { /* DualNet mode. */
5307
5110
5308
					*pBufPtr = pAC->GIni.GP[NetIndex].PFlowCtrlStatus;
5111
					*pBufPtr = pAC->GIni.GP[NetIndex].PFlowCtrlStatus;
5309
				}
5112
				}
5310
				Offset += sizeof(char);
5113
				Offset ++;
5311
				break;
5114
				break;
5312
5115
5313
			case OID_SKGE_PHY_OPERATION_CAP:
5116
			case OID_SKGE_PHY_OPERATION_CAP:
5314
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5117
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet Mode. */
5315
					if (LogPortIndex == 0) {
5118
					if (LogPortIndex == 0) {
5316
						/* Get value for virtual port */
5119
						/* Get value for virtual port. */
5317
						VirtualConf(pAC, IoC, Id, pBufPtr);
5120
						VirtualConf(pAC, IoC, Id, pBufPtr);
5318
					}
5121
					}
5319
					else {
5122
					else {
5320
						/* Get value for physical ports */
5123
						/* Get value for physical port. */
5321
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5124
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5322
							pAC, LogPortIndex);
5125
							pAC, LogPortIndex);
5323
	
5126
	
5324
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PMSCap;
5127
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PMSCap;
5325
					}
5128
					}
5326
				}
5129
				}
5327
				else { /* DualNetMode */
5130
				else { /* DualNet mode. */
5328
				
5131
				
5329
					*pBufPtr = pAC->GIni.GP[NetIndex].PMSCap;
5132
					*pBufPtr = pAC->GIni.GP[NetIndex].PMSCap;
5330
				}
5133
				}
5331
				Offset += sizeof(char);
5134
				Offset ++;
5332
				break;
5135
				break;
5333
5136
5334
			case OID_SKGE_PHY_OPERATION_MODE:
5137
			case OID_SKGE_PHY_OPERATION_MODE:
5335
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5138
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5336
					if (LogPortIndex == 0) {
5139
					if (LogPortIndex == 0) {
5337
						/* Get value for virtual port */
5140
						/* Get value for virtual port. */
5338
						VirtualConf(pAC, IoC, Id, pBufPtr);
5141
						VirtualConf(pAC, IoC, Id, pBufPtr);
5339
					}
5142
					}
5340
					else {
5143
					else {
5341
						/* Get value for physical port */
5144
						/* Get value for physical port. */
5342
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5145
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5343
							pAC, LogPortIndex);
5146
							pAC, LogPortIndex);
5344
5147
5345
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PMSMode;
5148
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PMSMode;
5346
					}
5149
					}
5347
				}
5150
				}
5348
				else { /* DualNetMode */
5151
				else { /* DualNet mode. */
5349
				
5152
				
5350
					*pBufPtr = pAC->GIni.GP[NetIndex].PMSMode;
5153
					*pBufPtr = pAC->GIni.GP[NetIndex].PMSMode;
5351
				}
5154
				}
5352
				Offset += sizeof(char);
5155
				Offset ++;
5353
				break;
5156
				break;
5354
5157
5355
			case OID_SKGE_PHY_OPERATION_STATUS:
5158
			case OID_SKGE_PHY_OPERATION_STATUS:
5356
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5159
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5357
					if (LogPortIndex == 0) {
5160
					if (LogPortIndex == 0) {
5358
						/* Get value for virtual port */
5161
						/* Get value for virtual port. */
5359
						VirtualConf(pAC, IoC, Id, pBufPtr);
5162
						VirtualConf(pAC, IoC, Id, pBufPtr);
5360
					}
5163
					}
5361
					else {
5164
					else {
5362
						/* Get value for physical port */
5165
						/* Get value for physical port. */
5363
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5166
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5364
							pAC, LogPortIndex);
5167
							pAC, LogPortIndex);
5365
	
5168
	
Lines 5370-5439 Link Here
5370
				
5173
				
5371
					*pBufPtr = pAC->GIni.GP[NetIndex].PMSStatus;
5174
					*pBufPtr = pAC->GIni.GP[NetIndex].PMSStatus;
5372
				}
5175
				}
5373
				Offset += sizeof(char);
5176
				Offset ++;
5374
				break;
5177
				break;
5375
5178
5376
			case OID_SKGE_SPEED_CAP:
5179
			case OID_SKGE_SPEED_CAP:
5377
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5180
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5378
					if (LogPortIndex == 0) {
5181
					if (LogPortIndex == 0) {
5379
						/* Get value for virtual port */
5182
						/* Get value for virtual port. */
5380
						VirtualConf(pAC, IoC, Id, pBufPtr);
5183
						VirtualConf(pAC, IoC, Id, pBufPtr);
5381
					}
5184
					}
5382
					else {
5185
					else {
5383
						/* Get value for physical ports */
5186
						/* Get value for physical port. */
5384
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5187
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5385
							pAC, LogPortIndex);
5188
							pAC, LogPortIndex);
5386
	
5189
	
5387
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkSpeedCap;
5190
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkSpeedCap;
5388
					}
5191
					}
5389
				}
5192
				}
5390
				else { /* DualNetMode */
5193
				else { /* DualNet mode. */
5391
				
5194
				
5392
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkSpeedCap;
5195
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkSpeedCap;
5393
				}
5196
				}
5394
				Offset += sizeof(char);
5197
				Offset ++;
5395
				break;
5198
				break;
5396
5199
5397
			case OID_SKGE_SPEED_MODE:
5200
			case OID_SKGE_SPEED_MODE:
5398
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5201
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5399
					if (LogPortIndex == 0) {
5202
					if (LogPortIndex == 0) {
5400
						/* Get value for virtual port */
5203
						/* Get value for virtual port. */
5401
						VirtualConf(pAC, IoC, Id, pBufPtr);
5204
						VirtualConf(pAC, IoC, Id, pBufPtr);
5402
					}
5205
					}
5403
					else {
5206
					else {
5404
						/* Get value for physical port */
5207
						/* Get value for physical port. */
5405
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5208
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5406
							pAC, LogPortIndex);
5209
							pAC, LogPortIndex);
5407
	
5210
	
5408
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkSpeed;
5211
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkSpeed;
5409
					}
5212
					}
5410
				}
5213
				}
5411
				else { /* DualNetMode */
5214
				else { /* DualNet mode. */
5412
5215
5413
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkSpeed;
5216
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkSpeed;
5414
				}
5217
				}
5415
				Offset += sizeof(char);
5218
				Offset ++;
5416
				break;
5219
				break;
5417
5220
5418
			case OID_SKGE_SPEED_STATUS:
5221
			case OID_SKGE_SPEED_STATUS:
5419
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5222
				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5420
					if (LogPortIndex == 0) {
5223
					if (LogPortIndex == 0) {
5421
						/* Get value for virtual port */
5224
						/* Get value for virtual port. */
5422
						VirtualConf(pAC, IoC, Id, pBufPtr);
5225
						VirtualConf(pAC, IoC, Id, pBufPtr);
5423
					}
5226
					}
5424
					else {
5227
					else {
5425
						/* Get value for physical port */
5228
						/* Get value for physical port. */
5426
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5229
						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
5427
							pAC, LogPortIndex);
5230
							pAC, LogPortIndex);
5428
	
5231
	
5429
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkSpeedUsed;
5232
						*pBufPtr = pAC->GIni.GP[PhysPortIndex].PLinkSpeedUsed;
5430
					}
5233
					}
5431
				}
5234
				}
5432
				else { /* DualNetMode */
5235
				else { /* DualNet mode. */
5433
5236
5434
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkSpeedUsed;
5237
					*pBufPtr = pAC->GIni.GP[NetIndex].PLinkSpeedUsed;
5435
				}
5238
				}
5436
				Offset += sizeof(char);
5239
				Offset ++;
5437
				break;
5240
				break;
5438
			
5241
			
5439
			case OID_SKGE_MTU:
5242
			case OID_SKGE_MTU:
Lines 5486-5525 Link Here
5486
			return (SK_PNMI_ERR_TOO_SHORT);
5289
			return (SK_PNMI_ERR_TOO_SHORT);
5487
		}
5290
		}
5488
		break;
5291
		break;
5489
#endif
5292
#endif /* SK_PHY_LP_MODE */
5490
5293
5491
	case OID_SKGE_MTU:
5294
	case OID_SKGE_MTU:
5492
		if (*pLen < sizeof(SK_U32)) {
5295
		if (*pLen < (Limit - LogPortIndex) * sizeof(SK_U32)) {
5493
5296
5494
			*pLen = sizeof(SK_U32);
5297
			*pLen = (Limit - LogPortIndex) * sizeof(SK_U32);
5495
			return (SK_PNMI_ERR_TOO_SHORT);
5298
			return (SK_PNMI_ERR_TOO_SHORT);
5496
		}
5299
		}
5497
		if (*pLen != sizeof(SK_U32)) {
5498
5499
			*pLen = 0;
5500
			return (SK_PNMI_ERR_BAD_VALUE);
5501
		}
5502
		break;
5300
		break;
5503
5301
	
5504
    default:
5302
    default:
5505
		*pLen = 0;
5303
		*pLen = 0;
5506
		return (SK_PNMI_ERR_READ_ONLY);
5304
		return (SK_PNMI_ERR_READ_ONLY);
5507
	}
5305
	}
5508
5306
5509
	/*
5307
	/* Perform PRESET or SET. */
5510
	 * Perform preset or set
5511
	 */
5512
	Offset = 0;
5308
	Offset = 0;
5513
	for (; LogPortIndex < Limit; LogPortIndex ++) {
5309
	for (; LogPortIndex < Limit; LogPortIndex ++) {
5514
5310
5311
		Val8 = *(pBuf + Offset);
5312
5515
		switch (Id) {
5313
		switch (Id) {
5516
5314
5517
		case OID_SKGE_LINK_MODE:
5315
		case OID_SKGE_LINK_MODE:
5518
			/* Check the value range */
5316
			/* Check the value range. */
5519
			Val8 = *(pBuf + Offset);
5520
			if (Val8 == 0) {
5317
			if (Val8 == 0) {
5521
5318
				Offset++;
5522
				Offset += sizeof(char);
5523
				break;
5319
				break;
5524
			}
5320
			}
5525
			if (Val8 < SK_LMODE_HALF ||
5321
			if (Val8 < SK_LMODE_HALF ||
Lines 5530-5580 Link Here
5530
				return (SK_PNMI_ERR_BAD_VALUE);
5326
				return (SK_PNMI_ERR_BAD_VALUE);
5531
			}
5327
			}
5532
5328
5533
			/* The preset ends here */
5329
			/* The PRESET ends here. */
5534
			if (Action == SK_PNMI_PRESET) {
5330
			if (Action == SK_PNMI_PRESET) {
5535
5331
5536
				return (SK_PNMI_ERR_OK);
5332
				return (SK_PNMI_ERR_OK);
5537
			}
5333
			}
5538
5334
5539
			if (LogPortIndex == 0) {
5335
			if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5540
5336
				if (LogPortIndex == 0) {
5541
				/*
5337
					/*
5542
				 * The virtual port consists of all currently
5338
					 * The virtual port consists of all currently
5543
				 * active ports. Find them and send an event
5339
					 * active ports. Find them and send an event
5544
				 * with the new link mode to SIRQ.
5340
					 * with the new link mode to SIRQ.
5545
				 */
5341
					 */
5546
				for (PhysPortIndex = 0;
5342
					for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
5547
					PhysPortIndex < PhysPortMax;
5343
						PhysPortIndex ++) {
5548
					PhysPortIndex ++) {
5549
5550
					if (!pAC->Pnmi.Port[PhysPortIndex].
5551
						ActiveFlag) {
5552
5553
						continue;
5554
					}
5555
5344
5556
					EventParam.Para32[0] = PhysPortIndex;
5345
						if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
5346
							continue;
5347
						}
5348
						
5349
						EventParam.Para32[0] = PhysPortIndex;
5350
						EventParam.Para32[1] = (SK_U32)Val8;
5351
						if (SkGeSirqEvent(pAC, IoC,
5352
							SK_HWEV_SET_LMODE,
5353
							EventParam) > 0) {
5354
							
5355
							SK_ERR_LOG(pAC, SK_ERRCL_SW,
5356
								SK_PNMI_ERR043,
5357
								SK_PNMI_ERR043MSG);
5358
							
5359
							*pLen = 0;
5360
							return (SK_PNMI_ERR_GENERAL);
5361
						}
5362
					} /* for */
5363
				}
5364
				else {
5365
					/*
5366
					 * Send an event with the new link mode to
5367
					 * the SIRQ module.
5368
					 */
5369
					EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
5370
						pAC, LogPortIndex);
5557
					EventParam.Para32[1] = (SK_U32)Val8;
5371
					EventParam.Para32[1] = (SK_U32)Val8;
5558
					if (SkGeSirqEvent(pAC, IoC,
5372
					if (SkGeSirqEvent(pAC, IoC, SK_HWEV_SET_LMODE,
5559
						SK_HWEV_SET_LMODE,
5560
						EventParam) > 0) {
5373
						EventParam) > 0) {
5561
5374
						
5562
						SK_ERR_LOG(pAC, SK_ERRCL_SW,
5375
						SK_ERR_LOG(pAC, SK_ERRCL_SW,
5563
							SK_PNMI_ERR043,
5376
							SK_PNMI_ERR043,
5564
							SK_PNMI_ERR043MSG);
5377
							SK_PNMI_ERR043MSG);
5565
5378
						
5566
						*pLen = 0;
5379
						*pLen = 0;
5567
						return (SK_PNMI_ERR_GENERAL);
5380
						return (SK_PNMI_ERR_GENERAL);
5568
					}
5381
					}
5569
				}
5382
				}
5570
			}
5383
			}
5571
			else {
5384
			else { /* DualNet mode. */
5385
5572
				/*
5386
				/*
5573
				 * Send an event with the new link mode to
5387
				 * Send an event with the new link mode to
5574
				 * the SIRQ module.
5388
				 * the SIRQ module.
5575
				 */
5389
				 */
5576
				EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
5390
				EventParam.Para32[0] = NetIndex;
5577
					pAC, LogPortIndex);
5578
				EventParam.Para32[1] = (SK_U32)Val8;
5391
				EventParam.Para32[1] = (SK_U32)Val8;
5579
				if (SkGeSirqEvent(pAC, IoC, SK_HWEV_SET_LMODE,
5392
				if (SkGeSirqEvent(pAC, IoC, SK_HWEV_SET_LMODE,
5580
					EventParam) > 0) {
5393
					EventParam) > 0) {
Lines 5587-5601 Link Here
5587
					return (SK_PNMI_ERR_GENERAL);
5400
					return (SK_PNMI_ERR_GENERAL);
5588
				}
5401
				}
5589
			}
5402
			}
5590
			Offset += sizeof(char);
5403
			Offset++;
5591
			break;
5404
			break;
5592
5405
5593
		case OID_SKGE_FLOWCTRL_MODE:
5406
		case OID_SKGE_FLOWCTRL_MODE:
5594
			/* Check the value range */
5407
			/* Check the value range. */
5595
			Val8 = *(pBuf + Offset);
5596
			if (Val8 == 0) {
5408
			if (Val8 == 0) {
5597
5409
				Offset++;
5598
				Offset += sizeof(char);
5599
				break;
5410
				break;
5600
			}
5411
			}
5601
			if (Val8 < SK_FLOW_MODE_NONE ||
5412
			if (Val8 < SK_FLOW_MODE_NONE ||
Lines 5606-5635 Link Here
5606
				return (SK_PNMI_ERR_BAD_VALUE);
5417
				return (SK_PNMI_ERR_BAD_VALUE);
5607
			}
5418
			}
5608
5419
5609
			/* The preset ends here */
5420
			/* The PRESET ends here. */
5610
			if (Action == SK_PNMI_PRESET) {
5421
			if (Action == SK_PNMI_PRESET) {
5611
5422
5612
				return (SK_PNMI_ERR_OK);
5423
				return (SK_PNMI_ERR_OK);
5613
			}
5424
			}
5614
5425
5615
			if (LogPortIndex == 0) {
5426
			if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5427
				if (LogPortIndex == 0) {
5428
					/*
5429
					 * The virtual port consists of all currently
5430
					 * active ports. Find them and send an event
5431
					 * with the new flow control mode to SIRQ.
5432
					 */
5433
					for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
5434
						PhysPortIndex ++) {
5616
5435
5617
				/*
5436
						if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
5618
				 * The virtual port consists of all currently
5437
							continue;
5619
				 * active ports. Find them and send an event
5438
						}
5620
				 * with the new flow control mode to SIRQ.
5621
				 */
5622
				for (PhysPortIndex = 0;
5623
					PhysPortIndex < PhysPortMax;
5624
					PhysPortIndex ++) {
5625
5439
5626
					if (!pAC->Pnmi.Port[PhysPortIndex].
5440
						EventParam.Para32[0] = PhysPortIndex;
5627
						ActiveFlag) {
5441
						EventParam.Para32[1] = (SK_U32)Val8;
5442
						if (SkGeSirqEvent(pAC, IoC,
5443
							SK_HWEV_SET_FLOWMODE,
5444
							EventParam) > 0) {
5445
5446
							SK_ERR_LOG(pAC, SK_ERRCL_SW,
5447
								SK_PNMI_ERR044,
5448
								SK_PNMI_ERR044MSG);
5628
5449
5629
						continue;
5450
							*pLen = 0;
5451
							return (SK_PNMI_ERR_GENERAL);
5452
						}
5630
					}
5453
					}
5631
5454
				}
5632
					EventParam.Para32[0] = PhysPortIndex;
5455
				else {
5456
					/*
5457
					 * Send an event with the new flow control
5458
					 * mode to the SIRQ module.
5459
					 */
5460
					EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
5461
						pAC, LogPortIndex);
5633
					EventParam.Para32[1] = (SK_U32)Val8;
5462
					EventParam.Para32[1] = (SK_U32)Val8;
5634
					if (SkGeSirqEvent(pAC, IoC,
5463
					if (SkGeSirqEvent(pAC, IoC,
5635
						SK_HWEV_SET_FLOWMODE,
5464
						SK_HWEV_SET_FLOWMODE,
Lines 5644-5660 Link Here
5644
					}
5473
					}
5645
				}
5474
				}
5646
			}
5475
			}
5647
			else {
5476
			else { /* DualNet mode. */
5477
				
5648
				/*
5478
				/*
5649
				 * Send an event with the new flow control
5479
				 * Send an event with the new link mode to
5650
				 * mode to the SIRQ module.
5480
				 * the SIRQ module.
5651
				 */
5481
				 */
5652
				EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
5482
				EventParam.Para32[0] = NetIndex;
5653
					pAC, LogPortIndex);
5654
				EventParam.Para32[1] = (SK_U32)Val8;
5483
				EventParam.Para32[1] = (SK_U32)Val8;
5655
				if (SkGeSirqEvent(pAC, IoC,
5484
				if (SkGeSirqEvent(pAC, IoC, SK_HWEV_SET_FLOWMODE,
5656
					SK_HWEV_SET_FLOWMODE, EventParam)
5485
					EventParam) > 0) {
5657
					> 0) {
5658
5486
5659
					SK_ERR_LOG(pAC, SK_ERRCL_SW,
5487
					SK_ERR_LOG(pAC, SK_ERRCL_SW,
5660
						SK_PNMI_ERR044,
5488
						SK_PNMI_ERR044,
Lines 5664-5678 Link Here
5664
					return (SK_PNMI_ERR_GENERAL);
5492
					return (SK_PNMI_ERR_GENERAL);
5665
				}
5493
				}
5666
			}
5494
			}
5667
			Offset += sizeof(char);
5495
			Offset++;
5668
			break;
5496
			break;
5669
5497
5670
		case OID_SKGE_PHY_OPERATION_MODE :
5498
		case OID_SKGE_PHY_OPERATION_MODE :
5671
			/* Check the value range */
5499
			/* Check the value range. */
5672
			Val8 = *(pBuf + Offset);
5673
			if (Val8 == 0) {
5500
			if (Val8 == 0) {
5674
				/* mode of this port remains unchanged */
5501
				/* Mode of this port remains unchanged. */
5675
				Offset += sizeof(char);
5502
				Offset++;
5676
				break;
5503
				break;
5677
			}
5504
			}
5678
			if (Val8 < SK_MS_MODE_AUTO ||
5505
			if (Val8 < SK_MS_MODE_AUTO ||
Lines 5683-5716 Link Here
5683
				return (SK_PNMI_ERR_BAD_VALUE);
5510
				return (SK_PNMI_ERR_BAD_VALUE);
5684
			}
5511
			}
5685
5512
5686
			/* The preset ends here */
5513
			/* The PRESET ends here. */
5687
			if (Action == SK_PNMI_PRESET) {
5514
			if (Action == SK_PNMI_PRESET) {
5688
5515
5689
				return (SK_PNMI_ERR_OK);
5516
				return (SK_PNMI_ERR_OK);
5690
			}
5517
			}
5691
5518
5692
			if (LogPortIndex == 0) {
5519
			if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5520
				if (LogPortIndex == 0) {
5521
					/*
5522
					 * The virtual port consists of all currently
5523
					 * active ports. Find them and send an event
5524
					 * with new master/slave (role) mode to SIRQ.
5525
					 */
5526
					for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
5527
						PhysPortIndex ++) {
5693
5528
5694
				/*
5529
						if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
5695
				 * The virtual port consists of all currently
5530
							continue;
5696
				 * active ports. Find them and send an event
5531
						}
5697
				 * with new master/slave (role) mode to SIRQ.
5698
				 */
5699
				for (PhysPortIndex = 0;
5700
					PhysPortIndex < PhysPortMax;
5701
					PhysPortIndex ++) {
5702
5532
5703
					if (!pAC->Pnmi.Port[PhysPortIndex].
5533
						EventParam.Para32[0] = PhysPortIndex;
5704
						ActiveFlag) {
5534
						EventParam.Para32[1] = (SK_U32)Val8;
5535
						if (SkGeSirqEvent(pAC, IoC,
5536
							SK_HWEV_SET_ROLE,
5537
							EventParam) > 0) {
5538
5539
							SK_ERR_LOG(pAC, SK_ERRCL_SW,
5540
								SK_PNMI_ERR042,
5541
								SK_PNMI_ERR042MSG);
5705
5542
5706
						continue;
5543
							*pLen = 0;
5544
							return (SK_PNMI_ERR_GENERAL);
5545
						}
5707
					}
5546
					}
5708
5547
				}
5709
					EventParam.Para32[0] = PhysPortIndex;
5548
				else {
5549
					/*
5550
					 * Send an event with the new master/slave
5551
					 * (role) mode to the SIRQ module.
5552
					 */
5553
					EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
5554
						pAC, LogPortIndex);
5710
					EventParam.Para32[1] = (SK_U32)Val8;
5555
					EventParam.Para32[1] = (SK_U32)Val8;
5711
					if (SkGeSirqEvent(pAC, IoC,
5556
					if (SkGeSirqEvent(pAC, IoC,
5712
						SK_HWEV_SET_ROLE,
5557
						SK_HWEV_SET_ROLE, EventParam) > 0) {
5713
						EventParam) > 0) {
5714
5558
5715
						SK_ERR_LOG(pAC, SK_ERRCL_SW,
5559
						SK_ERR_LOG(pAC, SK_ERRCL_SW,
5716
							SK_PNMI_ERR042,
5560
							SK_PNMI_ERR042,
Lines 5721-5736 Link Here
5721
					}
5565
					}
5722
				}
5566
				}
5723
			}
5567
			}
5724
			else {
5568
			else { /* DualNet mode. */
5569
5725
				/*
5570
				/*
5726
				 * Send an event with the new master/slave
5571
				 * Send an event with the new link mode to
5727
				 * (role) mode to the SIRQ module.
5572
				 * the SIRQ module.
5728
				 */
5573
				 */
5729
				EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
5574
				EventParam.Para32[0] = NetIndex;
5730
					pAC, LogPortIndex);
5731
				EventParam.Para32[1] = (SK_U32)Val8;
5575
				EventParam.Para32[1] = (SK_U32)Val8;
5732
				if (SkGeSirqEvent(pAC, IoC,
5576
				if (SkGeSirqEvent(pAC, IoC, SK_HWEV_SET_ROLE,
5733
					SK_HWEV_SET_ROLE, EventParam) > 0) {
5577
					EventParam) > 0) {
5734
5578
5735
					SK_ERR_LOG(pAC, SK_ERRCL_SW,
5579
					SK_ERR_LOG(pAC, SK_ERRCL_SW,
5736
						SK_PNMI_ERR042,
5580
						SK_PNMI_ERR042,
Lines 5740-5755 Link Here
5740
					return (SK_PNMI_ERR_GENERAL);
5584
					return (SK_PNMI_ERR_GENERAL);
5741
				}
5585
				}
5742
			}
5586
			}
5743
5587
			Offset++;
5744
			Offset += sizeof(char);
5745
			break;
5588
			break;
5746
5589
5747
		case OID_SKGE_SPEED_MODE:
5590
		case OID_SKGE_SPEED_MODE:
5748
			/* Check the value range */
5591
			/* Check the value range. */
5749
			Val8 = *(pBuf + Offset);
5750
			if (Val8 == 0) {
5592
			if (Val8 == 0) {
5751
5593
				Offset++;
5752
				Offset += sizeof(char);
5753
				break;
5594
				break;
5754
			}
5595
			}
5755
			if (Val8 < (SK_LSPEED_AUTO) ||
5596
			if (Val8 < (SK_LSPEED_AUTO) ||
Lines 5760-5788 Link Here
5760
				return (SK_PNMI_ERR_BAD_VALUE);
5601
				return (SK_PNMI_ERR_BAD_VALUE);
5761
			}
5602
			}
5762
5603
5763
			/* The preset ends here */
5604
			/* The PRESET ends here. */
5764
			if (Action == SK_PNMI_PRESET) {
5605
			if (Action == SK_PNMI_PRESET) {
5765
5606
5766
				return (SK_PNMI_ERR_OK);
5607
				return (SK_PNMI_ERR_OK);
5767
			}
5608
			}
5768
5609
5769
			if (LogPortIndex == 0) {
5610
			if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5611
				if (LogPortIndex == 0) {
5770
5612
5771
				/*
5613
					/*
5772
				 * The virtual port consists of all currently
5614
					 * The virtual port consists of all currently
5773
				 * active ports. Find them and send an event
5615
					 * active ports. Find them and send an event
5774
				 * with the new flow control mode to SIRQ.
5616
					 * with the new flow control mode to SIRQ.
5775
				 */
5617
					 */
5776
				for (PhysPortIndex = 0;
5618
					for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
5777
					PhysPortIndex < PhysPortMax;
5619
						PhysPortIndex ++) {
5778
					PhysPortIndex ++) {
5779
5620
5780
					if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
5621
						if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
5622
							continue;
5623
						}
5781
5624
5782
						continue;
5625
						EventParam.Para32[0] = PhysPortIndex;
5783
					}
5626
						EventParam.Para32[1] = (SK_U32)Val8;
5627
						if (SkGeSirqEvent(pAC, IoC,
5628
							SK_HWEV_SET_SPEED,
5629
							EventParam) > 0) {
5630
5631
							SK_ERR_LOG(pAC, SK_ERRCL_SW,
5632
								SK_PNMI_ERR045,
5633
								SK_PNMI_ERR045MSG);
5784
5634
5785
					EventParam.Para32[0] = PhysPortIndex;
5635
							*pLen = 0;
5636
							return (SK_PNMI_ERR_GENERAL);
5637
						}
5638
					}
5639
				}
5640
				else {
5641
					/*
5642
					 * Send an event with the new flow control
5643
					 * mode to the SIRQ module.
5644
					 */
5645
					EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
5646
						pAC, LogPortIndex);
5786
					EventParam.Para32[1] = (SK_U32)Val8;
5647
					EventParam.Para32[1] = (SK_U32)Val8;
5787
					if (SkGeSirqEvent(pAC, IoC,
5648
					if (SkGeSirqEvent(pAC, IoC,
5788
						SK_HWEV_SET_SPEED,
5649
						SK_HWEV_SET_SPEED,
Lines 5797-5812 Link Here
5797
					}
5658
					}
5798
				}
5659
				}
5799
			}
5660
			}
5800
			else {
5661
			else { /* DualNet mode. */
5662
				
5801
				/*
5663
				/*
5802
				 * Send an event with the new flow control
5664
				 * Send an event with the new link mode to
5803
				 * mode to the SIRQ module.
5665
				 * the SIRQ module.
5804
				 */
5666
				 */
5805
				EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
5667
				EventParam.Para32[0] = NetIndex;
5806
					pAC, LogPortIndex);
5807
				EventParam.Para32[1] = (SK_U32)Val8;
5668
				EventParam.Para32[1] = (SK_U32)Val8;
5808
				if (SkGeSirqEvent(pAC, IoC,
5669
				if (SkGeSirqEvent(pAC, IoC, SK_HWEV_SET_SPEED,
5809
					SK_HWEV_SET_SPEED,
5810
					EventParam) > 0) {
5670
					EventParam) > 0) {
5811
5671
5812
					SK_ERR_LOG(pAC, SK_ERRCL_SW,
5672
					SK_ERR_LOG(pAC, SK_ERRCL_SW,
Lines 5817-5839 Link Here
5817
					return (SK_PNMI_ERR_GENERAL);
5677
					return (SK_PNMI_ERR_GENERAL);
5818
				}
5678
				}
5819
			}
5679
			}
5820
			Offset += sizeof(char);
5680
			Offset++;
5821
			break;
5681
			break;
5822
5682
5823
		case OID_SKGE_MTU :
5683
		case OID_SKGE_MTU:
5824
			/* Check the value range */
5684
			/* Check the value range. */
5825
			Val32 = *(SK_U32*)(pBuf + Offset);
5685
			SK_PNMI_READ_U32((pBuf + Offset), Val32);
5686
5826
			if (Val32 == 0) {
5687
			if (Val32 == 0) {
5827
				/* mtu of this port remains unchanged */
5688
				/* MTU of this port remains unchanged. */
5828
				Offset += sizeof(SK_U32);
5689
				Offset += sizeof(SK_U32);
5829
				break;
5690
				break;
5830
			}
5691
			}
5692
5831
			if (SK_DRIVER_PRESET_MTU(pAC, IoC, NetIndex, Val32) != 0) {
5693
			if (SK_DRIVER_PRESET_MTU(pAC, IoC, NetIndex, Val32) != 0) {
5832
				*pLen = 0;
5694
				*pLen = 0;
5833
				return (SK_PNMI_ERR_BAD_VALUE);
5695
				return (SK_PNMI_ERR_BAD_VALUE);
5834
			}
5696
			}
5835
5697
5836
			/* The preset ends here */
5698
			/* The PRESET ends here. */
5837
			if (Action == SK_PNMI_PRESET) {
5699
			if (Action == SK_PNMI_PRESET) {
5838
				return (SK_PNMI_ERR_OK);
5700
				return (SK_PNMI_ERR_OK);
5839
			}
5701
			}
Lines 5844-5959 Link Here
5844
5706
5845
			Offset += sizeof(SK_U32);
5707
			Offset += sizeof(SK_U32);
5846
			break;
5708
			break;
5847
		
5709
5848
#ifdef SK_PHY_LP_MODE
5710
#ifdef SK_PHY_LP_MODE
5849
		case OID_SKGE_PHY_LP_MODE:
5711
		case OID_SKGE_PHY_LP_MODE:
5850
			/* The preset ends here */
5712
			/* The PRESET ends here. */
5851
			if (Action == SK_PNMI_PRESET) {
5713
			if (Action == SK_PNMI_PRESET) {
5852
5714
5853
				return (SK_PNMI_ERR_OK);
5715
				return (SK_PNMI_ERR_OK);
5854
			}
5716
			}
5855
5717
5856
			if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5718
			if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNet mode. */
5857
				if (LogPortIndex == 0) {
5719
				if (LogPortIndex == 0) {
5858
					Offset = 0;
5720
					Offset = 0;
5859
					continue;
5721
					continue;
5860
				}
5722
				}
5861
				else {
5862
					/* Set value for physical ports */
5863
					PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
5864
5865
					switch (*(pBuf + Offset)) {
5866
						case 0:
5867
							/* If LowPowerMode is active, we can leave it. */
5868
							if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
5869
5870
								Val32 = SkGmLeaveLowPowerMode(pAC, IoC, PhysPortIndex);
5871
								
5872
								if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState < 3)	{
5873
									
5874
									SkDrvInitAdapter(pAC);
5875
								}
5876
								break;
5877
							}
5878
							else {
5879
								*pLen = 0;
5880
								return (SK_PNMI_ERR_GENERAL);
5881
							}
5882
						case 1:
5883
						case 2:
5884
						case 3:
5885
						case 4:
5886
							/* If no LowPowerMode is active, we can enter it. */
5887
							if (!pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
5888
5889
								if ((*(pBuf + Offset)) < 3)	{
5890
								
5891
									SkDrvDeInitAdapter(pAC);
5892
								}
5893
5894
								Val32 = SkGmEnterLowPowerMode(pAC, IoC, PhysPortIndex, *pBuf);
5895
								break;
5896
							}
5897
							else {
5898
								*pLen = 0;
5899
								return (SK_PNMI_ERR_GENERAL);
5900
							}
5901
						default:
5902
							*pLen = 0;
5903
							return (SK_PNMI_ERR_BAD_VALUE);
5904
					}
5905
				}
5906
			}
5723
			}
5907
			else { /* DualNetMode */
5724
			/* Set value for physical port. */
5908
				
5725
			PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
5909
				switch (*(pBuf + Offset)) {
5726
			CurrentPhyPowerState = pAC->GIni.GP[PhysPortIndex].PPhyPowerState;
5910
					case 0:
5911
						/* If we are in a LowPowerMode, we can leave it. */
5912
						if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
5913
5727
5914
							Val32 = SkGmLeaveLowPowerMode(pAC, IoC, PhysPortIndex);
5728
			switch (Val8) {
5915
							
5729
				case PHY_PM_OPERATIONAL_MODE:
5916
							if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState < 3)	{
5730
					/* If LowPowerMode is active, we can leave it. */
5731
					if (CurrentPhyPowerState) {
5917
5732
5918
								SkDrvInitAdapter(pAC);
5733
						Val32 = SkGmLeaveLowPowerMode(pAC, IoC, PhysPortIndex);
5919
							}
5734
						
5920
							break;
5735
						if ((CurrentPhyPowerState == PHY_PM_DEEP_SLEEP) ||
5921
						}
5736
							(CurrentPhyPowerState == PHY_PM_IEEE_POWER_DOWN)) {
5922
						else {
5737
							
5923
							*pLen = 0;
5738
							SkDrvInitAdapter(pAC);
5924
							return (SK_PNMI_ERR_GENERAL);
5925
						}
5926
					
5927
					case 1:
5928
					case 2:
5929
					case 3:
5930
					case 4:
5931
						/* If we are not already in LowPowerMode, we can enter it. */
5932
						if (!pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
5933
5934
							if ((*(pBuf + Offset)) < 3)	{
5935
5936
								SkDrvDeInitAdapter(pAC);
5937
							}
5938
							else {
5939
5940
								Val32 = SkGmEnterLowPowerMode(pAC, IoC, PhysPortIndex, *pBuf);
5941
							}
5942
							break;
5943
						}
5944
						else {
5945
							*pLen = 0;
5946
							return (SK_PNMI_ERR_GENERAL);
5947
						}
5739
						}
5948
					
5740
						break;
5949
					default:
5741
					}
5742
					else {
5950
						*pLen = 0;
5743
						*pLen = 0;
5951
						return (SK_PNMI_ERR_BAD_VALUE);
5744
						return (SK_PNMI_ERR_GENERAL);
5952
				}
5745
					}
5746
				case PHY_PM_DEEP_SLEEP:
5747
				case PHY_PM_IEEE_POWER_DOWN:
5748
					/* If no LowPowerMode is active, we can enter it. */
5749
					if (!CurrentPhyPowerState) {
5750
						SkDrvDeInitAdapter(pAC);
5751
					}
5752
5753
				case PHY_PM_ENERGY_DETECT:
5754
				case PHY_PM_ENERGY_DETECT_PLUS:
5755
					/* If no LowPowerMode is active, we can enter it. */
5756
					if (!CurrentPhyPowerState) {
5757
5758
						Val32 = SkGmEnterLowPowerMode(pAC, IoC, PhysPortIndex, *pBuf);
5759
						break;
5760
					}
5761
					else {
5762
						*pLen = 0;
5763
						return (SK_PNMI_ERR_GENERAL);
5764
					}
5765
				default:
5766
					*pLen = 0;
5767
					return (SK_PNMI_ERR_BAD_VALUE);
5953
			}
5768
			}
5954
			Offset += sizeof(SK_U8);
5769
			Offset++;
5955
			break;
5770
			break;
5956
#endif
5771
#endif /* SK_PHY_LP_MODE */
5957
5772
5958
		default:
5773
		default:
5959
            SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR,
5774
            SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR,
Lines 6003-6016 Link Here
6003
	unsigned int	Limit;
5818
	unsigned int	Limit;
6004
	unsigned int	Offset;
5819
	unsigned int	Offset;
6005
	unsigned int	Entries;
5820
	unsigned int	Entries;
6006
6007
	
5821
	
6008
	/*
5822
	/* Not implemented yet. Return always an empty table. */
6009
	 * Calculate instance if wished.
6010
	 */
6011
	/* XXX Not yet implemented. Return always an empty table. */
6012
	Entries = 0;
5823
	Entries = 0;
6013
5824
5825
	/* Calculate instance if wished. */
6014
	if ((Instance != (SK_U32)(-1))) {
5826
	if ((Instance != (SK_U32)(-1))) {
6015
5827
6016
		if ((Instance < 1) || (Instance > Entries)) {
5828
		if ((Instance < 1) || (Instance > Entries)) {
Lines 6027-6038 Link Here
6027
		Limit = Entries;
5839
		Limit = Entries;
6028
	}
5840
	}
6029
5841
6030
	/*
5842
	/* GET/SET value. */
6031
	 * Get/Set value
6032
	*/
6033
	if (Action == SK_PNMI_GET) {
5843
	if (Action == SK_PNMI_GET) {
6034
5844
6035
		for (Offset=0; Index < Limit; Index ++) {
5845
		for (Offset = 0; Index < Limit; Index ++) {
6036
5846
6037
			switch (Id) {
5847
			switch (Id) {
6038
5848
Lines 6054-6085 Link Here
6054
		*pLen = Offset;
5864
		*pLen = Offset;
6055
	}
5865
	}
6056
	else {
5866
	else {
6057
		/* Only MONITOR_ADMIN can be set */
5867
		/* Only MONITOR_ADMIN can be set. */
6058
		if (Id != OID_SKGE_RLMT_MONITOR_ADMIN) {
5868
		if (Id != OID_SKGE_RLMT_MONITOR_ADMIN) {
6059
5869
6060
			*pLen = 0;
5870
			*pLen = 0;
6061
			return (SK_PNMI_ERR_READ_ONLY);
5871
			return (SK_PNMI_ERR_READ_ONLY);
6062
		}
5872
		}
6063
5873
6064
		/* Check if the length is plausible */
5874
		/* Check if the length is plausible. */
6065
		if (*pLen < (Limit - Index)) {
5875
		if (*pLen < (Limit - Index)) {
6066
5876
6067
			return (SK_PNMI_ERR_TOO_SHORT);
5877
			return (SK_PNMI_ERR_TOO_SHORT);
6068
		}
5878
		}
6069
		/* Okay, we have a wide value range */
5879
		/* Okay, we have a wide value range. */
6070
		if (*pLen != (Limit - Index)) {
5880
		if (*pLen != (Limit - Index)) {
6071
5881
6072
			*pLen = 0;
5882
			*pLen = 0;
6073
			return (SK_PNMI_ERR_BAD_VALUE);
5883
			return (SK_PNMI_ERR_BAD_VALUE);
6074
		}
5884
		}
6075
/*
5885
6076
		for (Offset=0; Index < Limit; Index ++) {
5886
		/*
6077
		}
5887
		 * Not yet implemented. Return always BAD_VALUE,
6078
*/
5888
		 * because the table is empty.
6079
/*
5889
		 */
6080
 * XXX Not yet implemented. Return always BAD_VALUE, because the table
6081
 * is empty.
6082
 */
6083
		*pLen = 0;
5890
		*pLen = 0;
6084
		return (SK_PNMI_ERR_BAD_VALUE);
5891
		return (SK_PNMI_ERR_BAD_VALUE);
6085
	}
5892
	}
Lines 6120-6133 Link Here
6120
	PortActiveFlag = SK_FALSE;
5927
	PortActiveFlag = SK_FALSE;
6121
	PhysPortMax = pAC->GIni.GIMacsFound;
5928
	PhysPortMax = pAC->GIni.GIMacsFound;
6122
	
5929
	
6123
	for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
5930
	for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax; PhysPortIndex ++) {
6124
		PhysPortIndex ++) {
6125
5931
6126
		pPrt = &pAC->GIni.GP[PhysPortIndex];
5932
		pPrt = &pAC->GIni.GP[PhysPortIndex];
6127
5933
6128
		/* Check if the physical port is active */
5934
		/* Check if the physical port is active. */
6129
		if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
5935
		if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
6130
6131
			continue;
5936
			continue;
6132
		}
5937
		}
6133
5938
Lines 6136-6147 Link Here
6136
		switch (Id) {
5941
		switch (Id) {
6137
5942
6138
		case OID_SKGE_PHY_TYPE:
5943
		case OID_SKGE_PHY_TYPE:
6139
			/* Check if it is the first active port */
5944
			/* Check if it is the first active port. */
6140
			if (*pBuf == 0) {
5945
			if (*pBuf == 0) {
6141
				Val32 = pPrt->PhyType;
5946
				Val32 = pPrt->PhyType;
6142
				SK_PNMI_STORE_U32(pBuf, Val32);
5947
				SK_PNMI_STORE_U32(pBuf, Val32);
6143
				continue;
5948
				continue;
6144
			}
5949
			}
5950
			break;
6145
5951
6146
		case OID_SKGE_LINK_CAP:
5952
		case OID_SKGE_LINK_CAP:
6147
5953
Lines 6155-6161 Link Here
6155
			break;
5961
			break;
6156
5962
6157
		case OID_SKGE_LINK_MODE:
5963
		case OID_SKGE_LINK_MODE:
6158
			/* Check if it is the first active port */
5964
			/* Check if it is the first active port. */
6159
			if (*pBuf == 0) {
5965
			if (*pBuf == 0) {
6160
5966
6161
				*pBuf = pPrt->PLinkModeConf;
5967
				*pBuf = pPrt->PLinkModeConf;
Lines 6163-6171 Link Here
6163
			}
5969
			}
6164
5970
6165
			/*
5971
			/*
6166
			 * If we find an active port with a different link
5972
			 * If we find an active port with a different link mode
6167
			 * mode than the first one we return a value that
5973
			 * than the first one we return indeterminated.
6168
			 * indicates that the link mode is indeterminated.
6169
			 */
5974
			 */
6170
			if (*pBuf != pPrt->PLinkModeConf) {
5975
			if (*pBuf != pPrt->PLinkModeConf) {
6171
5976
Lines 6174-6183 Link Here
6174
			break;
5979
			break;
6175
5980
6176
		case OID_SKGE_LINK_MODE_STATUS:
5981
		case OID_SKGE_LINK_MODE_STATUS:
6177
			/* Get the link mode of the physical port */
5982
			/* Get the link mode of the physical port. */
6178
			Val8 = CalculateLinkModeStatus(pAC, IoC, PhysPortIndex);
5983
			Val8 = CalculateLinkModeStatus(pAC, IoC, PhysPortIndex);
6179
5984
6180
			/* Check if it is the first active port */
5985
			/* Check if it is the first active port. */
6181
			if (*pBuf == 0) {
5986
			if (*pBuf == 0) {
6182
5987
6183
				*pBuf = Val8;
5988
				*pBuf = Val8;
Lines 6185-6194 Link Here
6185
			}
5990
			}
6186
5991
6187
			/*
5992
			/*
6188
			 * If we find an active port with a different link
5993
			 * If we find an active port with a different link mode status
6189
			 * mode status than the first one we return a value
5994
			 * than the first one we return indeterminated.
6190
			 * that indicates that the link mode status is
6191
			 * indeterminated.
6192
			 */
5995
			 */
6193
			if (*pBuf != Val8) {
5996
			if (*pBuf != Val8) {
6194
5997
Lines 6197-6206 Link Here
6197
			break;
6000
			break;
6198
6001
6199
		case OID_SKGE_LINK_STATUS:
6002
		case OID_SKGE_LINK_STATUS:
6200
			/* Get the link status of the physical port */
6003
			/* Get the link status of the physical port. */
6201
			Val8 = CalculateLinkStatus(pAC, IoC, PhysPortIndex);
6004
			Val8 = CalculateLinkStatus(pAC, IoC, PhysPortIndex);
6202
6005
6203
			/* Check if it is the first active port */
6006
			/* Check if it is the first active port. */
6204
			if (*pBuf == 0) {
6007
			if (*pBuf == 0) {
6205
6008
6206
				*pBuf = Val8;
6009
				*pBuf = Val8;
Lines 6208-6217 Link Here
6208
			}
6011
			}
6209
6012
6210
			/*
6013
			/*
6211
			 * If we find an active port with a different link
6014
			 * If we find an active port with a different link status
6212
			 * status than the first one, we return a value
6015
			 * than the first one we return indeterminated.
6213
			 * that indicates that the link status is
6214
			 * indeterminated.
6215
			 */
6016
			 */
6216
			if (*pBuf != Val8) {
6017
			if (*pBuf != Val8) {
6217
6018
Lines 6220-6226 Link Here
6220
			break;
6021
			break;
6221
6022
6222
		case OID_SKGE_FLOWCTRL_CAP:
6023
		case OID_SKGE_FLOWCTRL_CAP:
6223
			/* Check if it is the first active port */
6024
			/* Check if it is the first active port. */
6224
			if (*pBuf == 0) {
6025
			if (*pBuf == 0) {
6225
6026
6226
				*pBuf = pPrt->PFlowCtrlCap;
6027
				*pBuf = pPrt->PFlowCtrlCap;
Lines 6235-6241 Link Here
6235
			break;
6036
			break;
6236
6037
6237
		case OID_SKGE_FLOWCTRL_MODE:
6038
		case OID_SKGE_FLOWCTRL_MODE:
6238
			/* Check if it is the first active port */
6039
			/* Check if it is the first active port. */
6239
			if (*pBuf == 0) {
6040
			if (*pBuf == 0) {
6240
6041
6241
				*pBuf = pPrt->PFlowCtrlMode;
6042
				*pBuf = pPrt->PFlowCtrlMode;
Lines 6243-6251 Link Here
6243
			}
6044
			}
6244
6045
6245
			/*
6046
			/*
6246
			 * If we find an active port with a different flow
6047
			 * If we find an active port with a different flow-control mode
6247
			 * control mode than the first one, we return a value
6048
			 * than the first one we return indeterminated.
6248
			 * that indicates that the mode is indeterminated.
6249
			 */
6049
			 */
6250
			if (*pBuf != pPrt->PFlowCtrlMode) {
6050
			if (*pBuf != pPrt->PFlowCtrlMode) {
6251
6051
Lines 6254-6260 Link Here
6254
			break;
6054
			break;
6255
6055
6256
		case OID_SKGE_FLOWCTRL_STATUS:
6056
		case OID_SKGE_FLOWCTRL_STATUS:
6257
			/* Check if it is the first active port */
6057
			/* Check if it is the first active port. */
6258
			if (*pBuf == 0) {
6058
			if (*pBuf == 0) {
6259
6059
6260
				*pBuf = pPrt->PFlowCtrlStatus;
6060
				*pBuf = pPrt->PFlowCtrlStatus;
Lines 6262-6271 Link Here
6262
			}
6062
			}
6263
6063
6264
			/*
6064
			/*
6265
			 * If we find an active port with a different flow
6065
			 * If we find an active port with a different flow-control status
6266
			 * control status than the first one, we return a
6066
			 * than the first one we return indeterminated.
6267
			 * value that indicates that the status is
6268
			 * indeterminated.
6269
			 */
6067
			 */
6270
			if (*pBuf != pPrt->PFlowCtrlStatus) {
6068
			if (*pBuf != pPrt->PFlowCtrlStatus) {
6271
6069
Lines 6274-6280 Link Here
6274
			break;
6072
			break;
6275
		
6073
		
6276
		case OID_SKGE_PHY_OPERATION_CAP:
6074
		case OID_SKGE_PHY_OPERATION_CAP:
6277
			/* Check if it is the first active port */
6075
			/* Check if it is the first active port. */
6278
			if (*pBuf == 0) {
6076
			if (*pBuf == 0) {
6279
6077
6280
				*pBuf = pPrt->PMSCap;
6078
				*pBuf = pPrt->PMSCap;
Lines 6289-6295 Link Here
6289
			break;
6087
			break;
6290
6088
6291
		case OID_SKGE_PHY_OPERATION_MODE:
6089
		case OID_SKGE_PHY_OPERATION_MODE:
6292
			/* Check if it is the first active port */
6090
			/* Check if it is the first active port. */
6293
			if (*pBuf == 0) {
6091
			if (*pBuf == 0) {
6294
6092
6295
				*pBuf = pPrt->PMSMode;
6093
				*pBuf = pPrt->PMSMode;
Lines 6297-6305 Link Here
6297
			}
6095
			}
6298
6096
6299
			/*
6097
			/*
6300
			 * If we find an active port with a different master/
6098
			 * If we find an active port with a different master/slave mode
6301
			 * slave mode than the first one, we return a value
6099
			 * than the first one we return indeterminated.
6302
			 * that indicates that the mode is indeterminated.
6303
			 */
6100
			 */
6304
			if (*pBuf != pPrt->PMSMode) {
6101
			if (*pBuf != pPrt->PMSMode) {
6305
6102
Lines 6308-6314 Link Here
6308
			break;
6105
			break;
6309
6106
6310
		case OID_SKGE_PHY_OPERATION_STATUS:
6107
		case OID_SKGE_PHY_OPERATION_STATUS:
6311
			/* Check if it is the first active port */
6108
			/* Check if it is the first active port. */
6312
			if (*pBuf == 0) {
6109
			if (*pBuf == 0) {
6313
6110
6314
				*pBuf = pPrt->PMSStatus;
6111
				*pBuf = pPrt->PMSStatus;
Lines 6316-6325 Link Here
6316
			}
6113
			}
6317
6114
6318
			/*
6115
			/*
6319
			 * If we find an active port with a different master/
6116
			 * If we find an active port with a different master/slave status
6320
			 * slave status than the first one, we return a
6117
			 * than the first one we return indeterminated.
6321
			 * value that indicates that the status is
6322
			 * indeterminated.
6323
			 */
6118
			 */
6324
			if (*pBuf != pPrt->PMSStatus) {
6119
			if (*pBuf != pPrt->PMSStatus) {
6325
6120
Lines 6328-6334 Link Here
6328
			break;
6123
			break;
6329
		
6124
		
6330
		case OID_SKGE_SPEED_MODE:
6125
		case OID_SKGE_SPEED_MODE:
6331
			/* Check if it is the first active port */
6126
			/* Check if it is the first active port. */
6332
			if (*pBuf == 0) {
6127
			if (*pBuf == 0) {
6333
6128
6334
				*pBuf = pPrt->PLinkSpeed;
6129
				*pBuf = pPrt->PLinkSpeed;
Lines 6336-6344 Link Here
6336
			}
6131
			}
6337
6132
6338
			/*
6133
			/*
6339
			 * If we find an active port with a different flow
6134
			 * If we find an active port with a different link speed
6340
			 * control mode than the first one, we return a value
6135
			 * than the first one we return indeterminated.
6341
			 * that indicates that the mode is indeterminated.
6342
			 */
6136
			 */
6343
			if (*pBuf != pPrt->PLinkSpeed) {
6137
			if (*pBuf != pPrt->PLinkSpeed) {
6344
6138
Lines 6347-6353 Link Here
6347
			break;
6141
			break;
6348
		
6142
		
6349
		case OID_SKGE_SPEED_STATUS:
6143
		case OID_SKGE_SPEED_STATUS:
6350
			/* Check if it is the first active port */
6144
			/* Check if it is the first active port. */
6351
			if (*pBuf == 0) {
6145
			if (*pBuf == 0) {
6352
6146
6353
				*pBuf = pPrt->PLinkSpeedUsed;
6147
				*pBuf = pPrt->PLinkSpeedUsed;
Lines 6355-6364 Link Here
6355
			}
6149
			}
6356
6150
6357
			/*
6151
			/*
6358
			 * If we find an active port with a different flow
6152
			 * If we find an active port with a different link speed used
6359
			 * control status than the first one, we return a
6153
			 * than the first one we return indeterminated.
6360
			 * value that indicates that the status is
6361
			 * indeterminated.
6362
			 */
6154
			 */
6363
			if (*pBuf != pPrt->PLinkSpeedUsed) {
6155
			if (*pBuf != pPrt->PLinkSpeedUsed) {
6364
6156
Lines 6368-6376 Link Here
6368
		}
6160
		}
6369
	}
6161
	}
6370
6162
6371
	/*
6163
	/* If no port is active return an indeterminated answer. */
6372
	 * If no port is active return an indeterminated answer
6373
	 */
6374
	if (!PortActiveFlag) {
6164
	if (!PortActiveFlag) {
6375
6165
6376
		switch (Id) {
6166
		switch (Id) {
Lines 6487-6502 Link Here
6487
{
6277
{
6488
	SK_U8	Result;
6278
	SK_U8	Result;
6489
6279
6490
	/* Get the current mode, which can be full or half duplex */
6280
	/* Get the current mode, which can be full or half duplex. */
6491
	Result = pAC->GIni.GP[PhysPortIndex].PLinkModeStatus;
6281
	Result = pAC->GIni.GP[PhysPortIndex].PLinkModeStatus;
6492
6282
6493
	/* Check if no valid mode could be found (link is down) */
6283
	/* Check if no valid mode could be found (link is down). */
6494
	if (Result < SK_LMODE_STAT_HALF) {
6284
	if (Result < SK_LMODE_STAT_HALF) {
6495
6285
6496
		Result = SK_LMODE_STAT_UNKNOWN;
6286
		Result = SK_LMODE_STAT_UNKNOWN;
6497
	}
6287
	}
6498
	else if (pAC->GIni.GP[PhysPortIndex].PLinkMode >= SK_LMODE_AUTOHALF) {
6288
	else if (pAC->GIni.GP[PhysPortIndex].PLinkMode >= SK_LMODE_AUTOHALF) {
6499
6500
		/*
6289
		/*
6501
		 * Auto-negotiation was used to bring up the link. Change
6290
		 * Auto-negotiation was used to bring up the link. Change
6502
		 * the already found duplex status that it indicates
6291
		 * the already found duplex status that it indicates
Lines 6541-6562 Link Here
6541
	int			Index;
6330
	int			Index;
6542
	int			Ret;
6331
	int			Ret;
6543
6332
6544
6545
	SK_MEMSET(pKeyArr, 0, KeyArrLen);
6333
	SK_MEMSET(pKeyArr, 0, KeyArrLen);
6546
6334
6547
	/*
6335
	/* Get VPD key list. */
6548
	 * Get VPD key list
6336
	Ret = VpdKeys(pAC, IoC, BufKeys, (int *)&BufKeysLen,
6549
	 */
6550
	Ret = VpdKeys(pAC, IoC, (char *)&BufKeys, (int *)&BufKeysLen,
6551
		(int *)pKeyNo);
6337
		(int *)pKeyNo);
6338
	
6552
	if (Ret > 0) {
6339
	if (Ret > 0) {
6553
6340
6554
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR014,
6341
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR014, SK_PNMI_ERR014MSG);
6555
			SK_PNMI_ERR014MSG);
6556
6342
6557
		return (SK_PNMI_ERR_GENERAL);
6343
		return (SK_PNMI_ERR_GENERAL);
6558
	}
6344
	}
6559
	/* If no keys are available return now */
6345
	/* If no keys are available return now. */
6560
	if (*pKeyNo == 0 || BufKeysLen == 0) {
6346
	if (*pKeyNo == 0 || BufKeysLen == 0) {
6561
6347
6562
		return (SK_PNMI_ERR_OK);
6348
		return (SK_PNMI_ERR_OK);
Lines 6564-6575 Link Here
6564
	/*
6350
	/*
6565
	 * If the key list is too long for us trunc it and give a
6351
	 * If the key list is too long for us trunc it and give a
6566
	 * errorlog notification. This case should not happen because
6352
	 * errorlog notification. This case should not happen because
6567
	 * the maximum number of keys is limited due to RAM limitations
6353
	 * the maximum number of keys is limited due to RAM limitations.
6568
	 */
6354
	 */
6569
	if (*pKeyNo > SK_PNMI_VPD_ENTRIES) {
6355
	if (*pKeyNo > SK_PNMI_VPD_ENTRIES) {
6570
6356
6571
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR015,
6357
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR015, SK_PNMI_ERR015MSG);
6572
			SK_PNMI_ERR015MSG);
6573
6358
6574
		*pKeyNo = SK_PNMI_VPD_ENTRIES;
6359
		*pKeyNo = SK_PNMI_VPD_ENTRIES;
6575
	}
6360
	}
Lines 6582-6595 Link Here
6582
		Offset ++) {
6367
		Offset ++) {
6583
6368
6584
		if (BufKeys[Offset] != 0) {
6369
		if (BufKeys[Offset] != 0) {
6585
6586
			continue;
6370
			continue;
6587
		}
6371
		}
6588
6372
6589
		if (Offset - StartOffset > SK_PNMI_VPD_KEY_SIZE) {
6373
		if (Offset - StartOffset > SK_PNMI_VPD_KEY_SIZE) {
6590
6374
6591
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR016,
6375
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR016, SK_PNMI_ERR016MSG);
6592
				SK_PNMI_ERR016MSG);
6593
			return (SK_PNMI_ERR_GENERAL);
6376
			return (SK_PNMI_ERR_GENERAL);
6594
		}
6377
		}
6595
6378
Lines 6600-6606 Link Here
6600
		StartOffset = Offset + 1;
6383
		StartOffset = Offset + 1;
6601
	}
6384
	}
6602
6385
6603
	/* Last key not zero terminated? Get it anyway */
6386
	/* Last key not zero terminated? Get it anyway. */
6604
	if (StartOffset < Offset) {
6387
	if (StartOffset < Offset) {
6605
6388
6606
		SK_STRNCPY(pKeyArr + Index * SK_PNMI_VPD_KEY_SIZE,
6389
		SK_STRNCPY(pKeyArr + Index * SK_PNMI_VPD_KEY_SIZE,
Lines 6629-6647 Link Here
6629
{
6412
{
6630
	SK_EVPARA	EventParam;
6413
	SK_EVPARA	EventParam;
6631
6414
6632
6633
	/* Was the module already updated during the current PNMI call? */
6415
	/* Was the module already updated during the current PNMI call? */
6634
	if (pAC->Pnmi.SirqUpdatedFlag > 0) {
6416
	if (pAC->Pnmi.SirqUpdatedFlag > 0) {
6635
6417
6636
		return (SK_PNMI_ERR_OK);
6418
		return (SK_PNMI_ERR_OK);
6637
	}
6419
	}
6638
6420
6639
	/* Send an synchronuous update event to the module */
6421
	/* Send an synchronuous update event to the module. */
6640
	SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
6422
	SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
6641
	if (SkGeSirqEvent(pAC, IoC, SK_HWEV_UPDATE_STAT, EventParam) > 0) {
6423
	
6424
	if (SkGeSirqEvent(pAC, IoC, SK_HWEV_UPDATE_STAT, EventParam)) {
6642
6425
6643
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR047,
6426
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR047, SK_PNMI_ERR047MSG);
6644
			SK_PNMI_ERR047MSG);
6645
6427
6646
		return (SK_PNMI_ERR_GENERAL);
6428
		return (SK_PNMI_ERR_GENERAL);
6647
	}
6429
	}
Lines 6669-6689 Link Here
6669
{
6451
{
6670
	SK_EVPARA	EventParam;
6452
	SK_EVPARA	EventParam;
6671
6453
6672
6673
	/* Was the module already updated during the current PNMI call? */
6454
	/* Was the module already updated during the current PNMI call? */
6674
	if (pAC->Pnmi.RlmtUpdatedFlag > 0) {
6455
	if (pAC->Pnmi.RlmtUpdatedFlag > 0) {
6675
6456
6676
		return (SK_PNMI_ERR_OK);
6457
		return (SK_PNMI_ERR_OK);
6677
	}
6458
	}
6678
6459
6679
	/* Send an synchronuous update event to the module */
6460
	/* Send an synchronuous update event to the module. */
6680
	SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
6461
	SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
6681
	EventParam.Para32[0] = NetIndex;
6462
	EventParam.Para32[0] = NetIndex;
6682
	EventParam.Para32[1] = (SK_U32)-1;
6463
	EventParam.Para32[1] = (SK_U32)-1;
6683
	if (SkRlmtEvent(pAC, IoC, SK_RLMT_STATS_UPDATE, EventParam) > 0) {
6464
	if (SkRlmtEvent(pAC, IoC, SK_RLMT_STATS_UPDATE, EventParam) > 0) {
6684
6465
6685
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR048,
6466
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR048, SK_PNMI_ERR048MSG);
6686
			SK_PNMI_ERR048MSG);
6687
6467
6688
		return (SK_PNMI_ERR_GENERAL);
6468
		return (SK_PNMI_ERR_GENERAL);
6689
	}
6469
	}
Lines 6721-6740 Link Here
6721
		return (SK_PNMI_ERR_OK);
6501
		return (SK_PNMI_ERR_OK);
6722
	}
6502
	}
6723
6503
6724
	/* Send an update command to all MACs specified */
6504
	/* Send an update command to all MACs specified. */
6725
	for (MacIndex = FirstMac; MacIndex <= LastMac; MacIndex ++) {
6505
	for (MacIndex = FirstMac; MacIndex <= LastMac; MacIndex ++) {
6726
6506
6727
		/*
6507
		/*
6728
		 * 2002-09-13 pweber:	Freeze the current SW counters.
6508
		 * 2002-09-13 pweber:	Freeze the current SW counters.
6729
		 *                      (That should be done as close as
6509
		 *                      (That should be done as close as
6730
		 *                      possible to the update of the
6510
		 *                      possible to the update of the
6731
		 *                      HW counters)
6511
		 *                      HW counters).
6732
		 */
6512
		 */
6733
		if (pAC->GIni.GIMacType == SK_MAC_XMAC) {
6513
		if (pAC->GIni.GIMacType == SK_MAC_XMAC) {
6734
			pAC->Pnmi.BufPort[MacIndex] = pAC->Pnmi.Port[MacIndex];
6514
			pAC->Pnmi.BufPort[MacIndex] = pAC->Pnmi.Port[MacIndex];
6735
		}
6515
		}
6736
			
6516
			
6737
		/* 2002-09-13 pweber:  Update the HW counter  */
6517
		/* 2002-09-13 pweber:  Update the HW counter.  */
6738
		if (pAC->GIni.GIFunc.pFnMacUpdateStats(pAC, IoC, MacIndex) != 0) {
6518
		if (pAC->GIni.GIFunc.pFnMacUpdateStats(pAC, IoC, MacIndex) != 0) {
6739
6519
6740
			return (SK_PNMI_ERR_GENERAL);
6520
			return (SK_PNMI_ERR_GENERAL);
Lines 6772-6790 Link Here
6772
	SK_U64			Val = 0;
6552
	SK_U64			Val = 0;
6773
6553
6774
6554
6775
	if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {	/* Dual net mode */
6555
	if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {	/* DualNet mode. */
6776
6556
6777
		PhysPortIndex = NetIndex;
6557
		PhysPortIndex = NetIndex;
6778
		
6558
		
6779
		Val = GetPhysStatVal(pAC, IoC, PhysPortIndex, StatIndex);
6559
		Val = GetPhysStatVal(pAC, IoC, PhysPortIndex, StatIndex);
6780
	}
6560
	}
6781
	else {	/* Single Net mode */
6561
	else {	/* SingleNet mode. */
6782
6562
6783
		if (LogPortIndex == 0) {
6563
		if (LogPortIndex == 0) {
6784
6564
6785
			PhysPortMax = pAC->GIni.GIMacsFound;
6565
			PhysPortMax = pAC->GIni.GIMacsFound;
6786
6566
6787
			/* Add counter of all active ports */
6567
			/* Add counter of all active ports. */
6788
			for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
6568
			for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
6789
				PhysPortIndex ++) {
6569
				PhysPortIndex ++) {
6790
6570
Lines 6794-6804 Link Here
6794
				}
6574
				}
6795
			}
6575
			}
6796
6576
6797
			/* Correct value because of port switches */
6577
			/* Correct value because of port switches. */
6798
			Val += pAC->Pnmi.VirtualCounterOffset[StatIndex];
6578
			Val += pAC->Pnmi.VirtualCounterOffset[StatIndex];
6799
		}
6579
		}
6800
		else {
6580
		else {
6801
			/* Get counter value of physical port */
6581
			/* Get counter value of physical port. */
6802
			PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
6582
			PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
6803
			
6583
			
6804
			Val = GetPhysStatVal(pAC, IoC, PhysPortIndex, StatIndex);
6584
			Val = GetPhysStatVal(pAC, IoC, PhysPortIndex, StatIndex);
Lines 6844-6850 Link Here
6844
	
6624
	
6845
	MacType = pAC->GIni.GIMacType;
6625
	MacType = pAC->GIni.GIMacType;
6846
	
6626
	
6847
	/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort) */
6627
	/* 2002-09-17 pweber: For XMAC, use the frozen SW counters (BufPort). */
6848
	if (MacType == SK_MAC_XMAC) {
6628
	if (MacType == SK_MAC_XMAC) {
6849
		pPnmiPrt = &pAC->Pnmi.BufPort[PhysPortIndex];
6629
		pPnmiPrt = &pAC->Pnmi.BufPort[PhysPortIndex];
6850
	}
6630
	}
Lines 6912-6918 Link Here
6912
	case SK_PNMI_HTX_BURST:
6692
	case SK_PNMI_HTX_BURST:
6913
	case SK_PNMI_HTX_EXCESS_DEF:
6693
	case SK_PNMI_HTX_EXCESS_DEF:
6914
	case SK_PNMI_HTX_CARRIER:
6694
	case SK_PNMI_HTX_CARRIER:
6915
		/* Not supported by GMAC */
6695
		/* Not supported by GMAC. */
6916
		if (MacType == SK_MAC_GMAC) {
6696
		if (MacType == SK_MAC_GMAC) {
6917
			return (Val);
6697
			return (Val);
6918
		}
6698
		}
Lines 6924-6930 Link Here
6924
		break;
6704
		break;
6925
6705
6926
	case SK_PNMI_HTX_MACC:
6706
	case SK_PNMI_HTX_MACC:
6927
		/* GMAC only supports PAUSE MAC control frames */
6707
		/* GMAC only supports PAUSE MAC control frames. */
6928
		if (MacType == SK_MAC_GMAC) {
6708
		if (MacType == SK_MAC_GMAC) {
6929
			HelpIndex = SK_PNMI_HTX_PMACC;
6709
			HelpIndex = SK_PNMI_HTX_PMACC;
6930
		}
6710
		}
Lines 6941-6947 Link Here
6941
6721
6942
	case SK_PNMI_HTX_COL:
6722
	case SK_PNMI_HTX_COL:
6943
	case SK_PNMI_HRX_UNDERSIZE:
6723
	case SK_PNMI_HRX_UNDERSIZE:
6944
		/* Not supported by XMAC */
6724
		/* Not supported by XMAC. */
6945
		if (MacType == SK_MAC_XMAC) {
6725
		if (MacType == SK_MAC_XMAC) {
6946
			return (Val);
6726
			return (Val);
6947
		}
6727
		}
Lines 6953-6959 Link Here
6953
		break;
6733
		break;
6954
6734
6955
	case SK_PNMI_HTX_DEFFERAL:
6735
	case SK_PNMI_HTX_DEFFERAL:
6956
		/* Not supported by GMAC */
6736
		/* Not supported by GMAC. */
6957
		if (MacType == SK_MAC_GMAC) {
6737
		if (MacType == SK_MAC_GMAC) {
6958
			return (Val);
6738
			return (Val);
6959
		}
6739
		}
Lines 6971-6977 Link Here
6971
			HighVal = 0;
6751
			HighVal = 0;
6972
		}
6752
		}
6973
		else {
6753
		else {
6974
			/* Otherwise get contents of hardware register */
6754
			/* Otherwise get contents of hardware register. */
6975
			(void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
6755
			(void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
6976
										  StatAddr[StatIndex][MacType].Reg,
6756
										  StatAddr[StatIndex][MacType].Reg,
6977
										  &LowVal);
6757
										  &LowVal);
Lines 6980-6986 Link Here
6980
		break;
6760
		break;
6981
6761
6982
	case SK_PNMI_HRX_BADOCTET:
6762
	case SK_PNMI_HRX_BADOCTET:
6983
		/* Not supported by XMAC */
6763
		/* Not supported by XMAC. */
6984
		if (MacType == SK_MAC_XMAC) {
6764
		if (MacType == SK_MAC_XMAC) {
6985
			return (Val);
6765
			return (Val);
6986
		}
6766
		}
Lines 6999-7005 Link Here
6999
		return (Val);
6779
		return (Val);
7000
6780
7001
	case SK_PNMI_HRX_LONGFRAMES:
6781
	case SK_PNMI_HRX_LONGFRAMES:
7002
		/* For XMAC the SW counter is managed by PNMI */
6782
		/* For XMAC the SW counter is managed by PNMI. */
7003
		if (MacType == SK_MAC_XMAC) {
6783
		if (MacType == SK_MAC_XMAC) {
7004
			return (pPnmiPrt->StatRxLongFrameCts);
6784
			return (pPnmiPrt->StatRxLongFrameCts);
7005
		}
6785
		}
Lines 7019-7025 Link Here
7019
		Val = (((SK_U64)HighVal << 32) | (SK_U64)LowVal);
6799
		Val = (((SK_U64)HighVal << 32) | (SK_U64)LowVal);
7020
6800
7021
		if (MacType == SK_MAC_GMAC) {
6801
		if (MacType == SK_MAC_GMAC) {
7022
			/* For GMAC the SW counter is additionally managed by PNMI */
6802
			/* For GMAC the SW counter is additionally managed by PNMI. */
7023
			Val += pPnmiPrt->StatRxFrameTooLongCts;
6803
			Val += pPnmiPrt->StatRxFrameTooLongCts;
7024
		}
6804
		}
7025
		else {
6805
		else {
Lines 7037-7056 Link Here
7037
		break;
6817
		break;
7038
		
6818
		
7039
	case SK_PNMI_HRX_SHORTS:
6819
	case SK_PNMI_HRX_SHORTS:
7040
		/* Not supported by GMAC */
6820
		/* Not supported by GMAC. */
7041
		if (MacType == SK_MAC_GMAC) {
6821
		if (MacType == SK_MAC_GMAC) {
7042
			/* GM_RXE_FRAG?? */
6822
			/* GM_RXE_FRAG?? */
7043
			return (Val);
6823
			return (Val);
7044
		}
6824
		}
7045
		
6825
		
7046
		/*
6826
		/*
7047
		 * XMAC counts short frame errors even if link down (#10620)
6827
		 * XMAC counts short frame errors even if link down (#10620).
7048
		 *
6828
		 * If the link is down, the counter remains constant.
7049
		 * If link-down the counter remains constant
7050
		 */
6829
		 */
7051
		if (pPrt->PLinkModeStatus != SK_LMODE_STAT_UNKNOWN) {
6830
		if (pPrt->PLinkModeStatus != SK_LMODE_STAT_UNKNOWN) {
7052
6831
7053
			/* Otherwise get incremental difference */
6832
			/* Otherwise get incremental difference. */
7054
			(void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
6833
			(void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
7055
										  StatAddr[StatIndex][MacType].Reg,
6834
										  StatAddr[StatIndex][MacType].Reg,
7056
										  &LowVal);
6835
										  &LowVal);
Lines 7073-7079 Link Here
7073
	case SK_PNMI_HRX_IRLENGTH:
6852
	case SK_PNMI_HRX_IRLENGTH:
7074
	case SK_PNMI_HRX_SYMBOL:
6853
	case SK_PNMI_HRX_SYMBOL:
7075
	case SK_PNMI_HRX_CEXT:
6854
	case SK_PNMI_HRX_CEXT:
7076
		/* Not supported by GMAC */
6855
		/* Not supported by GMAC. */
7077
		if (MacType == SK_MAC_GMAC) {
6856
		if (MacType == SK_MAC_GMAC) {
7078
			return (Val);
6857
			return (Val);
7079
		}
6858
		}
Lines 7085-7091 Link Here
7085
		break;
6864
		break;
7086
6865
7087
	case SK_PNMI_HRX_PMACC_ERR:
6866
	case SK_PNMI_HRX_PMACC_ERR:
7088
		/* For GMAC the SW counter is managed by PNMI */
6867
		/* For GMAC the SW counter is managed by PNMI. */
7089
		if (MacType == SK_MAC_GMAC) {
6868
		if (MacType == SK_MAC_GMAC) {
7090
			return (pPnmiPrt->StatRxPMaccErr);
6869
			return (pPnmiPrt->StatRxPMaccErr);
7091
		}
6870
		}
Lines 7096-7108 Link Here
7096
		HighVal = pPnmiPrt->CounterHigh[StatIndex];
6875
		HighVal = pPnmiPrt->CounterHigh[StatIndex];
7097
		break;
6876
		break;
7098
6877
7099
	/* SW counter managed by PNMI */
6878
	/* SW counter managed by PNMI. */
7100
	case SK_PNMI_HTX_SYNC:
6879
	case SK_PNMI_HTX_SYNC:
7101
		LowVal = (SK_U32)pPnmiPrt->StatSyncCts;
6880
		LowVal = (SK_U32)pPnmiPrt->StatSyncCts;
7102
		HighVal = (SK_U32)(pPnmiPrt->StatSyncCts >> 32);
6881
		HighVal = (SK_U32)(pPnmiPrt->StatSyncCts >> 32);
7103
		break;
6882
		break;
7104
6883
7105
	/* SW counter managed by PNMI */
6884
	/* SW counter managed by PNMI. */
7106
	case SK_PNMI_HTX_SYNC_OCTET:
6885
	case SK_PNMI_HTX_SYNC_OCTET:
7107
		LowVal = (SK_U32)pPnmiPrt->StatSyncOctetsCts;
6886
		LowVal = (SK_U32)pPnmiPrt->StatSyncOctetsCts;
7108
		HighVal = (SK_U32)(pPnmiPrt->StatSyncOctetsCts >> 32);
6887
		HighVal = (SK_U32)(pPnmiPrt->StatSyncOctetsCts >> 32);
Lines 7110-7126 Link Here
7110
6889
7111
	case SK_PNMI_HRX_FCS:
6890
	case SK_PNMI_HRX_FCS:
7112
		/*
6891
		/*
7113
		 * Broadcom filters FCS errors and counts it in
6892
		 * Broadcom filters FCS errors and counts them in
7114
		 * Receive Error Counter register
6893
		 * Receive Error Counter register.
7115
		 */
6894
		 */
7116
		if (pPrt->PhyType == SK_PHY_BCOM) {
6895
		if (pPrt->PhyType == SK_PHY_BCOM) {
7117
			/* do not read while not initialized (PHY_READ hangs!)*/
6896
#ifdef GENESIS
6897
			/* Do not read while not initialized (PHY_READ hangs!). */
7118
			if (pPrt->PState != SK_PRT_RESET) {
6898
			if (pPrt->PState != SK_PRT_RESET) {
7119
				SkXmPhyRead(pAC, IoC, PhysPortIndex, PHY_BCOM_RE_CTR, &Word);
6899
				SkXmPhyRead(pAC, IoC, PhysPortIndex, PHY_BCOM_RE_CTR, &Word);
7120
				
6900
				
7121
				LowVal = Word;
6901
				LowVal = Word;
7122
			}
6902
			}
7123
			HighVal = pPnmiPrt->CounterHigh[StatIndex];
6903
			HighVal = pPnmiPrt->CounterHigh[StatIndex];
6904
#endif /* GENESIS */
7124
		}
6905
		}
7125
		else {
6906
		else {
7126
			(void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
6907
			(void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
Lines 7140-7146 Link Here
7140
6921
7141
	Val = (((SK_U64)HighVal << 32) | (SK_U64)LowVal);
6922
	Val = (((SK_U64)HighVal << 32) | (SK_U64)LowVal);
7142
6923
7143
	/* Correct value because of possible XMAC reset. XMAC Errata #2 */
6924
	/* Correct value because of possible XMAC reset (XMAC Errata #2). */
7144
	Val += pPnmiPrt->CounterOffset[StatIndex];
6925
	Val += pPnmiPrt->CounterOffset[StatIndex];
7145
6926
7146
	return (Val);
6927
	return (Val);
Lines 7165-7186 Link Here
7165
	unsigned int	PhysPortIndex;
6946
	unsigned int	PhysPortIndex;
7166
	SK_EVPARA	EventParam;
6947
	SK_EVPARA	EventParam;
7167
6948
7168
7169
	SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
6949
	SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
7170
6950
7171
	/* Notify sensor module */
6951
	/* Notify sensor module. */
7172
	SkEventQueue(pAC, SKGE_I2C, SK_I2CEV_CLEAR, EventParam);
6952
	SkEventQueue(pAC, SKGE_I2C, SK_I2CEV_CLEAR, EventParam);
7173
6953
7174
	/* Notify RLMT module */
6954
	/* Notify RLMT module. */
7175
	EventParam.Para32[0] = NetIndex;
6955
	EventParam.Para32[0] = NetIndex;
7176
	EventParam.Para32[1] = (SK_U32)-1;
6956
	EventParam.Para32[1] = (SK_U32)-1;
7177
	SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STATS_CLEAR, EventParam);
6957
	SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STATS_CLEAR, EventParam);
7178
	EventParam.Para32[1] = 0;
6958
	EventParam.Para32[1] = 0;
7179
6959
7180
	/* Notify SIRQ module */
6960
	/* Notify SIRQ module. */
7181
	SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_CLEAR_STAT, EventParam);
6961
	SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_CLEAR_STAT, EventParam);
7182
6962
7183
	/* Notify CSUM module */
6963
	/* Notify CSUM module. */
7184
#ifdef SK_USE_CSUM
6964
#ifdef SK_USE_CSUM
7185
	EventParam.Para32[0] = NetIndex;
6965
	EventParam.Para32[0] = NetIndex;
7186
	EventParam.Para32[1] = (SK_U32)-1;
6966
	EventParam.Para32[1] = (SK_U32)-1;
Lines 7188-7194 Link Here
7188
		EventParam);
6968
		EventParam);
7189
#endif /* SK_USE_CSUM */
6969
#endif /* SK_USE_CSUM */
7190
	
6970
	
7191
	/* Clear XMAC statistic */
6971
	/* Clear XMAC statistics. */
7192
	for (PhysPortIndex = 0; PhysPortIndex <
6972
	for (PhysPortIndex = 0; PhysPortIndex <
7193
		(unsigned int)pAC->GIni.GIMacsFound; PhysPortIndex ++) {
6973
		(unsigned int)pAC->GIni.GIMacsFound; PhysPortIndex ++) {
7194
6974
Lines 7215-7227 Link Here
7215
			PhysPortIndex].StatRxPMaccErr));
6995
			PhysPortIndex].StatRxPMaccErr));
7216
	}
6996
	}
7217
6997
7218
	/*
6998
	/* Clear local statistics. */
7219
	 * Clear local statistics
7220
	 */
7221
	SK_MEMSET((char *)&pAC->Pnmi.VirtualCounterOffset, 0,
6999
	SK_MEMSET((char *)&pAC->Pnmi.VirtualCounterOffset, 0,
7222
		  sizeof(pAC->Pnmi.VirtualCounterOffset));
7000
		  sizeof(pAC->Pnmi.VirtualCounterOffset));
7001
	
7223
	pAC->Pnmi.RlmtChangeCts = 0;
7002
	pAC->Pnmi.RlmtChangeCts = 0;
7224
	pAC->Pnmi.RlmtChangeTime = 0;
7003
	pAC->Pnmi.RlmtChangeTime = 0;
7004
	
7225
	SK_MEMSET((char *)&pAC->Pnmi.RlmtChangeEstimate.EstValue[0], 0,
7005
	SK_MEMSET((char *)&pAC->Pnmi.RlmtChangeEstimate.EstValue[0], 0,
7226
		sizeof(pAC->Pnmi.RlmtChangeEstimate.EstValue));
7006
		sizeof(pAC->Pnmi.RlmtChangeEstimate.EstValue));
7227
	pAC->Pnmi.RlmtChangeEstimate.EstValueIndex = 0;
7007
	pAC->Pnmi.RlmtChangeEstimate.EstValueIndex = 0;
Lines 7258-7280 Link Here
7258
SK_U32 TrapId,		/* SNMP ID of the trap */
7038
SK_U32 TrapId,		/* SNMP ID of the trap */
7259
unsigned int Size)	/* Space needed for trap entry */
7039
unsigned int Size)	/* Space needed for trap entry */
7260
{
7040
{
7261
	unsigned int		BufPad = pAC->Pnmi.TrapBufPad;
7041
	unsigned int	BufPad = pAC->Pnmi.TrapBufPad;
7262
	unsigned int		BufFree = pAC->Pnmi.TrapBufFree;
7042
	unsigned int	BufFree = pAC->Pnmi.TrapBufFree;
7263
	unsigned int		Beg = pAC->Pnmi.TrapQueueBeg;
7043
	unsigned int	Beg = pAC->Pnmi.TrapQueueBeg;
7264
	unsigned int		End = pAC->Pnmi.TrapQueueEnd;
7044
	unsigned int	End = pAC->Pnmi.TrapQueueEnd;
7265
	char			*pBuf = &pAC->Pnmi.TrapBuf[0];
7045
	char			*pBuf = &pAC->Pnmi.TrapBuf[0];
7266
	int			Wrap;
7046
	int			Wrap;
7267
	unsigned int		NeededSpace;
7047
	unsigned int	NeededSpace;
7268
	unsigned int		EntrySize;
7048
	unsigned int	EntrySize;
7269
	SK_U32			Val32;
7049
	SK_U32			Val32;
7270
	SK_U64			Val64;
7050
	SK_U64			Val64;
7271
7051
7272
7052
	/* Last byte of entry will get a copy of the entry length. */
7273
	/* Last byte of entry will get a copy of the entry length */
7274
	Size ++;
7053
	Size ++;
7275
7054
7276
	/*
7055
	/* Calculate needed buffer space. */
7277
	 * Calculate needed buffer space */
7278
	if (Beg >= Size) {
7056
	if (Beg >= Size) {
7279
7057
7280
		NeededSpace = Size;
7058
		NeededSpace = Size;
Lines 7289-7295 Link Here
7289
	 * Check if enough buffer space is provided. Otherwise
7067
	 * Check if enough buffer space is provided. Otherwise
7290
	 * free some entries. Leave one byte space between begin
7068
	 * free some entries. Leave one byte space between begin
7291
	 * and end of buffer to make it possible to detect whether
7069
	 * and end of buffer to make it possible to detect whether
7292
	 * the buffer is full or empty
7070
	 * the buffer is full or empty.
7293
	 */
7071
	 */
7294
	while (BufFree < NeededSpace + 1) {
7072
	while (BufFree < NeededSpace + 1) {
7295
7073
Lines 7328-7340 Link Here
7328
	}
7106
	}
7329
	BufFree -= NeededSpace;
7107
	BufFree -= NeededSpace;
7330
7108
7331
	/* Save the current offsets */
7109
	/* Save the current offsets. */
7332
	pAC->Pnmi.TrapQueueBeg = Beg;
7110
	pAC->Pnmi.TrapQueueBeg = Beg;
7333
	pAC->Pnmi.TrapQueueEnd = End;
7111
	pAC->Pnmi.TrapQueueEnd = End;
7334
	pAC->Pnmi.TrapBufPad = BufPad;
7112
	pAC->Pnmi.TrapBufPad = BufPad;
7335
	pAC->Pnmi.TrapBufFree = BufFree;
7113
	pAC->Pnmi.TrapBufFree = BufFree;
7336
7114
7337
	/* Initialize the trap entry */
7115
	/* Initialize the trap entry. */
7338
	*(pBuf + Beg + Size - 1) = (char)Size;
7116
	*(pBuf + Beg + Size - 1) = (char)Size;
7339
	*(pBuf + Beg) = (char)Size;
7117
	*(pBuf + Beg) = (char)Size;
7340
	Val32 = (pAC->Pnmi.TrapUnique) ++;
7118
	Val32 = (pAC->Pnmi.TrapUnique) ++;
Lines 7369-7375 Link Here
7369
	unsigned int	Len;
7147
	unsigned int	Len;
7370
	unsigned int	DstOff = 0;
7148
	unsigned int	DstOff = 0;
7371
7149
7372
7373
	while (Trap != End) {
7150
	while (Trap != End) {
7374
7151
7375
		Len = (unsigned int)*(pBuf + Trap);
7152
		Len = (unsigned int)*(pBuf + Trap);
Lines 7414-7420 Link Here
7414
	unsigned int	Entries = 0;
7191
	unsigned int	Entries = 0;
7415
	unsigned int	TotalLen = 0;
7192
	unsigned int	TotalLen = 0;
7416
7193
7417
7418
	while (Trap != End) {
7194
	while (Trap != End) {
7419
7195
7420
		Len = (unsigned int)*(pBuf + Trap);
7196
		Len = (unsigned int)*(pBuf + Trap);
Lines 7471-7484 Link Here
7471
	unsigned int	DescrLen;
7247
	unsigned int	DescrLen;
7472
	SK_U32		Val32;
7248
	SK_U32		Val32;
7473
7249
7474
7250
	/* Get trap buffer entry. */
7475
	/* Get trap buffer entry */
7476
	DescrLen = SK_STRLEN(pAC->I2c.SenTable[SensorIndex].SenDesc);
7251
	DescrLen = SK_STRLEN(pAC->I2c.SenTable[SensorIndex].SenDesc);
7252
	
7477
	pBuf = GetTrapEntry(pAC, TrapId,
7253
	pBuf = GetTrapEntry(pAC, TrapId,
7478
		SK_PNMI_TRAP_SENSOR_LEN_BASE + DescrLen);
7254
		SK_PNMI_TRAP_SENSOR_LEN_BASE + DescrLen);
7479
	Offset = SK_PNMI_TRAP_SIMPLE_LEN;
7255
	Offset = SK_PNMI_TRAP_SIMPLE_LEN;
7480
7256
7481
	/* Store additionally sensor trap related data */
7257
	/* Store additionally sensor trap related data. */
7482
	Val32 = OID_SKGE_SENSOR_INDEX;
7258
	Val32 = OID_SKGE_SENSOR_INDEX;
7483
	SK_PNMI_STORE_U32(pBuf + Offset, Val32);
7259
	SK_PNMI_STORE_U32(pBuf + Offset, Val32);
7484
	*(pBuf + Offset + 4) = 4;
7260
	*(pBuf + Offset + 4) = 4;
Lines 7523-7529 Link Here
7523
	char	*pBuf;
7299
	char	*pBuf;
7524
	SK_U32	Val32;
7300
	SK_U32	Val32;
7525
7301
7526
7527
	pBuf = GetTrapEntry(pAC, OID_SKGE_TRAP_RLMT_CHANGE_PORT,
7302
	pBuf = GetTrapEntry(pAC, OID_SKGE_TRAP_RLMT_CHANGE_PORT,
7528
		SK_PNMI_TRAP_RLMT_CHANGE_LEN);
7303
		SK_PNMI_TRAP_RLMT_CHANGE_LEN);
7529
7304
Lines 7551-7557 Link Here
7551
	char	*pBuf;
7326
	char	*pBuf;
7552
	SK_U32	Val32;
7327
	SK_U32	Val32;
7553
7328
7554
7555
	pBuf = GetTrapEntry(pAC, TrapId, SK_PNMI_TRAP_RLMT_PORT_LEN);
7329
	pBuf = GetTrapEntry(pAC, TrapId, SK_PNMI_TRAP_RLMT_PORT_LEN);
7556
7330
7557
	Val32 = OID_SKGE_RLMT_PORT_INDEX;
7331
	Val32 = OID_SKGE_RLMT_PORT_INDEX;
Lines 7571-7582 Link Here
7571
 *	Nothing
7345
 *	Nothing
7572
 */
7346
 */
7573
PNMI_STATIC void CopyMac(
7347
PNMI_STATIC void CopyMac(
7574
char *pDst,		/* Pointer to destination buffer */
7348
char		*pDst,	/* Pointer to destination buffer */
7575
SK_MAC_ADDR *pMac)	/* Pointer of Source */
7349
SK_MAC_ADDR *pMac)	/* Pointer of Source */
7576
{
7350
{
7577
	int	i;
7351
	int	i;
7578
7352
7579
7580
	for (i = 0; i < sizeof(SK_MAC_ADDR); i ++) {
7353
	for (i = 0; i < sizeof(SK_MAC_ADDR); i ++) {
7581
7354
7582
		*(pDst + i) = pMac->a[i];
7355
		*(pDst + i) = pMac->a[i];
Lines 7616-7632 Link Here
7616
	
7389
	
7617
	SK_U32	RetCode = SK_PNMI_ERR_GENERAL;
7390
	SK_U32	RetCode = SK_PNMI_ERR_GENERAL;
7618
7391
7619
	/*
7392
	/* Check instance. We only handle single instance variables. */
7620
	 * Check instance. We only handle single instance variables
7621
	 */
7622
	if (Instance != (SK_U32)(-1) && Instance != 1) {
7393
	if (Instance != (SK_U32)(-1) && Instance != 1) {
7623
7394
7624
		*pLen = 0;
7395
		*pLen = 0;
7625
		return (SK_PNMI_ERR_UNKNOWN_INST);
7396
		return (SK_PNMI_ERR_UNKNOWN_INST);
7626
	}
7397
	}
7627
	
7398
	
7628
    
7399
    /* Check length. */
7629
    /* Check length */
7630
    switch (Id) {
7400
    switch (Id) {
7631
7401
7632
    case OID_PNP_CAPABILITIES:
7402
    case OID_PNP_CAPABILITIES:
Lines 7664-7677 Link Here
7664
        break;
7434
        break;
7665
    }
7435
    }
7666
	
7436
	
7667
    /*
7437
	/* Perform action. */
7668
	 * Perform action
7669
	 */
7670
	if (Action == SK_PNMI_GET) {
7438
	if (Action == SK_PNMI_GET) {
7671
7439
7672
		/*
7440
		/* Get value. */
7673
		 * Get value
7674
		 */
7675
		switch (Id) {
7441
		switch (Id) {
7676
7442
7677
		case OID_PNP_CAPABILITIES:
7443
		case OID_PNP_CAPABILITIES:
Lines 7679-7696 Link Here
7679
			break;
7445
			break;
7680
7446
7681
		case OID_PNP_QUERY_POWER:
7447
		case OID_PNP_QUERY_POWER:
7682
			/* The Windows DDK describes: An OID_PNP_QUERY_POWER requests
7448
			/*
7683
			 the miniport to indicate whether it can transition its NIC
7449
			 * The Windows DDK describes: An OID_PNP_QUERY_POWER requests
7684
			 to the low-power state.
7450
			 * the miniport to indicate whether it can transition its NIC
7685
			 A miniport driver must always return NDIS_STATUS_SUCCESS
7451
			 * to the low-power state.
7686
			 to a query of OID_PNP_QUERY_POWER. */
7452
			 * A miniport driver must always return NDIS_STATUS_SUCCESS
7453
			 * to a query of OID_PNP_QUERY_POWER.
7454
			 */
7687
			*pLen = sizeof(SK_DEVICE_POWER_STATE);
7455
			*pLen = sizeof(SK_DEVICE_POWER_STATE);
7688
            RetCode = SK_PNMI_ERR_OK;
7456
            RetCode = SK_PNMI_ERR_OK;
7689
			break;
7457
			break;
7690
7458
7691
			/* NDIS handles these OIDs as write-only.
7459
			/*
7460
			 * NDIS handles these OIDs as write-only.
7692
			 * So in case of get action the buffer with written length = 0
7461
			 * So in case of get action the buffer with written length = 0
7693
			 * is returned
7462
			 * is returned.
7694
			 */
7463
			 */
7695
		case OID_PNP_SET_POWER:
7464
		case OID_PNP_SET_POWER:
7696
		case OID_PNP_ADD_WAKE_UP_PATTERN:
7465
		case OID_PNP_ADD_WAKE_UP_PATTERN:
Lines 7711-7723 Link Here
7711
		return (RetCode);
7480
		return (RetCode);
7712
	}
7481
	}
7713
	
7482
	
7714
7483
	/* Perform PRESET or SET. */
7715
	/*
7716
	 * Perform preset or set
7717
	 */
7718
	
7484
	
7719
	/* POWER module does not support PRESET action */
7485
	/* The POWER module does not support PRESET action. */
7720
	if (Action == SK_PNMI_PRESET) {
7486
	if (Action == SK_PNMI_PRESET) {
7487
7721
		return (SK_PNMI_ERR_OK);
7488
		return (SK_PNMI_ERR_OK);
7722
	}
7489
	}
7723
7490
Lines 7749-7755 Link Here
7749
#ifdef SK_DIAG_SUPPORT
7516
#ifdef SK_DIAG_SUPPORT
7750
/*****************************************************************************
7517
/*****************************************************************************
7751
 *
7518
 *
7752
 * DiagActions - OID handler function of Diagnostic driver 
7519
 * DiagActions - OID handler function of Diagnostic driver
7753
 *
7520
 *
7754
 * Description:
7521
 * Description:
7755
 *	The code is simple. No description necessary.
7522
 *	The code is simple. No description necessary.
Lines 7776-7797 Link Here
7776
unsigned int TableIndex, /* Index to the Id table */
7543
unsigned int TableIndex, /* Index to the Id table */
7777
SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode always zero */
7544
SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode always zero */
7778
{
7545
{
7779
7780
	SK_U32	DiagStatus;
7546
	SK_U32	DiagStatus;
7781
	SK_U32	RetCode = SK_PNMI_ERR_GENERAL;
7547
	SK_U32	RetCode = SK_PNMI_ERR_GENERAL;
7782
7548
7783
	/*
7549
	/* Check instance. We only handle single instance variables. */
7784
	 * Check instance. We only handle single instance variables.
7785
	 */
7786
	if (Instance != (SK_U32)(-1) && Instance != 1) {
7550
	if (Instance != (SK_U32)(-1) && Instance != 1) {
7787
7551
7788
		*pLen = 0;
7552
		*pLen = 0;
7789
		return (SK_PNMI_ERR_UNKNOWN_INST);
7553
		return (SK_PNMI_ERR_UNKNOWN_INST);
7790
	}
7554
	}
7791
7555
7792
	/*
7556
    /* Check length. */
7793
	 * Check length.
7794
	 */
7795
	switch (Id) {
7557
	switch (Id) {
7796
7558
7797
	case OID_SKGE_DIAG_MODE:
7559
	case OID_SKGE_DIAG_MODE:
Lines 7809-7818 Link Here
7809
	}
7571
	}
7810
7572
7811
	/* Perform action. */
7573
	/* Perform action. */
7812
7813
	/* GET value. */
7814
	if (Action == SK_PNMI_GET) {
7574
	if (Action == SK_PNMI_GET) {
7815
7575
7576
		/* Get value. */
7816
		switch (Id) {
7577
		switch (Id) {
7817
7578
7818
		case OID_SKGE_DIAG_MODE:
7579
		case OID_SKGE_DIAG_MODE:
Lines 7827-7840 Link Here
7827
			RetCode = SK_PNMI_ERR_GENERAL;
7588
			RetCode = SK_PNMI_ERR_GENERAL;
7828
			break;
7589
			break;
7829
		}
7590
		}
7830
		return (RetCode); 
7591
		return (RetCode);
7831
	}
7592
	}
7832
7593
7833
	/* From here SET or PRESET value. */
7594
	/* From here SET or PRESET value. */
7834
	
7595
	
7835
	/* PRESET value is not supported. */
7596
	/* PRESET value is not supported. */
7836
	if (Action == SK_PNMI_PRESET) {
7597
	if (Action == SK_PNMI_PRESET) {
7837
		return (SK_PNMI_ERR_OK); 
7598
7599
		return (SK_PNMI_ERR_OK);
7838
	}
7600
	}
7839
7601
7840
	/* SET value. */
7602
	/* SET value. */
Lines 7846-7852 Link Here
7846
7608
7847
				/* Attach the DIAG to this adapter. */
7609
				/* Attach the DIAG to this adapter. */
7848
				case SK_DIAG_ATTACHED:
7610
				case SK_DIAG_ATTACHED:
7849
					/* Check if we come from running */
7611
					/* Check if we come from running. */
7850
					if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) {
7612
					if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) {
7851
7613
7852
						RetCode = SkDrvLeaveDiagMode(pAC);
7614
						RetCode = SkDrvLeaveDiagMode(pAC);
Lines 7881-7887 Link Here
7881
						/* If DiagMode is not active, we can enter it. */
7643
						/* If DiagMode is not active, we can enter it. */
7882
						if (!pAC->DiagModeActive) {
7644
						if (!pAC->DiagModeActive) {
7883
7645
7884
							RetCode = SkDrvEnterDiagMode(pAC); 
7646
							RetCode = SkDrvEnterDiagMode(pAC);
7885
						}
7647
						}
7886
						else {
7648
						else {
7887
7649
Lines 7900-7906 Link Here
7900
					break;
7662
					break;
7901
7663
7902
				case SK_DIAG_IDLE:
7664
				case SK_DIAG_IDLE:
7903
					/* Check if we come from running */
7665
					/* Check if we come from running. */
7904
					if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) {
7666
					if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) {
7905
7667
7906
						RetCode = SkDrvLeaveDiagMode(pAC);
7668
						RetCode = SkDrvLeaveDiagMode(pAC);
Lines 7946-7952 Link Here
7946
7708
7947
/*****************************************************************************
7709
/*****************************************************************************
7948
 *
7710
 *
7949
 * Vct - OID handler function of  OIDs
7711
 * Vct - OID handler function of OIDs for Virtual Cable Tester (VCT)
7950
 *
7712
 *
7951
 * Description:
7713
 * Description:
7952
 *	The code is simple. No description necessary.
7714
 *	The code is simple. No description necessary.
Lines 7982-7996 Link Here
7982
	SK_U32		PhysPortIndex;
7744
	SK_U32		PhysPortIndex;
7983
	SK_U32		Limit;
7745
	SK_U32		Limit;
7984
	SK_U32		Offset;
7746
	SK_U32		Offset;
7985
	SK_BOOL		Link;
7747
	SK_U32		RetCode;
7986
	SK_U32		RetCode = SK_PNMI_ERR_GENERAL;
7748
	int			i;
7987
	int		i;
7988
	SK_EVPARA	Para;
7749
	SK_EVPARA	Para;
7989
	SK_U32		CableLength;
7990
	
7750
	
7991
	/*
7751
	RetCode = SK_PNMI_ERR_GENERAL;
7992
	 * Calculate the port indexes from the instance.
7752
	
7993
	 */
7753
	/* Calculate the port indexes from the instance. */
7994
	PhysPortMax = pAC->GIni.GIMacsFound;
7754
	PhysPortMax = pAC->GIni.GIMacsFound;
7995
	LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
7755
	LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
7996
	
7756
	
Lines 8000-8006 Link Here
8000
	}
7760
	}
8001
	
7761
	
8002
	if ((Instance != (SK_U32) (-1))) {
7762
	if ((Instance != (SK_U32) (-1))) {
8003
		/* Check instance range. */
7763
		/*
7764
		 * Get one instance of that OID, so check the instance range:
7765
		 * There is no virtual port with an Instance == 1, so we get
7766
		 * the values from one physical port only.
7767
		 */
8004
		if ((Instance < 2) || (Instance > LogPortMax)) {
7768
		if ((Instance < 2) || (Instance > LogPortMax)) {
8005
			*pLen = 0;
7769
			*pLen = 0;
8006
			return (SK_PNMI_ERR_UNKNOWN_INST);
7770
			return (SK_PNMI_ERR_UNKNOWN_INST);
Lines 8016-8049 Link Here
8016
	}
7780
	}
8017
	else {
7781
	else {
8018
		/*
7782
		/*
8019
		 * Instance == (SK_U32) (-1), get all Instances of that OID.
7783
		 * Instance == (SK_U32) (-1), so get all instances of that OID.
8020
		 *
7784
		 * There is no virtual port with an Instance == 1, so we get
8021
		 * Not implemented yet. May be used in future releases.
7785
		 * the values from all physical ports.
8022
		 */
7786
		 */
8023
		PhysPortIndex = 0;
7787
		PhysPortIndex = 0;
8024
		Limit = PhysPortMax;
7788
		Limit = PhysPortMax;
8025
	}
7789
	}
8026
	
7790
	
8027
	pPrt = &pAC->GIni.GP[PhysPortIndex];
7791
	pPrt = &pAC->GIni.GP[PhysPortIndex];
8028
	if (pPrt->PHWLinkUp) {
8029
		Link = SK_TRUE;
8030
	}
8031
	else {
8032
		Link = SK_FALSE;
8033
	}
8034
	
7792
	
8035
	/* Check MAC type */
7793
	/* Check MAC type. */
8036
	if (pPrt->PhyType != SK_PHY_MARV_COPPER) {
7794
	if ((Id != OID_SKGE_VCT_CAPABILITIES) &&
7795
		(pPrt->PhyType != SK_PHY_MARV_COPPER)) {
8037
		*pLen = 0;
7796
		*pLen = 0;
8038
		return (SK_PNMI_ERR_GENERAL);
7797
		return (SK_PNMI_ERR_NOT_SUPPORTED);
8039
	}
7798
	}
8040
	
7799
	
8041
	/* Initialize backup data pointer. */
7800
	/* Check action type. */
8042
	pVctBackupData = &pAC->Pnmi.VctBackup[PhysPortIndex];
8043
	
8044
	/* Check action type */
8045
	if (Action == SK_PNMI_GET) {
7801
	if (Action == SK_PNMI_GET) {
8046
		/* Check length */
7802
		/* Check length. */
8047
		switch (Id) {
7803
		switch (Id) {
8048
		
7804
		
8049
		case OID_SKGE_VCT_GET:
7805
		case OID_SKGE_VCT_GET:
Lines 8054-8059 Link Here
8054
			break;
7810
			break;
8055
		
7811
		
8056
		case OID_SKGE_VCT_STATUS:
7812
		case OID_SKGE_VCT_STATUS:
7813
		case OID_SKGE_VCT_CAPABILITIES:
8057
			if (*pLen < (Limit - PhysPortIndex) * sizeof(SK_U8)) {
7814
			if (*pLen < (Limit - PhysPortIndex) * sizeof(SK_U8)) {
8058
				*pLen = (Limit - PhysPortIndex) * sizeof(SK_U8);
7815
				*pLen = (Limit - PhysPortIndex) * sizeof(SK_U8);
8059
				return (SK_PNMI_ERR_TOO_SHORT);
7816
				return (SK_PNMI_ERR_TOO_SHORT);
Lines 8065-8134 Link Here
8065
			return (SK_PNMI_ERR_GENERAL);
7822
			return (SK_PNMI_ERR_GENERAL);
8066
		}	
7823
		}	
8067
		
7824
		
8068
		/* Get value */
7825
		/* Get value. */
8069
		Offset = 0;
7826
		Offset = 0;
8070
		for (; PhysPortIndex < Limit; PhysPortIndex++) {
7827
		for (; PhysPortIndex < Limit; PhysPortIndex++) {
7828
			
8071
			switch (Id) {
7829
			switch (Id) {
8072
			
7830
			
8073
			case OID_SKGE_VCT_GET:
7831
			case OID_SKGE_VCT_GET:
8074
				if ((Link == SK_FALSE) &&
7832
				if (!pPrt->PHWLinkUp &&
8075
					(pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_PENDING)) {
7833
					(pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_PENDING)) {
7834
8076
					RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_FALSE);
7835
					RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_FALSE);
7836
					
8077
					if (RetCode == 0) {
7837
					if (RetCode == 0) {
8078
						pAC->Pnmi.VctStatus[PhysPortIndex] &= ~SK_PNMI_VCT_PENDING;
8079
						pAC->Pnmi.VctStatus[PhysPortIndex] |=
8080
							(SK_PNMI_VCT_NEW_VCT_DATA | SK_PNMI_VCT_TEST_DONE);
8081
						
7838
						
8082
						/* Copy results for later use to PNMI struct. */
7839
						/* VCT test is finished, so save the data. */
8083
						for (i = 0; i < 4; i++)  {
7840
						VctGetResults(pAC, IoC, PhysPortIndex);
8084
							if (pPrt->PMdiPairSts[i] == SK_PNMI_VCT_NORMAL_CABLE) {
8085
								if ((pPrt->PMdiPairLen[i] > 35) && (pPrt->PMdiPairLen[i] < 0xff)) {
8086
									pPrt->PMdiPairSts[i] = SK_PNMI_VCT_IMPEDANCE_MISMATCH;
8087
								}
8088
							}
8089
							if ((pPrt->PMdiPairLen[i] > 35) && (pPrt->PMdiPairLen[i] != 0xff)) {
8090
								CableLength = 1000 * (((175 * pPrt->PMdiPairLen[i]) / 210) - 28);
8091
							}
8092
							else {
8093
								CableLength = 0;
8094
							}
8095
							pVctBackupData->PMdiPairLen[i] = CableLength;
8096
							pVctBackupData->PMdiPairSts[i] = pPrt->PMdiPairSts[i];
8097
						}
8098
7841
8099
						Para.Para32[0] = PhysPortIndex;
7842
						Para.Para32[0] = PhysPortIndex;
8100
						Para.Para32[1] = -1;
7843
						Para.Para32[1] = -1;
8101
						SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, Para);
7844
						SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, Para);
8102
						SkEventDispatcher(pAC, IoC);
7845
8103
					}
7846
						/* SkEventDispatcher(pAC, IoC); */
8104
					else {
8105
						; /* VCT test is running. */
8106
					}
7847
					}
8107
				}
7848
				}
8108
				
7849
				
7850
				/* Initialize backup data pointer. */
7851
				pVctBackupData = &pAC->Pnmi.VctBackup[PhysPortIndex];
7852
				
8109
				/* Get all results. */
7853
				/* Get all results. */
8110
				CheckVctStatus(pAC, IoC, pBuf, Offset, PhysPortIndex);
7854
				CheckVctStatus(pAC, IoC, pBuf, Offset, PhysPortIndex);
8111
				Offset += sizeof(SK_U8);
7855
				
7856
				Offset++;
8112
				*(pBuf + Offset) = pPrt->PCableLen;
7857
				*(pBuf + Offset) = pPrt->PCableLen;
8113
				Offset += sizeof(SK_U8);
7858
				Offset++;
8114
				for (i = 0; i < 4; i++)  {
7859
				for (i = 0; i < 4; i++)  {
8115
					SK_PNMI_STORE_U32((pBuf + Offset), pVctBackupData->PMdiPairLen[i]);
7860
7861
					SK_PNMI_STORE_U32((pBuf + Offset), pVctBackupData->MdiPairLen[i]);
8116
					Offset += sizeof(SK_U32);
7862
					Offset += sizeof(SK_U32);
8117
				}
7863
				}
8118
				for (i = 0; i < 4; i++)  {
7864
				for (i = 0; i < 4; i++)  {
8119
					*(pBuf + Offset) = pVctBackupData->PMdiPairSts[i];
7865
8120
					Offset += sizeof(SK_U8);
7866
					*(pBuf + Offset) = pVctBackupData->MdiPairSts[i];
7867
					Offset++;
8121
				}
7868
				}
8122
				
7869
				
8123
				RetCode = SK_PNMI_ERR_OK;
7870
				RetCode = SK_PNMI_ERR_OK;
8124
				break;
7871
				break;
8125
		
7872
8126
			case OID_SKGE_VCT_STATUS:
7873
			case OID_SKGE_VCT_STATUS:
8127
				CheckVctStatus(pAC, IoC, pBuf, Offset, PhysPortIndex);
7874
				CheckVctStatus(pAC, IoC, pBuf, Offset, PhysPortIndex);
8128
				Offset += sizeof(SK_U8);
7875
7876
				Offset++;
8129
				RetCode = SK_PNMI_ERR_OK;
7877
				RetCode = SK_PNMI_ERR_OK;
8130
				break;
7878
				break;
8131
			
7879
7880
			case OID_SKGE_VCT_CAPABILITIES:
7881
				if (pPrt->PhyType != SK_PHY_MARV_COPPER) {
7882
					*(pBuf + Offset) = SK_PNMI_VCT_NOT_SUPPORTED;
7883
				}
7884
				else {
7885
					*(pBuf + Offset) = SK_PNMI_VCT_SUPPORTED;
7886
				}
7887
				Offset++;
7888
7889
				RetCode = SK_PNMI_ERR_OK;
7890
				break;
7891
8132
			default:
7892
			default:
8133
				*pLen = 0;
7893
				*pLen = 0;
8134
				return (SK_PNMI_ERR_GENERAL);
7894
				return (SK_PNMI_ERR_GENERAL);
Lines 8144-8150 Link Here
8144
	 * buffer length is plausible.
7904
	 * buffer length is plausible.
8145
	 */
7905
	 */
8146
	
7906
	
8147
	/* Check length */
7907
	/* Check length. */
8148
	switch (Id) {
7908
	switch (Id) {
8149
	case OID_SKGE_VCT_SET:
7909
	case OID_SKGE_VCT_SET:
8150
		if (*pLen < (Limit - PhysPortIndex) * sizeof(SK_U32)) {
7910
		if (*pLen < (Limit - PhysPortIndex) * sizeof(SK_U32)) {
Lines 8158-8193 Link Here
8158
		return (SK_PNMI_ERR_GENERAL);
7918
		return (SK_PNMI_ERR_GENERAL);
8159
	}
7919
	}
8160
	
7920
	
8161
	/*
7921
	/* Perform PRESET or SET. */
8162
	 * Perform preset or set.
8163
	 */
8164
	
7922
	
8165
	/* VCT does not support PRESET action. */
7923
	/* VCT does not support PRESET action. */
8166
	if (Action == SK_PNMI_PRESET) {
7924
	if (Action == SK_PNMI_PRESET) {
7925
8167
		return (SK_PNMI_ERR_OK);
7926
		return (SK_PNMI_ERR_OK);
8168
	}
7927
	}
8169
	
7928
	
8170
	Offset = 0;
7929
	Offset = 0;
8171
	for (; PhysPortIndex < Limit; PhysPortIndex++) {
7930
	for (; PhysPortIndex < Limit; PhysPortIndex++) {
7931
7932
		pPrt = &pAC->GIni.GP[PhysPortIndex];
7933
8172
		switch (Id) {
7934
		switch (Id) {
8173
		case OID_SKGE_VCT_SET: /* Start VCT test. */
7935
		case OID_SKGE_VCT_SET: /* Start VCT test. */
8174
			if (Link == SK_FALSE) {
7936
			if (!pPrt->PHWLinkUp) {
8175
				SkGeStopPort(pAC, IoC, PhysPortIndex, SK_STOP_ALL, SK_SOFT_RST);
7937
				SkGeStopPort(pAC, IoC, PhysPortIndex, SK_STOP_ALL, SK_SOFT_RST);
8176
				
7938
				
8177
				RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_TRUE);
7939
				RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_TRUE);
7940
				
8178
				if (RetCode == 0) { /* RetCode: 0 => Start! */
7941
				if (RetCode == 0) { /* RetCode: 0 => Start! */
8179
					pAC->Pnmi.VctStatus[PhysPortIndex] |= SK_PNMI_VCT_PENDING;
7942
					pAC->Pnmi.VctStatus[PhysPortIndex] |= SK_PNMI_VCT_PENDING;
8180
					pAC->Pnmi.VctStatus[PhysPortIndex] &= ~SK_PNMI_VCT_NEW_VCT_DATA;
7943
					pAC->Pnmi.VctStatus[PhysPortIndex] &=
8181
					pAC->Pnmi.VctStatus[PhysPortIndex] &= ~SK_PNMI_VCT_LINK;
7944
						~(SK_PNMI_VCT_NEW_VCT_DATA | SK_PNMI_VCT_LINK);
8182
					
7945
					
8183
					/*
7946
					/* Start VCT timer counter. */
8184
					 * Start VCT timer counter.
7947
					SK_MEMSET((char *)&Para, 0, sizeof(Para));
8185
					 */
8186
					SK_MEMSET((char *) &Para, 0, sizeof(Para));
8187
					Para.Para32[0] = PhysPortIndex;
7948
					Para.Para32[0] = PhysPortIndex;
8188
					Para.Para32[1] = -1;
7949
					Para.Para32[1] = -1;
8189
					SkTimerStart(pAC, IoC, &pAC->Pnmi.VctTimeout[PhysPortIndex].VctTimer,
7950
					
8190
						4000000, SKGE_PNMI, SK_PNMI_EVT_VCT_RESET, Para);
7951
					SkTimerStart(pAC, IoC, &pAC->Pnmi.VctTimeout[PhysPortIndex],
7952
						SK_PNMI_VCT_TIMER_CHECK, SKGE_PNMI, SK_PNMI_EVT_VCT_RESET, Para);
7953
					
8191
					SK_PNMI_STORE_U32((pBuf + Offset), RetCode);
7954
					SK_PNMI_STORE_U32((pBuf + Offset), RetCode);
8192
					RetCode = SK_PNMI_ERR_OK;
7955
					RetCode = SK_PNMI_ERR_OK;
8193
				}
7956
				}
Lines 8215-8220 Link Here
8215
} /* Vct */
7978
} /* Vct */
8216
7979
8217
7980
7981
PNMI_STATIC void VctGetResults(
7982
SK_AC		*pAC,
7983
SK_IOC		IoC,
7984
SK_U32		Port)
7985
{
7986
	SK_GEPORT	*pPrt;
7987
	int			i;
7988
	SK_U8		PairLen;
7989
	SK_U8		PairSts;
7990
	SK_U32		MinLength;
7991
	SK_U32		CableLength;
7992
	
7993
	pPrt = &pAC->GIni.GP[Port];
7994
7995
	if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
7996
		MinLength = 25;
7997
	}
7998
	else {
7999
		MinLength = 35;
8000
	}
8001
8002
	/* Copy results for later use to PNMI struct. */
8003
	for (i = 0; i < 4; i++)  {
8004
8005
		PairLen = pPrt->PMdiPairLen[i];
8006
8007
		if (((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS) == 0) && (i > 1)) {
8008
			PairSts = SK_PNMI_VCT_NOT_PRESENT;
8009
		}
8010
		else {
8011
			PairSts = pPrt->PMdiPairSts[i];
8012
		}
8013
8014
		if ((PairSts == SK_PNMI_VCT_NORMAL_CABLE) &&
8015
			(PairLen > 28) && (PairLen < 0xff)) {
8016
8017
			PairSts = SK_PNMI_VCT_IMPEDANCE_MISMATCH;
8018
		}
8019
8020
		/* Ignore values <= MinLength, the linear factor is 4/5. */
8021
		if ((PairLen > MinLength) && (PairLen < 0xff)) {
8022
			
8023
			CableLength = 1000UL * (PairLen - MinLength) * 4 / 5;
8024
		}
8025
		else {
8026
			/* No cable or short cable. */
8027
			CableLength = 0;
8028
		}
8029
8030
		pAC->Pnmi.VctBackup[Port].MdiPairLen[i] = CableLength;
8031
		pAC->Pnmi.VctBackup[Port].MdiPairSts[i] = PairSts;
8032
	}
8033
8034
#if 0
8035
	if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
8036
		CableLength = pAC->Pnmi.VctBackup[Port].MdiPairLen[0];
8037
		pAC->Pnmi.VctBackup[Port].MdiPairLen[0] =
8038
			pAC->Pnmi.VctBackup[Port].MdiPairLen[1];
8039
		pAC->Pnmi.VctBackup[Port].MdiPairLen[1] = CableLength;
8040
		PairSts = pAC->Pnmi.VctBackup[Port].MdiPairSts[0];
8041
		pAC->Pnmi.VctBackup[Port].MdiPairSts[0] =
8042
			pAC->Pnmi.VctBackup[Port].MdiPairSts[1];
8043
		pAC->Pnmi.VctBackup[Port].MdiPairSts[1] = PairSts;
8044
	}
8045
#endif /* 0 */
8046
8047
	pAC->Pnmi.VctStatus[Port] &= ~SK_PNMI_VCT_PENDING;
8048
	pAC->Pnmi.VctStatus[Port] |= (SK_PNMI_VCT_NEW_VCT_DATA |
8049
		SK_PNMI_VCT_TEST_DONE);
8050
8051
} /* GetVctResults */
8052
8218
PNMI_STATIC void CheckVctStatus(
8053
PNMI_STATIC void CheckVctStatus(
8219
SK_AC		*pAC,
8054
SK_AC		*pAC,
8220
SK_IOC		IoC,
8055
SK_IOC		IoC,
Lines 8224-8229 Link Here
8224
{
8059
{
8225
	SK_GEPORT 	*pPrt;
8060
	SK_GEPORT 	*pPrt;
8226
	SK_PNMI_VCT	*pVctData;
8061
	SK_PNMI_VCT	*pVctData;
8062
	SK_U8		VctStatus;
8227
	SK_U32		RetCode;
8063
	SK_U32		RetCode;
8228
	
8064
	
8229
	pPrt = &pAC->GIni.GP[PhysPortIndex];
8065
	pPrt = &pAC->GIni.GP[PhysPortIndex];
Lines 8231-8241 Link Here
8231
	pVctData = (SK_PNMI_VCT *) (pBuf + Offset);
8067
	pVctData = (SK_PNMI_VCT *) (pBuf + Offset);
8232
	pVctData->VctStatus = SK_PNMI_VCT_NONE;
8068
	pVctData->VctStatus = SK_PNMI_VCT_NONE;
8233
	
8069
	
8070
	VctStatus = pAC->Pnmi.VctStatus[PhysPortIndex];
8071
	
8234
	if (!pPrt->PHWLinkUp) {
8072
	if (!pPrt->PHWLinkUp) {
8235
		
8073
		
8236
		/* Was a VCT test ever made before? */
8074
		/* Was a VCT test ever made before? */
8237
		if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_TEST_DONE) {
8075
		if (VctStatus & SK_PNMI_VCT_TEST_DONE) {
8238
			if ((pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_LINK)) {
8076
			if (VctStatus & SK_PNMI_VCT_LINK) {
8239
				pVctData->VctStatus |= SK_PNMI_VCT_OLD_VCT_DATA;
8077
				pVctData->VctStatus |= SK_PNMI_VCT_OLD_VCT_DATA;
8240
			}
8078
			}
8241
			else {
8079
			else {
Lines 8245-8255 Link Here
8245
		
8083
		
8246
		/* Check VCT test status. */
8084
		/* Check VCT test status. */
8247
		RetCode = SkGmCableDiagStatus(pAC,IoC, PhysPortIndex, SK_FALSE);
8085
		RetCode = SkGmCableDiagStatus(pAC,IoC, PhysPortIndex, SK_FALSE);
8086
		
8248
		if (RetCode == 2) { /* VCT test is running. */
8087
		if (RetCode == 2) { /* VCT test is running. */
8249
			pVctData->VctStatus |= SK_PNMI_VCT_RUNNING;
8088
			pVctData->VctStatus |= SK_PNMI_VCT_RUNNING;
8250
		}
8089
		}
8251
		else { /* VCT data was copied to pAC here. Check PENDING state. */
8090
		else { /* VCT data was copied to pAC here. Check PENDING state. */
8252
			if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_PENDING) {
8091
			if (VctStatus & SK_PNMI_VCT_PENDING) {
8253
				pVctData->VctStatus |= SK_PNMI_VCT_NEW_VCT_DATA;
8092
				pVctData->VctStatus |= SK_PNMI_VCT_NEW_VCT_DATA;
8254
			}
8093
			}
8255
		}
8094
		}
Lines 8259-8274 Link Here
8259
		}
8098
		}
8260
	}
8099
	}
8261
	else {
8100
	else {
8262
		
8263
		/* Was a VCT test ever made before? */
8101
		/* Was a VCT test ever made before? */
8264
		if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_TEST_DONE) {
8102
		if (VctStatus & SK_PNMI_VCT_TEST_DONE) {
8265
			pVctData->VctStatus &= ~SK_PNMI_VCT_NEW_VCT_DATA;
8103
			pVctData->VctStatus &= ~SK_PNMI_VCT_NEW_VCT_DATA;
8266
			pVctData->VctStatus |= SK_PNMI_VCT_OLD_VCT_DATA;
8104
			pVctData->VctStatus |= SK_PNMI_VCT_OLD_VCT_DATA;
8267
		}
8105
		}
8268
		
8106
		
8269
		/* DSP only valid in 100/1000 modes. */
8107
		/* DSP only valid in 100/1000 modes. */
8270
		if (pAC->GIni.GP[PhysPortIndex].PLinkSpeedUsed !=
8108
		if (pPrt->PLinkSpeedUsed != SK_LSPEED_STAT_10MBPS) {
8271
			SK_LSPEED_STAT_10MBPS) {	
8272
			pVctData->VctStatus |= SK_PNMI_VCT_NEW_DSP_DATA;
8109
			pVctData->VctStatus |= SK_PNMI_VCT_NEW_DSP_DATA;
8273
		}
8110
		}
8274
	}
8111
	}
Lines 8314-8342 Link Here
8314
	ReturnCode = SK_PNMI_ERR_GENERAL;
8151
	ReturnCode = SK_PNMI_ERR_GENERAL;
8315
	
8152
	
8316
	SK_MEMCPY(&Mode, pBuf, sizeof(SK_I32));
8153
	SK_MEMCPY(&Mode, pBuf, sizeof(SK_I32));
8317
	SK_MEMCPY(&Oid, (char *) pBuf + sizeof(SK_I32), sizeof(SK_U32));
8154
	SK_MEMCPY(&Oid, (char *)pBuf + sizeof(SK_I32), sizeof(SK_U32));
8318
	HeaderLength = sizeof(SK_I32) + sizeof(SK_U32);
8155
	HeaderLength = sizeof(SK_I32) + sizeof(SK_U32);
8319
	*pLen = *pLen - HeaderLength;
8156
	*pLen = *pLen - HeaderLength;
8320
	SK_MEMCPY((char *) pBuf + sizeof(SK_I32), (char *) pBuf + HeaderLength, *pLen);
8157
	SK_MEMCPY((char *)pBuf + sizeof(SK_I32), (char *)pBuf + HeaderLength, *pLen);
8321
	
8158
	
8322
	switch(Mode) {
8159
	switch(Mode) {
8323
	case SK_GET_SINGLE_VAR:
8160
	case SK_GET_SINGLE_VAR:
8324
		ReturnCode = SkPnmiGetVar(pAC, IoC, Oid, 
8161
		ReturnCode = SkPnmiGetVar(pAC, IoC, Oid,
8325
				(char *) pBuf + sizeof(SK_I32), pLen,
8162
				(char *)pBuf + sizeof(SK_I32), pLen,
8326
				((SK_U32) (-1)), NetIndex);
8163
				((SK_U32) (-1)), NetIndex);
8327
		SK_PNMI_STORE_U32(pBuf, ReturnCode);
8164
		SK_PNMI_STORE_U32(pBuf, ReturnCode);
8328
		*pLen = *pLen + sizeof(SK_I32);
8165
		*pLen = *pLen + sizeof(SK_I32);
8329
		break;
8166
		break;
8330
	case SK_PRESET_SINGLE_VAR:
8167
	case SK_PRESET_SINGLE_VAR:
8331
		ReturnCode = SkPnmiPreSetVar(pAC, IoC, Oid, 
8168
		ReturnCode = SkPnmiPreSetVar(pAC, IoC, Oid,
8332
				(char *) pBuf + sizeof(SK_I32), pLen,
8169
				(char *)pBuf + sizeof(SK_I32), pLen,
8333
				((SK_U32) (-1)), NetIndex);
8170
				((SK_U32) (-1)), NetIndex);
8334
		SK_PNMI_STORE_U32(pBuf, ReturnCode);
8171
		SK_PNMI_STORE_U32(pBuf, ReturnCode);
8335
		*pLen = *pLen + sizeof(SK_I32);
8172
		*pLen = *pLen + sizeof(SK_I32);
8336
		break;
8173
		break;
8337
	case SK_SET_SINGLE_VAR:
8174
	case SK_SET_SINGLE_VAR:
8338
		ReturnCode = SkPnmiSetVar(pAC, IoC, Oid, 
8175
		ReturnCode = SkPnmiSetVar(pAC, IoC, Oid,
8339
				(char *) pBuf + sizeof(SK_I32), pLen,
8176
				(char *)pBuf + sizeof(SK_I32), pLen,
8340
				((SK_U32) (-1)), NetIndex);
8177
				((SK_U32) (-1)), NetIndex);
8341
		SK_PNMI_STORE_U32(pBuf, ReturnCode);
8178
		SK_PNMI_STORE_U32(pBuf, ReturnCode);
8342
		*pLen = *pLen + sizeof(SK_I32);
8179
		*pLen = *pLen + sizeof(SK_I32);
Lines 8357-8359 Link Here
8357
	return (ReturnCode);
8194
	return (ReturnCode);
8358
8195
8359
} /* SkGeIocGen */
8196
} /* SkGeIocGen */
8197
8198
#ifdef SK_ASF
8199
/*****************************************************************************
8200
 *
8201
 * Asf
8202
 *
8203
 * Description:
8204
 *  The code is simple. No description necessary.
8205
 *
8206
 * Returns:
8207
 *  SK_PNMI_ERR_OK           The request was successfully performed.
8208
 *  SK_PNMI_ERR_GENERAL      A general severe internal error occured.
8209
 *  SK_PNMI_ERR_TOO_SHORT    The passed buffer is too short to contain
8210
 *                           the correct data (e.g. a 32bit value is
8211
 *                           needed, but a 16 bit value was passed).
8212
 *  SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
8213
 *                           exist (e.g. port instance 3 on a two port
8214
 *                           adapter.
8215
 */
8216
8217
PNMI_STATIC int Asf(
8218
SK_AC *pAC,     /* Pointer to adapter context */
8219
SK_IOC IoC,     /* IO context handle */
8220
int Action,     /* GET/PRESET/SET action */
8221
SK_U32 Id,      /* Object ID that is to be processed */
8222
char *pBuf,     /* Buffer used for the management data transfer */
8223
unsigned int *pLen, /* On call: pBuf buffer length. On return: used buffer */
8224
SK_U32 Instance,    /* Instance (1..n) that is to be queried or -1 */
8225
unsigned int TableIndex, /* Index to the Id table */
8226
SK_U32 NetIndex)    /* NetIndex (0..n), in single net mode always zero */
8227
{
8228
    SK_U32  RetCode = SK_PNMI_ERR_GENERAL;
8229
8230
    /*
8231
     * Check instance. We only handle single instance variables.
8232
     */
8233
    if (Instance != (SK_U32)(-1) && Instance != 1) {
8234
8235
        *pLen = 0;
8236
        return (SK_PNMI_ERR_UNKNOWN_INST);
8237
    }
8238
8239
    /* Perform action. */
8240
    /* GET value. */
8241
    if (Action == SK_PNMI_GET) {
8242
        switch (Id) {
8243
            case OID_SKGE_ASF:  
8244
                RetCode = SkAsfGet(pAC, IoC, (SK_U8 *) pBuf, pLen);
8245
                break;
8246
            default:
8247
                RetCode = SkAsfGetOid( pAC, IoC, Id, Instance, (SK_U8 *) pBuf, pLen );
8248
                break;
8249
        }
8250
8251
        return (RetCode); 
8252
    }
8253
8254
    /* PRESET value. */
8255
    if (Action == SK_PNMI_PRESET) { 
8256
        switch (Id) {
8257
            case OID_SKGE_ASF:
8258
                RetCode = SkAsfPreSet(pAC, IoC, (SK_U8 *) pBuf, pLen);
8259
                break;
8260
            default:
8261
                RetCode = SkAsfPreSetOid( pAC, IoC, Id, Instance, (SK_U8 *) pBuf, pLen );
8262
                break;
8263
        }
8264
    }
8265
8266
    /* SET value. */
8267
    if (Action == SK_PNMI_SET) {
8268
        switch (Id) {
8269
            case OID_SKGE_ASF:
8270
                RetCode = SkAsfSet(pAC, IoC, (SK_U8 *) pBuf, pLen);
8271
                break;
8272
            default:
8273
                RetCode = SkAsfSetOid( pAC, IoC, Id, Instance, (SK_U8 *) pBuf, pLen );
8274
                break;
8275
        }
8276
    }
8277
    return (RetCode);
8278
}
8279
#endif /* SK_ASF */
(-)linux/drivers/net/sk98lin/skgesirq.c (-464 / +780 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skgesirq.c
3
 * Name:	skgesirq.c
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.92 $
5
 * Version:	$Revision: 2.21 $
6
 * Date:	$Date: 2003/09/16 14:37:07 $
6
 * Date:	$Date: 2005/03/03 15:49:58 $
7
 * Purpose:	Special IRQ module
7
 * Purpose:	Special IRQ module
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-23 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2005 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
22
 *
21
 *
23
 ******************************************************************************/
22
 ******************************************************************************/
Lines 38-44 Link Here
38
 *	right after this ISR.
37
 *	right after this ISR.
39
 *
38
 *
40
 *	The Interrupt source register of the adapter is NOT read by this module.
39
 *	The Interrupt source register of the adapter is NOT read by this module.
41
 *  SO if the drivers implementor needs a while loop around the
40
 *	SO if the drivers implementor needs a while loop around the
42
 *	slow data paths interrupt bits, he needs to call the SkGeSirqIsr() for
41
 *	slow data paths interrupt bits, he needs to call the SkGeSirqIsr() for
43
 *	each loop entered.
42
 *	each loop entered.
44
 *
43
 *
Lines 46-56 Link Here
46
 *
45
 *
47
 */
46
 */
48
47
49
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
50
static const char SysKonnectFileId[] =
51
	"@(#) $Id: skgesirq.c,v 1.92 2003/09/16 14:37:07 rschmidt Exp $ (C) Marvell.";
52
#endif
53
54
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
48
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
55
#ifndef SK_SLIM
49
#ifndef SK_SLIM
56
#include "h/skgepnmi.h"		/* PNMI Definitions */
50
#include "h/skgepnmi.h"		/* PNMI Definitions */
Lines 58-63 Link Here
58
#endif
52
#endif
59
#include "h/skdrv2nd.h"		/* Adapter Control and Driver specific Def. */
53
#include "h/skdrv2nd.h"		/* Adapter Control and Driver specific Def. */
60
54
55
/* local variables ************************************************************/
56
57
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
58
static const char SysKonnectFileId[] =
59
	"@(#) $Id: skgesirq.c,v 2.21 2005/03/03 15:49:58 rschmidt Exp $ (C) Marvell.";
60
#endif
61
61
/* local function prototypes */
62
/* local function prototypes */
62
#ifdef GENESIS
63
#ifdef GENESIS
63
static int	SkGePortCheckUpXmac(SK_AC*, SK_IOC, int, SK_BOOL);
64
static int	SkGePortCheckUpXmac(SK_AC*, SK_IOC, int, SK_BOOL);
Lines 86-92 Link Here
86
	XM_RXF_511B,
87
	XM_RXF_511B,
87
	XM_RXF_1023B,
88
	XM_RXF_1023B,
88
	XM_RXF_MAX_SZ
89
	XM_RXF_MAX_SZ
89
} ;
90
};
90
#endif /* GENESIS */
91
#endif /* GENESIS */
91
92
92
#ifdef __C2MAN__
93
#ifdef __C2MAN__
Lines 109-116 Link Here
109
 * Returns: N/A
110
 * Returns: N/A
110
 */
111
 */
111
static void SkHWInitDefSense(
112
static void SkHWInitDefSense(
112
SK_AC	*pAC,	/* adapter context */
113
SK_AC	*pAC,	/* Adapter Context */
113
SK_IOC	IoC,	/* IO context */
114
SK_IOC	IoC,	/* I/O context */
114
int		Port)	/* Port Index (MAC_1 + n) */
115
int		Port)	/* Port Index (MAC_1 + n) */
115
{
116
{
116
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
117
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
Lines 119-125 Link Here
119
120
120
	pPrt->PAutoNegTimeOut = 0;
121
	pPrt->PAutoNegTimeOut = 0;
121
122
122
	if (pPrt->PLinkModeConf != SK_LMODE_AUTOSENSE) {
123
	if (pPrt->PLinkModeConf != (SK_U8)SK_LMODE_AUTOSENSE) {
123
		pPrt->PLinkMode = pPrt->PLinkModeConf;
124
		pPrt->PLinkMode = pPrt->PLinkModeConf;
124
		return;
125
		return;
125
	}
126
	}
Lines 145-152 Link Here
145
 *
146
 *
146
 */
147
 */
147
static SK_U8 SkHWSenseGetNext(
148
static SK_U8 SkHWSenseGetNext(
148
SK_AC	*pAC,	/* adapter context */
149
SK_AC	*pAC,	/* Adapter Context */
149
SK_IOC	IoC,	/* IO context */
150
SK_IOC	IoC,	/* I/O context */
150
int		Port)	/* Port Index (MAC_1 + n) */
151
int		Port)	/* Port Index (MAC_1 + n) */
151
{
152
{
152
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
153
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
Lines 155-172 Link Here
155
156
156
	pPrt->PAutoNegTimeOut = 0;
157
	pPrt->PAutoNegTimeOut = 0;
157
158
158
    if (pPrt->PLinkModeConf != (SK_U8)SK_LMODE_AUTOSENSE) {
159
	if (pPrt->PLinkModeConf != (SK_U8)SK_LMODE_AUTOSENSE) {
159
		/* Leave all as configured */
160
		/* Leave all as configured */
160
		return(pPrt->PLinkModeConf);
161
		return(pPrt->PLinkModeConf);
161
	}
162
	}
162
163
163
    if (pPrt->PLinkMode == (SK_U8)SK_LMODE_AUTOFULL) {
164
	if (pPrt->PLinkMode == (SK_U8)SK_LMODE_AUTOFULL) {
164
		/* Return next mode AUTOBOTH */
165
		/* Return next mode AUTOBOTH */
165
        return ((SK_U8)SK_LMODE_AUTOBOTH);
166
		return((SK_U8)SK_LMODE_AUTOBOTH);
166
	}
167
	}
167
168
168
	/* Return default autofull */
169
	/* Return default autofull */
169
    return ((SK_U8)SK_LMODE_AUTOFULL);
170
	return((SK_U8)SK_LMODE_AUTOFULL);
170
}	/* SkHWSenseGetNext */
171
}	/* SkHWSenseGetNext */
171
172
172
173
Lines 179-186 Link Here
179
 * Returns: N/A
180
 * Returns: N/A
180
 */
181
 */
181
static void SkHWSenseSetNext(
182
static void SkHWSenseSetNext(
182
SK_AC	*pAC,		/* adapter context */
183
SK_AC	*pAC,		/* Adapter Context */
183
SK_IOC	IoC,		/* IO context */
184
SK_IOC	IoC,		/* I/O context */
184
int		Port,		/* Port Index (MAC_1 + n) */
185
int		Port,		/* Port Index (MAC_1 + n) */
185
SK_U8	NewMode)	/* New Mode to be written in sense mode */
186
SK_U8	NewMode)	/* New Mode to be written in sense mode */
186
{
187
{
Lines 190-196 Link Here
190
191
191
	pPrt->PAutoNegTimeOut = 0;
192
	pPrt->PAutoNegTimeOut = 0;
192
193
193
    if (pPrt->PLinkModeConf != (SK_U8)SK_LMODE_AUTOSENSE) {
194
	if (pPrt->PLinkModeConf != (SK_U8)SK_LMODE_AUTOSENSE) {
194
		return;
195
		return;
195
	}
196
	}
196
197
Lines 214-221 Link Here
214
 * Returns: N/A
215
 * Returns: N/A
215
 */
216
 */
216
void SkHWLinkDown(
217
void SkHWLinkDown(
217
SK_AC	*pAC,		/* adapter context */
218
SK_AC	*pAC,		/* Adapter Context */
218
SK_IOC	IoC,		/* IO context */
219
SK_IOC	IoC,		/* I/O context */
219
int		Port)		/* Port Index (MAC_1 + n) */
220
int		Port)		/* Port Index (MAC_1 + n) */
220
{
221
{
221
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
222
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
Lines 227-237 Link Here
227
228
228
	/* Disable Receiver and Transmitter */
229
	/* Disable Receiver and Transmitter */
229
	SkMacRxTxDisable(pAC, IoC, Port);
230
	SkMacRxTxDisable(pAC, IoC, Port);
230
	
231
231
	/* Init default sense mode */
232
	/* Init default sense mode */
232
	SkHWInitDefSense(pAC, IoC, Port);
233
	SkHWInitDefSense(pAC, IoC, Port);
233
234
234
	if (pPrt->PHWLinkUp == SK_FALSE) {
235
	if (!pPrt->PHWLinkUp) {
235
		return;
236
		return;
236
	}
237
	}
237
238
Lines 242-249 Link Here
242
	pPrt->PHWLinkUp = SK_FALSE;
243
	pPrt->PHWLinkUp = SK_FALSE;
243
244
244
	/* Reset Port stati */
245
	/* Reset Port stati */
245
    pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;
246
	pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;
246
    pPrt->PFlowCtrlStatus = (SK_U8)SK_FLOW_STAT_NONE;
247
	pPrt->PFlowCtrlStatus = (SK_U8)SK_FLOW_STAT_NONE;
247
	pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_INDETERMINATED;
248
	pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_INDETERMINATED;
248
249
249
	/* Re-init Phy especially when the AutoSense default is set now */
250
	/* Re-init Phy especially when the AutoSense default is set now */
Lines 266-273 Link Here
266
 * Returns: N/A
267
 * Returns: N/A
267
 */
268
 */
268
void SkHWLinkUp(
269
void SkHWLinkUp(
269
SK_AC	*pAC,	/* adapter context */
270
SK_AC	*pAC,	/* Adapter Context */
270
SK_IOC	IoC,	/* IO context */
271
SK_IOC	IoC,	/* I/O context */
271
int		Port)	/* Port Index (MAC_1 + n) */
272
int		Port)	/* Port Index (MAC_1 + n) */
272
{
273
{
273
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
274
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
Lines 281-291 Link Here
281
282
282
	pPrt->PHWLinkUp = SK_TRUE;
283
	pPrt->PHWLinkUp = SK_TRUE;
283
	pPrt->PAutoNegFail = SK_FALSE;
284
	pPrt->PAutoNegFail = SK_FALSE;
284
    pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;
285
	pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;
285
286
286
    if (pPrt->PLinkMode != (SK_U8)SK_LMODE_AUTOHALF &&
287
	if (pPrt->PLinkMode != (SK_U8)SK_LMODE_AUTOHALF &&
287
        pPrt->PLinkMode != (SK_U8)SK_LMODE_AUTOFULL &&
288
		pPrt->PLinkMode != (SK_U8)SK_LMODE_AUTOFULL &&
288
        pPrt->PLinkMode != (SK_U8)SK_LMODE_AUTOBOTH) {
289
		pPrt->PLinkMode != (SK_U8)SK_LMODE_AUTOBOTH) {
289
		/* Link is up and no Auto-negotiation should be done */
290
		/* Link is up and no Auto-negotiation should be done */
290
291
291
		/* Link speed should be the configured one */
292
		/* Link speed should be the configured one */
Lines 304-321 Link Here
304
		}
305
		}
305
306
306
		/* Set Link Mode Status */
307
		/* Set Link Mode Status */
307
		if (pPrt->PLinkMode == SK_LMODE_FULL) {
308
		if (pPrt->PLinkMode == (SK_U8)SK_LMODE_FULL) {
308
			pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_FULL;
309
			pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_FULL;
309
		}
310
		}
310
		else {
311
		else {
311
            pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_HALF;
312
			pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_HALF;
312
		}
313
		}
313
314
314
		/* No flow control without auto-negotiation */
315
		/* No flow control without auto-negotiation */
315
        pPrt->PFlowCtrlStatus = (SK_U8)SK_FLOW_STAT_NONE;
316
		pPrt->PFlowCtrlStatus = (SK_U8)SK_FLOW_STAT_NONE;
316
317
317
		/* enable Rx/Tx */
318
		/* enable Rx/Tx */
318
        (void)SkMacRxTxEnable(pAC, IoC, Port);
319
		(void)SkMacRxTxEnable(pAC, IoC, Port);
319
	}
320
	}
320
}	/* SkHWLinkUp */
321
}	/* SkHWLinkUp */
321
322
Lines 329-342 Link Here
329
 * Returns: N/A
330
 * Returns: N/A
330
 */
331
 */
331
static void SkMacParity(
332
static void SkMacParity(
332
SK_AC	*pAC,	/* adapter context */
333
SK_AC	*pAC,	/* Adapter Context */
333
SK_IOC	IoC,	/* IO context */
334
SK_IOC	IoC,	/* I/O context */
334
int		Port)	/* Port Index of the port failed */
335
int		Port)	/* Port Index (MAC_1 + n) */
335
{
336
{
336
	SK_EVPARA	Para;
337
	SK_EVPARA	Para;
337
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
338
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
338
	SK_U32		TxMax;		/* Tx Max Size Counter */
339
	SK_U32		TxMax;		/* Tx Max Size Counter */
339
340
341
	TxMax = 0;
342
340
	pPrt = &pAC->GIni.GP[Port];
343
	pPrt = &pAC->GIni.GP[Port];
341
344
342
	/* Clear IRQ Tx Parity Error */
345
	/* Clear IRQ Tx Parity Error */
Lines 355-361 Link Here
355
			pAC->GIni.GIChipRev == 0) ? GMF_CLI_TX_FC : GMF_CLI_TX_PE));
358
			pAC->GIni.GIChipRev == 0) ? GMF_CLI_TX_FC : GMF_CLI_TX_PE));
356
	}
359
	}
357
#endif /* YUKON */
360
#endif /* YUKON */
358
	
361
359
	if (pPrt->PCheckPar) {
362
	if (pPrt->PCheckPar) {
360
363
361
		if (Port == MAC_1) {
364
		if (Port == MAC_1) {
Lines 366-372 Link Here
366
		}
369
		}
367
		Para.Para64 = Port;
370
		Para.Para64 = Port;
368
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
371
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
369
		
372
370
		Para.Para32[0] = Port;
373
		Para.Para32[0] = Port;
371
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
374
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
372
375
Lines 378-384 Link Here
378
	if (pAC->GIni.GIGenesis) {
381
	if (pAC->GIni.GIGenesis) {
379
		/* Snap statistic counters */
382
		/* Snap statistic counters */
380
		(void)SkXmUpdateStats(pAC, IoC, Port);
383
		(void)SkXmUpdateStats(pAC, IoC, Port);
381
		
384
382
		(void)SkXmMacStatistic(pAC, IoC, Port, XM_TXF_MAX_SZ, &TxMax);
385
		(void)SkXmMacStatistic(pAC, IoC, Port, XM_TXF_MAX_SZ, &TxMax);
383
	}
386
	}
384
#endif /* GENESIS */
387
#endif /* GENESIS */
Lines 399-413 Link Here
399
402
400
/******************************************************************************
403
/******************************************************************************
401
 *
404
 *
402
 *	SkGeHwErr() - Hardware Error service routine
405
 *	SkGeYuHwErr() - Hardware Error service routine (Genesis and Yukon)
403
 *
406
 *
404
 * Description: handles all HW Error interrupts
407
 * Description: handles all HW Error interrupts
405
 *
408
 *
406
 * Returns: N/A
409
 * Returns: N/A
407
 */
410
 */
408
static void SkGeHwErr(
411
static void SkGeYuHwErr(
409
SK_AC	*pAC,		/* adapter context */
412
SK_AC	*pAC,		/* Adapter Context */
410
SK_IOC	IoC,		/* IO context */
413
SK_IOC	IoC,		/* I/O context */
411
SK_U32	HwStatus)	/* Interrupt status word */
414
SK_U32	HwStatus)	/* Interrupt status word */
412
{
415
{
413
	SK_EVPARA	Para;
416
	SK_EVPARA	Para;
Lines 423-432 Link Here
423
		}
426
		}
424
427
425
		/* Reset all bits in the PCI STATUS register */
428
		/* Reset all bits in the PCI STATUS register */
426
		SK_IN16(IoC, PCI_C(PCI_STATUS), &Word);
429
		SK_IN16(IoC, PCI_C(pAC, PCI_STATUS), &Word);
427
		
430
428
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
431
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
429
        SK_OUT16(IoC, PCI_C(PCI_STATUS), (SK_U16)(Word | PCI_ERRBITS));
432
		SK_OUT16(IoC, PCI_C(pAC, PCI_STATUS), (SK_U16)(Word | PCI_ERRBITS));
430
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
433
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
431
434
432
		Para.Para64 = 0;
435
		Para.Para64 = 0;
Lines 484-497 Link Here
484
#endif /* YUKON */
487
#endif /* YUKON */
485
488
486
	if ((HwStatus & IS_RAM_RD_PAR) != 0) {
489
	if ((HwStatus & IS_RAM_RD_PAR) != 0) {
490
487
		SK_OUT16(IoC, B3_RI_CTRL, RI_CLR_RD_PERR);
491
		SK_OUT16(IoC, B3_RI_CTRL, RI_CLR_RD_PERR);
492
488
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E014, SKERR_SIRQ_E014MSG);
493
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E014, SKERR_SIRQ_E014MSG);
489
		Para.Para64 = 0;
494
		Para.Para64 = 0;
490
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_ADAP_FAIL, Para);
495
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_ADAP_FAIL, Para);
491
	}
496
	}
492
497
493
	if ((HwStatus & IS_RAM_WR_PAR) != 0) {
498
	if ((HwStatus & IS_RAM_WR_PAR) != 0) {
499
494
		SK_OUT16(IoC, B3_RI_CTRL, RI_CLR_WR_PERR);
500
		SK_OUT16(IoC, B3_RI_CTRL, RI_CLR_WR_PERR);
501
495
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E015, SKERR_SIRQ_E015MSG);
502
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E015, SKERR_SIRQ_E015MSG);
496
		Para.Para64 = 0;
503
		Para.Para64 = 0;
497
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_ADAP_FAIL, Para);
504
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_ADAP_FAIL, Para);
Lines 512-518 Link Here
512
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E018, SKERR_SIRQ_E018MSG);
519
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E018, SKERR_SIRQ_E018MSG);
513
		Para.Para64 = MAC_1;
520
		Para.Para64 = MAC_1;
514
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
521
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
515
		
522
516
		Para.Para32[0] = MAC_1;
523
		Para.Para32[0] = MAC_1;
517
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
524
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
518
	}
525
	}
Lines 524-560 Link Here
524
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E019, SKERR_SIRQ_E019MSG);
531
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E019, SKERR_SIRQ_E019MSG);
525
		Para.Para64 = MAC_2;
532
		Para.Para64 = MAC_2;
526
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
533
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
527
		
534
528
		Para.Para32[0] = MAC_2;
535
		Para.Para32[0] = MAC_2;
529
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
536
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
530
	}
537
	}
531
}	/* SkGeHwErr */
538
}	/* SkGeYuHwErr */
539
540
#ifdef YUK2
541
/******************************************************************************
542
 *
543
 *	SkYuk2HwPortErr() - Service HW Errors for specified port (Yukon-2 only)
544
 *
545
 * Description: handles the HW Error interrupts for a specific port.
546
 *
547
 * Returns: N/A
548
 */
549
static void SkYuk2HwPortErr(
550
SK_AC	*pAC,		/* Adapter Context */
551
SK_IOC	IoC,		/* I/O Context */
552
SK_U32	HwStatus,	/* Interrupt status word */
553
int		Port)		/* Port Index (MAC_1 + n) */
554
{
555
	SK_EVPARA	Para;
556
	int			Queue;
557
558
	if (Port == MAC_2) {
559
		HwStatus >>= 8;
560
	}
561
562
	if ((HwStatus & Y2_HWE_L1_MASK) == 0) {
563
		return;
564
	}
565
566
	if ((HwStatus & Y2_IS_PAR_RD1) != 0) {
567
		/* Clear IRQ */
568
		SK_OUT16(IoC, SELECT_RAM_BUFFER(Port, B3_RI_CTRL), RI_CLR_RD_PERR);
569
570
		if (Port == MAC_1) {
571
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E028, SKERR_SIRQ_E028MSG);
572
		}
573
		else {
574
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E030, SKERR_SIRQ_E030MSG);
575
		}
576
	}
577
578
	if ((HwStatus & Y2_IS_PAR_WR1) != 0) {
579
		/* Clear IRQ */
580
		SK_OUT16(IoC, SELECT_RAM_BUFFER(Port, B3_RI_CTRL), RI_CLR_WR_PERR);
532
581
582
		if (Port == MAC_1) {
583
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E029, SKERR_SIRQ_E029MSG);
584
		}
585
		else {
586
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E031, SKERR_SIRQ_E031MSG);
587
		}
588
	}
589
590
	if ((HwStatus & Y2_IS_PAR_MAC1) != 0) {
591
		/* Clear IRQ */
592
		SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), GMF_CLI_TX_PE);
593
594
		if (Port == MAC_1) {
595
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E016, SKERR_SIRQ_E016MSG);
596
		}
597
		else {
598
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E017, SKERR_SIRQ_E017MSG);
599
		}
600
	}
601
602
	if ((HwStatus & Y2_IS_PAR_RX1) != 0) {
603
		if (Port == MAC_1) {
604
			Queue = Q_R1;
605
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E018, SKERR_SIRQ_E018MSG);
606
		}
607
		else {
608
			Queue = Q_R2;
609
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E019, SKERR_SIRQ_E019MSG);
610
		}
611
		/* Clear IRQ */
612
		SK_OUT32(IoC, Q_ADDR(Queue, Q_CSR), BMU_CLR_IRQ_PAR);
613
	}
614
615
	if ((HwStatus & Y2_IS_TCP_TXS1) != 0) {
616
		if (Port == MAC_1) {
617
			Queue = Q_XS1;
618
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E033, SKERR_SIRQ_E033MSG);
619
		}
620
		else {
621
			Queue = Q_XS2;
622
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E035, SKERR_SIRQ_E035MSG);
623
		}
624
		/* Clear IRQ */
625
		SK_OUT32(IoC, Q_ADDR(Queue, Q_CSR), BMU_CLR_IRQ_TCP);
626
	}
627
628
	if ((HwStatus & Y2_IS_TCP_TXA1) != 0) {
629
		if (Port == MAC_1) {
630
			Queue = Q_XA1;
631
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E032, SKERR_SIRQ_E032MSG);
632
		}
633
		else {
634
			Queue = Q_XA2;
635
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E034, SKERR_SIRQ_E034MSG);
636
		}
637
		/* Clear IRQ */
638
		SK_OUT32(IoC, Q_ADDR(Queue, Q_CSR), BMU_CLR_IRQ_TCP);
639
	}
640
641
	Para.Para64 = Port;
642
	SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
643
644
	Para.Para32[0] = Port;
645
	SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
646
647
}	/* SkYuk2HwPortErr */
533
648
534
/******************************************************************************
649
/******************************************************************************
535
 *
650
 *
536
 *	SkGeSirqIsr() - Special Interrupt Service Routine
651
 *	SkYuk2HwErr() - Hardware Error service routine (Yukon-2 only)
537
 *
652
 *
538
 * Description: handles all non data transfer specific interrupts (slow path)
653
 * Description: handles all HW Error interrupts
654
 *
655
 * Returns: N/A
656
 */
657
static void SkYuk2HwErr(
658
SK_AC	*pAC,		/* Adapter Context */
659
SK_IOC	IoC,		/* I/O Context */
660
SK_U32	HwStatus)	/* Interrupt status word */
661
{
662
	SK_EVPARA	Para;
663
	SK_U16		Word;
664
	SK_U32		DWord;
665
	SK_U32		TlpHead[4];
666
	int			i;
667
668
	/* This is necessary only for Rx timing measurements */
669
	if ((HwStatus & Y2_IS_TIST_OV) != 0) {
670
		/* increment Time Stamp Timer counter (high) */
671
		pAC->GIni.GITimeStampCnt++;
672
673
		/* Clear Time Stamp Timer IRQ */
674
		SK_OUT8(IoC, GMAC_TI_ST_CTRL, (SK_U8)GMT_ST_CLR_IRQ);
675
	}
676
677
	/* Evaluate Y2_IS_PCI_NEXP before Y2_IS_MST_ERR or Y2_IS_IRQ_STAT */
678
	if ((HwStatus & Y2_IS_PCI_NEXP) != 0) {
679
		/* PCI-Express Error occured which is not described in PEX spec. */
680
		/*
681
		 * This error is also mapped either to Master Abort (Y2_IS_MST_ERR)
682
		 * or Target Abort (Y2_IS_IRQ_STAT) bit and can only be cleared there.
683
		 * Therefore handle this event just by printing an error log entry.
684
		 */
685
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E027, SKERR_SIRQ_E027MSG);
686
	}
687
688
	if ((HwStatus & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) != 0) {
689
		/* PCI Errors occured */
690
		if ((HwStatus & Y2_IS_IRQ_STAT) != 0) {
691
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E013, SKERR_SIRQ_E013MSG);
692
		}
693
		else {
694
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E012, SKERR_SIRQ_E012MSG);
695
		}
696
697
		/* Reset all bits in the PCI STATUS register */
698
		SK_IN16(IoC, PCI_C(pAC, PCI_STATUS), &Word);
699
700
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
701
		SK_OUT16(IoC, PCI_C(pAC, PCI_STATUS), (SK_U16)(Word | PCI_ERRBITS));
702
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
703
704
		Para.Para64 = 0;
705
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_ADAP_FAIL, Para);
706
	}
707
708
	/* check for PCI-Express Uncorrectable Error*/
709
	if ((HwStatus & Y2_IS_PCI_EXP) != 0) {
710
		/*
711
		 * On PCI-Express bus bridges are called root complexes (RC).
712
		 * PCI-Express errors are recognized by the root complex too,
713
		 * which requests the system to handle the problem. After error
714
		 * occurence it may be that no access to the adapter may be performed
715
		 * any longer.
716
		 */
717
718
		/* Get uncorrectable error status */
719
		SK_IN32(IoC, PCI_C(pAC, PEX_UNC_ERR_STAT), &DWord);
720
721
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
722
			("PEX Uncorr.Error Status: 0x%08lX\n", DWord));
723
724
		if (DWord != PEX_UNSUP_REQ) {
725
			/* ignore Unsupported Request Errors */
726
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E026, SKERR_SIRQ_E026MSG);
727
		}
728
729
		if ((DWord & (PEX_FATAL_ERRORS | PEX_POIS_TLP)) != 0) {
730
			/*
731
			 * Stop only, if the uncorrectable error is fatal or
732
			 * Poisoned TLP occured
733
			 */
734
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ, ("Header Log:"));
735
736
			for (i = 0; i < 4; i++) {
737
				/* get TLP Header from Log Registers */
738
				SK_IN32(IoC, PCI_C(pAC, PEX_HEADER_LOG + i*4), TlpHead + i);
739
740
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
741
					(" 0x%08lX", TlpHead[i]));
742
			}
743
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ, ("\n"));
744
745
			/* check for vendor defined broadcast message */
746
			if (TlpHead[0] == 0x73004001 && (SK_U8)TlpHead[1] == 0x7f) {
747
748
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
749
					("Vendor defined broadcast message\n"));
750
			}
751
			else {
752
				Para.Para64 = 0;
753
				SkEventQueue(pAC, SKGE_DRV, SK_DRV_ADAP_FAIL, Para);
754
755
				pAC->GIni.GIValHwIrqMask &= ~Y2_IS_PCI_EXP;
756
				/* Rewrite HW IRQ mask */
757
				SK_OUT32(IoC, B0_HWE_IMSK, pAC->GIni.GIValHwIrqMask);
758
			}
759
		}
760
		/* clear the interrupt */
761
		SK_OUT32(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
762
		SK_OUT32(IoC, PCI_C(pAC, PEX_UNC_ERR_STAT), 0xffffffffUL);
763
		SK_OUT32(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
764
	}
765
766
	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
767
768
		SkYuk2HwPortErr(pAC, IoC, HwStatus, i);
769
	}
770
771
}	/* SkYuk2HwErr */
772
#endif /* YUK2 */
773
774
/******************************************************************************
775
 *
776
 *	SkGeSirqIsr() - Wrapper for Special Interrupt Service Routine
777
 *
778
 * Description: calls the preselected special ISR (slow path)
539
 *
779
 *
540
 * Returns: N/A
780
 * Returns: N/A
541
 */
781
 */
542
void SkGeSirqIsr(
782
void SkGeSirqIsr(
543
SK_AC	*pAC,		/* adapter context */
783
SK_AC	*pAC,		/* Adapter Context */
544
SK_IOC	IoC,		/* IO context */
784
SK_IOC	IoC,		/* I/O context */
785
SK_U32	Istatus)	/* Interrupt status word */
786
{
787
	pAC->GIni.GIFunc.pSkGeSirqIsr(pAC, IoC, Istatus);
788
}
789
790
/******************************************************************************
791
 *
792
 *	SkGeYuSirqIsr() - Special Interrupt Service Routine
793
 *
794
 * Description: handles all non data transfer specific interrupts (slow path)
795
 *
796
 * Returns: N/A
797
 */
798
void SkGeYuSirqIsr(
799
SK_AC	*pAC,		/* Adapter Context */
800
SK_IOC	IoC,		/* I/O Context */
545
SK_U32	Istatus)	/* Interrupt status word */
801
SK_U32	Istatus)	/* Interrupt status word */
546
{
802
{
547
	SK_EVPARA	Para;
803
	SK_EVPARA	Para;
548
	SK_U32		RegVal32;	/* Read register value */
804
	SK_U32		RegVal32;	/* Read register value */
549
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
805
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
550
	SK_U16 		PhyInt;
806
	SK_U16		PhyInt;
551
	int			i;
807
	int			i;
552
808
553
	if (((Istatus & IS_HW_ERR) & pAC->GIni.GIValIrqMask) != 0) {
809
	if (((Istatus & IS_HW_ERR) & pAC->GIni.GIValIrqMask) != 0) {
554
		/* read the HW Error Interrupt source */
810
		/* read the HW Error Interrupt source */
555
		SK_IN32(IoC, B0_HWE_ISRC, &RegVal32);
811
		SK_IN32(IoC, B0_HWE_ISRC, &RegVal32);
556
		
812
557
		SkGeHwErr(pAC, IoC, RegVal32);
813
		SkGeYuHwErr(pAC, IoC, RegVal32);
558
	}
814
	}
559
815
560
	/*
816
	/*
Lines 569-575 Link Here
569
	}
825
	}
570
826
571
	if (((Istatus & (IS_PA_TO_RX2 | IS_PA_TO_TX2)) != 0) &&
827
	if (((Istatus & (IS_PA_TO_RX2 | IS_PA_TO_TX2)) != 0) &&
572
	    pAC->GIni.GP[MAC_2].PState == SK_PRT_RESET) {
828
		pAC->GIni.GP[MAC_2].PState == SK_PRT_RESET) {
573
		/* MAC 2 was not initialized but Packet timeout occured */
829
		/* MAC 2 was not initialized but Packet timeout occured */
574
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E005,
830
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E005,
575
			SKERR_SIRQ_E005MSG);
831
			SKERR_SIRQ_E005MSG);
Lines 590-597 Link Here
590
	}
846
	}
591
847
592
	if ((Istatus & IS_PA_TO_TX1) != 0) {
848
	if ((Istatus & IS_PA_TO_TX1) != 0) {
593
		
849
594
		pPrt = &pAC->GIni.GP[0];
850
		pPrt = &pAC->GIni.GP[MAC_1];
595
851
596
		/* May be a normal situation in a server with a slow network */
852
		/* May be a normal situation in a server with a slow network */
597
		SK_OUT16(IoC, B3_PA_CTRL, PA_CLR_TO_TX1);
853
		SK_OUT16(IoC, B3_PA_CTRL, PA_CLR_TO_TX1);
Lines 612-636 Link Here
612
				 * we ignore those
868
				 * we ignore those
613
				 */
869
				 */
614
				pPrt->HalfDupTimerActive = SK_TRUE;
870
				pPrt->HalfDupTimerActive = SK_TRUE;
615
#ifdef XXX
871
616
				Len = sizeof(SK_U64);
617
				SkPnmiGetVar(pAC, IoC, OID_SKGE_STAT_TX_OCTETS, (char *)&Octets,
618
					&Len, (SK_U32)SK_PNMI_PORT_PHYS2INST(pAC, 0),
619
					pAC->Rlmt.Port[0].Net->NetNumber);
620
				
621
				pPrt->LastOctets = Octets;
622
#endif /* XXX */
623
				/* Snap statistic counters */
872
				/* Snap statistic counters */
624
				(void)SkXmUpdateStats(pAC, IoC, 0);
873
				(void)SkXmUpdateStats(pAC, IoC, 0);
625
874
626
				(void)SkXmMacStatistic(pAC, IoC, 0, XM_TXO_OK_HI, &RegVal32);
875
				(void)SkXmMacStatistic(pAC, IoC, 0, XM_TXO_OK_HI, &RegVal32);
627
876
628
				pPrt->LastOctets = (SK_U64)RegVal32 << 32;
877
				pPrt->LastOctets = (SK_U64)RegVal32 << 32;
629
				
878
630
				(void)SkXmMacStatistic(pAC, IoC, 0, XM_TXO_OK_LO, &RegVal32);
879
				(void)SkXmMacStatistic(pAC, IoC, 0, XM_TXO_OK_LO, &RegVal32);
631
880
632
				pPrt->LastOctets += RegVal32;
881
				pPrt->LastOctets += RegVal32;
633
				
882
634
				Para.Para32[0] = 0;
883
				Para.Para32[0] = 0;
635
				SkTimerStart(pAC, IoC, &pPrt->HalfDupChkTimer, SK_HALFDUP_CHK_TIME,
884
				SkTimerStart(pAC, IoC, &pPrt->HalfDupChkTimer, SK_HALFDUP_CHK_TIME,
636
					SKGE_HWAC, SK_HWEV_HALFDUP_CHK, Para);
885
					SKGE_HWAC, SK_HWEV_HALFDUP_CHK, Para);
Lines 640-647 Link Here
640
	}
889
	}
641
890
642
	if ((Istatus & IS_PA_TO_TX2) != 0) {
891
	if ((Istatus & IS_PA_TO_TX2) != 0) {
643
		
892
644
		pPrt = &pAC->GIni.GP[1];
893
		pPrt = &pAC->GIni.GP[MAC_2];
645
894
646
		/* May be a normal situation in a server with a slow network */
895
		/* May be a normal situation in a server with a slow network */
647
		SK_OUT16(IoC, B3_PA_CTRL, PA_CLR_TO_TX2);
896
		SK_OUT16(IoC, B3_PA_CTRL, PA_CLR_TO_TX2);
Lines 653-677 Link Here
653
				 pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOHALF) &&
902
				 pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOHALF) &&
654
				!pPrt->HalfDupTimerActive) {
903
				!pPrt->HalfDupTimerActive) {
655
				pPrt->HalfDupTimerActive = SK_TRUE;
904
				pPrt->HalfDupTimerActive = SK_TRUE;
656
#ifdef XXX
905
657
				Len = sizeof(SK_U64);
658
				SkPnmiGetVar(pAC, IoC, OID_SKGE_STAT_TX_OCTETS, (char *)&Octets,
659
					&Len, (SK_U32)SK_PNMI_PORT_PHYS2INST(pAC, 1),
660
					pAC->Rlmt.Port[1].Net->NetNumber);
661
				
662
				pPrt->LastOctets = Octets;
663
#endif /* XXX */
664
				/* Snap statistic counters */
906
				/* Snap statistic counters */
665
				(void)SkXmUpdateStats(pAC, IoC, 1);
907
				(void)SkXmUpdateStats(pAC, IoC, 1);
666
908
667
				(void)SkXmMacStatistic(pAC, IoC, 1, XM_TXO_OK_HI, &RegVal32);
909
				(void)SkXmMacStatistic(pAC, IoC, 1, XM_TXO_OK_HI, &RegVal32);
668
910
669
				pPrt->LastOctets = (SK_U64)RegVal32 << 32;
911
				pPrt->LastOctets = (SK_U64)RegVal32 << 32;
670
				
912
671
				(void)SkXmMacStatistic(pAC, IoC, 1, XM_TXO_OK_LO, &RegVal32);
913
				(void)SkXmMacStatistic(pAC, IoC, 1, XM_TXO_OK_LO, &RegVal32);
672
914
673
				pPrt->LastOctets += RegVal32;
915
				pPrt->LastOctets += RegVal32;
674
				
916
675
				Para.Para32[0] = 1;
917
				Para.Para32[0] = 1;
676
				SkTimerStart(pAC, IoC, &pPrt->HalfDupChkTimer, SK_HALFDUP_CHK_TIME,
918
				SkTimerStart(pAC, IoC, &pPrt->HalfDupChkTimer, SK_HALFDUP_CHK_TIME,
677
					SKGE_HWAC, SK_HWEV_HALFDUP_CHK, Para);
919
					SKGE_HWAC, SK_HWEV_HALFDUP_CHK, Para);
Lines 684-689 Link Here
684
	if ((Istatus & IS_R1_C) != 0) {
926
	if ((Istatus & IS_R1_C) != 0) {
685
		/* Clear IRQ */
927
		/* Clear IRQ */
686
		SK_OUT32(IoC, B0_R1_CSR, CSR_IRQ_CL_C);
928
		SK_OUT32(IoC, B0_R1_CSR, CSR_IRQ_CL_C);
929
687
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E006,
930
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E006,
688
			SKERR_SIRQ_E006MSG);
931
			SKERR_SIRQ_E006MSG);
689
		Para.Para64 = MAC_1;
932
		Para.Para64 = MAC_1;
Lines 695-700 Link Here
695
	if ((Istatus & IS_R2_C) != 0) {
938
	if ((Istatus & IS_R2_C) != 0) {
696
		/* Clear IRQ */
939
		/* Clear IRQ */
697
		SK_OUT32(IoC, B0_R2_CSR, CSR_IRQ_CL_C);
940
		SK_OUT32(IoC, B0_R2_CSR, CSR_IRQ_CL_C);
941
698
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E007,
942
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E007,
699
			SKERR_SIRQ_E007MSG);
943
			SKERR_SIRQ_E007MSG);
700
		Para.Para64 = MAC_2;
944
		Para.Para64 = MAC_2;
Lines 706-711 Link Here
706
	if ((Istatus & IS_XS1_C) != 0) {
950
	if ((Istatus & IS_XS1_C) != 0) {
707
		/* Clear IRQ */
951
		/* Clear IRQ */
708
		SK_OUT32(IoC, B0_XS1_CSR, CSR_IRQ_CL_C);
952
		SK_OUT32(IoC, B0_XS1_CSR, CSR_IRQ_CL_C);
953
709
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E008,
954
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E008,
710
			SKERR_SIRQ_E008MSG);
955
			SKERR_SIRQ_E008MSG);
711
		Para.Para64 = MAC_1;
956
		Para.Para64 = MAC_1;
Lines 717-722 Link Here
717
	if ((Istatus & IS_XA1_C) != 0) {
962
	if ((Istatus & IS_XA1_C) != 0) {
718
		/* Clear IRQ */
963
		/* Clear IRQ */
719
		SK_OUT32(IoC, B0_XA1_CSR, CSR_IRQ_CL_C);
964
		SK_OUT32(IoC, B0_XA1_CSR, CSR_IRQ_CL_C);
965
720
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E009,
966
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E009,
721
			SKERR_SIRQ_E009MSG);
967
			SKERR_SIRQ_E009MSG);
722
		Para.Para64 = MAC_1;
968
		Para.Para64 = MAC_1;
Lines 728-733 Link Here
728
	if ((Istatus & IS_XS2_C) != 0) {
974
	if ((Istatus & IS_XS2_C) != 0) {
729
		/* Clear IRQ */
975
		/* Clear IRQ */
730
		SK_OUT32(IoC, B0_XS2_CSR, CSR_IRQ_CL_C);
976
		SK_OUT32(IoC, B0_XS2_CSR, CSR_IRQ_CL_C);
977
731
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E010,
978
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E010,
732
			SKERR_SIRQ_E010MSG);
979
			SKERR_SIRQ_E010MSG);
733
		Para.Para64 = MAC_2;
980
		Para.Para64 = MAC_2;
Lines 739-744 Link Here
739
	if ((Istatus & IS_XA2_C) != 0) {
986
	if ((Istatus & IS_XA2_C) != 0) {
740
		/* Clear IRQ */
987
		/* Clear IRQ */
741
		SK_OUT32(IoC, B0_XA2_CSR, CSR_IRQ_CL_C);
988
		SK_OUT32(IoC, B0_XA2_CSR, CSR_IRQ_CL_C);
989
742
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E011,
990
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E011,
743
			SKERR_SIRQ_E011MSG);
991
			SKERR_SIRQ_E011MSG);
744
		Para.Para64 = MAC_2;
992
		Para.Para64 = MAC_2;
Lines 751-789 Link Here
751
	if ((Istatus & IS_EXT_REG) != 0) {
999
	if ((Istatus & IS_EXT_REG) != 0) {
752
		/* Test IRQs from PHY */
1000
		/* Test IRQs from PHY */
753
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
1001
		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
754
			
1002
755
			pPrt = &pAC->GIni.GP[i];
1003
			pPrt = &pAC->GIni.GP[i];
756
			
1004
757
			if (pPrt->PState == SK_PRT_RESET) {
1005
			if (pPrt->PState == SK_PRT_RESET) {
758
				continue;
1006
				continue;
759
			}
1007
			}
760
			
1008
761
#ifdef GENESIS
1009
#ifdef GENESIS
762
			if (pAC->GIni.GIGenesis) {
1010
			if (pAC->GIni.GIGenesis) {
763
				
1011
764
				switch (pPrt->PhyType) {
1012
				switch (pPrt->PhyType) {
765
				
1013
766
				case SK_PHY_XMAC:
1014
				case SK_PHY_XMAC:
767
					break;
1015
					break;
768
				
1016
769
				case SK_PHY_BCOM:
1017
				case SK_PHY_BCOM:
770
					SkXmPhyRead(pAC, IoC, i, PHY_BCOM_INT_STAT, &PhyInt);
1018
					SkXmPhyRead(pAC, IoC, i, PHY_BCOM_INT_STAT, &PhyInt);
771
	
1019
772
					if ((PhyInt & ~PHY_B_DEF_MSK) != 0) {
1020
					if ((PhyInt & ~PHY_B_DEF_MSK) != 0) {
773
						SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1021
						SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
774
							("Port %d Bcom Int: 0x%04X\n",
1022
							("Port %d PHY Int: 0x%04X\n", i, PhyInt));
775
							i, PhyInt));
776
						SkPhyIsrBcom(pAC, IoC, i, PhyInt);
1023
						SkPhyIsrBcom(pAC, IoC, i, PhyInt);
777
					}
1024
					}
778
					break;
1025
					break;
779
#ifdef OTHER_PHY
1026
#ifdef OTHER_PHY
780
				case SK_PHY_LONE:
1027
				case SK_PHY_LONE:
781
					SkXmPhyRead(pAC, IoC, i, PHY_LONE_INT_STAT, &PhyInt);
1028
					SkXmPhyRead(pAC, IoC, i, PHY_LONE_INT_STAT, &PhyInt);
782
					
1029
783
					if ((PhyInt & PHY_L_DEF_MSK) != 0) {
1030
					if ((PhyInt & PHY_L_DEF_MSK) != 0) {
784
						SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1031
						SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
785
							("Port %d Lone Int: %x\n",
1032
							("Port %d PHY Int: 0x%04X\n", i, PhyInt));
786
							i, PhyInt));
787
						SkPhyIsrLone(pAC, IoC, i, PhyInt);
1033
						SkPhyIsrLone(pAC, IoC, i, PhyInt);
788
					}
1034
					}
789
					break;
1035
					break;
Lines 791-797 Link Here
791
				}
1037
				}
792
			}
1038
			}
793
#endif /* GENESIS */
1039
#endif /* GENESIS */
794
	
1040
795
#ifdef YUKON
1041
#ifdef YUKON
796
			if (pAC->GIni.GIYukon) {
1042
			if (pAC->GIni.GIYukon) {
797
				/* Read PHY Interrupt Status */
1043
				/* Read PHY Interrupt Status */
Lines 799-806 Link Here
799
1045
800
				if ((PhyInt & PHY_M_DEF_MSK) != 0) {
1046
				if ((PhyInt & PHY_M_DEF_MSK) != 0) {
801
					SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1047
					SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
802
						("Port %d Marv Int: 0x%04X\n",
1048
						("Port %d PHY Int: 0x%04X\n", i, PhyInt));
803
						i, PhyInt));
804
					SkPhyIsrGmac(pAC, IoC, i, PhyInt);
1049
					SkPhyIsrGmac(pAC, IoC, i, PhyInt);
805
				}
1050
				}
806
			}
1051
			}
Lines 808-820 Link Here
808
		}
1053
		}
809
	}
1054
	}
810
1055
811
	/* I2C Ready interrupt */
1056
	/* TWSI Ready interrupt */
812
	if ((Istatus & IS_I2C_READY) != 0) {
1057
	if ((Istatus & IS_I2C_READY) != 0) {
813
#ifdef SK_SLIM
1058
#ifdef SK_SLIM
814
        SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
1059
		SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
815
#else		
1060
#else
816
		SkI2cIsr(pAC, IoC);
1061
		SkI2cIsr(pAC, IoC);
817
#endif		
1062
#endif
818
	}
1063
	}
819
1064
820
	/* SW forced interrupt */
1065
	/* SW forced interrupt */
Lines 829-835 Link Here
829
		 * us only a link going down.
1074
		 * us only a link going down.
830
		 */
1075
		 */
831
		/* clear interrupt */
1076
		/* clear interrupt */
832
		SK_OUT8(IoC, MR_ADDR(MAC_1, LNK_SYNC_CTRL), LED_CLR_IRQ);
1077
		SK_OUT8(IoC, MR_ADDR(MAC_1, LNK_SYNC_CTRL), LNK_CLR_IRQ);
833
	}
1078
	}
834
1079
835
	/* Check MAC after link sync counter */
1080
	/* Check MAC after link sync counter */
Lines 844-850 Link Here
844
		 * us only a link going down.
1089
		 * us only a link going down.
845
		 */
1090
		 */
846
		/* clear interrupt */
1091
		/* clear interrupt */
847
		SK_OUT8(IoC, MR_ADDR(MAC_2, LNK_SYNC_CTRL), LED_CLR_IRQ);
1092
		SK_OUT8(IoC, MR_ADDR(MAC_2, LNK_SYNC_CTRL), LNK_CLR_IRQ);
848
	}
1093
	}
849
1094
850
	/* Check MAC after link sync counter */
1095
	/* Check MAC after link sync counter */
Lines 860-872 Link Here
860
			/* read the HW Error Interrupt source */
1105
			/* read the HW Error Interrupt source */
861
			SK_IN32(IoC, B0_HWE_ISRC, &RegVal32);
1106
			SK_IN32(IoC, B0_HWE_ISRC, &RegVal32);
862
1107
863
			SkGeHwErr(pAC, IoC, RegVal32);
1108
			SkGeYuHwErr(pAC, IoC, RegVal32);
864
		}
1109
		}
865
1110
866
		SkHwtIsr(pAC, IoC);
1111
		SkHwtIsr(pAC, IoC);
867
	}
1112
	}
868
1113
869
}	/* SkGeSirqIsr */
1114
}	/* SkGeYuSirqIsr */
1115
1116
#ifdef YUK2
1117
/******************************************************************************
1118
 *
1119
 *	SkYuk2PortSirq() - Service HW Errors for specified port (Yukon-2 only)
1120
 *
1121
 * Description: handles the HW Error interrupts for a specific port.
1122
 *
1123
 * Returns: N/A
1124
 */
1125
static void SkYuk2PortSirq(
1126
SK_AC	*pAC,		/* Adapter Context */
1127
SK_IOC	IoC,		/* I/O Context */
1128
SK_U32	IStatus,	/* Interrupt status word */
1129
int		Port)		/* Port Index (MAC_1 + n) */
1130
{
1131
	SK_EVPARA	Para;
1132
	int			Queue;
1133
	SK_U16		PhyInt;
1134
1135
	if (Port == MAC_2) {
1136
		IStatus >>= 8;
1137
	}
1138
1139
	/* Interrupt from PHY */
1140
	if ((IStatus & Y2_IS_IRQ_PHY1) != 0) {
1141
		/* Read PHY Interrupt Status */
1142
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_INT_STAT, &PhyInt);
1143
1144
		if ((PhyInt & PHY_M_DEF_MSK) != 0) {
1145
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1146
				("Port %d PHY Int: 0x%04X\n", Port, PhyInt));
1147
			SkPhyIsrGmac(pAC, IoC, Port, PhyInt);
1148
		}
1149
	}
1150
1151
	/* Interrupt from MAC */
1152
	if ((IStatus & Y2_IS_IRQ_MAC1) != 0) {
1153
		SkMacIrq(pAC, IoC, Port);
1154
	}
1155
1156
	if ((IStatus & (Y2_IS_CHK_RX1 | Y2_IS_CHK_TXS1 | Y2_IS_CHK_TXA1)) != 0) {
1157
		if ((IStatus & Y2_IS_CHK_RX1) != 0) {
1158
			if (Port == MAC_1) {
1159
				Queue = Q_R1;
1160
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E006,
1161
					SKERR_SIRQ_E006MSG);
1162
			}
1163
			else {
1164
				Queue = Q_R2;
1165
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E007,
1166
					SKERR_SIRQ_E007MSG);
1167
			}
1168
			/* Clear IRQ */
1169
			SK_OUT32(IoC, Q_ADDR(Queue, Q_CSR), BMU_CLR_IRQ_CHK);
1170
		}
1171
1172
		if ((IStatus & Y2_IS_CHK_TXS1) != 0) {
1173
			if (Port == MAC_1) {
1174
				Queue = Q_XS1;
1175
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E008,
1176
					SKERR_SIRQ_E008MSG);
1177
			}
1178
			else {
1179
				Queue = Q_XS2;
1180
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E010,
1181
					SKERR_SIRQ_E010MSG);
1182
			}
1183
			/* Clear IRQ */
1184
			SK_OUT32(IoC, Q_ADDR(Queue, Q_CSR), BMU_CLR_IRQ_CHK);
1185
		}
1186
1187
		if ((IStatus & Y2_IS_CHK_TXA1) != 0) {
1188
			if (Port == MAC_1) {
1189
				Queue = Q_XA1;
1190
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E009,
1191
					SKERR_SIRQ_E009MSG);
1192
			}
1193
			else {
1194
				Queue = Q_XA2;
1195
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E011,
1196
					SKERR_SIRQ_E011MSG);
1197
			}
1198
			/* Clear IRQ */
1199
			SK_OUT32(IoC, Q_ADDR(Queue, Q_CSR), BMU_CLR_IRQ_CHK);
1200
		}
1201
1202
		Para.Para64 = Port;
1203
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);
1204
1205
		Para.Para32[0] = Port;
1206
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
1207
	}
1208
}	/* SkYuk2PortSirq */
1209
#endif /* YUK2 */
1210
1211
/******************************************************************************
1212
 *
1213
 *	SkYuk2SirqIsr() - Special Interrupt Service Routine	(Yukon-2 only)
1214
 *
1215
 * Description: handles all non data transfer specific interrupts (slow path)
1216
 *
1217
 * Returns: N/A
1218
 */
1219
void SkYuk2SirqIsr(
1220
SK_AC	*pAC,		/* Adapter Context */
1221
SK_IOC	IoC,		/* I/O Context */
1222
SK_U32	Istatus)	/* Interrupt status word */
1223
{
1224
#ifdef YUK2
1225
	SK_EVPARA	Para;
1226
	SK_U32		RegVal32;	/* Read register value */
1227
	SK_U8		Value;
1228
1229
	/* HW Error indicated ? */
1230
	if (((Istatus & Y2_IS_HW_ERR) & pAC->GIni.GIValIrqMask) != 0) {
1231
		/* read the HW Error Interrupt source */
1232
		SK_IN32(IoC, B0_HWE_ISRC, &RegVal32);
1233
1234
		SkYuk2HwErr(pAC, IoC, RegVal32);
1235
	}
1236
1237
	/* Interrupt from ASF Subsystem */
1238
	if ((Istatus & Y2_IS_ASF) != 0) {
1239
		/* clear IRQ */
1240
		/* later on clearing should be done in ASF ISR handler */
1241
		SK_IN8(IoC, B28_Y2_ASF_STAT_CMD, &Value);
1242
		Value |= Y2_ASF_CLR_HSTI;
1243
		SK_OUT8(IoC, B28_Y2_ASF_STAT_CMD, Value);
1244
		/* Call IRQ handler in ASF Module */
1245
		/* TBD */
1246
	}
1247
1248
	/* Check IRQ from polling unit */
1249
	if ((Istatus & Y2_IS_POLL_CHK) != 0) {
1250
		/* Clear IRQ */
1251
		SK_OUT32(IoC, POLL_CTRL, PC_CLR_IRQ_CHK);
1252
1253
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_SIRQ_E036,
1254
			SKERR_SIRQ_E036MSG);
1255
		Para.Para64 = 0;
1256
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_ADAP_FAIL, Para);
1257
	}
1258
1259
	/* TWSI Ready interrupt */
1260
	if ((Istatus & Y2_IS_TWSI_RDY) != 0) {
1261
#ifdef SK_SLIM
1262
		SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
1263
#else
1264
		SkI2cIsr(pAC, IoC);
1265
#endif
1266
	}
1267
1268
	/* SW forced interrupt */
1269
	if ((Istatus & Y2_IS_IRQ_SW) != 0) {
1270
		/* clear the software IRQ */
1271
		SK_OUT8(IoC, B0_CTST, CS_CL_SW_IRQ);
1272
	}
1273
1274
	if ((Istatus & Y2_IS_L1_MASK) != 0) {
1275
		SkYuk2PortSirq(pAC, IoC, Istatus, MAC_1);
1276
	}
1277
1278
	if ((Istatus & Y2_IS_L2_MASK) != 0) {
1279
		SkYuk2PortSirq(pAC, IoC, Istatus, MAC_2);
1280
	}
1281
1282
	/* Timer interrupt (served last) */
1283
	if ((Istatus & Y2_IS_TIMINT) != 0) {
1284
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1285
			("Timer Int: 0x%08lX\n", Istatus));
1286
		SkHwtIsr(pAC, IoC);
1287
	}
1288
#endif	/* YUK2 */
1289
1290
}	/* SkYuk2SirqIsr */
870
1291
871
1292
872
#ifdef GENESIS
1293
#ifdef GENESIS
Lines 880-887 Link Here
880
 */
1301
 */
881
static int SkGePortCheckShorts(
1302
static int SkGePortCheckShorts(
882
SK_AC	*pAC,		/* Adapter Context */
1303
SK_AC	*pAC,		/* Adapter Context */
883
SK_IOC	IoC,		/* IO Context */
1304
SK_IOC	IoC,		/* I/O Context */
884
int		Port)		/* Which port should be checked */
1305
int		Port)		/* Port Index (MAC_1 + n) */
885
{
1306
{
886
	SK_U32		Shorts;			/* Short Event Counter */
1307
	SK_U32		Shorts;			/* Short Event Counter */
887
	SK_U32		CheckShorts;	/* Check value for Short Event Counter */
1308
	SK_U32		CheckShorts;	/* Check value for Short Event Counter */
Lines 909-917 Link Here
909
	RxCts = 0;
1330
	RxCts = 0;
910
1331
911
	for (i = 0; i < sizeof(SkGeRxRegs)/sizeof(SkGeRxRegs[0]); i++) {
1332
	for (i = 0; i < sizeof(SkGeRxRegs)/sizeof(SkGeRxRegs[0]); i++) {
912
		
1333
913
		(void)SkXmMacStatistic(pAC, IoC, Port, SkGeRxRegs[i], &RxTmp);
1334
		(void)SkXmMacStatistic(pAC, IoC, Port, SkGeRxRegs[i], &RxTmp);
914
		
1335
915
		RxCts += (SK_U64)RxTmp;
1336
		RxCts += (SK_U64)RxTmp;
916
	}
1337
	}
917
1338
Lines 928-938 Link Here
928
		CheckShorts = 2;
1349
		CheckShorts = 2;
929
1350
930
		(void)SkXmMacStatistic(pAC, IoC, Port, XM_RXF_FCS_ERR, &FcsErrCts);
1351
		(void)SkXmMacStatistic(pAC, IoC, Port, XM_RXF_FCS_ERR, &FcsErrCts);
931
		
1352
932
		if (pPrt->PLinkModeConf == SK_LMODE_AUTOSENSE &&
1353
		if (pPrt->PLinkModeConf == (SK_U8)SK_LMODE_AUTOSENSE &&
933
		    pPrt->PLipaAutoNeg == SK_LIPA_UNKNOWN &&
1354
			pPrt->PLipaAutoNeg == (SK_U8)SK_LIPA_UNKNOWN &&
934
		    (pPrt->PLinkMode == SK_LMODE_HALF ||
1355
			(pPrt->PLinkMode == (SK_U8)SK_LMODE_HALF ||
935
			 pPrt->PLinkMode == SK_LMODE_FULL)) {
1356
			 pPrt->PLinkMode == (SK_U8)SK_LMODE_FULL)) {
936
			/*
1357
			/*
937
			 * This is autosensing and we are in the fallback
1358
			 * This is autosensing and we are in the fallback
938
			 * manual full/half duplex mode.
1359
			 * manual full/half duplex mode.
Lines 941-956 Link Here
941
				/* Nothing received, restart link */
1362
				/* Nothing received, restart link */
942
				pPrt->PPrevFcs = FcsErrCts;
1363
				pPrt->PPrevFcs = FcsErrCts;
943
				pPrt->PPrevShorts = Shorts;
1364
				pPrt->PPrevShorts = Shorts;
944
				
1365
945
				return(SK_HW_PS_RESTART);
1366
				return(SK_HW_PS_RESTART);
946
			}
1367
			}
947
			else {
1368
			else {
948
				pPrt->PLipaAutoNeg = SK_LIPA_MANUAL;
1369
				pPrt->PLipaAutoNeg = (SK_U8)SK_LIPA_MANUAL;
949
			}
1370
			}
950
		}
1371
		}
951
1372
952
		if (((RxCts - pPrt->PPrevRx) > pPrt->PRxLim) ||
1373
		if (((RxCts - pPrt->PPrevRx) > pPrt->PRxLim) ||
953
		    (!(FcsErrCts - pPrt->PPrevFcs))) {
1374
			(!(FcsErrCts - pPrt->PPrevFcs))) {
954
			/*
1375
			/*
955
			 * Note: The compare with zero above has to be done the way shown,
1376
			 * Note: The compare with zero above has to be done the way shown,
956
			 * otherwise the Linux driver will have a problem.
1377
			 * otherwise the Linux driver will have a problem.
Lines 995-1023 Link Here
995
 */
1416
 */
996
static int SkGePortCheckUp(
1417
static int SkGePortCheckUp(
997
SK_AC	*pAC,		/* Adapter Context */
1418
SK_AC	*pAC,		/* Adapter Context */
998
SK_IOC	IoC,		/* IO Context */
1419
SK_IOC	IoC,		/* I/O Context */
999
int		Port)		/* Which port should be checked */
1420
int		Port)		/* Port Index (MAC_1 + n) */
1000
{
1421
{
1001
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
1422
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
1002
	SK_BOOL		AutoNeg;	/* Is Auto-negotiation used ? */
1423
	SK_BOOL		AutoNeg;	/* Is Auto-negotiation used ? */
1003
	int			Rtv;		/* Return value */
1424
	int			Rtv;		/* Return value */
1004
1425
1005
	Rtv = SK_HW_PS_NONE;
1426
	Rtv = SK_HW_PS_NONE;
1006
	
1427
1007
	pPrt = &pAC->GIni.GP[Port];
1428
	pPrt = &pAC->GIni.GP[Port];
1008
1429
1009
	if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
1430
	AutoNeg = pPrt->PLinkMode != SK_LMODE_HALF &&
1010
		AutoNeg = SK_FALSE;
1431
			  pPrt->PLinkMode != SK_LMODE_FULL;
1011
	}
1012
	else {
1013
		AutoNeg = SK_TRUE;
1014
	}
1015
1432
1016
#ifdef GENESIS
1433
#ifdef GENESIS
1017
	if (pAC->GIni.GIGenesis) {
1434
	if (pAC->GIni.GIGenesis) {
1018
1435
1019
		switch (pPrt->PhyType) {
1436
		switch (pPrt->PhyType) {
1020
		
1437
1021
		case SK_PHY_XMAC:
1438
		case SK_PHY_XMAC:
1022
			Rtv = SkGePortCheckUpXmac(pAC, IoC, Port, AutoNeg);
1439
			Rtv = SkGePortCheckUpXmac(pAC, IoC, Port, AutoNeg);
1023
			break;
1440
			break;
Lines 1038-1044 Link Here
1038
	
1455
	
1039
#ifdef YUKON
1456
#ifdef YUKON
1040
	if (pAC->GIni.GIYukon) {
1457
	if (pAC->GIni.GIYukon) {
1041
		
1458
1042
		Rtv = SkGePortCheckUpGmac(pAC, IoC, Port, AutoNeg);
1459
		Rtv = SkGePortCheckUpGmac(pAC, IoC, Port, AutoNeg);
1043
	}
1460
	}
1044
#endif /* YUKON */
1461
#endif /* YUKON */
Lines 1059-1066 Link Here
1059
 */
1476
 */
1060
static int SkGePortCheckUpXmac(
1477
static int SkGePortCheckUpXmac(
1061
SK_AC	*pAC,		/* Adapter Context */
1478
SK_AC	*pAC,		/* Adapter Context */
1062
SK_IOC	IoC,		/* IO Context */
1479
SK_IOC	IoC,		/* I/O Context */
1063
int		Port,		/* Which port should be checked */
1480
int		Port,		/* Port Index (MAC_1 + n) */
1064
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
1481
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
1065
{
1482
{
1066
	SK_U32		Shorts;		/* Short Event Counter */
1483
	SK_U32		Shorts;		/* Short Event Counter */
Lines 1098-1104 Link Here
1098
			XM_IN16(IoC, Port, XM_ISRC, &Isrc);
1515
			XM_IN16(IoC, Port, XM_ISRC, &Isrc);
1099
			IsrcSum |= Isrc;
1516
			IsrcSum |= Isrc;
1100
			SkXmAutoNegLipaXmac(pAC, IoC, Port, IsrcSum);
1517
			SkXmAutoNegLipaXmac(pAC, IoC, Port, IsrcSum);
1101
			
1518
1102
			if ((Isrc & XM_IS_INP_ASS) == 0) {
1519
			if ((Isrc & XM_IS_INP_ASS) == 0) {
1103
				/* It has been in sync since last time */
1520
				/* It has been in sync since last time */
1104
				/* Restart the PORT */
1521
				/* Restart the PORT */
Lines 1117-1130 Link Here
1117
				 * Link Restart Workaround:
1534
				 * Link Restart Workaround:
1118
				 *  it may be possible that the other Link side
1535
				 *  it may be possible that the other Link side
1119
				 *  restarts its link as well an we detect
1536
				 *  restarts its link as well an we detect
1120
				 *  another LinkBroken. To prevent this
1537
				 *  another PLinkBroken. To prevent this
1121
				 *  happening we check for a maximum number
1538
				 *  happening we check for a maximum number
1122
				 *  of consecutive restart. If those happens,
1539
				 *  of consecutive restart. If those happens,
1123
				 *  we do NOT restart the active link and
1540
				 *  we do NOT restart the active link and
1124
				 *  check whether the link is now o.k.
1541
				 *  check whether the link is now o.k.
1125
				 */
1542
				 */
1126
				pPrt->PLinkResCt++;
1543
				pPrt->PLinkResCt++;
1127
				
1544
1128
				pPrt->PAutoNegTimeOut = 0;
1545
				pPrt->PAutoNegTimeOut = 0;
1129
1546
1130
				if (pPrt->PLinkResCt < SK_MAX_LRESTART) {
1547
				if (pPrt->PLinkResCt < SK_MAX_LRESTART) {
Lines 1132-1144 Link Here
1132
				}
1549
				}
1133
1550
1134
				pPrt->PLinkResCt = 0;
1551
				pPrt->PLinkResCt = 0;
1135
				
1552
1136
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1553
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1137
					("Do NOT restart on Port %d %x %x\n", Port, Isrc, IsrcSum));
1554
					("Do NOT restart on Port %d %x %x\n", Port, Isrc, IsrcSum));
1138
			}
1555
			}
1139
			else {
1556
			else {
1140
				pPrt->PIsave = (SK_U16)(IsrcSum & XM_IS_AND);
1557
				pPrt->PIsave = (SK_U16)(IsrcSum & XM_IS_AND);
1141
				
1558
1142
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1559
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1143
					("Save Sync/nosync Port %d %x %x\n", Port, Isrc, IsrcSum));
1560
					("Save Sync/nosync Port %d %x %x\n", Port, Isrc, IsrcSum));
1144
1561
Lines 1165-1171 Link Here
1165
				if ((Isrc & XM_IS_INP_ASS) != 0) {
1582
				if ((Isrc & XM_IS_INP_ASS) != 0) {
1166
					pPrt->PLinkBroken = SK_TRUE;
1583
					pPrt->PLinkBroken = SK_TRUE;
1167
					/* Re-Init Link partner Autoneg flag */
1584
					/* Re-Init Link partner Autoneg flag */
1168
					pPrt->PLipaAutoNeg = SK_LIPA_UNKNOWN;
1585
					pPrt->PLipaAutoNeg = (SK_U8)SK_LIPA_UNKNOWN;
1169
					SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1586
					SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1170
						("Link broken Port %d\n", Port));
1587
						("Link broken Port %d\n", Port));
1171
1588
Lines 1178-1184 Link Here
1178
		}
1595
		}
1179
		else {
1596
		else {
1180
			SkXmAutoNegLipaXmac(pAC, IoC, Port, Isrc);
1597
			SkXmAutoNegLipaXmac(pAC, IoC, Port, Isrc);
1181
			
1598
1182
			if (SkGePortCheckShorts(pAC, IoC, Port) == SK_HW_PS_RESTART) {
1599
			if (SkGePortCheckShorts(pAC, IoC, Port) == SK_HW_PS_RESTART) {
1183
				return(SK_HW_PS_RESTART);
1600
				return(SK_HW_PS_RESTART);
1184
			}
1601
			}
Lines 1210-1226 Link Here
1210
	}
1627
	}
1211
1628
1212
	if (AutoNeg) {
1629
	if (AutoNeg) {
1630
		/* Auto-Negotiation Done ? */
1213
		if ((IsrcSum & XM_IS_AND) != 0) {
1631
		if ((IsrcSum & XM_IS_AND) != 0) {
1632
1214
			SkHWLinkUp(pAC, IoC, Port);
1633
			SkHWLinkUp(pAC, IoC, Port);
1634
1215
			Done = SkMacAutoNegDone(pAC, IoC, Port);
1635
			Done = SkMacAutoNegDone(pAC, IoC, Port);
1636
1216
			if (Done != SK_AND_OK) {
1637
			if (Done != SK_AND_OK) {
1217
				/* Get PHY parameters, for debugging only */
1638
				/* Get PHY parameters, for debugging only */
1218
				SkXmPhyRead(pAC, IoC, Port, PHY_XMAC_AUNE_LP, &LpAb);
1639
				SkXmPhyRead(pAC, IoC, Port, PHY_XMAC_AUNE_LP, &LpAb);
1219
				SkXmPhyRead(pAC, IoC, Port, PHY_XMAC_RES_ABI, &ResAb);
1640
				SkXmPhyRead(pAC, IoC, Port, PHY_XMAC_RES_ABI, &ResAb);
1220
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1641
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
1221
					("AutoNeg FAIL Port %d (LpAb %x, ResAb %x)\n",
1642
					("AutoNeg FAIL Port %d (LpAb %x, ResAb %x)\n",
1222
					 Port, LpAb, ResAb));
1643
					Port, LpAb, ResAb));
1223
					
1644
1224
				/* Try next possible mode */
1645
				/* Try next possible mode */
1225
				NextMode = SkHWSenseGetNext(pAC, IoC, Port);
1646
				NextMode = SkHWSenseGetNext(pAC, IoC, Port);
1226
				SkHWLinkDown(pAC, IoC, Port);
1647
				SkHWLinkDown(pAC, IoC, Port);
Lines 1236-1277 Link Here
1236
			 * (clear Page Received bit if set)
1657
			 * (clear Page Received bit if set)
1237
			 */
1658
			 */
1238
			SkXmPhyRead(pAC, IoC, Port, PHY_XMAC_AUNE_EXP, &ExtStat);
1659
			SkXmPhyRead(pAC, IoC, Port, PHY_XMAC_AUNE_EXP, &ExtStat);
1239
			
1660
1240
			return(SK_HW_PS_LINK);
1661
			return(SK_HW_PS_LINK);
1241
		}
1662
		}
1242
		
1663
1243
		/* AutoNeg not done, but HW link is up. Check for timeouts */
1664
		/* AutoNeg not done, but HW link is up. Check for timeouts */
1244
		pPrt->PAutoNegTimeOut++;
1665
		if (pPrt->PAutoNegTimeOut++ >= SK_AND_MAX_TO) {
1245
		if (pPrt->PAutoNegTimeOut >= SK_AND_MAX_TO) {
1246
			/* Increase the Timeout counter */
1666
			/* Increase the Timeout counter */
1247
			pPrt->PAutoNegTOCt++;
1667
			pPrt->PAutoNegTOCt++;
1248
1668
1249
			/* Timeout occured */
1669
			/* Timeout occured */
1250
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1670
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1251
				("AutoNeg timeout Port %d\n", Port));
1671
				("AutoNeg timeout Port %d\n", Port));
1252
			if (pPrt->PLinkModeConf == SK_LMODE_AUTOSENSE &&
1672
			if (pPrt->PLinkModeConf == (SK_U8)SK_LMODE_AUTOSENSE &&
1253
				pPrt->PLipaAutoNeg != SK_LIPA_AUTO) {
1673
				pPrt->PLipaAutoNeg != (SK_U8)SK_LIPA_AUTO) {
1254
				/* Set Link manually up */
1674
				/* Set Link manually up */
1255
				SkHWSenseSetNext(pAC, IoC, Port, SK_LMODE_FULL);
1675
				SkHWSenseSetNext(pAC, IoC, Port, SK_LMODE_FULL);
1256
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1676
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1257
					("Set manual full duplex Port %d\n", Port));
1677
					("Set manual full duplex Port %d\n", Port));
1258
			}
1678
			}
1259
1679
1260
			if (pPrt->PLinkModeConf == SK_LMODE_AUTOSENSE &&
1680
			if (pPrt->PLinkModeConf == (SK_U8)SK_LMODE_AUTOSENSE &&
1261
				pPrt->PLipaAutoNeg == SK_LIPA_AUTO &&
1681
				pPrt->PLipaAutoNeg == (SK_U8)SK_LIPA_AUTO &&
1262
				pPrt->PAutoNegTOCt >= SK_MAX_ANEG_TO) {
1682
				pPrt->PAutoNegTOCt >= SK_MAX_ANEG_TO) {
1263
				/*
1683
				/*
1264
				 * This is rather complicated.
1684
				 * This is rather complicated.
1265
				 * we need to check here whether the LIPA_AUTO
1685
				 * we need to check here whether the LIPA_AUTO
1266
				 * we saw before is false alert. We saw at one
1686
				 * we saw before is false alert. We saw at one
1267
				 * switch ( SR8800) that on boot time it sends
1687
				 * switch (SR8800) that on boot time it sends
1268
				 * just one auto-neg packet and does no further
1688
				 * just one auto-neg packet and does no further
1269
				 * auto-negotiation.
1689
				 * auto-negotiation.
1270
				 * Solution: we restart the autosensing after
1690
				 * Solution: we restart the autosensing after
1271
				 * a few timeouts.
1691
				 * a few timeouts.
1272
				 */
1692
				 */
1273
				pPrt->PAutoNegTOCt = 0;
1693
				pPrt->PAutoNegTOCt = 0;
1274
				pPrt->PLipaAutoNeg = SK_LIPA_UNKNOWN;
1694
				pPrt->PLipaAutoNeg = (SK_U8)SK_LIPA_UNKNOWN;
1275
				SkHWInitDefSense(pAC, IoC, Port);
1695
				SkHWInitDefSense(pAC, IoC, Port);
1276
			}
1696
			}
1277
1697
Lines 1282-1299 Link Here
1282
	else {
1702
	else {
1283
		/* Link is up and we don't need more */
1703
		/* Link is up and we don't need more */
1284
#ifdef DEBUG
1704
#ifdef DEBUG
1285
		if (pPrt->PLipaAutoNeg == SK_LIPA_AUTO) {
1705
		if (pPrt->PLipaAutoNeg == (SK_U8)SK_LIPA_AUTO) {
1286
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1706
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
1287
				("ERROR: Lipa auto detected on port %d\n", Port));
1707
				("ERROR: Lipa auto detected on port %d\n", Port));
1288
		}
1708
		}
1289
#endif /* DEBUG */
1709
#endif /* DEBUG */
1290
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1710
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1291
			("Link sync(GP), Port %d\n", Port));
1711
			("Link sync(GP), Port %d\n", Port));
1292
		SkHWLinkUp(pAC, IoC, Port);
1712
		SkHWLinkUp(pAC, IoC, Port);
1293
		
1713
1294
		/*
1714
		/*
1295
		 * Link sync (GP) and so assume a good connection. But if not received
1715
		 * Link sync (GP) and so assume a good connection. But if no
1296
		 * a bunch of frames received in a time slot (maybe broken tx cable)
1716
		 * bunch of frames received in a time slot (maybe broken Tx cable)
1297
		 * the port is restart.
1717
		 * the port is restart.
1298
		 */
1718
		 */
1299
		return(SK_HW_PS_LINK);
1719
		return(SK_HW_PS_LINK);
Lines 1314-1321 Link Here
1314
 */
1734
 */
1315
static int SkGePortCheckUpBcom(
1735
static int SkGePortCheckUpBcom(
1316
SK_AC	*pAC,		/* Adapter Context */
1736
SK_AC	*pAC,		/* Adapter Context */
1317
SK_IOC	IoC,		/* IO Context */
1737
SK_IOC	IoC,		/* I/O Context */
1318
int		Port,		/* Which port should be checked */
1738
int		Port,		/* Port Index (MAC_1 + n) */
1319
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
1739
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
1320
{
1740
{
1321
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
1741
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
Lines 1334-1407 Link Here
1334
	/* Check for No HCD Link events (#10523) */
1754
	/* Check for No HCD Link events (#10523) */
1335
	SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &Isrc);
1755
	SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &Isrc);
1336
1756
1337
#ifdef xDEBUG
1338
	if ((Isrc & ~(PHY_B_IS_HCT | PHY_B_IS_LCT) ==
1339
		(PHY_B_IS_SCR_S_ER | PHY_B_IS_RRS_CHANGE | PHY_B_IS_LRS_CHANGE)) {
1340
1341
		SK_U32	Stat1, Stat2, Stat3;
1342
1343
		Stat1 = 0;
1344
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_MASK, &Stat1);
1345
		CMSMPrintString(
1346
			pAC->pConfigTable,
1347
			MSG_TYPE_RUNTIME_INFO,
1348
			"CheckUp1 - Stat: %x, Mask: %x",
1349
			(void *)Isrc,
1350
			(void *)Stat1);
1351
1352
		Stat1 = 0;
1353
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_CTRL, &Stat1);
1354
		Stat2 = 0;
1355
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_STAT, &Stat2);
1356
		Stat1 = Stat1 << 16 | Stat2;
1357
		Stat2 = 0;
1358
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUNE_ADV, &Stat2);
1359
		Stat3 = 0;
1360
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUNE_LP, &Stat3);
1361
		Stat2 = Stat2 << 16 | Stat3;
1362
		CMSMPrintString(
1363
			pAC->pConfigTable,
1364
			MSG_TYPE_RUNTIME_INFO,
1365
			"Ctrl/Stat: %x, AN Adv/LP: %x",
1366
			(void *)Stat1,
1367
			(void *)Stat2);
1368
1369
		Stat1 = 0;
1370
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUNE_EXP, &Stat1);
1371
		Stat2 = 0;
1372
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_EXT_STAT, &Stat2);
1373
		Stat1 = Stat1 << 16 | Stat2;
1374
		Stat2 = 0;
1375
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_1000T_CTRL, &Stat2);
1376
		Stat3 = 0;
1377
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_1000T_STAT, &Stat3);
1378
		Stat2 = Stat2 << 16 | Stat3;
1379
		CMSMPrintString(
1380
			pAC->pConfigTable,
1381
			MSG_TYPE_RUNTIME_INFO,
1382
			"AN Exp/IEEE Ext: %x, 1000T Ctrl/Stat: %x",
1383
			(void *)Stat1,
1384
			(void *)Stat2);
1385
1386
		Stat1 = 0;
1387
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_P_EXT_CTRL, &Stat1);
1388
		Stat2 = 0;
1389
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_P_EXT_STAT, &Stat2);
1390
		Stat1 = Stat1 << 16 | Stat2;
1391
		Stat2 = 0;
1392
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_CTRL, &Stat2);
1393
		Stat3 = 0;
1394
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_STAT, &Stat3);
1395
		Stat2 = Stat2 << 16 | Stat3;
1396
		CMSMPrintString(
1397
			pAC->pConfigTable,
1398
			MSG_TYPE_RUNTIME_INFO,
1399
			"PHY Ext Ctrl/Stat: %x, Aux Ctrl/Stat: %x",
1400
			(void *)Stat1,
1401
			(void *)Stat2);
1402
	}
1403
#endif /* DEBUG */
1404
1405
	if ((Isrc & (PHY_B_IS_NO_HDCL /* | PHY_B_IS_NO_HDC */)) != 0) {
1757
	if ((Isrc & (PHY_B_IS_NO_HDCL /* | PHY_B_IS_NO_HDC */)) != 0) {
1406
		/*
1758
		/*
1407
		 * Workaround BCom Errata:
1759
		 * Workaround BCom Errata:
Lines 1414-1427 Link Here
1414
			(SK_U16)(Ctrl & ~PHY_CT_LOOP));
1766
			(SK_U16)(Ctrl & ~PHY_CT_LOOP));
1415
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1767
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1416
			("No HCD Link event, Port %d\n", Port));
1768
			("No HCD Link event, Port %d\n", Port));
1417
#ifdef xDEBUG
1418
		CMSMPrintString(
1419
			pAC->pConfigTable,
1420
			MSG_TYPE_RUNTIME_INFO,
1421
			"No HCD link event, port %d.",
1422
			(void *)Port,
1423
			(void *)NULL);
1424
#endif /* DEBUG */
1425
	}
1769
	}
1426
1770
1427
	/* Not obsolete: link status bit is latched to 0 and autoclearing! */
1771
	/* Not obsolete: link status bit is latched to 0 and autoclearing! */
Lines 1431-1502 Link Here
1431
		return(SK_HW_PS_NONE);
1775
		return(SK_HW_PS_NONE);
1432
	}
1776
	}
1433
1777
1434
#ifdef xDEBUG
1435
	{
1436
		SK_U32	Stat1, Stat2, Stat3;
1437
1438
		Stat1 = 0;
1439
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_MASK, &Stat1);
1440
		CMSMPrintString(
1441
			pAC->pConfigTable,
1442
			MSG_TYPE_RUNTIME_INFO,
1443
			"CheckUp1a - Stat: %x, Mask: %x",
1444
			(void *)Isrc,
1445
			(void *)Stat1);
1446
1447
		Stat1 = 0;
1448
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_CTRL, &Stat1);
1449
		Stat2 = 0;
1450
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_STAT, &PhyStat);
1451
		Stat1 = Stat1 << 16 | PhyStat;
1452
		Stat2 = 0;
1453
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUNE_ADV, &Stat2);
1454
		Stat3 = 0;
1455
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUNE_LP, &Stat3);
1456
		Stat2 = Stat2 << 16 | Stat3;
1457
		CMSMPrintString(
1458
			pAC->pConfigTable,
1459
			MSG_TYPE_RUNTIME_INFO,
1460
			"Ctrl/Stat: %x, AN Adv/LP: %x",
1461
			(void *)Stat1,
1462
			(void *)Stat2);
1463
1464
		Stat1 = 0;
1465
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUNE_EXP, &Stat1);
1466
		Stat2 = 0;
1467
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_EXT_STAT, &Stat2);
1468
		Stat1 = Stat1 << 16 | Stat2;
1469
		Stat2 = 0;
1470
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_1000T_CTRL, &Stat2);
1471
		Stat3 = 0;
1472
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_1000T_STAT, &ResAb);
1473
		Stat2 = Stat2 << 16 | ResAb;
1474
		CMSMPrintString(
1475
			pAC->pConfigTable,
1476
			MSG_TYPE_RUNTIME_INFO,
1477
			"AN Exp/IEEE Ext: %x, 1000T Ctrl/Stat: %x",
1478
			(void *)Stat1,
1479
			(void *)Stat2);
1480
1481
		Stat1 = 0;
1482
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_P_EXT_CTRL, &Stat1);
1483
		Stat2 = 0;
1484
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_P_EXT_STAT, &Stat2);
1485
		Stat1 = Stat1 << 16 | Stat2;
1486
		Stat2 = 0;
1487
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_CTRL, &Stat2);
1488
		Stat3 = 0;
1489
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_STAT, &Stat3);
1490
		Stat2 = Stat2 << 16 | Stat3;
1491
		CMSMPrintString(
1492
			pAC->pConfigTable,
1493
			MSG_TYPE_RUNTIME_INFO,
1494
			"PHY Ext Ctrl/Stat: %x, Aux Ctrl/Stat: %x",
1495
			(void *)Stat1,
1496
			(void *)Stat2);
1497
	}
1498
#endif /* DEBUG */
1499
1500
	/*
1778
	/*
1501
	 * Here we usually can check whether the link is in sync and
1779
	 * Here we usually can check whether the link is in sync and
1502
	 * auto-negotiation is done.
1780
	 * auto-negotiation is done.
Lines 1505-1511 Link Here
1505
	SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_STAT, &PhyStat);
1783
	SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_STAT, &PhyStat);
1506
1784
1507
	SkMacAutoNegLipaPhy(pAC, IoC, Port, PhyStat);
1785
	SkMacAutoNegLipaPhy(pAC, IoC, Port, PhyStat);
1508
	
1786
1509
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1787
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1510
		("CheckUp Port %d, PhyStat: 0x%04X\n", Port, PhyStat));
1788
		("CheckUp Port %d, PhyStat: 0x%04X\n", Port, PhyStat));
1511
1789
Lines 1513-1600 Link Here
1513
1791
1514
	if ((ResAb & PHY_B_1000S_MSF) != 0) {
1792
	if ((ResAb & PHY_B_1000S_MSF) != 0) {
1515
		/* Error */
1793
		/* Error */
1516
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1794
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
1517
			("Master/Slave Fault port %d\n", Port));
1795
			("Master/Slave Fault, ResAb: 0x%04X\n", ResAb));
1518
		
1796
1519
		pPrt->PAutoNegFail = SK_TRUE;
1797
		pPrt->PAutoNegFail = SK_TRUE;
1520
		pPrt->PMSStatus = SK_MS_STAT_FAULT;
1798
		pPrt->PMSStatus = SK_MS_STAT_FAULT;
1521
		
1799
1522
		return(SK_HW_PS_RESTART);
1800
		return(SK_HW_PS_RESTART);
1523
	}
1801
	}
1524
1802
1525
	if ((PhyStat & PHY_ST_LSYNC) == 0) {
1803
	if ((PhyStat & PHY_ST_LSYNC) == 0) {
1526
		return(SK_HW_PS_NONE);
1804
		return(SK_HW_PS_NONE);
1527
	}
1805
	}
1528
	
1806
1529
	pPrt->PMSStatus = ((ResAb & PHY_B_1000S_MSR) != 0) ?
1807
	pPrt->PMSStatus = ((ResAb & PHY_B_1000S_MSR) != 0) ?
1530
		SK_MS_STAT_MASTER : SK_MS_STAT_SLAVE;
1808
		SK_MS_STAT_MASTER : SK_MS_STAT_SLAVE;
1531
	
1809
1532
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1810
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1533
		("Port %d, ResAb: 0x%04X\n", Port, ResAb));
1811
		("Port %d, ResAb: 0x%04X\n", Port, ResAb));
1534
1812
1535
	if (AutoNeg) {
1813
	if (AutoNeg) {
1814
		/* Auto-Negotiation Over ? */
1536
		if ((PhyStat & PHY_ST_AN_OVER) != 0) {
1815
		if ((PhyStat & PHY_ST_AN_OVER) != 0) {
1537
			
1816
1538
			SkHWLinkUp(pAC, IoC, Port);
1817
			SkHWLinkUp(pAC, IoC, Port);
1539
			
1818
1540
			Done = SkMacAutoNegDone(pAC, IoC, Port);
1819
			Done = SkMacAutoNegDone(pAC, IoC, Port);
1541
			
1820
1542
			if (Done != SK_AND_OK) {
1821
			if (Done != SK_AND_OK) {
1543
#ifdef DEBUG
1822
#ifdef DEBUG
1544
				/* Get PHY parameters, for debugging only */
1823
				/* Get PHY parameters, for debugging only */
1545
				SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUNE_LP, &LpAb);
1824
				SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUNE_LP, &LpAb);
1546
				SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_1000T_STAT, &ExtStat);
1825
				SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_1000T_STAT, &ExtStat);
1547
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1826
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
1548
					("AutoNeg FAIL Port %d (LpAb %x, 1000TStat %x)\n",
1827
					("AutoNeg FAIL Port %d (LpAb %x, 1000TStat %x)\n",
1549
					Port, LpAb, ExtStat));
1828
					Port, LpAb, ExtStat));
1550
#endif /* DEBUG */
1829
#endif /* DEBUG */
1551
				return(SK_HW_PS_RESTART);
1830
				return(SK_HW_PS_RESTART);
1552
			}
1831
			}
1553
			else {
1832
			else {
1554
#ifdef xDEBUG
1555
				/* Dummy read ISR to prevent extra link downs/ups */
1556
				SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &ExtStat);
1557
1558
				if ((ExtStat & ~(PHY_B_IS_HCT | PHY_B_IS_LCT)) != 0) {
1559
					CMSMPrintString(
1560
						pAC->pConfigTable,
1561
						MSG_TYPE_RUNTIME_INFO,
1562
						"CheckUp2 - Stat: %x",
1563
						(void *)ExtStat,
1564
						(void *)NULL);
1565
				}
1566
#endif /* DEBUG */
1567
				return(SK_HW_PS_LINK);
1833
				return(SK_HW_PS_LINK);
1568
			}
1834
			}
1569
		}
1835
		}
1570
	}
1836
	}
1571
	else {	/* !AutoNeg */
1837
	else {	/* !AutoNeg */
1572
		/* Link is up and we don't need more. */
1838
		/* Link is up and we don't need more */
1573
#ifdef DEBUG
1839
#ifdef DEBUG
1574
		if (pPrt->PLipaAutoNeg == SK_LIPA_AUTO) {
1840
		if (pPrt->PLipaAutoNeg == (SK_U8)SK_LIPA_AUTO) {
1575
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1841
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
1576
				("ERROR: Lipa auto detected on port %d\n", Port));
1842
				("ERROR: Lipa auto detected on port %d\n", Port));
1577
		}
1843
		}
1578
#endif /* DEBUG */
1844
#endif /* DEBUG */
1579
1845
1580
#ifdef xDEBUG
1581
		/* Dummy read ISR to prevent extra link downs/ups */
1582
		SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &ExtStat);
1583
1584
		if ((ExtStat & ~(PHY_B_IS_HCT | PHY_B_IS_LCT)) != 0) {
1585
			CMSMPrintString(
1586
				pAC->pConfigTable,
1587
				MSG_TYPE_RUNTIME_INFO,
1588
				"CheckUp3 - Stat: %x",
1589
				(void *)ExtStat,
1590
				(void *)NULL);
1591
		}
1592
#endif /* DEBUG */
1593
		
1594
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1846
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1595
			("Link sync(GP), Port %d\n", Port));
1847
			("Link sync(GP), Port %d\n", Port));
1596
		SkHWLinkUp(pAC, IoC, Port);
1848
		SkHWLinkUp(pAC, IoC, Port);
1597
		
1849
1598
		return(SK_HW_PS_LINK);
1850
		return(SK_HW_PS_LINK);
1599
	}
1851
	}
1600
1852
Lines 1615-1634 Link Here
1615
 */
1867
 */
1616
static int SkGePortCheckUpGmac(
1868
static int SkGePortCheckUpGmac(
1617
SK_AC	*pAC,		/* Adapter Context */
1869
SK_AC	*pAC,		/* Adapter Context */
1618
SK_IOC	IoC,		/* IO Context */
1870
SK_IOC	IoC,		/* I/O Context */
1619
int		Port,		/* Which port should be checked */
1871
int		Port,		/* Port Index (MAC_1 + n) */
1620
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
1872
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
1621
{
1873
{
1622
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
1874
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
1623
	int			Done;
1875
	int			Done;
1624
	SK_U16		PhyIsrc;	/* PHY Interrupt source */
1876
	SK_U16		PhyStat;	/* PHY Status */
1625
	SK_U16		PhyStat;	/* PPY Status */
1626
	SK_U16		PhySpecStat;/* PHY Specific Status */
1877
	SK_U16		PhySpecStat;/* PHY Specific Status */
1627
	SK_U16		ResAb;		/* Master/Slave resolution */
1878
	SK_U16		ResAb;		/* Master/Slave resolution */
1628
	SK_EVPARA	Para;
1879
	SK_EVPARA	Para;
1629
#ifdef DEBUG
1630
	SK_U16		Word;		/* I/O helper */
1880
	SK_U16		Word;		/* I/O helper */
1631
#endif /* DEBUG */
1632
1881
1633
	pPrt = &pAC->GIni.GP[Port];
1882
	pPrt = &pAC->GIni.GP[Port];
1634
1883
Lines 1642-1735 Link Here
1642
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1891
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1643
		("CheckUp Port %d, PhyStat: 0x%04X\n", Port, PhyStat));
1892
		("CheckUp Port %d, PhyStat: 0x%04X\n", Port, PhyStat));
1644
1893
1645
	/* Read PHY Interrupt Status */
1894
	SkMacAutoNegLipaPhy(pAC, IoC, Port, PhyStat);
1646
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_INT_STAT, &PhyIsrc);
1647
1895
1648
	if ((PhyIsrc & PHY_M_IS_AN_COMPL) != 0) {
1896
	if ((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS) != 0) {
1649
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1650
			("Auto-Negotiation Completed, PhyIsrc: 0x%04X\n", PhyIsrc));
1651
	}
1652
1897
1653
	if ((PhyIsrc & PHY_M_IS_LSP_CHANGE) != 0) {
1898
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_1000T_STAT, &ResAb);
1654
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1655
			("Link Speed Changed, PhyIsrc: 0x%04X\n", PhyIsrc));
1656
	}
1657
1899
1658
	SkMacAutoNegLipaPhy(pAC, IoC, Port, PhyStat);
1900
		if ((ResAb & PHY_B_1000S_MSF) != 0) {
1659
	
1901
			/* Error */
1660
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_1000T_STAT, &ResAb);
1902
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
1903
				("Master/Slave Fault, ResAb: 0x%04X\n", ResAb));
1661
1904
1662
	if ((ResAb & PHY_B_1000S_MSF) != 0) {
1905
			pPrt->PAutoNegFail = SK_TRUE;
1663
		/* Error */
1906
			pPrt->PMSStatus = SK_MS_STAT_FAULT;
1664
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1907
1665
			("Master/Slave Fault port %d\n", Port));
1908
			return(SK_HW_PS_RESTART);
1666
		
1909
		}
1667
		pPrt->PAutoNegFail = SK_TRUE;
1668
		pPrt->PMSStatus = SK_MS_STAT_FAULT;
1669
		
1670
		return(SK_HW_PS_RESTART);
1671
	}
1910
	}
1672
1911
1673
	/* Read PHY Specific Status */
1912
	/* Read PHY Specific Status */
1674
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_STAT, &PhySpecStat);
1913
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_STAT, &PhySpecStat);
1675
	
1914
1676
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1915
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1677
		("Phy1000BT: 0x%04X, PhySpecStat: 0x%04X\n", ResAb, PhySpecStat));
1916
		("Phy1000BT: 0x%04X, PhySpecStat: 0x%04X\n", ResAb, PhySpecStat));
1678
1917
1679
#ifdef DEBUG
1918
#ifdef DEBUG
1680
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_EXP, &Word);
1919
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_EXP, &Word);
1681
1920
1682
	if ((PhyIsrc & PHY_M_IS_AN_PR) != 0 || (Word & PHY_ANE_RX_PG) != 0 ||
1921
	if ((Word & PHY_ANE_RX_PG) != 0 ||
1683
		(PhySpecStat & PHY_M_PS_PAGE_REC) != 0)  {
1922
		(PhySpecStat & PHY_M_PS_PAGE_REC) != 0)  {
1684
		/* Read PHY Next Page Link Partner */
1923
		/* Read PHY Next Page Link Partner */
1685
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_NEPG_LP, &Word);
1924
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_NEPG_LP, &Word);
1686
1925
1687
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1926
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1688
			("Page Received, NextPage: 0x%04X\n", Word));
1927
			("Page received, NextPage: 0x%04X\n", Word));
1689
	}
1928
	}
1690
#endif /* DEBUG */
1929
#endif /* DEBUG */
1691
1930
1692
	if ((PhySpecStat & PHY_M_PS_LINK_UP) == 0) {
1931
	if ((PhySpecStat & PHY_M_PS_LINK_UP) == 0) {
1932
		/* Link down */
1693
		return(SK_HW_PS_NONE);
1933
		return(SK_HW_PS_NONE);
1694
	}
1934
	}
1695
	
1935
1696
	if ((PhySpecStat & PHY_M_PS_DOWNS_STAT) != 0 ||
1936
#ifdef XXX
1697
		(PhyIsrc & PHY_M_IS_DOWNSH_DET) != 0) {
1937
	SK_U16		PhyInt;
1698
		/* Downshift detected */
1938
	/* Read PHY Interrupt Status */
1699
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E025, SKERR_SIRQ_E025MSG);
1939
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_INT_STAT, &PhyInt);
1700
		
1940
1701
		Para.Para64 = Port;
1941
	/* cross check that the link is really up */
1702
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_DOWNSHIFT_DET, Para);
1942
	if ((PhyInt & PHY_M_IS_LST_CHANGE) == 0) {
1703
		
1943
		/* Link Status unchanged */
1704
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1944
		return(SK_HW_PS_NONE);
1705
			("Downshift detected, PhyIsrc: 0x%04X\n", PhyIsrc));
1706
	}
1945
	}
1946
#endif /* XXX */
1707
1947
1708
	pPrt->PMSStatus = ((ResAb & PHY_B_1000S_MSR) != 0) ?
1948
	if (pAC->GIni.GICopperType) {
1709
		SK_MS_STAT_MASTER : SK_MS_STAT_SLAVE;
1949
1950
		if ((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS) != 0) {
1951
1952
			if ((PhySpecStat & PHY_M_PS_DOWNS_STAT) != 0) {
1953
				/* Downshift detected */
1954
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E025,
1955
					SKERR_SIRQ_E025MSG);
1956
	
1957
				Para.Para64 = Port;
1958
				SkEventQueue(pAC, SKGE_DRV, SK_DRV_DOWNSHIFT_DET, Para);
1710
	
1959
	
1711
	pPrt->PCableLen = (SK_U8)((PhySpecStat & PHY_M_PS_CABLE_MSK) >> 7);
1960
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1961
					("Downshift detected, PhySpecStat: 0x%04X\n", PhySpecStat));
1962
			}
1963
1964
			pPrt->PMSStatus = ((ResAb & PHY_B_1000S_MSR) != 0) ?
1965
				SK_MS_STAT_MASTER : SK_MS_STAT_SLAVE;
1966
		}
1712
	
1967
	
1968
		if ((PhySpecStat & PHY_M_PS_MDI_X_STAT) != 0) {
1969
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1970
				("MDI Xover detected, PhyStat: 0x%04X\n", PhySpecStat));
1971
		}
1972
1973
		/* on PHY 88E1112 cable length is in Reg. 26, Page 5 */
1974
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) {
1975
			/* save page register */
1976
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_ADR, &Word);
1977
1978
			/* select page 5 to access VCT DSP distance register */
1979
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 5);
1980
1981
			/* get VCT DSP distance */
1982
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_CTRL_2, &PhySpecStat);
1983
1984
			/* restore page register */
1985
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, Word);
1986
1987
			pPrt->PCableLen = (SK_U8)(PhySpecStat & PHY_M_EC2_FO_AM_MSK);
1988
		}
1989
		else {
1990
			pPrt->PCableLen = (SK_U8)((PhySpecStat & PHY_M_PS_CABLE_MSK) >> 7);
1991
		}
1992
	}
1993
1713
	if (AutoNeg) {
1994
	if (AutoNeg) {
1714
		/* Auto-Negotiation Over ? */
1995
		/* Auto-Negotiation Complete ? */
1715
		if ((PhyStat & PHY_ST_AN_OVER) != 0) {
1996
		if ((PhyStat & PHY_ST_AN_OVER) != 0) {
1716
			
1997
1717
			SkHWLinkUp(pAC, IoC, Port);
1998
			SkHWLinkUp(pAC, IoC, Port);
1718
			
1999
1719
			Done = SkMacAutoNegDone(pAC, IoC, Port);
2000
			Done = SkMacAutoNegDone(pAC, IoC, Port);
1720
			
2001
1721
			if (Done != SK_AND_OK) {
2002
			if (Done != SK_AND_OK) {
1722
				return(SK_HW_PS_RESTART);
2003
				return(SK_HW_PS_RESTART);
1723
			}
2004
			}
1724
			
2005
1725
			return(SK_HW_PS_LINK);
2006
			return(SK_HW_PS_LINK);
1726
		}
2007
		}
1727
	}
2008
	}
1728
	else {	/* !AutoNeg */
2009
	else {	/* !AutoNeg */
1729
		/* Link is up and we don't need more */
1730
#ifdef DEBUG
2010
#ifdef DEBUG
1731
		if (pPrt->PLipaAutoNeg == SK_LIPA_AUTO) {
2011
		if (pPrt->PLipaAutoNeg == (SK_U8)SK_LIPA_AUTO) {
1732
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2012
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
1733
				("ERROR: Lipa auto detected on port %d\n", Port));
2013
				("ERROR: Lipa auto detected on port %d\n", Port));
1734
		}
2014
		}
1735
#endif /* DEBUG */
2015
#endif /* DEBUG */
Lines 1737-1743 Link Here
1737
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
2017
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1738
			("Link sync, Port %d\n", Port));
2018
			("Link sync, Port %d\n", Port));
1739
		SkHWLinkUp(pAC, IoC, Port);
2019
		SkHWLinkUp(pAC, IoC, Port);
1740
		
2020
1741
		return(SK_HW_PS_LINK);
2021
		return(SK_HW_PS_LINK);
1742
	}
2022
	}
1743
2023
Lines 1758-1765 Link Here
1758
 */
2038
 */
1759
static int SkGePortCheckUpLone(
2039
static int SkGePortCheckUpLone(
1760
SK_AC	*pAC,		/* Adapter Context */
2040
SK_AC	*pAC,		/* Adapter Context */
1761
SK_IOC	IoC,		/* IO Context */
2041
SK_IOC	IoC,		/* I/O Context */
1762
int		Port,		/* Which port should be checked */
2042
int		Port,		/* Port Index (MAC_1 + n) */
1763
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
2043
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
1764
{
2044
{
1765
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
2045
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
Lines 1788-1794 Link Here
1788
	StatSum |= PhyStat;
2068
	StatSum |= PhyStat;
1789
2069
1790
	SkMacAutoNegLipaPhy(pAC, IoC, Port, PhyStat);
2070
	SkMacAutoNegLipaPhy(pAC, IoC, Port, PhyStat);
1791
	
2071
1792
	if ((PhyStat & PHY_ST_LSYNC) == 0) {
2072
	if ((PhyStat & PHY_ST_LSYNC) == 0) {
1793
		/* Save Auto-negotiation Done bit */
2073
		/* Save Auto-negotiation Done bit */
1794
		pPrt->PIsave = (SK_U16)(StatSum & PHY_ST_AN_OVER);
2074
		pPrt->PIsave = (SK_U16)(StatSum & PHY_ST_AN_OVER);
Lines 1802-1818 Link Here
1802
	}
2082
	}
1803
2083
1804
	if (AutoNeg) {
2084
	if (AutoNeg) {
2085
		/* Auto-Negotiation Over ? */
1805
		if ((StatSum & PHY_ST_AN_OVER) != 0) {
2086
		if ((StatSum & PHY_ST_AN_OVER) != 0) {
2087
1806
			SkHWLinkUp(pAC, IoC, Port);
2088
			SkHWLinkUp(pAC, IoC, Port);
2089
1807
			Done = SkMacAutoNegDone(pAC, IoC, Port);
2090
			Done = SkMacAutoNegDone(pAC, IoC, Port);
2091
1808
			if (Done != SK_AND_OK) {
2092
			if (Done != SK_AND_OK) {
1809
				/* Get PHY parameters, for debugging only */
2093
				/* Get PHY parameters, for debugging only */
1810
				SkXmPhyRead(pAC, IoC, Port, PHY_LONE_AUNE_LP, &LpAb);
2094
				SkXmPhyRead(pAC, IoC, Port, PHY_LONE_AUNE_LP, &LpAb);
1811
				SkXmPhyRead(pAC, IoC, Port, PHY_LONE_1000T_STAT, &ExtStat);
2095
				SkXmPhyRead(pAC, IoC, Port, PHY_LONE_1000T_STAT, &ExtStat);
1812
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2096
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
1813
					("AutoNeg FAIL Port %d (LpAb %x, 1000TStat %x)\n",
2097
					("AutoNeg FAIL Port %d (LpAb %x, 1000TStat %x)\n",
1814
					 Port, LpAb, ExtStat));
2098
					 Port, LpAb, ExtStat));
1815
					
2099
1816
				/* Try next possible mode */
2100
				/* Try next possible mode */
1817
				NextMode = SkHWSenseGetNext(pAC, IoC, Port);
2101
				NextMode = SkHWSenseGetNext(pAC, IoC, Port);
1818
				SkHWLinkDown(pAC, IoC, Port);
2102
				SkHWLinkDown(pAC, IoC, Port);
Lines 1833-1847 Link Here
1833
				return(SK_HW_PS_LINK);
2117
				return(SK_HW_PS_LINK);
1834
			}
2118
			}
1835
		}
2119
		}
1836
		
2120
1837
		/* AutoNeg not done, but HW link is up. Check for timeouts */
2121
		/* AutoNeg not done, but HW link is up. Check for timeouts */
1838
		pPrt->PAutoNegTimeOut++;
2122
		if (pPrt->PAutoNegTimeOut++ >= SK_AND_MAX_TO) {
1839
		if (pPrt->PAutoNegTimeOut >= SK_AND_MAX_TO) {
1840
			/* Timeout occured */
2123
			/* Timeout occured */
1841
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
2124
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1842
				("AutoNeg timeout Port %d\n", Port));
2125
				("AutoNeg timeout Port %d\n", Port));
1843
			if (pPrt->PLinkModeConf == SK_LMODE_AUTOSENSE &&
2126
			if (pPrt->PLinkModeConf == (SK_U8)SK_LMODE_AUTOSENSE &&
1844
				pPrt->PLipaAutoNeg != SK_LIPA_AUTO) {
2127
				pPrt->PLipaAutoNeg != (SK_U8)SK_LIPA_AUTO) {
1845
				/* Set Link manually up */
2128
				/* Set Link manually up */
1846
				SkHWSenseSetNext(pAC, IoC, Port, SK_LMODE_FULL);
2129
				SkHWSenseSetNext(pAC, IoC, Port, SK_LMODE_FULL);
1847
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
2130
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
Lines 1855-1862 Link Here
1855
	else {
2138
	else {
1856
		/* Link is up and we don't need more */
2139
		/* Link is up and we don't need more */
1857
#ifdef DEBUG
2140
#ifdef DEBUG
1858
		if (pPrt->PLipaAutoNeg == SK_LIPA_AUTO) {
2141
		if (pPrt->PLipaAutoNeg == (SK_U8)SK_LIPA_AUTO) {
1859
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2142
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
1860
				("ERROR: Lipa auto detected on port %d\n", Port));
2143
				("ERROR: Lipa auto detected on port %d\n", Port));
1861
		}
2144
		}
1862
#endif /* DEBUG */
2145
#endif /* DEBUG */
Lines 1866-1876 Link Here
1866
		 * extra link down/ups
2149
		 * extra link down/ups
1867
		 */
2150
		 */
1868
		SkXmPhyRead(pAC, IoC, Port, PHY_LONE_INT_STAT, &ExtStat);
2151
		SkXmPhyRead(pAC, IoC, Port, PHY_LONE_INT_STAT, &ExtStat);
1869
		
2152
1870
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
2153
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
1871
			("Link sync(GP), Port %d\n", Port));
2154
			("Link sync(GP), Port %d\n", Port));
2155
1872
		SkHWLinkUp(pAC, IoC, Port);
2156
		SkHWLinkUp(pAC, IoC, Port);
1873
		
2157
1874
		return(SK_HW_PS_LINK);
2158
		return(SK_HW_PS_LINK);
1875
	}
2159
	}
1876
2160
Lines 1889-1896 Link Here
1889
 */
2173
 */
1890
static int SkGePortCheckUpNat(
2174
static int SkGePortCheckUpNat(
1891
SK_AC	*pAC,		/* Adapter Context */
2175
SK_AC	*pAC,		/* Adapter Context */
1892
SK_IOC	IoC,		/* IO Context */
2176
SK_IOC	IoC,		/* I/O Context */
1893
int		Port,		/* Which port should be checked */
2177
int		Port,		/* Port Index (MAC_1 + n) */
1894
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
2178
SK_BOOL	AutoNeg)	/* Is Auto-negotiation used ? */
1895
{
2179
{
1896
	/* todo: National */
2180
	/* todo: National */
Lines 1909-1920 Link Here
1909
 */
2193
 */
1910
int	SkGeSirqEvent(
2194
int	SkGeSirqEvent(
1911
SK_AC		*pAC,		/* Adapter Context */
2195
SK_AC		*pAC,		/* Adapter Context */
1912
SK_IOC		IoC,		/* Io Context */
2196
SK_IOC		IoC,		/* I/O Context */
1913
SK_U32		Event,		/* Module specific Event */
2197
SK_U32		Event,		/* Module specific Event */
1914
SK_EVPARA	Para)		/* Event specific Parameter */
2198
SK_EVPARA	Para)		/* Event specific Parameter */
1915
{
2199
{
1916
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
2200
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
1917
	SK_U32		Port;
2201
	int			Port;
1918
	SK_U32		Val32;
2202
	SK_U32		Val32;
1919
	int			PortStat;
2203
	int			PortStat;
1920
	SK_U8		Val8;
2204
	SK_U8		Val8;
Lines 1922-1946 Link Here
1922
	SK_U64		Octets;
2206
	SK_U64		Octets;
1923
#endif /* GENESIS */
2207
#endif /* GENESIS */
1924
2208
1925
	Port = Para.Para32[0];
2209
	Port = (int)Para.Para32[0];
1926
	pPrt = &pAC->GIni.GP[Port];
2210
	pPrt = &pAC->GIni.GP[Port];
1927
2211
1928
	switch (Event) {
2212
	switch (Event) {
1929
	case SK_HWEV_WATIM:
2213
	case SK_HWEV_WATIM:
1930
		if (pPrt->PState == SK_PRT_RESET) {
2214
		if (pPrt->PState == SK_PRT_RESET) {
1931
		
2215
1932
			PortStat = SK_HW_PS_NONE;
2216
			PortStat = SK_HW_PS_NONE;
1933
		}
2217
		}
1934
		else {
2218
		else {
1935
			/* Check whether port came up */
2219
			/* Check whether port came up */
1936
			PortStat = SkGePortCheckUp(pAC, IoC, (int)Port);
2220
			PortStat = SkGePortCheckUp(pAC, IoC, Port);
1937
		}
2221
		}
1938
2222
1939
		switch (PortStat) {
2223
		switch (PortStat) {
1940
		case SK_HW_PS_RESTART:
2224
		case SK_HW_PS_RESTART:
1941
			if (pPrt->PHWLinkUp) {
2225
			if (pPrt->PHWLinkUp) {
1942
				/* Set Link to down */
2226
				/* Set Link to down */
1943
				SkHWLinkDown(pAC, IoC, (int)Port);
2227
				SkHWLinkDown(pAC, IoC, Port);
1944
2228
1945
				/*
2229
				/*
1946
				 * Signal directly to RLMT to ensure correct
2230
				 * Signal directly to RLMT to ensure correct
Lines 1958-1976 Link Here
1958
			SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_UP, Para);
2242
			SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_UP, Para);
1959
			break;
2243
			break;
1960
		}
2244
		}
1961
		
2245
1962
		/* Start again the check Timer */
2246
		/* Start again the check Timer */
1963
		if (pPrt->PHWLinkUp) {
2247
		if (pPrt->PHWLinkUp) {
2248
1964
			Val32 = SK_WA_ACT_TIME;
2249
			Val32 = SK_WA_ACT_TIME;
1965
		}
2250
		}
1966
		else {
2251
		else {
1967
			Val32 = SK_WA_INA_TIME;
2252
			Val32 = SK_WA_INA_TIME;
1968
		}
1969
2253
1970
		/* Todo: still needed for non-XMAC PHYs??? */
2254
			if (pAC->GIni.GIYukon) {
2255
				Val32 *= 5;
2256
			}
2257
		}
1971
		/* Start workaround Errata #2 timer */
2258
		/* Start workaround Errata #2 timer */
1972
		SkTimerStart(pAC, IoC, &pPrt->PWaTimer, Val32,
2259
		SkTimerStart(pAC, IoC, &pPrt->PWaTimer, Val32,
1973
			SKGE_HWAC, SK_HWEV_WATIM, Para);
2260
			SKGE_HWAC, SK_HWEV_WATIM, Para);
2261
1974
		break;
2262
		break;
1975
2263
1976
	case SK_HWEV_PORT_START:
2264
	case SK_HWEV_PORT_START:
Lines 1982-1988 Link Here
1982
			SkRlmtEvent(pAC, IoC, SK_RLMT_LINK_DOWN, Para);
2270
			SkRlmtEvent(pAC, IoC, SK_RLMT_LINK_DOWN, Para);
1983
		}
2271
		}
1984
2272
1985
		SkHWLinkDown(pAC, IoC, (int)Port);
2273
		SkHWLinkDown(pAC, IoC, Port);
1986
2274
1987
		/* Schedule Port RESET */
2275
		/* Schedule Port RESET */
1988
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, Para);
2276
		SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, Para);
Lines 1990-1995 Link Here
1990
		/* Start workaround Errata #2 timer */
2278
		/* Start workaround Errata #2 timer */
1991
		SkTimerStart(pAC, IoC, &pPrt->PWaTimer, SK_WA_INA_TIME,
2279
		SkTimerStart(pAC, IoC, &pPrt->PWaTimer, SK_WA_INA_TIME,
1992
			SKGE_HWAC, SK_HWEV_WATIM, Para);
2280
			SKGE_HWAC, SK_HWEV_WATIM, Para);
2281
1993
		break;
2282
		break;
1994
2283
1995
	case SK_HWEV_PORT_STOP:
2284
	case SK_HWEV_PORT_STOP:
Lines 2004-2010 Link Here
2004
		/* Stop Workaround Timer */
2293
		/* Stop Workaround Timer */
2005
		SkTimerStop(pAC, IoC, &pPrt->PWaTimer);
2294
		SkTimerStop(pAC, IoC, &pPrt->PWaTimer);
2006
2295
2007
		SkHWLinkDown(pAC, IoC, (int)Port);
2296
		SkHWLinkDown(pAC, IoC, Port);
2008
		break;
2297
		break;
2009
2298
2010
	case SK_HWEV_UPDATE_STAT:
2299
	case SK_HWEV_UPDATE_STAT:
Lines 2013-2019 Link Here
2013
2302
2014
	case SK_HWEV_CLEAR_STAT:
2303
	case SK_HWEV_CLEAR_STAT:
2015
		/* We do NOT need to clear any statistics */
2304
		/* We do NOT need to clear any statistics */
2016
		for (Port = 0; Port < (SK_U32)pAC->GIni.GIMacsFound; Port++) {
2305
		for (Port = 0; Port < pAC->GIni.GIMacsFound; Port++) {
2017
			pPrt->PPrevRx = 0;
2306
			pPrt->PPrevRx = 0;
2018
			pPrt->PPrevFcs = 0;
2307
			pPrt->PPrevFcs = 0;
2019
			pPrt->PPrevShorts = 0;
2308
			pPrt->PPrevShorts = 0;
Lines 2085-2107 Link Here
2085
			pPrt->HalfDupTimerActive = SK_FALSE;
2374
			pPrt->HalfDupTimerActive = SK_FALSE;
2086
			if (pPrt->PLinkModeStatus == SK_LMODE_STAT_HALF ||
2375
			if (pPrt->PLinkModeStatus == SK_LMODE_STAT_HALF ||
2087
				pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOHALF) {
2376
				pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOHALF) {
2088
#ifdef XXX
2377
2089
				Len = sizeof(SK_U64);
2090
				SkPnmiGetVar(pAC, IoC, OID_SKGE_STAT_TX_OCTETS, (char *)&Octets,
2091
					&Len, (SK_U32)SK_PNMI_PORT_PHYS2INST(pAC, Port),
2092
					pAC->Rlmt.Port[Port].Net->NetNumber);
2093
#endif /* XXX */
2094
				/* Snap statistic counters */
2378
				/* Snap statistic counters */
2095
				(void)SkXmUpdateStats(pAC, IoC, Port);
2379
				(void)SkXmUpdateStats(pAC, IoC, Port);
2096
2380
2097
				(void)SkXmMacStatistic(pAC, IoC, Port, XM_TXO_OK_HI, &Val32);
2381
				(void)SkXmMacStatistic(pAC, IoC, Port, XM_TXO_OK_HI, &Val32);
2098
2382
2099
				Octets = (SK_U64)Val32 << 32;
2383
				Octets = (SK_U64)Val32 << 32;
2100
				
2384
2101
				(void)SkXmMacStatistic(pAC, IoC, Port, XM_TXO_OK_LO, &Val32);
2385
				(void)SkXmMacStatistic(pAC, IoC, Port, XM_TXO_OK_LO, &Val32);
2102
2386
2103
				Octets += Val32;
2387
				Octets += Val32;
2104
				
2388
2105
				if (pPrt->LastOctets == Octets) {
2389
				if (pPrt->LastOctets == Octets) {
2106
					/* Tx hanging, a FIFO flush restarts it */
2390
					/* Tx hanging, a FIFO flush restarts it */
2107
					SkMacFlushTxFifo(pAC, IoC, Port);
2391
					SkMacFlushTxFifo(pAC, IoC, Port);
Lines 2110-2116 Link Here
2110
		}
2394
		}
2111
		break;
2395
		break;
2112
#endif /* GENESIS */
2396
#endif /* GENESIS */
2113
	
2397
2114
	default:
2398
	default:
2115
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_SIRQ_E001, SKERR_SIRQ_E001MSG);
2399
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_SIRQ_E001, SKERR_SIRQ_E001MSG);
2116
		break;
2400
		break;
Lines 2131-2138 Link Here
2131
 */
2415
 */
2132
static void SkPhyIsrBcom(
2416
static void SkPhyIsrBcom(
2133
SK_AC		*pAC,		/* Adapter Context */
2417
SK_AC		*pAC,		/* Adapter Context */
2134
SK_IOC		IoC,		/* Io Context */
2418
SK_IOC		IoC,		/* I/O Context */
2135
int			Port,		/* Port Num = PHY Num */
2419
int			Port,		/* Port Index (MAC_1 + n) */
2136
SK_U16		IStatus)	/* Interrupt Status */
2420
SK_U16		IStatus)	/* Interrupt Status */
2137
{
2421
{
2138
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
2422
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
Lines 2145-2151 Link Here
2145
		SK_ERR_LOG(pAC, SK_ERRCL_HW | SK_ERRCL_INIT, SKERR_SIRQ_E022,
2429
		SK_ERR_LOG(pAC, SK_ERRCL_HW | SK_ERRCL_INIT, SKERR_SIRQ_E022,
2146
			SKERR_SIRQ_E022MSG);
2430
			SKERR_SIRQ_E022MSG);
2147
	}
2431
	}
2148
	
2432
2149
	if ((IStatus & (PHY_B_IS_AN_PR | PHY_B_IS_LST_CHANGE)) != 0) {
2433
	if ((IStatus & (PHY_B_IS_AN_PR | PHY_B_IS_LST_CHANGE)) != 0) {
2150
2434
2151
		SkHWLinkDown(pAC, IoC, Port);
2435
		SkHWLinkDown(pAC, IoC, Port);
Lines 2174-2181 Link Here
2174
 */
2458
 */
2175
static void SkPhyIsrGmac(
2459
static void SkPhyIsrGmac(
2176
SK_AC		*pAC,		/* Adapter Context */
2460
SK_AC		*pAC,		/* Adapter Context */
2177
SK_IOC		IoC,		/* Io Context */
2461
SK_IOC		IoC,		/* I/O Context */
2178
int			Port,		/* Port Num = PHY Num */
2462
int			Port,		/* Port Index (MAC_1 + n) */
2179
SK_U16		IStatus)	/* Interrupt Status */
2463
SK_U16		IStatus)	/* Interrupt Status */
2180
{
2464
{
2181
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
2465
	SK_GEPORT	*pPrt;		/* GIni Port struct pointer */
Lines 2184-2220 Link Here
2184
2468
2185
	pPrt = &pAC->GIni.GP[Port];
2469
	pPrt = &pAC->GIni.GP[Port];
2186
2470
2187
	if ((IStatus & (PHY_M_IS_AN_PR | PHY_M_IS_LST_CHANGE)) != 0) {
2471
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2188
2472
		("Port %d PHY IRQ, PhyIsrc: 0x%04X\n", Port, IStatus));
2189
		SkHWLinkDown(pAC, IoC, Port);
2190
2473
2191
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_ADV, &Word);
2474
	if ((IStatus & PHY_M_IS_LST_CHANGE) != 0) {
2192
2475
2193
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2476
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2194
			("AutoNeg.Adv: 0x%04X\n", Word));
2477
			("Link Status changed\n"));
2195
		
2478
2196
		/* Set Auto-negotiation advertisement */
2197
		if (pPrt->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM) {
2198
			/* restore Asymmetric Pause bit */
2199
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_AUNE_ADV,
2200
				(SK_U16)(Word | PHY_M_AN_ASP));
2201
		}
2202
		
2203
		Para.Para32[0] = (SK_U32)Port;
2479
		Para.Para32[0] = (SK_U32)Port;
2204
		/* Signal to RLMT */
2480
2205
		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
2481
		if (pPrt->PHWLinkUp) {
2482
2483
			SkHWLinkDown(pAC, IoC, Port);
2484
2485
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_ADV, &Word);
2486
2487
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2488
				("AutoNeg.Adv: 0x%04X\n", Word));
2489
2490
			/* Set Auto-negotiation advertisement */
2491
			if (pAC->GIni.GIChipId != CHIP_ID_YUKON_FE &&
2492
				pPrt->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM) {
2493
				/* restore Asymmetric Pause bit */
2494
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_AUNE_ADV,
2495
					(SK_U16)(Word | PHY_M_AN_ASP));
2496
			}
2497
2498
			/* Signal to RLMT */
2499
			SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_LINK_DOWN, Para);
2500
		}
2501
		else {
2502
			if ((IStatus & PHY_M_IS_AN_COMPL) != 0) {
2503
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2504
					("Auto-Negotiation completed\n"));
2505
			}
2506
2507
			if ((IStatus & PHY_M_IS_LSP_CHANGE) != 0) {
2508
				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2509
					("Link Speed changed\n"));
2510
			}
2511
2512
			SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_WATIM, Para);
2513
		}
2206
	}
2514
	}
2207
	
2515
2208
	if ((IStatus & PHY_M_IS_AN_ERROR) != 0) {
2516
	if ((IStatus & PHY_M_IS_AN_ERROR) != 0) {
2209
		/* Auto-Negotiation Error */
2517
		/* the copper PHY makes 1 retry */
2210
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E023, SKERR_SIRQ_E023MSG);
2518
		if (pAC->GIni.GICopperType) {
2519
			/* not logged as error, it might be the first attempt */
2520
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2521
				("Auto-Negotiation Error\n"));
2522
		}
2523
		else {
2524
			/* Auto-Negotiation Error */
2525
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E023, SKERR_SIRQ_E023MSG);
2526
		}
2211
	}
2527
	}
2212
	
2528
2213
	if ((IStatus & PHY_M_IS_FIFO_ERROR) != 0) {
2529
	if ((IStatus & PHY_M_IS_FIFO_ERROR) != 0) {
2214
		/* FIFO Overflow/Underrun Error */
2530
		/* FIFO Overflow/Underrun Error */
2215
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E024, SKERR_SIRQ_E024MSG);
2531
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_SIRQ_E024, SKERR_SIRQ_E024MSG);
2216
	}
2532
	}
2217
	
2533
2218
}	/* SkPhyIsrGmac */
2534
}	/* SkPhyIsrGmac */
2219
#endif /* YUKON */
2535
#endif /* YUKON */
2220
2536
Lines 2230-2237 Link Here
2230
 */
2546
 */
2231
static void SkPhyIsrLone(
2547
static void SkPhyIsrLone(
2232
SK_AC	*pAC,		/* Adapter Context */
2548
SK_AC	*pAC,		/* Adapter Context */
2233
SK_IOC	IoC,		/* Io Context */
2549
SK_IOC	IoC,		/* I/O Context */
2234
int		Port,		/* Port Num = PHY Num */
2550
int		Port,		/* Port Index (MAC_1 + n) */
2235
SK_U16	IStatus)	/* Interrupt Status */
2551
SK_U16	IStatus)	/* Interrupt Status */
2236
{
2552
{
2237
	SK_EVPARA	Para;
2553
	SK_EVPARA	Para;
(-)linux/drivers/net/sk98lin/ski2c.c (-1296 lines)
Lines 1-1296 Link Here
1
/******************************************************************************
2
 *
3
 * Name:	ski2c.c
4
 * Project:	Gigabit Ethernet Adapters, TWSI-Module
5
 * Version:	$Revision: 1.59 $
6
 * Date:	$Date: 2003/10/20 09:07:25 $
7
 * Purpose:	Functions to access Voltage and Temperature Sensor
8
 *
9
 ******************************************************************************/
10
11
/******************************************************************************
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
22
 *
23
 ******************************************************************************/
24
25
/*
26
 *	I2C Protocol
27
 */
28
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
29
static const char SysKonnectFileId[] =
30
	"@(#) $Id: ski2c.c,v 1.59 2003/10/20 09:07:25 rschmidt Exp $ (C) Marvell. ";
31
#endif
32
33
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
34
#include "h/lm80.h"
35
#include "h/skdrv2nd.h"		/* Adapter Control- and Driver specific Def. */
36
37
#ifdef __C2MAN__
38
/*
39
	I2C protocol implementation.
40
41
	General Description:
42
43
	The I2C protocol is used for the temperature sensors and for
44
	the serial EEPROM which hold the configuration.
45
46
	This file covers functions that allow to read write and do
47
	some bulk requests a specified I2C address.
48
49
	The Genesis has 2 I2C buses. One for the EEPROM which holds
50
	the VPD Data and one for temperature and voltage sensor.
51
	The following picture shows the I2C buses, I2C devices and
52
	their control registers.
53
54
	Note: The VPD functions are in skvpd.c
55
.
56
.	PCI Config I2C Bus for VPD Data:
57
.
58
.		      +------------+
59
.		      | VPD EEPROM |
60
.		      +------------+
61
.			     |
62
.			     | <-- I2C
63
.			     |
64
.		 +-----------+-----------+
65
.		 |			 |
66
.	+-----------------+	+-----------------+
67
.	| PCI_VPD_ADR_REG |	| PCI_VPD_DAT_REG |
68
.	+-----------------+	+-----------------+
69
.
70
.
71
.	I2C Bus for LM80 sensor:
72
.
73
.			+-----------------+
74
.			| Temperature and |
75
.			| Voltage Sensor  |
76
.			| 	LM80	  |
77
.			+-----------------+
78
.				|
79
.				|
80
.			I2C --> |
81
.				|
82
.			     +----+
83
.	     +-------------->| OR |<--+
84
.	     |		     +----+   |
85
.     +------+------+		      |
86
.     |		    |		      |
87
. +--------+	+--------+	+----------+
88
. | B2_I2C |	| B2_I2C |	|  B2_I2C  |
89
. | _CTRL  |	| _DATA  |	|   _SW    |
90
. +--------+	+--------+	+----------+
91
.
92
	The I2C bus may be driven by the B2_I2C_SW or by the B2_I2C_CTRL
93
	and B2_I2C_DATA registers.
94
	For driver software it is recommended to use the I2C control and
95
	data register, because I2C bus timing is done by the ASIC and
96
	an interrupt may be received when the I2C request is completed.
97
98
	Clock Rate Timing:			MIN	MAX	generated by
99
		VPD EEPROM:			50 kHz	100 kHz		HW
100
		LM80 over I2C Ctrl/Data reg.	50 kHz	100 kHz		HW
101
		LM80 over B2_I2C_SW register	0	400 kHz		SW
102
103
	Note:	The clock generated by the hardware is dependend on the
104
		PCI clock. If the PCI bus clock is 33 MHz, the I2C/VPD
105
		clock is 50 kHz.
106
 */
107
intro()
108
{}
109
#endif
110
111
#ifdef SK_DIAG
112
/*
113
 * I2C Fast Mode timing values used by the LM80.
114
 * If new devices are added to the I2C bus the timing values have to be checked.
115
 */
116
#ifndef I2C_SLOW_TIMING
117
#define	T_CLK_LOW			1300L	/* clock low time in ns */
118
#define	T_CLK_HIGH		 	 600L	/* clock high time in ns */
119
#define T_DATA_IN_SETUP		 100L	/* data in Set-up Time */
120
#define T_START_HOLD		 600L	/* start condition hold time */
121
#define T_START_SETUP		 600L	/* start condition Set-up time */
122
#define	T_STOP_SETUP		 600L	/* stop condition Set-up time */
123
#define T_BUS_IDLE			1300L	/* time the bus must free after Tx */
124
#define	T_CLK_2_DATA_OUT	 900L	/* max. clock low to data output valid */
125
#else	/* I2C_SLOW_TIMING */
126
/* I2C Standard Mode Timing */
127
#define	T_CLK_LOW			4700L	/* clock low time in ns */
128
#define	T_CLK_HIGH			4000L	/* clock high time in ns */
129
#define T_DATA_IN_SETUP		 250L	/* data in Set-up Time */
130
#define T_START_HOLD		4000L	/* start condition hold time */
131
#define T_START_SETUP		4700L	/* start condition Set-up time */
132
#define	T_STOP_SETUP		4000L	/* stop condition Set-up time */
133
#define T_BUS_IDLE			4700L	/* time the bus must free after Tx */
134
#endif	/* !I2C_SLOW_TIMING */
135
136
#define NS2BCLK(x)	(((x)*125)/10000)
137
138
/*
139
 * I2C Wire Operations
140
 *
141
 * About I2C_CLK_LOW():
142
 *
143
 * The Data Direction bit (I2C_DATA_DIR) has to be set to input when setting
144
 * clock to low, to prevent the ASIC and the I2C data client from driving the
145
 * serial data line simultaneously (ASIC: last bit of a byte = '1', I2C client
146
 * send an 'ACK'). See also Concentrator Bugreport No. 10192.
147
 */
148
#define I2C_DATA_HIGH(IoC)	SK_I2C_SET_BIT(IoC, I2C_DATA)
149
#define	I2C_DATA_LOW(IoC)	SK_I2C_CLR_BIT(IoC, I2C_DATA)
150
#define	I2C_DATA_OUT(IoC)	SK_I2C_SET_BIT(IoC, I2C_DATA_DIR)
151
#define	I2C_DATA_IN(IoC)	SK_I2C_CLR_BIT(IoC, I2C_DATA_DIR | I2C_DATA)
152
#define	I2C_CLK_HIGH(IoC)	SK_I2C_SET_BIT(IoC, I2C_CLK)
153
#define	I2C_CLK_LOW(IoC)	SK_I2C_CLR_BIT(IoC, I2C_CLK | I2C_DATA_DIR)
154
#define	I2C_START_COND(IoC)	SK_I2C_CLR_BIT(IoC, I2C_CLK)
155
156
#define NS2CLKT(x)	((x*125L)/10000)
157
158
/*--------------- I2C Interface Register Functions --------------- */
159
160
/*
161
 * sending one bit
162
 */
163
void SkI2cSndBit(
164
SK_IOC	IoC,	/* I/O Context */
165
SK_U8	Bit)	/* Bit to send */
166
{
167
	I2C_DATA_OUT(IoC);
168
	if (Bit) {
169
		I2C_DATA_HIGH(IoC);
170
	}
171
	else {
172
		I2C_DATA_LOW(IoC);
173
	}
174
	SkDgWaitTime(IoC, NS2BCLK(T_DATA_IN_SETUP));
175
	I2C_CLK_HIGH(IoC);
176
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_HIGH));
177
	I2C_CLK_LOW(IoC);
178
}	/* SkI2cSndBit*/
179
180
181
/*
182
 * Signal a start to the I2C Bus.
183
 *
184
 * A start is signaled when data goes to low in a high clock cycle.
185
 *
186
 * Ends with Clock Low.
187
 *
188
 * Status: not tested
189
 */
190
void SkI2cStart(
191
SK_IOC	IoC)	/* I/O Context */
192
{
193
	/* Init data and Clock to output lines */
194
	/* Set Data high */
195
	I2C_DATA_OUT(IoC);
196
	I2C_DATA_HIGH(IoC);
197
	/* Set Clock high */
198
	I2C_CLK_HIGH(IoC);
199
200
	SkDgWaitTime(IoC, NS2BCLK(T_START_SETUP));
201
202
	/* Set Data Low */
203
	I2C_DATA_LOW(IoC);
204
205
	SkDgWaitTime(IoC, NS2BCLK(T_START_HOLD));
206
207
	/* Clock low without Data to Input */
208
	I2C_START_COND(IoC);
209
210
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_LOW));
211
}	/* SkI2cStart */
212
213
214
void SkI2cStop(
215
SK_IOC	IoC)	/* I/O Context */
216
{
217
	/* Init data and Clock to output lines */
218
	/* Set Data low */
219
	I2C_DATA_OUT(IoC);
220
	I2C_DATA_LOW(IoC);
221
222
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_2_DATA_OUT));
223
224
	/* Set Clock high */
225
	I2C_CLK_HIGH(IoC);
226
227
	SkDgWaitTime(IoC, NS2BCLK(T_STOP_SETUP));
228
229
	/*
230
	 * Set Data High:	Do it by setting the Data Line to Input.
231
	 *			Because of a pull up resistor the Data Line
232
	 *			floods to high.
233
	 */
234
	I2C_DATA_IN(IoC);
235
236
	/*
237
	 *	When I2C activity is stopped
238
	 *	 o	DATA should be set to input and
239
	 *	 o	CLOCK should be set to high!
240
	 */
241
	SkDgWaitTime(IoC, NS2BCLK(T_BUS_IDLE));
242
}	/* SkI2cStop */
243
244
245
/*
246
 * Receive just one bit via the I2C bus.
247
 *
248
 * Note:	Clock must be set to LOW before calling this function.
249
 *
250
 * Returns The received bit.
251
 */
252
int SkI2cRcvBit(
253
SK_IOC	IoC)	/* I/O Context */
254
{
255
	int	Bit;
256
	SK_U8	I2cSwCtrl;
257
258
	/* Init data as input line */
259
	I2C_DATA_IN(IoC);
260
261
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_2_DATA_OUT));
262
263
	I2C_CLK_HIGH(IoC);
264
265
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_HIGH));
266
267
	SK_I2C_GET_SW(IoC, &I2cSwCtrl);
268
	
269
	Bit = (I2cSwCtrl & I2C_DATA) ? 1 : 0;
270
271
	I2C_CLK_LOW(IoC);
272
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_LOW-T_CLK_2_DATA_OUT));
273
274
	return(Bit);
275
}	/* SkI2cRcvBit */
276
277
278
/*
279
 * Receive an ACK.
280
 *
281
 * returns	0 If acknowledged
282
 *		1 in case of an error
283
 */
284
int SkI2cRcvAck(
285
SK_IOC	IoC)	/* I/O Context */
286
{
287
	/*
288
	 * Received bit must be zero.
289
	 */
290
	return(SkI2cRcvBit(IoC) != 0);
291
}	/* SkI2cRcvAck */
292
293
294
/*
295
 * Send an NACK.
296
 */
297
void SkI2cSndNAck(
298
SK_IOC	IoC)	/* I/O Context */
299
{
300
	/*
301
	 * Received bit must be zero.
302
	 */
303
	SkI2cSndBit(IoC, 1);
304
}	/* SkI2cSndNAck */
305
306
307
/*
308
 * Send an ACK.
309
 */
310
void SkI2cSndAck(
311
SK_IOC IoC)	/* I/O Context */
312
{
313
	/*
314
	 * Received bit must be zero.
315
	 */
316
	SkI2cSndBit(IoC, 0);
317
}	/* SkI2cSndAck */
318
319
320
/*
321
 * Send one byte to the I2C device and wait for ACK.
322
 *
323
 * Return acknowleged status.
324
 */
325
int SkI2cSndByte(
326
SK_IOC	IoC,	/* I/O Context */
327
int		Byte)	/* byte to send */
328
{
329
	int	i;
330
331
	for (i = 0; i < 8; i++) {
332
		if (Byte & (1<<(7-i))) {
333
			SkI2cSndBit(IoC, 1);
334
		}
335
		else {
336
			SkI2cSndBit(IoC, 0);
337
		}
338
	}
339
340
	return(SkI2cRcvAck(IoC));
341
}	/* SkI2cSndByte */
342
343
344
/*
345
 * Receive one byte and ack it.
346
 *
347
 * Return byte.
348
 */
349
int SkI2cRcvByte(
350
SK_IOC	IoC,	/* I/O Context */
351
int		Last)	/* Last Byte Flag */
352
{
353
	int	i;
354
	int	Byte = 0;
355
356
	for (i = 0; i < 8; i++) {
357
		Byte <<= 1;
358
		Byte |= SkI2cRcvBit(IoC);
359
	}
360
361
	if (Last) {
362
		SkI2cSndNAck(IoC);
363
	}
364
	else {
365
		SkI2cSndAck(IoC);
366
	}
367
368
	return(Byte);
369
}	/* SkI2cRcvByte */
370
371
372
/*
373
 * Start dialog and send device address
374
 *
375
 * Return 0 if acknowleged, 1 in case of an error
376
 */
377
int	SkI2cSndDev(
378
SK_IOC	IoC,	/* I/O Context */
379
int		Addr,	/* Device Address */
380
int		Rw)		/* Read / Write Flag */
381
{
382
	SkI2cStart(IoC);
383
	Rw = ~Rw;
384
	Rw &= I2C_WRITE;
385
	return(SkI2cSndByte(IoC, (Addr<<1) | Rw));
386
}	/* SkI2cSndDev */
387
388
#endif /* SK_DIAG */
389
390
/*----------------- I2C CTRL Register Functions ----------*/
391
392
/*
393
 * waits for a completion of an I2C transfer
394
 *
395
 * returns	0:	success, transfer completes
396
 *			1:	error,	 transfer does not complete, I2C transfer
397
 *						 killed, wait loop terminated.
398
 */
399
int	SkI2cWait(
400
SK_AC	*pAC,	/* Adapter Context */
401
SK_IOC	IoC,	/* I/O Context */
402
int		Event)	/* complete event to wait for (I2C_READ or I2C_WRITE) */
403
{
404
	SK_U64	StartTime;
405
	SK_U64	CurrentTime;
406
	SK_U32	I2cCtrl;
407
408
	StartTime = SkOsGetTime(pAC);
409
	
410
	do {
411
		CurrentTime = SkOsGetTime(pAC);
412
413
		if (CurrentTime - StartTime > SK_TICKS_PER_SEC / 8) {
414
			
415
			SK_I2C_STOP(IoC);
416
#ifndef SK_DIAG
417
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E002, SKERR_I2C_E002MSG);
418
#endif /* !SK_DIAG */
419
			return(1);
420
		}
421
		
422
		SK_I2C_GET_CTL(IoC, &I2cCtrl);
423
424
#ifdef xYUKON_DBG
425
		printf("StartTime=%lu, CurrentTime=%lu\n",
426
			StartTime, CurrentTime);
427
		if (kbhit()) {
428
			return(1);
429
		}
430
#endif /* YUKON_DBG */
431
	
432
	} while ((I2cCtrl & I2C_FLAG) == (SK_U32)Event << 31);
433
434
	return(0);
435
}	/* SkI2cWait */
436
437
438
/*
439
 * waits for a completion of an I2C transfer
440
 *
441
 * Returns
442
 *	Nothing
443
 */
444
void SkI2cWaitIrq(
445
SK_AC	*pAC,	/* Adapter Context */
446
SK_IOC	IoC)	/* I/O Context */
447
{
448
	SK_SENSOR	*pSen;
449
	SK_U64		StartTime;
450
	SK_U32		IrqSrc;
451
452
	pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
453
454
	if (pSen->SenState == SK_SEN_IDLE) {
455
		return;
456
	}
457
458
	StartTime = SkOsGetTime(pAC);
459
	
460
	do {
461
		if (SkOsGetTime(pAC) - StartTime > SK_TICKS_PER_SEC / 8) {
462
			
463
			SK_I2C_STOP(IoC);
464
#ifndef SK_DIAG
465
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E016, SKERR_I2C_E016MSG);
466
#endif /* !SK_DIAG */
467
			return;
468
		}
469
		
470
		SK_IN32(IoC, B0_ISRC, &IrqSrc);
471
472
	} while ((IrqSrc & IS_I2C_READY) == 0);
473
474
	pSen->SenState = SK_SEN_IDLE;
475
	return;
476
}	/* SkI2cWaitIrq */
477
478
/*
479
 * writes a single byte or 4 bytes into the I2C device
480
 *
481
 * returns	0:	success
482
 *			1:	error
483
 */
484
int SkI2cWrite(
485
SK_AC	*pAC,		/* Adapter Context */
486
SK_IOC	IoC,		/* I/O Context */
487
SK_U32	I2cData,	/* I2C Data to write */
488
int		I2cDev,		/* I2C Device Address */
489
int		I2cDevSize, /* I2C Device Size (e.g. I2C_025K_DEV or I2C_2K_DEV) */
490
int		I2cReg,		/* I2C Device Register Address */
491
int		I2cBurst)	/* I2C Burst Flag */
492
{
493
	SK_OUT32(IoC, B2_I2C_DATA, I2cData);
494
	
495
	SK_I2C_CTL(IoC, I2C_WRITE, I2cDev, I2cDevSize, I2cReg, I2cBurst);
496
	
497
	return(SkI2cWait(pAC, IoC, I2C_WRITE));
498
}	/* SkI2cWrite*/
499
500
501
#ifdef	SK_DIAG
502
/*
503
 * reads a single byte or 4 bytes from the I2C device
504
 *
505
 * returns	the word read
506
 */
507
SK_U32 SkI2cRead(
508
SK_AC	*pAC,		/* Adapter Context */
509
SK_IOC	IoC,		/* I/O Context */
510
int		I2cDev,		/* I2C Device Address */
511
int		I2cDevSize, /* I2C Device Size (e.g. I2C_025K_DEV or I2C_2K_DEV) */
512
int		I2cReg,		/* I2C Device Register Address */
513
int		I2cBurst)	/* I2C Burst Flag */
514
{
515
	SK_U32	Data;
516
517
	SK_OUT32(IoC, B2_I2C_DATA, 0);
518
	SK_I2C_CTL(IoC, I2C_READ, I2cDev, I2cDevSize, I2cReg, I2cBurst);
519
	
520
	if (SkI2cWait(pAC, IoC, I2C_READ) != 0) {
521
		w_print("%s\n", SKERR_I2C_E002MSG);
522
	}
523
	
524
	SK_IN32(IoC, B2_I2C_DATA, &Data);
525
	
526
	return(Data);
527
}	/* SkI2cRead */
528
#endif /* SK_DIAG */
529
530
531
/*
532
 * read a sensor's value
533
 *
534
 * This function reads a sensor's value from the I2C sensor chip. The sensor
535
 * is defined by its index into the sensors database in the struct pAC points
536
 * to.
537
 * Returns
538
 *		1 if the read is completed
539
 *		0 if the read must be continued (I2C Bus still allocated)
540
 */
541
int	SkI2cReadSensor(
542
SK_AC		*pAC,	/* Adapter Context */
543
SK_IOC		IoC,	/* I/O Context */
544
SK_SENSOR	*pSen)	/* Sensor to be read */
545
{
546
    if (pSen->SenRead != NULL) {
547
        return((*pSen->SenRead)(pAC, IoC, pSen));
548
    }
549
	else {
550
        return(0); /* no success */
551
	}
552
}	/* SkI2cReadSensor */
553
554
/*
555
 * Do the Init state 0 initialization
556
 */
557
static int SkI2cInit0(
558
SK_AC	*pAC)	/* Adapter Context */
559
{
560
	int	i;
561
562
	/* Begin with first sensor */
563
	pAC->I2c.CurrSens = 0;
564
	
565
	/* Begin with timeout control for state machine */
566
	pAC->I2c.TimerMode = SK_TIMER_WATCH_SM;
567
	
568
	/* Set sensor number to zero */
569
	pAC->I2c.MaxSens = 0;
570
571
#ifndef SK_DIAG
572
	/* Initialize Number of Dummy Reads */
573
	pAC->I2c.DummyReads = SK_MAX_SENSORS;
574
#endif
575
576
	for (i = 0; i < SK_MAX_SENSORS; i++) {
577
		pAC->I2c.SenTable[i].SenDesc = "unknown";
578
		pAC->I2c.SenTable[i].SenType = SK_SEN_UNKNOWN;
579
		pAC->I2c.SenTable[i].SenThreErrHigh = 0;
580
		pAC->I2c.SenTable[i].SenThreErrLow = 0;
581
		pAC->I2c.SenTable[i].SenThreWarnHigh = 0;
582
		pAC->I2c.SenTable[i].SenThreWarnLow = 0;
583
		pAC->I2c.SenTable[i].SenReg = LM80_FAN2_IN;
584
		pAC->I2c.SenTable[i].SenInit = SK_SEN_DYN_INIT_NONE;
585
		pAC->I2c.SenTable[i].SenValue = 0;
586
		pAC->I2c.SenTable[i].SenErrFlag = SK_SEN_ERR_NOT_PRESENT;
587
		pAC->I2c.SenTable[i].SenErrCts = 0;
588
		pAC->I2c.SenTable[i].SenBegErrTS = 0;
589
		pAC->I2c.SenTable[i].SenState = SK_SEN_IDLE;
590
		pAC->I2c.SenTable[i].SenRead = NULL;
591
		pAC->I2c.SenTable[i].SenDev = 0;
592
	}
593
594
	/* Now we are "INIT data"ed */
595
	pAC->I2c.InitLevel = SK_INIT_DATA;
596
	return(0);
597
}	/* SkI2cInit0*/
598
599
600
/*
601
 * Do the init state 1 initialization
602
 *
603
 * initialize the following register of the LM80:
604
 * Configuration register:
605
 * - START, noINT, activeLOW, noINT#Clear, noRESET, noCI, noGPO#, noINIT
606
 *
607
 * Interrupt Mask Register 1:
608
 * - all interrupts are Disabled (0xff)
609
 *
610
 * Interrupt Mask Register 2:
611
 * - all interrupts are Disabled (0xff) Interrupt modi doesn't matter.
612
 *
613
 * Fan Divisor/RST_OUT register:
614
 * - Divisors set to 1 (bits 00), all others 0s.
615
 *
616
 * OS# Configuration/Temperature resolution Register:
617
 * - all 0s
618
 *
619
 */
620
static int SkI2cInit1(
621
SK_AC	*pAC,	/* Adapter Context */
622
SK_IOC	IoC)	/* I/O Context */
623
{
624
    int i;
625
    SK_U8 I2cSwCtrl;
626
	SK_GEPORT *pPrt;	/* GIni Port struct pointer */
627
628
	if (pAC->I2c.InitLevel != SK_INIT_DATA) {
629
		/* ReInit not needed in I2C module */
630
		return(0);
631
	}
632
633
    /* Set the Direction of I2C-Data Pin to IN */
634
    SK_I2C_CLR_BIT(IoC, I2C_DATA_DIR | I2C_DATA);
635
    /* Check for 32-Bit Yukon with Low at I2C-Data Pin */
636
	SK_I2C_GET_SW(IoC, &I2cSwCtrl);
637
638
	if ((I2cSwCtrl & I2C_DATA) == 0) {
639
		/* this is a 32-Bit board */
640
		pAC->GIni.GIYukon32Bit = SK_TRUE;
641
        return(0);
642
    }
643
644
	/* Check for 64 Bit Yukon without sensors */
645
	if (SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_CFG, 0) != 0) {
646
        return(0);
647
    }
648
649
	(void)SkI2cWrite(pAC, IoC, 0xffUL, LM80_ADDR, I2C_025K_DEV, LM80_IMSK_1, 0);
650
	
651
	(void)SkI2cWrite(pAC, IoC, 0xffUL, LM80_ADDR, I2C_025K_DEV, LM80_IMSK_2, 0);
652
	
653
	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_FAN_CTRL, 0);
654
	
655
	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_TEMP_CTRL, 0);
656
	
657
	(void)SkI2cWrite(pAC, IoC, (SK_U32)LM80_CFG_START, LM80_ADDR, I2C_025K_DEV,
658
		LM80_CFG, 0);
659
	
660
	/*
661
	 * MaxSens has to be updated here, because PhyType is not
662
	 * set when performing Init Level 0
663
	 */
664
    pAC->I2c.MaxSens = 5;
665
	
666
	pPrt = &pAC->GIni.GP[0];
667
	
668
	if (pAC->GIni.GIGenesis) {
669
		if (pPrt->PhyType == SK_PHY_BCOM) {
670
			if (pAC->GIni.GIMacsFound == 1) {
671
				pAC->I2c.MaxSens += 1;
672
			}
673
			else {
674
				pAC->I2c.MaxSens += 3;
675
			}
676
		}
677
	}
678
	else {
679
		pAC->I2c.MaxSens += 3;
680
	}
681
	
682
	for (i = 0; i < pAC->I2c.MaxSens; i++) {
683
		switch (i) {
684
		case 0:
685
			pAC->I2c.SenTable[i].SenDesc = "Temperature";
686
			pAC->I2c.SenTable[i].SenType = SK_SEN_TEMP;
687
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_TEMP_HIGH_ERR;
688
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_TEMP_HIGH_WARN;
689
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_TEMP_LOW_WARN;
690
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_TEMP_LOW_ERR;
691
			pAC->I2c.SenTable[i].SenReg = LM80_TEMP_IN;
692
			break;
693
		case 1:
694
			pAC->I2c.SenTable[i].SenDesc = "Voltage PCI";
695
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
696
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PCI_5V_HIGH_ERR;
697
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PCI_5V_HIGH_WARN;
698
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PCI_5V_LOW_WARN;
699
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PCI_5V_LOW_ERR;
700
			pAC->I2c.SenTable[i].SenReg = LM80_VT0_IN;
701
			break;
702
		case 2:
703
			pAC->I2c.SenTable[i].SenDesc = "Voltage PCI-IO";
704
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
705
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PCI_IO_5V_HIGH_ERR;
706
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PCI_IO_5V_HIGH_WARN;
707
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PCI_IO_3V3_LOW_WARN;
708
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PCI_IO_3V3_LOW_ERR;
709
			pAC->I2c.SenTable[i].SenReg = LM80_VT1_IN;
710
			pAC->I2c.SenTable[i].SenInit = SK_SEN_DYN_INIT_PCI_IO;
711
			break;
712
		case 3:
713
			pAC->I2c.SenTable[i].SenDesc = "Voltage ASIC";
714
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
715
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_VDD_HIGH_ERR;
716
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_VDD_HIGH_WARN;
717
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_VDD_LOW_WARN;
718
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_VDD_LOW_ERR;
719
			pAC->I2c.SenTable[i].SenReg = LM80_VT2_IN;
720
			break;
721
		case 4:
722
			if (pAC->GIni.GIGenesis) {
723
				if (pPrt->PhyType == SK_PHY_BCOM) {
724
					pAC->I2c.SenTable[i].SenDesc = "Voltage PHY A PLL";
725
					pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
726
					pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
727
					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
728
					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
729
				}
730
				else {
731
					pAC->I2c.SenTable[i].SenDesc = "Voltage PMA";
732
					pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
733
					pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
734
					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
735
					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
736
				}
737
			}
738
			else {
739
				pAC->I2c.SenTable[i].SenDesc = "Voltage VAUX";
740
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_VAUX_3V3_HIGH_ERR;
741
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_VAUX_3V3_HIGH_WARN;
742
				if (pAC->GIni.GIVauxAvail) {
743
					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_VAUX_3V3_LOW_WARN;
744
					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_VAUX_3V3_LOW_ERR;
745
				}
746
				else {
747
					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_VAUX_0V_WARN_ERR;
748
					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_VAUX_0V_WARN_ERR;
749
				}
750
			}
751
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
752
			pAC->I2c.SenTable[i].SenReg = LM80_VT3_IN;
753
			break;
754
		case 5:
755
			if (pAC->GIni.GIGenesis) {
756
				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 2V5";
757
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PHY_2V5_HIGH_ERR;
758
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PHY_2V5_HIGH_WARN;
759
				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PHY_2V5_LOW_WARN;
760
				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PHY_2V5_LOW_ERR;
761
			}
762
			else {
763
				pAC->I2c.SenTable[i].SenDesc = "Voltage Core 1V5";
764
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_CORE_1V5_HIGH_ERR;
765
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_CORE_1V5_HIGH_WARN;
766
				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_CORE_1V5_LOW_WARN;
767
				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_CORE_1V5_LOW_ERR;
768
			}
769
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
770
			pAC->I2c.SenTable[i].SenReg = LM80_VT4_IN;
771
			break;
772
		case 6:
773
			if (pAC->GIni.GIGenesis) {
774
				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY B PLL";
775
			}
776
			else {
777
				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 3V3";
778
			}
779
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
780
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
781
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
782
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
783
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
784
			pAC->I2c.SenTable[i].SenReg = LM80_VT5_IN;
785
			break;
786
		case 7:
787
			if (pAC->GIni.GIGenesis) {
788
				pAC->I2c.SenTable[i].SenDesc = "Speed Fan";
789
				pAC->I2c.SenTable[i].SenType = SK_SEN_FAN;
790
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_FAN_HIGH_ERR;
791
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_FAN_HIGH_WARN;
792
				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_FAN_LOW_WARN;
793
				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_FAN_LOW_ERR;
794
				pAC->I2c.SenTable[i].SenReg = LM80_FAN2_IN;
795
			}
796
			else {
797
				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 2V5";
798
				pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
799
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PHY_2V5_HIGH_ERR;
800
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PHY_2V5_HIGH_WARN;
801
				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PHY_2V5_LOW_WARN;
802
				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PHY_2V5_LOW_ERR;
803
				pAC->I2c.SenTable[i].SenReg = LM80_VT6_IN;
804
			}
805
			break;
806
		default:
807
			SK_ERR_LOG(pAC, SK_ERRCL_INIT | SK_ERRCL_SW,
808
				SKERR_I2C_E001, SKERR_I2C_E001MSG);
809
			break;
810
		}
811
812
		pAC->I2c.SenTable[i].SenValue = 0;
813
		pAC->I2c.SenTable[i].SenErrFlag = SK_SEN_ERR_OK;
814
		pAC->I2c.SenTable[i].SenErrCts = 0;
815
		pAC->I2c.SenTable[i].SenBegErrTS = 0;
816
		pAC->I2c.SenTable[i].SenState = SK_SEN_IDLE;
817
		pAC->I2c.SenTable[i].SenRead = SkLm80ReadSensor;
818
		pAC->I2c.SenTable[i].SenDev = LM80_ADDR;
819
	}
820
821
#ifndef SK_DIAG
822
	pAC->I2c.DummyReads = pAC->I2c.MaxSens;
823
#endif /* !SK_DIAG */
824
	
825
	/* Clear I2C IRQ */
826
	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
827
	
828
	/* Now we are I/O initialized */
829
	pAC->I2c.InitLevel = SK_INIT_IO;
830
	return(0);
831
}	/* SkI2cInit1 */
832
833
834
/*
835
 * Init level 2: Start first sensor read.
836
 */
837
static int SkI2cInit2(
838
SK_AC	*pAC,	/* Adapter Context */
839
SK_IOC	IoC)	/* I/O Context */
840
{
841
	int		ReadComplete;
842
	SK_SENSOR	*pSen;
843
844
	if (pAC->I2c.InitLevel != SK_INIT_IO) {
845
		/* ReInit not needed in I2C module */
846
		/* Init0 and Init2 not permitted */
847
		return(0);
848
	}
849
850
	pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
851
	ReadComplete = SkI2cReadSensor(pAC, IoC, pSen);
852
853
	if (ReadComplete) {
854
		SK_ERR_LOG(pAC, SK_ERRCL_INIT, SKERR_I2C_E008, SKERR_I2C_E008MSG);
855
	}
856
857
	/* Now we are correctly initialized */
858
	pAC->I2c.InitLevel = SK_INIT_RUN;
859
860
	return(0);
861
}	/* SkI2cInit2*/
862
863
864
/*
865
 * Initialize I2C devices
866
 *
867
 * Get the first voltage value and discard it.
868
 * Go into temperature read mode. A default pointer is not set.
869
 *
870
 * The things to be done depend on the init level in the parameter list:
871
 * Level 0:
872
 *	Initialize only the data structures. Do NOT access hardware.
873
 * Level 1:
874
 *	Initialize hardware through SK_IN / SK_OUT commands. Do NOT use interrupts.
875
 * Level 2:
876
 *	Everything is possible. Interrupts may be used from now on.
877
 *
878
 * return:
879
 *	0 = success
880
 *	other = error.
881
 */
882
int	SkI2cInit(
883
SK_AC	*pAC,	/* Adapter Context */
884
SK_IOC	IoC,	/* I/O Context needed in levels 1 and 2 */
885
int		Level)	/* Init Level */
886
{
887
888
	switch (Level) {
889
	case SK_INIT_DATA:
890
		return(SkI2cInit0(pAC));
891
	case SK_INIT_IO:
892
		return(SkI2cInit1(pAC, IoC));
893
	case SK_INIT_RUN:
894
		return(SkI2cInit2(pAC, IoC));
895
	default:
896
		break;
897
	}
898
899
	return(0);
900
}	/* SkI2cInit */
901
902
903
#ifndef SK_DIAG
904
905
/*
906
 * Interrupt service function for the I2C Interface
907
 *
908
 * Clears the Interrupt source
909
 *
910
 * Reads the register and check it for sending a trap.
911
 *
912
 * Starts the timer if necessary.
913
 */
914
void SkI2cIsr(
915
SK_AC	*pAC,	/* Adapter Context */
916
SK_IOC	IoC)	/* I/O Context */
917
{
918
	SK_EVPARA	Para;
919
920
	/* Clear I2C IRQ */
921
	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
922
923
	Para.Para64 = 0;
924
	SkEventQueue(pAC, SKGE_I2C, SK_I2CEV_IRQ, Para);
925
}	/* SkI2cIsr */
926
927
928
/*
929
 * Check this sensors Value against the threshold and send events.
930
 */
931
static void SkI2cCheckSensor(
932
SK_AC		*pAC,	/* Adapter Context */
933
SK_SENSOR	*pSen)
934
{
935
	SK_EVPARA	ParaLocal;
936
	SK_BOOL		TooHigh;	/* Is sensor too high? */
937
	SK_BOOL		TooLow;		/* Is sensor too low? */
938
	SK_U64		CurrTime;	/* Current Time */
939
	SK_BOOL		DoTrapSend;	/* We need to send a trap */
940
	SK_BOOL		DoErrLog;	/* We need to log the error */
941
	SK_BOOL		IsError;	/* We need to log the error */
942
943
	/* Check Dummy Reads first */
944
	if (pAC->I2c.DummyReads > 0) {
945
		pAC->I2c.DummyReads--;
946
		return;
947
	}
948
949
	/* Get the current time */
950
	CurrTime = SkOsGetTime(pAC);
951
952
	/* Set para to the most useful setting: The current sensor. */
953
	ParaLocal.Para64 = (SK_U64)pAC->I2c.CurrSens;
954
955
	/* Check the Value against the thresholds. First: Error Thresholds */
956
	TooHigh = (pSen->SenValue > pSen->SenThreErrHigh);
957
	TooLow = (pSen->SenValue < pSen->SenThreErrLow);
958
		
959
	IsError = SK_FALSE;
960
	if (TooHigh || TooLow) {
961
		/* Error condition is satisfied */
962
		DoTrapSend = SK_TRUE;
963
		DoErrLog = SK_TRUE;
964
965
		/* Now error condition is satisfied */
966
		IsError = SK_TRUE;
967
968
		if (pSen->SenErrFlag == SK_SEN_ERR_ERR) {
969
			/* This state is the former one */
970
971
			/* So check first whether we have to send a trap */
972
			if (pSen->SenLastErrTrapTS + SK_SEN_ERR_TR_HOLD >
973
			    CurrTime) {
974
				/*
975
				 * Do NOT send the Trap. The hold back time
976
				 * has to run out first.
977
				 */
978
				DoTrapSend = SK_FALSE;
979
			}
980
981
			/* Check now whether we have to log an Error */
982
			if (pSen->SenLastErrLogTS + SK_SEN_ERR_LOG_HOLD >
983
			    CurrTime) {
984
				/*
985
				 * Do NOT log the error. The hold back time
986
				 * has to run out first.
987
				 */
988
				DoErrLog = SK_FALSE;
989
			}
990
		}
991
		else {
992
			/* We came from a different state -> Set Begin Time Stamp */
993
			pSen->SenBegErrTS = CurrTime;
994
			pSen->SenErrFlag = SK_SEN_ERR_ERR;
995
		}
996
997
		if (DoTrapSend) {
998
			/* Set current Time */
999
			pSen->SenLastErrTrapTS = CurrTime;
1000
			pSen->SenErrCts++;
1001
1002
			/* Queue PNMI Event */
1003
			SkEventQueue(pAC, SKGE_PNMI, (TooHigh ?
1004
				SK_PNMI_EVT_SEN_ERR_UPP :
1005
				SK_PNMI_EVT_SEN_ERR_LOW),
1006
				ParaLocal);
1007
		}
1008
1009
		if (DoErrLog) {
1010
			/* Set current Time */
1011
			pSen->SenLastErrLogTS = CurrTime;
1012
1013
			if (pSen->SenType == SK_SEN_TEMP) {
1014
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E011, SKERR_I2C_E011MSG);
1015
			}
1016
			else if (pSen->SenType == SK_SEN_VOLT) {
1017
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E012, SKERR_I2C_E012MSG);
1018
			}
1019
			else {
1020
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E015, SKERR_I2C_E015MSG);
1021
			}
1022
		}
1023
	}
1024
1025
	/* Check the Value against the thresholds */
1026
	/* 2nd: Warning thresholds */
1027
	TooHigh = (pSen->SenValue > pSen->SenThreWarnHigh);
1028
	TooLow = (pSen->SenValue < pSen->SenThreWarnLow);
1029
		
1030
	if (!IsError && (TooHigh || TooLow)) {
1031
		/* Error condition is satisfied */
1032
		DoTrapSend = SK_TRUE;
1033
		DoErrLog = SK_TRUE;
1034
1035
		if (pSen->SenErrFlag == SK_SEN_ERR_WARN) {
1036
			/* This state is the former one */
1037
1038
			/* So check first whether we have to send a trap */
1039
			if (pSen->SenLastWarnTrapTS + SK_SEN_WARN_TR_HOLD > CurrTime) {
1040
				/*
1041
				 * Do NOT send the Trap. The hold back time
1042
				 * has to run out first.
1043
				 */
1044
				DoTrapSend = SK_FALSE;
1045
			}
1046
1047
			/* Check now whether we have to log an Error */
1048
			if (pSen->SenLastWarnLogTS + SK_SEN_WARN_LOG_HOLD > CurrTime) {
1049
				/*
1050
				 * Do NOT log the error. The hold back time
1051
				 * has to run out first.
1052
				 */
1053
				DoErrLog = SK_FALSE;
1054
			}
1055
		}
1056
		else {
1057
			/* We came from a different state -> Set Begin Time Stamp */
1058
			pSen->SenBegWarnTS = CurrTime;
1059
			pSen->SenErrFlag = SK_SEN_ERR_WARN;
1060
		}
1061
1062
		if (DoTrapSend) {
1063
			/* Set current Time */
1064
			pSen->SenLastWarnTrapTS = CurrTime;
1065
			pSen->SenWarnCts++;
1066
1067
			/* Queue PNMI Event */
1068
			SkEventQueue(pAC, SKGE_PNMI, (TooHigh ?
1069
				SK_PNMI_EVT_SEN_WAR_UPP :
1070
				SK_PNMI_EVT_SEN_WAR_LOW),
1071
				ParaLocal);
1072
		}
1073
1074
		if (DoErrLog) {
1075
			/* Set current Time */
1076
			pSen->SenLastWarnLogTS = CurrTime;
1077
1078
			if (pSen->SenType == SK_SEN_TEMP) {
1079
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E009, SKERR_I2C_E009MSG);
1080
			}
1081
			else if (pSen->SenType == SK_SEN_VOLT) {
1082
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E010, SKERR_I2C_E010MSG);
1083
			}
1084
			else {
1085
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E014, SKERR_I2C_E014MSG);
1086
			}
1087
		}
1088
	}
1089
1090
	/* Check for NO error at all */
1091
	if (!IsError && !TooHigh && !TooLow) {
1092
		/* Set o.k. Status if no error and no warning condition */
1093
		pSen->SenErrFlag = SK_SEN_ERR_OK;
1094
	}
1095
1096
	/* End of check against the thresholds */
1097
1098
	/* Bug fix AF: 16.Aug.2001: Correct the init base
1099
	 * of LM80 sensor.
1100
	 */
1101
	if (pSen->SenInit == SK_SEN_DYN_INIT_PCI_IO) {
1102
1103
        pSen->SenInit = SK_SEN_DYN_INIT_NONE;
1104
1105
		if (pSen->SenValue > SK_SEN_PCI_IO_RANGE_LIMITER) {
1106
			/* 5V PCI-IO Voltage */
1107
			pSen->SenThreWarnLow = SK_SEN_PCI_IO_5V_LOW_WARN;
1108
			pSen->SenThreErrLow = SK_SEN_PCI_IO_5V_LOW_ERR;
1109
		}
1110
		else {
1111
			/* 3.3V PCI-IO Voltage */
1112
			pSen->SenThreWarnHigh = SK_SEN_PCI_IO_3V3_HIGH_WARN;
1113
			pSen->SenThreErrHigh = SK_SEN_PCI_IO_3V3_HIGH_ERR;
1114
		}
1115
	}
1116
	
1117
#ifdef TEST_ONLY
1118
    /* Dynamic thresholds also for VAUX of LM80 sensor */
1119
	if (pSen->SenInit == SK_SEN_DYN_INIT_VAUX) {
1120
1121
        pSen->SenInit = SK_SEN_DYN_INIT_NONE;
1122
1123
		/* 3.3V VAUX Voltage */
1124
		if (pSen->SenValue > SK_SEN_VAUX_RANGE_LIMITER) {
1125
			pSen->SenThreWarnLow = SK_SEN_VAUX_3V3_LOW_WARN;
1126
			pSen->SenThreErrLow = SK_SEN_VAUX_3V3_LOW_ERR;
1127
		}
1128
		/* 0V VAUX Voltage */
1129
		else {
1130
			pSen->SenThreWarnHigh = SK_SEN_VAUX_0V_WARN_ERR;
1131
			pSen->SenThreErrHigh = SK_SEN_VAUX_0V_WARN_ERR;
1132
		}
1133
	}
1134
1135
	/*
1136
	 * Check initialization state:
1137
	 * The VIO Thresholds need adaption
1138
	 */
1139
	if (!pSen->SenInit && pSen->SenReg == LM80_VT1_IN &&
1140
	     pSen->SenValue > SK_SEN_WARNLOW2C &&
1141
	     pSen->SenValue < SK_SEN_WARNHIGH2) {
1142
		pSen->SenThreErrLow = SK_SEN_ERRLOW2C;
1143
		pSen->SenThreWarnLow = SK_SEN_WARNLOW2C;
1144
		pSen->SenInit = SK_TRUE;
1145
	}
1146
1147
	if (!pSen->SenInit && pSen->SenReg == LM80_VT1_IN &&
1148
	     pSen->SenValue > SK_SEN_WARNLOW2 &&
1149
	     pSen->SenValue < SK_SEN_WARNHIGH2C) {
1150
		pSen->SenThreErrHigh = SK_SEN_ERRHIGH2C;
1151
		pSen->SenThreWarnHigh = SK_SEN_WARNHIGH2C;
1152
		pSen->SenInit = SK_TRUE;
1153
	}
1154
#endif
1155
1156
	if (pSen->SenInit != SK_SEN_DYN_INIT_NONE) {
1157
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E013, SKERR_I2C_E013MSG);
1158
	}
1159
}	/* SkI2cCheckSensor */
1160
1161
1162
/*
1163
 * The only Event to be served is the timeout event
1164
 *
1165
 */
1166
int	SkI2cEvent(
1167
SK_AC		*pAC,	/* Adapter Context */
1168
SK_IOC		IoC,	/* I/O Context */
1169
SK_U32		Event,	/* Module specific Event */
1170
SK_EVPARA	Para)	/* Event specific Parameter */
1171
{
1172
	int			ReadComplete;
1173
	SK_SENSOR	*pSen;
1174
	SK_U32		Time;
1175
	SK_EVPARA	ParaLocal;
1176
	int			i;
1177
1178
	/* New case: no sensors */
1179
	if (pAC->I2c.MaxSens == 0) {
1180
		return(0);
1181
	}
1182
1183
	switch (Event) {
1184
	case SK_I2CEV_IRQ:
1185
		pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
1186
		ReadComplete = SkI2cReadSensor(pAC, IoC, pSen);
1187
1188
		if (ReadComplete) {
1189
			/* Check sensor against defined thresholds */
1190
			SkI2cCheckSensor(pAC, pSen);
1191
1192
			/* Increment Current sensor and set appropriate Timeout */
1193
			pAC->I2c.CurrSens++;
1194
			if (pAC->I2c.CurrSens >= pAC->I2c.MaxSens) {
1195
				pAC->I2c.CurrSens = 0;
1196
				Time = SK_I2C_TIM_LONG;
1197
			}
1198
			else {
1199
				Time = SK_I2C_TIM_SHORT;
1200
			}
1201
1202
			/* Start Timer */
1203
			ParaLocal.Para64 = (SK_U64)0;
1204
1205
			pAC->I2c.TimerMode = SK_TIMER_NEW_GAUGING;
1206
			
1207
			SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time,
1208
				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
1209
		}
1210
        else {
1211
			/* Start Timer */
1212
			ParaLocal.Para64 = (SK_U64)0;
1213
1214
			pAC->I2c.TimerMode = SK_TIMER_WATCH_SM;
1215
1216
            SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, SK_I2C_TIM_WATCH,
1217
				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
1218
		}
1219
		break;
1220
	case SK_I2CEV_TIM:
1221
		if (pAC->I2c.TimerMode == SK_TIMER_NEW_GAUGING) {
1222
1223
			ParaLocal.Para64 = (SK_U64)0;
1224
			SkTimerStop(pAC, IoC, &pAC->I2c.SenTimer);
1225
1226
			pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
1227
			ReadComplete = SkI2cReadSensor(pAC, IoC, pSen);
1228
1229
			if (ReadComplete) {
1230
				/* Check sensor against defined thresholds */
1231
				SkI2cCheckSensor(pAC, pSen);
1232
1233
				/* Increment Current sensor and set appropriate Timeout */
1234
				pAC->I2c.CurrSens++;
1235
				if (pAC->I2c.CurrSens == pAC->I2c.MaxSens) {
1236
					pAC->I2c.CurrSens = 0;
1237
					Time = SK_I2C_TIM_LONG;
1238
				}
1239
				else {
1240
					Time = SK_I2C_TIM_SHORT;
1241
				}
1242
1243
				/* Start Timer */
1244
				ParaLocal.Para64 = (SK_U64)0;
1245
1246
				pAC->I2c.TimerMode = SK_TIMER_NEW_GAUGING;
1247
1248
				SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time,
1249
					SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
1250
			}
1251
		}
1252
		else {
1253
			pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
1254
			pSen->SenErrFlag = SK_SEN_ERR_FAULTY;
1255
			SK_I2C_STOP(IoC);
1256
1257
			/* Increment Current sensor and set appropriate Timeout */
1258
			pAC->I2c.CurrSens++;
1259
			if (pAC->I2c.CurrSens == pAC->I2c.MaxSens) {
1260
				pAC->I2c.CurrSens = 0;
1261
				Time = SK_I2C_TIM_LONG;
1262
			}
1263
			else {
1264
				Time = SK_I2C_TIM_SHORT;
1265
			}
1266
1267
			/* Start Timer */
1268
			ParaLocal.Para64 = (SK_U64)0;
1269
1270
			pAC->I2c.TimerMode = SK_TIMER_NEW_GAUGING;
1271
1272
			SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time,
1273
				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
1274
		}
1275
		break;
1276
	case SK_I2CEV_CLEAR:
1277
		for (i = 0; i < SK_MAX_SENSORS; i++) {
1278
			pAC->I2c.SenTable[i].SenErrFlag = SK_SEN_ERR_OK;
1279
			pAC->I2c.SenTable[i].SenErrCts = 0;
1280
			pAC->I2c.SenTable[i].SenWarnCts = 0;
1281
			pAC->I2c.SenTable[i].SenBegErrTS = 0;
1282
			pAC->I2c.SenTable[i].SenBegWarnTS = 0;
1283
			pAC->I2c.SenTable[i].SenLastErrTrapTS = (SK_U64)0;
1284
			pAC->I2c.SenTable[i].SenLastErrLogTS = (SK_U64)0;
1285
			pAC->I2c.SenTable[i].SenLastWarnTrapTS = (SK_U64)0;
1286
			pAC->I2c.SenTable[i].SenLastWarnLogTS = (SK_U64)0;
1287
		}
1288
		break;
1289
	default:
1290
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E006, SKERR_I2C_E006MSG);
1291
	}
1292
1293
	return(0);
1294
}	/* SkI2cEvent*/
1295
1296
#endif /* !SK_DIAG */
(-)linux/drivers/net/sk98lin/sklm80.c (-5 / +5 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	sklm80.c
3
 * Name:	sklm80.c
4
 * Project:	Gigabit Ethernet Adapters, TWSI-Module
4
 * Project:	Gigabit Ethernet Adapters, TWSI-Module
5
 * Version:	$Revision: 1.22 $
5
 * Version:	$Revision: 1.1 $
6
 * Date:	$Date: 2003/10/20 09:08:21 $
6
 * Date:	$Date: 2003/12/19 14:02:31 $
7
 * Purpose:	Functions to access Voltage and Temperature Sensor (LM80)
7
 * Purpose:	Functions to access Voltage and Temperature Sensor (LM80)
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 27-33 Link Here
27
*/
27
*/
28
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
28
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
29
static const char SysKonnectFileId[] =
29
static const char SysKonnectFileId[] =
30
	"@(#) $Id: sklm80.c,v 1.22 2003/10/20 09:08:21 rschmidt Exp $ (C) Marvell. ";
30
	"@(#) $Id: sklm80.c,v 1.1 2003/12/19 14:02:31 mschmid Exp $ (C) Marvell. ";
31
#endif
31
#endif
32
32
33
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
33
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
Lines 111-122 Link Here
111
/*
111
/*
112
 * read a sensors value (LM80 specific)
112
 * read a sensors value (LM80 specific)
113
 *
113
 *
114
 * This function reads a sensors value from the I2C sensor chip LM80.
114
 * This function reads a sensors value from the TWSI sensor chip LM80.
115
 * The sensor is defined by its index into the sensors database in the struct
115
 * The sensor is defined by its index into the sensors database in the struct
116
 * pAC points to.
116
 * pAC points to.
117
 *
117
 *
118
 * Returns	1 if the read is completed
118
 * Returns	1 if the read is completed
119
 *		0 if the read must be continued (I2C Bus still allocated)
119
 *		0 if the read must be continued (TWSI Bus still allocated)
120
 */
120
 */
121
int SkLm80ReadSensor(
121
int SkLm80ReadSensor(
122
SK_AC		*pAC,	/* Adapter Context */
122
SK_AC		*pAC,	/* Adapter Context */
(-)linux/drivers/net/sk98lin/skproc.c (-186 / +401 lines)
Lines 2-29 Link Here
2
 *
2
 *
3
 * Name:	skproc.c
3
 * Name:	skproc.c
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.11 $
5
 * Version:	$Revision: 1.14.2.2 $
6
 * Date:	$Date: 2003/12/11 16:03:57 $
6
 * Date:	$Date: 2004/11/23 19:42:25 $
7
 * Purpose:	Funktions to display statictic data
7
 * Purpose:	Functions to display statictic data
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
10
 
10
 
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	Driver for Marvell Yukon/2 chipset and SysKonnect Gigabit Ethernet 
17
 *      Server Adapters.
18
 *
19
 *	Author: Ralph Roesler (rroesler@syskonnect.de)
20
 *	        Mirko Lindner (mlindner@syskonnect.de)
21
 *
22
 *	Address all question to: linux@syskonnect.de
23
 *
24
 *	The technical manual for the adapters is available from SysKonnect's
25
 *	web pages: www.syskonnect.com
26
 *	
16
 *	This program is free software; you can redistribute it and/or modify
27
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
28
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
29
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
30
 *	(at your option) any later version.
20
 *
31
 *
21
 *	Created 22-Nov-2000
22
 *	Author: Mirko Lindner (mlindner@syskonnect.de)
23
 *
24
 *	The information in this file is provided "AS IS" without warranty.
32
 *	The information in this file is provided "AS IS" without warranty.
25
 *
33
 *
26
 ******************************************************************************/
34
 *****************************************************************************/
35
27
#include <linux/proc_fs.h>
36
#include <linux/proc_fs.h>
28
#include <linux/seq_file.h>
37
#include <linux/seq_file.h>
29
38
Lines 31-39 Link Here
31
#include "h/skdrv2nd.h"
40
#include "h/skdrv2nd.h"
32
#include "h/skversion.h"
41
#include "h/skversion.h"
33
42
43
extern struct SK_NET_DEVICE *SkGeRootDev;
44
45
/******************************************************************************
46
 *
47
 * Local Function Prototypes and Local Variables
48
 *
49
 *****************************************************************************/
50
51
static int sk_proc_print(void *writePtr, char *format, ...);
52
static void sk_gen_browse(void *buffer);
53
static int len;
54
34
static int sk_seq_show(struct seq_file *seq, void *v);
55
static int sk_seq_show(struct seq_file *seq, void *v);
35
static int sk_proc_open(struct inode *inode, struct file *file);
56
static int sk_proc_open(struct inode *inode, struct file *file);
36
37
struct file_operations sk_proc_fops = {
57
struct file_operations sk_proc_fops = {
38
	.owner		= THIS_MODULE,
58
	.owner		= THIS_MODULE,
39
	.open		= sk_proc_open,
59
	.open		= sk_proc_open,
Lines 41-245 Link Here
41
	.llseek		= seq_lseek,
61
	.llseek		= seq_lseek,
42
	.release	= single_release,
62
	.release	= single_release,
43
};
63
};
44
64
struct net_device *currDev = NULL;
45
65
46
/*****************************************************************************
66
/*****************************************************************************
47
 *
67
 *
48
 *      sk_seq_show - show proc information of a particular adapter
68
 * 	sk_gen_browse -generic  print "summaries" entry 
49
 *
69
 *
50
 * Description:
70
 * Description:
51
 *  This function fills the proc entry with statistic data about 
71
 *	This function fills the proc entry with statistic data about 
52
 *  the ethernet device. It invokes the generic sk_gen_browse() to
72
 *	the ethernet device.
53
 *  print out all items one per one.
54
 *  
73
 *  
55
 * Returns: 0
74
 * Returns:	N/A
56
 *      
75
 *	
57
 */
76
 */
58
static int sk_seq_show(struct seq_file *seq, void *v)
77
static void sk_gen_browse(
78
void *buffer)  /* buffer where the statistics will be stored in */
59
{
79
{
60
	struct net_device *dev = seq->private;
80
	struct SK_NET_DEVICE	*SkgeProcDev = SkGeRootDev;
61
	DEV_NET			*pNet = netdev_priv(dev);
81
	struct SK_NET_DEVICE	*next;
62
	SK_AC			*pAC = pNet->pAC;
82
	SK_BOOL			DisableStatistic = 0;
63
	SK_PNMI_STRUCT_DATA 	*pPnmiStruct = &pAC->PnmiStruct;
83
	SK_PNMI_STRUCT_DATA 	*pPnmiStruct;
84
	SK_PNMI_STAT		*pPnmiStat;
64
	unsigned long		Flags;	
85
	unsigned long		Flags;	
65
	unsigned int		Size;
86
	unsigned int		Size;
87
	DEV_NET			*pNet;
88
	SK_AC			*pAC;
66
	char			sens_msg[50];
89
	char			sens_msg[50];
90
	int 			card_type;
91
	int			MaxSecurityCount = 0;
67
	int 			t;
92
	int 			t;
68
	int 			i;
93
	int 			i;
69
94
70
	/* NetIndex in GetStruct is now required, zero is only dummy */
95
	while (SkgeProcDev) {
71
	for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
96
		MaxSecurityCount++;
72
		if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
97
		if (MaxSecurityCount > 100) {
73
			t--;
98
			printk("Max limit for sk_proc_read security counter!\n");
74
99
			return;
75
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
76
		Size = SK_PNMI_STRUCT_SIZE;
77
#ifdef SK_DIAG_SUPPORT
78
		if (pAC->BoardLevel == SK_INIT_DATA) {
79
			SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
80
			if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
81
				pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
82
			}
83
		} else {
84
			SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
85
		}
100
		}
86
#else
101
		pNet = (DEV_NET*) SkgeProcDev->priv;
87
		SkPnmiGetStruct(pAC, pAC->IoBase, 
102
		pAC = pNet->pAC;
88
				pPnmiStruct, &Size, t-1);
103
		next = pAC->Next;
89
#endif
104
		pPnmiStruct = &pAC->PnmiStruct;
90
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
105
		/* NetIndex in GetStruct is now required, zero is only dummy */
106
107
		for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
108
			if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
109
				t--;
110
111
			spin_lock_irqsave(&pAC->SlowPathLock, Flags);
112
			Size = SK_PNMI_STRUCT_SIZE;
113
			DisableStatistic = 0;
114
			if (pAC->BoardLevel == SK_INIT_DATA) {
115
				SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
116
				if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
117
					pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
118
				}
119
			} else {
120
				SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
121
			}
122
			spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
123
			if (strcmp(pAC->dev[t-1]->name, currDev->name) == 0) {
124
				if (!pAC->GIni.GIYukon32Bit)
125
					card_type = 64;
126
				else
127
					card_type = 32;
128
129
				pPnmiStat = &pPnmiStruct->Stat[0];
130
				len = sk_proc_print(buffer, 
131
					"\nDetailed statistic for device %s\n",
132
					pAC->dev[t-1]->name);
133
				len += sk_proc_print(buffer,
134
					"=======================================\n");
91
	
135
	
92
		if (pAC->dev[t-1] == dev) {
136
				/* Board statistics */
93
			SK_PNMI_STAT	*pPnmiStat = &pPnmiStruct->Stat[0];
137
				len += sk_proc_print(buffer, 
138
					"\nBoard statistics\n\n");
139
				len += sk_proc_print(buffer,
140
					"Card name                      %s\n",
141
					pAC->DeviceStr);
142
				len += sk_proc_print(buffer,
143
					"Vendor/Device ID               %x/%x\n",
144
					pAC->PciDev->vendor,
145
					pAC->PciDev->device);
146
				len += sk_proc_print(buffer,
147
					"Card type (Bit)                %d\n",
148
					card_type);
149
					
150
				len += sk_proc_print(buffer,
151
					"Active Port                    %c\n",
152
					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
153
					Net[t-1].PrefPort]->PortNumber);
154
				len += sk_proc_print(buffer,
155
					"Preferred Port                 %c\n",
156
					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
157
					Net[t-1].PrefPort]->PortNumber);
158
159
				if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_STATIC) {
160
					len += sk_proc_print(buffer,
161
					"Interrupt Moderation           static (%d ints/sec)\n",
162
					pAC->DynIrqModInfo.MaxModIntsPerSec);
163
				} else if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_DYNAMIC) {
164
					len += sk_proc_print(buffer,
165
					"Interrupt Moderation           dynamic (%d ints/sec)\n",
166
					pAC->DynIrqModInfo.MaxModIntsPerSec);
167
				} else {
168
					len += sk_proc_print(buffer,
169
					"Interrupt Moderation           disabled\n");
170
				}
94
171
95
			seq_printf(seq, "\nDetailed statistic for device %s\n",
172
				if (pAC->GIni.GIPciBus == SK_PEX_BUS) {
96
				      pAC->dev[t-1]->name);
173
					len += sk_proc_print(buffer,
97
			seq_printf(seq, "=======================================\n");
174
						"Bus type                       PCI-Express\n");
98
	
175
					len += sk_proc_print(buffer,
99
			/* Board statistics */
176
						"Bus width (Lanes)              %d\n",
100
			seq_printf(seq, "\nBoard statistics\n\n");
177
						pAC->GIni.GIPexWidth);
101
			seq_printf(seq, "Active Port                    %c\n",
178
				} else {
102
				      'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
179
					if (pAC->GIni.GIPciBus == SK_PCIX_BUS) {
103
								    Net[t-1].PrefPort]->PortNumber);
180
						len += sk_proc_print(buffer,
104
			seq_printf(seq, "Preferred Port                 %c\n",
181
							"Bus type                       PCI-X\n");
105
				      'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
182
						if (pAC->GIni.GIPciMode == PCI_OS_SPD_X133) {
106
								    Net[t-1].PrefPort]->PortNumber);
183
							len += sk_proc_print(buffer,
107
184
								"Bus speed (MHz)                133\n");
108
			seq_printf(seq, "Bus speed (MHz)                %d\n",
185
						} else if (pAC->GIni.GIPciMode == PCI_OS_SPD_X100) {
109
				      pPnmiStruct->BusSpeed);
186
							len += sk_proc_print(buffer,
110
187
								"Bus speed (MHz)                100\n");
111
			seq_printf(seq, "Bus width (Bit)                %d\n",
188
						} else if (pAC->GIni.GIPciMode == PCI_OS_SPD_X66) {
112
				      pPnmiStruct->BusWidth);
189
							len += sk_proc_print(buffer,
113
			seq_printf(seq, "Driver version                 %s\n",
190
								"Bus speed (MHz)                66\n");
114
				      VER_STRING);
191
						} else {
115
			seq_printf(seq, "Hardware revision              v%d.%d\n",
192
							len += sk_proc_print(buffer,
116
				      (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
193
								"Bus speed (MHz)                33\n");
117
				      pAC->GIni.GIPciHwRev & 0x0F);
194
						}
118
195
					} else {
119
			/* Print sensor informations */
196
						len += sk_proc_print(buffer,
120
			for (i=0; i < pAC->I2c.MaxSens; i ++) {
197
							"Bus type                       PCI\n");
121
				/* Check type */
198
						len += sk_proc_print(buffer,
122
				switch (pAC->I2c.SenTable[i].SenType) {
199
							"Bus speed (MHz)                %d\n",
123
				case 1:
200
							pPnmiStruct->BusSpeed);
124
					strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
201
					}
125
					strcat(sens_msg, " (C)");
202
					len += sk_proc_print(buffer,
126
					seq_printf(seq, "%-25s      %d.%02d\n",
203
						"Bus width (Bit)                %d\n",
127
						      sens_msg,
204
						pPnmiStruct->BusWidth);
128
						      pAC->I2c.SenTable[i].SenValue / 10,
205
				}
129
						      pAC->I2c.SenTable[i].SenValue % 10);
206
130
207
				len += sk_proc_print(buffer,
131
					strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
208
					"Driver version                 %s (%s)\n",
132
					strcat(sens_msg, " (F)");
209
					VER_STRING, PATCHLEVEL);
133
					seq_printf(seq, "%-25s      %d.%02d\n",
210
				len += sk_proc_print(buffer,
134
						      sens_msg,
211
					"Driver release date            %s\n",
135
						      ((((pAC->I2c.SenTable[i].SenValue)
212
					pAC->Pnmi.pDriverReleaseDate);
136
							 *10)*9)/5 + 3200)/100,
213
				len += sk_proc_print(buffer,
137
						      ((((pAC->I2c.SenTable[i].SenValue)
214
					"Hardware revision              v%d.%d\n",
138
							 *10)*9)/5 + 3200) % 10);
215
					(pAC->GIni.GIPciHwRev >> 4) & 0x0F,
139
					break;
216
					pAC->GIni.GIPciHwRev & 0x0F);
140
				case 2:
217
141
					strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
218
				if (!netif_running(pAC->dev[t-1])) {
142
					strcat(sens_msg, " (V)");
219
					len += sk_proc_print(buffer,
143
					seq_printf(seq, "%-25s      %d.%03d\n",
220
						"\n      Device %s is down.\n"
144
						      sens_msg,
221
						"      Therefore no statistics are available.\n"
145
						      pAC->I2c.SenTable[i].SenValue / 1000,
222
						"      After bringing the device up (ifconfig)"
146
						      pAC->I2c.SenTable[i].SenValue % 1000);
223
						" statistics will\n"
147
					break;
224
						"      be displayed.\n",
148
				case 3:
225
						pAC->dev[t-1]->name);
149
					strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
226
					DisableStatistic = 1;
150
					strcat(sens_msg, " (rpm)");
151
					seq_printf(seq, "%-25s      %d\n",
152
						      sens_msg,
153
						      pAC->I2c.SenTable[i].SenValue);
154
					break;
155
				default:
156
					break;
157
				}
227
				}
158
			}
159
				
160
			/*Receive statistics */
161
			seq_printf(seq, "\nReceive statistics\n\n");
162
228
163
			seq_printf(seq, "Received bytes                 %Lu\n",
229
				/* Display only if statistic info available */
164
				      (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
230
				/* Print sensor informations */
165
			seq_printf(seq, "Received packets               %Lu\n",
231
				if (!DisableStatistic) {
166
				      (unsigned long long) pPnmiStat->StatRxOkCts);
232
					for (i=0; i < pAC->I2c.MaxSens; i ++) {
233
						/* Check type */
234
						switch (pAC->I2c.SenTable[i].SenType) {
235
						case 1:
236
							strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
237
							strcat(sens_msg, " (C)");
238
							len += sk_proc_print(buffer,
239
								"%-25s      %d.%02d\n",
240
								sens_msg,
241
								pAC->I2c.SenTable[i].SenValue / 10,
242
								pAC->I2c.SenTable[i].SenValue %
243
								10);
244
245
							strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
246
							strcat(sens_msg, " (F)");
247
							len += sk_proc_print(buffer,
248
								"%-25s      %d.%02d\n",
249
								sens_msg,
250
								((((pAC->I2c.SenTable[i].SenValue)
251
								*10)*9)/5 + 3200)/100,
252
								((((pAC->I2c.SenTable[i].SenValue)
253
								*10)*9)/5 + 3200) % 10);
254
							break;
255
						case 2:
256
							strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
257
							strcat(sens_msg, " (V)");
258
							len += sk_proc_print(buffer,
259
								"%-25s      %d.%03d\n",
260
								sens_msg,
261
								pAC->I2c.SenTable[i].SenValue / 1000,
262
								pAC->I2c.SenTable[i].SenValue % 1000);
263
							break;
264
						case 3:
265
							strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
266
							strcat(sens_msg, " (rpm)");
267
							len += sk_proc_print(buffer,
268
								"%-25s      %d\n",
269
								sens_msg,
270
								pAC->I2c.SenTable[i].SenValue);
271
							break;
272
						default:
273
							break;
274
						}
275
					}
276
			
277
					/*Receive statistics */
278
					len += sk_proc_print(buffer, 
279
					"\nReceive statistics\n\n");
280
281
					len += sk_proc_print(buffer,
282
						"Received bytes                 %Lu\n",
283
						(unsigned long long) pPnmiStat->StatRxOctetsOkCts);
284
					len += sk_proc_print(buffer,
285
						"Received packets               %Lu\n",
286
						(unsigned long long) pPnmiStat->StatRxOkCts);
167
#if 0
287
#if 0
168
			if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && 
288
					if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && 
169
			    pAC->HWRevision < 12) {
289
						pAC->HWRevision < 12) {
170
				pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts - 
290
						pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts - 
171
					pPnmiStat->StatRxShortsCts;
291
							pPnmiStat->StatRxShortsCts;
172
				pPnmiStat->StatRxShortsCts = 0;
292
						pPnmiStat->StatRxShortsCts = 0;
173
			}
293
					}
294
#endif
295
					if (pAC->dev[t-1]->mtu > 1500) 
296
						pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
297
							pPnmiStat->StatRxTooLongCts;
298
299
					len += sk_proc_print(buffer,
300
						"Receive errors                 %Lu\n",
301
						(unsigned long long) pPnmiStruct->InErrorsCts);
302
					len += sk_proc_print(buffer,
303
						"Receive dropped                %Lu\n",
304
						(unsigned long long) pPnmiStruct->RxNoBufCts);
305
					len += sk_proc_print(buffer,
306
						"Received multicast             %Lu\n",
307
						(unsigned long long) pPnmiStat->StatRxMulticastOkCts);
308
#ifdef ADVANCED_STATISTIC_OUTPUT
309
					len += sk_proc_print(buffer,
310
						"Receive error types\n");
311
					len += sk_proc_print(buffer,
312
						"   length                      %Lu\n",
313
						(unsigned long long) pPnmiStat->StatRxRuntCts);
314
					len += sk_proc_print(buffer,
315
						"   buffer overflow             %Lu\n",
316
						(unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
317
					len += sk_proc_print(buffer,
318
						"   bad crc                     %Lu\n",
319
						(unsigned long long) pPnmiStat->StatRxFcsCts);
320
					len += sk_proc_print(buffer,
321
						"   framing                     %Lu\n",
322
						(unsigned long long) pPnmiStat->StatRxFramingCts);
323
					len += sk_proc_print(buffer,
324
						"   missed frames               %Lu\n",
325
						(unsigned long long) pPnmiStat->StatRxMissedCts);
326
327
					if (pAC->dev[t-1]->mtu > 1500)
328
						pPnmiStat->StatRxTooLongCts = 0;
329
330
					len += sk_proc_print(buffer,
331
						"   too long                    %Lu\n",
332
						(unsigned long long) pPnmiStat->StatRxTooLongCts);					
333
					len += sk_proc_print(buffer,
334
						"   carrier extension           %Lu\n",
335
						(unsigned long long) pPnmiStat->StatRxCextCts);				
336
					len += sk_proc_print(buffer,
337
						"   too short                   %Lu\n",
338
						(unsigned long long) pPnmiStat->StatRxShortsCts);				
339
					len += sk_proc_print(buffer,
340
						"   symbol                      %Lu\n",
341
						(unsigned long long) pPnmiStat->StatRxSymbolCts);				
342
					len += sk_proc_print(buffer,
343
						"   LLC MAC size                %Lu\n",
344
						(unsigned long long) pPnmiStat->StatRxIRLengthCts);				
345
					len += sk_proc_print(buffer,
346
						"   carrier event               %Lu\n",
347
						(unsigned long long) pPnmiStat->StatRxCarrierCts);				
348
					len += sk_proc_print(buffer,
349
						"   jabber                      %Lu\n",
350
						(unsigned long long) pPnmiStat->StatRxJabberCts);				
174
#endif
351
#endif
175
			if (dev->mtu > 1500)
176
				pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
177
					pPnmiStat->StatRxTooLongCts;
178
179
			seq_printf(seq, "Receive errors                 %Lu\n",
180
				      (unsigned long long) pPnmiStruct->InErrorsCts);
181
			seq_printf(seq, "Receive dropped                %Lu\n",
182
				      (unsigned long long) pPnmiStruct->RxNoBufCts);
183
			seq_printf(seq, "Received multicast             %Lu\n",
184
				      (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
185
			seq_printf(seq, "Receive error types\n");
186
			seq_printf(seq, "   length                      %Lu\n",
187
				      (unsigned long long) pPnmiStat->StatRxRuntCts);
188
			seq_printf(seq, "   buffer overflow             %Lu\n",
189
				      (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
190
			seq_printf(seq, "   bad crc                     %Lu\n",
191
				      (unsigned long long) pPnmiStat->StatRxFcsCts);
192
			seq_printf(seq, "   framing                     %Lu\n",
193
				      (unsigned long long) pPnmiStat->StatRxFramingCts);
194
			seq_printf(seq, "   missed frames               %Lu\n",
195
				      (unsigned long long) pPnmiStat->StatRxMissedCts);
196
197
			if (dev->mtu > 1500)
198
				pPnmiStat->StatRxTooLongCts = 0;
199
200
			seq_printf(seq, "   too long                    %Lu\n",
201
				      (unsigned long long) pPnmiStat->StatRxTooLongCts);					
202
			seq_printf(seq, "   carrier extension           %Lu\n",
203
				      (unsigned long long) pPnmiStat->StatRxCextCts);				
204
			seq_printf(seq, "   too short                   %Lu\n",
205
				      (unsigned long long) pPnmiStat->StatRxShortsCts);				
206
			seq_printf(seq, "   symbol                      %Lu\n",
207
				      (unsigned long long) pPnmiStat->StatRxSymbolCts);				
208
			seq_printf(seq, "   LLC MAC size                %Lu\n",
209
				      (unsigned long long) pPnmiStat->StatRxIRLengthCts);				
210
			seq_printf(seq, "   carrier event               %Lu\n",
211
				      (unsigned long long) pPnmiStat->StatRxCarrierCts);				
212
			seq_printf(seq, "   jabber                      %Lu\n",
213
				      (unsigned long long) pPnmiStat->StatRxJabberCts);				
214
215
352
216
			/*Transmit statistics */
353
					/*Transmit statistics */
217
			seq_printf(seq, "\nTransmit statistics\n\n");
354
					len += sk_proc_print(buffer, 
355
					"\nTransmit statistics\n\n");
218
				
356
				
219
			seq_printf(seq, "Transmited bytes               %Lu\n",
357
					len += sk_proc_print(buffer,
220
				      (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
358
						"Transmitted bytes              %Lu\n",
221
			seq_printf(seq, "Transmited packets             %Lu\n",
359
						(unsigned long long) pPnmiStat->StatTxOctetsOkCts);
222
				      (unsigned long long) pPnmiStat->StatTxOkCts);
360
					len += sk_proc_print(buffer,
223
			seq_printf(seq, "Transmit errors                %Lu\n",
361
						"Transmitted packets            %Lu\n",
224
				      (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
362
						(unsigned long long) pPnmiStat->StatTxOkCts);
225
			seq_printf(seq, "Transmit dropped               %Lu\n",
363
					len += sk_proc_print(buffer,
226
				      (unsigned long long) pPnmiStruct->TxNoBufCts);
364
						"Transmit errors                %Lu\n",
227
			seq_printf(seq, "Transmit collisions            %Lu\n",
365
						(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
228
				      (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
366
					len += sk_proc_print(buffer,
229
			seq_printf(seq, "Transmit error types\n");
367
						"Transmit dropped               %Lu\n",
230
			seq_printf(seq, "   excessive collision         %ld\n",
368
						(unsigned long long) pPnmiStruct->TxNoBufCts);
231
				      pAC->stats.tx_aborted_errors);
369
					len += sk_proc_print(buffer,
232
			seq_printf(seq, "   carrier                     %Lu\n",
370
						"Transmit collisions            %Lu\n",
233
				      (unsigned long long) pPnmiStat->StatTxCarrierCts);
371
						(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
234
			seq_printf(seq, "   fifo underrun               %Lu\n",
372
#ifdef ADVANCED_STATISTIC_OUTPUT
235
				      (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
373
					len += sk_proc_print(buffer,
236
			seq_printf(seq, "   heartbeat                   %Lu\n",
374
						"Transmit error types\n");
237
				      (unsigned long long) pPnmiStat->StatTxCarrierCts);
375
					len += sk_proc_print(buffer,
238
			seq_printf(seq, "   window                      %ld\n",
376
						"   excessive collision         %ld\n",
239
				      pAC->stats.tx_window_errors);
377
						pAC->stats.tx_aborted_errors);
378
					len += sk_proc_print(buffer,
379
						"   carrier                     %Lu\n",
380
						(unsigned long long) pPnmiStat->StatTxCarrierCts);
381
					len += sk_proc_print(buffer,
382
						"   fifo underrun               %Lu\n",
383
						(unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
384
					len += sk_proc_print(buffer,
385
						"   heartbeat                   %Lu\n",
386
						(unsigned long long) pPnmiStat->StatTxCarrierCts);
387
					len += sk_proc_print(buffer,
388
						"   window                      %ld\n",
389
						pAC->stats.tx_window_errors);
390
#endif
391
				} /* if (!DisableStatistic) */
240
				
392
				
393
			} /* if (strcmp(pACname, currDeviceName) == 0) */
241
		}
394
		}
395
		SkgeProcDev = next;
242
	}
396
	}
397
}
398
399
/*****************************************************************************
400
 *
401
 *      sk_proc_print - generic line print  
402
 *
403
 * Description:
404
 *	This function fills the proc entry with statistic data about the 
405
 *	ethernet device.
406
 *  
407
 * Returns:
408
 *	the number of bytes written
409
 *      
410
 */ 
411
static int sk_proc_print(
412
void *writePtr, /* the buffer pointer         */
413
char *format,   /* the format of the string   */
414
...)            /* variable list of arguments */
415
{   
416
#define MAX_LEN_SINGLE_LINE 256
417
	char     str[MAX_LEN_SINGLE_LINE];
418
	va_list  a_start;
419
	int      lenght = 0;
420
421
	struct seq_file *seq = (struct seq_file *) writePtr;
422
423
	SK_MEMSET(str, 0, MAX_LEN_SINGLE_LINE);
424
425
	va_start(a_start, format);
426
	vsprintf(str, format, a_start);
427
	va_end(a_start);
428
429
	lenght = strlen(str);
430
431
	seq_printf(seq, str);
432
	return lenght;
433
}
434
435
/*****************************************************************************
436
 *
437
 *      sk_seq_show - show proc information of a particular adapter
438
 *
439
 * Description:
440
 *	This function fills the proc entry with statistic data about the
441
 *	ethernet device. It invokes the generic sk_gen_browse() to print
442
 *	out all items one per one.
443
 *  
444
 * Returns:
445
 *	the number of bytes written
446
 *      
447
 */
448
static int sk_seq_show(
449
struct seq_file *seq,  /* the sequence pointer */
450
void            *v)    /* additional pointer   */
451
{
452
	void *castedBuffer = (void *) seq;
453
	currDev = seq->private;
454
	sk_gen_browse(castedBuffer);
243
	return 0;
455
	return 0;
244
}
456
}
245
457
Lines 248-261 Link Here
248
 *      sk_proc_open - register the show function when proc is open'ed
460
 *      sk_proc_open - register the show function when proc is open'ed
249
 *  
461
 *  
250
 * Description:
462
 * Description:
251
 *  This function is called whenever a sk98lin proc file is queried.
463
 *	This function is called whenever a sk98lin proc file is queried.
252
 *  
464
 *  
253
 * Returns: the return value of single_open()
465
 * Returns:
466
 *	the return value of single_open()
254
 *      
467
 *      
255
 */
468
 */
256
static int sk_proc_open(struct inode *inode, struct file *file)
469
static int sk_proc_open(
470
struct inode *inode,  /* the inode of the file   */
471
struct file  *file)   /* the file pointer itself */
257
{
472
{
258
    return single_open(file, sk_seq_show, PDE(inode)->data);
473
	return single_open(file, sk_seq_show, PDE(inode)->data);
259
}
474
}
260
475
261
/*******************************************************************************
476
/*******************************************************************************
(-)linux/drivers/net/sk98lin/skqueue.c (-23 / +80 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skqueue.c
3
 * Name:	skqueue.c
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
5
 * Version:	$Revision: 1.20 $
5
 * Version:	$Revision: 2.3 $
6
 * Date:	$Date: 2003/09/16 13:44:00 $
6
 * Date:	$Date: 2004/05/14 13:28:18 $
7
 * Purpose:	Management of an event queue.
7
 * Purpose:	Management of an event queue.
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 28-34 Link Here
28
 */
28
 */
29
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
29
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
30
static const char SysKonnectFileId[] =
30
static const char SysKonnectFileId[] =
31
	"@(#) $Id: skqueue.c,v 1.20 2003/09/16 13:44:00 rschmidt Exp $ (C) Marvell.";
31
	"@(#) $Id: skqueue.c,v 2.3 2004/05/14 13:28:18 malthoff Exp $ (C) Marvell.";
32
#endif
32
#endif
33
33
34
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
34
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
Lines 48-57 Link Here
48
48
49
#define PRINTF(a,b,c)
49
#define PRINTF(a,b,c)
50
50
51
/*
51
/******************************************************************************
52
 * init event queue management
52
 *
53
 *	SkEventInit() - init event queue management
53
 *
54
 *
54
 * Must be called during init level 0.
55
 * Description:
56
 * 	This function initializes event queue management.
57
 *	It must be called during init level 0.
58
 *
59
 * Returns:
60
 *	nothing
55
 */
61
 */
56
void	SkEventInit(
62
void	SkEventInit(
57
SK_AC	*pAC,	/* Adapter context */
63
SK_AC	*pAC,	/* Adapter context */
Lines 67-74 Link Here
67
	}
73
	}
68
}
74
}
69
75
70
/*
76
/******************************************************************************
71
 * add event to queue
77
 *
78
 *	SkEventQueue()	-	add event to queue
79
 *
80
 * Description:
81
 *	This function adds an event to the event queue.
82
 *	At least Init Level 1 is required to queue events,
83
 *	but will be scheduled add Init Level 2.
84
 *
85
 * returns:
86
 *	nothing
72
 */
87
 */
73
void	SkEventQueue(
88
void	SkEventQueue(
74
SK_AC		*pAC,	/* Adapters context */
89
SK_AC		*pAC,	/* Adapters context */
Lines 76-101 Link Here
76
SK_U32		Event,	/* Event to be queued */
91
SK_U32		Event,	/* Event to be queued */
77
SK_EVPARA	Para)	/* Event parameter */
92
SK_EVPARA	Para)	/* Event parameter */
78
{
93
{
79
	pAC->Event.EvPut->Class = Class;
94
80
	pAC->Event.EvPut->Event = Event;
95
	if (pAC->GIni.GILevel == SK_INIT_DATA) {
81
	pAC->Event.EvPut->Para = Para;
96
		SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E003, SKERR_Q_E003MSG);
97
	}
98
	else {
99
		pAC->Event.EvPut->Class = Class;
100
		pAC->Event.EvPut->Event = Event;
101
		pAC->Event.EvPut->Para = Para;
82
	
102
	
83
	if (++pAC->Event.EvPut == &pAC->Event.EvQueue[SK_MAX_EVENT])
103
		if (++pAC->Event.EvPut == &pAC->Event.EvQueue[SK_MAX_EVENT])
84
		pAC->Event.EvPut = pAC->Event.EvQueue;
104
			pAC->Event.EvPut = pAC->Event.EvQueue;
85
105
86
	if (pAC->Event.EvPut == pAC->Event.EvGet) {
106
		if (pAC->Event.EvPut == pAC->Event.EvGet) {
87
		SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG);
107
			SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG);
108
		}
88
	}
109
	}
89
}
110
}
90
111
91
/*
112
/******************************************************************************
92
 * event dispatcher
113
 *
93
 *	while event queue is not empty
114
 *	SkEventDispatcher() -	 Event Dispatcher
94
 *		get event from queue
115
 *
95
 *		send command to state machine
116
 * Description:
96
 *	end
117
 *	The event dispatcher performs the following operations:
97
 *	return error reported by individual Event function
118
 *		o while event queue is not empty
98
 *		0 if no error occured.
119
 *			- get event from queue
120
 *			- send event to state machine
121
 *		  end
122
 *
123
 * CAUTION:
124
 *	The event functions MUST report an error if performing a reinitialization
125
 *	of the event queue, e.g. performing level Init 0..2 while in dispatcher
126
 *	call!
127
 *  ANY OTHER return value delays scheduling the other events in the
128
 *	queue. In this case the event blocks the queue until
129
 *  the error condition is cleared!
130
 *
131
 * Returns:
132
 *	The return value error reported by individual event function
99
 */
133
 */
100
int	SkEventDispatcher(
134
int	SkEventDispatcher(
101
SK_AC	*pAC,	/* Adapters Context */
135
SK_AC	*pAC,	/* Adapters Context */
Lines 105-110 Link Here
105
	SK_U32			Class;
139
	SK_U32			Class;
106
	int			Rtv;
140
	int			Rtv;
107
141
142
	if (pAC->GIni.GILevel != SK_INIT_RUN) {
143
		SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E005, SKERR_Q_E005MSG);
144
	}
145
108
	pEv = pAC->Event.EvGet;
146
	pEv = pAC->Event.EvGet;
109
	
147
	
110
	PRINTF("dispatch get %x put %x\n", pEv, pAC->Event.ev_put);
148
	PRINTF("dispatch get %x put %x\n", pEv, pAC->Event.ev_put);
Lines 152-157 Link Here
152
			Rtv = SkFdEvent(pAC, Ioc, pEv->Event, pEv->Para);
190
			Rtv = SkFdEvent(pAC, Ioc, pEv->Event, pEv->Para);
153
			break;
191
			break;
154
#endif /* SK_USE_LAC_EV */
192
#endif /* SK_USE_LAC_EV */
193
#ifdef SK_ASF
194
		case SKGE_ASF :
195
			Rtv = SkAsfEvent(pAC,Ioc,pEv->Event,pEv->Para);
196
			break ;
197
#endif
155
#ifdef	SK_USE_CSUM
198
#ifdef	SK_USE_CSUM
156
		case SKGE_CSUM :
199
		case SKGE_CSUM :
157
			Rtv = SkCsEvent(pAC, Ioc, pEv->Event, pEv->Para);
200
			Rtv = SkCsEvent(pAC, Ioc, pEv->Event, pEv->Para);
Lines 163-168 Link Here
163
		}
206
		}
164
207
165
		if (Rtv != 0) {
208
		if (Rtv != 0) {
209
			/* 
210
			 * Special Case: See CAUTION statement above.
211
			 * We assume the event queue is reset.
212
			 */
213
			if (pAC->Event.EvGet != pAC->Event.EvQueue &&
214
				pAC->Event.EvGet != pEv) {
215
				/*
216
				 * Create an error log entry if the
217
				 * event queue isn't reset.
218
				 * In this case it may be blocked.
219
				 */
220
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E004, SKERR_Q_E004MSG);
221
			}
222
166
			return(Rtv);
223
			return(Rtv);
167
		}
224
		}
168
225
(-)linux/drivers/net/sk98lin/skrlmt.c (-129 / +129 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skrlmt.c
3
 * Name:	skrlmt.c
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
5
 * Version:	$Revision: 1.69 $
5
 * Version:	$Revision: 2.2 $
6
 * Date:	$Date: 2003/04/15 09:39:22 $
6
 * Date:	$Date: 2003/11/24 12:27:57 $
7
 * Purpose:	Manage links on SK-NET Adapters, esp. redundant ones.
7
 * Purpose:	Manage links on SK-NET Adapters, esp. redundant ones.
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 39-45 Link Here
39
39
40
#ifndef	lint
40
#ifndef	lint
41
static const char SysKonnectFileId[] =
41
static const char SysKonnectFileId[] =
42
	"@(#) $Id: skrlmt.c,v 1.69 2003/04/15 09:39:22 tschilli Exp $ (C) Marvell.";
42
	"@(#) $Id: skrlmt.c,v 2.2 2003/11/24 12:27:57 mkarl Exp $ (C) Marvell.";
43
#endif	/* !defined(lint) */
43
#endif	/* !defined(lint) */
44
44
45
#define __SKRLMT_C
45
#define __SKRLMT_C
Lines 350-356 Link Here
350
    SK_BOOL		PhysicalAMacAddressSet;
350
    SK_BOOL		PhysicalAMacAddressSet;
351
351
352
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_INIT,
352
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_INIT,
353
		("RLMT Init level %d.\n", Level))
353
		("RLMT Init level %d.\n", Level));
354
354
355
	switch (Level) {
355
	switch (Level) {
356
	case SK_INIT_DATA:	/* Initialize data structures. */
356
	case SK_INIT_DATA:	/* Initialize data structures. */
Lines 390-396 Link Here
390
390
391
	case SK_INIT_IO:	/* GIMacsFound first available here. */
391
	case SK_INIT_IO:	/* GIMacsFound first available here. */
392
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_INIT,
392
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_INIT,
393
			("RLMT: %d MACs were detected.\n", pAC->GIni.GIMacsFound))
393
			("RLMT: %d MACs were detected.\n", pAC->GIni.GIMacsFound));
394
394
395
		pAC->Rlmt.Net[0].NumPorts = pAC->GIni.GIMacsFound;
395
		pAC->Rlmt.Net[0].NumPorts = pAC->GIni.GIMacsFound;
396
396
Lines 512-518 Link Here
512
	}
512
	}
513
			
513
			
514
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
514
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
515
		("SkRlmtBuildCheckChain.\n"))
515
		("SkRlmtBuildCheckChain.\n"));
516
516
517
	NumMacsUp = 0;
517
	NumMacsUp = 0;
518
518
Lines 558-564 Link Here
558
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
558
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
559
			("Port %d checks %d other ports: %2X.\n", i,
559
			("Port %d checks %d other ports: %2X.\n", i,
560
				pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked,
560
				pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked,
561
				pAC->Rlmt.Net[NetIdx].Port[i]->PortCheck[0].CheckAddr.a[5]))
561
				pAC->Rlmt.Net[NetIdx].Port[i]->PortCheck[0].CheckAddr.a[5]));
562
	}
562
	}
563
#endif	/* DEBUG */
563
#endif	/* DEBUG */
564
564
Lines 604-610 Link Here
604
	if ((CheckSrc == 0) || (CheckDest == 0)) {
604
	if ((CheckSrc == 0) || (CheckDest == 0)) {
605
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_ERR,
605
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_ERR,
606
			("SkRlmtBuildPacket: Invalid %s%saddr.\n",
606
			("SkRlmtBuildPacket: Invalid %s%saddr.\n",
607
			 (CheckSrc == 0 ? "Src" : ""), (CheckDest == 0 ? "Dest" : "")))
607
			 (CheckSrc == 0 ? "Src" : ""), (CheckDest == 0 ? "Dest" : "")));
608
	}
608
	}
609
#endif
609
#endif
610
610
Lines 796-802 Link Here
796
796
797
			SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
797
			SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
798
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_TX,
798
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_TX,
799
				("SkRlmtSend: BPDU Packet on Port %u.\n", PortNumber))
799
				("SkRlmtSend: BPDU Packet on Port %u.\n", PortNumber));
800
		}
800
		}
801
	}
801
	}
802
	return;
802
	return;
Lines 835-841 Link Here
835
		 * Bring it up.
835
		 * Bring it up.
836
		 */
836
		 */
837
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
837
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
838
			("SkRlmtPacketReceive: Received on PortDown.\n"))
838
			("SkRlmtPacketReceive: Received on PortDown.\n"));
839
839
840
		pRPort->PortState = SK_RLMT_PS_GOING_UP;
840
		pRPort->PortState = SK_RLMT_PS_GOING_UP;
841
		pRPort->GuTimeStamp = SkOsGetTime(pAC);
841
		pRPort->GuTimeStamp = SkOsGetTime(pAC);
Lines 849-855 Link Here
849
	}	/* PortDown && !SuspectTx */
849
	}	/* PortDown && !SuspectTx */
850
	else if (pRPort->CheckingState & SK_RLMT_PCS_RX) {
850
	else if (pRPort->CheckingState & SK_RLMT_PCS_RX) {
851
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
851
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
852
			("SkRlmtPacketReceive: Stop bringing port down.\n"))
852
			("SkRlmtPacketReceive: Stop bringing port down.\n"));
853
		SkTimerStop(pAC, IoC, &pRPort->DownRxTimer);
853
		SkTimerStop(pAC, IoC, &pRPort->DownRxTimer);
854
		pRPort->CheckingState &= ~SK_RLMT_PCS_RX;
854
		pRPort->CheckingState &= ~SK_RLMT_PCS_RX;
855
		/* pAC->Rlmt.CheckSwitch = SK_TRUE; */
855
		/* pAC->Rlmt.CheckSwitch = SK_TRUE; */
Lines 896-902 Link Here
896
	pRPort = &pAC->Rlmt.Port[PortNumber];
896
	pRPort = &pAC->Rlmt.Port[PortNumber];
897
897
898
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
898
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
899
		("SkRlmtPacketReceive: PortNumber == %d.\n", PortNumber))
899
		("SkRlmtPacketReceive: PortNumber == %d.\n", PortNumber));
900
900
901
	pRPacket = (SK_RLMT_PACKET*)pMb->pData;
901
	pRPacket = (SK_RLMT_PACKET*)pMb->pData;
902
	pSPacket = (SK_SPTREE_PACKET*)pRPacket;
902
	pSPacket = (SK_SPTREE_PACKET*)pRPacket;
Lines 917-923 Link Here
917
917
918
		/* Not sent to current MAC or registered MC address => Trash it. */
918
		/* Not sent to current MAC or registered MC address => Trash it. */
919
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
919
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
920
			("SkRlmtPacketReceive: Not for me.\n"))
920
			("SkRlmtPacketReceive: Not for me.\n"));
921
921
922
		SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
922
		SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
923
		return;
923
		return;
Lines 955-961 Link Here
955
			pRPacket->Indicator[5] == SK_RLMT_INDICATOR5 &&
955
			pRPacket->Indicator[5] == SK_RLMT_INDICATOR5 &&
956
			pRPacket->Indicator[6] == SK_RLMT_INDICATOR6) {
956
			pRPacket->Indicator[6] == SK_RLMT_INDICATOR6) {
957
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
957
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
958
				("SkRlmtPacketReceive: Duplicate MAC Address.\n"))
958
				("SkRlmtPacketReceive: Duplicate MAC Address.\n"));
959
959
960
			/* Error Log entry. */
960
			/* Error Log entry. */
961
			SK_ERR_LOG(pAC, SK_ERRCL_COMM, SKERR_RLMT_E006, SKERR_RLMT_E006_MSG);
961
			SK_ERR_LOG(pAC, SK_ERRCL_COMM, SKERR_RLMT_E006, SKERR_RLMT_E006_MSG);
Lines 963-969 Link Here
963
		else {
963
		else {
964
			/* Simply trash it. */
964
			/* Simply trash it. */
965
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
965
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
966
				("SkRlmtPacketReceive: Sent by me.\n"))
966
				("SkRlmtPacketReceive: Sent by me.\n"));
967
		}
967
		}
968
968
969
		SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
969
		SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
Lines 1007-1013 Link Here
1007
#endif	/* 0 */
1007
#endif	/* 0 */
1008
1008
1009
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1009
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1010
				("SkRlmtPacketReceive: Announce.\n"))
1010
				("SkRlmtPacketReceive: Announce.\n"));
1011
1011
1012
			SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1012
			SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1013
			break;
1013
			break;
Lines 1015-1021 Link Here
1015
		case SK_PACKET_ALIVE:
1015
		case SK_PACKET_ALIVE:
1016
			if (pRPacket->SSap & LLC_COMMAND_RESPONSE_BIT) {
1016
			if (pRPacket->SSap & LLC_COMMAND_RESPONSE_BIT) {
1017
				SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1017
				SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1018
					("SkRlmtPacketReceive: Alive Reply.\n"))
1018
					("SkRlmtPacketReceive: Alive Reply.\n"));
1019
1019
1020
				if (!(pAC->Addr.Port[PortNumber].PromMode & SK_PROM_MODE_LLC) ||
1020
				if (!(pAC->Addr.Port[PortNumber].PromMode & SK_PROM_MODE_LLC) ||
1021
					SK_ADDR_EQUAL(
1021
					SK_ADDR_EQUAL(
Lines 1046-1052 Link Here
1046
			}
1046
			}
1047
			else {	/* Alive Request Packet. */
1047
			else {	/* Alive Request Packet. */
1048
				SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1048
				SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1049
					("SkRlmtPacketReceive: Alive Request.\n"))
1049
					("SkRlmtPacketReceive: Alive Request.\n"));
1050
1050
1051
				pRPort->RxHelloCts++;
1051
				pRPort->RxHelloCts++;
1052
1052
Lines 1065-1071 Link Here
1065
1065
1066
		case SK_PACKET_CHECK_TX:
1066
		case SK_PACKET_CHECK_TX:
1067
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1067
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1068
				("SkRlmtPacketReceive: Check your tx line.\n"))
1068
				("SkRlmtPacketReceive: Check your tx line.\n"));
1069
1069
1070
			/* A port checking us requests us to check our tx line. */
1070
			/* A port checking us requests us to check our tx line. */
1071
			pRPort->CheckingState |= SK_RLMT_PCS_TX;
1071
			pRPort->CheckingState |= SK_RLMT_PCS_TX;
Lines 1088-1094 Link Here
1088
1088
1089
		case SK_PACKET_ADDR_CHANGED:
1089
		case SK_PACKET_ADDR_CHANGED:
1090
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1090
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1091
				("SkRlmtPacketReceive: Address Change.\n"))
1091
				("SkRlmtPacketReceive: Address Change.\n"));
1092
1092
1093
			/* Build the check chain. */
1093
			/* Build the check chain. */
1094
			SkRlmtBuildCheckChain(pAC, pRPort->Net->NetNumber);
1094
			SkRlmtBuildCheckChain(pAC, pRPort->Net->NetNumber);
Lines 1097-1103 Link Here
1097
1097
1098
		default:
1098
		default:
1099
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1099
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1100
				("SkRlmtPacketReceive: Unknown RLMT packet.\n"))
1100
				("SkRlmtPacketReceive: Unknown RLMT packet.\n"));
1101
1101
1102
			/* RA;:;: ??? */
1102
			/* RA;:;: ??? */
1103
			SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1103
			SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
Lines 1107-1113 Link Here
1107
		pSPacket->Ctrl == SK_RLMT_SPT_CTRL &&
1107
		pSPacket->Ctrl == SK_RLMT_SPT_CTRL &&
1108
		(pSPacket->SSap & ~LLC_COMMAND_RESPONSE_BIT) == SK_RLMT_SPT_SSAP) {
1108
		(pSPacket->SSap & ~LLC_COMMAND_RESPONSE_BIT) == SK_RLMT_SPT_SSAP) {
1109
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1109
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1110
			("SkRlmtPacketReceive: BPDU Packet.\n"))
1110
			("SkRlmtPacketReceive: BPDU Packet.\n"));
1111
1111
1112
		/* Spanning Tree packet. */
1112
		/* Spanning Tree packet. */
1113
		pRPort->RxSpHelloCts++;
1113
		pRPort->RxSpHelloCts++;
Lines 1139-1145 Link Here
1139
					pRPort->Root.Id[0], pRPort->Root.Id[1],
1139
					pRPort->Root.Id[0], pRPort->Root.Id[1],
1140
					pRPort->Root.Id[2], pRPort->Root.Id[3],
1140
					pRPort->Root.Id[2], pRPort->Root.Id[3],
1141
					pRPort->Root.Id[4], pRPort->Root.Id[5],
1141
					pRPort->Root.Id[4], pRPort->Root.Id[5],
1142
					pRPort->Root.Id[6], pRPort->Root.Id[7]))
1142
					pRPort->Root.Id[6], pRPort->Root.Id[7]));
1143
		}
1143
		}
1144
1144
1145
		SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1145
		SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
Lines 1150-1156 Link Here
1150
	}
1150
	}
1151
	else {
1151
	else {
1152
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1152
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1153
			("SkRlmtPacketReceive: Unknown Packet Type.\n"))
1153
			("SkRlmtPacketReceive: Unknown Packet Type.\n"));
1154
1154
1155
		/* Unknown packet. */
1155
		/* Unknown packet. */
1156
		SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1156
		SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
Lines 1232-1238 Link Here
1232
	if ((pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot) == 0) {
1232
	if ((pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot) == 0) {
1233
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1233
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1234
			("SkRlmtCheckPort %d: No (%d) receives in last time slot.\n",
1234
			("SkRlmtCheckPort %d: No (%d) receives in last time slot.\n",
1235
				PortNumber, pRPort->PacketsPerTimeSlot))
1235
				PortNumber, pRPort->PacketsPerTimeSlot));
1236
1236
1237
		/*
1237
		/*
1238
		 * Check segmentation if there was no receive at least twice
1238
		 * Check segmentation if there was no receive at least twice
Lines 1249-1255 Link Here
1249
1249
1250
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1250
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1251
			("SkRlmtCheckPort: PortsSuspect %d, PcsRx %d.\n",
1251
			("SkRlmtCheckPort: PortsSuspect %d, PcsRx %d.\n",
1252
				pRPort->PortsSuspect, pRPort->CheckingState & SK_RLMT_PCS_RX))
1252
				pRPort->PortsSuspect, pRPort->CheckingState & SK_RLMT_PCS_RX));
1253
1253
1254
		if (pRPort->PortState != SK_RLMT_PS_DOWN) {
1254
		if (pRPort->PortState != SK_RLMT_PS_DOWN) {
1255
			NewTimeout = TO_SHORTEN(pAC->Rlmt.Port[PortNumber].Net->TimeoutValue);
1255
			NewTimeout = TO_SHORTEN(pAC->Rlmt.Port[PortNumber].Net->TimeoutValue);
Lines 1295-1301 Link Here
1295
			("SkRlmtCheckPort %d: %d (%d) receives in last time slot.\n",
1295
			("SkRlmtCheckPort %d: %d (%d) receives in last time slot.\n",
1296
				PortNumber,
1296
				PortNumber,
1297
				pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot,
1297
				pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot,
1298
				pRPort->PacketsPerTimeSlot))
1298
				pRPort->PacketsPerTimeSlot));
1299
		
1299
		
1300
		SkRlmtPortReceives(pAC, IoC, PortNumber);
1300
		SkRlmtPortReceives(pAC, IoC, PortNumber);
1301
		if (pAC->Rlmt.CheckSwitch) {
1301
		if (pAC->Rlmt.CheckSwitch) {
Lines 1345-1351 Link Here
1345
				i,
1345
				i,
1346
   				pAC->Rlmt.Port[i].PortDown, pAC->Rlmt.Port[i].PortNoRx,
1346
   				pAC->Rlmt.Port[i].PortDown, pAC->Rlmt.Port[i].PortNoRx,
1347
				*((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_HI32),
1347
				*((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_HI32),
1348
				*((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_LO32)))
1348
				*((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_LO32)));
1349
1349
1350
		if (!pAC->Rlmt.Port[i].PortDown && !pAC->Rlmt.Port[i].PortNoRx) {
1350
		if (!pAC->Rlmt.Port[i].PortDown && !pAC->Rlmt.Port[i].PortNoRx) {
1351
			if (!PortFound || pAC->Rlmt.Port[i].BcTimeStamp > BcTimeStamp) {
1351
			if (!PortFound || pAC->Rlmt.Port[i].BcTimeStamp > BcTimeStamp) {
Lines 1358-1364 Link Here
1358
1358
1359
	if (PortFound) {
1359
	if (PortFound) {
1360
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1360
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1361
			("Port %d received the last broadcast.\n", *pSelect))
1361
			("Port %d received the last broadcast.\n", *pSelect));
1362
1362
1363
		/* Look if another port's time stamp is similar. */
1363
		/* Look if another port's time stamp is similar. */
1364
		for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1364
		for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
Lines 1373-1379 Link Here
1373
				PortFound = SK_FALSE;
1373
				PortFound = SK_FALSE;
1374
				
1374
				
1375
				SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1375
				SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1376
					("Port %d received a broadcast at a similar time.\n", i))
1376
					("Port %d received a broadcast at a similar time.\n", i));
1377
				break;
1377
				break;
1378
			}
1378
			}
1379
		}
1379
		}
Lines 1385-1391 Link Here
1385
			("SK_RLMT_SELECT_BCRX found Port %d receiving the substantially "
1385
			("SK_RLMT_SELECT_BCRX found Port %d receiving the substantially "
1386
			 "latest broadcast (%u).\n",
1386
			 "latest broadcast (%u).\n",
1387
				*pSelect,
1387
				*pSelect,
1388
				BcTimeStamp - pAC->Rlmt.Port[1 - *pSelect].BcTimeStamp))
1388
				BcTimeStamp - pAC->Rlmt.Port[1 - *pSelect].BcTimeStamp));
1389
	}
1389
	}
1390
#endif	/* DEBUG */
1390
#endif	/* DEBUG */
1391
1391
Lines 1434-1440 Link Here
1434
			PortFound = SK_TRUE;
1434
			PortFound = SK_TRUE;
1435
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1435
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1436
				("SK_RLMT_SELECT_NOTSUSPECT found Port %d up and not check RX.\n",
1436
				("SK_RLMT_SELECT_NOTSUSPECT found Port %d up and not check RX.\n",
1437
					*pSelect))
1437
					*pSelect));
1438
			break;
1438
			break;
1439
		}
1439
		}
1440
	}
1440
	}
Lines 1483-1489 Link Here
1483
			}
1483
			}
1484
			PortFound = SK_TRUE;
1484
			PortFound = SK_TRUE;
1485
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1485
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1486
				("SK_RLMT_SELECT_UP found Port %d up.\n", *pSelect))
1486
				("SK_RLMT_SELECT_UP found Port %d up.\n", *pSelect));
1487
			break;
1487
			break;
1488
		}
1488
		}
1489
	}
1489
	}
Lines 1544-1550 Link Here
1544
	}
1544
	}
1545
1545
1546
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1546
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1547
		("SK_RLMT_SELECT_GOINGUP found Port %d going up.\n", *pSelect))
1547
		("SK_RLMT_SELECT_GOINGUP found Port %d going up.\n", *pSelect));
1548
	return (SK_TRUE);
1548
	return (SK_TRUE);
1549
}	/* SkRlmtSelectGoingUp */
1549
}	/* SkRlmtSelectGoingUp */
1550
1550
Lines 1590-1596 Link Here
1590
			}
1590
			}
1591
			PortFound = SK_TRUE;
1591
			PortFound = SK_TRUE;
1592
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1592
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1593
				("SK_RLMT_SELECT_DOWN found Port %d down.\n", *pSelect))
1593
				("SK_RLMT_SELECT_DOWN found Port %d down.\n", *pSelect));
1594
			break;
1594
			break;
1595
		}
1595
		}
1596
	}
1596
	}
Lines 1788-1794 Link Here
1788
1788
1789
			if (Para.Para32[1] != Active) {
1789
			if (Para.Para32[1] != Active) {
1790
				SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1790
				SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1791
					("Active: %d, Para1: %d.\n", Active, Para.Para32[1]))
1791
					("Active: %d, Para1: %d.\n", Active, Para.Para32[1]));
1792
				pAC->Rlmt.Net[NetIdx].ActivePort = Para.Para32[1];
1792
				pAC->Rlmt.Net[NetIdx].ActivePort = Para.Para32[1];
1793
				Para.Para32[0] = pAC->Rlmt.Net[NetIdx].
1793
				Para.Para32[0] = pAC->Rlmt.Net[NetIdx].
1794
					Port[Para.Para32[0]]->PortNumber;
1794
					Port[Para.Para32[0]]->PortNumber;
Lines 1868-1874 Link Here
1868
				pNet->Port[i]->Root.Id[0], pNet->Port[i]->Root.Id[1],
1868
				pNet->Port[i]->Root.Id[0], pNet->Port[i]->Root.Id[1],
1869
				pNet->Port[i]->Root.Id[2], pNet->Port[i]->Root.Id[3],
1869
				pNet->Port[i]->Root.Id[2], pNet->Port[i]->Root.Id[3],
1870
				pNet->Port[i]->Root.Id[4], pNet->Port[i]->Root.Id[5],
1870
				pNet->Port[i]->Root.Id[4], pNet->Port[i]->Root.Id[5],
1871
				pNet->Port[i]->Root.Id[6], pNet->Port[i]->Root.Id[7]))
1871
				pNet->Port[i]->Root.Id[6], pNet->Port[i]->Root.Id[7]));
1872
1872
1873
		if (!pNet->RootIdSet) {
1873
		if (!pNet->RootIdSet) {
1874
			pNet->Root = pNet->Port[i]->Root;
1874
			pNet->Root = pNet->Port[i]->Root;
Lines 1963-1975 Link Here
1963
	SK_U32			i;
1963
	SK_U32			i;
1964
1964
1965
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1965
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1966
		("SK_RLMT_PORTSTART_TIMEOUT Port %d Event BEGIN.\n", Para.Para32[0]))
1966
		("SK_RLMT_PORTSTART_TIMEOUT Port %d Event BEGIN.\n", Para.Para32[0]));
1967
1967
1968
		if (Para.Para32[1] != (SK_U32)-1) {
1968
		if (Para.Para32[1] != (SK_U32)-1) {
1969
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1969
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1970
			("Bad Parameter.\n"))
1970
			("Bad Parameter.\n"));
1971
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1971
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1972
			("SK_RLMT_PORTSTART_TIMEOUT Event EMPTY.\n"))
1972
			("SK_RLMT_PORTSTART_TIMEOUT Event EMPTY.\n"));
1973
		return;
1973
		return;
1974
	}
1974
	}
1975
1975
Lines 1990-1996 Link Here
1990
	}
1990
	}
1991
1991
1992
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1992
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1993
		("SK_RLMT_PORTSTART_TIMEOUT Event END.\n"))
1993
		("SK_RLMT_PORTSTART_TIMEOUT Event END.\n"));
1994
}	/* SkRlmtEvtPortStartTim */
1994
}	/* SkRlmtEvtPortStartTim */
1995
1995
1996
1996
Lines 2018-2038 Link Here
2018
	SK_EVPARA		Para2;
2018
	SK_EVPARA		Para2;
2019
2019
2020
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2020
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2021
		("SK_RLMT_LINK_UP Port %d Event BEGIN.\n", Para.Para32[0]))
2021
		("SK_RLMT_LINK_UP Port %d Event BEGIN.\n", Para.Para32[0]));
2022
2022
2023
	pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2023
	pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2024
	if (!pRPort->PortStarted) {
2024
	if (!pRPort->PortStarted) {
2025
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E008, SKERR_RLMT_E008_MSG);
2025
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E008, SKERR_RLMT_E008_MSG);
2026
2026
2027
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2027
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2028
				("SK_RLMT_LINK_UP Event EMPTY.\n"))
2028
				("SK_RLMT_LINK_UP Event EMPTY.\n"));
2029
		return;
2029
		return;
2030
	}
2030
	}
2031
2031
2032
	if (!pRPort->LinkDown) {
2032
	if (!pRPort->LinkDown) {
2033
		/* RA;:;: Any better solution? */
2033
		/* RA;:;: Any better solution? */
2034
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2034
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2035
			("SK_RLMT_LINK_UP Event EMPTY.\n"))
2035
			("SK_RLMT_LINK_UP Event EMPTY.\n"));
2036
		return;
2036
		return;
2037
	}
2037
	}
2038
2038
Lines 2110-2116 Link Here
2110
	}
2110
	}
2111
2111
2112
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2112
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2113
		("SK_RLMT_LINK_UP Event END.\n"))
2113
		("SK_RLMT_LINK_UP Event END.\n"));
2114
}	/* SkRlmtEvtLinkUp */
2114
}	/* SkRlmtEvtLinkUp */
2115
2115
2116
2116
Lines 2136-2155 Link Here
2136
	SK_RLMT_PORT	*pRPort;
2136
	SK_RLMT_PORT	*pRPort;
2137
2137
2138
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2138
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2139
		("SK_RLMT_PORTUP_TIM Port %d Event BEGIN.\n", Para.Para32[0]))
2139
		("SK_RLMT_PORTUP_TIM Port %d Event BEGIN.\n", Para.Para32[0]));
2140
2140
2141
	if (Para.Para32[1] != (SK_U32)-1) {
2141
	if (Para.Para32[1] != (SK_U32)-1) {
2142
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2142
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2143
			("Bad Parameter.\n"))
2143
			("Bad Parameter.\n"));
2144
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2144
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2145
			("SK_RLMT_PORTUP_TIM Event EMPTY.\n"))
2145
			("SK_RLMT_PORTUP_TIM Event EMPTY.\n"));
2146
		return;
2146
		return;
2147
	}
2147
	}
2148
2148
2149
	pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2149
	pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2150
	if (pRPort->LinkDown || (pRPort->PortState == SK_RLMT_PS_UP)) {
2150
	if (pRPort->LinkDown || (pRPort->PortState == SK_RLMT_PS_UP)) {
2151
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2151
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2152
			("SK_RLMT_PORTUP_TIM Port %d Event EMPTY.\n", Para.Para32[0]))
2152
			("SK_RLMT_PORTUP_TIM Port %d Event EMPTY.\n", Para.Para32[0]));
2153
		return;
2153
		return;
2154
	}
2154
	}
2155
2155
Lines 2164-2170 Link Here
2164
	}
2164
	}
2165
2165
2166
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2166
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2167
		("SK_RLMT_PORTUP_TIM Event END.\n"))
2167
		("SK_RLMT_PORTUP_TIM Event END.\n"));
2168
}	/* SkRlmtEvtPortUpTim */
2168
}	/* SkRlmtEvtPortUpTim */
2169
2169
2170
2170
Lines 2192-2204 Link Here
2192
2192
2193
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2193
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2194
		("SK_RLMT_PORTDOWN* Port %d Event (%d) BEGIN.\n",
2194
		("SK_RLMT_PORTDOWN* Port %d Event (%d) BEGIN.\n",
2195
			Para.Para32[0], Event))
2195
			Para.Para32[0], Event));
2196
2196
2197
	if (Para.Para32[1] != (SK_U32)-1) {
2197
	if (Para.Para32[1] != (SK_U32)-1) {
2198
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2198
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2199
			("Bad Parameter.\n"))
2199
			("Bad Parameter.\n"));
2200
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2200
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2201
			("SK_RLMT_PORTDOWN* Event EMPTY.\n"))
2201
			("SK_RLMT_PORTDOWN* Event EMPTY.\n"));
2202
		return;
2202
		return;
2203
	}
2203
	}
2204
2204
Lines 2206-2212 Link Here
2206
	if (!pRPort->PortStarted || (Event == SK_RLMT_PORTDOWN_TX_TIM &&
2206
	if (!pRPort->PortStarted || (Event == SK_RLMT_PORTDOWN_TX_TIM &&
2207
		!(pRPort->CheckingState & SK_RLMT_PCS_TX))) {
2207
		!(pRPort->CheckingState & SK_RLMT_PCS_TX))) {
2208
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2208
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2209
			("SK_RLMT_PORTDOWN* Event (%d) EMPTY.\n", Event))
2209
			("SK_RLMT_PORTDOWN* Event (%d) EMPTY.\n", Event));
2210
		return;
2210
		return;
2211
	}
2211
	}
2212
	
2212
	
Lines 2243-2249 Link Here
2243
	}
2243
	}
2244
2244
2245
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2245
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2246
		("SK_RLMT_PORTDOWN* Event (%d) END.\n", Event))
2246
		("SK_RLMT_PORTDOWN* Event (%d) END.\n", Event));
2247
}	/* SkRlmtEvtPortDownX */
2247
}	/* SkRlmtEvtPortDownX */
2248
2248
2249
2249
Lines 2270-2276 Link Here
2270
2270
2271
	pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2271
	pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2272
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2272
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2273
		("SK_RLMT_LINK_DOWN Port %d Event BEGIN.\n", Para.Para32[0]))
2273
		("SK_RLMT_LINK_DOWN Port %d Event BEGIN.\n", Para.Para32[0]));
2274
2274
2275
	if (!pAC->Rlmt.Port[Para.Para32[0]].LinkDown) {
2275
	if (!pAC->Rlmt.Port[Para.Para32[0]].LinkDown) {
2276
		pRPort->Net->LinksUp--;
2276
		pRPort->Net->LinksUp--;
Lines 2289-2295 Link Here
2289
	}
2289
	}
2290
2290
2291
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2291
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2292
		("SK_RLMT_LINK_DOWN Event END.\n"))
2292
		("SK_RLMT_LINK_DOWN Event END.\n"));
2293
}	/* SkRlmtEvtLinkDown */
2293
}	/* SkRlmtEvtLinkDown */
2294
2294
2295
2295
Lines 2318-2330 Link Here
2318
	SK_MAC_ADDR		*pNewMacAddr;
2318
	SK_MAC_ADDR		*pNewMacAddr;
2319
2319
2320
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2320
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2321
		("SK_RLMT_PORT_ADDR Port %d Event BEGIN.\n", Para.Para32[0]))
2321
		("SK_RLMT_PORT_ADDR Port %d Event BEGIN.\n", Para.Para32[0]));
2322
2322
2323
	if (Para.Para32[1] != (SK_U32)-1) {
2323
	if (Para.Para32[1] != (SK_U32)-1) {
2324
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2324
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2325
			("Bad Parameter.\n"))
2325
			("Bad Parameter.\n"));
2326
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2326
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2327
			("SK_RLMT_PORT_ADDR Event EMPTY.\n"))
2327
			("SK_RLMT_PORT_ADDR Event EMPTY.\n"));
2328
		return;
2328
		return;
2329
	}
2329
	}
2330
2330
Lines 2348-2354 Link Here
2348
	}
2348
	}
2349
2349
2350
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2350
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2351
			("SK_RLMT_PORT_ADDR Event END.\n"))
2351
			("SK_RLMT_PORT_ADDR Event END.\n"));
2352
}	/* SkRlmtEvtPortAddr */
2352
}	/* SkRlmtEvtPortAddr */
2353
2353
2354
2354
Lines 2376-2410 Link Here
2376
	SK_U32		PortNumber;
2376
	SK_U32		PortNumber;
2377
2377
2378
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2378
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2379
		("SK_RLMT_START Net %d Event BEGIN.\n", Para.Para32[0]))
2379
		("SK_RLMT_START Net %d Event BEGIN.\n", Para.Para32[0]));
2380
2380
2381
	if (Para.Para32[1] != (SK_U32)-1) {
2381
	if (Para.Para32[1] != (SK_U32)-1) {
2382
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2382
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2383
			("Bad Parameter.\n"))
2383
			("Bad Parameter.\n"));
2384
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2384
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2385
			("SK_RLMT_START Event EMPTY.\n"))
2385
			("SK_RLMT_START Event EMPTY.\n"));
2386
		return;
2386
		return;
2387
	}
2387
	}
2388
2388
2389
	if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2389
	if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2390
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2390
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2391
			("Bad NetNumber %d.\n", Para.Para32[0]))
2391
			("Bad NetNumber %d.\n", Para.Para32[0]));
2392
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2392
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2393
			("SK_RLMT_START Event EMPTY.\n"))
2393
			("SK_RLMT_START Event EMPTY.\n"));
2394
		return;
2394
		return;
2395
	}
2395
	}
2396
2396
2397
	if (pAC->Rlmt.Net[Para.Para32[0]].RlmtState != SK_RLMT_RS_INIT) {
2397
	if (pAC->Rlmt.Net[Para.Para32[0]].RlmtState != SK_RLMT_RS_INIT) {
2398
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2398
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2399
			("SK_RLMT_START Event EMPTY.\n"))
2399
			("SK_RLMT_START Event EMPTY.\n"));
2400
		return;
2400
		return;
2401
	}
2401
	}
2402
2402
2403
	if (pAC->Rlmt.NetsStarted >= pAC->Rlmt.NumNets) {
2403
	if (pAC->Rlmt.NetsStarted >= pAC->Rlmt.NumNets) {
2404
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2404
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2405
			("All nets should have been started.\n"))
2405
			("All nets should have been started.\n"));
2406
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2406
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2407
			("SK_RLMT_START Event EMPTY.\n"))
2407
			("SK_RLMT_START Event EMPTY.\n"));
2408
		return;
2408
		return;
2409
	}
2409
	}
2410
2410
Lines 2438-2444 Link Here
2438
	pAC->Rlmt.NetsStarted++;
2438
	pAC->Rlmt.NetsStarted++;
2439
2439
2440
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2440
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2441
			("SK_RLMT_START Event END.\n"))
2441
			("SK_RLMT_START Event END.\n"));
2442
}	/* SkRlmtEvtStart */
2442
}	/* SkRlmtEvtStart */
2443
2443
2444
2444
Lines 2466-2500 Link Here
2466
	SK_U32		i;
2466
	SK_U32		i;
2467
2467
2468
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2468
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2469
		("SK_RLMT_STOP Net %d Event BEGIN.\n", Para.Para32[0]))
2469
		("SK_RLMT_STOP Net %d Event BEGIN.\n", Para.Para32[0]));
2470
2470
2471
	if (Para.Para32[1] != (SK_U32)-1) {
2471
	if (Para.Para32[1] != (SK_U32)-1) {
2472
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2472
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2473
			("Bad Parameter.\n"))
2473
			("Bad Parameter.\n"));
2474
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2474
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2475
			("SK_RLMT_STOP Event EMPTY.\n"))
2475
			("SK_RLMT_STOP Event EMPTY.\n"));
2476
		return;
2476
		return;
2477
	}
2477
	}
2478
2478
2479
	if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2479
	if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2480
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2480
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2481
			("Bad NetNumber %d.\n", Para.Para32[0]))
2481
			("Bad NetNumber %d.\n", Para.Para32[0]));
2482
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2482
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2483
			("SK_RLMT_STOP Event EMPTY.\n"))
2483
			("SK_RLMT_STOP Event EMPTY.\n"));
2484
		return;
2484
		return;
2485
	}
2485
	}
2486
2486
2487
	if (pAC->Rlmt.Net[Para.Para32[0]].RlmtState == SK_RLMT_RS_INIT) {
2487
	if (pAC->Rlmt.Net[Para.Para32[0]].RlmtState == SK_RLMT_RS_INIT) {
2488
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2488
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2489
			("SK_RLMT_STOP Event EMPTY.\n"))
2489
			("SK_RLMT_STOP Event EMPTY.\n"));
2490
		return;
2490
		return;
2491
	}
2491
	}
2492
2492
2493
	if (pAC->Rlmt.NetsStarted == 0) {
2493
	if (pAC->Rlmt.NetsStarted == 0) {
2494
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2494
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2495
			("All nets are stopped.\n"))
2495
			("All nets are stopped.\n"));
2496
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2496
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2497
			("SK_RLMT_STOP Event EMPTY.\n"))
2497
			("SK_RLMT_STOP Event EMPTY.\n"));
2498
		return;
2498
		return;
2499
	}
2499
	}
2500
2500
Lines 2529-2535 Link Here
2529
	pAC->Rlmt.NetsStarted--;
2529
	pAC->Rlmt.NetsStarted--;
2530
2530
2531
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2531
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2532
		("SK_RLMT_STOP Event END.\n"))
2532
		("SK_RLMT_STOP Event END.\n"));
2533
}	/* SkRlmtEvtStop */
2533
}	/* SkRlmtEvtStop */
2534
2534
2535
2535
Lines 2559-2571 Link Here
2559
	SK_U32			i;
2559
	SK_U32			i;
2560
2560
2561
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2561
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2562
		("SK_RLMT_TIM Event BEGIN.\n"))
2562
		("SK_RLMT_TIM Event BEGIN.\n"));
2563
2563
2564
	if (Para.Para32[1] != (SK_U32)-1) {
2564
	if (Para.Para32[1] != (SK_U32)-1) {
2565
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2565
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2566
			("Bad Parameter.\n"))
2566
			("Bad Parameter.\n"));
2567
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2567
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2568
			("SK_RLMT_TIM Event EMPTY.\n"))
2568
			("SK_RLMT_TIM Event EMPTY.\n"));
2569
		return;
2569
		return;
2570
	}
2570
	}
2571
2571
Lines 2637-2643 Link Here
2637
	}
2637
	}
2638
2638
2639
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2639
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2640
			("SK_RLMT_TIM Event END.\n"))
2640
			("SK_RLMT_TIM Event END.\n"));
2641
}	/* SkRlmtEvtTim */
2641
}	/* SkRlmtEvtTim */
2642
2642
2643
2643
Lines 2665-2677 Link Here
2665
#endif	/* DEBUG */
2665
#endif	/* DEBUG */
2666
2666
2667
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2667
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2668
		("SK_RLMT_SEG_TIM Event BEGIN.\n"))
2668
		("SK_RLMT_SEG_TIM Event BEGIN.\n"));
2669
2669
2670
	if (Para.Para32[1] != (SK_U32)-1) {
2670
	if (Para.Para32[1] != (SK_U32)-1) {
2671
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2671
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2672
			("Bad Parameter.\n"))
2672
			("Bad Parameter.\n"));
2673
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2673
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2674
			("SK_RLMT_SEG_TIM Event EMPTY.\n"))
2674
			("SK_RLMT_SEG_TIM Event EMPTY.\n"));
2675
		return;
2675
		return;
2676
	}
2676
	}
2677
2677
Lines 2695-2701 Link Here
2695
					InAddr8[3], InAddr8[4], InAddr8[5],
2695
					InAddr8[3], InAddr8[4], InAddr8[5],
2696
					pAPort->Exact[k].a[0], pAPort->Exact[k].a[1],
2696
					pAPort->Exact[k].a[0], pAPort->Exact[k].a[1],
2697
					pAPort->Exact[k].a[2], pAPort->Exact[k].a[3],
2697
					pAPort->Exact[k].a[2], pAPort->Exact[k].a[3],
2698
					pAPort->Exact[k].a[4], pAPort->Exact[k].a[5]))
2698
					pAPort->Exact[k].a[4], pAPort->Exact[k].a[5]));
2699
		}
2699
		}
2700
	}
2700
	}
2701
#endif	/* xDEBUG */
2701
#endif	/* xDEBUG */
Lines 2703-2709 Link Here
2703
	SkRlmtCheckSeg(pAC, IoC, Para.Para32[0]);
2703
	SkRlmtCheckSeg(pAC, IoC, Para.Para32[0]);
2704
2704
2705
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2705
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2706
			("SK_RLMT_SEG_TIM Event END.\n"))
2706
			("SK_RLMT_SEG_TIM Event END.\n"));
2707
}	/* SkRlmtEvtSegTim */
2707
}	/* SkRlmtEvtSegTim */
2708
2708
2709
2709
Lines 2732-2749 Link Here
2732
2732
2733
	
2733
	
2734
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2734
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2735
		("SK_RLMT_PACKET_RECEIVED Event BEGIN.\n"))
2735
		("SK_RLMT_PACKET_RECEIVED Event BEGIN.\n"));
2736
2736
2737
	/* Should we ignore frames during port switching? */
2737
	/* Should we ignore frames during port switching? */
2738
2738
2739
#ifdef DEBUG
2739
#ifdef DEBUG
2740
	pMb = Para.pParaPtr;
2740
	pMb = Para.pParaPtr;
2741
	if (pMb == NULL) {
2741
	if (pMb == NULL) {
2742
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL, ("No mbuf.\n"))
2742
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL, ("No mbuf.\n"));
2743
	}
2743
	}
2744
	else if (pMb->pNext != NULL) {
2744
	else if (pMb->pNext != NULL) {
2745
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2745
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2746
			("More than one mbuf or pMb->pNext not set.\n"))
2746
			("More than one mbuf or pMb->pNext not set.\n"));
2747
	}
2747
	}
2748
#endif	/* DEBUG */
2748
#endif	/* DEBUG */
2749
2749
Lines 2761-2767 Link Here
2761
	}
2761
	}
2762
2762
2763
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2763
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2764
		("SK_RLMT_PACKET_RECEIVED Event END.\n"))
2764
		("SK_RLMT_PACKET_RECEIVED Event END.\n"));
2765
}	/* SkRlmtEvtPacketRx */
2765
}	/* SkRlmtEvtPacketRx */
2766
2766
2767
2767
Lines 2788-2808 Link Here
2788
	SK_RLMT_PORT	*pRPort;
2788
	SK_RLMT_PORT	*pRPort;
2789
2789
2790
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2790
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2791
		("SK_RLMT_STATS_CLEAR Event BEGIN.\n"))
2791
		("SK_RLMT_STATS_CLEAR Event BEGIN.\n"));
2792
2792
2793
	if (Para.Para32[1] != (SK_U32)-1) {
2793
	if (Para.Para32[1] != (SK_U32)-1) {
2794
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2794
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2795
			("Bad Parameter.\n"))
2795
			("Bad Parameter.\n"));
2796
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2796
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2797
			("SK_RLMT_STATS_CLEAR Event EMPTY.\n"))
2797
			("SK_RLMT_STATS_CLEAR Event EMPTY.\n"));
2798
		return;
2798
		return;
2799
	}
2799
	}
2800
2800
2801
	if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2801
	if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2802
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2802
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2803
			("Bad NetNumber %d.\n", Para.Para32[0]))
2803
			("Bad NetNumber %d.\n", Para.Para32[0]));
2804
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2804
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2805
			("SK_RLMT_STATS_CLEAR Event EMPTY.\n"))
2805
			("SK_RLMT_STATS_CLEAR Event EMPTY.\n"));
2806
		return;
2806
		return;
2807
	}
2807
	}
2808
2808
Lines 2817-2823 Link Here
2817
	}
2817
	}
2818
2818
2819
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2819
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2820
		("SK_RLMT_STATS_CLEAR Event END.\n"))
2820
		("SK_RLMT_STATS_CLEAR Event END.\n"));
2821
}	/* SkRlmtEvtStatsClear */
2821
}	/* SkRlmtEvtStatsClear */
2822
2822
2823
2823
Lines 2841-2868 Link Here
2841
SK_EVPARA	Para)	/* SK_U32 NetNumber; SK_U32 -1 */
2841
SK_EVPARA	Para)	/* SK_U32 NetNumber; SK_U32 -1 */
2842
{
2842
{
2843
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2843
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2844
		("SK_RLMT_STATS_UPDATE Event BEGIN.\n"))
2844
		("SK_RLMT_STATS_UPDATE Event BEGIN.\n"));
2845
2845
2846
	if (Para.Para32[1] != (SK_U32)-1) {
2846
	if (Para.Para32[1] != (SK_U32)-1) {
2847
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2847
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2848
			("Bad Parameter.\n"))
2848
			("Bad Parameter.\n"));
2849
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2849
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2850
			("SK_RLMT_STATS_UPDATE Event EMPTY.\n"))
2850
			("SK_RLMT_STATS_UPDATE Event EMPTY.\n"));
2851
		return;
2851
		return;
2852
	}
2852
	}
2853
2853
2854
	if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2854
	if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2855
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2855
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2856
			("Bad NetNumber %d.\n", Para.Para32[0]))
2856
			("Bad NetNumber %d.\n", Para.Para32[0]));
2857
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2857
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2858
			("SK_RLMT_STATS_UPDATE Event EMPTY.\n"))
2858
			("SK_RLMT_STATS_UPDATE Event EMPTY.\n"));
2859
		return;
2859
		return;
2860
	}
2860
	}
2861
2861
2862
	/* Update statistics - currently always up-to-date. */
2862
	/* Update statistics - currently always up-to-date. */
2863
2863
2864
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2864
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2865
		("SK_RLMT_STATS_UPDATE Event END.\n"))
2865
		("SK_RLMT_STATS_UPDATE Event END.\n"));
2866
}	/* SkRlmtEvtStatsUpdate */
2866
}	/* SkRlmtEvtStatsUpdate */
2867
2867
2868
2868
Lines 2886-2898 Link Here
2886
SK_EVPARA	Para)	/* SK_U32 PortIndex; SK_U32 NetNumber */
2886
SK_EVPARA	Para)	/* SK_U32 PortIndex; SK_U32 NetNumber */
2887
{
2887
{
2888
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2888
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2889
		("SK_RLMT_PREFPORT_CHANGE to Port %d Event BEGIN.\n", Para.Para32[0]))
2889
		("SK_RLMT_PREFPORT_CHANGE to Port %d Event BEGIN.\n", Para.Para32[0]));
2890
2890
2891
	if (Para.Para32[1] >= pAC->Rlmt.NumNets) {
2891
	if (Para.Para32[1] >= pAC->Rlmt.NumNets) {
2892
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2892
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2893
			("Bad NetNumber %d.\n", Para.Para32[1]))
2893
			("Bad NetNumber %d.\n", Para.Para32[1]));
2894
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2894
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2895
			("SK_RLMT_PREFPORT_CHANGE Event EMPTY.\n"))
2895
			("SK_RLMT_PREFPORT_CHANGE Event EMPTY.\n"));
2896
		return;
2896
		return;
2897
	}
2897
	}
2898
2898
Lines 2905-2911 Link Here
2905
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E010, SKERR_RLMT_E010_MSG);
2905
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E010, SKERR_RLMT_E010_MSG);
2906
2906
2907
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2907
			SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2908
				("SK_RLMT_PREFPORT_CHANGE Event EMPTY.\n"))
2908
				("SK_RLMT_PREFPORT_CHANGE Event EMPTY.\n"));
2909
			return;
2909
			return;
2910
		}
2910
		}
2911
2911
Lines 2919-2925 Link Here
2919
	}
2919
	}
2920
2920
2921
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2921
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2922
		("SK_RLMT_PREFPORT_CHANGE Event END.\n"))
2922
		("SK_RLMT_PREFPORT_CHANGE Event END.\n"));
2923
}	/* SkRlmtEvtPrefportChange */
2923
}	/* SkRlmtEvtPrefportChange */
2924
2924
2925
2925
Lines 2945-2981 Link Here
2945
	int i;
2945
	int i;
2946
2946
2947
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2947
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2948
		("SK_RLMT_SET_NETS Event BEGIN.\n"))
2948
		("SK_RLMT_SET_NETS Event BEGIN.\n"));
2949
2949
2950
	if (Para.Para32[1] != (SK_U32)-1) {
2950
	if (Para.Para32[1] != (SK_U32)-1) {
2951
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2951
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2952
			("Bad Parameter.\n"))
2952
			("Bad Parameter.\n"));
2953
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2953
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2954
			("SK_RLMT_SET_NETS Event EMPTY.\n"))
2954
			("SK_RLMT_SET_NETS Event EMPTY.\n"));
2955
		return;
2955
		return;
2956
	}
2956
	}
2957
2957
2958
	if (Para.Para32[0] == 0 || Para.Para32[0] > SK_MAX_NETS ||
2958
	if (Para.Para32[0] == 0 || Para.Para32[0] > SK_MAX_NETS ||
2959
		Para.Para32[0] > (SK_U32)pAC->GIni.GIMacsFound) {
2959
		Para.Para32[0] > (SK_U32)pAC->GIni.GIMacsFound) {
2960
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2960
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2961
			("Bad number of nets: %d.\n", Para.Para32[0]))
2961
			("Bad number of nets: %d.\n", Para.Para32[0]));
2962
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2962
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2963
			("SK_RLMT_SET_NETS Event EMPTY.\n"))
2963
			("SK_RLMT_SET_NETS Event EMPTY.\n"));
2964
		return;
2964
		return;
2965
	}
2965
	}
2966
2966
2967
	if (Para.Para32[0] == pAC->Rlmt.NumNets) {	/* No change. */
2967
	if (Para.Para32[0] == pAC->Rlmt.NumNets) {	/* No change. */
2968
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2968
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2969
			("SK_RLMT_SET_NETS Event EMPTY.\n"))
2969
			("SK_RLMT_SET_NETS Event EMPTY.\n"));
2970
		return;
2970
		return;
2971
	}
2971
	}
2972
2972
2973
	/* Entering and leaving dual mode only allowed while nets are stopped. */
2973
	/* Entering and leaving dual mode only allowed while nets are stopped. */
2974
	if (pAC->Rlmt.NetsStarted > 0) {
2974
	if (pAC->Rlmt.NetsStarted > 0) {
2975
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2975
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2976
			("Changing dual mode only allowed while all nets are stopped.\n"))
2976
			("Changing dual mode only allowed while all nets are stopped.\n"));
2977
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2977
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2978
			("SK_RLMT_SET_NETS Event EMPTY.\n"))
2978
			("SK_RLMT_SET_NETS Event EMPTY.\n"));
2979
		return;
2979
		return;
2980
	}
2980
	}
2981
2981
Lines 3006-3012 Link Here
3006
		SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SET_NETS, Para);
3006
		SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SET_NETS, Para);
3007
3007
3008
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3008
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3009
			("RLMT: Changed to one net with two ports.\n"))
3009
			("RLMT: Changed to one net with two ports.\n"));
3010
	}
3010
	}
3011
	else if (Para.Para32[0] == 2) {
3011
	else if (Para.Para32[0] == 2) {
3012
		pAC->Rlmt.Port[1].Net= &pAC->Rlmt.Net[1];
3012
		pAC->Rlmt.Port[1].Net= &pAC->Rlmt.Net[1];
Lines 3035-3053 Link Here
3035
		SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SET_NETS, Para);
3035
		SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SET_NETS, Para);
3036
3036
3037
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3037
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3038
			("RLMT: Changed to two nets with one port each.\n"))
3038
			("RLMT: Changed to two nets with one port each.\n"));
3039
	}
3039
	}
3040
	else {
3040
	else {
3041
		/* Not implemented for more than two nets. */
3041
		/* Not implemented for more than two nets. */
3042
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3042
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3043
			("SetNets not implemented for more than two nets.\n"))
3043
			("SetNets not implemented for more than two nets.\n"));
3044
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3044
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3045
			("SK_RLMT_SET_NETS Event EMPTY.\n"))
3045
			("SK_RLMT_SET_NETS Event EMPTY.\n"));
3046
		return;
3046
		return;
3047
	}
3047
	}
3048
3048
3049
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3049
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3050
		("SK_RLMT_SET_NETS Event END.\n"))
3050
		("SK_RLMT_SET_NETS Event END.\n"));
3051
}	/* SkRlmtSetNets */
3051
}	/* SkRlmtSetNets */
3052
3052
3053
3053
Lines 3075-3087 Link Here
3075
	SK_U32		PrevRlmtMode;
3075
	SK_U32		PrevRlmtMode;
3076
3076
3077
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3077
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3078
		("SK_RLMT_MODE_CHANGE Event BEGIN.\n"))
3078
		("SK_RLMT_MODE_CHANGE Event BEGIN.\n"));
3079
3079
3080
	if (Para.Para32[1] >= pAC->Rlmt.NumNets) {
3080
	if (Para.Para32[1] >= pAC->Rlmt.NumNets) {
3081
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3081
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3082
			("Bad NetNumber %d.\n", Para.Para32[1]))
3082
			("Bad NetNumber %d.\n", Para.Para32[1]));
3083
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3083
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3084
			("SK_RLMT_MODE_CHANGE Event EMPTY.\n"))
3084
			("SK_RLMT_MODE_CHANGE Event EMPTY.\n"));
3085
		return;
3085
		return;
3086
	}
3086
	}
3087
3087
Lines 3091-3099 Link Here
3091
		Para.Para32[0] != SK_RLMT_MODE_CLS) {
3091
		Para.Para32[0] != SK_RLMT_MODE_CLS) {
3092
		pAC->Rlmt.Net[Para.Para32[1]].RlmtMode = SK_RLMT_MODE_CLS;
3092
		pAC->Rlmt.Net[Para.Para32[1]].RlmtMode = SK_RLMT_MODE_CLS;
3093
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3093
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3094
			("Forced RLMT mode to CLS on single port net.\n"))
3094
			("Forced RLMT mode to CLS on single port net.\n"));
3095
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3095
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3096
			("SK_RLMT_MODE_CHANGE Event EMPTY.\n"))
3096
			("SK_RLMT_MODE_CHANGE Event EMPTY.\n"));
3097
		return;
3097
		return;
3098
	}
3098
	}
3099
3099
Lines 3159-3165 Link Here
3159
	}	/* SK_RLMT_CHECK_SEG bit changed. */
3159
	}	/* SK_RLMT_CHECK_SEG bit changed. */
3160
3160
3161
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3161
	SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3162
			("SK_RLMT_MODE_CHANGE Event END.\n"))
3162
			("SK_RLMT_MODE_CHANGE Event END.\n"));
3163
}	/* SkRlmtEvtModeChange */
3163
}	/* SkRlmtEvtModeChange */
3164
3164
3165
3165
Lines 3245-3251 Link Here
3245
3245
3246
	default:	/* Create error log entry. */
3246
	default:	/* Create error log entry. */
3247
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3247
		SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3248
			("Unknown RLMT Event %d.\n", Event))
3248
			("Unknown RLMT Event %d.\n", Event));
3249
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E003, SKERR_RLMT_E003_MSG);
3249
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E003, SKERR_RLMT_E003_MSG);
3250
		break;
3250
		break;
3251
	}	/* switch() */
3251
	}	/* switch() */
(-)linux/drivers/net/sk98lin/sktimer.c (-38 / +23 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	sktimer.c
3
 * Name:	sktimer.c
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
4
 * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
5
 * Version:	$Revision: 1.14 $
5
 * Version:	$Revision: 2.2 $
6
 * Date:	$Date: 2003/09/16 13:46:51 $
6
 * Date:	$Date: 2004/05/28 13:44:39 $
7
 * Purpose:	High level timer functions.
7
 * Purpose:	High level timer functions.
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-17 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
Lines 22-34 Link Here
22
 *
22
 *
23
 ******************************************************************************/
23
 ******************************************************************************/
24
24
25
26
/*
25
/*
27
 *	Event queue and dispatcher
26
 *	Event queue and dispatcher
28
 */
27
 */
29
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
28
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
30
static const char SysKonnectFileId[] =
29
static const char SysKonnectFileId[] =
31
	"@(#) $Id: sktimer.c,v 1.14 2003/09/16 13:46:51 rschmidt Exp $ (C) Marvell.";
30
	"@(#) $Id: sktimer.c,v 2.2 2004/05/28 13:44:39 rschmidt Exp $ (C) Marvell.";
32
#endif
31
#endif
33
32
34
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
33
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
Lines 62-68 Link Here
62
{
61
{
63
	switch (Level) {
62
	switch (Level) {
64
	case SK_INIT_DATA:
63
	case SK_INIT_DATA:
65
		pAC->Tim.StQueue = NULL;
64
		pAC->Tim.StQueue = 0;
66
		break;
65
		break;
67
	case SK_INIT_IO:
66
	case SK_INIT_IO:
68
		SkHwtInit(pAC, Ioc);
67
		SkHwtInit(pAC, Ioc);
Lines 85-106 Link Here
85
	SK_TIMER	**ppTimPrev;
84
	SK_TIMER	**ppTimPrev;
86
	SK_TIMER	*pTm;
85
	SK_TIMER	*pTm;
87
86
88
	/*
87
	/* remove timer from queue */
89
	 * remove timer from queue
90
	 */
91
	pTimer->TmActive = SK_FALSE;
88
	pTimer->TmActive = SK_FALSE;
92
	
89
93
	if (pAC->Tim.StQueue == pTimer && !pTimer->TmNext) {
90
	if (pAC->Tim.StQueue == pTimer && !pTimer->TmNext) {
94
		SkHwtStop(pAC, Ioc);
91
		SkHwtStop(pAC, Ioc);
95
	}
92
	}
96
	
93
97
	for (ppTimPrev = &pAC->Tim.StQueue; (pTm = *ppTimPrev);
94
	for (ppTimPrev = &pAC->Tim.StQueue; (pTm = *ppTimPrev);
98
		ppTimPrev = &pTm->TmNext ) {
95
		ppTimPrev = &pTm->TmNext ) {
99
		
96
100
		if (pTm == pTimer) {
97
		if (pTm == pTimer) {
101
			/*
98
			/*
102
			 * Timer found in queue
99
			 * Timer found in queue
103
			 * - dequeue it and
100
			 * - dequeue it
104
			 * - correct delta of the next timer
101
			 * - correct delta of the next timer
105
			 */
102
			 */
106
			*ppTimPrev = pTm->TmNext;
103
			*ppTimPrev = pTm->TmNext;
Lines 121-127 Link Here
121
SK_AC		*pAC,		/* Adapters context */
118
SK_AC		*pAC,		/* Adapters context */
122
SK_IOC		Ioc,		/* IoContext */
119
SK_IOC		Ioc,		/* IoContext */
123
SK_TIMER	*pTimer,	/* Timer Pointer to be started */
120
SK_TIMER	*pTimer,	/* Timer Pointer to be started */
124
SK_U32		Time,		/* Time value */
121
SK_U32		Time,		/* Time Value (in microsec.) */
125
SK_U32		Class,		/* Event Class for this timer */
122
SK_U32		Class,		/* Event Class for this timer */
126
SK_U32		Event,		/* Event Value for this timer */
123
SK_U32		Event,		/* Event Value for this timer */
127
SK_EVPARA	Para)		/* Event Parameter for this timer */
124
SK_EVPARA	Para)		/* Event Parameter for this timer */
Lines 130-140 Link Here
130
	SK_TIMER	*pTm;
127
	SK_TIMER	*pTm;
131
	SK_U32		Delta;
128
	SK_U32		Delta;
132
129
133
	Time /= 16;		/* input is uS, clock ticks are 16uS */
134
	
135
	if (!Time)
136
		Time = 1;
137
138
	SkTimerStop(pAC, Ioc, pTimer);
130
	SkTimerStop(pAC, Ioc, pTimer);
139
131
140
	pTimer->TmClass = Class;
132
	pTimer->TmClass = Class;
Lines 143-173 Link Here
143
	pTimer->TmActive = SK_TRUE;
135
	pTimer->TmActive = SK_TRUE;
144
136
145
	if (!pAC->Tim.StQueue) {
137
	if (!pAC->Tim.StQueue) {
146
		/* First Timer to be started */
138
		/* first Timer to be started */
147
		pAC->Tim.StQueue = pTimer;
139
		pAC->Tim.StQueue = pTimer;
148
		pTimer->TmNext = NULL;
140
		pTimer->TmNext = 0;
149
		pTimer->TmDelta = Time;
141
		pTimer->TmDelta = Time;
150
		
142
151
		SkHwtStart(pAC, Ioc, Time);
143
		SkHwtStart(pAC, Ioc, Time);
152
		
144
153
		return;
145
		return;
154
	}
146
	}
155
147
156
	/*
148
	/* timer correction */
157
	 * timer correction
158
	 */
159
	timer_done(pAC, Ioc, 0);
149
	timer_done(pAC, Ioc, 0);
160
150
161
	/*
151
	/* find position in queue */
162
	 * find position in queue
163
	 */
164
	Delta = 0;
152
	Delta = 0;
165
	for (ppTimPrev = &pAC->Tim.StQueue; (pTm = *ppTimPrev);
153
	for (ppTimPrev = &pAC->Tim.StQueue; (pTm = *ppTimPrev);
166
		ppTimPrev = &pTm->TmNext ) {
154
		ppTimPrev = &pTm->TmNext ) {
167
		
155
168
		if (Delta + pTm->TmDelta > Time) {
156
		if (Delta + pTm->TmDelta > Time) {
169
			/* Position found */
157
			/* the timer needs to be inserted here */
170
			/* Here the timer needs to be inserted. */
171
			break;
158
			break;
172
		}
159
		}
173
		Delta += pTm->TmDelta;
160
		Delta += pTm->TmDelta;
Lines 179-187 Link Here
179
	pTimer->TmDelta = Time - Delta;
166
	pTimer->TmDelta = Time - Delta;
180
167
181
	if (pTm) {
168
	if (pTm) {
182
		/* There is a next timer
169
		/* there is a next timer:  correct its Delta value */
183
		 * -> correct its Delta value.
184
		 */
185
		pTm->TmDelta -= pTimer->TmDelta;
170
		pTm->TmDelta -= pTimer->TmDelta;
186
	}
171
	}
187
172
Lines 210-216 Link Here
210
	int		Done = 0;
195
	int		Done = 0;
211
196
212
	Delta = SkHwtRead(pAC, Ioc);
197
	Delta = SkHwtRead(pAC, Ioc);
213
	
198
214
	ppLast = &pAC->Tim.StQueue;
199
	ppLast = &pAC->Tim.StQueue;
215
	pTm = pAC->Tim.StQueue;
200
	pTm = pAC->Tim.StQueue;
216
	while (pTm && !Done) {
201
	while (pTm && !Done) {
Lines 228-240 Link Here
228
			Done = 1;
213
			Done = 1;
229
		}
214
		}
230
	}
215
	}
231
	*ppLast = NULL;
216
	*ppLast = 0;
232
	/*
217
	/*
233
	 * pTm points to the first Timer that did not run out.
218
	 * pTm points to the first Timer that did not run out.
234
	 * StQueue points to the first Timer that run out.
219
	 * StQueue points to the first Timer that run out.
235
	 */
220
	 */
236
221
237
	for ( pTComp = pAC->Tim.StQueue; pTComp; pTComp = pTComp->TmNext) {
222
	for (pTComp = pAC->Tim.StQueue; pTComp; pTComp = pTComp->TmNext) {
238
		SkEventQueue(pAC,pTComp->TmClass, pTComp->TmEvent, pTComp->TmPara);
223
		SkEventQueue(pAC,pTComp->TmClass, pTComp->TmEvent, pTComp->TmPara);
239
	}
224
	}
240
225
(-)linux/drivers/net/sk98lin/sktwsi.c (+1355 lines)
Line 0 Link Here
1
/******************************************************************************
2
 *
3
 * Name:	sktwsi.c
4
 * Project:	Gigabit Ethernet Adapters, TWSI-Module
5
 * Version:	$Revision: 1.9 $
6
 * Date:	$Date: 2004/12/20 15:10:30 $
7
 * Purpose:	Functions to access Voltage and Temperature Sensor
8
 *
9
 ******************************************************************************/
10
11
/******************************************************************************
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
20
 *	The information in this file is provided "AS IS" without warranty.
21
 *
22
 ******************************************************************************/
23
24
/*
25
 *	TWSI Protocol
26
 */
27
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
28
static const char SysKonnectFileId[] =
29
	"@(#) $Id: sktwsi.c,v 1.9 2004/12/20 15:10:30 rschmidt Exp $ (C) Marvell.";
30
#endif
31
32
#include "h/skdrv1st.h"		/* Driver Specific Definitions */
33
#include "h/lm80.h"
34
#include "h/skdrv2nd.h"		/* Adapter Control- and Driver specific Def. */
35
36
#ifdef __C2MAN__
37
/*
38
	TWSI protocol implementation.
39
40
	General Description:
41
42
	The TWSI protocol is used for the temperature sensors and for
43
	the serial EEPROM which hold the configuration.
44
45
	This file covers functions that allow to read write and do
46
	some bulk requests a specified TWSI address.
47
48
	The Genesis has 2 TWSI buses. One for the EEPROM which holds
49
	the VPD Data and one for temperature and voltage sensor.
50
	The following picture shows the TWSI buses, TWSI devices and
51
	their control registers.
52
53
	Note: The VPD functions are in skvpd.c
54
.
55
.	PCI Config TWSI Bus for VPD Data:
56
.
57
.		      +------------+
58
.		      | VPD EEPROM |
59
.		      +------------+
60
.			     |
61
.			     | <-- TWSI
62
.			     |
63
.		 +-----------+-----------+
64
.		 |			 |
65
.	+-----------------+	+-----------------+
66
.	| PCI_VPD_ADR_REG |	| PCI_VPD_DAT_REG |
67
.	+-----------------+	+-----------------+
68
.
69
.
70
.	TWSI Bus for LM80 sensor:
71
.
72
.			+-----------------+
73
.			| Temperature and |
74
.			| Voltage Sensor  |
75
.			| 	LM80	  |
76
.			+-----------------+
77
.				|
78
.				|
79
.			TWSI --> |
80
.				|
81
.			     +----+
82
.	     +-------------->| OR |<--+
83
.	     |		     +----+   |
84
.     +------+------+		      |
85
.     |		    |		      |
86
. +--------+	+--------+	+----------+
87
. | B2_I2C |	| B2_I2C |	|  B2_I2C  |
88
. | _CTRL  |	| _DATA  |	|   _SW    |
89
. +--------+	+--------+	+----------+
90
.
91
	The TWSI bus may be driven by the B2_I2C_SW or by the B2_I2C_CTRL
92
	and B2_I2C_DATA registers.
93
	For driver software it is recommended to use the TWSI control and
94
	data register, because TWSI bus timing is done by the ASIC and
95
	an interrupt may be received when the TWSI request is completed.
96
97
	Clock Rate Timing:			MIN	MAX	generated by
98
		VPD EEPROM:			50 kHz	100 kHz		HW
99
		LM80 over TWSI Ctrl/Data reg.	50 kHz	100 kHz		HW
100
		LM80 over B2_I2C_SW register	0	400 kHz		SW
101
102
	Note:	The clock generated by the hardware is dependend on the
103
		PCI clock. If the PCI bus clock is 33 MHz, the I2C/VPD
104
		clock is 50 kHz.
105
 */
106
intro()
107
{}
108
#endif
109
110
#ifdef SK_DIAG
111
/*
112
 * TWSI Fast Mode timing values used by the LM80.
113
 * If new devices are added to the TWSI bus the timing values have to be checked.
114
 */
115
#ifndef I2C_SLOW_TIMING
116
#define T_CLK_LOW			1300L	/* clock low time in ns */
117
#define T_CLK_HIGH			 600L	/* clock high time in ns */
118
#define T_DATA_IN_SETUP		 100L	/* data in Set-up Time */
119
#define T_START_HOLD		 600L	/* start condition hold time */
120
#define T_START_SETUP		 600L	/* start condition Set-up time */
121
#define T_STOP_SETUP		 600L	/* stop condition Set-up time */
122
#define T_BUS_IDLE			1300L	/* time the bus must free after Tx */
123
#define T_CLK_2_DATA_OUT	 900L	/* max. clock low to data output valid */
124
#else	/* I2C_SLOW_TIMING */
125
/* TWSI Standard Mode Timing */
126
#define T_CLK_LOW			4700L	/* clock low time in ns */
127
#define T_CLK_HIGH			4000L	/* clock high time in ns */
128
#define T_DATA_IN_SETUP		 250L	/* data in Set-up Time */
129
#define T_START_HOLD		4000L	/* start condition hold time */
130
#define T_START_SETUP		4700L	/* start condition Set-up time */
131
#define T_STOP_SETUP		4000L	/* stop condition Set-up time */
132
#define T_BUS_IDLE			4700L	/* time the bus must free after Tx */
133
#endif	/* !I2C_SLOW_TIMING */
134
135
#define NS2BCLK(x)	(((x)*125)/10000)
136
137
/*
138
 * TWSI Wire Operations
139
 *
140
 * About I2C_CLK_LOW():
141
 *
142
 * The Data Direction bit (I2C_DATA_DIR) has to be set to input when setting
143
 * clock to low, to prevent the ASIC and the TWSI data client from driving the
144
 * serial data line simultaneously (ASIC: last bit of a byte = '1', TWSI client
145
 * send an 'ACK'). See also Concentrator Bugreport No. 10192.
146
 */
147
#define I2C_DATA_HIGH(IoC)	SK_I2C_SET_BIT(IoC, I2C_DATA)
148
#define I2C_DATA_LOW(IoC)	SK_I2C_CLR_BIT(IoC, I2C_DATA)
149
#define I2C_DATA_OUT(IoC)	SK_I2C_SET_BIT(IoC, I2C_DATA_DIR)
150
#define I2C_DATA_IN(IoC)	SK_I2C_CLR_BIT(IoC, I2C_DATA_DIR | I2C_DATA)
151
#define I2C_CLK_HIGH(IoC)	SK_I2C_SET_BIT(IoC, I2C_CLK)
152
#define I2C_CLK_LOW(IoC)	SK_I2C_CLR_BIT(IoC, I2C_CLK | I2C_DATA_DIR)
153
#define I2C_START_COND(IoC)	SK_I2C_CLR_BIT(IoC, I2C_CLK)
154
155
#define NS2CLKT(x)	((x*125L)/10000)
156
157
/*--------------- TWSI Interface Register Functions --------------- */
158
159
/*
160
 * sending one bit
161
 */
162
void SkI2cSndBit(
163
SK_IOC	IoC,	/* I/O Context */
164
SK_U8	Bit)	/* Bit to send */
165
{
166
	I2C_DATA_OUT(IoC);
167
	if (Bit) {
168
		I2C_DATA_HIGH(IoC);
169
	}
170
	else {
171
		I2C_DATA_LOW(IoC);
172
	}
173
	SkDgWaitTime(IoC, NS2BCLK(T_DATA_IN_SETUP));
174
	I2C_CLK_HIGH(IoC);
175
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_HIGH));
176
	I2C_CLK_LOW(IoC);
177
}	/* SkI2cSndBit*/
178
179
180
/*
181
 * Signal a start to the TWSI Bus.
182
 *
183
 * A start is signaled when data goes to low in a high clock cycle.
184
 *
185
 * Ends with Clock Low.
186
 *
187
 * Status: not tested
188
 */
189
void SkI2cStart(
190
SK_IOC	IoC)	/* I/O Context */
191
{
192
	/* Init data and Clock to output lines */
193
	/* Set Data high */
194
	I2C_DATA_OUT(IoC);
195
	I2C_DATA_HIGH(IoC);
196
	/* Set Clock high */
197
	I2C_CLK_HIGH(IoC);
198
199
	SkDgWaitTime(IoC, NS2BCLK(T_START_SETUP));
200
201
	/* Set Data Low */
202
	I2C_DATA_LOW(IoC);
203
204
	SkDgWaitTime(IoC, NS2BCLK(T_START_HOLD));
205
206
	/* Clock low without Data to Input */
207
	I2C_START_COND(IoC);
208
209
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_LOW));
210
}	/* SkI2cStart */
211
212
213
void SkI2cStop(
214
SK_IOC	IoC)	/* I/O Context */
215
{
216
	/* Init data and Clock to output lines */
217
	/* Set Data low */
218
	I2C_DATA_OUT(IoC);
219
	I2C_DATA_LOW(IoC);
220
221
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_2_DATA_OUT));
222
223
	/* Set Clock high */
224
	I2C_CLK_HIGH(IoC);
225
226
	SkDgWaitTime(IoC, NS2BCLK(T_STOP_SETUP));
227
228
	/*
229
	 * Set Data High:	Do it by setting the Data Line to Input.
230
	 *			Because of a pull up resistor the Data Line
231
	 *			floods to high.
232
	 */
233
	I2C_DATA_IN(IoC);
234
235
	/*
236
	 *	When TWSI activity is stopped
237
	 *	 o	DATA should be set to input and
238
	 *	 o	CLOCK should be set to high!
239
	 */
240
	SkDgWaitTime(IoC, NS2BCLK(T_BUS_IDLE));
241
}	/* SkI2cStop */
242
243
244
/*
245
 * Receive just one bit via the TWSI bus.
246
 *
247
 * Note:	Clock must be set to LOW before calling this function.
248
 *
249
 * Returns The received bit.
250
 */
251
int SkI2cRcvBit(
252
SK_IOC	IoC)	/* I/O Context */
253
{
254
	int	Bit;
255
	SK_U8	I2cSwCtrl;
256
257
	/* Init data as input line */
258
	I2C_DATA_IN(IoC);
259
260
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_2_DATA_OUT));
261
262
	I2C_CLK_HIGH(IoC);
263
264
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_HIGH));
265
266
	SK_I2C_GET_SW(IoC, &I2cSwCtrl);
267
268
	Bit = (I2cSwCtrl & I2C_DATA) ? 1 : 0;
269
270
	I2C_CLK_LOW(IoC);
271
	SkDgWaitTime(IoC, NS2BCLK(T_CLK_LOW-T_CLK_2_DATA_OUT));
272
273
	return(Bit);
274
}	/* SkI2cRcvBit */
275
276
277
/*
278
 * Receive an ACK.
279
 *
280
 * returns	0 If acknowledged
281
 *		1 in case of an error
282
 */
283
int SkI2cRcvAck(
284
SK_IOC	IoC)	/* I/O Context */
285
{
286
	/*
287
	 * Received bit must be zero.
288
	 */
289
	return(SkI2cRcvBit(IoC) != 0);
290
}	/* SkI2cRcvAck */
291
292
293
/*
294
 * Send an NACK.
295
 */
296
void SkI2cSndNAck(
297
SK_IOC	IoC)	/* I/O Context */
298
{
299
	/*
300
	 * Received bit must be zero.
301
	 */
302
	SkI2cSndBit(IoC, 1);
303
}	/* SkI2cSndNAck */
304
305
306
/*
307
 * Send an ACK.
308
 */
309
void SkI2cSndAck(
310
SK_IOC IoC)	/* I/O Context */
311
{
312
	/*
313
	 * Received bit must be zero.
314
	 */
315
	SkI2cSndBit(IoC, 0);
316
}	/* SkI2cSndAck */
317
318
319
/*
320
 * Send one byte to the TWSI device and wait for ACK.
321
 *
322
 * Return acknowleged status.
323
 */
324
int SkI2cSndByte(
325
SK_IOC	IoC,	/* I/O Context */
326
int		Byte)	/* byte to send */
327
{
328
	int	i;
329
330
	for (i = 0; i < 8; i++) {
331
		if (Byte & (1<<(7-i))) {
332
			SkI2cSndBit(IoC, 1);
333
		}
334
		else {
335
			SkI2cSndBit(IoC, 0);
336
		}
337
	}
338
339
	return(SkI2cRcvAck(IoC));
340
}	/* SkI2cSndByte */
341
342
343
/*
344
 * Receive one byte and ack it.
345
 *
346
 * Return byte.
347
 */
348
int SkI2cRcvByte(
349
SK_IOC	IoC,	/* I/O Context */
350
int		Last)	/* Last Byte Flag */
351
{
352
	int	i;
353
	int	Byte = 0;
354
355
	for (i = 0; i < 8; i++) {
356
		Byte <<= 1;
357
		Byte |= SkI2cRcvBit(IoC);
358
	}
359
360
	if (Last) {
361
		SkI2cSndNAck(IoC);
362
	}
363
	else {
364
		SkI2cSndAck(IoC);
365
	}
366
367
	return(Byte);
368
}	/* SkI2cRcvByte */
369
370
371
/*
372
 * Start dialog and send device address
373
 *
374
 * Return 0 if acknowleged, 1 in case of an error
375
 */
376
int	SkI2cSndDev(
377
SK_IOC	IoC,	/* I/O Context */
378
int		Addr,	/* Device Address */
379
int		Rw)		/* Read / Write Flag */
380
{
381
	SkI2cStart(IoC);
382
	Rw = ~Rw;
383
	Rw &= I2C_WRITE;
384
	return(SkI2cSndByte(IoC, (Addr << 1) | Rw));
385
}	/* SkI2cSndDev */
386
387
#endif /* SK_DIAG */
388
389
/*----------------- TWSI CTRL Register Functions ----------*/
390
391
/*
392
 * waits for a completion of an TWSI transfer
393
 *
394
 * returns	0:	success, transfer completes
395
 *			1:	error,	 transfer does not complete, TWSI transfer
396
 *						 killed, wait loop terminated.
397
 */
398
int	SkI2cWait(
399
SK_AC	*pAC,	/* Adapter Context */
400
SK_IOC	IoC,	/* I/O Context */
401
int		Event)	/* complete event to wait for (I2C_READ or I2C_WRITE) */
402
{
403
	SK_U64	StartTime;
404
	SK_U64	CurrentTime;
405
	SK_U32	I2cCtrl;
406
407
	StartTime = SkOsGetTime(pAC);
408
409
	do {
410
		CurrentTime = SkOsGetTime(pAC);
411
412
		if (CurrentTime - StartTime > SK_TICKS_PER_SEC / 8) {
413
414
			SK_I2C_STOP(IoC);
415
#ifndef SK_DIAG
416
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E002, SKERR_I2C_E002MSG);
417
#endif /* !SK_DIAG */
418
			return(1);
419
		}
420
421
		SK_I2C_GET_CTL(IoC, &I2cCtrl);
422
423
#ifdef xYUKON_DBG
424
		printf("StartTime=%lu, CurrentTime=%lu\n",
425
			StartTime, CurrentTime);
426
		if (kbhit()) {
427
			return(1);
428
		}
429
#endif /* YUKON_DBG */
430
431
	} while ((I2cCtrl & I2C_FLAG) == (SK_U32)Event << 31);
432
433
	return(0);
434
}	/* SkI2cWait */
435
436
437
/*
438
 * waits for a completion of an TWSI transfer
439
 *
440
 * Returns
441
 *	Nothing
442
 */
443
void SkI2cWaitIrq(
444
SK_AC	*pAC,	/* Adapter Context */
445
SK_IOC	IoC)	/* I/O Context */
446
{
447
	SK_SENSOR	*pSen;
448
	SK_U64		StartTime;
449
	SK_U32		IrqSrc;
450
	SK_U32		IsTwsiReadyBit;
451
452
	IsTwsiReadyBit = CHIP_ID_YUKON_2(pAC) ? Y2_IS_TWSI_RDY : IS_I2C_READY;
453
454
	pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
455
456
	if (pSen->SenState == SK_SEN_IDLE) {
457
		return;
458
	}
459
460
	StartTime = SkOsGetTime(pAC);
461
462
	do {
463
		if (SkOsGetTime(pAC) - StartTime > SK_TICKS_PER_SEC / 8) {
464
465
			SK_I2C_STOP(IoC);
466
#ifndef SK_DIAG
467
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E016, SKERR_I2C_E016MSG);
468
#endif /* !SK_DIAG */
469
			return;
470
		}
471
472
		SK_IN32(IoC, B0_ISRC, &IrqSrc);
473
474
	} while ((IrqSrc & IsTwsiReadyBit) == 0);
475
476
	pSen->SenState = SK_SEN_IDLE;
477
	return;
478
}	/* SkI2cWaitIrq */
479
480
/*
481
 * writes a single byte or 4 bytes into the TWSI device
482
 *
483
 * returns	0:	success
484
 *			1:	error
485
 */
486
int SkI2cWrite(
487
SK_AC	*pAC,		/* Adapter Context */
488
SK_IOC	IoC,		/* I/O Context */
489
SK_U32	I2cData,	/* TWSI Data to write */
490
int		I2cDev,		/* TWSI Device Address */
491
int		I2cDevSize,	/* TWSI Device Size (e.g. I2C_025K_DEV or I2C_2K_DEV) */
492
int		I2cReg,		/* TWSI Device Register Address */
493
int		I2cBurst)	/* TWSI Burst Flag */
494
{
495
	SK_OUT32(IoC, B2_I2C_DATA, I2cData);
496
497
	SK_I2C_CTL(IoC, I2C_WRITE, I2cDev, I2cDevSize, I2cReg, I2cBurst);
498
499
	return(SkI2cWait(pAC, IoC, I2C_WRITE));
500
}	/* SkI2cWrite*/
501
502
503
#ifdef	SK_DIAG
504
/*
505
 * reads a single byte or 4 bytes from the TWSI device
506
 *
507
 * returns	the word read
508
 */
509
SK_U32 SkI2cRead(
510
SK_AC	*pAC,		/* Adapter Context */
511
SK_IOC	IoC,		/* I/O Context */
512
int		I2cDev,		/* TWSI Device Address */
513
int		I2cDevSize,	/* TWSI Device Size (e.g. I2C_025K_DEV or I2C_2K_DEV) */
514
int		I2cReg,		/* TWSI Device Register Address */
515
int		I2cBurst)	/* TWSI Burst Flag */
516
{
517
	SK_U32	Data;
518
519
	SK_OUT32(IoC, B2_I2C_DATA, 0);
520
	SK_I2C_CTL(IoC, I2C_READ, I2cDev, I2cDevSize, I2cReg, I2cBurst);
521
522
	if (SkI2cWait(pAC, IoC, I2C_READ) != 0) {
523
		w_print("%s\n", SKERR_I2C_E002MSG);
524
	}
525
526
	SK_IN32(IoC, B2_I2C_DATA, &Data);
527
528
	return(Data);
529
}	/* SkI2cRead */
530
#endif /* SK_DIAG */
531
532
533
/*
534
 * read a sensor's value
535
 *
536
 * This function reads a sensor's value from the TWSI sensor chip. The sensor
537
 * is defined by its index into the sensors database in the struct pAC points
538
 * to.
539
 * Returns
540
 *		1 if the read is completed
541
 *		0 if the read must be continued (TWSI Bus still allocated)
542
 */
543
int	SkI2cReadSensor(
544
SK_AC		*pAC,	/* Adapter Context */
545
SK_IOC		IoC,	/* I/O Context */
546
SK_SENSOR	*pSen)	/* Sensor to be read */
547
{
548
	if (pSen->SenRead != NULL) {
549
		return((*pSen->SenRead)(pAC, IoC, pSen));
550
	}
551
552
	return(0); /* no success */
553
}	/* SkI2cReadSensor */
554
555
/*
556
 * Do the Init state 0 initialization
557
 */
558
static int SkI2cInit0(
559
SK_AC	*pAC)	/* Adapter Context */
560
{
561
	int			i;
562
	SK_SENSOR	*pSen;
563
564
	/* Begin with first sensor */
565
	pAC->I2c.CurrSens = 0;
566
567
	/* Begin with timeout control for state machine */
568
	pAC->I2c.TimerMode = SK_TIMER_WATCH_SM;
569
570
	/* Set sensor number to zero */
571
	pAC->I2c.MaxSens = 0;
572
573
#ifndef SK_DIAG
574
	/* Initialize Number of Dummy Reads */
575
	pAC->I2c.DummyReads = SK_MAX_SENSORS;
576
#endif /* !SK_DIAG */
577
578
	for (i = 0; i < SK_MAX_SENSORS; i++) {
579
		pSen = &pAC->I2c.SenTable[i];
580
581
		pSen->SenDesc = "unknown";
582
		pSen->SenType = SK_SEN_UNKNOWN;
583
		pSen->SenThreErrHigh = 0;
584
		pSen->SenThreErrLow = 0;
585
		pSen->SenThreWarnHigh = 0;
586
		pSen->SenThreWarnLow = 0;
587
		pSen->SenReg = LM80_FAN2_IN;
588
		pSen->SenInit = SK_SEN_DYN_INIT_NONE;
589
		pSen->SenValue = 0;
590
		pSen->SenErrFlag = SK_SEN_ERR_NOT_PRESENT;
591
		pSen->SenErrCts = 0;
592
		pSen->SenBegErrTS = 0;
593
		pSen->SenState = SK_SEN_IDLE;
594
		pSen->SenRead = NULL;
595
		pSen->SenDev = 0;
596
	}
597
598
	/* Now we are "INIT data"ed */
599
	pAC->I2c.InitLevel = SK_INIT_DATA;
600
	return(0);
601
}	/* SkI2cInit0*/
602
603
604
/*
605
 * Do the init state 1 initialization
606
 *
607
 * initialize the following register of the LM80:
608
 * Configuration register:
609
 * - START, noINT, activeLOW, noINT#Clear, noRESET, noCI, noGPO#, noINIT
610
 *
611
 * Interrupt Mask Register 1:
612
 * - all interrupts are Disabled (0xff)
613
 *
614
 * Interrupt Mask Register 2:
615
 * - all interrupts are Disabled (0xff) Interrupt modi doesn't matter.
616
 *
617
 * Fan Divisor/RST_OUT register:
618
 * - Divisors set to 1 (bits 00), all others 0s.
619
 *
620
 * OS# Configuration/Temperature resolution Register:
621
 * - all 0s
622
 *
623
 */
624
static int SkI2cInit1(
625
SK_AC	*pAC,	/* Adapter Context */
626
SK_IOC	IoC)	/* I/O Context */
627
{
628
	int			i;
629
	SK_U8		I2cSwCtrl;
630
	SK_GEPORT	*pPrt;	/* GIni Port struct pointer */
631
	SK_SENSOR	*pSen;
632
633
	if (pAC->I2c.InitLevel != SK_INIT_DATA) {
634
		/* Re-init not needed in TWSI module */
635
		return(0);
636
	}
637
638
	if (pAC->GIni.GIChipId == CHIP_ID_YUKON_EC ||
639
		pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
640
		/* No sensors on Yukon-EC and Yukon-FE */
641
		return(0);
642
	}
643
644
	/* Set the Direction of TWSI-Data Pin to IN */
645
	SK_I2C_CLR_BIT(IoC, I2C_DATA_DIR | I2C_DATA);
646
	/* Check for 32-Bit Yukon with Low at TWSI-Data Pin */
647
	SK_I2C_GET_SW(IoC, &I2cSwCtrl);
648
649
	if ((I2cSwCtrl & I2C_DATA) == 0) {
650
		/* this is a 32-Bit board */
651
		pAC->GIni.GIYukon32Bit = SK_TRUE;
652
		return(0);
653
	}
654
655
	/* Check for 64 Bit Yukon without sensors */
656
	if (SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_CFG, 0) != 0) {
657
		return(0);
658
	}
659
660
	(void)SkI2cWrite(pAC, IoC, 0xffUL, LM80_ADDR, I2C_025K_DEV, LM80_IMSK_1, 0);
661
662
	(void)SkI2cWrite(pAC, IoC, 0xffUL, LM80_ADDR, I2C_025K_DEV, LM80_IMSK_2, 0);
663
664
	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_FAN_CTRL, 0);
665
666
	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_TEMP_CTRL, 0);
667
668
	(void)SkI2cWrite(pAC, IoC, (SK_U32)LM80_CFG_START, LM80_ADDR, I2C_025K_DEV,
669
		LM80_CFG, 0);
670
671
	/*
672
	 * MaxSens has to be updated here, because PhyType is not
673
	 * set when performing Init Level 0
674
	 */
675
	pAC->I2c.MaxSens = 5;
676
677
	pPrt = &pAC->GIni.GP[0];
678
679
	if (pAC->GIni.GIGenesis) {
680
		if (pPrt->PhyType == SK_PHY_BCOM) {
681
			if (pAC->GIni.GIMacsFound == 1) {
682
				pAC->I2c.MaxSens += 1;
683
			}
684
			else {
685
				pAC->I2c.MaxSens += 3;
686
			}
687
		}
688
	}
689
	else {
690
		pAC->I2c.MaxSens += 3;
691
	}
692
693
	for (i = 0; i < pAC->I2c.MaxSens; i++) {
694
		pSen = &pAC->I2c.SenTable[i];
695
		switch (i) {
696
		case 0:
697
			pSen->SenDesc = "Temperature";
698
			pSen->SenType = SK_SEN_TEMP;
699
			pSen->SenThreErrHigh = SK_SEN_TEMP_HIGH_ERR;
700
			pSen->SenThreWarnHigh = SK_SEN_TEMP_HIGH_WARN;
701
			pSen->SenThreWarnLow = SK_SEN_TEMP_LOW_WARN;
702
			pSen->SenThreErrLow = SK_SEN_TEMP_LOW_ERR;
703
			pSen->SenReg = LM80_TEMP_IN;
704
			break;
705
		case 1:
706
			pSen->SenDesc = "Voltage PCI";
707
			pSen->SenType = SK_SEN_VOLT;
708
			pSen->SenThreErrHigh = SK_SEN_PCI_5V_HIGH_ERR;
709
			pSen->SenThreWarnHigh = SK_SEN_PCI_5V_HIGH_WARN;
710
			if (pAC->GIni.GIPciBus != SK_PEX_BUS) {
711
				pSen->SenThreWarnLow = SK_SEN_PCI_5V_LOW_WARN;
712
				pSen->SenThreErrLow = SK_SEN_PCI_5V_LOW_ERR;
713
			}
714
			else {
715
				pSen->SenThreWarnLow = 0;
716
				pSen->SenThreErrLow = 0;
717
			}
718
			pSen->SenReg = LM80_VT0_IN;
719
			break;
720
		case 2:
721
			pSen->SenDesc = "Voltage PCI-IO";
722
			pSen->SenType = SK_SEN_VOLT;
723
			pSen->SenThreErrHigh = SK_SEN_PCI_IO_5V_HIGH_ERR;
724
			pSen->SenThreWarnHigh = SK_SEN_PCI_IO_5V_HIGH_WARN;
725
			if (pAC->GIni.GIPciBus != SK_PEX_BUS) {
726
				pSen->SenThreWarnLow = SK_SEN_PCI_IO_3V3_LOW_WARN;
727
				pSen->SenThreErrLow = SK_SEN_PCI_IO_3V3_LOW_ERR;
728
			}
729
			else {
730
				pSen->SenThreWarnLow = 0;
731
				pSen->SenThreErrLow = 0;
732
			}
733
			pSen->SenReg = LM80_VT1_IN;
734
			pSen->SenInit = SK_SEN_DYN_INIT_PCI_IO;
735
			break;
736
		case 3:
737
			if (pAC->GIni.GIGenesis) {
738
				pSen->SenDesc = "Voltage ASIC";
739
			}
740
			else {
741
				pSen->SenDesc = "Voltage VMAIN";
742
			}
743
			pSen->SenType = SK_SEN_VOLT;
744
			pSen->SenThreErrHigh = SK_SEN_VDD_HIGH_ERR;
745
			pSen->SenThreWarnHigh = SK_SEN_VDD_HIGH_WARN;
746
			pSen->SenThreWarnLow = SK_SEN_VDD_LOW_WARN;
747
			pSen->SenThreErrLow = SK_SEN_VDD_LOW_ERR;
748
			pSen->SenReg = LM80_VT2_IN;
749
			break;
750
		case 4:
751
			if (pAC->GIni.GIGenesis) {
752
				if (pPrt->PhyType == SK_PHY_BCOM) {
753
					pSen->SenDesc = "Voltage PHY A PLL";
754
					pSen->SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
755
					pSen->SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
756
					pSen->SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
757
					pSen->SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
758
				}
759
				else {
760
					pSen->SenDesc = "Voltage PMA";
761
					pSen->SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
762
					pSen->SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
763
					pSen->SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
764
					pSen->SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
765
				}
766
			}
767
			else {
768
				pSen->SenDesc = "Voltage VAUX";
769
				pSen->SenThreErrHigh = SK_SEN_VAUX_3V3_HIGH_ERR;
770
				pSen->SenThreWarnHigh = SK_SEN_VAUX_3V3_HIGH_WARN;
771
				if (pAC->GIni.GIVauxAvail) {
772
					pSen->SenThreWarnLow = SK_SEN_VAUX_3V3_LOW_WARN;
773
					pSen->SenThreErrLow = SK_SEN_VAUX_3V3_LOW_ERR;
774
				}
775
				else {
776
					pSen->SenThreErrLow = 0;
777
					pSen->SenThreWarnLow = 0;
778
				}
779
			}
780
			pSen->SenType = SK_SEN_VOLT;
781
			pSen->SenReg = LM80_VT3_IN;
782
			break;
783
		case 5:
784
			if (CHIP_ID_YUKON_2(pAC)) {
785
				if (pAC->GIni.GIChipRev == 0) {
786
					pSen->SenDesc = "Voltage Core 1V3";
787
					pSen->SenThreErrHigh = SK_SEN_CORE_1V3_HIGH_ERR;
788
					pSen->SenThreWarnHigh = SK_SEN_CORE_1V3_HIGH_WARN;
789
					pSen->SenThreWarnLow = SK_SEN_CORE_1V3_LOW_WARN;
790
					pSen->SenThreErrLow = SK_SEN_CORE_1V3_LOW_ERR;
791
				}
792
				else {
793
					pSen->SenDesc = "Voltage Core 1V2";
794
					pSen->SenThreErrHigh = SK_SEN_CORE_1V2_HIGH_ERR;
795
					pSen->SenThreWarnHigh = SK_SEN_CORE_1V2_HIGH_WARN;
796
					pSen->SenThreWarnLow = SK_SEN_CORE_1V2_LOW_WARN;
797
					pSen->SenThreErrLow = SK_SEN_CORE_1V2_LOW_ERR;
798
				}
799
			}
800
			else {
801
				if (pAC->GIni.GIGenesis) {
802
					pSen->SenDesc = "Voltage PHY 2V5";
803
					pSen->SenThreErrHigh = SK_SEN_PHY_2V5_HIGH_ERR;
804
					pSen->SenThreWarnHigh = SK_SEN_PHY_2V5_HIGH_WARN;
805
					pSen->SenThreWarnLow = SK_SEN_PHY_2V5_LOW_WARN;
806
					pSen->SenThreErrLow = SK_SEN_PHY_2V5_LOW_ERR;
807
				}
808
				else {
809
					pSen->SenDesc = "Voltage Core 1V5";
810
					pSen->SenThreErrHigh = SK_SEN_CORE_1V5_HIGH_ERR;
811
					pSen->SenThreWarnHigh = SK_SEN_CORE_1V5_HIGH_WARN;
812
					pSen->SenThreWarnLow = SK_SEN_CORE_1V5_LOW_WARN;
813
					pSen->SenThreErrLow = SK_SEN_CORE_1V5_LOW_ERR;
814
				}
815
			}
816
			pSen->SenType = SK_SEN_VOLT;
817
			pSen->SenReg = LM80_VT4_IN;
818
			break;
819
		case 6:
820
			if (CHIP_ID_YUKON_2(pAC)) {
821
				pSen->SenDesc = "Voltage PHY 1V5";
822
				pSen->SenThreErrHigh = SK_SEN_CORE_1V5_HIGH_ERR;
823
				pSen->SenThreWarnHigh = SK_SEN_CORE_1V5_HIGH_WARN;
824
				if (pAC->GIni.GIPciBus == SK_PEX_BUS) {
825
					pSen->SenThreWarnLow = SK_SEN_CORE_1V5_LOW_WARN;
826
					pSen->SenThreErrLow = SK_SEN_CORE_1V5_LOW_ERR;
827
				}
828
				else {
829
					pSen->SenThreWarnLow = 0;
830
					pSen->SenThreErrLow = 0;
831
				}
832
			}
833
			else {
834
				if (pAC->GIni.GIGenesis) {
835
					pSen->SenDesc = "Voltage PHY B PLL";
836
				}
837
				else {
838
					pSen->SenDesc = "Voltage PHY 3V3";
839
				}
840
				pSen->SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
841
				pSen->SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
842
				pSen->SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
843
				pSen->SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
844
			}
845
			pSen->SenType = SK_SEN_VOLT;
846
			pSen->SenReg = LM80_VT5_IN;
847
			break;
848
		case 7:
849
			if (pAC->GIni.GIGenesis) {
850
				pSen->SenDesc = "Speed Fan";
851
				pSen->SenType = SK_SEN_FAN;
852
				pSen->SenThreErrHigh = SK_SEN_FAN_HIGH_ERR;
853
				pSen->SenThreWarnHigh = SK_SEN_FAN_HIGH_WARN;
854
				pSen->SenThreWarnLow = SK_SEN_FAN_LOW_WARN;
855
				pSen->SenThreErrLow = SK_SEN_FAN_LOW_ERR;
856
				pSen->SenReg = LM80_FAN2_IN;
857
			}
858
			else {
859
				pSen->SenDesc = "Voltage PHY 2V5";
860
				pSen->SenType = SK_SEN_VOLT;
861
				pSen->SenThreErrHigh = SK_SEN_PHY_2V5_HIGH_ERR;
862
				pSen->SenThreWarnHigh = SK_SEN_PHY_2V5_HIGH_WARN;
863
				pSen->SenThreWarnLow = SK_SEN_PHY_2V5_LOW_WARN;
864
				pSen->SenThreErrLow = SK_SEN_PHY_2V5_LOW_ERR;
865
				pSen->SenReg = LM80_VT6_IN;
866
			}
867
			break;
868
		default:
869
			SK_ERR_LOG(pAC, SK_ERRCL_INIT | SK_ERRCL_SW,
870
				SKERR_I2C_E001, SKERR_I2C_E001MSG);
871
			break;
872
		}
873
874
		pSen->SenValue = 0;
875
		pSen->SenErrFlag = SK_SEN_ERR_OK;
876
		pSen->SenErrCts = 0;
877
		pSen->SenBegErrTS = 0;
878
		pSen->SenState = SK_SEN_IDLE;
879
		if (pSen->SenThreWarnLow != 0) {
880
			pSen->SenRead = SkLm80ReadSensor;
881
		}
882
		pSen->SenDev = LM80_ADDR;
883
	}
884
885
#ifndef SK_DIAG
886
	pAC->I2c.DummyReads = pAC->I2c.MaxSens;
887
#endif /* !SK_DIAG */
888
889
	/* Clear TWSI IRQ */
890
	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
891
892
	/* Now we are I/O initialized */
893
	pAC->I2c.InitLevel = SK_INIT_IO;
894
	return(0);
895
}	/* SkI2cInit1 */
896
897
898
/*
899
 * Init level 2: Start first sensor read.
900
 */
901
static int SkI2cInit2(
902
SK_AC	*pAC,	/* Adapter Context */
903
SK_IOC	IoC)	/* I/O Context */
904
{
905
	int			ReadComplete;
906
	SK_SENSOR	*pSen;
907
908
	if (pAC->I2c.InitLevel != SK_INIT_IO) {
909
		/* ReInit not needed in TWSI module */
910
		/* Init0 and Init2 not permitted */
911
		return(0);
912
	}
913
914
	pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
915
916
	ReadComplete = SkI2cReadSensor(pAC, IoC, pSen);
917
918
	if (ReadComplete) {
919
		SK_ERR_LOG(pAC, SK_ERRCL_INIT, SKERR_I2C_E008, SKERR_I2C_E008MSG);
920
	}
921
922
	/* Now we are correctly initialized */
923
	pAC->I2c.InitLevel = SK_INIT_RUN;
924
925
	return(0);
926
}	/* SkI2cInit2*/
927
928
929
/*
930
 * Initialize TWSI devices
931
 *
932
 * Get the first voltage value and discard it.
933
 * Go into temperature read mode. A default pointer is not set.
934
 *
935
 * The things to be done depend on the init level in the parameter list:
936
 * Level 0:
937
 *	Initialize only the data structures. Do NOT access hardware.
938
 * Level 1:
939
 *	Initialize hardware through SK_IN / SK_OUT commands. Do NOT use interrupts.
940
 * Level 2:
941
 *	Everything is possible. Interrupts may be used from now on.
942
 *
943
 * return:
944
 *	0 = success
945
 *	other = error.
946
 */
947
int	SkI2cInit(
948
SK_AC	*pAC,	/* Adapter Context */
949
SK_IOC	IoC,	/* I/O Context needed in levels 1 and 2 */
950
int		Level)	/* Init Level */
951
{
952
953
	switch (Level) {
954
	case SK_INIT_DATA:
955
		return(SkI2cInit0(pAC));
956
	case SK_INIT_IO:
957
		return(SkI2cInit1(pAC, IoC));
958
	case SK_INIT_RUN:
959
		return(SkI2cInit2(pAC, IoC));
960
	default:
961
		break;
962
	}
963
964
	return(0);
965
}	/* SkI2cInit */
966
967
968
#ifndef SK_DIAG
969
/*
970
 * Interrupt service function for the TWSI Interface
971
 *
972
 * Clears the Interrupt source
973
 *
974
 * Reads the register and check it for sending a trap.
975
 *
976
 * Starts the timer if necessary.
977
 */
978
void SkI2cIsr(
979
SK_AC	*pAC,	/* Adapter Context */
980
SK_IOC	IoC)	/* I/O Context */
981
{
982
	SK_EVPARA	Para;
983
984
	/* Clear TWSI IRQ */
985
	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
986
987
	Para.Para64 = 0;
988
	SkEventQueue(pAC, SKGE_I2C, SK_I2CEV_IRQ, Para);
989
}	/* SkI2cIsr */
990
991
992
/*
993
 * Check this sensors Value against the threshold and send events.
994
 */
995
static void SkI2cCheckSensor(
996
SK_AC		*pAC,	/* Adapter Context */
997
SK_SENSOR	*pSen)
998
{
999
	SK_EVPARA	ParaLocal;
1000
	SK_BOOL		TooHigh;	/* Is sensor too high? */
1001
	SK_BOOL		TooLow;		/* Is sensor too low? */
1002
	SK_U64		CurrTime;	/* Current Time */
1003
	SK_BOOL		DoTrapSend;	/* We need to send a trap */
1004
	SK_BOOL		DoErrLog;	/* We need to log the error */
1005
	SK_BOOL		IsError;	/* Error occured */
1006
1007
	/* Check Dummy Reads first */
1008
	if (pAC->I2c.DummyReads > 0) {
1009
		pAC->I2c.DummyReads--;
1010
		return;
1011
	}
1012
1013
	/* Get the current time */
1014
	CurrTime = SkOsGetTime(pAC);
1015
1016
	/* Set para to the most useful setting: The current sensor. */
1017
	ParaLocal.Para64 = (SK_U64)pAC->I2c.CurrSens;
1018
1019
	/* Check the Value against the thresholds. First: Error Thresholds */
1020
	TooHigh = pSen->SenValue > pSen->SenThreErrHigh;
1021
	TooLow  = pSen->SenValue < pSen->SenThreErrLow;
1022
1023
	IsError = SK_FALSE;
1024
1025
	if (TooHigh || TooLow) {
1026
		/* Error condition is satisfied */
1027
		DoTrapSend = SK_TRUE;
1028
		DoErrLog = SK_TRUE;
1029
1030
		/* Now error condition is satisfied */
1031
		IsError = SK_TRUE;
1032
1033
		if (pSen->SenErrFlag == SK_SEN_ERR_ERR) {
1034
			/* This state is the former one */
1035
1036
			/* So check first whether we have to send a trap */
1037
			if (pSen->SenLastErrTrapTS + SK_SEN_ERR_TR_HOLD > CurrTime) {
1038
				/*
1039
				 * Do NOT send the Trap. The hold back time
1040
				 * has to run out first.
1041
				 */
1042
				DoTrapSend = SK_FALSE;
1043
			}
1044
1045
			/* Check now whether we have to log an Error */
1046
			if (pSen->SenLastErrLogTS + SK_SEN_ERR_LOG_HOLD > CurrTime) {
1047
				/*
1048
				 * Do NOT log the error. The hold back time
1049
				 * has to run out first.
1050
				 */
1051
				DoErrLog = SK_FALSE;
1052
			}
1053
		}
1054
		else {
1055
			/* We came from a different state -> Set Begin Time Stamp */
1056
			pSen->SenBegErrTS = CurrTime;
1057
			pSen->SenErrFlag = SK_SEN_ERR_ERR;
1058
		}
1059
1060
		if (DoTrapSend) {
1061
			/* Set current Time */
1062
			pSen->SenLastErrTrapTS = CurrTime;
1063
			pSen->SenErrCts++;
1064
1065
			/* Queue PNMI Event */
1066
			SkEventQueue(pAC, SKGE_PNMI, TooHigh ?
1067
				SK_PNMI_EVT_SEN_ERR_UPP : SK_PNMI_EVT_SEN_ERR_LOW,
1068
				ParaLocal);
1069
		}
1070
1071
		if (DoErrLog) {
1072
			/* Set current Time */
1073
			pSen->SenLastErrLogTS = CurrTime;
1074
1075
			if (pSen->SenType == SK_SEN_TEMP) {
1076
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E011, SKERR_I2C_E011MSG);
1077
			}
1078
			else if (pSen->SenType == SK_SEN_VOLT) {
1079
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E012, SKERR_I2C_E012MSG);
1080
			}
1081
			else {
1082
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E015, SKERR_I2C_E015MSG);
1083
			}
1084
		}
1085
	}
1086
1087
	/* Check the Value against the thresholds */
1088
	/* 2nd: Warning thresholds */
1089
	TooHigh = pSen->SenValue > pSen->SenThreWarnHigh;
1090
	TooLow  = pSen->SenValue < pSen->SenThreWarnLow;
1091
1092
	if (!IsError && (TooHigh || TooLow)) {
1093
		/* Error condition is satisfied */
1094
		DoTrapSend = SK_TRUE;
1095
		DoErrLog = SK_TRUE;
1096
1097
		if (pSen->SenErrFlag == SK_SEN_ERR_WARN) {
1098
			/* This state is the former one */
1099
1100
			/* So check first whether we have to send a trap */
1101
			if (pSen->SenLastWarnTrapTS + SK_SEN_WARN_TR_HOLD > CurrTime) {
1102
				/*
1103
				 * Do NOT send the Trap. The hold back time
1104
				 * has to run out first.
1105
				 */
1106
				DoTrapSend = SK_FALSE;
1107
			}
1108
1109
			/* Check now whether we have to log an Error */
1110
			if (pSen->SenLastWarnLogTS + SK_SEN_WARN_LOG_HOLD > CurrTime) {
1111
				/*
1112
				 * Do NOT log the error. The hold back time
1113
				 * has to run out first.
1114
				 */
1115
				DoErrLog = SK_FALSE;
1116
			}
1117
		}
1118
		else {
1119
			/* We came from a different state -> Set Begin Time Stamp */
1120
			pSen->SenBegWarnTS = CurrTime;
1121
			pSen->SenErrFlag = SK_SEN_ERR_WARN;
1122
		}
1123
1124
		if (DoTrapSend) {
1125
			/* Set current Time */
1126
			pSen->SenLastWarnTrapTS = CurrTime;
1127
			pSen->SenWarnCts++;
1128
1129
			/* Queue PNMI Event */
1130
			SkEventQueue(pAC, SKGE_PNMI, TooHigh ?
1131
				SK_PNMI_EVT_SEN_WAR_UPP : SK_PNMI_EVT_SEN_WAR_LOW, ParaLocal);
1132
		}
1133
1134
		if (DoErrLog) {
1135
			/* Set current Time */
1136
			pSen->SenLastWarnLogTS = CurrTime;
1137
1138
			if (pSen->SenType == SK_SEN_TEMP) {
1139
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E009, SKERR_I2C_E009MSG);
1140
			}
1141
			else if (pSen->SenType == SK_SEN_VOLT) {
1142
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E010, SKERR_I2C_E010MSG);
1143
			}
1144
			else {
1145
				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E014, SKERR_I2C_E014MSG);
1146
			}
1147
		}
1148
	}
1149
1150
	/* Check for NO error at all */
1151
	if (!IsError && !TooHigh && !TooLow) {
1152
		/* Set o.k. Status if no error and no warning condition */
1153
		pSen->SenErrFlag = SK_SEN_ERR_OK;
1154
	}
1155
1156
	/* End of check against the thresholds */
1157
1158
	if (pSen->SenInit == SK_SEN_DYN_INIT_PCI_IO) {
1159
		/* Bug fix AF: 16.Aug.2001: Correct the init base of LM80 sensor */
1160
		pSen->SenInit = SK_SEN_DYN_INIT_NONE;
1161
1162
		if (pSen->SenValue > SK_SEN_PCI_IO_RANGE_LIMITER) {
1163
			/* 5V PCI-IO Voltage */
1164
			pSen->SenThreWarnLow = SK_SEN_PCI_IO_5V_LOW_WARN;
1165
			pSen->SenThreErrLow = SK_SEN_PCI_IO_5V_LOW_ERR;
1166
		}
1167
		else {
1168
			/* 3.3V PCI-IO Voltage */
1169
			pSen->SenThreWarnHigh = SK_SEN_PCI_IO_3V3_HIGH_WARN;
1170
			pSen->SenThreErrHigh = SK_SEN_PCI_IO_3V3_HIGH_ERR;
1171
		}
1172
	}
1173
1174
#ifdef TEST_ONLY
1175
	/* Dynamic thresholds also for VAUX of LM80 sensor */
1176
	if (pSen->SenInit == SK_SEN_DYN_INIT_VAUX) {
1177
1178
		pSen->SenInit = SK_SEN_DYN_INIT_NONE;
1179
1180
		/* 3.3V VAUX Voltage */
1181
		if (pSen->SenValue > SK_SEN_VAUX_RANGE_LIMITER) {
1182
			pSen->SenThreWarnLow = SK_SEN_VAUX_3V3_LOW_WARN;
1183
			pSen->SenThreErrLow = SK_SEN_VAUX_3V3_LOW_ERR;
1184
		}
1185
		/* 0V VAUX Voltage */
1186
		else {
1187
			pSen->SenThreWarnHigh = SK_SEN_VAUX_0V_WARN_ERR;
1188
			pSen->SenThreErrHigh = SK_SEN_VAUX_0V_WARN_ERR;
1189
		}
1190
	}
1191
1192
	/* Check initialization state: the VIO Thresholds need adaption */
1193
	if (!pSen->SenInit && pSen->SenReg == LM80_VT1_IN &&
1194
		 pSen->SenValue > SK_SEN_WARNLOW2C &&
1195
		 pSen->SenValue < SK_SEN_WARNHIGH2) {
1196
1197
		pSen->SenThreErrLow = SK_SEN_ERRLOW2C;
1198
		pSen->SenThreWarnLow = SK_SEN_WARNLOW2C;
1199
		pSen->SenInit = SK_TRUE;
1200
	}
1201
1202
	if (!pSen->SenInit && pSen->SenReg == LM80_VT1_IN &&
1203
		 pSen->SenValue > SK_SEN_WARNLOW2 &&
1204
		 pSen->SenValue < SK_SEN_WARNHIGH2C) {
1205
1206
		pSen->SenThreErrHigh = SK_SEN_ERRHIGH2C;
1207
		pSen->SenThreWarnHigh = SK_SEN_WARNHIGH2C;
1208
		pSen->SenInit = SK_TRUE;
1209
	}
1210
#endif
1211
1212
	if (pSen->SenInit != SK_SEN_DYN_INIT_NONE) {
1213
		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E013, SKERR_I2C_E013MSG);
1214
	}
1215
}	/* SkI2cCheckSensor */
1216
1217
1218
/*
1219
 * The only Event to be served is the timeout event
1220
 *
1221
 */
1222
int	SkI2cEvent(
1223
SK_AC		*pAC,	/* Adapter Context */
1224
SK_IOC		IoC,	/* I/O Context */
1225
SK_U32		Event,	/* Module specific Event */
1226
SK_EVPARA	Para)	/* Event specific Parameter */
1227
{
1228
	int			ReadComplete;
1229
	SK_SENSOR	*pSen;
1230
	SK_U32		Time;
1231
	SK_EVPARA	ParaLocal;
1232
	int			i;
1233
1234
	/* New case: no sensors */
1235
	if (pAC->I2c.MaxSens == 0) {
1236
		return(0);
1237
	}
1238
1239
	switch (Event) {
1240
	case SK_I2CEV_IRQ:
1241
		pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
1242
		ReadComplete = SkI2cReadSensor(pAC, IoC, pSen);
1243
1244
		if (ReadComplete) {
1245
			/* Check sensor against defined thresholds */
1246
			SkI2cCheckSensor(pAC, pSen);
1247
1248
			/* Increment Current sensor and set appropriate Timeout */
1249
			pAC->I2c.CurrSens++;
1250
			if (pAC->I2c.CurrSens >= pAC->I2c.MaxSens) {
1251
				pAC->I2c.CurrSens = 0;
1252
				Time = SK_I2C_TIM_LONG;
1253
			}
1254
			else {
1255
				Time = SK_I2C_TIM_SHORT;
1256
			}
1257
1258
			/* Start Timer */
1259
			ParaLocal.Para64 = (SK_U64)0;
1260
1261
			pAC->I2c.TimerMode = SK_TIMER_NEW_GAUGING;
1262
1263
			SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time,
1264
				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
1265
		}
1266
		else {
1267
			/* Start Timer */
1268
			ParaLocal.Para64 = (SK_U64)0;
1269
1270
			pAC->I2c.TimerMode = SK_TIMER_WATCH_SM;
1271
1272
			SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, SK_I2C_TIM_WATCH,
1273
				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
1274
		}
1275
		break;
1276
	case SK_I2CEV_TIM:
1277
		if (pAC->I2c.TimerMode == SK_TIMER_NEW_GAUGING) {
1278
1279
			ParaLocal.Para64 = (SK_U64)0;
1280
			SkTimerStop(pAC, IoC, &pAC->I2c.SenTimer);
1281
1282
			pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
1283
			ReadComplete = SkI2cReadSensor(pAC, IoC, pSen);
1284
1285
			if (ReadComplete) {
1286
				/* Check sensor against defined thresholds */
1287
				SkI2cCheckSensor(pAC, pSen);
1288
1289
				/* Increment Current sensor and set appropriate Timeout */
1290
				pAC->I2c.CurrSens++;
1291
				if (pAC->I2c.CurrSens == pAC->I2c.MaxSens) {
1292
					pAC->I2c.CurrSens = 0;
1293
					Time = SK_I2C_TIM_LONG;
1294
				}
1295
				else {
1296
					Time = SK_I2C_TIM_SHORT;
1297
				}
1298
1299
				/* Start Timer */
1300
				ParaLocal.Para64 = (SK_U64)0;
1301
1302
				pAC->I2c.TimerMode = SK_TIMER_NEW_GAUGING;
1303
1304
				SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time,
1305
					SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
1306
			}
1307
		}
1308
		else {
1309
			pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
1310
			pSen->SenErrFlag = SK_SEN_ERR_FAULTY;
1311
			SK_I2C_STOP(IoC);
1312
1313
			/* Increment Current sensor and set appropriate Timeout */
1314
			pAC->I2c.CurrSens++;
1315
			if (pAC->I2c.CurrSens == pAC->I2c.MaxSens) {
1316
				pAC->I2c.CurrSens = 0;
1317
				Time = SK_I2C_TIM_LONG;
1318
			}
1319
			else {
1320
				Time = SK_I2C_TIM_SHORT;
1321
			}
1322
1323
			/* Start Timer */
1324
			ParaLocal.Para64 = (SK_U64)0;
1325
1326
			pAC->I2c.TimerMode = SK_TIMER_NEW_GAUGING;
1327
1328
			SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time,
1329
				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
1330
		}
1331
		break;
1332
	case SK_I2CEV_CLEAR:
1333
		for (i = 0; i < SK_MAX_SENSORS; i++) {
1334
			pSen = &pAC->I2c.SenTable[i];
1335
1336
			pSen->SenErrFlag = SK_SEN_ERR_OK;
1337
			pSen->SenErrCts = 0;
1338
			pSen->SenWarnCts = 0;
1339
			pSen->SenBegErrTS = 0;
1340
			pSen->SenBegWarnTS = 0;
1341
			pSen->SenLastErrTrapTS = (SK_U64)0;
1342
			pSen->SenLastErrLogTS = (SK_U64)0;
1343
			pSen->SenLastWarnTrapTS = (SK_U64)0;
1344
			pSen->SenLastWarnLogTS = (SK_U64)0;
1345
		}
1346
		break;
1347
	default:
1348
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E006, SKERR_I2C_E006MSG);
1349
	}
1350
1351
	return(0);
1352
}	/* SkI2cEvent*/
1353
1354
#endif /* !SK_DIAG */
1355
(-)linux/drivers/net/sk98lin/skvpd.c (-91 / +104 lines)
Lines 1-22 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 *
2
 *
3
 * Name:	skvpd.c
3
 * Name:	skvpd.c
4
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
4
 * Project:	Gigabit Ethernet Adapters, VPD-Module
5
 * Version:	$Revision: 1.37 $
5
 * Version:	$Revision: 2.6 $
6
 * Date:	$Date: 2003/01/13 10:42:45 $
6
 * Date:	$Date: 2004/11/02 10:47:39 $
7
 * Purpose:	Shared software to read and write VPD data
7
 * Purpose:	Shared software to read and write VPD
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
10
10
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2003 SysKonnect GmbH.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2004 Marvell.
14
 *
15
 *
15
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
17
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	(at your option) any later version.
19
 *	(at your option) any later version.
19
 *
20
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
21
 *
21
 *
22
 ******************************************************************************/
22
 ******************************************************************************/
Lines 25-31 Link Here
25
	Please refer skvpd.txt for infomation how to include this module
25
	Please refer skvpd.txt for infomation how to include this module
26
 */
26
 */
27
static const char SysKonnectFileId[] =
27
static const char SysKonnectFileId[] =
28
	"@(#)$Id: skvpd.c,v 1.37 2003/01/13 10:42:45 rschmidt Exp $ (C) SK";
28
	"@(#) $Id: skvpd.c,v 2.6 2004/11/02 10:47:39 rschmidt Exp $ (C) Marvell.";
29
29
30
#include "h/skdrv1st.h"
30
#include "h/skdrv1st.h"
31
#include "h/sktypes.h"
31
#include "h/sktypes.h"
Lines 59-67 Link Here
59
	SK_U64	start_time;
59
	SK_U64	start_time;
60
	SK_U16	state;
60
	SK_U16	state;
61
61
62
	SK_DBG_MSG(pAC,SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
62
	SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
63
		("VPD wait for %s\n", event?"Write":"Read"));
63
		("VPD wait for %s\n", event?"Write":"Read"));
64
	start_time = SkOsGetTime(pAC);
64
	start_time = SkOsGetTime(pAC);
65
65
	do {
66
	do {
66
		if (SkOsGetTime(pAC) - start_time > SK_TICKS_PER_SEC) {
67
		if (SkOsGetTime(pAC) - start_time > SK_TICKS_PER_SEC) {
67
68
Lines 81-97 Link Here
81
				("ERROR:VPD wait timeout\n"));
82
				("ERROR:VPD wait timeout\n"));
82
			return(1);
83
			return(1);
83
		}
84
		}
84
		
85
85
		VPD_IN16(pAC, IoC, PCI_VPD_ADR_REG, &state);
86
		VPD_IN16(pAC, IoC, PCI_VPD_ADR_REG, &state);
86
		
87
87
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
88
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
88
			("state = %x, event %x\n",state,event));
89
			("state = %x, event %x\n",state,event));
89
	} while((int)(state & PCI_VPD_FLAG) == event);
90
	} while ((int)(state & PCI_VPD_FLAG) == event);
90
91
91
	return(0);
92
	return(0);
92
}
93
}
93
94
94
#ifdef SKDIAG
95
96
#ifdef SK_DIAG
95
97
96
/*
98
/*
97
 * Read the dword at address 'addr' from the VPD EEPROM.
99
 * Read the dword at address 'addr' from the VPD EEPROM.
Lines 124-139 Link Here
124
	Rtv = 0;
126
	Rtv = 0;
125
127
126
	VPD_IN32(pAC, IoC, PCI_VPD_DAT_REG, &Rtv);
128
	VPD_IN32(pAC, IoC, PCI_VPD_DAT_REG, &Rtv);
127
	
129
128
	SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
130
	SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
129
		("VPD read dword data = 0x%x\n",Rtv));
131
		("VPD read dword data = 0x%x\n",Rtv));
130
	return(Rtv);
132
	return(Rtv);
131
}
133
}
134
#endif /* SK_DIAG */
132
135
133
#endif	/* SKDIAG */
134
135
#if 0
136
136
137
#ifdef XXX
137
/*
138
/*
138
	Write the dword 'data' at address 'addr' into the VPD EEPROM, and
139
	Write the dword 'data' at address 'addr' into the VPD EEPROM, and
139
	verify that the data is written.
140
	verify that the data is written.
Lines 151-157 Link Here
151
. over all 			3.8 ms		13.2 ms
152
. over all 			3.8 ms		13.2 ms
152
.
153
.
153
154
154
155
 Returns	0:	success
155
 Returns	0:	success
156
			1:	error,	I2C transfer does not terminate
156
			1:	error,	I2C transfer does not terminate
157
			2:	error,	data verify error
157
			2:	error,	data verify error
Lines 189-195 Link Here
189
	return(0);
189
	return(0);
190
}	/* VpdWriteDWord */
190
}	/* VpdWriteDWord */
191
191
192
#endif	/* 0 */
192
#endif /* XXX */
193
193
194
194
/*
195
/*
195
 *	Read one Stream of 'len' bytes of VPD data, starting at 'addr' from
196
 *	Read one Stream of 'len' bytes of VPD data, starting at 'addr' from
Lines 215-221 Link Here
215
	pComp = (SK_U8 *) buf;
216
	pComp = (SK_U8 *) buf;
216
217
217
	for (i = 0; i < Len; i++, buf++) {
218
	for (i = 0; i < Len; i++, buf++) {
218
		if ((i%sizeof(SK_U32)) == 0) {
219
		if ((i % SZ_LONG) == 0) {
219
			/*
220
			/*
220
			 * At the begin of each cycle read the Data Reg
221
			 * At the begin of each cycle read the Data Reg
221
			 * So it is initialized even if only a few bytes
222
			 * So it is initialized even if only a few bytes
Lines 233-246 Link Here
233
			}
234
			}
234
		}
235
		}
235
236
236
		/* Write current Byte */
237
		/* Write current byte */
237
		VPD_OUT8(pAC, IoC, PCI_VPD_DAT_REG + (i%sizeof(SK_U32)),
238
		VPD_OUT8(pAC, IoC, PCI_VPD_DAT_REG + (i % SZ_LONG), *(SK_U8*)buf);
238
				*(SK_U8*)buf);
239
239
240
		if (((i%sizeof(SK_U32)) == 3) || (i == (Len - 1))) {
240
		if (((i % SZ_LONG) == 3) || (i == (Len - 1))) {
241
			/* New Address needs to be written to VPD_ADDR reg */
241
			/* New Address needs to be written to VPD_ADDR reg */
242
			AdrReg = (SK_U16) Addr;
242
			AdrReg = (SK_U16) Addr;
243
			Addr += sizeof(SK_U32);
243
			Addr += SZ_LONG;
244
			AdrReg |= VPD_WRITE;	/* WRITE operation */
244
			AdrReg |= VPD_WRITE;	/* WRITE operation */
245
245
246
			VPD_OUT16(pAC, IoC, PCI_VPD_ADR_REG, AdrReg);
246
			VPD_OUT16(pAC, IoC, PCI_VPD_ADR_REG, AdrReg);
Lines 250-256 Link Here
250
			if (Rtv != 0) {
250
			if (Rtv != 0) {
251
				SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
251
				SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
252
					("Write Timed Out\n"));
252
					("Write Timed Out\n"));
253
				return(i - (i%sizeof(SK_U32)));
253
				return(i - (i % SZ_LONG));
254
			}
254
			}
255
255
256
			/*
256
			/*
Lines 265-282 Link Here
265
			if (Rtv != 0) {
265
			if (Rtv != 0) {
266
				SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
266
				SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
267
					("Verify Timed Out\n"));
267
					("Verify Timed Out\n"));
268
				return(i - (i%sizeof(SK_U32)));
268
				return(i - (i % SZ_LONG));
269
			}
269
			}
270
270
271
			for (j = 0; j <= (int)(i%sizeof(SK_U32)); j++, pComp++) {
271
			for (j = 0; j <= (int)(i % SZ_LONG); j++, pComp++) {
272
				
272
273
				VPD_IN8(pAC, IoC, PCI_VPD_DAT_REG + j, &Data);
273
				VPD_IN8(pAC, IoC, PCI_VPD_DAT_REG + j, &Data);
274
				
274
275
				if (Data != *pComp) {
275
				if (Data != *pComp) {
276
					/* Verify Error */
276
					/* Verify Error */
277
					SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
277
					SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
278
						("WriteStream Verify Error\n"));
278
						("WriteStream Verify Error\n"));
279
					return(i - (i%sizeof(SK_U32)) + j);
279
					return(i - (i % SZ_LONG) + j);
280
				}
280
				}
281
			}
281
			}
282
		}
282
		}
Lines 284-290 Link Here
284
284
285
	return(Len);
285
	return(Len);
286
}
286
}
287
	
287
288
288
289
/*
289
/*
290
 *	Read one Stream of 'len' bytes of VPD data, starting at 'addr' from
290
 *	Read one Stream of 'len' bytes of VPD data, starting at 'addr' from
Lines 304-313 Link Here
304
	int		Rtv;
304
	int		Rtv;
305
305
306
	for (i = 0; i < Len; i++, buf++) {
306
	for (i = 0; i < Len; i++, buf++) {
307
		if ((i%sizeof(SK_U32)) == 0) {
307
		if ((i % SZ_LONG) == 0) {
308
			/* New Address needs to be written to VPD_ADDR reg */
308
			/* New Address needs to be written to VPD_ADDR reg */
309
			AdrReg = (SK_U16) Addr;
309
			AdrReg = (SK_U16) Addr;
310
			Addr += sizeof(SK_U32);
310
			Addr += SZ_LONG;
311
			AdrReg &= ~VPD_WRITE;	/* READ operation */
311
			AdrReg &= ~VPD_WRITE;	/* READ operation */
312
312
313
			VPD_OUT16(pAC, IoC, PCI_VPD_ADR_REG, AdrReg);
313
			VPD_OUT16(pAC, IoC, PCI_VPD_ADR_REG, AdrReg);
Lines 318-330 Link Here
318
				return(i);
318
				return(i);
319
			}
319
			}
320
		}
320
		}
321
		VPD_IN8(pAC, IoC, PCI_VPD_DAT_REG + (i%sizeof(SK_U32)),
321
		VPD_IN8(pAC, IoC, PCI_VPD_DAT_REG + (i % SZ_LONG), (SK_U8 *)buf);
322
			(SK_U8 *)buf);
323
	}
322
	}
324
323
325
	return(Len);
324
	return(Len);
326
}
325
}
327
326
327
328
/*
328
/*
329
 *	Read ore writes 'len' bytes of VPD data, starting at 'addr' from
329
 *	Read ore writes 'len' bytes of VPD data, starting at 'addr' from
330
 *	or to the I2C EEPROM.
330
 *	or to the I2C EEPROM.
Lines 350-363 Link Here
350
		return(0);
350
		return(0);
351
351
352
	vpd_rom_size = pAC->vpd.rom_size;
352
	vpd_rom_size = pAC->vpd.rom_size;
353
	
353
354
	if (addr > vpd_rom_size - 4) {
354
	if (addr > vpd_rom_size - 4) {
355
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
355
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
356
			("Address error: 0x%x, exp. < 0x%x\n",
356
			("Address error: 0x%x, exp. < 0x%x\n",
357
			addr, vpd_rom_size - 4));
357
			addr, vpd_rom_size - 4));
358
		return(0);
358
		return(0);
359
	}
359
	}
360
	
360
361
	if (addr + len > vpd_rom_size) {
361
	if (addr + len > vpd_rom_size) {
362
		len = vpd_rom_size - addr;
362
		len = vpd_rom_size - addr;
363
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
363
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
Lines 374-381 Link Here
374
	return(Rtv);
374
	return(Rtv);
375
}
375
}
376
376
377
#ifdef SKDIAG
378
377
378
#if defined (SK_DIAG) || defined (SK_ASF)
379
/*
379
/*
380
 *	Read 'len' bytes of VPD data, starting at 'addr'.
380
 *	Read 'len' bytes of VPD data, starting at 'addr'.
381
 *
381
 *
Lines 391-396 Link Here
391
	return(VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_READ));
391
	return(VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_READ));
392
}
392
}
393
393
394
394
/*
395
/*
395
 *	Write 'len' bytes of *but to the VPD EEPROM, starting at 'addr'.
396
 *	Write 'len' bytes of *but to the VPD EEPROM, starting at 'addr'.
396
 *
397
 *
Lines 405-422 Link Here
405
{
406
{
406
	return(VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_WRITE));
407
	return(VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_WRITE));
407
}
408
}
408
#endif	/* SKDIAG */
409
#endif /* SK_DIAG */
409
410
410
/*
411
411
 * (re)initialize the VPD buffer
412
/******************************************************************************
412
 *
413
 *
413
 * Reads the VPD data from the EEPROM into the VPD buffer.
414
 *	VpdInit() - (re)initialize the VPD buffer
414
 * Get the remaining read only and read / write space.
415
 *
415
 *
416
 * return	0:	success
416
 * Description:
417
 *		1:	fatal VPD error
417
 *	Reads the VPD data from the EEPROM into the VPD buffer.
418
 *	Get the remaining read only and read / write space.
419
 *
420
 * Note:
421
 *	This is a local function and should be used locally only.
422
 *	However, the ASF module needs to use this function also.
423
 *	Therfore it has been published.
424
 *
425
 * Returns:
426
 *	0:	success
427
 *	1:	fatal VPD error
418
 */
428
 */
419
static int VpdInit(
429
int VpdInit(
420
SK_AC	*pAC,	/* Adapters context */
430
SK_AC	*pAC,	/* Adapters context */
421
SK_IOC	IoC)	/* IO Context */
431
SK_IOC	IoC)	/* IO Context */
422
{
432
{
Lines 427-440 Link Here
427
	SK_U16	dev_id;
437
	SK_U16	dev_id;
428
	SK_U32	our_reg2;
438
	SK_U32	our_reg2;
429
439
430
	SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_INIT, ("VpdInit .. "));
440
	SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_INIT, ("VpdInit ... "));
431
	
441
432
	VPD_IN16(pAC, IoC, PCI_DEVICE_ID, &dev_id);
442
	VPD_IN16(pAC, IoC, PCI_DEVICE_ID, &dev_id);
433
	
443
434
	VPD_IN32(pAC, IoC, PCI_OUR_REG_2, &our_reg2);
444
	VPD_IN32(pAC, IoC, PCI_OUR_REG_2, &our_reg2);
435
	
445
436
	pAC->vpd.rom_size = 256 << ((our_reg2 & PCI_VPD_ROM_SZ) >> 14);
446
	pAC->vpd.rom_size = 256 << ((our_reg2 & PCI_VPD_ROM_SZ) >> 14);
437
	
447
438
	/*
448
	/*
439
	 * this function might get used before the hardware is initialized
449
	 * this function might get used before the hardware is initialized
440
	 * therefore we cannot always trust in GIChipId
450
	 * therefore we cannot always trust in GIChipId
Lines 465-483 Link Here
465
			("Block Read Error\n"));
475
			("Block Read Error\n"));
466
		return(1);
476
		return(1);
467
	}
477
	}
468
	
478
469
	pAC->vpd.vpd_size = vpd_size;
479
	pAC->vpd.vpd_size = vpd_size;
470
480
471
	/* Asus K8V Se Deluxe bugfix. Correct VPD content */
481
	/* Asus K8V Se Deluxe bugfix. Correct VPD content */
472
	/* MBo April 2004 */
482
	i = 62;
473
	if (((unsigned char)pAC->vpd.vpd_buf[0x3f] == 0x38) &&
483
	if (!SK_STRNCMP(pAC->vpd.vpd_buf + i, " 8<E", 4)) {
474
	    ((unsigned char)pAC->vpd.vpd_buf[0x40] == 0x3c) &&
475
	    ((unsigned char)pAC->vpd.vpd_buf[0x41] == 0x45)) {
476
		printk("sk98lin: Asus mainboard with buggy VPD? "
477
				"Correcting data.\n");
478
		pAC->vpd.vpd_buf[0x40] = 0x38;
479
	}
480
484
485
		pAC->vpd.vpd_buf[i + 2] = '8';
486
	}
481
487
482
	/* find the end tag of the RO area */
488
	/* find the end tag of the RO area */
483
	if (!(r = vpd_find_para(pAC, VPD_RV, &rp))) {
489
	if (!(r = vpd_find_para(pAC, VPD_RV, &rp))) {
Lines 485-493 Link Here
485
			("Encoding Error: RV Tag not found\n"));
491
			("Encoding Error: RV Tag not found\n"));
486
		return(1);
492
		return(1);
487
	}
493
	}
488
	
494
489
	if (r->p_val + r->p_len > pAC->vpd.vpd_buf + vpd_size/2) {
495
	if (r->p_val + r->p_len > pAC->vpd.vpd_buf + vpd_size/2) {
490
		SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
496
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
491
			("Encoding Error: Invalid VPD struct size\n"));
497
			("Encoding Error: Invalid VPD struct size\n"));
492
		return(1);
498
		return(1);
493
	}
499
	}
Lines 497-503 Link Here
497
	for (i = 0, x = 0; (unsigned)i <= (unsigned)vpd_size/2 - r->p_len; i++) {
503
	for (i = 0, x = 0; (unsigned)i <= (unsigned)vpd_size/2 - r->p_len; i++) {
498
		x += pAC->vpd.vpd_buf[i];
504
		x += pAC->vpd.vpd_buf[i];
499
	}
505
	}
500
	
506
501
	if (x != 0) {
507
	if (x != 0) {
502
		/* checksum error */
508
		/* checksum error */
503
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
509
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
Lines 511-517 Link Here
511
			("Encoding Error: RV Tag not found\n"));
517
			("Encoding Error: RV Tag not found\n"));
512
		return(1);
518
		return(1);
513
	}
519
	}
514
	
520
515
	if (r->p_val < pAC->vpd.vpd_buf + vpd_size/2) {
521
	if (r->p_val < pAC->vpd.vpd_buf + vpd_size/2) {
516
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
522
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
517
			("Encoding Error: Invalid VPD struct size\n"));
523
			("Encoding Error: Invalid VPD struct size\n"));
Lines 531-536 Link Here
531
	return(0);
537
	return(0);
532
}
538
}
533
539
540
534
/*
541
/*
535
 *	find the Keyword 'key' in the VPD buffer and fills the
542
 *	find the Keyword 'key' in the VPD buffer and fills the
536
 *	parameter struct 'p' with it's values
543
 *	parameter struct 'p' with it's values
Lines 541-547 Link Here
541
static SK_VPD_PARA *vpd_find_para(
548
static SK_VPD_PARA *vpd_find_para(
542
SK_AC		*pAC,	/* common data base */
549
SK_AC		*pAC,	/* common data base */
543
const char	*key,	/* keyword to find (e.g. "MN") */
550
const char	*key,	/* keyword to find (e.g. "MN") */
544
SK_VPD_PARA *p)		/* parameter description struct */
551
SK_VPD_PARA	*p)		/* parameter description struct */
545
{
552
{
546
	char *v	;	/* points to VPD buffer */
553
	char *v	;	/* points to VPD buffer */
547
	int max;	/* Maximum Number of Iterations */
554
	int max;	/* Maximum Number of Iterations */
Lines 556-565 Link Here
556
	if (*v != (char)RES_ID) {
563
	if (*v != (char)RES_ID) {
557
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
564
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
558
			("Error: 0x%x missing\n", RES_ID));
565
			("Error: 0x%x missing\n", RES_ID));
559
		return NULL;
566
		return(0);
560
	}
567
	}
561
568
562
	if (strcmp(key, VPD_NAME) == 0) {
569
	if (SK_STRCMP(key, VPD_NAME) == 0) {
563
		p->p_len = VPD_GET_RES_LEN(v);
570
		p->p_len = VPD_GET_RES_LEN(v);
564
		p->p_val = VPD_GET_VAL(v);
571
		p->p_val = VPD_GET_VAL(v);
565
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
572
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
Lines 569-575 Link Here
569
576
570
	v += 3 + VPD_GET_RES_LEN(v) + 3;
577
	v += 3 + VPD_GET_RES_LEN(v) + 3;
571
	for (;; ) {
578
	for (;; ) {
572
		if (SK_MEMCMP(key,v,2) == 0) {
579
		if (SK_MEMCMP(key, v, 2) == 0) {
573
			p->p_len = VPD_GET_VPD_LEN(v);
580
			p->p_len = VPD_GET_VPD_LEN(v);
574
			p->p_val = VPD_GET_VAL(v);
581
			p->p_val = VPD_GET_VAL(v);
575
			SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
582
			SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
Lines 579-589 Link Here
579
586
580
		/* exit when reaching the "RW" Tag or the maximum of itera. */
587
		/* exit when reaching the "RW" Tag or the maximum of itera. */
581
		max--;
588
		max--;
582
		if (SK_MEMCMP(VPD_RW,v,2) == 0 || max == 0) {
589
		if (SK_MEMCMP(VPD_RW, v, 2) == 0 || max == 0) {
583
			break;
590
			break;
584
		}
591
		}
585
592
586
		if (SK_MEMCMP(VPD_RV,v,2) == 0) {
593
		if (SK_MEMCMP(VPD_RV, v, 2) == 0) {
587
			v += 3 + VPD_GET_VPD_LEN(v) + 3;	/* skip VPD-W */
594
			v += 3 + VPD_GET_VPD_LEN(v) + 3;	/* skip VPD-W */
588
		}
595
		}
589
		else {
596
		else {
Lines 600-608 Link Here
600
			("Key/Len Encoding error\n"));
607
			("Key/Len Encoding error\n"));
601
	}
608
	}
602
#endif /* DEBUG */
609
#endif /* DEBUG */
603
	return NULL;
610
	return(0);
604
}
611
}
605
612
613
606
/*
614
/*
607
 *	Move 'n' bytes. Begin with the last byte if 'n' is > 0,
615
 *	Move 'n' bytes. Begin with the last byte if 'n' is > 0,
608
 *	Start with the last byte if n is < 0.
616
 *	Start with the last byte if n is < 0.
Lines 637-642 Link Here
637
	}
645
	}
638
}
646
}
639
647
648
640
/*
649
/*
641
 *	setup the VPD keyword 'key' at 'ip'.
650
 *	setup the VPD keyword 'key' at 'ip'.
642
 *
651
 *
Lines 653-662 Link Here
653
	p = (SK_VPD_KEY *) ip;
662
	p = (SK_VPD_KEY *) ip;
654
	p->p_key[0] = key[0];
663
	p->p_key[0] = key[0];
655
	p->p_key[1] = key[1];
664
	p->p_key[1] = key[1];
656
	p->p_len = (unsigned char) len;
665
	p->p_len = (unsigned char)len;
657
	SK_MEMCPY(&p->p_val,buf,len);
666
	SK_MEMCPY(&p->p_val, buf, len);
658
}
667
}
659
668
669
660
/*
670
/*
661
 *	Setup the VPD end tag "RV" / "RW".
671
 *	Setup the VPD end tag "RV" / "RW".
662
 *	Also correct the remaining space variables vpd_free_ro / vpd_free_rw.
672
 *	Also correct the remaining space variables vpd_free_ro / vpd_free_rw.
Lines 682-688 Link Here
682
692
683
	if (p->p_key[0] != 'R' || (p->p_key[1] != 'V' && p->p_key[1] != 'W')) {
693
	if (p->p_key[0] != 'R' || (p->p_key[1] != 'V' && p->p_key[1] != 'W')) {
684
		/* something wrong here, encoding error */
694
		/* something wrong here, encoding error */
685
		SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
695
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
686
			("Encoding Error: invalid end tag\n"));
696
			("Encoding Error: invalid end tag\n"));
687
		return(1);
697
		return(1);
688
	}
698
	}
Lines 714-719 Link Here
714
	return(0);
724
	return(0);
715
}
725
}
716
726
727
717
/*
728
/*
718
 *	Insert a VPD keyword into the VPD buffer.
729
 *	Insert a VPD keyword into the VPD buffer.
719
 *
730
 *
Lines 747-757 Link Here
747
758
748
	SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
759
	SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
749
		("VPD setup para key = %s, val = %s\n",key,buf));
760
		("VPD setup para key = %s, val = %s\n",key,buf));
750
	
761
751
	vpd_size = pAC->vpd.vpd_size;
762
	vpd_size = pAC->vpd.vpd_size;
752
763
753
	rtv = 0;
764
	rtv = 0;
754
	ip = NULL;
765
	ip = 0;
755
	if (type == VPD_RW_KEY) {
766
	if (type == VPD_RW_KEY) {
756
		/* end tag is "RW" */
767
		/* end tag is "RW" */
757
		free = pAC->vpd.v.vpd_free_rw;
768
		free = pAC->vpd.v.vpd_free_rw;
Lines 875-892 Link Here
875
		}
886
		}
876
	}
887
	}
877
888
878
	if ((signed)strlen(VPD_NAME) + 1 <= *len) {
889
	if ((signed)SK_STRLEN(VPD_NAME) + 1 <= *len) {
879
		v = pAC->vpd.vpd_buf;
890
		v = pAC->vpd.vpd_buf;
880
		strcpy(buf,VPD_NAME);
891
		SK_STRCPY(buf, VPD_NAME);
881
		n = strlen(VPD_NAME) + 1;
892
		n = SK_STRLEN(VPD_NAME) + 1;
882
		buf += n;
893
		buf += n;
883
		*elements = 1;
894
		*elements = 1;
884
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_RX,
895
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_RX,
885
			("'%c%c' ",v[0],v[1]));
896
			("'%c%c' ", v[0], v[1]));
886
	}
897
	}
887
	else {
898
	else {
888
		*len = 0;
899
		*len = 0;
889
		SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
900
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
890
			("buffer overflow\n"));
901
			("buffer overflow\n"));
891
		return(2);
902
		return(2);
892
	}
903
	}
Lines 894-910 Link Here
894
	v += 3 + VPD_GET_RES_LEN(v) + 3;
905
	v += 3 + VPD_GET_RES_LEN(v) + 3;
895
	for (;; ) {
906
	for (;; ) {
896
		/* exit when reaching the "RW" Tag */
907
		/* exit when reaching the "RW" Tag */
897
		if (SK_MEMCMP(VPD_RW,v,2) == 0) {
908
		if (SK_MEMCMP(VPD_RW, v, 2) == 0) {
898
			break;
909
			break;
899
		}
910
		}
900
911
901
		if (SK_MEMCMP(VPD_RV,v,2) == 0) {
912
		if (SK_MEMCMP(VPD_RV, v, 2) == 0) {
902
			v += 3 + VPD_GET_VPD_LEN(v) + 3;	/* skip VPD-W */
913
			v += 3 + VPD_GET_VPD_LEN(v) + 3;	/* skip VPD-W */
903
			continue;
914
			continue;
904
		}
915
		}
905
916
906
		if (n+3 <= *len) {
917
		if (n+3 <= *len) {
907
			SK_MEMCPY(buf,v,2);
918
			SK_MEMCPY(buf, v, 2);
908
			buf += 2;
919
			buf += 2;
909
			*buf++ = '\0';
920
			*buf++ = '\0';
910
			n += 3;
921
			n += 3;
Lines 991-1003 Link Here
991
{
1002
{
992
	if ((*key != 'Y' && *key != 'V') ||
1003
	if ((*key != 'Y' && *key != 'V') ||
993
		key[1] < '0' || key[1] > 'Z' ||
1004
		key[1] < '0' || key[1] > 'Z' ||
994
		(key[1] > '9' && key[1] < 'A') || strlen(key) != 2) {
1005
		(key[1] > '9' && key[1] < 'A') || SK_STRLEN(key) != 2) {
995
1006
996
		return(SK_FALSE);
1007
		return(SK_FALSE);
997
	}
1008
	}
998
	return(SK_TRUE);
1009
	return(SK_TRUE);
999
}
1010
}
1000
1011
1012
1001
/*
1013
/*
1002
 *	Read the contents of the VPD EEPROM and copy it to the VPD
1014
 *	Read the contents of the VPD EEPROM and copy it to the VPD
1003
 *	buffer if not already done. Insert/overwrite the keyword 'key'
1015
 *	buffer if not already done. Insert/overwrite the keyword 'key'
Lines 1026-1032 Link Here
1026
1038
1027
	if ((*key != 'Y' && *key != 'V') ||
1039
	if ((*key != 'Y' && *key != 'V') ||
1028
		key[1] < '0' || key[1] > 'Z' ||
1040
		key[1] < '0' || key[1] > 'Z' ||
1029
		(key[1] > '9' && key[1] < 'A') || strlen(key) != 2) {
1041
		(key[1] > '9' && key[1] < 'A') || SK_STRLEN(key) != 2) {
1030
1042
1031
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
1043
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
1032
			("illegal key tag, keyword not written\n"));
1044
			("illegal key tag, keyword not written\n"));
Lines 1042-1054 Link Here
1042
	}
1054
	}
1043
1055
1044
	rtv = 0;
1056
	rtv = 0;
1045
	len = strlen(buf);
1057
	len = SK_STRLEN(buf);
1046
	if (len > VPD_MAX_LEN) {
1058
	if (len > VPD_MAX_LEN) {
1047
		/* cut it */
1059
		/* cut it */
1048
		len = VPD_MAX_LEN;
1060
		len = VPD_MAX_LEN;
1049
		rtv = 2;
1061
		rtv = 2;
1050
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
1062
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
1051
			("keyword too long, cut after %d bytes\n",VPD_MAX_LEN));
1063
			("keyword too long, cut after %d bytes\n", VPD_MAX_LEN));
1052
	}
1064
	}
1053
	if ((rtv2 = VpdSetupPara(pAC, key, buf, len, VPD_RW_KEY, OWR_KEY)) != 0) {
1065
	if ((rtv2 = VpdSetupPara(pAC, key, buf, len, VPD_RW_KEY, OWR_KEY)) != 0) {
1054
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
1066
		SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
Lines 1059-1064 Link Here
1059
	return(rtv);
1071
	return(rtv);
1060
}
1072
}
1061
1073
1074
1062
/*
1075
/*
1063
 *	Read the contents of the VPD EEPROM and copy it to the
1076
 *	Read the contents of the VPD EEPROM and copy it to the
1064
 *	VPD buffer if not already done. Remove the VPD keyword
1077
 *	VPD buffer if not already done. Remove the VPD keyword
Lines 1082-1088 Link Here
1082
1095
1083
	vpd_size = pAC->vpd.vpd_size;
1096
	vpd_size = pAC->vpd.vpd_size;
1084
1097
1085
	SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("VPD delete key %s\n",key));
1098
	SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_TX, ("VPD delete key %s\n", key));
1086
	if ((pAC->vpd.v.vpd_status & VPD_VALID) == 0) {
1099
	if ((pAC->vpd.v.vpd_status & VPD_VALID) == 0) {
1087
		if (VpdInit(pAC, IoC) != 0) {
1100
		if (VpdInit(pAC, IoC) != 0) {
1088
			SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
1101
			SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
Lines 1119-1124 Link Here
1119
	return(0);
1132
	return(0);
1120
}
1133
}
1121
1134
1135
1122
/*
1136
/*
1123
 *	If the VPD buffer contains valid data write the VPD
1137
 *	If the VPD buffer contains valid data write the VPD
1124
 *	read/write area back to the VPD EEPROM.
1138
 *	read/write area back to the VPD EEPROM.
Lines 1149-1155 Link Here
1149
}
1163
}
1150
1164
1151
1165
1152
1153
/*
1166
/*
1154
 *	Read the contents of the VPD EEPROM and copy it to the VPD buffer
1167
 *	Read the contents of the VPD EEPROM and copy it to the VPD buffer
1155
 *	if not already done. If the keyword "VF" is not present it will be
1168
 *	if not already done. If the keyword "VF" is not present it will be
Lines 1178-1184 Link Here
1178
		}
1191
		}
1179
	}
1192
	}
1180
1193
1181
	len = strlen(msg);
1194
	len = SK_STRLEN(msg);
1182
	if (len > VPD_MAX_LEN) {
1195
	if (len > VPD_MAX_LEN) {
1183
		/* cut it */
1196
		/* cut it */
1184
		len = VPD_MAX_LEN;
1197
		len = VPD_MAX_LEN;
(-)linux/drivers/net/sk98lin/skxmac2.c (-885 / +1350 lines)
Lines 2-9 Link Here
2
 *
2
 *
3
 * Name:	skxmac2.c
3
 * Name:	skxmac2.c
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
4
 * Project:	Gigabit Ethernet Adapters, Common Modules
5
 * Version:	$Revision: 1.102 $
5
 * Version:	$Revision: 2.32 $
6
 * Date:	$Date: 2003/10/02 16:53:58 $
6
 * Date:	$Date: 2005/01/26 10:16:41 $
7
 * Purpose:	Contains functions to initialize the MACs and PHYs
7
 * Purpose:	Contains functions to initialize the MACs and PHYs
8
 *
8
 *
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 11-23 Link Here
11
/******************************************************************************
11
/******************************************************************************
12
 *
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect.
13
 *	(C)Copyright 1998-2002 SysKonnect.
14
 *	(C)Copyright 2002-2003 Marvell.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
15
 *
16
 *	This program is free software; you can redistribute it and/or modify
16
 *	This program is free software; you can redistribute it and/or modify
17
 *	it under the terms of the GNU General Public License as published by
17
 *	it under the terms of the GNU General Public License as published by
18
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	the Free Software Foundation; either version 2 of the License, or
19
 *	(at your option) any later version.
19
 *	(at your option) any later version.
20
 *
21
 *	The information in this file is provided "AS IS" without warranty.
20
 *	The information in this file is provided "AS IS" without warranty.
22
 *
21
 *
23
 ******************************************************************************/
22
 ******************************************************************************/
Lines 37-43 Link Here
37
36
38
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
37
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
39
static const char SysKonnectFileId[] =
38
static const char SysKonnectFileId[] =
40
	"@(#) $Id: skxmac2.c,v 1.102 2003/10/02 16:53:58 rschmidt Exp $ (C) Marvell.";
39
	"@(#) $Id: skxmac2.c,v 2.32 2005/01/26 10:16:41 rschmidt Exp $ (C) Marvell.";
41
#endif
40
#endif
42
41
43
#ifdef GENESIS
42
#ifdef GENESIS
Lines 83-89 Link Here
83
 * Returns:
82
 * Returns:
84
 *	nothing
83
 *	nothing
85
 */
84
 */
86
void SkXmPhyRead(
85
int SkXmPhyRead(
87
SK_AC	*pAC,			/* Adapter Context */
86
SK_AC	*pAC,			/* Adapter Context */
88
SK_IOC	IoC,			/* I/O Context */
87
SK_IOC	IoC,			/* I/O Context */
89
int		Port,			/* Port Index (MAC_1 + n) */
88
int		Port,			/* Port Index (MAC_1 + n) */
Lines 94-106 Link Here
94
	SK_GEPORT	*pPrt;
93
	SK_GEPORT	*pPrt;
95
94
96
	pPrt = &pAC->GIni.GP[Port];
95
	pPrt = &pAC->GIni.GP[Port];
97
	
96
98
	/* write the PHY register's address */
97
	/* write the PHY register's address */
99
	XM_OUT16(IoC, Port, XM_PHY_ADDR, PhyReg | pPrt->PhyAddr);
98
	XM_OUT16(IoC, Port, XM_PHY_ADDR, PhyReg | pPrt->PhyAddr);
100
	
99
101
	/* get the PHY register's value */
100
	/* get the PHY register's value */
102
	XM_IN16(IoC, Port, XM_PHY_DATA, pVal);
101
	XM_IN16(IoC, Port, XM_PHY_DATA, pVal);
103
	
102
104
	if (pPrt->PhyType != SK_PHY_XMAC) {
103
	if (pPrt->PhyType != SK_PHY_XMAC) {
105
		do {
104
		do {
106
			XM_IN16(IoC, Port, XM_MMU_CMD, &Mmu);
105
			XM_IN16(IoC, Port, XM_MMU_CMD, &Mmu);
Lines 110-115 Link Here
110
		/* get the PHY register's value */
109
		/* get the PHY register's value */
111
		XM_IN16(IoC, Port, XM_PHY_DATA, pVal);
110
		XM_IN16(IoC, Port, XM_PHY_DATA, pVal);
112
	}
111
	}
112
113
	return(0);
113
}	/* SkXmPhyRead */
114
}	/* SkXmPhyRead */
114
115
115
116
Lines 122-128 Link Here
122
 * Returns:
123
 * Returns:
123
 *	nothing
124
 *	nothing
124
 */
125
 */
125
void SkXmPhyWrite(
126
int SkXmPhyWrite(
126
SK_AC	*pAC,		/* Adapter Context */
127
SK_AC	*pAC,		/* Adapter Context */
127
SK_IOC	IoC,		/* I/O Context */
128
SK_IOC	IoC,		/* I/O Context */
128
int		Port,		/* Port Index (MAC_1 + n) */
129
int		Port,		/* Port Index (MAC_1 + n) */
Lines 133-158 Link Here
133
	SK_GEPORT	*pPrt;
134
	SK_GEPORT	*pPrt;
134
135
135
	pPrt = &pAC->GIni.GP[Port];
136
	pPrt = &pAC->GIni.GP[Port];
136
	
137
137
	if (pPrt->PhyType != SK_PHY_XMAC) {
138
	if (pPrt->PhyType != SK_PHY_XMAC) {
138
		do {
139
		do {
139
			XM_IN16(IoC, Port, XM_MMU_CMD, &Mmu);
140
			XM_IN16(IoC, Port, XM_MMU_CMD, &Mmu);
140
			/* wait until 'Busy' is cleared */
141
			/* wait until 'Busy' is cleared */
141
		} while ((Mmu & XM_MMU_PHY_BUSY) != 0);
142
		} while ((Mmu & XM_MMU_PHY_BUSY) != 0);
142
	}
143
	}
143
	
144
144
	/* write the PHY register's address */
145
	/* write the PHY register's address */
145
	XM_OUT16(IoC, Port, XM_PHY_ADDR, PhyReg | pPrt->PhyAddr);
146
	XM_OUT16(IoC, Port, XM_PHY_ADDR, PhyReg | pPrt->PhyAddr);
146
	
147
147
	/* write the PHY register's value */
148
	/* write the PHY register's value */
148
	XM_OUT16(IoC, Port, XM_PHY_DATA, Val);
149
	XM_OUT16(IoC, Port, XM_PHY_DATA, Val);
149
	
150
150
	if (pPrt->PhyType != SK_PHY_XMAC) {
151
	if (pPrt->PhyType != SK_PHY_XMAC) {
151
		do {
152
		do {
152
			XM_IN16(IoC, Port, XM_MMU_CMD, &Mmu);
153
			XM_IN16(IoC, Port, XM_MMU_CMD, &Mmu);
153
			/* wait until 'Busy' is cleared */
154
			/* wait until 'Busy' is cleared */
154
		} while ((Mmu & XM_MMU_PHY_BUSY) != 0);
155
		} while ((Mmu & XM_MMU_PHY_BUSY) != 0);
155
	}
156
	}
157
158
	return(0);
156
}	/* SkXmPhyWrite */
159
}	/* SkXmPhyWrite */
157
#endif /* GENESIS */
160
#endif /* GENESIS */
158
161
Lines 167-173 Link Here
167
 * Returns:
170
 * Returns:
168
 *	nothing
171
 *	nothing
169
 */
172
 */
170
void SkGmPhyRead(
173
int SkGmPhyRead(
171
SK_AC	*pAC,			/* Adapter Context */
174
SK_AC	*pAC,			/* Adapter Context */
172
SK_IOC	IoC,			/* I/O Context */
175
SK_IOC	IoC,			/* I/O Context */
173
int		Port,			/* Port Index (MAC_1 + n) */
176
int		Port,			/* Port Index (MAC_1 + n) */
Lines 176-227 Link Here
176
{
179
{
177
	SK_U16	Ctrl;
180
	SK_U16	Ctrl;
178
	SK_GEPORT	*pPrt;
181
	SK_GEPORT	*pPrt;
179
#ifdef VCPU
182
	SK_U32	StartTime;
180
	u_long SimCyle;
183
	SK_U32	CurrTime;
181
	u_long SimLowTime;
184
	SK_U32	Delta;
182
	
185
183
	VCPUgetTime(&SimCyle, &SimLowTime);
184
	VCPUprintf(0, "SkGmPhyRead(%u), SimCyle=%u, SimLowTime=%u\n",
185
		PhyReg, SimCyle, SimLowTime);
186
#endif /* VCPU */
187
	
188
	pPrt = &pAC->GIni.GP[Port];
186
	pPrt = &pAC->GIni.GP[Port];
189
	
187
190
	/* set PHY-Register offset and 'Read' OpCode (= 1) */
188
	/* set PHY-Register offset and 'Read' OpCode (= 1) */
191
	*pVal = (SK_U16)(GM_SMI_CT_PHY_AD(pPrt->PhyAddr) |
189
	*pVal = (SK_U16)(GM_SMI_CT_PHY_AD(pPrt->PhyAddr) |
192
		GM_SMI_CT_REG_AD(PhyReg) | GM_SMI_CT_OP_RD);
190
		GM_SMI_CT_REG_AD(PhyReg) | GM_SMI_CT_OP_RD);
193
191
194
	GM_OUT16(IoC, Port, GM_SMI_CTRL, *pVal);
192
	GM_OUT16(IoC, Port, GM_SMI_CTRL, *pVal);
195
193
196
	GM_IN16(IoC, Port, GM_SMI_CTRL, &Ctrl);
194
#ifdef DEBUG
197
	
198
	/* additional check for MDC/MDIO activity */
195
	/* additional check for MDC/MDIO activity */
199
	if ((Ctrl & GM_SMI_CT_BUSY) == 0) {
196
	GM_IN16(IoC, Port, GM_SMI_CTRL, &Ctrl);
197
198
	if ((Ctrl & GM_SMI_CT_OP_RD) == 0) {
199
200
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
201
			("PHY read impossible on Port %d (Ctrl=0x%04x)\n", Port, Ctrl));
202
200
		*pVal = 0;
203
		*pVal = 0;
201
		return;
204
		return(1);
202
	}
205
	}
206
#endif /* DEBUG */
203
207
204
	*pVal |= GM_SMI_CT_BUSY;
208
	*pVal |= GM_SMI_CT_BUSY;
205
	
209
206
	do {
210
	SK_IN32(IoC, GMAC_TI_ST_VAL, &StartTime);
211
212
	do {	/* wait until 'Busy' is cleared and 'ReadValid' is set */
207
#ifdef VCPU
213
#ifdef VCPU
208
		VCPUwaitTime(1000);
214
		VCPUwaitTime(1000);
209
#endif /* VCPU */
215
#endif /* VCPU */
210
216
217
		SK_IN32(IoC, GMAC_TI_ST_VAL, &CurrTime);
218
219
		if (CurrTime >= StartTime) {
220
			Delta = CurrTime - StartTime;
221
		}
222
		else {
223
			Delta = CurrTime + ~StartTime + 1;
224
		}
225
226
		if (Delta > SK_PHY_ACC_TO) {
227
228
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
229
				("PHY read timeout on Port %d (Ctrl=0x%04x)\n", Port, Ctrl));
230
			return(1);
231
		}
232
211
		GM_IN16(IoC, Port, GM_SMI_CTRL, &Ctrl);
233
		GM_IN16(IoC, Port, GM_SMI_CTRL, &Ctrl);
212
234
213
	/* wait until 'ReadValid' is set */
235
		/* Error on reading SMI Control Register */
214
	} while (Ctrl == *pVal);
236
		if (Ctrl == 0xffff) {
215
	
237
			return(1);
216
	/* get the PHY register's value */
238
		}
239
240
	} while ((Ctrl ^ *pVal) != (GM_SMI_CT_RD_VAL | GM_SMI_CT_BUSY));
241
217
	GM_IN16(IoC, Port, GM_SMI_DATA, pVal);
242
	GM_IN16(IoC, Port, GM_SMI_DATA, pVal);
218
243
219
#ifdef VCPU
244
	/* dummy read after GM_IN16() */
220
	VCPUgetTime(&SimCyle, &SimLowTime);
245
	SK_IN32(IoC, GMAC_TI_ST_VAL, &CurrTime);
221
	VCPUprintf(0, "VCPUgetTime(), SimCyle=%u, SimLowTime=%u\n",
222
		SimCyle, SimLowTime);
223
#endif /* VCPU */
224
246
247
	return(0);
225
}	/* SkGmPhyRead */
248
}	/* SkGmPhyRead */
226
249
227
250
Lines 234-240 Link Here
234
 * Returns:
257
 * Returns:
235
 *	nothing
258
 *	nothing
236
 */
259
 */
237
void SkGmPhyWrite(
260
int SkGmPhyWrite(
238
SK_AC	*pAC,		/* Adapter Context */
261
SK_AC	*pAC,		/* Adapter Context */
239
SK_IOC	IoC,		/* I/O Context */
262
SK_IOC	IoC,		/* I/O Context */
240
int		Port,		/* Port Index (MAC_1 + n) */
263
int		Port,		/* Port Index (MAC_1 + n) */
Lines 243-296 Link Here
243
{
266
{
244
	SK_U16	Ctrl;
267
	SK_U16	Ctrl;
245
	SK_GEPORT	*pPrt;
268
	SK_GEPORT	*pPrt;
246
#ifdef VCPU
269
	SK_U32	StartTime;
247
	SK_U32	DWord;
270
	SK_U32	CurrTime;
248
	u_long	SimCyle;
271
	SK_U32	Delta;
249
	u_long	SimLowTime;
272
250
	
251
	VCPUgetTime(&SimCyle, &SimLowTime);
252
	VCPUprintf(0, "SkGmPhyWrite(Reg=%u, Val=0x%04x), SimCyle=%u, SimLowTime=%u\n",
253
		PhyReg, Val, SimCyle, SimLowTime);
254
#endif /* VCPU */
255
	
256
	pPrt = &pAC->GIni.GP[Port];
273
	pPrt = &pAC->GIni.GP[Port];
257
	
274
258
	/* write the PHY register's value */
275
	/* write the PHY register's value */
259
	GM_OUT16(IoC, Port, GM_SMI_DATA, Val);
276
	GM_OUT16(IoC, Port, GM_SMI_DATA, Val);
260
	
261
	/* set PHY-Register offset and 'Write' OpCode (= 0) */
262
	Val = GM_SMI_CT_PHY_AD(pPrt->PhyAddr) | GM_SMI_CT_REG_AD(PhyReg);
263
277
264
	GM_OUT16(IoC, Port, GM_SMI_CTRL, Val);
278
#ifdef DEBUG
265
266
	GM_IN16(IoC, Port, GM_SMI_CTRL, &Ctrl);
267
	
268
	/* additional check for MDC/MDIO activity */
279
	/* additional check for MDC/MDIO activity */
269
	if ((Ctrl & GM_SMI_CT_BUSY) == 0) {
280
	GM_IN16(IoC, Port, GM_SMI_DATA, &Ctrl);
270
		return;
281
282
	if (Ctrl != Val) {
283
284
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
285
			("PHY write impossible on Port %d (Val=0x%04x)\n", Port, Ctrl));
286
287
		return(1);
271
	}
288
	}
272
	
289
#endif /* DEBUG */
273
	Val |= GM_SMI_CT_BUSY;
274
290
275
	do {
291
	/* set PHY-Register offset and 'Write' OpCode (= 0) */
276
#ifdef VCPU
292
	Ctrl = (SK_U16)(GM_SMI_CT_PHY_AD(pPrt->PhyAddr) |
277
		/* read Timer value */
293
		GM_SMI_CT_REG_AD(PhyReg));
278
		SK_IN32(IoC, B2_TI_VAL, &DWord);
294
295
	GM_OUT16(IoC, Port, GM_SMI_CTRL, Ctrl);
296
297
	SK_IN32(IoC, GMAC_TI_ST_VAL, &StartTime);
279
298
299
	do {	/* wait until 'Busy' is cleared */
300
#ifdef VCPU
280
		VCPUwaitTime(1000);
301
		VCPUwaitTime(1000);
281
#endif /* VCPU */
302
#endif /* VCPU */
282
303
304
		SK_IN32(IoC, GMAC_TI_ST_VAL, &CurrTime);
305
306
		if (CurrTime >= StartTime) {
307
			Delta = CurrTime - StartTime;
308
		}
309
		else {
310
			Delta = CurrTime + ~StartTime + 1;
311
		}
312
313
		if (Delta > SK_PHY_ACC_TO) {
314
315
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
316
				("PHY write timeout on Port %d (Ctrl=0x%04x)\n", Port, Ctrl));
317
			return(1);
318
		}
319
283
		GM_IN16(IoC, Port, GM_SMI_CTRL, &Ctrl);
320
		GM_IN16(IoC, Port, GM_SMI_CTRL, &Ctrl);
284
321
285
	/* wait until 'Busy' is cleared */
322
		/* Error on reading SMI Control Register */
286
	} while (Ctrl == Val);
323
		if (Ctrl == 0xffff) {
324
			return(1);
325
		}
287
	
326
	
288
#ifdef VCPU
327
	} while ((Ctrl & GM_SMI_CT_BUSY) != 0);
289
	VCPUgetTime(&SimCyle, &SimLowTime);
290
	VCPUprintf(0, "VCPUgetTime(), SimCyle=%u, SimLowTime=%u\n",
291
		SimCyle, SimLowTime);
292
#endif /* VCPU */
293
328
329
	/* dummy read after GM_IN16() */
330
	SK_IN32(IoC, GMAC_TI_ST_VAL, &CurrTime);
331
332
	return(0);
294
}	/* SkGmPhyWrite */
333
}	/* SkGmPhyWrite */
295
#endif /* YUKON */
334
#endif /* YUKON */
296
335
Lines 312-327 Link Here
312
int		PhyReg,		/* Register Address (Offset) */
351
int		PhyReg,		/* Register Address (Offset) */
313
SK_U16	*pVal)		/* Pointer to Value */
352
SK_U16	*pVal)		/* Pointer to Value */
314
{
353
{
315
	void (*r_func)(SK_AC *pAC, SK_IOC IoC, int Port, int Reg, SK_U16 *pVal);
316
354
317
	if (pAC->GIni.GIGenesis) {
355
	pAC->GIni.GIFunc.pFnMacPhyRead(pAC, IoC, Port, PhyReg, pVal);
318
		r_func = SkXmPhyRead;
319
	}
320
	else {
321
		r_func = SkGmPhyRead;
322
	}
323
	
324
	r_func(pAC, IoC, Port, PhyReg, pVal);
325
}	/* SkGePhyRead */
356
}	/* SkGePhyRead */
326
357
327
358
Lines 341-356 Link Here
341
int		PhyReg,		/* Register Address (Offset) */
372
int		PhyReg,		/* Register Address (Offset) */
342
SK_U16	Val)		/* Value */
373
SK_U16	Val)		/* Value */
343
{
374
{
344
	void (*w_func)(SK_AC *pAC, SK_IOC IoC, int Port, int Reg, SK_U16 Val);
345
375
346
	if (pAC->GIni.GIGenesis) {
376
	pAC->GIni.GIFunc.pFnMacPhyWrite(pAC, IoC, Port, PhyReg, Val);
347
		w_func = SkXmPhyWrite;
348
	}
349
	else {
350
		w_func = SkGmPhyWrite;
351
	}
352
	
353
	w_func(pAC, IoC, Port, PhyReg, Val);
354
}	/* SkGePhyWrite */
377
}	/* SkGePhyWrite */
355
#endif /* SK_DIAG */
378
#endif /* SK_DIAG */
356
379
Lines 360-374 Link Here
360
 *	SkMacPromiscMode() - Enable / Disable Promiscuous Mode
383
 *	SkMacPromiscMode() - Enable / Disable Promiscuous Mode
361
 *
384
 *
362
 * Description:
385
 * Description:
363
 *   enables / disables promiscuous mode by setting Mode Register (XMAC) or
386
 *	enables / disables promiscuous mode by setting Mode Register (XMAC) or
364
 *   Receive Control Register (GMAC) dep. on board type   	
387
 *	Receive Control Register (GMAC) dep. on board type
365
 *
388
 *
366
 * Returns:
389
 * Returns:
367
 *	nothing
390
 *	nothing
368
 */
391
 */
369
void SkMacPromiscMode(
392
void SkMacPromiscMode(
370
SK_AC	*pAC,	/* adapter context */
393
SK_AC	*pAC,	/* Adapter Context */
371
SK_IOC	IoC,	/* IO context */
394
SK_IOC	IoC,	/* I/O Context */
372
int		Port,	/* Port Index (MAC_1 + n) */
395
int		Port,	/* Port Index (MAC_1 + n) */
373
SK_BOOL	Enable)	/* Enable / Disable */
396
SK_BOOL	Enable)	/* Enable / Disable */
374
{
397
{
Lines 377-387 Link Here
377
#endif
400
#endif
378
#ifdef GENESIS
401
#ifdef GENESIS
379
	SK_U32	MdReg;
402
	SK_U32	MdReg;
380
#endif	
403
#endif
381
404
382
#ifdef GENESIS
405
#ifdef GENESIS
383
	if (pAC->GIni.GIGenesis) {
406
	if (pAC->GIni.GIGenesis) {
384
		
407
385
		XM_IN32(IoC, Port, XM_MODE, &MdReg);
408
		XM_IN32(IoC, Port, XM_MODE, &MdReg);
386
		/* enable or disable promiscuous mode */
409
		/* enable or disable promiscuous mode */
387
		if (Enable) {
410
		if (Enable) {
Lines 394-405 Link Here
394
		XM_OUT32(IoC, Port, XM_MODE, MdReg);
417
		XM_OUT32(IoC, Port, XM_MODE, MdReg);
395
	}
418
	}
396
#endif /* GENESIS */
419
#endif /* GENESIS */
397
	
420
398
#ifdef YUKON
421
#ifdef YUKON
399
	if (pAC->GIni.GIYukon) {
422
	if (pAC->GIni.GIYukon) {
400
		
423
401
		GM_IN16(IoC, Port, GM_RX_CTRL, &RcReg);
424
		GM_IN16(IoC, Port, GM_RX_CTRL, &RcReg);
402
		
425
403
		/* enable or disable unicast and multicast filtering */
426
		/* enable or disable unicast and multicast filtering */
404
		if (Enable) {
427
		if (Enable) {
405
			RcReg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
428
			RcReg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
Lines 420-447 Link Here
420
 *	SkMacHashing() - Enable / Disable Hashing
443
 *	SkMacHashing() - Enable / Disable Hashing
421
 *
444
 *
422
 * Description:
445
 * Description:
423
 *   enables / disables hashing by setting Mode Register (XMAC) or
446
 *	enables / disables hashing by setting Mode Register (XMAC) or
424
 *   Receive Control Register (GMAC) dep. on board type		
447
 *	Receive Control Register (GMAC) dep. on board type
425
 *
448
 *
426
 * Returns:
449
 * Returns:
427
 *	nothing
450
 *	nothing
428
 */
451
 */
429
void SkMacHashing(
452
void SkMacHashing(
430
SK_AC	*pAC,	/* adapter context */
453
SK_AC	*pAC,	/* Adapter Context */
431
SK_IOC	IoC,	/* IO context */
454
SK_IOC	IoC,	/* I/O Context */
432
int		Port,	/* Port Index (MAC_1 + n) */
455
int		Port,	/* Port Index (MAC_1 + n) */
433
SK_BOOL	Enable)	/* Enable / Disable */
456
SK_BOOL	Enable)	/* Enable / Disable */
434
{
457
{
435
#ifdef YUKON
458
#ifdef YUKON
436
	SK_U16	RcReg;
459
	SK_U16	RcReg;
437
#endif	
460
#endif
438
#ifdef GENESIS
461
#ifdef GENESIS
439
	SK_U32	MdReg;
462
	SK_U32	MdReg;
440
#endif
463
#endif
441
464
442
#ifdef GENESIS
465
#ifdef GENESIS
443
	if (pAC->GIni.GIGenesis) {
466
	if (pAC->GIni.GIGenesis) {
444
		
467
445
		XM_IN32(IoC, Port, XM_MODE, &MdReg);
468
		XM_IN32(IoC, Port, XM_MODE, &MdReg);
446
		/* enable or disable hashing */
469
		/* enable or disable hashing */
447
		if (Enable) {
470
		if (Enable) {
Lines 454-465 Link Here
454
		XM_OUT32(IoC, Port, XM_MODE, MdReg);
477
		XM_OUT32(IoC, Port, XM_MODE, MdReg);
455
	}
478
	}
456
#endif /* GENESIS */
479
#endif /* GENESIS */
457
	
480
458
#ifdef YUKON
481
#ifdef YUKON
459
	if (pAC->GIni.GIYukon) {
482
	if (pAC->GIni.GIYukon) {
460
		
483
461
		GM_IN16(IoC, Port, GM_RX_CTRL, &RcReg);
484
		GM_IN16(IoC, Port, GM_RX_CTRL, &RcReg);
462
		
485
463
		/* enable or disable multicast filtering */
486
		/* enable or disable multicast filtering */
464
		if (Enable) {
487
		if (Enable) {
465
			RcReg |= GM_RXCR_MCF_ENA;
488
			RcReg |= GM_RXCR_MCF_ENA;
Lines 487-494 Link Here
487
 *	 - don't set XMR_FS_ERR in status	SK_LENERR_OK_ON/OFF
510
 *	 - don't set XMR_FS_ERR in status	SK_LENERR_OK_ON/OFF
488
 *	   for inrange length error frames
511
 *	   for inrange length error frames
489
 *	 - don't set XMR_FS_ERR in status	SK_BIG_PK_OK_ON/OFF
512
 *	 - don't set XMR_FS_ERR in status	SK_BIG_PK_OK_ON/OFF
490
 *	   for frames > 1514 bytes
513
 *		for frames > 1514 bytes
491
 *   - enable Rx of own packets         SK_SELF_RX_ON/OFF
514
 *	- enable Rx of own packets			SK_SELF_RX_ON/OFF
492
 *
515
 *
493
 *	for incoming packets may be enabled/disabled by this function.
516
 *	for incoming packets may be enabled/disabled by this function.
494
 *	Additional modes may be added later.
517
 *	Additional modes may be added later.
Lines 499-509 Link Here
499
 *	nothing
522
 *	nothing
500
 */
523
 */
501
static void SkXmSetRxCmd(
524
static void SkXmSetRxCmd(
502
SK_AC	*pAC,		/* adapter context */
525
SK_AC	*pAC,		/* Adapter Context */
503
SK_IOC	IoC,		/* IO context */
526
SK_IOC	IoC,		/* I/O Context */
504
int		Port,		/* Port Index (MAC_1 + n) */
527
int		Port,		/* Port Index (MAC_1 + n) */
505
int		Mode)		/* Mode is SK_STRIP_FCS_ON/OFF, SK_STRIP_PAD_ON/OFF,
528
int		Mode)		/* Mode is SK_STRIP_FCS_ON/OFF, SK_STRIP_PAD_ON/OFF,
506
					   SK_LENERR_OK_ON/OFF, or SK_BIG_PK_OK_ON/OFF */
529
						SK_LENERR_OK_ON/OFF, or SK_BIG_PK_OK_ON/OFF */
507
{
530
{
508
	SK_U16	OldRxCmd;
531
	SK_U16	OldRxCmd;
509
	SK_U16	RxCmd;
532
	SK_U16	RxCmd;
Lines 511-517 Link Here
511
	XM_IN16(IoC, Port, XM_RX_CMD, &OldRxCmd);
534
	XM_IN16(IoC, Port, XM_RX_CMD, &OldRxCmd);
512
535
513
	RxCmd = OldRxCmd;
536
	RxCmd = OldRxCmd;
514
	
537
515
	switch (Mode & (SK_STRIP_FCS_ON | SK_STRIP_FCS_OFF)) {
538
	switch (Mode & (SK_STRIP_FCS_ON | SK_STRIP_FCS_OFF)) {
516
	case SK_STRIP_FCS_ON:
539
	case SK_STRIP_FCS_ON:
517
		RxCmd |= XM_RX_STRIP_FCS;
540
		RxCmd |= XM_RX_STRIP_FCS;
Lines 572-579 Link Here
572
 *	The features
595
 *	The features
573
 *	 - FCS (CRC) stripping,				SK_STRIP_FCS_ON/OFF
596
 *	 - FCS (CRC) stripping,				SK_STRIP_FCS_ON/OFF
574
 *	 - don't set GMR_FS_LONG_ERR		SK_BIG_PK_OK_ON/OFF
597
 *	 - don't set GMR_FS_LONG_ERR		SK_BIG_PK_OK_ON/OFF
575
 *	   for frames > 1514 bytes
598
 *		for frames > 1514 bytes
576
 *   - enable Rx of own packets         SK_SELF_RX_ON/OFF
599
 *	- enable Rx of own packets			SK_SELF_RX_ON/OFF
577
 *
600
 *
578
 *	for incoming packets may be enabled/disabled by this function.
601
 *	for incoming packets may be enabled/disabled by this function.
579
 *	Additional modes may be added later.
602
 *	Additional modes may be added later.
Lines 584-603 Link Here
584
 *	nothing
607
 *	nothing
585
 */
608
 */
586
static void SkGmSetRxCmd(
609
static void SkGmSetRxCmd(
587
SK_AC	*pAC,		/* adapter context */
610
SK_AC	*pAC,		/* Adapter Context */
588
SK_IOC	IoC,		/* IO context */
611
SK_IOC	IoC,		/* I/O Context */
589
int		Port,		/* Port Index (MAC_1 + n) */
612
int		Port,		/* Port Index (MAC_1 + n) */
590
int		Mode)		/* Mode is SK_STRIP_FCS_ON/OFF, SK_STRIP_PAD_ON/OFF,
613
int		Mode)		/* Mode is SK_STRIP_FCS_ON/OFF, SK_STRIP_PAD_ON/OFF,
591
					   SK_LENERR_OK_ON/OFF, or SK_BIG_PK_OK_ON/OFF */
614
						SK_LENERR_OK_ON/OFF, or SK_BIG_PK_OK_ON/OFF */
592
{
615
{
593
	SK_U16	OldRxCmd;
594
	SK_U16	RxCmd;
616
	SK_U16	RxCmd;
595
617
596
	if ((Mode & (SK_STRIP_FCS_ON | SK_STRIP_FCS_OFF)) != 0) {
618
	if ((Mode & (SK_STRIP_FCS_ON | SK_STRIP_FCS_OFF)) != 0) {
597
		
598
		GM_IN16(IoC, Port, GM_RX_CTRL, &OldRxCmd);
599
619
600
		RxCmd = OldRxCmd;
620
		GM_IN16(IoC, Port, GM_RX_CTRL, &RxCmd);
601
621
602
		if ((Mode & SK_STRIP_FCS_ON) != 0) {
622
		if ((Mode & SK_STRIP_FCS_ON) != 0) {
603
			RxCmd |= GM_RXCR_CRC_DIS;
623
			RxCmd |= GM_RXCR_CRC_DIS;
Lines 605-621 Link Here
605
		else {
625
		else {
606
			RxCmd &= ~GM_RXCR_CRC_DIS;
626
			RxCmd &= ~GM_RXCR_CRC_DIS;
607
		}
627
		}
608
		/* Write the new mode to the Rx control register if required */
628
		/* Write the new mode to the Rx Control register */
609
		if (OldRxCmd != RxCmd) {
629
		GM_OUT16(IoC, Port, GM_RX_CTRL, RxCmd);
610
			GM_OUT16(IoC, Port, GM_RX_CTRL, RxCmd);
611
		}
612
	}
630
	}
613
631
614
	if ((Mode & (SK_BIG_PK_OK_ON | SK_BIG_PK_OK_OFF)) != 0) {
632
	if ((Mode & (SK_BIG_PK_OK_ON | SK_BIG_PK_OK_OFF)) != 0) {
615
		
616
		GM_IN16(IoC, Port, GM_SERIAL_MODE, &OldRxCmd);
617
633
618
		RxCmd = OldRxCmd;
634
		GM_IN16(IoC, Port, GM_SERIAL_MODE, &RxCmd);
619
635
620
		if ((Mode & SK_BIG_PK_OK_ON) != 0) {
636
		if ((Mode & SK_BIG_PK_OK_ON) != 0) {
621
			RxCmd |= GM_SMOD_JUMBO_ENA;
637
			RxCmd |= GM_SMOD_JUMBO_ENA;
Lines 623-632 Link Here
623
		else {
639
		else {
624
			RxCmd &= ~GM_SMOD_JUMBO_ENA;
640
			RxCmd &= ~GM_SMOD_JUMBO_ENA;
625
		}
641
		}
626
		/* Write the new mode to the Rx control register if required */
642
		/* Write the new mode to the Serial Mode register */
627
		if (OldRxCmd != RxCmd) {
643
		GM_OUT16(IoC, Port, GM_SERIAL_MODE, RxCmd);
628
			GM_OUT16(IoC, Port, GM_SERIAL_MODE, RxCmd);
629
		}
630
	}
644
	}
631
}	/* SkGmSetRxCmd */
645
}	/* SkGmSetRxCmd */
632
646
Lines 641-657 Link Here
641
 *	nothing
655
 *	nothing
642
 */
656
 */
643
void SkMacSetRxCmd(
657
void SkMacSetRxCmd(
644
SK_AC	*pAC,		/* adapter context */
658
SK_AC	*pAC,		/* Adapter Context */
645
SK_IOC	IoC,		/* IO context */
659
SK_IOC	IoC,		/* I/O Context */
646
int		Port,		/* Port Index (MAC_1 + n) */
660
int		Port,		/* Port Index (MAC_1 + n) */
647
int		Mode)		/* Rx Mode */
661
int		Mode)		/* Rx Mode */
648
{
662
{
649
	if (pAC->GIni.GIGenesis) {
663
	if (pAC->GIni.GIGenesis) {
650
		
664
651
		SkXmSetRxCmd(pAC, IoC, Port, Mode);
665
		SkXmSetRxCmd(pAC, IoC, Port, Mode);
652
	}
666
	}
653
	else {
667
	else {
654
		
668
655
		SkGmSetRxCmd(pAC, IoC, Port, Mode);
669
		SkGmSetRxCmd(pAC, IoC, Port, Mode);
656
	}
670
	}
657
671
Lines 668-682 Link Here
668
 *	nothing
682
 *	nothing
669
 */
683
 */
670
void SkMacCrcGener(
684
void SkMacCrcGener(
671
SK_AC	*pAC,	/* adapter context */
685
SK_AC	*pAC,	/* Adapter Context */
672
SK_IOC	IoC,	/* IO context */
686
SK_IOC	IoC,	/* I/O Context */
673
int		Port,	/* Port Index (MAC_1 + n) */
687
int		Port,	/* Port Index (MAC_1 + n) */
674
SK_BOOL	Enable)	/* Enable / Disable */
688
SK_BOOL	Enable)	/* Enable / Disable */
675
{
689
{
676
	SK_U16	Word;
690
	SK_U16	Word;
677
691
678
	if (pAC->GIni.GIGenesis) {
692
	if (pAC->GIni.GIGenesis) {
679
		
693
680
		XM_IN16(IoC, Port, XM_TX_CMD, &Word);
694
		XM_IN16(IoC, Port, XM_TX_CMD, &Word);
681
695
682
		if (Enable) {
696
		if (Enable) {
Lines 689-697 Link Here
689
		XM_OUT16(IoC, Port, XM_TX_CMD, Word);
703
		XM_OUT16(IoC, Port, XM_TX_CMD, Word);
690
	}
704
	}
691
	else {
705
	else {
692
		
706
693
		GM_IN16(IoC, Port, GM_TX_CTRL, &Word);
707
		GM_IN16(IoC, Port, GM_TX_CTRL, &Word);
694
		
708
695
		if (Enable) {
709
		if (Enable) {
696
			Word &= ~GM_TXCR_CRC_DIS;
710
			Word &= ~GM_TXCR_CRC_DIS;
697
		}
711
		}
Lines 721-734 Link Here
721
 *	nothing
735
 *	nothing
722
 */
736
 */
723
void SkXmClrExactAddr(
737
void SkXmClrExactAddr(
724
SK_AC	*pAC,		/* adapter context */
738
SK_AC	*pAC,		/* Adapter Context */
725
SK_IOC	IoC,		/* IO context */
739
SK_IOC	IoC,		/* I/O Context */
726
int		Port,		/* Port Index (MAC_1 + n) */
740
int		Port,		/* Port Index (MAC_1 + n) */
727
int		StartNum,	/* Begin with this Address Register Index (0..15) */
741
int		StartNum,	/* Begin with this Address Register Index (0..15) */
728
int		StopNum)	/* Stop after finished with this Register Idx (0..15) */
742
int		StopNum)	/* Stop after finished with this Register Idx (0..15) */
729
{
743
{
730
	int		i;
744
	int		i;
731
	SK_U16	ZeroAddr[3] = {0x0000, 0x0000, 0x0000};
745
	SK_U16	ZeroAddr[3] = {0, 0, 0};
732
746
733
	if ((unsigned)StartNum > 15 || (unsigned)StopNum > 15 ||
747
	if ((unsigned)StartNum > 15 || (unsigned)StopNum > 15 ||
734
		StartNum > StopNum) {
748
		StartNum > StopNum) {
Lines 738-744 Link Here
738
	}
752
	}
739
753
740
	for (i = StartNum; i <= StopNum; i++) {
754
	for (i = StartNum; i <= StopNum; i++) {
741
		XM_OUTADDR(IoC, Port, XM_EXM(i), &ZeroAddr[0]);
755
		XM_OUTADDR(IoC, Port, XM_EXM(i), ZeroAddr);
742
	}
756
	}
743
}	/* SkXmClrExactAddr */
757
}	/* SkXmClrExactAddr */
744
#endif /* GENESIS */
758
#endif /* GENESIS */
Lines 755-775 Link Here
755
 *	nothing
769
 *	nothing
756
 */
770
 */
757
void SkMacFlushTxFifo(
771
void SkMacFlushTxFifo(
758
SK_AC	*pAC,	/* adapter context */
772
SK_AC	*pAC,	/* Adapter Context */
759
SK_IOC	IoC,	/* IO context */
773
SK_IOC	IoC,	/* I/O Context */
760
int		Port)	/* Port Index (MAC_1 + n) */
774
int		Port)	/* Port Index (MAC_1 + n) */
761
{
775
{
762
#ifdef GENESIS
776
#ifdef GENESIS
763
	SK_U32	MdReg;
777
	SK_U32	MdReg;
764
778
765
	if (pAC->GIni.GIGenesis) {
779
	if (pAC->GIni.GIGenesis) {
766
		
780
767
		XM_IN32(IoC, Port, XM_MODE, &MdReg);
781
		XM_IN32(IoC, Port, XM_MODE, &MdReg);
768
782
769
		XM_OUT32(IoC, Port, XM_MODE, MdReg | XM_MD_FTF);
783
		XM_OUT32(IoC, Port, XM_MODE, MdReg | XM_MD_FTF);
770
	}
784
	}
771
#endif /* GENESIS */
785
#endif /* GENESIS */
772
	
786
773
#ifdef YUKON
787
#ifdef YUKON
774
	if (pAC->GIni.GIYukon) {
788
	if (pAC->GIni.GIYukon) {
775
		/* no way to flush the FIFO we have to issue a reset */
789
		/* no way to flush the FIFO we have to issue a reset */
Lines 791-798 Link Here
791
 *	nothing
805
 *	nothing
792
 */
806
 */
793
void SkMacFlushRxFifo(
807
void SkMacFlushRxFifo(
794
SK_AC	*pAC,	/* adapter context */
808
SK_AC	*pAC,	/* Adapter Context */
795
SK_IOC	IoC,	/* IO context */
809
SK_IOC	IoC,	/* I/O Context */
796
int		Port)	/* Port Index (MAC_1 + n) */
810
int		Port)	/* Port Index (MAC_1 + n) */
797
{
811
{
798
#ifdef GENESIS
812
#ifdef GENESIS
Lines 805-811 Link Here
805
		XM_OUT32(IoC, Port, XM_MODE, MdReg | XM_MD_FRF);
819
		XM_OUT32(IoC, Port, XM_MODE, MdReg | XM_MD_FRF);
806
	}
820
	}
807
#endif /* GENESIS */
821
#endif /* GENESIS */
808
	
822
809
#ifdef YUKON
823
#ifdef YUKON
810
	if (pAC->GIni.GIYukon) {
824
	if (pAC->GIni.GIYukon) {
811
		/* no way to flush the FIFO we have to issue a reset */
825
		/* no way to flush the FIFO we have to issue a reset */
Lines 853-875 Link Here
853
 *	nothing
867
 *	nothing
854
 */
868
 */
855
static void SkXmSoftRst(
869
static void SkXmSoftRst(
856
SK_AC	*pAC,	/* adapter context */
870
SK_AC	*pAC,	/* Adapter Context */
857
SK_IOC	IoC,	/* IO context */
871
SK_IOC	IoC,	/* I/O Context */
858
int		Port)	/* Port Index (MAC_1 + n) */
872
int		Port)	/* Port Index (MAC_1 + n) */
859
{
873
{
860
	SK_U16	ZeroAddr[4] = {0x0000, 0x0000, 0x0000, 0x0000};
874
	SK_U16	ZeroAddr[4] = {0, 0, 0, 0};
861
	
875
862
	/* reset the statistics module */
876
	/* reset the statistics module */
863
	XM_OUT32(IoC, Port, XM_GP_PORT, XM_GP_RES_STAT);
877
	XM_OUT32(IoC, Port, XM_GP_PORT, XM_GP_RES_STAT);
864
878
865
	/* disable all XMAC IRQs */
879
	/* disable all XMAC IRQs */
866
	XM_OUT16(IoC, Port, XM_IMSK, 0xffff);
880
	XM_OUT16(IoC, Port, XM_IMSK, 0xffff);
867
	
881
868
	XM_OUT32(IoC, Port, XM_MODE, 0);		/* clear Mode Reg */
882
	XM_OUT32(IoC, Port, XM_MODE, 0);		/* clear Mode Reg */
869
	
883
870
	XM_OUT16(IoC, Port, XM_TX_CMD, 0);		/* reset TX CMD Reg */
884
	XM_OUT16(IoC, Port, XM_TX_CMD, 0);		/* reset TX CMD Reg */
871
	XM_OUT16(IoC, Port, XM_RX_CMD, 0);		/* reset RX CMD Reg */
885
	XM_OUT16(IoC, Port, XM_RX_CMD, 0);		/* reset RX CMD Reg */
872
	
886
873
	/* disable all PHY IRQs */
887
	/* disable all PHY IRQs */
874
	switch (pAC->GIni.GP[Port].PhyType) {
888
	switch (pAC->GIni.GP[Port].PhyType) {
875
	case SK_PHY_BCOM:
889
	case SK_PHY_BCOM:
Lines 887-899 Link Here
887
	}
901
	}
888
902
889
	/* clear the Hash Register */
903
	/* clear the Hash Register */
890
	XM_OUTHASH(IoC, Port, XM_HSM, &ZeroAddr);
904
	XM_OUTHASH(IoC, Port, XM_HSM, ZeroAddr);
891
905
892
	/* clear the Exact Match Address registers */
906
	/* clear the Exact Match Address registers */
893
	SkXmClrExactAddr(pAC, IoC, Port, 0, 15);
907
	SkXmClrExactAddr(pAC, IoC, Port, 0, 15);
894
	
908
895
	/* clear the Source Check Address registers */
909
	/* clear the Source Check Address registers */
896
	XM_OUTHASH(IoC, Port, XM_SRC_CHK, &ZeroAddr);
910
	XM_OUTHASH(IoC, Port, XM_SRC_CHK, ZeroAddr);
897
911
898
}	/* SkXmSoftRst */
912
}	/* SkXmSoftRst */
899
913
Lines 916-923 Link Here
916
 *	nothing
930
 *	nothing
917
 */
931
 */
918
static void SkXmHardRst(
932
static void SkXmHardRst(
919
SK_AC	*pAC,	/* adapter context */
933
SK_AC	*pAC,	/* Adapter Context */
920
SK_IOC	IoC,	/* IO context */
934
SK_IOC	IoC,	/* I/O Context */
921
int		Port)	/* Port Index (MAC_1 + n) */
935
int		Port)	/* Port Index (MAC_1 + n) */
922
{
936
{
923
	SK_U32	Reg;
937
	SK_U32	Reg;
Lines 940-956 Link Here
940
			}
954
			}
941
955
942
			SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_SET_MAC_RST);
956
			SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_SET_MAC_RST);
943
			
957
944
			SK_IN16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), &Word);
958
			SK_IN16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), &Word);
945
		
959
946
		} while ((Word & MFF_SET_MAC_RST) == 0);
960
		} while ((Word & MFF_SET_MAC_RST) == 0);
947
	}
961
	}
948
962
949
	/* For external PHYs there must be special handling */
963
	/* For external PHYs there must be special handling */
950
	if (pAC->GIni.GP[Port].PhyType != SK_PHY_XMAC) {
964
	if (pAC->GIni.GP[Port].PhyType != SK_PHY_XMAC) {
951
		
965
952
		SK_IN32(IoC, B2_GP_IO, &Reg);
966
		SK_IN32(IoC, B2_GP_IO, &Reg);
953
		
967
954
		if (Port == 0) {
968
		if (Port == 0) {
955
			Reg |= GP_DIR_0; 	/* set to output */
969
			Reg |= GP_DIR_0; 	/* set to output */
956
			Reg &= ~GP_IO_0;	/* set PHY reset (active low) */
970
			Reg &= ~GP_IO_0;	/* set PHY reset (active low) */
Lines 978-989 Link Here
978
 *	nothing
992
 *	nothing
979
 */
993
 */
980
static void SkXmClearRst(
994
static void SkXmClearRst(
981
SK_AC	*pAC,	/* adapter context */
995
SK_AC	*pAC,	/* Adapter Context */
982
SK_IOC	IoC,	/* IO context */
996
SK_IOC	IoC,	/* I/O Context */
983
int		Port)	/* Port Index (MAC_1 + n) */
997
int		Port)	/* Port Index (MAC_1 + n) */
984
{
998
{
985
	SK_U32	DWord;
999
	SK_U32	DWord;
986
	
1000
987
	/* clear HW reset */
1001
	/* clear HW reset */
988
	SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_CLR_MAC_RST);
1002
	SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_CLR_MAC_RST);
989
1003
Lines 1000-1006 Link Here
1000
		/* Clear PHY reset */
1014
		/* Clear PHY reset */
1001
		SK_OUT32(IoC, B2_GP_IO, DWord);
1015
		SK_OUT32(IoC, B2_GP_IO, DWord);
1002
1016
1003
		/* Enable GMII interface */
1017
		/* enable GMII interface */
1004
		XM_OUT16(IoC, Port, XM_HW_CFG, XM_HW_GMII_MD);
1018
		XM_OUT16(IoC, Port, XM_HW_CFG, XM_HW_GMII_MD);
1005
	}
1019
	}
1006
}	/* SkXmClearRst */
1020
}	/* SkXmClearRst */
Lines 1020-1027 Link Here
1020
 *	nothing
1034
 *	nothing
1021
 */
1035
 */
1022
static void SkGmSoftRst(
1036
static void SkGmSoftRst(
1023
SK_AC	*pAC,	/* adapter context */
1037
SK_AC	*pAC,	/* Adapter Context */
1024
SK_IOC	IoC,	/* IO context */
1038
SK_IOC	IoC,	/* I/O Context */
1025
int		Port)	/* Port Index (MAC_1 + n) */
1039
int		Port)	/* Port Index (MAC_1 + n) */
1026
{
1040
{
1027
	SK_U16	EmptyHash[4] = {0x0000, 0x0000, 0x0000, 0x0000};
1041
	SK_U16	EmptyHash[4] = {0x0000, 0x0000, 0x0000, 0x0000};
Lines 1030-1048 Link Here
1030
	/* reset the statistics module */
1044
	/* reset the statistics module */
1031
1045
1032
	/* disable all GMAC IRQs */
1046
	/* disable all GMAC IRQs */
1033
	SK_OUT8(IoC, GMAC_IRQ_MSK, 0);
1047
	SK_OUT8(IoC, MR_ADDR(Port, GMAC_IRQ_MSK), 0);
1034
	
1048
1035
	/* disable all PHY IRQs */
1049
	/* disable all PHY IRQs */
1036
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_INT_MASK, 0);
1050
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_INT_MASK, 0);
1037
	
1051
1038
	/* clear the Hash Register */
1052
	/* clear the Hash Register */
1039
	GM_OUTHASH(IoC, Port, GM_MC_ADDR_H1, EmptyHash);
1053
	GM_OUTHASH(IoC, Port, GM_MC_ADDR_H1, EmptyHash);
1040
1054
1041
	/* Enable Unicast and Multicast filtering */
1055
	/* enable Unicast and Multicast filtering */
1042
	GM_IN16(IoC, Port, GM_RX_CTRL, &RxCtrl);
1056
	GM_IN16(IoC, Port, GM_RX_CTRL, &RxCtrl);
1043
	
1057
1044
	GM_OUT16(IoC, Port, GM_RX_CTRL,
1058
	GM_OUT16(IoC, Port, GM_RX_CTRL, RxCtrl | GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
1045
		(SK_U16)(RxCtrl | GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA));
1046
1059
1047
}	/* SkGmSoftRst */
1060
}	/* SkGmSoftRst */
1048
1061
Lines 1057-1072 Link Here
1057
 *	nothing
1070
 *	nothing
1058
 */
1071
 */
1059
static void SkGmHardRst(
1072
static void SkGmHardRst(
1060
SK_AC	*pAC,	/* adapter context */
1073
SK_AC	*pAC,	/* Adapter Context */
1061
SK_IOC	IoC,	/* IO context */
1074
SK_IOC	IoC,	/* I/O Context */
1062
int		Port)	/* Port Index (MAC_1 + n) */
1075
int		Port)	/* Port Index (MAC_1 + n) */
1063
{
1076
{
1064
	SK_U32	DWord;
1077
	SK_U32	DWord;
1065
	
1078
1066
	/* WA code for COMA mode */
1079
	/* WA code for COMA mode */
1067
	if (pAC->GIni.GIYukonLite &&
1080
	if (pAC->GIni.GIYukonLite &&
1068
		pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
1081
		pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
1069
		
1082
1070
		SK_IN32(IoC, B2_GP_IO, &DWord);
1083
		SK_IN32(IoC, B2_GP_IO, &DWord);
1071
1084
1072
		DWord |= (GP_DIR_9 | GP_IO_9);
1085
		DWord |= (GP_DIR_9 | GP_IO_9);
Lines 1076-1085 Link Here
1076
	}
1089
	}
1077
1090
1078
	/* set GPHY Control reset */
1091
	/* set GPHY Control reset */
1079
	SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), GPC_RST_SET);
1092
	SK_OUT8(IoC, MR_ADDR(Port, GPHY_CTRL), (SK_U8)GPC_RST_SET);
1080
1093
1081
	/* set GMAC Control reset */
1094
	/* set GMAC Control reset */
1082
	SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_RST_SET);
1095
	SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_RST_SET);
1083
1096
1084
}	/* SkGmHardRst */
1097
}	/* SkGmHardRst */
1085
1098
Lines 1094-1117 Link Here
1094
 *	nothing
1107
 *	nothing
1095
 */
1108
 */
1096
static void SkGmClearRst(
1109
static void SkGmClearRst(
1097
SK_AC	*pAC,	/* adapter context */
1110
SK_AC	*pAC,	/* Adapter Context */
1098
SK_IOC	IoC,	/* IO context */
1111
SK_IOC	IoC,	/* I/O Context */
1099
int		Port)	/* Port Index (MAC_1 + n) */
1112
int		Port)	/* Port Index (MAC_1 + n) */
1100
{
1113
{
1101
	SK_U32	DWord;
1114
	SK_U32	DWord;
1102
	
1115
	SK_U16	PhyId0;
1116
	SK_U16	PhyId1;
1117
	SK_U16	Word;
1118
1103
#ifdef XXX
1119
#ifdef XXX
1104
		/* clear GMAC Control reset */
1120
	/* clear GMAC Control reset */
1105
		SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_RST_CLR);
1121
	SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_RST_CLR);
1106
1122
1107
		/* set GMAC Control reset */
1123
	/* set GMAC Control reset */
1108
		SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_RST_SET);
1124
	SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_RST_SET);
1109
#endif /* XXX */
1125
#endif /* XXX */
1110
1126
1111
	/* WA code for COMA mode */
1127
	/* WA code for COMA mode */
1112
	if (pAC->GIni.GIYukonLite &&
1128
	if (pAC->GIni.GIYukonLite &&
1113
		pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
1129
		pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
1114
		
1130
1115
		SK_IN32(IoC, B2_GP_IO, &DWord);
1131
		SK_IN32(IoC, B2_GP_IO, &DWord);
1116
1132
1117
		DWord |= GP_DIR_9;		/* set to output */
1133
		DWord |= GP_DIR_9;		/* set to output */
Lines 1121-1150 Link Here
1121
		SK_OUT32(IoC, B2_GP_IO, DWord);
1137
		SK_OUT32(IoC, B2_GP_IO, DWord);
1122
	}
1138
	}
1123
1139
1124
	/* set HWCFG_MODE */
1140
#ifdef VCPU
1125
	DWord = GPC_INT_POL_HI | GPC_DIS_FC | GPC_DIS_SLEEP |
1141
	/* set MAC Reset before PHY reset is set */
1126
		GPC_ENA_XC | GPC_ANEG_ADV_ALL_M | GPC_ENA_PAUSE |
1142
	SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_RST_SET);
1127
		(pAC->GIni.GICopperType ? GPC_HWCFG_GMII_COP :
1143
#endif /* VCPU */
1128
		GPC_HWCFG_GMII_FIB);
1129
1144
1130
	/* set GPHY Control reset */
1145
	if (CHIP_ID_YUKON_2(pAC)) {
1131
	SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), DWord | GPC_RST_SET);
1146
		/* set GPHY Control reset */
1147
		SK_OUT8(IoC, MR_ADDR(Port, GPHY_CTRL), (SK_U8)GPC_RST_SET);
1148
1149
		/* release GPHY Control reset */
1150
		SK_OUT8(IoC, MR_ADDR(Port, GPHY_CTRL), (SK_U8)GPC_RST_CLR);
1151
	}
1152
	else {
1153
		/* set HWCFG_MODE */
1154
		DWord = GPC_INT_POL | GPC_DIS_FC | GPC_DIS_SLEEP |
1155
			GPC_ENA_XC | GPC_ANEG_ADV_ALL_M | GPC_ENA_PAUSE |
1156
			(pAC->GIni.GICopperType ? GPC_HWCFG_GMII_COP :
1157
			GPC_HWCFG_GMII_FIB);
1132
1158
1133
	/* release GPHY Control reset */
1159
		/* set GPHY Control reset */
1134
	SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), DWord | GPC_RST_CLR);
1160
		SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), DWord | GPC_RST_SET);
1161
1162
		/* release GPHY Control reset */
1163
		SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), DWord | GPC_RST_CLR);
1164
	}
1135
1165
1136
#ifdef VCPU
1166
#ifdef VCPU
1167
	/* wait for internal initialization of GPHY */
1168
	VCPUprintf(0, "Waiting until PHY %d is ready to initialize\n", Port);
1169
	VCpuWait(10000);
1170
1171
	/* release GMAC reset */
1172
	SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_RST_CLR);
1173
1174
	/* wait for stable GMAC clock */
1137
	VCpuWait(9000);
1175
	VCpuWait(9000);
1138
#endif /* VCPU */
1176
#endif /* VCPU */
1139
1177
1140
	/* clear GMAC Control reset */
1178
	/* clear GMAC Control reset */
1141
	SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_PAUSE_ON | GMC_RST_CLR);
1179
	SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_RST_CLR);
1180
1181
	if (HW_FEATURE(pAC, HWF_WA_DEV_472) && Port == MAC_2) {
1182
1183
		/* clear GMAC 1 Control reset */
1184
		SK_OUT8(IoC, MR_ADDR(MAC_1, GMAC_CTRL), (SK_U8)GMC_RST_CLR);
1185
1186
		do {
1187
			/* set GMAC 2 Control reset */
1188
			SK_OUT8(IoC, MR_ADDR(MAC_2, GMAC_CTRL), (SK_U8)GMC_RST_SET);
1189
1190
			/* clear GMAC 2 Control reset */
1191
			SK_OUT8(IoC, MR_ADDR(MAC_2, GMAC_CTRL), (SK_U8)GMC_RST_CLR);
1192
1193
			SkGmPhyRead(pAC, IoC, MAC_2, PHY_MARV_ID0, &PhyId0);
1194
1195
			SkGmPhyRead(pAC, IoC, MAC_2, PHY_MARV_ID1, &PhyId1);
1196
1197
			SkGmPhyRead(pAC, IoC, MAC_2, PHY_MARV_INT_MASK, &Word);
1198
1199
		} while (Word != 0 || PhyId0 != PHY_MARV_ID0_VAL ||
1200
				 PhyId1 != PHY_MARV_ID1_Y2);
1201
	}
1142
1202
1143
#ifdef VCPU
1203
#ifdef VCPU
1144
	VCpuWait(2000);
1204
	VCpuWait(2000);
1145
	
1205
1146
	SK_IN32(IoC, MR_ADDR(Port, GPHY_CTRL), &DWord);
1206
	SK_IN32(IoC, MR_ADDR(Port, GPHY_CTRL), &DWord);
1147
			
1207
1148
	SK_IN32(IoC, B0_ISRC, &DWord);
1208
	SK_IN32(IoC, B0_ISRC, &DWord);
1149
#endif /* VCPU */
1209
#endif /* VCPU */
1150
1210
Lines 1162-1198 Link Here
1162
 *	nothing
1222
 *	nothing
1163
 */
1223
 */
1164
void SkMacSoftRst(
1224
void SkMacSoftRst(
1165
SK_AC	*pAC,	/* adapter context */
1225
SK_AC	*pAC,	/* Adapter Context */
1166
SK_IOC	IoC,	/* IO context */
1226
SK_IOC	IoC,	/* I/O Context */
1167
int		Port)	/* Port Index (MAC_1 + n) */
1227
int		Port)	/* Port Index (MAC_1 + n) */
1168
{
1228
{
1169
	SK_GEPORT	*pPrt;
1170
1171
	pPrt = &pAC->GIni.GP[Port];
1172
1173
	/* disable receiver and transmitter */
1229
	/* disable receiver and transmitter */
1174
	SkMacRxTxDisable(pAC, IoC, Port);
1230
	SkMacRxTxDisable(pAC, IoC, Port);
1175
1231
1176
#ifdef GENESIS
1232
#ifdef GENESIS
1177
	if (pAC->GIni.GIGenesis) {
1233
	if (pAC->GIni.GIGenesis) {
1178
		
1234
1179
		SkXmSoftRst(pAC, IoC, Port);
1235
		SkXmSoftRst(pAC, IoC, Port);
1180
	}
1236
	}
1181
#endif /* GENESIS */
1237
#endif /* GENESIS */
1182
	
1238
1183
#ifdef YUKON
1239
#ifdef YUKON
1184
	if (pAC->GIni.GIYukon) {
1240
	if (pAC->GIni.GIYukon) {
1185
		
1241
1186
		SkGmSoftRst(pAC, IoC, Port);
1242
		SkGmSoftRst(pAC, IoC, Port);
1187
	}
1243
	}
1188
#endif /* YUKON */
1244
#endif /* YUKON */
1189
1245
1190
	/* flush the MAC's Rx and Tx FIFOs */
1246
	/* flush the MAC's Rx and Tx FIFOs */
1191
	SkMacFlushTxFifo(pAC, IoC, Port);
1247
	SkMacFlushTxFifo(pAC, IoC, Port);
1192
	
1248
1193
	SkMacFlushRxFifo(pAC, IoC, Port);
1249
	SkMacFlushRxFifo(pAC, IoC, Port);
1194
1250
1195
	pPrt->PState = SK_PRT_STOP;
1251
	pAC->GIni.GP[Port].PState = SK_PRT_STOP;
1196
1252
1197
}	/* SkMacSoftRst */
1253
}	/* SkMacSoftRst */
1198
1254
Lines 1207-1231 Link Here
1207
 *	nothing
1263
 *	nothing
1208
 */
1264
 */
1209
void SkMacHardRst(
1265
void SkMacHardRst(
1210
SK_AC	*pAC,	/* adapter context */
1266
SK_AC	*pAC,	/* Adapter Context */
1211
SK_IOC	IoC,	/* IO context */
1267
SK_IOC	IoC,	/* I/O Context */
1212
int		Port)	/* Port Index (MAC_1 + n) */
1268
int		Port)	/* Port Index (MAC_1 + n) */
1213
{
1269
{
1214
	
1270
1215
#ifdef GENESIS
1271
#ifdef GENESIS
1216
	if (pAC->GIni.GIGenesis) {
1272
	if (pAC->GIni.GIGenesis) {
1217
		
1273
1218
		SkXmHardRst(pAC, IoC, Port);
1274
		SkXmHardRst(pAC, IoC, Port);
1219
	}
1275
	}
1220
#endif /* GENESIS */
1276
#endif /* GENESIS */
1221
	
1277
1222
#ifdef YUKON
1278
#ifdef YUKON
1223
	if (pAC->GIni.GIYukon) {
1279
	if (pAC->GIni.GIYukon) {
1224
		
1280
1225
		SkGmHardRst(pAC, IoC, Port);
1281
		SkGmHardRst(pAC, IoC, Port);
1226
	}
1282
	}
1227
#endif /* YUKON */
1283
#endif /* YUKON */
1228
1284
1285
	pAC->GIni.GP[Port].PHWLinkUp = SK_FALSE;
1286
1229
	pAC->GIni.GP[Port].PState = SK_PRT_RESET;
1287
	pAC->GIni.GP[Port].PState = SK_PRT_RESET;
1230
1288
1231
}	/* SkMacHardRst */
1289
}	/* SkMacHardRst */
Lines 1241-1261 Link Here
1241
 *	nothing
1299
 *	nothing
1242
 */
1300
 */
1243
void SkMacClearRst(
1301
void SkMacClearRst(
1244
SK_AC	*pAC,	/* adapter context */
1302
SK_AC	*pAC,	/* Adapter Context */
1245
SK_IOC	IoC,	/* IO context */
1303
SK_IOC	IoC,	/* I/O Context */
1246
int		Port)	/* Port Index (MAC_1 + n) */
1304
int		Port)	/* Port Index (MAC_1 + n) */
1247
{
1305
{
1248
	
1306
1249
#ifdef GENESIS
1307
#ifdef GENESIS
1250
	if (pAC->GIni.GIGenesis) {
1308
	if (pAC->GIni.GIGenesis) {
1251
		
1309
1252
		SkXmClearRst(pAC, IoC, Port);
1310
		SkXmClearRst(pAC, IoC, Port);
1253
	}
1311
	}
1254
#endif /* GENESIS */
1312
#endif /* GENESIS */
1255
	
1313
1256
#ifdef YUKON
1314
#ifdef YUKON
1257
	if (pAC->GIni.GIYukon) {
1315
	if (pAC->GIni.GIYukon) {
1258
		
1316
1259
		SkGmClearRst(pAC, IoC, Port);
1317
		SkGmClearRst(pAC, IoC, Port);
1260
	}
1318
	}
1261
#endif /* YUKON */
1319
#endif /* YUKON */
Lines 1279-1286 Link Here
1279
 *	nothing
1337
 *	nothing
1280
 */
1338
 */
1281
void SkXmInitMac(
1339
void SkXmInitMac(
1282
SK_AC	*pAC,		/* adapter context */
1340
SK_AC	*pAC,		/* Adapter Context */
1283
SK_IOC	IoC,		/* IO context */
1341
SK_IOC	IoC,		/* I/O Context */
1284
int		Port)		/* Port Index (MAC_1 + n) */
1342
int		Port)		/* Port Index (MAC_1 + n) */
1285
{
1343
{
1286
	SK_GEPORT	*pPrt;
1344
	SK_GEPORT	*pPrt;
Lines 1296-1302 Link Here
1296
1354
1297
		if ((SWord & MFF_SET_MAC_RST) != 0) {
1355
		if ((SWord & MFF_SET_MAC_RST) != 0) {
1298
			/* PState does not match HW state */
1356
			/* PState does not match HW state */
1299
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E006, SKERR_HWI_E006MSG);
1357
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
1358
				("SkXmInitMac: PState does not match HW state"));
1300
			/* Correct it */
1359
			/* Correct it */
1301
			pPrt->PState = SK_PRT_RESET;
1360
			pPrt->PState = SK_PRT_RESET;
1302
		}
1361
		}
Lines 1315-1321 Link Here
1315
			 * Must be done AFTER first access to BCOM chip.
1374
			 * Must be done AFTER first access to BCOM chip.
1316
			 */
1375
			 */
1317
			XM_IN16(IoC, Port, XM_MMU_CMD, &SWord);
1376
			XM_IN16(IoC, Port, XM_MMU_CMD, &SWord);
1318
			
1377
1319
			XM_OUT16(IoC, Port, XM_MMU_CMD, SWord | XM_MMU_NO_PRE);
1378
			XM_OUT16(IoC, Port, XM_MMU_CMD, SWord | XM_MMU_NO_PRE);
1320
1379
1321
			if (pPrt->PhyId1 == PHY_BCOM_ID1_C0) {
1380
			if (pPrt->PhyId1 == PHY_BCOM_ID1_C0) {
Lines 1348-1354 Link Here
1348
			 * Disable Power Management after reset.
1407
			 * Disable Power Management after reset.
1349
			 */
1408
			 */
1350
			SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_CTRL, &SWord);
1409
			SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_CTRL, &SWord);
1351
			
1410
1352
			SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_AUX_CTRL,
1411
			SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_AUX_CTRL,
1353
				(SK_U16)(SWord | PHY_B_AC_DIS_PM));
1412
				(SK_U16)(SWord | PHY_B_AC_DIS_PM));
1354
1413
Lines 1357-1363 Link Here
1357
1416
1358
		/* Dummy read the Interrupt source register */
1417
		/* Dummy read the Interrupt source register */
1359
		XM_IN16(IoC, Port, XM_ISRC, &SWord);
1418
		XM_IN16(IoC, Port, XM_ISRC, &SWord);
1360
		
1419
1361
		/*
1420
		/*
1362
		 * The auto-negotiation process starts immediately after
1421
		 * The auto-negotiation process starts immediately after
1363
		 * clearing the reset. The auto-negotiation process should be
1422
		 * clearing the reset. The auto-negotiation process should be
Lines 1383-1389 Link Here
1383
		 * independent. Remember this when changing.
1442
		 * independent. Remember this when changing.
1384
		 */
1443
		 */
1385
		SK_IN16(IoC, (B2_MAC_2 + Port * 8 + i * 2), &SWord);
1444
		SK_IN16(IoC, (B2_MAC_2 + Port * 8 + i * 2), &SWord);
1386
		
1445
1387
		XM_OUT16(IoC, Port, (XM_SA + i * 2), SWord);
1446
		XM_OUT16(IoC, Port, (XM_SA + i * 2), SWord);
1388
	}
1447
	}
1389
1448
Lines 1436-1442 Link Here
1436
		 */
1495
		 */
1437
		SWord |= XM_RX_DIS_CEXT;
1496
		SWord |= XM_RX_DIS_CEXT;
1438
	}
1497
	}
1439
	
1498
1440
	XM_OUT16(IoC, Port, XM_RX_CMD, SWord);
1499
	XM_OUT16(IoC, Port, XM_RX_CMD, SWord);
1441
1500
1442
	/*
1501
	/*
Lines 1493-1500 Link Here
1493
 *	nothing
1552
 *	nothing
1494
 */
1553
 */
1495
void SkGmInitMac(
1554
void SkGmInitMac(
1496
SK_AC	*pAC,		/* adapter context */
1555
SK_AC	*pAC,		/* Adapter Context */
1497
SK_IOC	IoC,		/* IO context */
1556
SK_IOC	IoC,		/* I/O Context */
1498
int		Port)		/* Port Index (MAC_1 + n) */
1557
int		Port)		/* Port Index (MAC_1 + n) */
1499
{
1558
{
1500
	SK_GEPORT	*pPrt;
1559
	SK_GEPORT	*pPrt;
Lines 1508-1528 Link Here
1508
		/* Port State: SK_PRT_STOP */
1567
		/* Port State: SK_PRT_STOP */
1509
		/* Verify that the reset bit is cleared */
1568
		/* Verify that the reset bit is cleared */
1510
		SK_IN32(IoC, MR_ADDR(Port, GMAC_CTRL), &DWord);
1569
		SK_IN32(IoC, MR_ADDR(Port, GMAC_CTRL), &DWord);
1511
		
1570
1512
		if ((DWord & GMC_RST_SET) != 0) {
1571
		if ((DWord & GMC_RST_SET) != 0) {
1513
			/* PState does not match HW state */
1572
			/* PState does not match HW state */
1514
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E006, SKERR_HWI_E006MSG);
1573
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1574
				("SkGmInitMac: PState does not match HW state"));
1515
			/* Correct it */
1575
			/* Correct it */
1516
			pPrt->PState = SK_PRT_RESET;
1576
			pPrt->PState = SK_PRT_RESET;
1517
		}
1577
		}
1578
		else {
1579
			/* enable all PHY interrupts */
1580
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_INT_MASK,
1581
				(SK_U16)PHY_M_DEF_MSK);
1582
		}
1518
	}
1583
	}
1519
1584
1520
	if (pPrt->PState == SK_PRT_RESET) {
1585
	if (pPrt->PState == SK_PRT_RESET) {
1521
		
1586
1522
		SkGmHardRst(pAC, IoC, Port);
1587
		SkGmHardRst(pAC, IoC, Port);
1523
1588
1524
		SkGmClearRst(pAC, IoC, Port);
1589
		SkGmClearRst(pAC, IoC, Port);
1525
		
1590
1526
		/* Auto-negotiation ? */
1591
		/* Auto-negotiation ? */
1527
		if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
1592
		if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
1528
			/* Auto-negotiation disabled */
1593
			/* Auto-negotiation disabled */
Lines 1532-1541 Link Here
1532
1597
1533
			/* disable auto-update for speed, duplex and flow-control */
1598
			/* disable auto-update for speed, duplex and flow-control */
1534
			SWord |= GM_GPCR_AU_ALL_DIS;
1599
			SWord |= GM_GPCR_AU_ALL_DIS;
1535
			
1600
1536
			/* setup General Purpose Control Register */
1601
			/* setup General Purpose Control Register */
1537
			GM_OUT16(IoC, Port, GM_GP_CTRL, SWord);
1602
			GM_OUT16(IoC, Port, GM_GP_CTRL, SWord);
1538
			
1603
1539
			SWord = GM_GPCR_AU_ALL_DIS;
1604
			SWord = GM_GPCR_AU_ALL_DIS;
1540
		}
1605
		}
1541
		else {
1606
		else {
Lines 1546-1552 Link Here
1546
		switch (pPrt->PLinkSpeed) {
1611
		switch (pPrt->PLinkSpeed) {
1547
		case SK_LSPEED_AUTO:
1612
		case SK_LSPEED_AUTO:
1548
		case SK_LSPEED_1000MBPS:
1613
		case SK_LSPEED_1000MBPS:
1549
			SWord |= GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100;
1614
			if ((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS) != 0) {
1615
1616
				SWord |= GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100;
1617
			}
1550
			break;
1618
			break;
1551
		case SK_LSPEED_100MBPS:
1619
		case SK_LSPEED_100MBPS:
1552
			SWord |= GM_GPCR_SPEED_100;
1620
			SWord |= GM_GPCR_SPEED_100;
Lines 1564-1571 Link Here
1564
		/* flow-control settings */
1632
		/* flow-control settings */
1565
		switch (pPrt->PFlowCtrlMode) {
1633
		switch (pPrt->PFlowCtrlMode) {
1566
		case SK_FLOW_MODE_NONE:
1634
		case SK_FLOW_MODE_NONE:
1567
			/* set Pause Off */
1568
			SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_PAUSE_OFF);
1569
			/* disable Tx & Rx flow-control */
1635
			/* disable Tx & Rx flow-control */
1570
			SWord |= GM_GPCR_FC_TX_DIS | GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS;
1636
			SWord |= GM_GPCR_FC_TX_DIS | GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS;
1571
			break;
1637
			break;
Lines 1583-1606 Link Here
1583
		GM_OUT16(IoC, Port, GM_GP_CTRL, SWord);
1649
		GM_OUT16(IoC, Port, GM_GP_CTRL, SWord);
1584
1650
1585
		/* dummy read the Interrupt Source Register */
1651
		/* dummy read the Interrupt Source Register */
1586
		SK_IN16(IoC, GMAC_IRQ_SRC, &SWord);
1652
		SK_IN16(IoC, MR_ADDR(Port, GMAC_IRQ_SRC), &SWord);
1587
		
1653
1588
#ifndef VCPU
1654
#ifndef VCPU
1589
		/* read Id from PHY */
1655
		/* read Id from PHY */
1590
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_ID1, &pPrt->PhyId1);
1656
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_ID1, &pPrt->PhyId1);
1591
		
1657
1592
		SkGmInitPhyMarv(pAC, IoC, Port, SK_FALSE);
1658
		SkGmInitPhyMarv(pAC, IoC, Port, SK_FALSE);
1593
#endif /* VCPU */
1659
#endif /* !VCPU */
1594
	}
1660
	}
1595
1661
1596
	(void)SkGmResetCounter(pAC, IoC, Port);
1662
	(void)SkGmResetCounter(pAC, IoC, Port);
1597
1663
1598
	/* setup Transmit Control Register */
1664
	/* setup Transmit Control Register */
1599
	GM_OUT16(IoC, Port, GM_TX_CTRL, TX_COL_THR(pPrt->PMacColThres));
1665
	GM_OUT16(IoC, Port, GM_TX_CTRL, (SK_U16)TX_COL_THR(pPrt->PMacColThres));
1600
1666
1601
	/* setup Receive Control Register */
1667
	/* setup Receive Control Register */
1602
	GM_OUT16(IoC, Port, GM_RX_CTRL, GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA |
1668
	SWord = GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA | GM_RXCR_CRC_DIS;
1603
		GM_RXCR_CRC_DIS);
1669
1670
	GM_OUT16(IoC, Port, GM_RX_CTRL, SWord);
1604
1671
1605
	/* setup Transmit Flow Control Register */
1672
	/* setup Transmit Flow Control Register */
1606
	GM_OUT16(IoC, Port, GM_TX_FLOW_CTRL, 0xffff);
1673
	GM_OUT16(IoC, Port, GM_TX_FLOW_CTRL, 0xffff);
Lines 1610-1627 Link Here
1610
	GM_IN16(IoC, Port, GM_TX_PARAM, &SWord);
1677
	GM_IN16(IoC, Port, GM_TX_PARAM, &SWord);
1611
#endif /* VCPU */
1678
#endif /* VCPU */
1612
1679
1613
    SWord = TX_JAM_LEN_VAL(pPrt->PMacJamLen) |
1680
	SWord = (SK_U16)(TX_JAM_LEN_VAL(pPrt->PMacJamLen) |
1614
			TX_JAM_IPG_VAL(pPrt->PMacJamIpgVal) |
1681
		TX_JAM_IPG_VAL(pPrt->PMacJamIpgVal) |
1615
			TX_IPG_JAM_DATA(pPrt->PMacJamIpgData);
1682
		TX_IPG_JAM_DATA(pPrt->PMacJamIpgData) |
1616
	
1683
		TX_BACK_OFF_LIM(pPrt->PMacBackOffLim));
1684
1617
	GM_OUT16(IoC, Port, GM_TX_PARAM, SWord);
1685
	GM_OUT16(IoC, Port, GM_TX_PARAM, SWord);
1618
1686
1619
	/* configure the Serial Mode Register */
1687
	/* configure the Serial Mode Register */
1620
#ifdef VCPU
1688
	SWord = (SK_U16)(DATA_BLIND_VAL(pPrt->PMacDataBlind) |
1621
	GM_IN16(IoC, Port, GM_SERIAL_MODE, &SWord);
1689
		GM_SMOD_VLAN_ENA | IPG_DATA_VAL(pPrt->PMacIpgData));
1622
#endif /* VCPU */
1623
	
1624
	SWord = GM_SMOD_VLAN_ENA | IPG_DATA_VAL(pPrt->PMacIpgData);
1625
1690
1626
	if (pPrt->PMacLimit4) {
1691
	if (pPrt->PMacLimit4) {
1627
		/* reset of collision counter after 4 consecutive collisions */
1692
		/* reset of collision counter after 4 consecutive collisions */
Lines 1632-1640 Link Here
1632
		/* enable jumbo mode (Max. Frame Length = 9018) */
1697
		/* enable jumbo mode (Max. Frame Length = 9018) */
1633
		SWord |= GM_SMOD_JUMBO_ENA;
1698
		SWord |= GM_SMOD_JUMBO_ENA;
1634
	}
1699
	}
1635
	
1700
1636
	GM_OUT16(IoC, Port, GM_SERIAL_MODE, SWord);
1701
	GM_OUT16(IoC, Port, GM_SERIAL_MODE, SWord);
1637
	
1702
1638
	/*
1703
	/*
1639
	 * configure the GMACs Station Addresses
1704
	 * configure the GMACs Station Addresses
1640
	 * in PROM you can find our addresses at:
1705
	 * in PROM you can find our addresses at:
Lines 1663-1677 Link Here
1663
		else {
1728
		else {
1664
			GM_OUT16(IoC, Port, (GM_SRC_ADDR_1L + i * 4), SWord);
1729
			GM_OUT16(IoC, Port, (GM_SRC_ADDR_1L + i * 4), SWord);
1665
		}
1730
		}
1666
#else		
1731
#else
1667
		GM_OUT16(IoC, Port, (GM_SRC_ADDR_1L + i * 4), SWord);
1732
		GM_OUT16(IoC, Port, (GM_SRC_ADDR_1L + i * 4), SWord);
1668
#endif /* WA_DEV_16 */
1733
#endif /* WA_DEV_16 */
1669
		
1734
1670
		/* virtual address: will be used for data */
1735
		/* virtual address: will be used for data */
1671
		SK_IN16(IoC, (B2_MAC_1 + Port * 8 + i * 2), &SWord);
1736
		SK_IN16(IoC, (B2_MAC_1 + Port * 8 + i * 2), &SWord);
1672
1737
1673
		GM_OUT16(IoC, Port, (GM_SRC_ADDR_2L + i * 4), SWord);
1738
		GM_OUT16(IoC, Port, (GM_SRC_ADDR_2L + i * 4), SWord);
1674
		
1739
1675
		/* reset Multicast filtering Hash registers 1-3 */
1740
		/* reset Multicast filtering Hash registers 1-3 */
1676
		GM_OUT16(IoC, Port, GM_MC_ADDR_H1 + 4*i, 0);
1741
		GM_OUT16(IoC, Port, GM_MC_ADDR_H1 + 4*i, 0);
1677
	}
1742
	}
Lines 1684-1701 Link Here
1684
	GM_OUT16(IoC, Port, GM_RX_IRQ_MSK, 0);
1749
	GM_OUT16(IoC, Port, GM_RX_IRQ_MSK, 0);
1685
	GM_OUT16(IoC, Port, GM_TR_IRQ_MSK, 0);
1750
	GM_OUT16(IoC, Port, GM_TR_IRQ_MSK, 0);
1686
1751
1687
#if defined(SK_DIAG) || defined(DEBUG)
1688
	/* read General Purpose Status */
1689
	GM_IN16(IoC, Port, GM_GP_STAT, &SWord);
1690
	
1691
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1692
		("MAC Stat Reg.=0x%04X\n", SWord));
1693
#endif /* SK_DIAG || DEBUG */
1694
1695
#ifdef SK_DIAG
1696
	c_print("MAC Stat Reg=0x%04X\n", SWord);
1697
#endif /* SK_DIAG */
1698
1699
}	/* SkGmInitMac */
1752
}	/* SkGmInitMac */
1700
#endif /* YUKON */
1753
#endif /* YUKON */
1701
1754
Lines 1714-1721 Link Here
1714
 *	nothing
1767
 *	nothing
1715
 */
1768
 */
1716
void SkXmInitDupMd(
1769
void SkXmInitDupMd(
1717
SK_AC	*pAC,		/* adapter context */
1770
SK_AC	*pAC,		/* Adapter Context */
1718
SK_IOC	IoC,		/* IO context */
1771
SK_IOC	IoC,		/* I/O Context */
1719
int		Port)		/* Port Index (MAC_1 + n) */
1772
int		Port)		/* Port Index (MAC_1 + n) */
1720
{
1773
{
1721
	switch (pAC->GIni.GP[Port].PLinkModeStatus) {
1774
	switch (pAC->GIni.GP[Port].PLinkModeStatus) {
Lines 1762-1769 Link Here
1762
 *	nothing
1815
 *	nothing
1763
 */
1816
 */
1764
void SkXmInitPauseMd(
1817
void SkXmInitPauseMd(
1765
SK_AC	*pAC,		/* adapter context */
1818
SK_AC	*pAC,		/* Adapter Context */
1766
SK_IOC	IoC,		/* IO context */
1819
SK_IOC	IoC,		/* I/O Context */
1767
int		Port)		/* Port Index (MAC_1 + n) */
1820
int		Port)		/* Port Index (MAC_1 + n) */
1768
{
1821
{
1769
	SK_GEPORT	*pPrt;
1822
	SK_GEPORT	*pPrt;
Lines 1773-1783 Link Here
1773
	pPrt = &pAC->GIni.GP[Port];
1826
	pPrt = &pAC->GIni.GP[Port];
1774
1827
1775
	XM_IN16(IoC, Port, XM_MMU_CMD, &Word);
1828
	XM_IN16(IoC, Port, XM_MMU_CMD, &Word);
1776
	
1829
1777
	if (pPrt->PFlowCtrlStatus == SK_FLOW_STAT_NONE ||
1830
	if (pPrt->PFlowCtrlStatus == SK_FLOW_STAT_NONE ||
1778
		pPrt->PFlowCtrlStatus == SK_FLOW_STAT_LOC_SEND) {
1831
		pPrt->PFlowCtrlStatus == SK_FLOW_STAT_LOC_SEND) {
1779
1832
1780
		/* Disable Pause Frame Reception */
1833
		/* disable Pause Frame Reception */
1781
		Word |= XM_MMU_IGN_PF;
1834
		Word |= XM_MMU_IGN_PF;
1782
	}
1835
	}
1783
	else {
1836
	else {
Lines 1785-1794 Link Here
1785
		 * enabling pause frame reception is required for 1000BT
1838
		 * enabling pause frame reception is required for 1000BT
1786
		 * because the XMAC is not reset if the link is going down
1839
		 * because the XMAC is not reset if the link is going down
1787
		 */
1840
		 */
1788
		/* Enable Pause Frame Reception */
1841
		/* enable Pause Frame Reception */
1789
		Word &= ~XM_MMU_IGN_PF;
1842
		Word &= ~XM_MMU_IGN_PF;
1790
	}	
1843
	}
1791
	
1844
1792
	XM_OUT16(IoC, Port, XM_MMU_CMD, Word);
1845
	XM_OUT16(IoC, Port, XM_MMU_CMD, Word);
1793
1846
1794
	XM_IN32(IoC, Port, XM_MODE, &DWord);
1847
	XM_IN32(IoC, Port, XM_MODE, &DWord);
Lines 1811-1820 Link Here
1811
		/* remember this value is defined in big endian (!) */
1864
		/* remember this value is defined in big endian (!) */
1812
		XM_OUT16(IoC, Port, XM_MAC_PTIME, 0xffff);
1865
		XM_OUT16(IoC, Port, XM_MAC_PTIME, 0xffff);
1813
1866
1814
		/* Set Pause Mode in Mode Register */
1867
		/* set Pause Mode in Mode Register */
1815
		DWord |= XM_PAUSE_MODE;
1868
		DWord |= XM_PAUSE_MODE;
1816
1869
1817
		/* Set Pause Mode in MAC Rx FIFO */
1870
		/* set Pause Mode in MAC Rx FIFO */
1818
		SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_ENA_PAUSE);
1871
		SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_ENA_PAUSE);
1819
	}
1872
	}
1820
	else {
1873
	else {
Lines 1822-1834 Link Here
1822
		 * disable pause frame generation is required for 1000BT
1875
		 * disable pause frame generation is required for 1000BT
1823
		 * because the XMAC is not reset if the link is going down
1876
		 * because the XMAC is not reset if the link is going down
1824
		 */
1877
		 */
1825
		/* Disable Pause Mode in Mode Register */
1878
		/* disable Pause Mode in Mode Register */
1826
		DWord &= ~XM_PAUSE_MODE;
1879
		DWord &= ~XM_PAUSE_MODE;
1827
1880
1828
		/* Disable Pause Mode in MAC Rx FIFO */
1881
		/* disable Pause Mode in MAC Rx FIFO */
1829
		SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_DIS_PAUSE);
1882
		SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_DIS_PAUSE);
1830
	}
1883
	}
1831
	
1884
1832
	XM_OUT32(IoC, Port, XM_MODE, DWord);
1885
	XM_OUT32(IoC, Port, XM_MODE, DWord);
1833
}	/* SkXmInitPauseMd*/
1886
}	/* SkXmInitPauseMd*/
1834
1887
Lines 1845-1852 Link Here
1845
 *	nothing
1898
 *	nothing
1846
 */
1899
 */
1847
static void SkXmInitPhyXmac(
1900
static void SkXmInitPhyXmac(
1848
SK_AC	*pAC,		/* adapter context */
1901
SK_AC	*pAC,		/* Adapter Context */
1849
SK_IOC	IoC,		/* IO context */
1902
SK_IOC	IoC,		/* I/O Context */
1850
int		Port,		/* Port Index (MAC_1 + n) */
1903
int		Port,		/* Port Index (MAC_1 + n) */
1851
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
1904
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
1852
{
1905
{
Lines 1855-1866 Link Here
1855
1908
1856
	pPrt = &pAC->GIni.GP[Port];
1909
	pPrt = &pAC->GIni.GP[Port];
1857
	Ctrl = 0;
1910
	Ctrl = 0;
1858
	
1911
1859
	/* Auto-negotiation ? */
1912
	/* Auto-negotiation ? */
1860
	if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
1913
	if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
1861
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1914
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1862
			("InitPhyXmac: no auto-negotiation Port %d\n", Port));
1915
			("InitPhyXmac: no auto-negotiation Port %d\n", Port));
1863
		/* Set DuplexMode in Config register */
1916
		/* set DuplexMode in Config register */
1864
		if (pPrt->PLinkMode == SK_LMODE_FULL) {
1917
		if (pPrt->PLinkMode == SK_LMODE_FULL) {
1865
			Ctrl |= PHY_CT_DUP_MD;
1918
			Ctrl |= PHY_CT_DUP_MD;
1866
		}
1919
		}
Lines 1873-1881 Link Here
1873
	else {
1926
	else {
1874
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1927
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1875
			("InitPhyXmac: with auto-negotiation Port %d\n", Port));
1928
			("InitPhyXmac: with auto-negotiation Port %d\n", Port));
1876
		/* Set Auto-negotiation advertisement */
1929
		/* set Auto-negotiation advertisement */
1877
1930
1878
		/* Set Full/half duplex capabilities */
1931
		/* set Full/half duplex capabilities */
1879
		switch (pPrt->PLinkMode) {
1932
		switch (pPrt->PLinkMode) {
1880
		case SK_LMODE_AUTOHALF:
1933
		case SK_LMODE_AUTOHALF:
1881
			Ctrl |= PHY_X_AN_HD;
1934
			Ctrl |= PHY_X_AN_HD;
Lines 1891-1897 Link Here
1891
				SKERR_HWI_E015MSG);
1944
				SKERR_HWI_E015MSG);
1892
		}
1945
		}
1893
1946
1894
		/* Set Flow-control capabilities */
1947
		/* set Flow-control capabilities */
1895
		switch (pPrt->PFlowCtrlMode) {
1948
		switch (pPrt->PFlowCtrlMode) {
1896
		case SK_FLOW_MODE_NONE:
1949
		case SK_FLOW_MODE_NONE:
1897
			Ctrl |= PHY_X_P_NO_PAUSE;
1950
			Ctrl |= PHY_X_P_NO_PAUSE;
Lines 1918-1924 Link Here
1918
	}
1971
	}
1919
1972
1920
	if (DoLoop) {
1973
	if (DoLoop) {
1921
		/* Set the Phy Loopback bit, too */
1974
		/* set the Phy Loopback bit, too */
1922
		Ctrl |= PHY_CT_LOOP;
1975
		Ctrl |= PHY_CT_LOOP;
1923
	}
1976
	}
1924
1977
Lines 1939-1946 Link Here
1939
 *	nothing
1992
 *	nothing
1940
 */
1993
 */
1941
static void SkXmInitPhyBcom(
1994
static void SkXmInitPhyBcom(
1942
SK_AC	*pAC,		/* adapter context */
1995
SK_AC	*pAC,		/* Adapter Context */
1943
SK_IOC	IoC,		/* IO context */
1996
SK_IOC	IoC,		/* I/O Context */
1944
int		Port,		/* Port Index (MAC_1 + n) */
1997
int		Port,		/* Port Index (MAC_1 + n) */
1945
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
1998
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
1946
{
1999
{
Lines 1962-1968 Link Here
1962
	/* manually Master/Slave ? */
2015
	/* manually Master/Slave ? */
1963
	if (pPrt->PMSMode != SK_MS_MODE_AUTO) {
2016
	if (pPrt->PMSMode != SK_MS_MODE_AUTO) {
1964
		Ctrl2 |= PHY_B_1000C_MSE;
2017
		Ctrl2 |= PHY_B_1000C_MSE;
1965
		
2018
1966
		if (pPrt->PMSMode == SK_MS_MODE_MASTER) {
2019
		if (pPrt->PMSMode == SK_MS_MODE_MASTER) {
1967
			Ctrl2 |= PHY_B_1000C_MSC;
2020
			Ctrl2 |= PHY_B_1000C_MSC;
1968
		}
2021
		}
Lines 1971-1977 Link Here
1971
	if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
2024
	if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
1972
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2025
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1973
			("InitPhyBcom: no auto-negotiation Port %d\n", Port));
2026
			("InitPhyBcom: no auto-negotiation Port %d\n", Port));
1974
		/* Set DuplexMode in Config register */
2027
		/* set DuplexMode in Config register */
1975
		if (pPrt->PLinkMode == SK_LMODE_FULL) {
2028
		if (pPrt->PLinkMode == SK_LMODE_FULL) {
1976
			Ctrl1 |= PHY_CT_DUP_MD;
2029
			Ctrl1 |= PHY_CT_DUP_MD;
1977
		}
2030
		}
Lines 1989-1995 Link Here
1989
	else {
2042
	else {
1990
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2043
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
1991
			("InitPhyBcom: with auto-negotiation Port %d\n", Port));
2044
			("InitPhyBcom: with auto-negotiation Port %d\n", Port));
1992
		/* Set Auto-negotiation advertisement */
2045
		/* set Auto-negotiation advertisement */
1993
2046
1994
		/*
2047
		/*
1995
		 * Workaround BCOM Errata #1 for the C5 type.
2048
		 * Workaround BCOM Errata #1 for the C5 type.
Lines 1997-2004 Link Here
1997
		 * Set Repeater/DTE bit 10 of the 1000Base-T Control Register
2050
		 * Set Repeater/DTE bit 10 of the 1000Base-T Control Register
1998
		 */
2051
		 */
1999
		Ctrl2 |= PHY_B_1000C_RD;
2052
		Ctrl2 |= PHY_B_1000C_RD;
2000
		
2053
2001
		 /* Set Full/half duplex capabilities */
2054
		 /* set Full/half duplex capabilities */
2002
		switch (pPrt->PLinkMode) {
2055
		switch (pPrt->PLinkMode) {
2003
		case SK_LMODE_AUTOHALF:
2056
		case SK_LMODE_AUTOHALF:
2004
			Ctrl2 |= PHY_B_1000C_AHD;
2057
			Ctrl2 |= PHY_B_1000C_AHD;
Lines 2014-2020 Link Here
2014
				SKERR_HWI_E015MSG);
2067
				SKERR_HWI_E015MSG);
2015
		}
2068
		}
2016
2069
2017
		/* Set Flow-control capabilities */
2070
		/* set Flow-control capabilities */
2018
		switch (pPrt->PFlowCtrlMode) {
2071
		switch (pPrt->PFlowCtrlMode) {
2019
		case SK_FLOW_MODE_NONE:
2072
		case SK_FLOW_MODE_NONE:
2020
			Ctrl3 |= PHY_B_P_NO_PAUSE;
2073
			Ctrl3 |= PHY_B_P_NO_PAUSE;
Lines 2036-2058 Link Here
2036
		/* Restart Auto-negotiation */
2089
		/* Restart Auto-negotiation */
2037
		Ctrl1 |= PHY_CT_ANE | PHY_CT_RE_CFG;
2090
		Ctrl1 |= PHY_CT_ANE | PHY_CT_RE_CFG;
2038
	}
2091
	}
2039
	
2092
2040
	/* Initialize LED register here? */
2093
	/* Initialize LED register here? */
2041
	/* No. Please do it in SkDgXmitLed() (if required) and swap
2094
	/* No. Please do it in SkDgXmitLed() (if required) and swap
2042
	   init order of LEDs and XMAC. (MAl) */
2095
		init order of LEDs and XMAC. (MAl) */
2043
	
2096
2044
	/* Write 1000Base-T Control Register */
2097
	/* Write 1000Base-T Control Register */
2045
	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_1000T_CTRL, Ctrl2);
2098
	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_1000T_CTRL, Ctrl2);
2046
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2099
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2047
		("Set 1000B-T Ctrl Reg=0x%04X\n", Ctrl2));
2100
		("Set 1000B-T Ctrl Reg=0x%04X\n", Ctrl2));
2048
	
2101
2049
	/* Write AutoNeg Advertisement Register */
2102
	/* Write AutoNeg Advertisement Register */
2050
	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_AUNE_ADV, Ctrl3);
2103
	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_AUNE_ADV, Ctrl3);
2051
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2104
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2052
		("Set Auto-Neg.Adv.Reg=0x%04X\n", Ctrl3));
2105
		("Set Auto-Neg.Adv.Reg=0x%04X\n", Ctrl3));
2053
	
2106
2054
	if (DoLoop) {
2107
	if (DoLoop) {
2055
		/* Set the Phy Loopback bit, too */
2108
		/* set the Phy Loopback bit, too */
2056
		Ctrl1 |= PHY_CT_LOOP;
2109
		Ctrl1 |= PHY_CT_LOOP;
2057
	}
2110
	}
2058
2111
Lines 2068-2074 Link Here
2068
2121
2069
	/* Configure LED Traffic Mode and Jumbo Frame usage if specified */
2122
	/* Configure LED Traffic Mode and Jumbo Frame usage if specified */
2070
	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_P_EXT_CTRL, Ctrl4);
2123
	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_P_EXT_CTRL, Ctrl4);
2071
	
2124
2072
	/* Write to the Phy control register */
2125
	/* Write to the Phy control register */
2073
	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_CTRL, Ctrl1);
2126
	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_CTRL, Ctrl1);
2074
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2127
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
Lines 2078-2094 Link Here
2078
2131
2079
2132
2080
#ifdef YUKON
2133
#ifdef YUKON
2081
#ifndef SK_SLIM
2134
#ifdef SK_PHY_LP_MODE
2082
/******************************************************************************
2135
/******************************************************************************
2083
 *
2136
 *
2084
 *	SkGmEnterLowPowerMode()
2137
 *	SkGmEnterLowPowerMode()
2085
 *
2138
 *
2086
 * Description:	
2139
 * Description:
2087
 *	This function sets the Marvell Alaska PHY to the low power mode
2140
 *	This function sets the Marvell Alaska PHY to the low power mode
2088
 *	given by parameter mode.
2141
 *	given by parameter mode.
2089
 *	The following low power modes are available:
2142
 *	The following low power modes are available:
2090
 *		
2143
 *
2091
 *		- Coma Mode (Deep Sleep):
2144
 *		- COMA Mode (Deep Sleep):
2092
 *			Power consumption: ~15 - 30 mW
2145
 *			Power consumption: ~15 - 30 mW
2093
 *			The PHY cannot wake up on its own.
2146
 *			The PHY cannot wake up on its own.
2094
 *
2147
 *
Lines 2115-2228 Link Here
2115
 *		1: error
2168
 *		1: error
2116
 */
2169
 */
2117
int SkGmEnterLowPowerMode(
2170
int SkGmEnterLowPowerMode(
2118
SK_AC	*pAC,		/* adapter context */
2171
SK_AC	*pAC,		/* Adapter Context */
2119
SK_IOC	IoC,		/* IO context */
2172
SK_IOC	IoC,		/* I/O Context */
2120
int		Port,		/* Port Index (e.g. MAC_1) */
2173
int		Port,		/* Port Index (e.g. MAC_1) */
2121
SK_U8	Mode)		/* low power mode */
2174
SK_U8	Mode)		/* low power mode */
2122
{
2175
{
2123
	SK_U16	Word;
2176
	SK_U16	Word;
2124
	SK_U32	DWord;
2177
	SK_U32	DWord;
2178
	SK_U32	PowerDownBit;
2125
	SK_U8	LastMode;
2179
	SK_U8	LastMode;
2126
	int		Ret = 0;
2180
	int		Ret = 0;
2127
2181
2128
	if (pAC->GIni.GIYukonLite &&
2182
	if (!(CHIP_ID_YUKON_2(pAC) || (pAC->GIni.GIYukonLite &&
2129
	    pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
2183
		pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3))) {
2130
2184
2131
		/* save current power mode */
2185
		return(1);
2132
		LastMode = pAC->GIni.GP[Port].PPhyPowerState;
2186
	}
2133
		pAC->GIni.GP[Port].PPhyPowerState = Mode;
2134
2135
		switch (Mode) {
2136
			/* coma mode (deep sleep) */
2137
			case PHY_PM_DEEP_SLEEP:
2138
				/* setup General Purpose Control Register */
2139
				GM_OUT16(IoC, 0, GM_GP_CTRL, GM_GPCR_FL_PASS |
2140
					GM_GPCR_SPEED_100 | GM_GPCR_AU_ALL_DIS);
2141
2142
				/* apply COMA mode workaround */
2143
				SkGmPhyWrite(pAC, IoC, Port, 29, 0x001f);
2144
				SkGmPhyWrite(pAC, IoC, Port, 30, 0xfff3);
2145
2146
				SK_IN32(IoC, PCI_C(PCI_OUR_REG_1), &DWord);
2147
2148
				SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2149
				
2150
				/* Set PHY to Coma Mode */
2151
				SK_OUT32(IoC, PCI_C(PCI_OUR_REG_1), DWord | PCI_PHY_COMA);
2152
				
2153
				SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2154
2155
			break;
2156
			
2157
			/* IEEE 22.2.4.1.5 compatible power down mode */
2158
			case PHY_PM_IEEE_POWER_DOWN:
2159
				/*
2160
				 * - disable MAC 125 MHz clock
2161
				 * - allow MAC power down
2162
				 */
2163
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2164
				Word |= PHY_M_PC_DIS_125CLK;
2165
				Word &=	~PHY_M_PC_MAC_POW_UP;
2166
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2167
2187
2168
				/*
2188
	/* save current power mode */
2169
				 * register changes must be followed by a software
2189
	LastMode = pAC->GIni.GP[Port].PPhyPowerState;
2170
				 * reset to take effect
2190
	pAC->GIni.GP[Port].PPhyPowerState = Mode;
2171
				 */
2191
2172
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2192
	SK_DBG_MSG(pAC, SK_DBGMOD_POWM, SK_DBGCAT_CTRL,
2173
				Word |= PHY_CT_RESET;
2193
		("SkGmEnterLowPowerMode: %u\n", Mode));
2174
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2194
2175
2195
	switch (Mode) {
2176
				/* switch IEEE compatible power down mode on */
2196
	/* COMA mode (deep sleep) */
2177
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2197
	case PHY_PM_DEEP_SLEEP:
2178
				Word |= PHY_CT_PDOWN;
2198
		/* clear PHY & MAC reset first */
2179
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2199
		SkGmClearRst(pAC, IoC, Port);
2180
			break;
2181
2200
2182
			/* energy detect and energy detect plus mode */
2201
		/* setup General Purpose Control Register */
2183
			case PHY_PM_ENERGY_DETECT:
2202
		GM_OUT16(IoC, Port, GM_GP_CTRL, GM_GPCR_FL_PASS |
2184
			case PHY_PM_ENERGY_DETECT_PLUS:
2203
			GM_GPCR_SPEED_100 | GM_GPCR_AU_ALL_DIS);
2185
				/*
2186
				 * - disable MAC 125 MHz clock
2187
				 */
2188
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2189
				Word |= PHY_M_PC_DIS_125CLK;
2190
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2191
				
2192
				/* activate energy detect mode 1 */
2193
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2194
2195
				/* energy detect mode */
2196
				if (Mode == PHY_PM_ENERGY_DETECT) {
2197
					Word |= PHY_M_PC_EN_DET;
2198
				}
2199
				/* energy detect plus mode */
2200
				else {
2201
					Word |= PHY_M_PC_EN_DET_PLUS;
2202
				}
2203
2204
2204
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2205
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2205
2206
2206
				/*
2207
		if (CHIP_ID_YUKON_2(pAC)) {
2207
				 * reinitialize the PHY to force a software reset
2208
			/* set power down bit */
2208
				 * which is necessary after the register settings
2209
			PowerDownBit = (Port == MAC_1) ? PCI_Y2_PHY1_POWD :
2209
				 * for the energy detect modes.
2210
				PCI_Y2_PHY2_POWD;
2210
				 * Furthermore reinitialisation prevents that the
2211
2211
				 * PHY is running out of a stable state.
2212
			/* no COMA mode on Yukon-FE and Yukon-2 PHY */
2212
				 */
2213
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE ||
2213
				SkGmInitPhyMarv(pAC, IoC, Port, SK_FALSE);
2214
				pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) {
2214
			break;
2215
				/* set IEEE compatible Power Down Mode */
2216
				Ret = SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, PHY_CT_PDOWN);
2215
2217
2216
			/* don't change current power mode */
2218
				Word = 0;	/* divide clock by 2 */
2217
			default:
2219
			}
2218
				pAC->GIni.GP[Port].PPhyPowerState = LastMode;
2220
			else {
2219
				Ret = 1;
2221
				Word = 1;	/* divide clock by 4 */
2220
			break;
2222
			}
2223
2224
			/* enable Core Clock Division */
2225
			SK_OUT32(IoC, B2_Y2_CLK_CTRL,
2226
				((pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) ?
2227
				 /* on Yukon-2 divide clock by 2, clock select value is 31 */
2228
				(Y2_CLK_DIV_VAL_2(0) | Y2_CLK_SEL_VAL_2(Y2_CLK_SELECT2_MSK)) :
2229
				Y2_CLK_DIV_VAL(Word)) | Y2_CLK_DIV_ENA);
2230
2231
			/* ASF system clock stopped */
2232
			SK_OUT8(IoC, B28_Y2_ASF_STAT_CMD, Y2_ASF_CLK_HALT);
2221
		}
2233
		}
2222
	}
2234
		else {
2223
	/* low power modes are not supported by this chip */
2235
			/* apply COMA mode workaround */
2224
	else {
2236
			(void)SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_ADDR, 0x001f);
2237
2238
			Ret = SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_DATA, 0xfff3);
2239
2240
			PowerDownBit = PCI_PHY_COMA;
2241
		}
2242
2243
		SK_IN32(IoC, PCI_C(pAC, PCI_OUR_REG_1), &DWord);
2244
2245
		/* set PHY to PowerDown/COMA Mode */
2246
		SK_OUT32(IoC, PCI_C(pAC, PCI_OUR_REG_1), DWord | PowerDownBit);
2247
2248
		/* check if this routine was called from a for loop */
2249
		if (pAC->GIni.GIMacsFound == 1 || Port == MAC_2) {
2250
2251
			SK_IN16(IoC, PCI_C(pAC, PCI_PM_CTL_STS), &Word);
2252
2253
			/* switch to D1 state */
2254
			SK_OUT16(IoC, PCI_C(pAC, PCI_PM_CTL_STS), Word | PCI_PM_STATE_D1);
2255
		}
2256
2257
		break;
2258
2259
	/* IEEE 22.2.4.1.5 compatible power down mode */
2260
	case PHY_PM_IEEE_POWER_DOWN:
2261
2262
		Ret = SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2263
2264
		Word |= PHY_M_PC_POL_R_DIS;
2265
2266
		if (!CHIP_ID_YUKON_2(pAC)) {
2267
			/* disable MAC 125 MHz clock */
2268
			Word |= PHY_M_PC_DIS_125CLK;
2269
			Word &= ~PHY_M_PC_MAC_POW_UP;
2270
		}
2271
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2272
2273
		/* these register changes must be followed by a software reset */
2274
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2275
		Word |= PHY_CT_RESET;
2276
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2277
2278
		/* switch IEEE compatible power down mode on */
2279
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2280
		Word |= PHY_CT_PDOWN;
2281
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2282
2283
		break;
2284
2285
	/* energy detect and energy detect plus mode */
2286
	case PHY_PM_ENERGY_DETECT:
2287
	case PHY_PM_ENERGY_DETECT_PLUS:
2288
2289
		Ret = SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2290
2291
		Word |= PHY_M_PC_POL_R_DIS;
2292
2293
		if (!CHIP_ID_YUKON_2(pAC)) {
2294
			/* disable MAC 125 MHz clock */
2295
			Word |= PHY_M_PC_DIS_125CLK;
2296
		}
2297
2298
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
2299
			/* enable Energy Detect (sense & pulse) */
2300
			Word |= PHY_M_PC_ENA_ENE_DT;
2301
		}
2302
		else {
2303
			/* clear energy detect mode bits */
2304
			Word &= ~PHY_M_PC_EN_DET_MSK;
2305
2306
			Word |= (Mode == PHY_PM_ENERGY_DETECT) ? PHY_M_PC_EN_DET :
2307
				PHY_M_PC_EN_DET_PLUS;
2308
		}
2309
2310
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2311
2312
		/* these register changes must be followed by a software reset */
2313
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2314
		Word |= PHY_CT_RESET;
2315
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2316
2317
		break;
2318
2319
	/* don't change current power mode */
2320
	default:
2321
		pAC->GIni.GP[Port].PPhyPowerState = LastMode;
2225
		Ret = 1;
2322
		Ret = 1;
2323
		break;
2226
	}
2324
	}
2227
2325
2228
	return(Ret);
2326
	return(Ret);
Lines 2233-2239 Link Here
2233
 *
2331
 *
2234
 *	SkGmLeaveLowPowerMode()
2332
 *	SkGmLeaveLowPowerMode()
2235
 *
2333
 *
2236
 * Description:	
2334
 * Description:
2237
 *	Leave the current low power mode and switch to normal mode
2335
 *	Leave the current low power mode and switch to normal mode
2238
 *
2336
 *
2239
 * Note:
2337
 * Note:
Lines 2243-2357 Link Here
2243
 *		1:	error
2341
 *		1:	error
2244
 */
2342
 */
2245
int SkGmLeaveLowPowerMode(
2343
int SkGmLeaveLowPowerMode(
2246
SK_AC	*pAC,		/* adapter context */
2344
SK_AC	*pAC,		/* Adapter Context */
2247
SK_IOC	IoC,		/* IO context */
2345
SK_IOC	IoC,		/* I/O Context */
2248
int		Port)		/* Port Index (e.g. MAC_1) */
2346
int		Port)		/* Port Index (e.g. MAC_1) */
2249
{
2347
{
2250
	SK_U32	DWord;
2348
	SK_U32	DWord;
2349
	SK_U32	PowerDownBit;
2251
	SK_U16	Word;
2350
	SK_U16	Word;
2252
	SK_U8	LastMode;
2351
	SK_U8	LastMode;
2253
	int		Ret = 0;
2352
	int		Ret = 0;
2254
2353
2255
	if (pAC->GIni.GIYukonLite &&
2354
	if (!(CHIP_ID_YUKON_2(pAC) || (pAC->GIni.GIYukonLite &&
2256
		pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
2355
		pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3))) {
2257
2356
2258
		/* save current power mode */
2357
		return(1);
2259
		LastMode = pAC->GIni.GP[Port].PPhyPowerState;
2358
	}
2260
		pAC->GIni.GP[Port].PPhyPowerState = PHY_PM_OPERATIONAL_MODE;
2261
2262
		switch (LastMode) {
2263
			/* coma mode (deep sleep) */
2264
			case PHY_PM_DEEP_SLEEP:
2265
				SK_IN32(IoC, PCI_C(PCI_OUR_REG_1), &DWord);
2266
2267
				SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2268
				
2269
				/* Release PHY from Coma Mode */
2270
				SK_OUT32(IoC, PCI_C(PCI_OUR_REG_1), DWord & ~PCI_PHY_COMA);
2271
				
2272
				SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2273
				
2274
				SK_IN32(IoC, B2_GP_IO, &DWord);
2275
2276
				/* set to output */
2277
				DWord |= (GP_DIR_9 | GP_IO_9);
2278
2279
				/* set PHY reset */
2280
				SK_OUT32(IoC, B2_GP_IO, DWord);
2281
2282
				DWord &= ~GP_IO_9; /* clear PHY reset (active high) */
2283
2284
				/* clear PHY reset */
2285
				SK_OUT32(IoC, B2_GP_IO, DWord);
2286
			break;
2287
			
2288
			/* IEEE 22.2.4.1.5 compatible power down mode */
2289
			case PHY_PM_IEEE_POWER_DOWN:
2290
				/*
2291
				 * - enable MAC 125 MHz clock
2292
				 * - set MAC power up
2293
				 */
2294
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2295
				Word &= ~PHY_M_PC_DIS_125CLK;
2296
				Word |=	PHY_M_PC_MAC_POW_UP;
2297
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2298
2359
2299
				/*
2360
	/* save current power mode */
2300
				 * register changes must be followed by a software
2361
	LastMode = pAC->GIni.GP[Port].PPhyPowerState;
2301
				 * reset to take effect
2362
	pAC->GIni.GP[Port].PPhyPowerState = PHY_PM_OPERATIONAL_MODE;
2302
				 */
2303
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2304
				Word |= PHY_CT_RESET;
2305
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2306
2307
				/* switch IEEE compatible power down mode off */
2308
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2309
				Word &= ~PHY_CT_PDOWN;
2310
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2311
			break;
2312
2363
2313
			/* energy detect and energy detect plus mode */
2364
	SK_DBG_MSG(pAC, SK_DBGMOD_POWM, SK_DBGCAT_CTRL,
2314
			case PHY_PM_ENERGY_DETECT:
2365
		("SkGmLeaveLowPowerMode: %u\n", LastMode));
2315
			case PHY_PM_ENERGY_DETECT_PLUS:
2316
				/*
2317
				 * - enable MAC 125 MHz clock
2318
				 */
2319
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2320
				Word &= ~PHY_M_PC_DIS_125CLK;
2321
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2322
				
2323
				/* disable energy detect mode */
2324
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2325
				Word &= ~PHY_M_PC_EN_DET_MSK;
2326
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2327
2366
2328
				/*
2367
	switch (LastMode) {
2329
				 * reinitialize the PHY to force a software reset
2368
	/* COMA mode (deep sleep) */
2330
				 * which is necessary after the register settings
2369
	case PHY_PM_DEEP_SLEEP:
2331
				 * for the energy detect modes.
2332
				 * Furthermore reinitialisation prevents that the
2333
				 * PHY is running out of a stable state.
2334
				 */
2335
				SkGmInitPhyMarv(pAC, IoC, Port, SK_FALSE);
2336
			break;
2337
2370
2338
			/* don't change current power mode */
2371
		SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &Word);
2339
			default:
2372
2340
				pAC->GIni.GP[Port].PPhyPowerState = LastMode;
2373
		/* reset all DState bits */
2341
				Ret = 1;
2374
		Word &= ~(PCI_PM_STATE_MSK);
2342
			break;
2375
2376
		/* switch to D0 state */
2377
		SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, Word);
2378
2379
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2380
2381
		if (CHIP_ID_YUKON_2(pAC)) {
2382
			/* disable Core Clock Division */
2383
			SK_OUT32(IoC, B2_Y2_CLK_CTRL, Y2_CLK_DIV_DIS);
2384
2385
			/* set power down bit */
2386
			PowerDownBit = (Port == MAC_1) ? PCI_Y2_PHY1_POWD :
2387
				PCI_Y2_PHY2_POWD;
2343
		}
2388
		}
2344
	}
2389
		else {
2345
	/* low power modes are not supported by this chip */
2390
			PowerDownBit = PCI_PHY_COMA;
2346
	else {
2391
		}
2392
2393
		SK_IN32(IoC, PCI_C(pAC, PCI_OUR_REG_1), &DWord);
2394
2395
		/* Release PHY from PowerDown/COMA Mode */
2396
		SK_OUT32(IoC, PCI_C(pAC, PCI_OUR_REG_1), DWord & ~PowerDownBit);
2397
2398
		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2399
2400
		if (CHIP_ID_YUKON_2(pAC)) {
2401
			/* no COMA mode on Yukon-FE */
2402
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
2403
				/* release IEEE compatible Power Down Mode */
2404
				Ret = SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, PHY_CT_ANE);
2405
			}
2406
		}
2407
		else {
2408
			SK_IN32(IoC, B2_GP_IO, &DWord);
2409
2410
			/* set to output */
2411
			DWord |= (GP_DIR_9 | GP_IO_9);
2412
2413
			/* set PHY reset */
2414
			SK_OUT32(IoC, B2_GP_IO, DWord);
2415
2416
			DWord &= ~GP_IO_9; /* clear PHY reset (active high) */
2417
2418
			/* clear PHY reset */
2419
			SK_OUT32(IoC, B2_GP_IO, DWord);
2420
		}
2421
2422
		break;
2423
2424
	/* IEEE 22.2.4.1.5 compatible power down mode */
2425
	case PHY_PM_IEEE_POWER_DOWN:
2426
2427
		if (pAC->GIni.GIChipId != CHIP_ID_YUKON_XL) {
2428
2429
			Ret = SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2430
			Word &= ~PHY_M_PC_DIS_125CLK;	/* enable MAC 125 MHz clock */
2431
			Word |= PHY_M_PC_MAC_POW_UP;	/* set MAC power up */
2432
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2433
2434
			/* these register changes must be followed by a software reset */
2435
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2436
			Word |= PHY_CT_RESET;
2437
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2438
		}
2439
2440
		/* switch IEEE compatible power down mode off */
2441
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2442
		Word &= ~PHY_CT_PDOWN;
2443
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2444
2445
		break;
2446
2447
	/* energy detect and energy detect plus mode */
2448
	case PHY_PM_ENERGY_DETECT:
2449
	case PHY_PM_ENERGY_DETECT_PLUS:
2450
2451
		if (pAC->GIni.GIChipId != CHIP_ID_YUKON_XL) {
2452
2453
			Ret = SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2454
2455
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
2456
				/* disable Energy Detect */
2457
				Word &= ~PHY_M_PC_ENA_ENE_DT;
2458
			}
2459
			else {
2460
				/* disable energy detect mode & enable MAC 125 MHz clock */
2461
				Word &= ~(PHY_M_PC_EN_DET_MSK | PHY_M_PC_DIS_125CLK);
2462
			}
2463
2464
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2465
2466
			/* these register changes must be followed by a software reset */
2467
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2468
			Word |= PHY_CT_RESET;
2469
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2470
		}
2471
		break;
2472
2473
	/* don't change current power mode */
2474
	default:
2475
		pAC->GIni.GP[Port].PPhyPowerState = LastMode;
2347
		Ret = 1;
2476
		Ret = 1;
2477
		break;
2348
	}
2478
	}
2349
2479
2350
	return(Ret);
2480
	return(Ret);
2351
2481
2352
}	/* SkGmLeaveLowPowerMode */
2482
}	/* SkGmLeaveLowPowerMode */
2353
#endif /* !SK_SLIM */
2483
#endif /* SK_PHY_LP_MODE */
2354
2355
2484
2356
/******************************************************************************
2485
/******************************************************************************
2357
 *
2486
 *
Lines 2365-2438 Link Here
2365
 *	nothing
2494
 *	nothing
2366
 */
2495
 */
2367
static void SkGmInitPhyMarv(
2496
static void SkGmInitPhyMarv(
2368
SK_AC	*pAC,		/* adapter context */
2497
SK_AC	*pAC,		/* Adapter Context */
2369
SK_IOC	IoC,		/* IO context */
2498
SK_IOC	IoC,		/* I/O Context */
2370
int		Port,		/* Port Index (MAC_1 + n) */
2499
int		Port,		/* Port Index (MAC_1 + n) */
2371
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
2500
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
2372
{
2501
{
2373
	SK_GEPORT	*pPrt;
2502
	SK_GEPORT	*pPrt;
2503
	SK_BOOL		AutoNeg;
2374
	SK_U16		PhyCtrl;
2504
	SK_U16		PhyCtrl;
2375
	SK_U16		C1000BaseT;
2505
	SK_U16		C1000BaseT;
2376
	SK_U16		AutoNegAdv;
2506
	SK_U16		AutoNegAdv;
2507
#ifndef VCPU
2508
	SK_U16		SWord;
2509
	SK_U16		PageReg;
2510
	SK_U16		LoopSpeed;
2377
	SK_U16		ExtPhyCtrl;
2511
	SK_U16		ExtPhyCtrl;
2378
	SK_U16		LedCtrl;
2512
	SK_U16		LedCtrl;
2379
	SK_BOOL		AutoNeg;
2513
	SK_U16		LedOver;
2380
#if defined(SK_DIAG) || defined(DEBUG)
2514
#if defined(SK_DIAG) || defined(DEBUG)
2381
	SK_U16		PhyStat;
2515
	SK_U16		PhyStat;
2382
	SK_U16		PhyStat1;
2516
	SK_U16		PhyStat1;
2383
	SK_U16		PhySpecStat;
2517
	SK_U16		PhySpecStat;
2384
#endif /* SK_DIAG || DEBUG */
2518
#endif /* SK_DIAG || DEBUG */
2519
#endif /* !VCPU */
2385
2520
2386
	pPrt = &pAC->GIni.GP[Port];
2521
	pPrt = &pAC->GIni.GP[Port];
2387
2522
2388
	/* Auto-negotiation ? */
2523
	/* Auto-negotiation ? */
2389
	if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
2524
	AutoNeg = pPrt->PLinkMode != SK_LMODE_HALF &&
2390
		AutoNeg = SK_FALSE;
2525
			  pPrt->PLinkMode != SK_LMODE_FULL;
2391
	}
2526
2392
	else {
2393
		AutoNeg = SK_TRUE;
2394
	}
2395
	
2396
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2527
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2397
		("InitPhyMarv: Port %d, auto-negotiation %s\n",
2528
		("InitPhyMarv: Port %d, Auto-neg. %s, LMode %d, LSpeed %d, FlowC %d\n",
2398
		 Port, AutoNeg ? "ON" : "OFF"));
2529
		 Port, AutoNeg ? "ON" : "OFF",
2530
		 pPrt->PLinkMode, pPrt->PLinkSpeed, pPrt->PFlowCtrlMode));
2399
2531
2400
#ifdef VCPU
2532
#ifndef VCPU
2401
	VCPUprintf(0, "SkGmInitPhyMarv(), Port=%u, DoLoop=%u\n",
2533
	if ((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS) != 0) {
2402
		Port, DoLoop);
2534
2403
#else /* VCPU */
2535
		if (DoLoop) {
2404
	if (DoLoop) {
2536
			/* special setup for PHY 88E1112 */
2405
		/* Set 'MAC Power up'-bit, set Manual MDI configuration */
2537
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) {
2406
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL,
2538
2407
			PHY_M_PC_MAC_POW_UP);
2539
				LoopSpeed = pPrt->PLinkSpeed;
2540
2541
				if (LoopSpeed == SK_LSPEED_AUTO) {
2542
					/* force 1000 Mbps */
2543
					LoopSpeed = SK_LSPEED_1000MBPS;
2544
				}
2545
				LoopSpeed += 2;
2546
2547
				/* save page register */
2548
				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_ADR, &PageReg);
2549
2550
				/* select page 2 to access MAC control register */
2551
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 2);
2552
2553
				/* set MAC interface speed */
2554
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, LoopSpeed << 4);
2555
2556
				/* restore page register */
2557
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, PageReg);
2558
2559
				/* disable link pulses */
2560
				SWord = PHY_M_PC_DIS_LINK_P;
2561
			}
2562
			else {
2563
				/* set 'MAC Power up'-bit, set Manual MDI configuration */
2564
				SWord = PHY_M_PC_MAC_POW_UP;
2565
			}
2566
2567
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, SWord);
2568
		}
2569
		else if (AutoNeg && pPrt->PLinkSpeed == SK_LSPEED_AUTO &&
2570
				 pAC->GIni.GIChipId != CHIP_ID_YUKON_XL) {
2571
			/* Read Ext. PHY Specific Control */
2572
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_CTRL, &ExtPhyCtrl);
2573
2574
			ExtPhyCtrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK |
2575
				PHY_M_EC_MAC_S_MSK);
2576
2577
			ExtPhyCtrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ);
2578
2579
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_EC) {
2580
				/* on PHY 88E1111 there is a change for downshift control */
2581
				ExtPhyCtrl |= PHY_M_EC_DSC_2(0) | PHY_M_EC_DOWN_S_ENA;
2582
			}
2583
			else {
2584
				ExtPhyCtrl |= PHY_M_EC_M_DSC(0) | PHY_M_EC_S_DSC(1);
2585
			}
2586
2587
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_CTRL, ExtPhyCtrl);
2588
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2589
				("Set Ext. PHY Ctrl=0x%04X\n", ExtPhyCtrl));
2590
		}
2408
	}
2591
	}
2409
	else if (AutoNeg && pPrt->PLinkSpeed == SK_LSPEED_AUTO) {
2592
2410
		/* Read Ext. PHY Specific Control */
2593
	if (CHIP_ID_YUKON_2(pAC)) {
2411
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_CTRL, &ExtPhyCtrl);
2594
		/* Read PHY Specific Control */
2412
		
2595
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &PhyCtrl);
2413
		ExtPhyCtrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK |
2596
2414
			PHY_M_EC_MAC_S_MSK);
2597
		if (!DoLoop && pAC->GIni.GICopperType) {
2415
		
2598
2416
		ExtPhyCtrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ) |
2599
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
2417
			PHY_M_EC_M_DSC(0) | PHY_M_EC_S_DSC(1);
2600
				/* enable Automatic Crossover (!!! Bits 5..4) */
2418
	
2601
				PhyCtrl |= (SK_U16)(PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO) >> 1);
2419
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_CTRL, ExtPhyCtrl);
2602
			}
2420
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2603
			else {
2421
			("Set Ext. PHY Ctrl=0x%04X\n", ExtPhyCtrl));
2604
				/* disable Energy Detect Mode */
2605
				PhyCtrl &= ~PHY_M_PC_EN_DET_MSK;
2606
2607
				/* enable Automatic Crossover */
2608
				PhyCtrl |= (SK_U16)PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO);
2609
2610
				if (AutoNeg && pPrt->PLinkSpeed == SK_LSPEED_AUTO &&
2611
					pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) {
2612
					/* on PHY 88E1112 there is a change for downshift control */
2613
					PhyCtrl &= ~PHY_M_PC_DSC_MSK;
2614
					PhyCtrl |= PHY_M_PC_DSC(0) | PHY_M_PC_DOWN_S_ENA;
2615
				}
2616
			}
2617
		}
2618
		/* workaround for deviation #4.88 (CRC errors) */
2619
		else {
2620
			/* disable Automatic Crossover */
2621
			PhyCtrl &= ~PHY_M_PC_MDIX_MSK;
2622
		}
2623
2624
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, PhyCtrl);
2625
	}
2626
2627
	/* special setup for PHY 88E1112 Fiber */
2628
	if (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL && !pAC->GIni.GICopperType) {
2629
		/* Fiber: select 1000BASE-X only mode MAC Specific Ctrl Reg. */
2630
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 2);
2631
2632
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &SWord);
2633
2634
		SWord &= ~PHY_M_MAC_MD_MSK;
2635
		SWord |= PHY_M_MAC_MODE_SEL(PHY_M_MAC_MD_1000BX);
2636
2637
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, SWord);
2638
2639
		/* select page 1 to access Fiber register */
2640
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 1);
2422
	}
2641
	}
2423
2642
2424
	/* Read PHY Control */
2643
	/* Read PHY Control */
2425
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &PhyCtrl);
2644
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &PhyCtrl);
2426
2645
2427
	if (!AutoNeg) {
2646
	if (!AutoNeg) {
2428
		/* Disable Auto-negotiation */
2647
		/* disable Auto-negotiation */
2429
		PhyCtrl &= ~PHY_CT_ANE;
2648
		PhyCtrl &= ~PHY_CT_ANE;
2430
	}
2649
	}
2431
2650
2432
	PhyCtrl |= PHY_CT_RESET;
2651
	PhyCtrl |= PHY_CT_RESET;
2433
	/* Assert software reset */
2652
	/* assert software reset */
2434
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, PhyCtrl);
2653
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, PhyCtrl);
2435
#endif /* VCPU */
2654
#endif /* !VCPU */
2436
2655
2437
	PhyCtrl = 0 /* PHY_CT_COL_TST */;
2656
	PhyCtrl = 0 /* PHY_CT_COL_TST */;
2438
	C1000BaseT = 0;
2657
	C1000BaseT = 0;
Lines 2442-2471 Link Here
2442
	if (pPrt->PMSMode != SK_MS_MODE_AUTO) {
2661
	if (pPrt->PMSMode != SK_MS_MODE_AUTO) {
2443
		/* enable Manual Master/Slave */
2662
		/* enable Manual Master/Slave */
2444
		C1000BaseT |= PHY_M_1000C_MSE;
2663
		C1000BaseT |= PHY_M_1000C_MSE;
2445
		
2664
2446
		if (pPrt->PMSMode == SK_MS_MODE_MASTER) {
2665
		if (pPrt->PMSMode == SK_MS_MODE_MASTER) {
2447
			C1000BaseT |= PHY_M_1000C_MSC;	/* set it to Master */
2666
			C1000BaseT |= PHY_M_1000C_MSC;	/* set it to Master */
2448
		}
2667
		}
2449
	}
2668
	}
2450
	
2669
2451
	/* Auto-negotiation ? */
2670
	/* Auto-negotiation ? */
2452
	if (!AutoNeg) {
2671
	if (!AutoNeg) {
2453
		
2672
2454
		if (pPrt->PLinkMode == SK_LMODE_FULL) {
2673
		if (pPrt->PLinkMode == SK_LMODE_FULL) {
2455
			/* Set Full Duplex Mode */
2674
			/* set Full Duplex Mode */
2456
			PhyCtrl |= PHY_CT_DUP_MD;
2675
			PhyCtrl |= PHY_CT_DUP_MD;
2457
		}
2676
		}
2458
2677
2459
		/* Set Master/Slave manually if not already done */
2678
		/* set Master/Slave manually if not already done */
2460
		if (pPrt->PMSMode == SK_MS_MODE_AUTO) {
2679
		if (pPrt->PMSMode == SK_MS_MODE_AUTO) {
2461
			C1000BaseT |= PHY_M_1000C_MSE;	/* set it to Slave */
2680
			C1000BaseT |= PHY_M_1000C_MSE;	/* set it to Slave */
2462
		}
2681
		}
2463
2682
2464
		/* Set Speed */
2683
		/* set Speed */
2465
		switch (pPrt->PLinkSpeed) {
2684
		switch (pPrt->PLinkSpeed) {
2466
		case SK_LSPEED_AUTO:
2685
		case SK_LSPEED_AUTO:
2467
		case SK_LSPEED_1000MBPS:
2686
		case SK_LSPEED_1000MBPS:
2468
			PhyCtrl |= PHY_CT_SP1000;
2687
			PhyCtrl |= (((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS) != 0) ?
2688
						PHY_CT_SP1000 : PHY_CT_SP100);
2469
			break;
2689
			break;
2470
		case SK_LSPEED_100MBPS:
2690
		case SK_LSPEED_100MBPS:
2471
			PhyCtrl |= PHY_CT_SP100;
2691
			PhyCtrl |= PHY_CT_SP100;
Lines 2477-2514 Link Here
2477
				SKERR_HWI_E019MSG);
2697
				SKERR_HWI_E019MSG);
2478
		}
2698
		}
2479
2699
2700
		if ((pPrt->PFlowCtrlMode == SK_FLOW_STAT_NONE) ||
2701
			/* disable Pause also for 10/100 Mbps in half duplex mode */
2702
			((pPrt->PLinkMode == SK_LMODE_HALF) &&
2703
			 ((pPrt->PLinkSpeed == SK_LSPEED_STAT_100MBPS) ||
2704
			  (pPrt->PLinkSpeed == SK_LSPEED_STAT_10MBPS)))) {
2705
2706
			/* set Pause Off */
2707
			SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_PAUSE_OFF);
2708
		}
2709
		else {
2710
			/* set Pause On */
2711
			SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_PAUSE_ON);
2712
		}
2713
2480
		if (!DoLoop) {
2714
		if (!DoLoop) {
2715
			/* assert software reset */
2481
			PhyCtrl |= PHY_CT_RESET;
2716
			PhyCtrl |= PHY_CT_RESET;
2482
		}
2717
		}
2483
	}
2718
	}
2484
	else {
2719
	else {
2485
		/* Set Auto-negotiation advertisement */
2720
		/* set Auto-negotiation advertisement */
2486
		
2721
2487
		if (pAC->GIni.GICopperType) {
2722
		if (pAC->GIni.GICopperType) {
2488
			/* Set Speed capabilities */
2723
			/* set Speed capabilities */
2489
			switch (pPrt->PLinkSpeed) {
2724
			switch (pPrt->PLinkSpeed) {
2490
			case SK_LSPEED_AUTO:
2725
			case SK_LSPEED_AUTO:
2491
				C1000BaseT |= PHY_M_1000C_AHD | PHY_M_1000C_AFD;
2726
				if ((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS) != 0) {
2727
					C1000BaseT |= PHY_M_1000C_AFD;
2728
#ifdef xSK_DIAG
2729
					C1000BaseT |= PHY_M_1000C_AHD;
2730
#endif /* SK_DIAG */
2731
				}
2492
				AutoNegAdv |= PHY_M_AN_100_FD | PHY_M_AN_100_HD |
2732
				AutoNegAdv |= PHY_M_AN_100_FD | PHY_M_AN_100_HD |
2493
					PHY_M_AN_10_FD | PHY_M_AN_10_HD;
2733
					PHY_M_AN_10_FD | PHY_M_AN_10_HD;
2494
				break;
2734
				break;
2495
			case SK_LSPEED_1000MBPS:
2735
			case SK_LSPEED_1000MBPS:
2496
				C1000BaseT |= PHY_M_1000C_AHD | PHY_M_1000C_AFD;
2736
				if ((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS) != 0) {
2737
					C1000BaseT |= PHY_M_1000C_AFD;
2738
#ifdef xSK_DIAG
2739
					C1000BaseT |= PHY_M_1000C_AHD;
2740
#endif /* SK_DIAG */
2741
				}
2497
				break;
2742
				break;
2498
			case SK_LSPEED_100MBPS:
2743
			case SK_LSPEED_100MBPS:
2499
				AutoNegAdv |= PHY_M_AN_100_FD | PHY_M_AN_100_HD |
2744
				if ((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_100MBPS) != 0) {
2500
					/* advertise 10Base-T also */
2745
					AutoNegAdv |= PHY_M_AN_100_FD | PHY_M_AN_100_HD |
2501
					PHY_M_AN_10_FD | PHY_M_AN_10_HD;
2746
						/* advertise 10Base-T also */
2747
						PHY_M_AN_10_FD | PHY_M_AN_10_HD;
2748
				}
2502
				break;
2749
				break;
2503
			case SK_LSPEED_10MBPS:
2750
			case SK_LSPEED_10MBPS:
2504
				AutoNegAdv |= PHY_M_AN_10_FD | PHY_M_AN_10_HD;
2751
				if ((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_10MBPS) != 0) {
2752
					AutoNegAdv |= PHY_M_AN_10_FD | PHY_M_AN_10_HD;
2753
				}
2505
				break;
2754
				break;
2506
			default:
2755
			default:
2507
				SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_HWI_E019,
2756
				SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_HWI_E019,
2508
					SKERR_HWI_E019MSG);
2757
					SKERR_HWI_E019MSG);
2509
			}
2758
			}
2510
2759
2511
			/* Set Full/half duplex capabilities */
2760
			/* set Full/half duplex capabilities */
2512
			switch (pPrt->PLinkMode) {
2761
			switch (pPrt->PLinkMode) {
2513
			case SK_LMODE_AUTOHALF:
2762
			case SK_LMODE_AUTOHALF:
2514
				C1000BaseT &= ~PHY_M_1000C_AFD;
2763
				C1000BaseT &= ~PHY_M_1000C_AFD;
Lines 2524-2531 Link Here
2524
				SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_HWI_E015,
2773
				SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_HWI_E015,
2525
					SKERR_HWI_E015MSG);
2774
					SKERR_HWI_E015MSG);
2526
			}
2775
			}
2527
			
2776
2528
			/* Set Flow-control capabilities */
2777
			/* set Flow-control capabilities */
2529
			switch (pPrt->PFlowCtrlMode) {
2778
			switch (pPrt->PFlowCtrlMode) {
2530
			case SK_FLOW_MODE_NONE:
2779
			case SK_FLOW_MODE_NONE:
2531
				AutoNegAdv |= PHY_B_P_NO_PAUSE;
2780
				AutoNegAdv |= PHY_B_P_NO_PAUSE;
Lines 2545-2552 Link Here
2545
			}
2794
			}
2546
		}
2795
		}
2547
		else {	/* special defines for FIBER (88E1011S only) */
2796
		else {	/* special defines for FIBER (88E1011S only) */
2548
			
2797
2549
			/* Set Full/half duplex capabilities */
2798
			/* set Full/half duplex capabilities */
2550
			switch (pPrt->PLinkMode) {
2799
			switch (pPrt->PLinkMode) {
2551
			case SK_LMODE_AUTOHALF:
2800
			case SK_LMODE_AUTOHALF:
2552
				AutoNegAdv |= PHY_M_AN_1000X_AHD;
2801
				AutoNegAdv |= PHY_M_AN_1000X_AHD;
Lines 2561-2568 Link Here
2561
				SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_HWI_E015,
2810
				SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_HWI_E015,
2562
					SKERR_HWI_E015MSG);
2811
					SKERR_HWI_E015MSG);
2563
			}
2812
			}
2564
			
2813
2565
			/* Set Flow-control capabilities */
2814
			/* set Flow-control capabilities */
2566
			switch (pPrt->PFlowCtrlMode) {
2815
			switch (pPrt->PFlowCtrlMode) {
2567
			case SK_FLOW_MODE_NONE:
2816
			case SK_FLOW_MODE_NONE:
2568
				AutoNegAdv |= PHY_M_P_NO_PAUSE_X;
2817
				AutoNegAdv |= PHY_M_P_NO_PAUSE_X;
Lines 2587-2638 Link Here
2587
			PhyCtrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
2836
			PhyCtrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
2588
		}
2837
		}
2589
	}
2838
	}
2590
	
2839
2591
#ifdef VCPU
2840
#ifdef VCPU
2592
	/*
2841
	/*
2593
	 * E-mail from Gu Lin (08-03-2002):
2842
	 * E-mail from Gu Lin (08-03-2002):
2594
	 */
2843
	 */
2595
	
2844
2596
	/* Program PHY register 30 as 16'h0708 for simulation speed up */
2845
	/* Program PHY register 30 as 16'h0708 for simulation speed up */
2597
	SkGmPhyWrite(pAC, IoC, Port, 30, 0x0700 /* 0x0708 */);
2846
	SkGmPhyWrite(pAC, IoC, Port, 30, 0x0700 /* 0x0708 */);
2598
	
2847
2599
	VCpuWait(2000);
2848
	VCpuWait(2000);
2600
2849
2601
#else /* VCPU */
2850
#else /* VCPU */
2602
	
2851
2603
	/* Write 1000Base-T Control Register */
2852
	if (pAC->GIni.GIChipId != CHIP_ID_YUKON_FE) {
2604
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_1000T_CTRL, C1000BaseT);
2853
		/* Write 1000Base-T Control Register */
2605
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2854
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_1000T_CTRL, C1000BaseT);
2606
		("Set 1000B-T Ctrl =0x%04X\n", C1000BaseT));
2855
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2607
	
2856
			("Set 1000B-T Ctrl =0x%04X\n", C1000BaseT));
2857
	}
2858
2608
	/* Write AutoNeg Advertisement Register */
2859
	/* Write AutoNeg Advertisement Register */
2609
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_AUNE_ADV, AutoNegAdv);
2860
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_AUNE_ADV, AutoNegAdv);
2610
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2861
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2611
		("Set Auto-Neg.Adv.=0x%04X\n", AutoNegAdv));
2862
		("Set Auto-Neg.Adv.=0x%04X\n", AutoNegAdv));
2612
#endif /* VCPU */
2863
#endif /* VCPU */
2613
	
2864
2614
	if (DoLoop) {
2865
	if (DoLoop) {
2615
		/* Set the PHY Loopback bit */
2866
		/* set the PHY Loopback bit */
2616
		PhyCtrl |= PHY_CT_LOOP;
2867
		PhyCtrl |= PHY_CT_LOOP;
2617
2868
2618
#ifdef XXX
2869
#ifdef XXX
2619
		/* Program PHY register 16 as 16'h0400 to force link good */
2870
		/* Program PHY register 16 as 16'h0400 to force link good */
2620
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, PHY_M_PC_FL_GOOD);
2871
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, PHY_M_PC_FL_GOOD);
2621
#endif /* XXX */
2622
2872
2623
#ifndef VCPU
2624
		if (pPrt->PLinkSpeed != SK_LSPEED_AUTO) {
2873
		if (pPrt->PLinkSpeed != SK_LSPEED_AUTO) {
2625
			/* Write Ext. PHY Specific Control */
2874
			/* Write Ext. PHY Specific Control */
2626
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_CTRL,
2875
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_CTRL,
2627
				(SK_U16)((pPrt->PLinkSpeed + 2) << 4));
2876
				(SK_U16)((pPrt->PLinkSpeed + 2) << 4));
2628
		}
2877
		}
2629
#endif /* VCPU */
2878
#endif /* XXX */
2630
	}
2879
	}
2631
#ifdef TEST_ONLY
2880
#ifdef TEST_ONLY
2632
	else if (pPrt->PLinkSpeed == SK_LSPEED_10MBPS) {
2881
	else if (pPrt->PLinkSpeed == SK_LSPEED_10MBPS) {
2633
			/* Write PHY Specific Control */
2882
		/* Write PHY Specific Control */
2634
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL,
2883
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, PHY_M_PC_EN_DET_MSK);
2635
				PHY_M_PC_EN_DET_MSK);
2636
	}
2884
	}
2637
#endif
2885
#endif
2638
2886
Lines 2645-2671 Link Here
2645
	VCpuWait(2000);
2893
	VCpuWait(2000);
2646
#else
2894
#else
2647
2895
2648
	LedCtrl = PHY_M_LED_PULS_DUR(PULS_170MS) | PHY_M_LED_BLINK_RT(BLINK_84MS);
2896
	LedCtrl = PHY_M_LED_PULS_DUR(PULS_170MS);
2897
2898
	LedOver = 0;
2899
2900
	if ((pAC->GIni.GILedBlinkCtrl & SK_ACT_LED_BLINK) != 0)  {
2901
2902
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
2903
			/* on 88E3082 these bits are at 11..9 (shifted left) */
2904
			LedCtrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) << 1;
2905
2906
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_FE_LED_PAR, &SWord);
2907
2908
			/* delete ACT LED control bits */
2909
			SWord &= ~PHY_M_FELP_LED1_MSK;
2910
			/* change ACT LED control to blink mode */
2911
			SWord |= PHY_M_FELP_LED1_CTRL(LED_PAR_CTRL_ACT_BL);
2912
2913
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_FE_LED_PAR, SWord);
2914
		}
2915
		else if (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) {
2916
			/* save page register */
2917
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_ADR, &PageReg);
2918
2919
			/* select page 3 to access LED control register */
2920
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 3);
2921
2922
			/* set LED Function Control register */
2923
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, (SK_U16)
2924
				(PHY_M_LEDC_LOS_CTRL(1) |		/* LINK/ACT */
2925
				 PHY_M_LEDC_INIT_CTRL(7) |		/* 10 Mbps */
2926
				 PHY_M_LEDC_STA1_CTRL(7) |		/* 100 Mbps */
2927
				 PHY_M_LEDC_STA0_CTRL(7)));		/* 1000 Mbps */
2928
2929
			/* set Polarity Control register */
2930
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_STAT, (SK_U16)
2931
				(PHY_M_POLC_LS1_P_MIX(4) | PHY_M_POLC_IS0_P_MIX(4) |
2932
				 PHY_M_POLC_LOS_CTRL(2) | PHY_M_POLC_INIT_CTRL(2) |
2933
				 PHY_M_POLC_STA1_CTRL(2) | PHY_M_POLC_STA0_CTRL(2)));
2649
2934
2650
	if ((pAC->GIni.GILedBlinkCtrl & SK_ACT_LED_BLINK) != 0) {
2935
			/* restore page register */
2651
		LedCtrl |= PHY_M_LEDC_RX_CTRL | PHY_M_LEDC_TX_CTRL;
2936
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, PageReg);
2937
		}
2938
		else {
2939
			/* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
2940
			LedCtrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL;
2941
2942
			/* on PHY 88E1111 there is a change for LED control */
2943
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_EC &&
2944
				(pAC->GIni.GILedBlinkCtrl & SK_DUAL_LED_ACT_LNK) != 0)  {
2945
				/* Yukon-EC needs setting of 2 bits: 0,6=11) */
2946
				LedCtrl |= PHY_M_LEDC_TX_C_LSB;
2947
			}
2948
			/* turn off the Rx LED (LED_RX) */
2949
			LedOver |= PHY_M_LED_MO_RX(MO_LED_OFF);
2950
		}
2652
	}
2951
	}
2653
2952
2654
	if ((pAC->GIni.GILedBlinkCtrl & SK_DUP_LED_NORMAL) != 0) {
2953
	if ((pAC->GIni.GILedBlinkCtrl & SK_DUP_LED_NORMAL) != 0) {
2954
		/* disable blink mode (LED_DUPLEX) on collisions */
2655
		LedCtrl |= PHY_M_LEDC_DP_CTRL;
2955
		LedCtrl |= PHY_M_LEDC_DP_CTRL;
2656
	}
2956
	}
2657
	
2957
2658
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_LED_CTRL, LedCtrl);
2958
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_LED_CTRL, LedCtrl);
2659
2959
2660
	if ((pAC->GIni.GILedBlinkCtrl & SK_LED_LINK100_ON) != 0) {
2960
	if ((pAC->GIni.GILedBlinkCtrl & SK_LED_LINK100_ON) != 0) {
2661
		/* only in forced 100 Mbps mode */
2961
		/* only in forced 100 Mbps mode */
2662
		if (!AutoNeg && pPrt->PLinkSpeed == SK_LSPEED_100MBPS) {
2962
		if (!AutoNeg && pPrt->PLinkSpeed == SK_LSPEED_100MBPS) {
2663
2963
			/* turn on 100 Mbps LED (LED_LINK100) */
2664
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_LED_OVER,
2964
			LedOver |= PHY_M_LED_MO_100(MO_LED_ON);
2665
				PHY_M_LED_MO_100(MO_LED_ON));
2666
		}
2965
		}
2667
	}
2966
	}
2668
2967
2968
	if (LedOver != 0) {
2969
		/* set Manual LED Override */
2970
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_LED_OVER, LedOver);
2971
	}
2972
2669
#ifdef SK_DIAG
2973
#ifdef SK_DIAG
2670
	c_print("Set PHY Ctrl=0x%04X\n", PhyCtrl);
2974
	c_print("Set PHY Ctrl=0x%04X\n", PhyCtrl);
2671
	c_print("Set 1000 B-T=0x%04X\n", C1000BaseT);
2975
	c_print("Set 1000 B-T=0x%04X\n", C1000BaseT);
Lines 2678-2707 Link Here
2678
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &PhyCtrl);
2982
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &PhyCtrl);
2679
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2983
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2680
		("PHY Ctrl Reg.=0x%04X\n", PhyCtrl));
2984
		("PHY Ctrl Reg.=0x%04X\n", PhyCtrl));
2681
	
2985
2682
	/* Read 1000Base-T Control Register */
2683
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_1000T_CTRL, &C1000BaseT);
2684
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2685
		("1000B-T Ctrl =0x%04X\n", C1000BaseT));
2686
	
2687
	/* Read AutoNeg Advertisement Register */
2986
	/* Read AutoNeg Advertisement Register */
2688
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_ADV, &AutoNegAdv);
2987
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_ADV, &AutoNegAdv);
2689
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2988
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2690
		("Auto-Neg.Adv.=0x%04X\n", AutoNegAdv));
2989
		("Auto-Neg.Adv.=0x%04X\n", AutoNegAdv));
2691
	
2990
2692
	/* Read Ext. PHY Specific Control */
2991
	if (pAC->GIni.GIChipId != CHIP_ID_YUKON_FE) {
2693
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_CTRL, &ExtPhyCtrl);
2992
		/* Read 1000Base-T Control Register */
2694
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2993
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_1000T_CTRL, &C1000BaseT);
2695
		("Ext. PHY Ctrl=0x%04X\n", ExtPhyCtrl));
2994
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2696
	
2995
			("1000B-T Ctrl =0x%04X\n", C1000BaseT));
2996
2997
		/* Read Ext. PHY Specific Control */
2998
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_CTRL, &ExtPhyCtrl);
2999
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3000
			("Ext. PHY Ctrl=0x%04X\n", ExtPhyCtrl));
3001
	}
3002
2697
	/* Read PHY Status */
3003
	/* Read PHY Status */
2698
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_STAT, &PhyStat);
3004
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_STAT, &PhyStat);
2699
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3005
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2700
		("PHY Stat Reg.=0x%04X\n", PhyStat));
3006
		("PHY Stat Reg.=0x%04X\n", PhyStat));
3007
2701
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_STAT, &PhyStat1);
3008
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_STAT, &PhyStat1);
2702
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3009
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2703
		("PHY Stat Reg.=0x%04X\n", PhyStat1));
3010
		("PHY Stat Reg.=0x%04X\n", PhyStat1));
2704
	
3011
2705
	/* Read PHY Specific Status */
3012
	/* Read PHY Specific Status */
2706
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_STAT, &PhySpecStat);
3013
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_STAT, &PhySpecStat);
2707
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3014
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
Lines 2718-2723 Link Here
2718
	c_print("PHY Spec Reg=0x%04X\n", PhySpecStat);
3025
	c_print("PHY Spec Reg=0x%04X\n", PhySpecStat);
2719
#endif /* SK_DIAG */
3026
#endif /* SK_DIAG */
2720
3027
3028
	/* enable all PHY interrupts */
3029
	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_INT_MASK, (SK_U16)PHY_M_DEF_MSK);
2721
#endif /* VCPU */
3030
#endif /* VCPU */
2722
3031
2723
}	/* SkGmInitPhyMarv */
3032
}	/* SkGmInitPhyMarv */
Lines 2737-2744 Link Here
2737
 *	nothing
3046
 *	nothing
2738
 */
3047
 */
2739
static void SkXmInitPhyLone(
3048
static void SkXmInitPhyLone(
2740
SK_AC	*pAC,		/* adapter context */
3049
SK_AC	*pAC,		/* Adapter Context */
2741
SK_IOC	IoC,		/* IO context */
3050
SK_IOC	IoC,		/* I/O Context */
2742
int		Port,		/* Port Index (MAC_1 + n) */
3051
int		Port,		/* Port Index (MAC_1 + n) */
2743
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
3052
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
2744
{
3053
{
Lines 2756-2762 Link Here
2756
	/* manually Master/Slave ? */
3065
	/* manually Master/Slave ? */
2757
	if (pPrt->PMSMode != SK_MS_MODE_AUTO) {
3066
	if (pPrt->PMSMode != SK_MS_MODE_AUTO) {
2758
		Ctrl2 |= PHY_L_1000C_MSE;
3067
		Ctrl2 |= PHY_L_1000C_MSE;
2759
		
3068
2760
		if (pPrt->PMSMode == SK_MS_MODE_MASTER) {
3069
		if (pPrt->PMSMode == SK_MS_MODE_MASTER) {
2761
			Ctrl2 |= PHY_L_1000C_MSC;
3070
			Ctrl2 |= PHY_L_1000C_MSC;
2762
		}
3071
		}
Lines 2769-2775 Link Here
2769
		 */
3078
		 */
2770
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3079
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2771
			("InitPhyLone: no auto-negotiation Port %d\n", Port));
3080
			("InitPhyLone: no auto-negotiation Port %d\n", Port));
2772
		/* Set DuplexMode in Config register */
3081
		/* set DuplexMode in Config register */
2773
		if (pPrt->PLinkMode == SK_LMODE_FULL) {
3082
		if (pPrt->PLinkMode == SK_LMODE_FULL) {
2774
			Ctrl1 |= PHY_CT_DUP_MD;
3083
			Ctrl1 |= PHY_CT_DUP_MD;
2775
		}
3084
		}
Lines 2778-2784 Link Here
2778
		if (pPrt->PMSMode == SK_MS_MODE_AUTO) {
3087
		if (pPrt->PMSMode == SK_MS_MODE_AUTO) {
2779
			Ctrl2 |= PHY_L_1000C_MSE;	/* set it to Slave */
3088
			Ctrl2 |= PHY_L_1000C_MSE;	/* set it to Slave */
2780
		}
3089
		}
2781
2782
		/*
3090
		/*
2783
		 * Do NOT enable Auto-negotiation here. This would hold
3091
		 * Do NOT enable Auto-negotiation here. This would hold
2784
		 * the link down because no IDLES are transmitted
3092
		 * the link down because no IDLES are transmitted
Lines 2787-2795 Link Here
2787
	else {
3095
	else {
2788
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3096
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2789
			("InitPhyLone: with auto-negotiation Port %d\n", Port));
3097
			("InitPhyLone: with auto-negotiation Port %d\n", Port));
2790
		/* Set Auto-negotiation advertisement */
3098
		/* set Auto-negotiation advertisement */
2791
3099
2792
		/* Set Full/half duplex capabilities */
3100
		/* set Full/half duplex capabilities */
2793
		switch (pPrt->PLinkMode) {
3101
		switch (pPrt->PLinkMode) {
2794
		case SK_LMODE_AUTOHALF:
3102
		case SK_LMODE_AUTOHALF:
2795
			Ctrl2 |= PHY_L_1000C_AHD;
3103
			Ctrl2 |= PHY_L_1000C_AHD;
Lines 2805-2811 Link Here
2805
				SKERR_HWI_E015MSG);
3113
				SKERR_HWI_E015MSG);
2806
		}
3114
		}
2807
3115
2808
		/* Set Flow-control capabilities */
3116
		/* set Flow-control capabilities */
2809
		switch (pPrt->PFlowCtrlMode) {
3117
		switch (pPrt->PFlowCtrlMode) {
2810
		case SK_FLOW_MODE_NONE:
3118
		case SK_FLOW_MODE_NONE:
2811
			Ctrl3 |= PHY_L_P_NO_PAUSE;
3119
			Ctrl3 |= PHY_L_P_NO_PAUSE;
Lines 2827-2845 Link Here
2827
		/* Restart Auto-negotiation */
3135
		/* Restart Auto-negotiation */
2828
		Ctrl1 = PHY_CT_ANE | PHY_CT_RE_CFG;
3136
		Ctrl1 = PHY_CT_ANE | PHY_CT_RE_CFG;
2829
	}
3137
	}
2830
	
3138
2831
	/* Write 1000Base-T Control Register */
3139
	/* Write 1000Base-T Control Register */
2832
	SkXmPhyWrite(pAC, IoC, Port, PHY_LONE_1000T_CTRL, Ctrl2);
3140
	SkXmPhyWrite(pAC, IoC, Port, PHY_LONE_1000T_CTRL, Ctrl2);
2833
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3141
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2834
		("1000B-T Ctrl Reg=0x%04X\n", Ctrl2));
3142
		("1000B-T Ctrl Reg=0x%04X\n", Ctrl2));
2835
	
3143
2836
	/* Write AutoNeg Advertisement Register */
3144
	/* Write AutoNeg Advertisement Register */
2837
	SkXmPhyWrite(pAC, IoC, Port, PHY_LONE_AUNE_ADV, Ctrl3);
3145
	SkXmPhyWrite(pAC, IoC, Port, PHY_LONE_AUNE_ADV, Ctrl3);
2838
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3146
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2839
		("Auto-Neg.Adv.Reg=0x%04X\n", Ctrl3));
3147
		("Auto-Neg.Adv.Reg=0x%04X\n", Ctrl3));
2840
3148
2841
	if (DoLoop) {
3149
	if (DoLoop) {
2842
		/* Set the Phy Loopback bit, too */
3150
		/* set the Phy Loopback bit, too */
2843
		Ctrl1 |= PHY_CT_LOOP;
3151
		Ctrl1 |= PHY_CT_LOOP;
2844
	}
3152
	}
2845
3153
Lines 2862-2869 Link Here
2862
 *	nothing
3170
 *	nothing
2863
 */
3171
 */
2864
static void SkXmInitPhyNat(
3172
static void SkXmInitPhyNat(
2865
SK_AC	*pAC,		/* adapter context */
3173
SK_AC	*pAC,		/* Adapter Context */
2866
SK_IOC	IoC,		/* IO context */
3174
SK_IOC	IoC,		/* I/O Context */
2867
int		Port,		/* Port Index (MAC_1 + n) */
3175
int		Port,		/* Port Index (MAC_1 + n) */
2868
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
3176
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
2869
{
3177
{
Lines 2884-2891 Link Here
2884
 *	nothing
3192
 *	nothing
2885
 */
3193
 */
2886
void SkMacInitPhy(
3194
void SkMacInitPhy(
2887
SK_AC	*pAC,		/* adapter context */
3195
SK_AC	*pAC,		/* Adapter Context */
2888
SK_IOC	IoC,		/* IO context */
3196
SK_IOC	IoC,		/* I/O Context */
2889
int		Port,		/* Port Index (MAC_1 + n) */
3197
int		Port,		/* Port Index (MAC_1 + n) */
2890
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
3198
SK_BOOL	DoLoop)		/* Should a Phy LoopBack be set-up? */
2891
{
3199
{
Lines 2895-2901 Link Here
2895
3203
2896
#ifdef GENESIS
3204
#ifdef GENESIS
2897
	if (pAC->GIni.GIGenesis) {
3205
	if (pAC->GIni.GIGenesis) {
2898
		
3206
2899
		switch (pPrt->PhyType) {
3207
		switch (pPrt->PhyType) {
2900
		case SK_PHY_XMAC:
3208
		case SK_PHY_XMAC:
2901
			SkXmInitPhyXmac(pAC, IoC, Port, DoLoop);
3209
			SkXmInitPhyXmac(pAC, IoC, Port, DoLoop);
Lines 2914-2923 Link Here
2914
		}
3222
		}
2915
	}
3223
	}
2916
#endif /* GENESIS */
3224
#endif /* GENESIS */
2917
	
3225
2918
#ifdef YUKON
3226
#ifdef YUKON
2919
	if (pAC->GIni.GIYukon) {
3227
	if (pAC->GIni.GIYukon) {
2920
		
3228
2921
		SkGmInitPhyMarv(pAC, IoC, Port, DoLoop);
3229
		SkGmInitPhyMarv(pAC, IoC, Port, DoLoop);
2922
	}
3230
	}
2923
#endif /* YUKON */
3231
#endif /* YUKON */
Lines 2939-2946 Link Here
2939
 *	SK_AND_OTHER 	Other error happened
3247
 *	SK_AND_OTHER 	Other error happened
2940
 */
3248
 */
2941
static int SkXmAutoNegDoneXmac(
3249
static int SkXmAutoNegDoneXmac(
2942
SK_AC	*pAC,		/* adapter context */
3250
SK_AC	*pAC,		/* Adapter Context */
2943
SK_IOC	IoC,		/* IO context */
3251
SK_IOC	IoC,		/* I/O Context */
2944
int		Port)		/* Port Index (MAC_1 + n) */
3252
int		Port)		/* Port Index (MAC_1 + n) */
2945
{
3253
{
2946
	SK_GEPORT	*pPrt;
3254
	SK_GEPORT	*pPrt;
Lines 2958-2967 Link Here
2958
3266
2959
	if ((LPAb & PHY_X_AN_RFB) != 0) {
3267
	if ((LPAb & PHY_X_AN_RFB) != 0) {
2960
		/* At least one of the remote fault bit is set */
3268
		/* At least one of the remote fault bit is set */
2961
		/* Error */
3269
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
2962
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
2963
			("AutoNegFail: Remote fault bit set Port %d\n", Port));
3270
			("AutoNegFail: Remote fault bit set Port %d\n", Port));
2964
		pPrt->PAutoNegFail = SK_TRUE;
3271
		pPrt->PAutoNegFail = SK_TRUE;
3272
2965
		return(SK_AND_OTHER);
3273
		return(SK_AND_OTHER);
2966
	}
3274
	}
2967
3275
Lines 2974-2980 Link Here
2974
	}
3282
	}
2975
	else {
3283
	else {
2976
		/* Error */
3284
		/* Error */
2977
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3285
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
2978
			("AutoNegFail: Duplex mode mismatch Port %d\n", Port));
3286
			("AutoNegFail: Duplex mode mismatch Port %d\n", Port));
2979
		pPrt->PAutoNegFail = SK_TRUE;
3287
		pPrt->PAutoNegFail = SK_TRUE;
2980
		return(SK_AND_DUP_CAP);
3288
		return(SK_AND_DUP_CAP);
Lines 2984-3002 Link Here
2984
	/* We are NOT using chapter 4.23 of the Xaqti manual */
3292
	/* We are NOT using chapter 4.23 of the Xaqti manual */
2985
	/* We are using IEEE 802.3z/D5.0 Table 37-4 */
3293
	/* We are using IEEE 802.3z/D5.0 Table 37-4 */
2986
	if ((pPrt->PFlowCtrlMode == SK_FLOW_MODE_SYMMETRIC ||
3294
	if ((pPrt->PFlowCtrlMode == SK_FLOW_MODE_SYMMETRIC ||
2987
	     pPrt->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM) &&
3295
		 pPrt->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM) &&
2988
	    (LPAb & PHY_X_P_SYM_MD) != 0) {
3296
		(LPAb & PHY_X_P_SYM_MD) != 0) {
2989
		/* Symmetric PAUSE */
3297
		/* Symmetric PAUSE */
2990
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_SYMMETRIC;
3298
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_SYMMETRIC;
2991
	}
3299
	}
2992
	else if (pPrt->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM &&
3300
	else if (pPrt->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM &&
2993
		   (LPAb & PHY_X_RS_PAUSE) == PHY_X_P_ASYM_MD) {
3301
			 (LPAb & PHY_X_RS_PAUSE) == PHY_X_P_ASYM_MD) {
2994
		/* Enable PAUSE receive, disable PAUSE transmit */
3302
		/* enable PAUSE receive, disable PAUSE transmit */
2995
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_REM_SEND;
3303
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_REM_SEND;
2996
	}
3304
	}
2997
	else if (pPrt->PFlowCtrlMode == SK_FLOW_MODE_LOC_SEND &&
3305
	else if (pPrt->PFlowCtrlMode == SK_FLOW_MODE_LOC_SEND &&
2998
		   (LPAb & PHY_X_RS_PAUSE) == PHY_X_P_BOTH_MD) {
3306
			 (LPAb & PHY_X_RS_PAUSE) == PHY_X_P_BOTH_MD) {
2999
		/* Disable PAUSE receive, enable PAUSE transmit */
3307
		/* disable PAUSE receive, enable PAUSE transmit */
3000
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_LOC_SEND;
3308
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_LOC_SEND;
3001
	}
3309
	}
3002
	else {
3310
	else {
Lines 3022-3029 Link Here
3022
 *	SK_AND_OTHER 	Other error happened
3330
 *	SK_AND_OTHER 	Other error happened
3023
 */
3331
 */
3024
static int SkXmAutoNegDoneBcom(
3332
static int SkXmAutoNegDoneBcom(
3025
SK_AC	*pAC,		/* adapter context */
3333
SK_AC	*pAC,		/* Adapter Context */
3026
SK_IOC	IoC,		/* IO context */
3334
SK_IOC	IoC,		/* I/O Context */
3027
int		Port)		/* Port Index (MAC_1 + n) */
3335
int		Port)		/* Port Index (MAC_1 + n) */
3028
{
3336
{
3029
	SK_GEPORT	*pPrt;
3337
	SK_GEPORT	*pPrt;
Lines 3045-3056 Link Here
3045
01-Sep-2000 RA;:;:
3353
01-Sep-2000 RA;:;:
3046
	SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_1000T_STAT, &ResAb);
3354
	SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_1000T_STAT, &ResAb);
3047
#endif	/* 0 */
3355
#endif	/* 0 */
3048
	
3356
3049
	SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_STAT, &AuxStat);
3357
	SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_STAT, &AuxStat);
3050
3358
3051
	if ((LPAb & PHY_B_AN_RF) != 0) {
3359
	if ((LPAb & PHY_B_AN_RF) != 0) {
3052
		/* Remote fault bit is set: Error */
3360
		/* Remote fault bit is set: Error */
3053
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3361
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
3054
			("AutoNegFail: Remote fault bit set Port %d\n", Port));
3362
			("AutoNegFail: Remote fault bit set Port %d\n", Port));
3055
		pPrt->PAutoNegFail = SK_TRUE;
3363
		pPrt->PAutoNegFail = SK_TRUE;
3056
		return(SK_AND_OTHER);
3364
		return(SK_AND_OTHER);
Lines 3065-3087 Link Here
3065
	}
3373
	}
3066
	else {
3374
	else {
3067
		/* Error */
3375
		/* Error */
3068
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3376
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
3069
			("AutoNegFail: Duplex mode mismatch Port %d\n", Port));
3377
			("AutoNegFail: Duplex mode mismatch Port %d\n", Port));
3070
		pPrt->PAutoNegFail = SK_TRUE;
3378
		pPrt->PAutoNegFail = SK_TRUE;
3071
		return(SK_AND_DUP_CAP);
3379
		return(SK_AND_DUP_CAP);
3072
	}
3380
	}
3073
	
3381
3074
#ifdef TEST_ONLY
3382
#ifdef TEST_ONLY
3075
01-Sep-2000 RA;:;:
3383
01-Sep-2000 RA;:;:
3076
	/* Check Master/Slave resolution */
3384
	/* Check Master/Slave resolution */
3077
	if ((ResAb & PHY_B_1000S_MSF) != 0) {
3385
	if ((ResAb & PHY_B_1000S_MSF) != 0) {
3078
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3386
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
3079
			("Master/Slave Fault Port %d\n", Port));
3387
			("Master/Slave Fault Port %d\n", Port));
3080
		pPrt->PAutoNegFail = SK_TRUE;
3388
		pPrt->PAutoNegFail = SK_TRUE;
3081
		pPrt->PMSStatus = SK_MS_STAT_FAULT;
3389
		pPrt->PMSStatus = SK_MS_STAT_FAULT;
3082
		return(SK_AND_OTHER);
3390
		return(SK_AND_OTHER);
3083
	}
3391
	}
3084
	
3392
3085
	pPrt->PMSStatus = ((ResAb & PHY_B_1000S_MSR) != 0) ?
3393
	pPrt->PMSStatus = ((ResAb & PHY_B_1000S_MSR) != 0) ?
3086
		SK_MS_STAT_MASTER : SK_MS_STAT_SLAVE;
3394
		SK_MS_STAT_MASTER : SK_MS_STAT_SLAVE;
3087
#endif	/* 0 */
3395
#endif	/* 0 */
Lines 3093-3103 Link Here
3093
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_SYMMETRIC;
3401
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_SYMMETRIC;
3094
	}
3402
	}
3095
	else if ((AuxStat & PHY_B_AS_PAUSE_MSK) == PHY_B_AS_PRR) {
3403
	else if ((AuxStat & PHY_B_AS_PAUSE_MSK) == PHY_B_AS_PRR) {
3096
		/* Enable PAUSE receive, disable PAUSE transmit */
3404
		/* enable PAUSE receive, disable PAUSE transmit */
3097
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_REM_SEND;
3405
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_REM_SEND;
3098
	}
3406
	}
3099
	else if ((AuxStat & PHY_B_AS_PAUSE_MSK) == PHY_B_AS_PRT) {
3407
	else if ((AuxStat & PHY_B_AS_PAUSE_MSK) == PHY_B_AS_PRT) {
3100
		/* Disable PAUSE receive, enable PAUSE transmit */
3408
		/* disable PAUSE receive, enable PAUSE transmit */
3101
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_LOC_SEND;
3409
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_LOC_SEND;
3102
	}
3410
	}
3103
	else {
3411
	else {
Lines 3125-3132 Link Here
3125
 *	SK_AND_OTHER 	Other error happened
3433
 *	SK_AND_OTHER 	Other error happened
3126
 */
3434
 */
3127
static int SkGmAutoNegDoneMarv(
3435
static int SkGmAutoNegDoneMarv(
3128
SK_AC	*pAC,		/* adapter context */
3436
SK_AC	*pAC,		/* Adapter Context */
3129
SK_IOC	IoC,		/* IO context */
3437
SK_IOC	IoC,		/* I/O Context */
3130
int		Port)		/* Port Index (MAC_1 + n) */
3438
int		Port)		/* Port Index (MAC_1 + n) */
3131
{
3439
{
3132
	SK_GEPORT	*pPrt;
3440
	SK_GEPORT	*pPrt;
Lines 3142-3217 Link Here
3142
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_LP, &LPAb);
3450
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_LP, &LPAb);
3143
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3451
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3144
		("Link P.Abil.=0x%04X\n", LPAb));
3452
		("Link P.Abil.=0x%04X\n", LPAb));
3145
	
3453
3146
	if ((LPAb & PHY_M_AN_RF) != 0) {
3454
	if ((LPAb & PHY_M_AN_RF) != 0) {
3147
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3455
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
3148
			("AutoNegFail: Remote fault bit set Port %d\n", Port));
3456
			("AutoNegFail: Remote fault bit set Port %d\n", Port));
3149
		pPrt->PAutoNegFail = SK_TRUE;
3457
		pPrt->PAutoNegFail = SK_TRUE;
3150
		return(SK_AND_OTHER);
3458
		return(SK_AND_OTHER);
3151
	}
3459
	}
3152
3460
3153
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_1000T_STAT, &ResAb);
3461
	if ((pPrt->PLinkSpeedCap & SK_LSPEED_CAP_1000MBPS) != 0) {
3154
	
3462
3155
	/* Check Master/Slave resolution */
3463
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_1000T_STAT, &ResAb);
3156
	if ((ResAb & PHY_B_1000S_MSF) != 0) {
3464
3157
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3465
		/* Check Master/Slave resolution */
3158
			("Master/Slave Fault Port %d\n", Port));
3466
		if ((ResAb & PHY_B_1000S_MSF) != 0) {
3159
		pPrt->PAutoNegFail = SK_TRUE;
3467
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
3160
		pPrt->PMSStatus = SK_MS_STAT_FAULT;
3468
				("Master/Slave Fault Port %d\n", Port));
3161
		return(SK_AND_OTHER);
3469
			pPrt->PAutoNegFail = SK_TRUE;
3470
			pPrt->PMSStatus = SK_MS_STAT_FAULT;
3471
			return(SK_AND_OTHER);
3472
		}
3162
	}
3473
	}
3163
	
3474
3164
	pPrt->PMSStatus = ((ResAb & PHY_B_1000S_MSR) != 0) ?
3475
	pPrt->PMSStatus = ((ResAb & PHY_B_1000S_MSR) != 0) ?
3165
		(SK_U8)SK_MS_STAT_MASTER : (SK_U8)SK_MS_STAT_SLAVE;
3476
		(SK_U8)SK_MS_STAT_MASTER : (SK_U8)SK_MS_STAT_SLAVE;
3166
	
3477
3167
	/* Read PHY Specific Status */
3478
	/* Read PHY Specific Status */
3168
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_STAT, &AuxStat);
3479
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_STAT, &AuxStat);
3169
	
3480
3170
	/* Check Speed & Duplex resolved */
3481
	/* Check Speed & Duplex resolved */
3171
	if ((AuxStat & PHY_M_PS_SPDUP_RES) == 0) {
3482
	if ((AuxStat & PHY_M_PS_SPDUP_RES) == 0) {
3172
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3483
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
3173
			("AutoNegFail: Speed & Duplex not resolved, Port %d\n", Port));
3484
			("AutoNegFail: Speed & Duplex not resolved, Port %d\n", Port));
3174
		pPrt->PAutoNegFail = SK_TRUE;
3485
		pPrt->PAutoNegFail = SK_TRUE;
3175
		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;
3486
		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;
3176
		return(SK_AND_DUP_CAP);
3487
		return(SK_AND_DUP_CAP);
3177
	}
3178
	
3179
	if ((AuxStat & PHY_M_PS_FULL_DUP) != 0) {
3180
		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOFULL;
3181
	}
3182
	else {
3183
		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOHALF;
3184
	}
3488
	}
3185
	
3489
3186
	/* Check PAUSE mismatch ??? */
3490
	pPrt->PLinkModeStatus = (SK_U8)(((AuxStat & PHY_M_PS_FULL_DUP) != 0) ?
3187
	/* We are using IEEE 802.3z/D5.0 Table 37-4 */
3491
		SK_LMODE_STAT_AUTOFULL : SK_LMODE_STAT_AUTOHALF);
3188
	if ((AuxStat & PHY_M_PS_PAUSE_MSK) == PHY_M_PS_PAUSE_MSK) {
3492
3189
		/* Symmetric PAUSE */
3493
	if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
3190
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_SYMMETRIC;
3494
		/* set used link speed */
3495
		pPrt->PLinkSpeedUsed = (SK_U8)(((AuxStat & PHY_M_PS_SPEED_100) != 0) ?
3496
			SK_LSPEED_STAT_100MBPS : SK_LSPEED_STAT_10MBPS);
3191
	}
3497
	}
3192
	else if ((AuxStat & PHY_M_PS_PAUSE_MSK) == PHY_M_PS_RX_P_EN) {
3498
	else {
3193
		/* Enable PAUSE receive, disable PAUSE transmit */
3499
		/* set used link speed */
3194
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_REM_SEND;
3500
		switch ((unsigned)(AuxStat & PHY_M_PS_SPEED_MSK)) {
3501
		case (unsigned)PHY_M_PS_SPEED_1000:
3502
			pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_1000MBPS;
3503
			break;
3504
		case PHY_M_PS_SPEED_100:
3505
			pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_100MBPS;
3506
			break;
3507
		default:
3508
			pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_10MBPS;
3509
		}
3510
3511
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) {
3512
			/* Tx & Rx Pause Enabled bits are at 9..8 */
3513
			AuxStat >>= 6;
3514
3515
			if (!pAC->GIni.GICopperType) {
3516
				/* always 1000 Mbps on fiber */
3517
				pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_1000MBPS;
3518
			}
3519
		}
3520
3521
		AuxStat &= PHY_M_PS_PAUSE_MSK;
3522
		/* We are using IEEE 802.3z/D5.0 Table 37-4 */
3523
		if (AuxStat == PHY_M_PS_PAUSE_MSK) {
3524
			/* Symmetric PAUSE */
3525
			pPrt->PFlowCtrlStatus = SK_FLOW_STAT_SYMMETRIC;
3526
		}
3527
		else if (AuxStat == PHY_M_PS_RX_P_EN) {
3528
			/* enable PAUSE receive, disable PAUSE transmit */
3529
			pPrt->PFlowCtrlStatus = SK_FLOW_STAT_REM_SEND;
3530
		}
3531
		else if (AuxStat == PHY_M_PS_TX_P_EN) {
3532
			/* disable PAUSE receive, enable PAUSE transmit */
3533
			pPrt->PFlowCtrlStatus = SK_FLOW_STAT_LOC_SEND;
3534
		}
3535
		else {
3536
			/* PAUSE mismatch -> no PAUSE */
3537
			pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE;
3538
		}
3195
	}
3539
	}
3196
	else if ((AuxStat & PHY_M_PS_PAUSE_MSK) == PHY_M_PS_TX_P_EN) {
3540
3197
		/* Disable PAUSE receive, enable PAUSE transmit */
3541
	if ((pPrt->PFlowCtrlStatus == SK_FLOW_STAT_NONE) ||
3198
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_LOC_SEND;
3542
		/* disable Pause also for 10/100 Mbps in half duplex mode */
3543
		((pPrt->PLinkSpeedUsed < (SK_U8)SK_LSPEED_STAT_1000MBPS) &&
3544
		 pPrt->PLinkModeStatus == (SK_U8)SK_LMODE_STAT_AUTOHALF)) {
3545
		/* set Pause Off */
3546
		SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_PAUSE_OFF);
3199
	}
3547
	}
3200
	else {
3548
	else {
3201
		/* PAUSE mismatch -> no PAUSE */
3549
		/* set Pause On */
3202
		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE;
3550
		SK_OUT8(IoC, MR_ADDR(Port, GMAC_CTRL), (SK_U8)GMC_PAUSE_ON);
3203
	}
3204
	
3205
	/* set used link speed */
3206
	switch ((unsigned)(AuxStat & PHY_M_PS_SPEED_MSK)) {
3207
	case (unsigned)PHY_M_PS_SPEED_1000:
3208
		pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_1000MBPS;
3209
		break;
3210
	case PHY_M_PS_SPEED_100:
3211
		pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_100MBPS;
3212
		break;
3213
	default:
3214
		pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_10MBPS;
3215
	}
3551
	}
3216
3552
3217
	return(SK_AND_OK);
3553
	return(SK_AND_OK);
Lines 3233-3240 Link Here
3233
 *	SK_AND_OTHER 	Other error happened
3569
 *	SK_AND_OTHER 	Other error happened
3234
 */
3570
 */
3235
static int SkXmAutoNegDoneLone(
3571
static int SkXmAutoNegDoneLone(
3236
SK_AC	*pAC,		/* adapter context */
3572
SK_AC	*pAC,		/* Adapter Context */
3237
SK_IOC	IoC,		/* IO context */
3573
SK_IOC	IoC,		/* I/O Context */
3238
int		Port)		/* Port Index (MAC_1 + n) */
3574
int		Port)		/* Port Index (MAC_1 + n) */
3239
{
3575
{
3240
	SK_GEPORT	*pPrt;
3576
	SK_GEPORT	*pPrt;
Lines 3253-3260 Link Here
3253
3589
3254
	if ((LPAb & PHY_L_AN_RF) != 0) {
3590
	if ((LPAb & PHY_L_AN_RF) != 0) {
3255
		/* Remote fault bit is set */
3591
		/* Remote fault bit is set */
3256
		/* Error */
3592
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
3257
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3258
			("AutoNegFail: Remote fault bit set Port %d\n", Port));
3593
			("AutoNegFail: Remote fault bit set Port %d\n", Port));
3259
		pPrt->PAutoNegFail = SK_TRUE;
3594
		pPrt->PAutoNegFail = SK_TRUE;
3260
		return(SK_AND_OTHER);
3595
		return(SK_AND_OTHER);
Lines 3267-3277 Link Here
3267
	else {
3602
	else {
3268
		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOHALF;
3603
		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOHALF;
3269
	}
3604
	}
3270
	
3605
3271
	/* Check Master/Slave resolution */
3606
	/* Check Master/Slave resolution */
3272
	if ((ResAb & PHY_L_1000S_MSF) != 0) {
3607
	if ((ResAb & PHY_L_1000S_MSF) != 0) {
3273
		/* Error */
3608
		/* Error */
3274
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3609
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
3275
			("Master/Slave Fault Port %d\n", Port));
3610
			("Master/Slave Fault Port %d\n", Port));
3276
		pPrt->PAutoNegFail = SK_TRUE;
3611
		pPrt->PAutoNegFail = SK_TRUE;
3277
		pPrt->PMSStatus = SK_MS_STAT_FAULT;
3612
		pPrt->PMSStatus = SK_MS_STAT_FAULT;
Lines 3288-3294 Link Here
3288
	/* We are using IEEE 802.3z/D5.0 Table 37-4 */
3623
	/* We are using IEEE 802.3z/D5.0 Table 37-4 */
3289
	/* we must manually resolve the abilities here */
3624
	/* we must manually resolve the abilities here */
3290
	pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE;
3625
	pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE;
3291
	
3626
3292
	switch (pPrt->PFlowCtrlMode) {
3627
	switch (pPrt->PFlowCtrlMode) {
3293
	case SK_FLOW_MODE_NONE:
3628
	case SK_FLOW_MODE_NONE:
3294
		/* default */
3629
		/* default */
Lines 3296-3302 Link Here
3296
	case SK_FLOW_MODE_LOC_SEND:
3631
	case SK_FLOW_MODE_LOC_SEND:
3297
		if ((QuickStat & (PHY_L_QS_PAUSE | PHY_L_QS_AS_PAUSE)) ==
3632
		if ((QuickStat & (PHY_L_QS_PAUSE | PHY_L_QS_AS_PAUSE)) ==
3298
			(PHY_L_QS_PAUSE | PHY_L_QS_AS_PAUSE)) {
3633
			(PHY_L_QS_PAUSE | PHY_L_QS_AS_PAUSE)) {
3299
			/* Disable PAUSE receive, enable PAUSE transmit */
3634
			/* disable PAUSE receive, enable PAUSE transmit */
3300
			pPrt->PFlowCtrlStatus = SK_FLOW_STAT_LOC_SEND;
3635
			pPrt->PFlowCtrlStatus = SK_FLOW_STAT_LOC_SEND;
3301
		}
3636
		}
3302
		break;
3637
		break;
Lines 3309-3315 Link Here
3309
	case SK_FLOW_MODE_SYM_OR_REM:
3644
	case SK_FLOW_MODE_SYM_OR_REM:
3310
		if ((QuickStat & (PHY_L_QS_PAUSE | PHY_L_QS_AS_PAUSE)) ==
3645
		if ((QuickStat & (PHY_L_QS_PAUSE | PHY_L_QS_AS_PAUSE)) ==
3311
			PHY_L_QS_AS_PAUSE) {
3646
			PHY_L_QS_AS_PAUSE) {
3312
			/* Enable PAUSE receive, disable PAUSE transmit */
3647
			/* enable PAUSE receive, disable PAUSE transmit */
3313
			pPrt->PFlowCtrlStatus = SK_FLOW_STAT_REM_SEND;
3648
			pPrt->PFlowCtrlStatus = SK_FLOW_STAT_REM_SEND;
3314
		}
3649
		}
3315
		else if ((QuickStat & PHY_L_QS_PAUSE) != 0) {
3650
		else if ((QuickStat & PHY_L_QS_PAUSE) != 0) {
Lines 3321-3327 Link Here
3321
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_HWI_E016,
3656
		SK_ERR_LOG(pAC, SK_ERRCL_SW | SK_ERRCL_INIT, SKERR_HWI_E016,
3322
			SKERR_HWI_E016MSG);
3657
			SKERR_HWI_E016MSG);
3323
	}
3658
	}
3324
	
3659
3325
	return(SK_AND_OK);
3660
	return(SK_AND_OK);
3326
}	/* SkXmAutoNegDoneLone */
3661
}	/* SkXmAutoNegDoneLone */
3327
3662
Lines 3339-3346 Link Here
3339
 *	SK_AND_OTHER 	Other error happened
3674
 *	SK_AND_OTHER 	Other error happened
3340
 */
3675
 */
3341
static int SkXmAutoNegDoneNat(
3676
static int SkXmAutoNegDoneNat(
3342
SK_AC	*pAC,		/* adapter context */
3677
SK_AC	*pAC,		/* Adapter Context */
3343
SK_IOC	IoC,		/* IO context */
3678
SK_IOC	IoC,		/* I/O Context */
3344
int		Port)		/* Port Index (MAC_1 + n) */
3679
int		Port)		/* Port Index (MAC_1 + n) */
3345
{
3680
{
3346
/* todo: National */
3681
/* todo: National */
Lines 3360-3368 Link Here
3360
 *	SK_AND_DUP_CAP 	Duplex capability error happened
3695
 *	SK_AND_DUP_CAP 	Duplex capability error happened
3361
 *	SK_AND_OTHER 	Other error happened
3696
 *	SK_AND_OTHER 	Other error happened
3362
 */
3697
 */
3363
int	SkMacAutoNegDone(
3698
int SkMacAutoNegDone(
3364
SK_AC	*pAC,		/* adapter context */
3699
SK_AC	*pAC,		/* Adapter Context */
3365
SK_IOC	IoC,		/* IO context */
3700
SK_IOC	IoC,		/* I/O Context */
3366
int		Port)		/* Port Index (MAC_1 + n) */
3701
int		Port)		/* Port Index (MAC_1 + n) */
3367
{
3702
{
3368
	SK_GEPORT	*pPrt;
3703
	SK_GEPORT	*pPrt;
Lines 3374-3382 Link Here
3374
3709
3375
#ifdef GENESIS
3710
#ifdef GENESIS
3376
	if (pAC->GIni.GIGenesis) {
3711
	if (pAC->GIni.GIGenesis) {
3377
		
3712
3378
		switch (pPrt->PhyType) {
3713
		switch (pPrt->PhyType) {
3379
		
3714
3380
		case SK_PHY_XMAC:
3715
		case SK_PHY_XMAC:
3381
			Rtv = SkXmAutoNegDoneXmac(pAC, IoC, Port);
3716
			Rtv = SkXmAutoNegDoneXmac(pAC, IoC, Port);
3382
			break;
3717
			break;
Lines 3396-3421 Link Here
3396
		}
3731
		}
3397
	}
3732
	}
3398
#endif /* GENESIS */
3733
#endif /* GENESIS */
3399
	
3734
3400
#ifdef YUKON
3735
#ifdef YUKON
3401
	if (pAC->GIni.GIYukon) {
3736
	if (pAC->GIni.GIYukon) {
3402
		
3737
3403
		Rtv = SkGmAutoNegDoneMarv(pAC, IoC, Port);
3738
		Rtv = SkGmAutoNegDoneMarv(pAC, IoC, Port);
3404
	}
3739
	}
3405
#endif /* YUKON */
3740
#endif /* YUKON */
3406
	
3741
3407
	if (Rtv != SK_AND_OK) {
3742
	if (Rtv != SK_AND_OK) {
3408
		return(Rtv);
3743
		return(Rtv);
3409
	}
3744
	}
3410
3745
3411
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3746
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3412
		("AutoNeg done Port %d\n", Port));
3747
		("AutoNeg done Port %d\n", Port));
3413
	
3748
3414
	/* We checked everything and may now enable the link */
3749
	/* We checked everything and may now enable the link */
3415
	pPrt->PAutoNegFail = SK_FALSE;
3750
	pPrt->PAutoNegFail = SK_FALSE;
3416
3751
3417
	SkMacRxTxEnable(pAC, IoC, Port);
3752
	SkMacRxTxEnable(pAC, IoC, Port);
3418
	
3753
3419
	return(SK_AND_OK);
3754
	return(SK_AND_OK);
3420
}	/* SkMacAutoNegDone */
3755
}	/* SkMacAutoNegDone */
3421
3756
Lines 3433-3439 Link Here
3433
 */
3768
 */
3434
static void SkXmSetRxTxEn(
3769
static void SkXmSetRxTxEn(
3435
SK_AC	*pAC,		/* Adapter Context */
3770
SK_AC	*pAC,		/* Adapter Context */
3436
SK_IOC	IoC,		/* IO context */
3771
SK_IOC	IoC,		/* I/O Context */
3437
int		Port,		/* Port Index (MAC_1 + n) */
3772
int		Port,		/* Port Index (MAC_1 + n) */
3438
int		Para)		/* Parameter to set: MAC or PHY LoopBack, Duplex Mode */
3773
int		Para)		/* Parameter to set: MAC or PHY LoopBack, Duplex Mode */
3439
{
3774
{
Lines 3458-3464 Link Here
3458
		Word &= ~XM_MMU_GMII_LOOP;
3793
		Word &= ~XM_MMU_GMII_LOOP;
3459
		break;
3794
		break;
3460
	}
3795
	}
3461
	
3796
3462
	switch (Para & (SK_PHY_FULLD_ON | SK_PHY_FULLD_OFF)) {
3797
	switch (Para & (SK_PHY_FULLD_ON | SK_PHY_FULLD_OFF)) {
3463
	case SK_PHY_FULLD_ON:
3798
	case SK_PHY_FULLD_ON:
3464
		Word |= XM_MMU_GMII_FD;
3799
		Word |= XM_MMU_GMII_FD;
Lines 3467-3473 Link Here
3467
		Word &= ~XM_MMU_GMII_FD;
3802
		Word &= ~XM_MMU_GMII_FD;
3468
		break;
3803
		break;
3469
	}
3804
	}
3470
	
3805
3471
	XM_OUT16(IoC, Port, XM_MMU_CMD, Word | XM_MMU_ENA_RX | XM_MMU_ENA_TX);
3806
	XM_OUT16(IoC, Port, XM_MMU_CMD, Word | XM_MMU_ENA_RX | XM_MMU_ENA_TX);
3472
3807
3473
	/* dummy read to ensure writing */
3808
	/* dummy read to ensure writing */
Lines 3490-3501 Link Here
3490
 */
3825
 */
3491
static void SkGmSetRxTxEn(
3826
static void SkGmSetRxTxEn(
3492
SK_AC	*pAC,		/* Adapter Context */
3827
SK_AC	*pAC,		/* Adapter Context */
3493
SK_IOC	IoC,		/* IO context */
3828
SK_IOC	IoC,		/* I/O Context */
3494
int		Port,		/* Port Index (MAC_1 + n) */
3829
int		Port,		/* Port Index (MAC_1 + n) */
3495
int		Para)		/* Parameter to set: MAC LoopBack, Duplex Mode */
3830
int		Para)		/* Parameter to set: MAC LoopBack, Duplex Mode */
3496
{
3831
{
3497
	SK_U16	Ctrl;
3832
	SK_U16	Ctrl;
3498
	
3833
3499
	GM_IN16(IoC, Port, GM_GP_CTRL, &Ctrl);
3834
	GM_IN16(IoC, Port, GM_GP_CTRL, &Ctrl);
3500
3835
3501
	switch (Para & (SK_MAC_LOOPB_ON | SK_MAC_LOOPB_OFF)) {
3836
	switch (Para & (SK_MAC_LOOPB_ON | SK_MAC_LOOPB_OFF)) {
Lines 3515-3526 Link Here
3515
		Ctrl &= ~GM_GPCR_DUP_FULL;
3850
		Ctrl &= ~GM_GPCR_DUP_FULL;
3516
		break;
3851
		break;
3517
	}
3852
	}
3518
	
3519
    GM_OUT16(IoC, Port, GM_GP_CTRL, (SK_U16)(Ctrl | GM_GPCR_RX_ENA |
3520
		GM_GPCR_TX_ENA));
3521
3853
3854
	GM_OUT16(IoC, Port, GM_GP_CTRL, Ctrl | GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
3855
3856
#ifdef XXX
3522
	/* dummy read to ensure writing */
3857
	/* dummy read to ensure writing */
3523
	GM_IN16(IoC, Port, GM_GP_CTRL, &Ctrl);
3858
	GM_IN16(IoC, Port, GM_GP_CTRL, &Ctrl);
3859
#endif /* XXX */
3524
3860
3525
}	/* SkGmSetRxTxEn */
3861
}	/* SkGmSetRxTxEn */
3526
#endif /* YUKON */
3862
#endif /* YUKON */
Lines 3537-3556 Link Here
3537
 */
3873
 */
3538
void SkMacSetRxTxEn(
3874
void SkMacSetRxTxEn(
3539
SK_AC	*pAC,		/* Adapter Context */
3875
SK_AC	*pAC,		/* Adapter Context */
3540
SK_IOC	IoC,		/* IO context */
3876
SK_IOC	IoC,		/* I/O Context */
3541
int		Port,		/* Port Index (MAC_1 + n) */
3877
int		Port,		/* Port Index (MAC_1 + n) */
3542
int		Para)
3878
int		Para)
3543
{
3879
{
3544
#ifdef GENESIS
3880
#ifdef GENESIS
3545
	if (pAC->GIni.GIGenesis) {
3881
	if (pAC->GIni.GIGenesis) {
3546
		
3882
3547
		SkXmSetRxTxEn(pAC, IoC, Port, Para);
3883
		SkXmSetRxTxEn(pAC, IoC, Port, Para);
3548
	}
3884
	}
3549
#endif /* GENESIS */
3885
#endif /* GENESIS */
3550
	
3886
3551
#ifdef YUKON
3887
#ifdef YUKON
3552
	if (pAC->GIni.GIYukon) {
3888
	if (pAC->GIni.GIYukon) {
3553
		
3889
3554
		SkGmSetRxTxEn(pAC, IoC, Port, Para);
3890
		SkGmSetRxTxEn(pAC, IoC, Port, Para);
3555
	}
3891
	}
3556
#endif /* YUKON */
3892
#endif /* YUKON */
Lines 3570-3577 Link Here
3570
 *	!= 0	Error happened
3906
 *	!= 0	Error happened
3571
 */
3907
 */
3572
int SkMacRxTxEnable(
3908
int SkMacRxTxEnable(
3573
SK_AC	*pAC,		/* adapter context */
3909
SK_AC	*pAC,		/* Adapter Context */
3574
SK_IOC	IoC,		/* IO context */
3910
SK_IOC	IoC,		/* I/O Context */
3575
int		Port)		/* Port Index (MAC_1 + n) */
3911
int		Port)		/* Port Index (MAC_1 + n) */
3576
{
3912
{
3577
	SK_GEPORT	*pPrt;
3913
	SK_GEPORT	*pPrt;
Lines 3589-3597 Link Here
3589
	}
3925
	}
3590
3926
3591
	if ((pPrt->PLinkMode == SK_LMODE_AUTOHALF ||
3927
	if ((pPrt->PLinkMode == SK_LMODE_AUTOHALF ||
3592
	     pPrt->PLinkMode == SK_LMODE_AUTOFULL ||
3928
		 pPrt->PLinkMode == SK_LMODE_AUTOFULL ||
3593
	     pPrt->PLinkMode == SK_LMODE_AUTOBOTH) &&
3929
		 pPrt->PLinkMode == SK_LMODE_AUTOBOTH) &&
3594
	     pPrt->PAutoNegFail) {
3930
		 pPrt->PAutoNegFail) {
3595
		/* Auto-negotiation is not done or failed */
3931
		/* Auto-negotiation is not done or failed */
3596
		return(0);
3932
		return(0);
3597
	}
3933
	}
Lines 3600-3608 Link Here
3600
	if (pAC->GIni.GIGenesis) {
3936
	if (pAC->GIni.GIGenesis) {
3601
		/* set Duplex Mode and Pause Mode */
3937
		/* set Duplex Mode and Pause Mode */
3602
		SkXmInitDupMd(pAC, IoC, Port);
3938
		SkXmInitDupMd(pAC, IoC, Port);
3603
		
3939
3604
		SkXmInitPauseMd(pAC, IoC, Port);
3940
		SkXmInitPauseMd(pAC, IoC, Port);
3605
	
3941
3606
		/*
3942
		/*
3607
		 * Initialize the Interrupt Mask Register. Default IRQs are...
3943
		 * Initialize the Interrupt Mask Register. Default IRQs are...
3608
		 *	- Link Asynchronous Event
3944
		 *	- Link Asynchronous Event
Lines 3618-3640 Link Here
3618
		/* add IRQ for Receive FIFO Overflow */
3954
		/* add IRQ for Receive FIFO Overflow */
3619
		IntMask &= ~XM_IS_RXF_OV;
3955
		IntMask &= ~XM_IS_RXF_OV;
3620
#endif /* DEBUG */
3956
#endif /* DEBUG */
3621
		
3957
3622
		if (pPrt->PhyType != SK_PHY_XMAC) {
3958
		if (pPrt->PhyType != SK_PHY_XMAC) {
3623
			/* disable GP0 interrupt bit */
3959
			/* disable GP0 interrupt bit */
3624
			IntMask |= XM_IS_INP_ASS;
3960
			IntMask |= XM_IS_INP_ASS;
3625
		}
3961
		}
3626
		XM_OUT16(IoC, Port, XM_IMSK, IntMask);
3962
		XM_OUT16(IoC, Port, XM_IMSK, IntMask);
3627
	
3963
3628
		/* get MMU Command Reg. */
3964
		/* get MMU Command Reg. */
3629
		XM_IN16(IoC, Port, XM_MMU_CMD, &Reg);
3965
		XM_IN16(IoC, Port, XM_MMU_CMD, &Reg);
3630
		
3966
3631
		if (pPrt->PhyType != SK_PHY_XMAC &&
3967
		if (pPrt->PhyType != SK_PHY_XMAC &&
3632
			(pPrt->PLinkModeStatus == SK_LMODE_STAT_FULL ||
3968
			(pPrt->PLinkModeStatus == SK_LMODE_STAT_FULL ||
3633
			 pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOFULL)) {
3969
			 pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOFULL)) {
3634
			/* set to Full Duplex */
3970
			/* set to Full Duplex */
3635
			Reg |= XM_MMU_GMII_FD;
3971
			Reg |= XM_MMU_GMII_FD;
3636
		}
3972
		}
3637
		
3973
3638
		switch (pPrt->PhyType) {
3974
		switch (pPrt->PhyType) {
3639
		case SK_PHY_BCOM:
3975
		case SK_PHY_BCOM:
3640
			/*
3976
			/*
Lines 3644-3650 Link Here
3644
			SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_CTRL, &SWord);
3980
			SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_CTRL, &SWord);
3645
			SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_AUX_CTRL,
3981
			SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_AUX_CTRL,
3646
				(SK_U16)(SWord & ~PHY_B_AC_DIS_PM));
3982
				(SK_U16)(SWord & ~PHY_B_AC_DIS_PM));
3647
            SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_INT_MASK,
3983
			SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_INT_MASK,
3648
				(SK_U16)PHY_B_DEF_MSK);
3984
				(SK_U16)PHY_B_DEF_MSK);
3649
			break;
3985
			break;
3650
#ifdef OTHER_PHY
3986
#ifdef OTHER_PHY
Lines 3658-3669 Link Here
3658
			break;
3994
			break;
3659
#endif /* OTHER_PHY */
3995
#endif /* OTHER_PHY */
3660
		}
3996
		}
3661
		
3997
3662
		/* enable Rx/Tx */
3998
		/* enable Rx/Tx */
3663
		XM_OUT16(IoC, Port, XM_MMU_CMD, Reg | XM_MMU_ENA_RX | XM_MMU_ENA_TX);
3999
		XM_OUT16(IoC, Port, XM_MMU_CMD, Reg | XM_MMU_ENA_RX | XM_MMU_ENA_TX);
3664
	}
4000
	}
3665
#endif /* GENESIS */
4001
#endif /* GENESIS */
3666
	
4002
3667
#ifdef YUKON
4003
#ifdef YUKON
3668
	if (pAC->GIni.GIYukon) {
4004
	if (pAC->GIni.GIYukon) {
3669
		/*
4005
		/*
Lines 3678-3707 Link Here
3678
		/* add IRQ for Receive FIFO Overrun */
4014
		/* add IRQ for Receive FIFO Overrun */
3679
		IntMask |= GM_IS_RX_FF_OR;
4015
		IntMask |= GM_IS_RX_FF_OR;
3680
#endif /* DEBUG */
4016
#endif /* DEBUG */
3681
		
4017
3682
		SK_OUT8(IoC, GMAC_IRQ_MSK, (SK_U8)IntMask);
4018
		SK_OUT8(IoC, MR_ADDR(Port, GMAC_IRQ_MSK), (SK_U8)IntMask);
3683
		
4019
3684
		/* get General Purpose Control */
4020
		/* get General Purpose Control */
3685
		GM_IN16(IoC, Port, GM_GP_CTRL, &Reg);
4021
		GM_IN16(IoC, Port, GM_GP_CTRL, &Reg);
3686
		
4022
3687
		if (pPrt->PLinkModeStatus == SK_LMODE_STAT_FULL ||
4023
		if (pPrt->PLinkModeStatus == SK_LMODE_STAT_FULL ||
3688
			pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOFULL) {
4024
			pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOFULL) {
3689
			/* set to Full Duplex */
4025
			/* set to Full Duplex */
3690
			Reg |= GM_GPCR_DUP_FULL;
4026
			Reg |= GM_GPCR_DUP_FULL;
3691
		}
4027
		}
3692
		
4028
3693
		/* enable Rx/Tx */
4029
		/* enable Rx/Tx */
3694
        GM_OUT16(IoC, Port, GM_GP_CTRL, (SK_U16)(Reg | GM_GPCR_RX_ENA |
4030
		GM_OUT16(IoC, Port, GM_GP_CTRL, Reg | GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
3695
			GM_GPCR_TX_ENA));
3696
4031
3697
#ifndef VCPU
4032
#ifdef XXX
3698
		/* Enable all PHY interrupts */
4033
		/* dummy read to ensure writing */
3699
        SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_INT_MASK,
4034
		GM_IN16(IoC, Port, GM_GP_CTRL, &Reg);
3700
			(SK_U16)PHY_M_DEF_MSK);
4035
#endif /* XXX */
3701
#endif /* VCPU */
3702
	}
4036
	}
3703
#endif /* YUKON */
4037
#endif /* YUKON */
3704
					
4038
4039
	pAC->GIni.GP[Port].PState = SK_PRT_RUN;
4040
3705
	return(0);
4041
	return(0);
3706
4042
3707
}	/* SkMacRxTxEnable */
4043
}	/* SkMacRxTxEnable */
Lines 3717-3749 Link Here
3717
 */
4053
 */
3718
void SkMacRxTxDisable(
4054
void SkMacRxTxDisable(
3719
SK_AC	*pAC,		/* Adapter Context */
4055
SK_AC	*pAC,		/* Adapter Context */
3720
SK_IOC	IoC,		/* IO context */
4056
SK_IOC	IoC,		/* I/O Context */
3721
int		Port)		/* Port Index (MAC_1 + n) */
4057
int		Port)		/* Port Index (MAC_1 + n) */
3722
{
4058
{
3723
	SK_U16	Word;
4059
	SK_U16	Word;
3724
4060
3725
#ifdef GENESIS
4061
#ifdef GENESIS
3726
	if (pAC->GIni.GIGenesis) {
4062
	if (pAC->GIni.GIGenesis) {
3727
		
4063
3728
		XM_IN16(IoC, Port, XM_MMU_CMD, &Word);
4064
		XM_IN16(IoC, Port, XM_MMU_CMD, &Word);
3729
		
4065
3730
		XM_OUT16(IoC, Port, XM_MMU_CMD, Word & ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX));
4066
		Word &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
3731
	
4067
4068
		XM_OUT16(IoC, Port, XM_MMU_CMD, Word);
4069
3732
		/* dummy read to ensure writing */
4070
		/* dummy read to ensure writing */
3733
		XM_IN16(IoC, Port, XM_MMU_CMD, &Word);
4071
		XM_IN16(IoC, Port, XM_MMU_CMD, &Word);
3734
	}
4072
	}
3735
#endif /* GENESIS */
4073
#endif /* GENESIS */
3736
	
4074
3737
#ifdef YUKON
4075
#ifdef YUKON
3738
	if (pAC->GIni.GIYukon) {
4076
	if (pAC->GIni.GIYukon) {
3739
		
4077
3740
		GM_IN16(IoC, Port, GM_GP_CTRL, &Word);
4078
		GM_IN16(IoC, Port, GM_GP_CTRL, &Word);
3741
4079
3742
        GM_OUT16(IoC, Port, GM_GP_CTRL, (SK_U16)(Word & ~(GM_GPCR_RX_ENA |
4080
		Word &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
3743
			GM_GPCR_TX_ENA)));
3744
4081
4082
		GM_OUT16(IoC, Port, GM_GP_CTRL, Word);
4083
4084
#ifdef XXX
3745
		/* dummy read to ensure writing */
4085
		/* dummy read to ensure writing */
3746
		GM_IN16(IoC, Port, GM_GP_CTRL, &Word);
4086
		GM_IN16(IoC, Port, GM_GP_CTRL, &Word);
4087
#endif /* XXX */
3747
	}
4088
	}
3748
#endif /* YUKON */
4089
#endif /* YUKON */
3749
4090
Lines 3760-3766 Link Here
3760
 */
4101
 */
3761
void SkMacIrqDisable(
4102
void SkMacIrqDisable(
3762
SK_AC	*pAC,		/* Adapter Context */
4103
SK_AC	*pAC,		/* Adapter Context */
3763
SK_IOC	IoC,		/* IO context */
4104
SK_IOC	IoC,		/* I/O Context */
3764
int		Port)		/* Port Index (MAC_1 + n) */
4105
int		Port)		/* Port Index (MAC_1 + n) */
3765
{
4106
{
3766
	SK_GEPORT	*pPrt;
4107
	SK_GEPORT	*pPrt;
Lines 3772-3789 Link Here
3772
4113
3773
#ifdef GENESIS
4114
#ifdef GENESIS
3774
	if (pAC->GIni.GIGenesis) {
4115
	if (pAC->GIni.GIGenesis) {
3775
		
4116
3776
		/* disable all XMAC IRQs */
4117
		/* disable all XMAC IRQs */
3777
		XM_OUT16(IoC, Port, XM_IMSK, 0xffff);	
4118
		XM_OUT16(IoC, Port, XM_IMSK, 0xffff);
3778
		
4119
3779
		/* Disable all PHY interrupts */
4120
		/* disable all PHY interrupts */
3780
		switch (pPrt->PhyType) {
4121
		switch (pPrt->PhyType) {
3781
			case SK_PHY_BCOM:
4122
			case SK_PHY_BCOM:
3782
				/* Make sure that PHY is initialized */
4123
				/* Make sure that PHY is initialized */
3783
				if (pPrt->PState != SK_PRT_RESET) {
4124
				if (pPrt->PState != SK_PRT_RESET) {
3784
					/* NOT allowed if BCOM is in RESET state */
4125
					/* NOT allowed if BCOM is in RESET state */
3785
					/* Workaround BCOM Errata (#10523) all BCom */
4126
					/* Workaround BCOM Errata (#10523) all BCom */
3786
					/* Disable Power Management if link is down */
4127
					/* disable Power Management if link is down */
3787
					SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_CTRL, &Word);
4128
					SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_AUX_CTRL, &Word);
3788
					SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_AUX_CTRL,
4129
					SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_AUX_CTRL,
3789
						(SK_U16)(Word | PHY_B_AC_DIS_PM));
4130
						(SK_U16)(Word | PHY_B_AC_DIS_PM));
Lines 3802-3817 Link Here
3802
		}
4143
		}
3803
	}
4144
	}
3804
#endif /* GENESIS */
4145
#endif /* GENESIS */
3805
	
4146
3806
#ifdef YUKON
4147
#ifdef YUKON
3807
	if (pAC->GIni.GIYukon) {
4148
	if (pAC->GIni.GIYukon) {
3808
		/* disable all GMAC IRQs */
4149
		/* disable all GMAC IRQs */
3809
		SK_OUT8(IoC, GMAC_IRQ_MSK, 0);
4150
		SK_OUT8(IoC, MR_ADDR(Port, GMAC_IRQ_MSK), 0);
3810
		
4151
3811
#ifndef VCPU
4152
#ifndef VCPU
3812
		/* Disable all PHY interrupts */
4153
		/* disable all PHY interrupts */
3813
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_INT_MASK, 0);
4154
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_INT_MASK, 0);
3814
#endif /* VCPU */
4155
#endif /* !VCPU */
3815
	}
4156
	}
3816
#endif /* YUKON */
4157
#endif /* YUKON */
3817
4158
Lines 3823-3851 Link Here
3823
 *
4164
 *
3824
 *	SkXmSendCont() - Enable / Disable Send Continuous Mode
4165
 *	SkXmSendCont() - Enable / Disable Send Continuous Mode
3825
 *
4166
 *
3826
 * Description:	enable / disable Send Continuous Mode on XMAC
4167
 * Description:	enable / disable Send Continuous Mode on XMAC resp.
4168
 *								Packet Generation on GPHY
3827
 *
4169
 *
3828
 * Returns:
4170
 * Returns:
3829
 *	nothing
4171
 *	nothing
3830
 */
4172
 */
3831
void SkXmSendCont(
4173
void SkXmSendCont(
3832
SK_AC	*pAC,	/* adapter context */
4174
SK_AC	*pAC,	/* Adapter Context */
3833
SK_IOC	IoC,	/* IO context */
4175
SK_IOC	IoC,	/* I/O Context */
3834
int		Port,	/* Port Index (MAC_1 + n) */
4176
int		Port,	/* Port Index (MAC_1 + n) */
3835
SK_BOOL	Enable)	/* Enable / Disable */
4177
SK_BOOL	Enable)	/* Enable / Disable */
3836
{
4178
{
4179
	SK_U16	Reg;
4180
	SK_U16	Save;
3837
	SK_U32	MdReg;
4181
	SK_U32	MdReg;
3838
4182
3839
	XM_IN32(IoC, Port, XM_MODE, &MdReg);
4183
	if (pAC->GIni.GIGenesis) {
4184
		XM_IN32(IoC, Port, XM_MODE, &MdReg);
3840
4185
3841
	if (Enable) {
4186
		if (Enable) {
3842
		MdReg |= XM_MD_TX_CONT;
4187
			MdReg |= XM_MD_TX_CONT;
4188
		}
4189
		else {
4190
			MdReg &= ~XM_MD_TX_CONT;
4191
		}
4192
		/* setup Mode Register */
4193
		XM_OUT32(IoC, Port, XM_MODE, MdReg);
3843
	}
4194
	}
3844
	else {
4195
	else {
3845
		MdReg &= ~XM_MD_TX_CONT;
4196
		if (pAC->GIni.GIChipId == CHIP_ID_YUKON_EC) {
4197
			/* select page 18 */
4198
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_ADDR, 18);
4199
4200
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PAGE_DATA, &Reg);
4201
4202
			Reg &= ~0x003c;			/* clear bits 5..2 */
4203
4204
			if (Enable) {
4205
				/* enable packet generation, 1518 byte length */
4206
				Reg |= (BIT_5S | BIT_3S);
4207
			}
4208
4209
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_DATA, Reg);
4210
		}
4211
		else if (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) {
4212
			/* save page register */
4213
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_ADR, &Save);
4214
4215
			/* select page 6 to access Packet Generation register */
4216
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 6);
4217
4218
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Reg);
4219
4220
			Reg &= ~0x003f;			/* clear bits 5..0 */
4221
4222
			if (Enable) {
4223
				/* enable packet generation, 1518 byte length */
4224
				Reg |= (BIT_3S | BIT_1S);
4225
			}
4226
4227
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Reg);
4228
4229
			/* restore page register */
4230
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, Save);
4231
		}
3846
	}
4232
	}
3847
	/* setup Mode Register */
3848
	XM_OUT32(IoC, Port, XM_MODE, MdReg);
3849
4233
3850
}	/* SkXmSendCont */
4234
}	/* SkXmSendCont */
3851
4235
Lines 3860-3867 Link Here
3860
 *	nothing
4244
 *	nothing
3861
 */
4245
 */
3862
void SkMacTimeStamp(
4246
void SkMacTimeStamp(
3863
SK_AC	*pAC,	/* adapter context */
4247
SK_AC	*pAC,	/* Adapter Context */
3864
SK_IOC	IoC,	/* IO context */
4248
SK_IOC	IoC,	/* I/O Context */
3865
int		Port,	/* Port Index (MAC_1 + n) */
4249
int		Port,	/* Port Index (MAC_1 + n) */
3866
SK_BOOL	Enable)	/* Enable / Disable */
4250
SK_BOOL	Enable)	/* Enable / Disable */
3867
{
4251
{
Lines 3906-3913 Link Here
3906
 *	is set true.
4290
 *	is set true.
3907
 */
4291
 */
3908
void SkXmAutoNegLipaXmac(
4292
void SkXmAutoNegLipaXmac(
3909
SK_AC	*pAC,		/* adapter context */
4293
SK_AC	*pAC,		/* Adapter Context */
3910
SK_IOC	IoC,		/* IO context */
4294
SK_IOC	IoC,		/* I/O Context */
3911
int		Port,		/* Port Index (MAC_1 + n) */
4295
int		Port,		/* Port Index (MAC_1 + n) */
3912
SK_U16	IStatus)	/* Interrupt Status word to analyse */
4296
SK_U16	IStatus)	/* Interrupt Status word to analyse */
3913
{
4297
{
Lines 3921-3926 Link Here
3921
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
4305
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3922
			("AutoNegLipa: AutoNeg detected on Port %d, IStatus=0x%04X\n",
4306
			("AutoNegLipa: AutoNeg detected on Port %d, IStatus=0x%04X\n",
3923
			Port, IStatus));
4307
			Port, IStatus));
4308
3924
		pPrt->PLipaAutoNeg = SK_LIPA_AUTO;
4309
		pPrt->PLipaAutoNeg = SK_LIPA_AUTO;
3925
	}
4310
	}
3926
}	/* SkXmAutoNegLipaXmac */
4311
}	/* SkXmAutoNegLipaXmac */
Lines 3936-3943 Link Here
3936
 *	is set true.
4321
 *	is set true.
3937
 */
4322
 */
3938
void SkMacAutoNegLipaPhy(
4323
void SkMacAutoNegLipaPhy(
3939
SK_AC	*pAC,		/* adapter context */
4324
SK_AC	*pAC,		/* Adapter Context */
3940
SK_IOC	IoC,		/* IO context */
4325
SK_IOC	IoC,		/* I/O Context */
3941
int		Port,		/* Port Index (MAC_1 + n) */
4326
int		Port,		/* Port Index (MAC_1 + n) */
3942
SK_U16	PhyStat)	/* PHY Status word to analyse */
4327
SK_U16	PhyStat)	/* PHY Status word to analyse */
3943
{
4328
{
Lines 3951-3956 Link Here
3951
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
4336
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
3952
			("AutoNegLipa: AutoNeg detected on Port %d, PhyStat=0x%04X\n",
4337
			("AutoNegLipa: AutoNeg detected on Port %d, PhyStat=0x%04X\n",
3953
			Port, PhyStat));
4338
			Port, PhyStat));
4339
3954
		pPrt->PLipaAutoNeg = SK_LIPA_AUTO;
4340
		pPrt->PLipaAutoNeg = SK_LIPA_AUTO;
3955
	}
4341
	}
3956
}	/* SkMacAutoNegLipaPhy */
4342
}	/* SkMacAutoNegLipaPhy */
Lines 3965-3971 Link Here
3965
 *
4351
 *
3966
 * Note:
4352
 * Note:
3967
 *	With an external PHY, some interrupt bits are not meaningfull any more:
4353
 *	With an external PHY, some interrupt bits are not meaningfull any more:
3968
 *	- LinkAsyncEvent (bit #14)              XM_IS_LNK_AE
4354
 *	- LinkAsyncEvent (bit #14)		XM_IS_LNK_AE
3969
 *	- LinkPartnerReqConfig (bit #10)	XM_IS_LIPA_RC
4355
 *	- LinkPartnerReqConfig (bit #10)	XM_IS_LIPA_RC
3970
 *	- Page Received (bit #9)		XM_IS_RX_PAGE
4356
 *	- Page Received (bit #9)		XM_IS_RX_PAGE
3971
 *	- NextPageLoadedForXmt (bit #8)		XM_IS_TX_PAGE
4357
 *	- NextPageLoadedForXmt (bit #8)		XM_IS_TX_PAGE
Lines 3977-3984 Link Here
3977
 *	nothing
4363
 *	nothing
3978
 */
4364
 */
3979
void SkXmIrq(
4365
void SkXmIrq(
3980
SK_AC	*pAC,		/* adapter context */
4366
SK_AC	*pAC,		/* Adapter Context */
3981
SK_IOC	IoC,		/* IO context */
4367
SK_IOC	IoC,		/* I/O Context */
3982
int		Port)		/* Port Index (MAC_1 + n) */
4368
int		Port)		/* Port Index (MAC_1 + n) */
3983
{
4369
{
3984
	SK_GEPORT	*pPrt;
4370
	SK_GEPORT	*pPrt;
Lines 3986-3998 Link Here
3986
	SK_U16		IStatus;	/* Interrupt status read from the XMAC */
4372
	SK_U16		IStatus;	/* Interrupt status read from the XMAC */
3987
	SK_U16		IStatus2;
4373
	SK_U16		IStatus2;
3988
#ifdef SK_SLIM
4374
#ifdef SK_SLIM
3989
    SK_U64      OverflowStatus;
4375
	SK_U64		OverflowStatus;
3990
#endif	
4376
#endif
3991
4377
3992
	pPrt = &pAC->GIni.GP[Port];
4378
	pPrt = &pAC->GIni.GP[Port];
3993
	
4379
3994
	XM_IN16(IoC, Port, XM_ISRC, &IStatus);
4380
	XM_IN16(IoC, Port, XM_ISRC, &IStatus);
3995
	
4381
3996
	/* LinkPartner Auto-negable? */
4382
	/* LinkPartner Auto-negable? */
3997
	if (pPrt->PhyType == SK_PHY_XMAC) {
4383
	if (pPrt->PhyType == SK_PHY_XMAC) {
3998
		SkXmAutoNegLipaXmac(pAC, IoC, Port, IStatus);
4384
		SkXmAutoNegLipaXmac(pAC, IoC, Port, IStatus);
Lines 4003-4009 Link Here
4003
			XM_IS_RX_PAGE | XM_IS_TX_PAGE |
4389
			XM_IS_RX_PAGE | XM_IS_TX_PAGE |
4004
			XM_IS_AND | XM_IS_INP_ASS);
4390
			XM_IS_AND | XM_IS_INP_ASS);
4005
	}
4391
	}
4006
	
4392
4007
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
4393
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
4008
		("XmacIrq Port %d Isr 0x%04X\n", Port, IStatus));
4394
		("XmacIrq Port %d Isr 0x%04X\n", Port, IStatus));
4009
4395
Lines 4113-4152 Link Here
4113
 *	nothing
4499
 *	nothing
4114
 */
4500
 */
4115
void SkGmIrq(
4501
void SkGmIrq(
4116
SK_AC	*pAC,		/* adapter context */
4502
SK_AC	*pAC,		/* Adapter Context */
4117
SK_IOC	IoC,		/* IO context */
4503
SK_IOC	IoC,		/* I/O Context */
4118
int		Port)		/* Port Index (MAC_1 + n) */
4504
int		Port)		/* Port Index (MAC_1 + n) */
4119
{
4505
{
4120
	SK_GEPORT	*pPrt;
4506
	SK_GEPORT	*pPrt;
4121
	SK_U8		IStatus;	/* Interrupt status */
4507
	SK_U8		IStatus;	/* Interrupt status */
4122
#ifdef SK_SLIM
4508
#ifdef SK_SLIM
4123
    SK_U64      OverflowStatus;
4509
	SK_U64		OverflowStatus;
4124
#else
4510
#else
4125
	SK_EVPARA	Para;
4511
	SK_EVPARA	Para;
4126
#endif	
4512
#endif
4127
4513
4128
	pPrt = &pAC->GIni.GP[Port];
4514
	pPrt = &pAC->GIni.GP[Port];
4129
	
4515
4130
	SK_IN8(IoC, GMAC_IRQ_SRC, &IStatus);
4516
	SK_IN8(IoC, MR_ADDR(Port, GMAC_IRQ_SRC), &IStatus);
4131
	
4517
4132
#ifdef XXX
4518
#ifdef XXX
4133
	/* LinkPartner Auto-negable? */
4519
	/* LinkPartner Auto-negable? */
4134
	SkMacAutoNegLipaPhy(pAC, IoC, Port, IStatus);
4520
	SkMacAutoNegLipaPhy(pAC, IoC, Port, IStatus);
4135
#endif /* XXX */
4521
#endif /* XXX */
4136
	
4522
4137
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
4523
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ,
4138
		("GmacIrq Port %d Isr 0x%04X\n", Port, IStatus));
4524
		("GmacIrq Port %d Isr 0x%02X\n", Port, IStatus));
4139
4525
4140
	/* Combined Tx & Rx Counter Overflow SIRQ Event */
4526
	/* Combined Tx & Rx Counter Overflow SIRQ Event */
4141
	if (IStatus & (GM_IS_RX_CO_OV | GM_IS_TX_CO_OV)) {
4527
	if (IStatus & (GM_IS_RX_CO_OV | GM_IS_TX_CO_OV)) {
4142
		/* these IRQs will be cleared by reading GMACs register */
4528
		/* these IRQs will be cleared by reading GMACs register */
4143
#ifdef SK_SLIM
4529
#ifdef SK_SLIM
4144
        SkGmOverflowStatus(pAC, IoC, Port, IStatus, &OverflowStatus);
4530
		SkGmOverflowStatus(pAC, IoC, Port, (SK_U16)IStatus, &OverflowStatus);
4145
#else
4531
#else
4146
		Para.Para32[0] = (SK_U32)Port;
4532
		Para.Para32[0] = (SK_U32)Port;
4147
		Para.Para32[1] = (SK_U32)IStatus;
4533
		Para.Para32[1] = (SK_U32)IStatus;
4148
		SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_SIRQ_OVERFLOW, Para);
4534
		SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_SIRQ_OVERFLOW, Para);
4149
#endif		
4535
#endif
4150
	}
4536
	}
4151
4537
4152
	if (IStatus & GM_IS_RX_FF_OR) {
4538
	if (IStatus & GM_IS_RX_FF_OR) {
Lines 4185-4192 Link Here
4185
 *	nothing
4571
 *	nothing
4186
 */
4572
 */
4187
void SkMacIrq(
4573
void SkMacIrq(
4188
SK_AC	*pAC,		/* adapter context */
4574
SK_AC	*pAC,		/* Adapter Context */
4189
SK_IOC	IoC,		/* IO context */
4575
SK_IOC	IoC,		/* I/O Context */
4190
int		Port)		/* Port Index (MAC_1 + n) */
4576
int		Port)		/* Port Index (MAC_1 + n) */
4191
{
4577
{
4192
#ifdef GENESIS
4578
#ifdef GENESIS
Lines 4195-4201 Link Here
4195
		SkXmIrq(pAC, IoC, Port);
4581
		SkXmIrq(pAC, IoC, Port);
4196
	}
4582
	}
4197
#endif /* GENESIS */
4583
#endif /* GENESIS */
4198
	
4584
4199
#ifdef YUKON
4585
#ifdef YUKON
4200
	if (pAC->GIni.GIYukon) {
4586
	if (pAC->GIni.GIYukon) {
4201
		/* IRQ from GMAC */
4587
		/* IRQ from GMAC */
Lines 4222-4229 Link Here
4222
 *	1:  something went wrong
4608
 *	1:  something went wrong
4223
 */
4609
 */
4224
int SkXmUpdateStats(
4610
int SkXmUpdateStats(
4225
SK_AC	*pAC,		/* adapter context */
4611
SK_AC	*pAC,		/* Adapter Context */
4226
SK_IOC	IoC,		/* IO context */
4612
SK_IOC	IoC,		/* I/O Context */
4227
unsigned int Port)	/* Port Index (MAC_1 + n) */
4613
unsigned int Port)	/* Port Index (MAC_1 + n) */
4228
{
4614
{
4229
	SK_GEPORT	*pPrt;
4615
	SK_GEPORT	*pPrt;
Lines 4245-4251 Link Here
4245
	do {
4631
	do {
4246
4632
4247
		XM_IN16(IoC, Port, XM_STAT_CMD, &StatReg);
4633
		XM_IN16(IoC, Port, XM_STAT_CMD, &StatReg);
4248
		
4634
4249
		if (++WaitIndex > 10) {
4635
		if (++WaitIndex > 10) {
4250
4636
4251
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E021, SKERR_HWI_E021MSG);
4637
			SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E021, SKERR_HWI_E021MSG);
Lines 4253-4259 Link Here
4253
			return(1);
4639
			return(1);
4254
		}
4640
		}
4255
	} while ((StatReg & (XM_SC_SNP_TXC | XM_SC_SNP_RXC)) != 0);
4641
	} while ((StatReg & (XM_SC_SNP_TXC | XM_SC_SNP_RXC)) != 0);
4256
	
4642
4257
	return(0);
4643
	return(0);
4258
}	/* SkXmUpdateStats */
4644
}	/* SkXmUpdateStats */
4259
4645
Lines 4272-4290 Link Here
4272
 *	1:  something went wrong
4658
 *	1:  something went wrong
4273
 */
4659
 */
4274
int SkXmMacStatistic(
4660
int SkXmMacStatistic(
4275
SK_AC	*pAC,			/* adapter context */
4661
SK_AC	*pAC,			/* Adapter Context */
4276
SK_IOC	IoC,			/* IO context */
4662
SK_IOC	IoC,			/* I/O Context */
4277
unsigned int Port,		/* Port Index (MAC_1 + n) */
4663
unsigned int Port,		/* Port Index (MAC_1 + n) */
4278
SK_U16	StatAddr,		/* MIB counter base address */
4664
SK_U16	StatAddr,		/* MIB counter base address */
4279
SK_U32	SK_FAR *pVal)	/* ptr to return statistic value */
4665
SK_U32	SK_FAR *pVal)	/* Pointer to return statistic value */
4280
{
4666
{
4281
	if ((StatAddr < XM_TXF_OK) || (StatAddr > XM_RXF_MAX_SZ)) {
4667
	if ((StatAddr < XM_TXF_OK) || (StatAddr > XM_RXF_MAX_SZ)) {
4282
		
4668
4283
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E022, SKERR_HWI_E022MSG);
4669
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E022, SKERR_HWI_E022MSG);
4284
		
4670
4285
		return(1);
4671
		return(1);
4286
	}
4672
	}
4287
	
4673
4288
	XM_IN32(IoC, Port, StatAddr, pVal);
4674
	XM_IN32(IoC, Port, StatAddr, pVal);
4289
4675
4290
	return(0);
4676
	return(0);
Lines 4303-4314 Link Here
4303
 *	1:  something went wrong
4689
 *	1:  something went wrong
4304
 */
4690
 */
4305
int SkXmResetCounter(
4691
int SkXmResetCounter(
4306
SK_AC	*pAC,		/* adapter context */
4692
SK_AC	*pAC,		/* Adapter Context */
4307
SK_IOC	IoC,		/* IO context */
4693
SK_IOC	IoC,		/* I/O Context */
4308
unsigned int Port)	/* Port Index (MAC_1 + n) */
4694
unsigned int Port)	/* Port Index (MAC_1 + n) */
4309
{
4695
{
4310
	XM_OUT16(IoC, Port, XM_STAT_CMD, XM_SC_CLR_RXC | XM_SC_CLR_TXC);
4696
	XM_OUT16(IoC, Port, XM_STAT_CMD, XM_SC_CLR_RXC | XM_SC_CLR_TXC);
4311
	/* Clear two times according to Errata #3 */
4697
	/* Clear two times according to XMAC Errata #3 */
4312
	XM_OUT16(IoC, Port, XM_STAT_CMD, XM_SC_CLR_RXC | XM_SC_CLR_TXC);
4698
	XM_OUT16(IoC, Port, XM_STAT_CMD, XM_SC_CLR_RXC | XM_SC_CLR_TXC);
4313
4699
4314
	return(0);
4700
	return(0);
Lines 4335-4345 Link Here
4335
 *	1:  something went wrong
4721
 *	1:  something went wrong
4336
 */
4722
 */
4337
int SkXmOverflowStatus(
4723
int SkXmOverflowStatus(
4338
SK_AC	*pAC,				/* adapter context */
4724
SK_AC	*pAC,				/* Adapter Context */
4339
SK_IOC	IoC,				/* IO context */
4725
SK_IOC	IoC,				/* I/O Context */
4340
unsigned int Port,			/* Port Index (MAC_1 + n) */
4726
unsigned int Port,			/* Port Index (MAC_1 + n) */
4341
SK_U16	IStatus,			/* Interupt Status from MAC */
4727
SK_U16	IStatus,			/* Interrupt Status from MAC */
4342
SK_U64	SK_FAR *pStatus)	/* ptr for return overflow status value */
4728
SK_U64	SK_FAR *pStatus)	/* Pointer for return overflow status value */
4343
{
4729
{
4344
	SK_U64	Status;	/* Overflow status */
4730
	SK_U64	Status;	/* Overflow status */
4345
	SK_U32	RegVal;
4731
	SK_U32	RegVal;
Lines 4351-4357 Link Here
4351
		XM_IN32(IoC, Port, XM_RX_CNT_EV, &RegVal);
4737
		XM_IN32(IoC, Port, XM_RX_CNT_EV, &RegVal);
4352
		Status |= (SK_U64)RegVal << 32;
4738
		Status |= (SK_U64)RegVal << 32;
4353
	}
4739
	}
4354
	
4740
4355
	if ((IStatus & XM_IS_TXC_OV) != 0) {
4741
	if ((IStatus & XM_IS_TXC_OV) != 0) {
4356
4742
4357
		XM_IN32(IoC, Port, XM_TX_CNT_EV, &RegVal);
4743
		XM_IN32(IoC, Port, XM_TX_CNT_EV, &RegVal);
Lines 4378-4385 Link Here
4378
 *	1:  something went wrong
4764
 *	1:  something went wrong
4379
 */
4765
 */
4380
int SkGmUpdateStats(
4766
int SkGmUpdateStats(
4381
SK_AC	*pAC,		/* adapter context */
4767
SK_AC	*pAC,		/* Adapter Context */
4382
SK_IOC	IoC,		/* IO context */
4768
SK_IOC	IoC,		/* I/O Context */
4383
unsigned int Port)	/* Port Index (MAC_1 + n) */
4769
unsigned int Port)	/* Port Index (MAC_1 + n) */
4384
{
4770
{
4385
	return(0);
4771
	return(0);
Lines 4400-4423 Link Here
4400
 *	1:  something went wrong
4786
 *	1:  something went wrong
4401
 */
4787
 */
4402
int SkGmMacStatistic(
4788
int SkGmMacStatistic(
4403
SK_AC	*pAC,			/* adapter context */
4789
SK_AC	*pAC,			/* Adapter Context */
4404
SK_IOC	IoC,			/* IO context */
4790
SK_IOC	IoC,			/* I/O Context */
4405
unsigned int Port,		/* Port Index (MAC_1 + n) */
4791
unsigned int Port,		/* Port Index (MAC_1 + n) */
4406
SK_U16	StatAddr,		/* MIB counter base address */
4792
SK_U16	StatAddr,		/* MIB counter base address */
4407
SK_U32	SK_FAR *pVal)	/* ptr to return statistic value */
4793
SK_U32	SK_FAR *pVal)	/* Pointer to return statistic value */
4408
{
4794
{
4409
4795
4410
	if ((StatAddr < GM_RXF_UC_OK) || (StatAddr > GM_TXE_FIFO_UR)) {
4796
	if ((StatAddr < GM_RXF_UC_OK) || (StatAddr > GM_TXE_FIFO_UR)) {
4411
		
4797
4412
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E022, SKERR_HWI_E022MSG);
4798
		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E022, SKERR_HWI_E022MSG);
4413
		
4799
4414
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
4800
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
4415
			("SkGmMacStat: wrong MIB counter 0x%04X\n", StatAddr));
4801
			("SkGmMacStat: wrong MIB counter 0x%04X\n", StatAddr));
4416
		return(1);
4802
		return(1);
4417
	}
4803
	}
4418
		
4804
4419
	GM_IN32(IoC, Port, StatAddr, pVal);
4805
	GM_IN32(IoC, Port, StatAddr, pVal);
4420
4806
4807
	/* dummy read */
4808
	SK_IN16(IoC, B0_RAP, &StatAddr);
4809
4421
	return(0);
4810
	return(0);
4422
}	/* SkGmMacStatistic */
4811
}	/* SkGmMacStatistic */
4423
4812
Lines 4434-4441 Link Here
4434
 *	1:  something went wrong
4823
 *	1:  something went wrong
4435
 */
4824
 */
4436
int SkGmResetCounter(
4825
int SkGmResetCounter(
4437
SK_AC	*pAC,		/* adapter context */
4826
SK_AC	*pAC,		/* Adapter Context */
4438
SK_IOC	IoC,		/* IO context */
4827
SK_IOC	IoC,		/* I/O Context */
4439
unsigned int Port)	/* Port Index (MAC_1 + n) */
4828
unsigned int Port)	/* Port Index (MAC_1 + n) */
4440
{
4829
{
4441
	SK_U16	Reg;	/* Phy Address Register */
4830
	SK_U16	Reg;	/* Phy Address Register */
Lines 4446-4461 Link Here
4446
4835
4447
	/* set MIB Clear Counter Mode */
4836
	/* set MIB Clear Counter Mode */
4448
	GM_OUT16(IoC, Port, GM_PHY_ADDR, Reg | GM_PAR_MIB_CLR);
4837
	GM_OUT16(IoC, Port, GM_PHY_ADDR, Reg | GM_PAR_MIB_CLR);
4449
	
4838
4450
	/* read all MIB Counters with Clear Mode set */
4839
	/* read all MIB Counters with Clear Mode set */
4451
	for (i = 0; i < GM_MIB_CNT_SIZE; i++) {
4840
	for (i = 0; i < GM_MIB_CNT_SIZE; i++) {
4452
		/* the reset is performed only when the lower 16 bits are read */
4841
		/* the reset is performed only when the lower 16 bits are read */
4453
		GM_IN16(IoC, Port, GM_MIB_CNT_BASE + 8*i, &Word);
4842
		GM_IN16(IoC, Port, GM_MIB_CNT_BASE + 8*i, &Word);
4454
	}
4843
	}
4455
	
4844
4456
	/* clear MIB Clear Counter Mode */
4845
	/* clear MIB Clear Counter Mode */
4457
	GM_OUT16(IoC, Port, GM_PHY_ADDR, Reg);
4846
	GM_OUT16(IoC, Port, GM_PHY_ADDR, Reg);
4458
	
4847
4459
	return(0);
4848
	return(0);
4460
}	/* SkGmResetCounter */
4849
}	/* SkGmResetCounter */
4461
4850
Lines 4469-4516 Link Here
4469
 *	resulting counter overflow status is written to <pStatus>, whereas the
4858
 *	resulting counter overflow status is written to <pStatus>, whereas the
4470
 *	the following bit coding is used:
4859
 *	the following bit coding is used:
4471
 *	63:56 - unused
4860
 *	63:56 - unused
4472
 *	55:48 - TxRx interrupt register bit7:0
4861
 *	55:48 - TxRx interrupt register bit 7:0
4473
 *	32:47 - Rx interrupt register
4862
 *	47:32 - Rx interrupt register
4474
 *	31:24 - unused
4863
 *	31:24 - unused
4475
 *	23:16 - TxRx interrupt register bit15:8
4864
 *	23:16 - TxRx interrupt register bit 15:8
4476
 *	15:0  - Tx interrupt register
4865
 *	15: 0 - Tx interrupt register
4477
 *
4866
 *
4478
 * Returns:
4867
 * Returns:
4479
 *	0:  success
4868
 *	0:  success
4480
 *	1:  something went wrong
4869
 *	1:  something went wrong
4481
 */
4870
 */
4482
int SkGmOverflowStatus(
4871
int SkGmOverflowStatus(
4483
SK_AC	*pAC,				/* adapter context */
4872
SK_AC	*pAC,				/* Adapter Context */
4484
SK_IOC	IoC,				/* IO context */
4873
SK_IOC	IoC,				/* I/O Context */
4485
unsigned int Port,			/* Port Index (MAC_1 + n) */
4874
unsigned int Port,			/* Port Index (MAC_1 + n) */
4486
SK_U16	IStatus,			/* Interupt Status from MAC */
4875
SK_U16	IStatus,			/* Interrupt Status from MAC */
4487
SK_U64	SK_FAR *pStatus)	/* ptr for return overflow status value */
4876
SK_U64	SK_FAR *pStatus)	/* Pointer for return overflow status value */
4488
{
4877
{
4489
	SK_U64	Status;		/* Overflow status */
4490
	SK_U16	RegVal;
4878
	SK_U16	RegVal;
4879
#ifndef SK_SLIM
4880
	SK_U64	Status;		/* Overflow status */
4491
4881
4492
	Status = 0;
4882
	Status = 0;
4883
#endif /* !SK_SLIM */
4493
4884
4494
	if ((IStatus & GM_IS_RX_CO_OV) != 0) {
4885
	if ((IStatus & GM_IS_RX_CO_OV) != 0) {
4495
		/* this register is self-clearing after read */
4886
		/* this register is self-clearing after read */
4496
		GM_IN16(IoC, Port, GM_RX_IRQ_SRC, &RegVal);
4887
		GM_IN16(IoC, Port, GM_RX_IRQ_SRC, &RegVal);
4888
4889
#ifndef SK_SLIM
4497
		Status |= (SK_U64)RegVal << 32;
4890
		Status |= (SK_U64)RegVal << 32;
4891
#endif /* !SK_SLIM */
4498
	}
4892
	}
4499
	
4893
4500
	if ((IStatus & GM_IS_TX_CO_OV) != 0) {
4894
	if ((IStatus & GM_IS_TX_CO_OV) != 0) {
4501
		/* this register is self-clearing after read */
4895
		/* this register is self-clearing after read */
4502
		GM_IN16(IoC, Port, GM_TX_IRQ_SRC, &RegVal);
4896
		GM_IN16(IoC, Port, GM_TX_IRQ_SRC, &RegVal);
4897
4898
#ifndef SK_SLIM
4503
		Status |= (SK_U64)RegVal;
4899
		Status |= (SK_U64)RegVal;
4900
#endif /* !SK_SLIM */
4504
	}
4901
	}
4505
	
4902
4506
	/* this register is self-clearing after read */
4903
	/* this register is self-clearing after read */
4507
	GM_IN16(IoC, Port, GM_TR_IRQ_SRC, &RegVal);
4904
	GM_IN16(IoC, Port, GM_TR_IRQ_SRC, &RegVal);
4905
4906
#ifndef SK_SLIM
4508
	/* Rx overflow interrupt register bits (LoByte)*/
4907
	/* Rx overflow interrupt register bits (LoByte)*/
4509
	Status |= (SK_U64)((SK_U8)RegVal) << 48;
4908
	Status |= (SK_U64)((SK_U8)RegVal) << 48;
4510
	/* Tx overflow interrupt register bits (HiByte)*/
4909
	/* Tx overflow interrupt register bits (HiByte)*/
4511
	Status |= (SK_U64)(RegVal >> 8) << 16;
4910
	Status |= (SK_U64)(RegVal >> 8) << 16;
4512
4911
4513
	*pStatus = Status;
4912
	*pStatus = Status;
4913
#endif /* !SK_SLIM */
4914
4915
	/* dummy read */
4916
	SK_IN16(IoC, B0_RAP, &RegVal);
4514
4917
4515
	return(0);
4918
	return(0);
4516
}	/* SkGmOverflowStatus */
4919
}	/* SkGmOverflowStatus */
Lines 4526-4582 Link Here
4526
 *  gets the results if 'StartTest' is true
4929
 *  gets the results if 'StartTest' is true
4527
 *
4930
 *
4528
 * NOTE:	this test is meaningful only when link is down
4931
 * NOTE:	this test is meaningful only when link is down
4529
 *	
4932
 *
4530
 * Returns:
4933
 * Returns:
4531
 *	0:  success
4934
 *	0:  success
4532
 *	1:	no YUKON copper
4935
 *	1:	no YUKON copper
4533
 *	2:	test in progress
4936
 *	2:	test in progress
4534
 */
4937
 */
4535
int SkGmCableDiagStatus(
4938
int SkGmCableDiagStatus(
4536
SK_AC	*pAC,		/* adapter context */
4939
SK_AC	*pAC,		/* Adapter Context */
4537
SK_IOC	IoC,   		/* IO context */
4940
SK_IOC	IoC,		/* I/O Context */
4538
int		Port,		/* Port Index (MAC_1 + n) */
4941
int		Port,		/* Port Index (MAC_1 + n) */
4539
SK_BOOL	StartTest)	/* flag for start / get result */
4942
SK_BOOL	StartTest)	/* flag for start / get result */
4540
{
4943
{
4541
	int		i;
4944
	int		i;
4945
	int		CableDiagOffs;
4946
	int		MdiPairs;
4947
	SK_BOOL	FastEthernet;
4948
	SK_BOOL	Yukon2;
4542
	SK_U16	RegVal;
4949
	SK_U16	RegVal;
4543
	SK_GEPORT	*pPrt;
4950
	SK_GEPORT	*pPrt;
4544
4951
4545
	pPrt = &pAC->GIni.GP[Port];
4952
	pPrt = &pAC->GIni.GP[Port];
4546
4953
4547
	if (pPrt->PhyType != SK_PHY_MARV_COPPER) {
4954
	if (pPrt->PhyType != SK_PHY_MARV_COPPER) {
4548
		
4955
4549
		return(1);
4956
		return(1);
4550
	}
4957
	}
4551
4958
4959
	Yukon2 = (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL);
4960
4961
	if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
4962
4963
		CableDiagOffs = PHY_MARV_FE_VCT_TX;
4964
		FastEthernet = SK_TRUE;
4965
		MdiPairs = 2;
4966
	}
4967
	else {
4968
		CableDiagOffs = Yukon2 ? PHY_MARV_PHY_CTRL : PHY_MARV_CABLE_DIAG;
4969
		FastEthernet = SK_FALSE;
4970
		MdiPairs = 4;
4971
	}
4972
4552
	if (StartTest) {
4973
	if (StartTest) {
4553
		/* only start the cable test */
4974
		/* only start the cable test */
4554
		if ((pPrt->PhyId1 & PHY_I1_REV_MSK) < 4) {
4975
		if (!FastEthernet) {
4555
			/* apply TDR workaround from Marvell */
4976
4556
			SkGmPhyWrite(pAC, IoC, Port, 29, 0x001e);
4977
			if ((((pPrt->PhyId1 & PHY_I1_MOD_NUM) >> 4) == 2) &&
4557
			
4978
				 ((pPrt->PhyId1 & PHY_I1_REV_MSK) < 4)) {
4558
			SkGmPhyWrite(pAC, IoC, Port, 30, 0xcc00);
4979
				/* apply TDR workaround for model 2, rev. < 4 */
4559
			SkGmPhyWrite(pAC, IoC, Port, 30, 0xc800);
4980
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_ADDR, 0x001e);
4560
			SkGmPhyWrite(pAC, IoC, Port, 30, 0xc400);
4981
4561
			SkGmPhyWrite(pAC, IoC, Port, 30, 0xc000);
4982
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_DATA, 0xcc00);
4562
			SkGmPhyWrite(pAC, IoC, Port, 30, 0xc100);
4983
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_DATA, 0xc800);
4984
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_DATA, 0xc400);
4985
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_DATA, 0xc000);
4986
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PAGE_DATA, 0xc100);
4987
			}
4988
4989
#ifdef YUKON_DBG
4990
			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_EC) {
4991
				/* set address to 1 for page 1 */
4992
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 1);
4993
4994
				/* disable waiting period */
4995
				SkGmPhyWrite(pAC, IoC, Port, CableDiagOffs,
4996
					PHY_M_CABD_DIS_WAIT);
4997
			}
4998
#endif
4999
			if (Yukon2) {
5000
				/* set address to 5 for page 5 */
5001
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 5);
5002
	
5003
#ifdef YUKON_DBG
5004
				/* disable waiting period */
5005
				SkGmPhyWrite(pAC, IoC, Port, CableDiagOffs + 1,
5006
					PHY_M_CABD_DIS_WAIT);
5007
#endif
5008
			}
5009
			else {
5010
				/* set address to 0 for MDI[0] (Page 0) */
5011
				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 0);
5012
			}
4563
		}
5013
		}
5014
		else {
5015
			RegVal = PHY_CT_RESET | PHY_CT_SP100;
4564
5016
4565
		/* set address to 0 for MDI[0] */
5017
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, RegVal);
4566
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, 0);
4567
5018
4568
		/* Read Cable Diagnostic Reg */
5019
#ifdef xYUKON_DBG
4569
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CABLE_DIAG, &RegVal);
5020
			SkGmPhyRead(pAC, IoC, Port, PHY_MARV_FE_SPEC_2, &RegVal);
5021
			/* disable waiting period */
5022
			RegVal |= PHY_M_FESC_DIS_WAIT;
5023
5024
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_FE_SPEC_2, RegVal);
5025
#endif
5026
		}
4570
5027
4571
		/* start Cable Diagnostic Test */
5028
		/* start Cable Diagnostic Test */
4572
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CABLE_DIAG,
5029
		SkGmPhyWrite(pAC, IoC, Port, CableDiagOffs, PHY_M_CABD_ENA_TEST);
4573
			(SK_U16)(RegVal | PHY_M_CABD_ENA_TEST));
5030
4574
	
4575
		return(0);
5031
		return(0);
4576
	}
5032
	}
4577
	
5033
4578
	/* Read Cable Diagnostic Reg */
5034
	/* Read Cable Diagnostic Reg */
4579
	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CABLE_DIAG, &RegVal);
5035
	SkGmPhyRead(pAC, IoC, Port, CableDiagOffs, &RegVal);
4580
5036
4581
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
5037
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
4582
		("PHY Cable Diag.=0x%04X\n", RegVal));
5038
		("PHY Cable Diag.=0x%04X\n", RegVal));
Lines 4587-4602 Link Here
4587
	}
5043
	}
4588
5044
4589
	/* get the test results */
5045
	/* get the test results */
4590
	for (i = 0; i < 4; i++)  {
5046
	for (i = 0; i < MdiPairs; i++)  {
4591
		/* set address to i for MDI[i] */
5047
4592
		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, (SK_U16)i);
5048
		if (!FastEthernet && !Yukon2) {
5049
			/* set address to i for MDI[i] */
5050
			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_ADR, (SK_U16)i);
5051
		}
4593
5052
4594
		/* get Cable Diagnostic values */
5053
		/* get Cable Diagnostic values */
4595
		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CABLE_DIAG, &RegVal);
5054
		SkGmPhyRead(pAC, IoC, Port, CableDiagOffs, &RegVal);
4596
5055
4597
		pPrt->PMdiPairLen[i] = (SK_U8)(RegVal & PHY_M_CABD_DIST_MSK);
5056
		pPrt->PMdiPairLen[i] = (SK_U8)(RegVal & PHY_M_CABD_DIST_MSK);
4598
5057
4599
		pPrt->PMdiPairSts[i] = (SK_U8)((RegVal & PHY_M_CABD_STAT_MSK) >> 13);
5058
		pPrt->PMdiPairSts[i] = (SK_U8)((RegVal & PHY_M_CABD_STAT_MSK) >> 13);
5059
5060
		if (FastEthernet) {
5061
			/* get next register */
5062
			CableDiagOffs++;
5063
		}
4600
	}
5064
	}
4601
5065
4602
	return(0);
5066
	return(0);
Lines 4605-4607 Link Here
4605
#endif /* YUKON */
5069
#endif /* YUKON */
4606
5070
4607
/* End of file */
5071
/* End of file */
5072
(-)linux/drivers/net/sk98lin/sky2.c (+2728 lines)
Line 0 Link Here
1
/******************************************************************************
2
 *
3
 * Name:        sky2.c
4
 * Project:     Yukon2 specific functions and implementations
5
 * Version:     $Revision: 1.35.2.28 $
6
 * Date:        $Date: 2005/03/22 13:51:13 $
7
 * Purpose:     The main driver source module
8
 *
9
 *****************************************************************************/
10
11
/******************************************************************************
12
 *
13
 *	(C)Copyright 1998-2002 SysKonnect GmbH.
14
 *	(C)Copyright 2002-2004 Marvell.
15
 *
16
 *	Driver for Marvell Yukon/2 chipset and SysKonnect Gigabit Ethernet 
17
 *      Server Adapters.
18
 *
19
 *	Author: Ralph Roesler (rroesler@syskonnect.de)
20
 *	        Mirko Lindner (mlindner@syskonnect.de)
21
 *
22
 *	Address all question to: linux@syskonnect.de
23
 *
24
 *	The technical manual for the adapters is available from SysKonnect's
25
 *	web pages: www.syskonnect.com
26
 *	
27
 *	This program is free software; you can redistribute it and/or modify
28
 *	it under the terms of the GNU General Public License as published by
29
 *	the Free Software Foundation; either version 2 of the License, or
30
 *	(at your option) any later version.
31
 *
32
 *	The information in this file is provided "AS IS" without warranty.
33
 *
34
 *****************************************************************************/
35
36
#include "h/skdrv1st.h"
37
#include "h/skdrv2nd.h"
38
#include <linux/tcp.h>
39
40
/******************************************************************************
41
 *
42
 * Local Function Prototypes
43
 *
44
 *****************************************************************************/
45
46
static void InitPacketQueues(SK_AC *pAC,int Port);
47
static void GiveTxBufferToHw(SK_AC *pAC,SK_IOC IoC,int Port);
48
static void GiveRxBufferToHw(SK_AC *pAC,SK_IOC IoC,int Port,SK_PACKET *pPacket);
49
static void FillReceiveTableYukon2(SK_AC *pAC,SK_IOC IoC,int Port);
50
static SK_BOOL HandleReceives(SK_AC *pAC,int Port,SK_U16 Len,SK_U32 FrameStatus,SK_U16 Tcp1,SK_U16 Tcp2,SK_U32 Tist,SK_U16 Vlan);
51
static void CheckForSendComplete(SK_AC *pAC,SK_IOC IoC,int Port,SK_PKT_QUEUE *pPQ,SK_LE_TABLE *pLETab,unsigned int Done);
52
static void UnmapAndFreeTxPktBuffer(SK_AC *pAC,SK_PACKET *pSkPacket,int TxPort);
53
static SK_BOOL AllocateAndInitLETables(SK_AC *pAC);
54
static SK_BOOL AllocatePacketBuffersYukon2(SK_AC *pAC);
55
static void FreeLETables(SK_AC *pAC);
56
static void FreePacketBuffers(SK_AC *pAC);
57
static SK_BOOL AllocAndMapRxBuffer(SK_AC *pAC,SK_PACKET *pSkPacket,int Port);
58
#ifdef CONFIG_SK98LIN_NAPI
59
static SK_BOOL HandleStatusLEs(SK_AC *pAC,int *WorkDone,int WorkToDo);
60
#else
61
static SK_BOOL HandleStatusLEs(SK_AC *pAC);
62
#endif
63
64
extern void	SkGeCheckTimer		(DEV_NET *pNet);
65
extern void	SkLocalEventQueue(	SK_AC *pAC,
66
					SK_U32 Class,
67
					SK_U32 Event,
68
					SK_U32 Param1,
69
					SK_U32 Param2,
70
					SK_BOOL Flag);
71
extern void	SkLocalEventQueue64(	SK_AC *pAC,
72
					SK_U32 Class,
73
					SK_U32 Event,
74
					SK_U64 Param,
75
					SK_BOOL Flag);
76
77
/******************************************************************************
78
 *
79
 * Local Variables
80
 *
81
 *****************************************************************************/
82
83
#define MAX_NBR_RX_BUFFERS_IN_HW	0x15
84
static SK_U8 NbrRxBuffersInHW;
85
86
#if defined(__i386__) || defined(__x86_64__)
87
#if defined(__x86_64__)
88
#define FLUSH_OPC(le)
89
/* #define FLUSH_OPC(le)			\ 	*/
90
/*	cache0 = ((long *)(le))[0]; 		\	*/
91
/*	cache1 = ((long *)(le))[1];		\	*/
92
/*	((volatile long *)(le))[0] = cache0;	\	*/
93
/*	((volatile long *)(le))[1] = cache1;		*/
94
#else
95
#define FLUSH_OPC(le) 
96
#endif
97
#else
98
#define FLUSH_OPC(le) 
99
#endif
100
101
/******************************************************************************
102
 *
103
 * Global Functions
104
 *
105
 *****************************************************************************/
106
107
int SkY2Xmit( struct sk_buff *skb, struct SK_NET_DEVICE *dev); 
108
109
/*****************************************************************************
110
 *
111
 * 	SkY2RestartStatusUnit - restarts teh status unit
112
 *
113
 * Description:
114
 *	Reenables the status unit after any De-Init (e.g. when altering 
115
 *	the sie of the MTU via 'ifconfig a.b.c.d mtu xxx')
116
 *
117
 * Returns:	N/A
118
 */
119
void SkY2RestartStatusUnit(
120
SK_AC  *pAC)  /* pointer to adapter control context */
121
{
122
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
123
		("==> SkY2RestartStatusUnit\n"));
124
125
	/*
126
	** It might be that the TX timer is not started. Therefore
127
	** it is initialized here -> to be more investigated!
128
	*/
129
	SK_OUT32(pAC->IoBase, STAT_TX_TIMER_INI, HW_MS_TO_TICKS(pAC,10));
130
131
	pAC->StatusLETable.Done  = 0;
132
	pAC->StatusLETable.Put   = 0;
133
	pAC->StatusLETable.HwPut = 0;
134
	SkGeY2InitStatBmu(pAC, pAC->IoBase, &pAC->StatusLETable);
135
136
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
137
		("<== SkY2RestartStatusUnit\n"));
138
}
139
140
/*****************************************************************************
141
 *
142
 * 	SkY2RlmtSend - sends out a single RLMT notification
143
 *
144
 * Description:
145
 *	This function sends out an RLMT frame
146
 *
147
 * Returns:	
148
 *	> 0 - on succes: the number of bytes in the message
149
 *	= 0 - on resource shortage: this frame sent or dropped, now
150
 *	      the ring is full ( -> set tbusy)
151
 *	< 0 - on failure: other problems ( -> return failure to upper layers)
152
 */
153
int SkY2RlmtSend (
154
SK_AC          *pAC,       /* pointer to adapter control context           */
155
int             PortNr,    /* index of port the packet(s) shall be send to */
156
struct sk_buff *pMessage)  /* pointer to send-message                      */
157
{
158
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
159
		("=== SkY2RlmtSend\n"));
160
#if 0
161
	return -1;   // temporarily do not send out RLMT frames
162
#endif
163
	skb_shinfo(pMessage)->nr_frags = (2*MAX_SKB_FRAGS) + PortNr;
164
	return(SkY2Xmit(pMessage, pAC->dev[PortNr])); // SkY2Xmit needs device
165
}
166
167
/*****************************************************************************
168
 *
169
 * 	SkY2AllocateResources - Allocates all required resources for Yukon2
170
 *
171
 * Description:
172
 *	This function allocates all memory needed for the Yukon2. 
173
 *	It maps also RX buffers to the LETables and initializes the
174
 *	status list element table.
175
 *
176
 * Returns:	
177
 *	SK_TRUE, if all resources could be allocated and setup succeeded
178
 *	SK_FALSE, if an error 
179
 */
180
SK_BOOL SkY2AllocateResources (
181
SK_AC  *pAC)  /* pointer to adapter control context */
182
{
183
	int CurrMac;
184
185
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
186
		("==> SkY2AllocateResources\n"));
187
188
	/*
189
	** Initialize the packet queue variables first
190
	*/
191
	for (CurrMac = 0; CurrMac < pAC->GIni.GIMacsFound; CurrMac++) {
192
		InitPacketQueues(pAC, CurrMac);
193
	}
194
195
	/* 
196
	** Get sufficient memory for the LETables
197
	*/
198
	if (!AllocateAndInitLETables(pAC)) {
199
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
200
			SK_DBGCAT_INIT | SK_DBGCAT_DRV_ERROR,
201
			("No memory for LETable.\n"));
202
		return(SK_FALSE);
203
	}
204
205
	/*
206
	** Allocate and intialize memory for both RX and TX 
207
	** packet and fragment buffers. On an error, free 
208
	** previously allocated LETable memory and quit.
209
	*/
210
	if (!AllocatePacketBuffersYukon2(pAC)) {
211
		FreeLETables(pAC);
212
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
213
			SK_DBGCAT_INIT | SK_DBGCAT_DRV_ERROR,
214
			("No memory for Packetbuffers.\n"));
215
		return(SK_FALSE);
216
	}
217
218
	/* 
219
	** Rx and Tx LE tables will be initialized in SkGeOpen() 
220
	**
221
	** It might be that the TX timer is not started. Therefore
222
	** it is initialized here -> to be more investigated!
223
	*/
224
	SK_OUT32(pAC->IoBase, STAT_TX_TIMER_INI, HW_MS_TO_TICKS(pAC,10));
225
	SkGeY2InitStatBmu(pAC, pAC->IoBase, &pAC->StatusLETable);
226
227
	pAC->MaxUnusedRxLeWorking = MAX_UNUSED_RX_LE_WORKING;
228
229
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
230
		("<== SkY2AllocateResources\n"));
231
232
	return (SK_TRUE);
233
}
234
235
/*****************************************************************************
236
 *
237
 * 	SkY2FreeResources - Frees previously allocated resources of Yukon2
238
 *
239
 * Description:
240
 *	This function frees all previously allocated memory of the Yukon2. 
241
 *
242
 * Returns: N/A
243
 */
244
void SkY2FreeResources (
245
SK_AC  *pAC)  /* pointer to adapter control context */
246
{
247
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
248
		("==> SkY2FreeResources\n"));
249
250
	FreeLETables(pAC);
251
	FreePacketBuffers(pAC);
252
253
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
254
		("<== SkY2FreeResources\n"));
255
}
256
257
/*****************************************************************************
258
 *
259
 * 	SkY2AllocateRxBuffers - Allocates the receive buffers for a port
260
 *
261
 * Description:
262
 *	This function allocated all the RX buffers of the Yukon2. 
263
 *
264
 * Returns: N/A
265
 */
266
void SkY2AllocateRxBuffers (
267
SK_AC    *pAC,   /* pointer to adapter control context */
268
SK_IOC    IoC,	 /* I/O control context                */
269
int       Port)	 /* port index of RX                   */
270
{
271
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
272
		("==> SkY2AllocateRxBuffers (Port %c)\n", Port));
273
274
	FillReceiveTableYukon2(pAC, IoC, Port);
275
276
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
277
		("<== SkY2AllocateRxBuffers\n"));
278
}
279
280
/*****************************************************************************
281
 *
282
 * 	SkY2FreeRxBuffers - Free's all allocates RX buffers of
283
 *
284
 * Description:
285
 *	This function frees all RX buffers of the Yukon2 for a single port
286
 *
287
 * Returns: N/A
288
 */
289
void SkY2FreeRxBuffers (
290
SK_AC    *pAC,   /* pointer to adapter control context */
291
SK_IOC    IoC,	 /* I/O control context                */
292
int       Port)	 /* port index of RX                   */
293
{
294
	SK_PACKET     *pSkPacket;
295
	unsigned long  Flags;   /* for POP/PUSH macros */
296
297
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
298
		("==> SkY2FreeRxBuffers (Port %c)\n", Port));
299
300
	if (pAC->RxPort[Port].ReceivePacketTable   != NULL) {
301
		POP_FIRST_PKT_FROM_QUEUE(&pAC->RxPort[Port].RxQ_working, pSkPacket);
302
		while (pSkPacket != NULL) {
303
			if ((pSkPacket->pFrag) != NULL) {
304
				pci_unmap_page(pAC->PciDev,
305
				(dma_addr_t) pSkPacket->pFrag->pPhys,
306
				pSkPacket->pFrag->FragLen - 2,
307
				PCI_DMA_FROMDEVICE);
308
309
				DEV_KFREE_SKB_ANY(pSkPacket->pMBuf);
310
				pSkPacket->pMBuf        = NULL;
311
				pSkPacket->pFrag->pPhys = (SK_U64) 0;
312
				pSkPacket->pFrag->pVirt = NULL;
313
			}
314
			PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pSkPacket);
315
			POP_FIRST_PKT_FROM_QUEUE(&pAC->RxPort[Port].RxQ_working, pSkPacket);
316
		}
317
	}
318
319
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
320
		("<== SkY2FreeRxBuffers\n"));
321
}
322
323
/*****************************************************************************
324
 *
325
 * 	SkY2FreeTxBuffers - Free's any currently maintained Tx buffer
326
 *
327
 * Description:
328
 *	This function frees the TX buffers of the Yukon2 for a single port
329
 *	which might be in use by a transmit action
330
 *
331
 * Returns: N/A
332
 */
333
void SkY2FreeTxBuffers (
334
SK_AC    *pAC,   /* pointer to adapter control context */
335
SK_IOC    IoC,	 /* I/O control context                */
336
int       Port)	 /* port index of TX                   */
337
{
338
	SK_PACKET      *pSkPacket;
339
	SK_FRAG        *pSkFrag;
340
	unsigned long   Flags;
341
342
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
343
		("==> SkY2FreeTxBuffers (Port %c)\n", Port));
344
 
345
	if (pAC->TxPort[Port][0].TransmitPacketTable != NULL) {
346
		POP_FIRST_PKT_FROM_QUEUE(&pAC->TxPort[Port][0].TxAQ_working, pSkPacket);
347
		while (pSkPacket != NULL) {
348
			if ((pSkFrag = pSkPacket->pFrag) != NULL) {
349
				UnmapAndFreeTxPktBuffer(pAC, pSkPacket, Port);
350
			}
351
			PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->TxPort[Port][0].TxQ_free, pSkPacket);
352
			POP_FIRST_PKT_FROM_QUEUE(&pAC->TxPort[Port][0].TxAQ_working, pSkPacket);
353
		}
354
#if USE_SYNC_TX_QUEUE
355
		POP_FIRST_PKT_FROM_QUEUE(&pAC->TxPort[Port][0].TxSQ_working, pSkPacket);
356
		while (pSkPacket != NULL) {
357
			if ((pSkFrag = pSkPacket->pFrag) != NULL) {
358
				UnmapAndFreeTxPktBuffer(pAC, pSkPacket, Port);
359
			}
360
			PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->TxPort[Port][0].TxQ_free, pSkPacket);
361
			POP_FIRST_PKT_FROM_QUEUE(&pAC->TxPort[Port][0].TxSQ_working, pSkPacket);
362
		}
363
#endif
364
	}
365
366
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
367
		("<== SkY2FreeTxBuffers\n"));
368
}
369
370
/*****************************************************************************
371
 *
372
 * 	SkY2Isr - handle a receive IRQ for all yukon2 cards
373
 *
374
 * Description:
375
 *	This function is called when a receive IRQ is set. (only for yukon2)
376
 *	HandleReceives does the deferred processing of all outstanding
377
 *	interrupt operations.
378
 *
379
 * Returns:	N/A
380
 */
381
SkIsrRetVar SkY2Isr (
382
int              irq,     /* the irq we have received (might be shared!) */
383
void            *dev_id,  /* current device id                           */
384
struct  pt_regs *ptregs)  /* not used by our driver                      */
385
{
386
	struct SK_NET_DEVICE  *dev  = (struct SK_NET_DEVICE *)dev_id;
387
	DEV_NET               *pNet = (DEV_NET*) dev->priv;
388
	SK_AC                 *pAC  = pNet->pAC;
389
	SK_U32                 IntSrc;
390
	unsigned long          Flags;
391
#ifndef CONFIG_SK98LIN_NAPI
392
	SK_BOOL                handledStatLE = SK_FALSE;
393
#endif
394
395
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
396
		("==> SkY2Isr\n"));
397
398
	SK_IN32(pAC->IoBase, B0_Y2_SP_ISRC2, &IntSrc);
399
400
	if (IntSrc == 0) {
401
		SK_OUT32(pAC->IoBase, B0_Y2_SP_ICR, 2);
402
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
403
			("No Interrupt\n ==> SkY2Isr\n"));
404
		return SkIsrRetNone;
405
406
	}
407
408
#ifdef Y2_RECOVERY
409
	if (pNet->InRecover) {
410
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
411
			("Already in recover\n ==> SkY2Isr\n"));
412
		SK_OUT32(pAC->IoBase, B0_Y2_SP_ICR, 2);
413
		return SkIsrRetNone;
414
	}
415
#endif
416
417
#ifdef CONFIG_SK98LIN_NAPI
418
	if (netif_rx_schedule_prep(dev)) {
419
		pAC->GIni.GIValIrqMask &= ~(Y2_IS_STAT_BMU);
420
		SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
421
		__netif_rx_schedule(dev);
422
	}
423
#else
424
	handledStatLE = HandleStatusLEs(pAC);
425
#endif
426
427
	/* 
428
	** Check for Special Interrupts 
429
	*/
430
	if ((IntSrc & ~Y2_IS_STAT_BMU) || pAC->CheckQueue || pNet->TimerExpired) {
431
		pAC->CheckQueue = SK_FALSE;
432
		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
433
#ifdef Y2_RECOVERY
434
		if (pNet->TimerExpired) {
435
			SkGeCheckTimer(pNet);
436
		}
437
#endif
438
		SkGeSirqIsr(pAC, pAC->IoBase, IntSrc);
439
		SkEventDispatcher(pAC, pAC->IoBase);
440
		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
441
	}
442
443
	/* Speed enhancement for a2 chipsets */
444
	if (HW_FEATURE(pAC, HWF_WA_DEV_42)) {
445
		spin_lock_irqsave(&pAC->SetPutIndexLock, Flags);
446
		SkGeY2SetPutIndex(pAC, pAC->IoBase, Y2_PREF_Q_ADDR(Q_XA1,0), &pAC->TxPort[0][0].TxALET);
447
		SkGeY2SetPutIndex(pAC, pAC->IoBase, Y2_PREF_Q_ADDR(Q_R1,0), &pAC->RxPort[0].RxLET);
448
		spin_unlock_irqrestore(&pAC->SetPutIndexLock, Flags);
449
	}
450
451
	/* 
452
	** Reenable interrupts and signal end of ISR 
453
	*/
454
	SK_OUT32(pAC->IoBase, B0_Y2_SP_ICR, 2);
455
			
456
	/*
457
	** Stop and restart TX timer in case a Status LE was handled
458
	*/
459
#ifndef CONFIG_SK98LIN_NAPI
460
	if ((HW_FEATURE(pAC, HWF_WA_DEV_43_418)) && (handledStatLE)) {
461
		SK_OUT8(pAC->IoBase, STAT_TX_TIMER_CTRL, TIM_STOP);
462
		SK_OUT8(pAC->IoBase, STAT_TX_TIMER_CTRL, TIM_START);
463
	}
464
#endif
465
466
	if (!(IS_Q_EMPTY(&(pAC->TxPort[0][TX_PRIO_LOW].TxAQ_waiting)))) {
467
		GiveTxBufferToHw(pAC, pAC->IoBase, 0);
468
	}
469
	if (!(IS_Q_EMPTY(&(pAC->TxPort[1][TX_PRIO_LOW].TxAQ_waiting)))) {
470
		GiveTxBufferToHw(pAC, pAC->IoBase, 1);
471
	}
472
473
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
474
		("<== SkY2Isr\n"));
475
476
	return SkIsrRetHandled;
477
}	/* SkY2Isr */
478
479
/*****************************************************************************
480
 *
481
 *	SkY2Xmit - Linux frame transmit function for Yukon2
482
 *
483
 * Description:
484
 *	The system calls this function to send frames onto the wire.
485
 *	It puts the frame in the tx descriptor ring. If the ring is
486
 *	full then, the 'tbusy' flag is set.
487
 *
488
 * Returns:
489
 *	0, if everything is ok
490
 *	!=0, on error
491
 *
492
 * WARNING: 
493
 *	returning 1 in 'tbusy' case caused system crashes (double
494
 *	allocated skb's) !!!
495
 */
496
int SkY2Xmit(
497
struct sk_buff       *skb,  /* socket buffer to be sent */
498
struct SK_NET_DEVICE *dev)  /* via which device?        */
499
{
500
	DEV_NET         *pNet    = (DEV_NET*) dev->priv;
501
	SK_AC           *pAC     = pNet->pAC;
502
	SK_U8            FragIdx = 0;
503
	SK_PACKET       *pSkPacket;
504
	SK_FRAG         *PrevFrag;
505
	SK_FRAG         *CurrFrag;
506
	SK_PKT_QUEUE    *pWorkQueue;  /* corresponding TX queue */
507
	SK_PKT_QUEUE    *pWaitQueue; 
508
	SK_PKT_QUEUE    *pFreeQueue; 
509
	SK_LE_TABLE     *pLETab;      /* corresponding LETable  */ 
510
	skb_frag_t      *sk_frag;
511
	SK_U64           PhysAddr;
512
	unsigned long    Flags;
513
	unsigned int     Port;
514
	int              CurrFragCtr;
515
516
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
517
		("==> SkY2Xmit\n"));
518
519
	/*
520
	** Get port and return if no free packet is available 
521
	*/
522
	if (skb_shinfo(skb)->nr_frags > MAX_SKB_FRAGS) {
523
		Port = skb_shinfo(skb)->nr_frags - (2*MAX_SKB_FRAGS);
524
		skb_shinfo(skb)->nr_frags = 0;
525
	} else {
526
		Port = (pAC->RlmtNets == 2) ? pNet->PortNr : pAC->ActivePort;
527
	}
528
529
	if (IS_Q_EMPTY(&(pAC->TxPort[Port][TX_PRIO_LOW].TxQ_free))) {
530
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
531
			SK_DBGCAT_DRV_TX_PROGRESS | SK_DBGCAT_DRV_ERROR,
532
			("Not free packets available for send\n"));
533
		return 1; /* zero bytes sent! */
534
	}
535
536
	/*
537
	** Put any new packet to be sent in the waiting queue and 
538
	** handle also any possible fragment of that packet.
539
	*/
540
	pWorkQueue = &(pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_working);
541
	pWaitQueue = &(pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_waiting);
542
	pFreeQueue = &(pAC->TxPort[Port][TX_PRIO_LOW].TxQ_free);
543
	pLETab     = &(pAC->TxPort[Port][TX_PRIO_LOW].TxALET);
544
545
	/*
546
	** Normal send operations require only one fragment, because 
547
	** only one sk_buff data area is passed. 
548
	** In contradiction to this, scatter-gather (zerocopy) send
549
	** operations might pass one or more additional fragments 
550
	** where each fragment needs a separate fragment info packet.
551
	*/
552
	if (((skb_shinfo(skb)->nr_frags + 1) * MAX_FRAG_OVERHEAD) > 
553
					NUM_FREE_LE_IN_TABLE(pLETab)) {
554
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
555
			SK_DBGCAT_DRV_TX_PROGRESS | SK_DBGCAT_DRV_ERROR,
556
			("Not enough LE available for send\n"));
557
		return 1; /* zero bytes sent! */
558
	}
559
	
560
	if ((skb_shinfo(skb)->nr_frags + 1) > MAX_NUM_FRAGS) {
561
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
562
			SK_DBGCAT_DRV_TX_PROGRESS | SK_DBGCAT_DRV_ERROR,
563
			("Not even one fragment available for send\n"));
564
		return 1; /* zero bytes sent! */
565
	}
566
567
	/*
568
	** Get first packet from free packet queue
569
	*/
570
	POP_FIRST_PKT_FROM_QUEUE(pFreeQueue, pSkPacket);
571
	if(pSkPacket == NULL) {
572
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
573
			SK_DBGCAT_DRV_TX_PROGRESS | SK_DBGCAT_DRV_ERROR,
574
			("Could not obtain free packet used for xmit\n"));
575
		return 1; /* zero bytes sent! */
576
	}
577
578
	pSkPacket->pFrag = &(pSkPacket->FragArray[FragIdx]);
579
580
	/* 
581
	** map the sk_buff to be available for the adapter 
582
	*/
583
	PhysAddr = (SK_U64) pci_map_page(pAC->PciDev,
584
			virt_to_page(skb->data),
585
			((unsigned long) skb->data & ~PAGE_MASK),
586
			skb_headlen(skb),
587
			PCI_DMA_TODEVICE);
588
	pSkPacket->pMBuf	  = skb;
589
	pSkPacket->pFrag->pPhys   = PhysAddr;
590
	pSkPacket->pFrag->FragLen = skb_headlen(skb);
591
	pSkPacket->pFrag->pNext   = NULL; /* initial has no next default */
592
	pSkPacket->NumFrags	  = skb_shinfo(skb)->nr_frags + 1;
593
594
	PrevFrag = pSkPacket->pFrag;
595
596
	/*
597
	** Each scatter-gather fragment need to be mapped...
598
	*/
599
        for (	CurrFragCtr = 0; 
600
		CurrFragCtr < skb_shinfo(skb)->nr_frags;
601
		CurrFragCtr++) {
602
		FragIdx++;
603
		sk_frag = &skb_shinfo(skb)->frags[CurrFragCtr];
604
		CurrFrag = &(pSkPacket->FragArray[FragIdx]);
605
606
		/* 
607
		** map the sk_buff to be available for the adapter 
608
		*/
609
		PhysAddr = (SK_U64) pci_map_page(pAC->PciDev,
610
				sk_frag->page,
611
		 		sk_frag->page_offset,
612
		 		sk_frag->size,
613
		 		PCI_DMA_TODEVICE);
614
615
		CurrFrag->pPhys   = PhysAddr;
616
 		CurrFrag->FragLen = sk_frag->size;
617
 		CurrFrag->pNext   = NULL;
618
619
		/*
620
		** Add the new fragment to the list of fragments
621
		*/
622
		PrevFrag->pNext = CurrFrag;
623
		PrevFrag = CurrFrag;
624
	}
625
626
	/* 
627
	** Add packet to waiting packets queue 
628
	*/
629
	PUSH_PKT_AS_LAST_IN_QUEUE(pWaitQueue, pSkPacket);
630
	GiveTxBufferToHw(pAC, pAC->IoBase, Port);
631
	dev->trans_start = jiffies;
632
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
633
		("<== SkY2Xmit(return 0)\n"));
634
	return (0);
635
}	/* SkY2Xmit */
636
637
#ifdef CONFIG_SK98LIN_NAPI
638
/*****************************************************************************
639
 *
640
 *	SkY2Poll - NAPI Rx polling callback for Yukon2 chipsets
641
 *
642
 * Description:
643
 *	Called by the Linux system in case NAPI polling is activated
644
 *
645
 * Returns
646
 *	The number of work data still to be handled
647
 *
648
 * Notes
649
 *	The slowpath lock needs to be set because HW accesses may
650
 *	interfere with slowpath events (e.g. TWSI)
651
 */
652
int SkY2Poll(
653
struct net_device *dev,     /* device that needs to be polled */
654
int               *budget)  /* how many budget do we have?    */
655
{
656
	SK_AC	       *pAC           = ((DEV_NET*)(dev->priv))->pAC;
657
	int	        WorkToDo      = min(*budget, dev->quota);
658
	int	        WorkDone      = 0;
659
	SK_BOOL         handledStatLE = SK_FALSE;
660
	unsigned long   Flags;       
661
662
	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
663
	handledStatLE = HandleStatusLEs(pAC, &WorkDone, WorkToDo);
664
665
	*budget -= WorkDone;
666
	dev->quota -= WorkDone;
667
668
	if(WorkDone < WorkToDo) {
669
		netif_rx_complete(dev);
670
		pAC->GIni.GIValIrqMask |= (Y2_IS_STAT_BMU);
671
		SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
672
		if ((HW_FEATURE(pAC, HWF_WA_DEV_43_418)) && (handledStatLE)) {
673
			SK_OUT8(pAC->IoBase, STAT_TX_TIMER_CTRL, TIM_STOP);
674
			SK_OUT8(pAC->IoBase, STAT_TX_TIMER_CTRL, TIM_START);
675
		}
676
	}
677
	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
678
	return (WorkDone >= WorkToDo);
679
}	/* SkY2Poll */
680
#endif
681
682
/******************************************************************************
683
 *
684
 *	SkY2PortStop - stop a port on Yukon2
685
 *
686
 * Description:
687
 *	This function stops a port of the Yukon2 chip. This stop 
688
 *	stop needs to be performed in a specific order:
689
 * 
690
 *	a) Stop the Prefetch unit
691
 *	b) Stop the Port (MAC, PHY etc.)
692
 *
693
 * Returns: N/A
694
 */
695
void SkY2PortStop(
696
SK_AC   *pAC,      /* adapter control context                             */
697
SK_IOC   IoC,      /* I/O control context (address of adapter registers)  */
698
int      Port,     /* port to stop (MAC_1 + n)                            */
699
int      Dir,      /* StopDirection (SK_STOP_RX, SK_STOP_TX, SK_STOP_ALL) */
700
int      RstMode)  /* Reset Mode (SK_SOFT_RST, SK_HARD_RST)               */
701
{
702
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
703
		("==> SkY2PortStop (Port %c)\n", 'A' + Port));
704
705
	/*
706
	** Stop the HW
707
	*/
708
	SkGeStopPort(pAC, IoC, Port, Dir, RstMode);
709
710
	/*
711
	** Move any TX packet from work queues into the free queue again
712
	** and initialize the TX LETable variables
713
	*/
714
	SkY2FreeTxBuffers(pAC, pAC->IoBase, Port);
715
	pAC->TxPort[Port][TX_PRIO_LOW].TxALET.Bmu.RxTx.TcpWp    = 0;
716
	pAC->TxPort[Port][TX_PRIO_LOW].TxALET.Bmu.RxTx.MssValue = 0;
717
	pAC->TxPort[Port][TX_PRIO_LOW].TxALET.BufHighAddr       = 0;
718
	pAC->TxPort[Port][TX_PRIO_LOW].TxALET.Done              = 0;    
719
	pAC->TxPort[Port][TX_PRIO_LOW].TxALET.Put               = 0;
720
	// pAC->GIni.GP[Port].PState = SK_PRT_STOP;
721
722
	/*
723
	** Move any RX packet from work queue into the waiting queue
724
	** and initialize the RX LETable variables
725
	*/
726
	SkY2FreeRxBuffers(pAC, pAC->IoBase, Port);
727
	pAC->RxPort[Port].RxLET.BufHighAddr = 0;
728
729
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
730
		("<== SkY2PortStop()\n"));
731
}
732
733
/******************************************************************************
734
 *
735
 *	SkY2PortStart - start a port on Yukon2
736
 *
737
 * Description:
738
 *	This function starts a port of the Yukon2 chip. This start 
739
 *	action needs to be performed in a specific order:
740
 * 
741
 *	a) Initialize the LET indices (PUT/GET to 0)
742
 *	b) Initialize the LET in HW (enables also prefetch unit)
743
 *	c) Move all RX buffers from waiting queue to working queue
744
 *	   which involves also setting up of RX list elements
745
 *	d) Initialize the FIFO settings of Yukon2 (Watermark etc.)
746
 *	e) Initialize the Port (MAC, PHY etc.)
747
 *	f) Initialize the MC addresses
748
 *
749
 * Returns:	N/A
750
 */
751
void SkY2PortStart(
752
SK_AC   *pAC,   /* adapter control context                            */
753
SK_IOC   IoC,   /* I/O control context (address of adapter registers) */
754
int      Port)  /* port to start                                      */
755
{
756
	// SK_GEPORT *pPrt = &pAC->GIni.GP[Port];
757
	SK_HWLE   *pLE;
758
	SK_U32     DWord;
759
	SK_U32     PrefetchReg; /* register for Put index */
760
#if defined(__x86_64__)
761
	long       cache0, cache1;
762
#endif
763
764
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
765
		("==> SkY2PortStart (Port %c)\n", 'A' + Port));
766
767
	/*
768
	** Initialize the LET indices
769
	*/
770
	pAC->RxPort[Port].RxLET.Done                = 0; 
771
	pAC->RxPort[Port].RxLET.Put                 = 0;
772
	pAC->RxPort[Port].RxLET.HwPut               = 0;
773
	pAC->TxPort[Port][TX_PRIO_LOW].TxALET.Done  = 0;    
774
	pAC->TxPort[Port][TX_PRIO_LOW].TxALET.Put   = 0;
775
	pAC->TxPort[Port][TX_PRIO_LOW].TxALET.HwPut = 0;
776
	if (HW_SYNC_TX_SUPPORTED(pAC)) {
777
		pAC->TxPort[Port][TX_PRIO_LOW].TxSLET.Done  = 0;    
778
		pAC->TxPort[Port][TX_PRIO_LOW].TxSLET.Put   = 0;
779
		pAC->TxPort[Port][TX_PRIO_LOW].TxSLET.HwPut = 0;
780
	}
781
	
782
	if (HW_FEATURE(pAC, HWF_WA_DEV_420)) {
783
		/*
784
		** It might be that we have to limit the RX buffers 
785
		** effectively passed to HW. Initialize the start
786
		** value in that case...
787
		*/
788
		NbrRxBuffersInHW = 0;
789
	}
790
791
	/*
792
	** TODO on dual net adapters we need to check if
793
	** StatusLETable need to be set...
794
	** 
795
	** pAC->StatusLETable.Done  = 0;
796
	** pAC->StatusLETable.Put   = 0;
797
	** pAC->StatusLETable.HwPut = 0;
798
	** SkGeY2InitPrefetchUnit(pAC, pAC->IoBase, Q_ST, &pAC->StatusLETable);
799
	*/
800
801
	/*
802
	** Initialize the LET in HW (enables also prefetch unit)
803
	*/
804
	SkGeY2InitPrefetchUnit(pAC, IoC,(Port == 0) ? Q_R1 : Q_R2,
805
			&pAC->RxPort[Port].RxLET);
806
	SkGeY2InitPrefetchUnit( pAC, IoC,(Port == 0) ? Q_XA1 : Q_XA2, 
807
			&pAC->TxPort[Port][TX_PRIO_LOW].TxALET);
808
	if (HW_SYNC_TX_SUPPORTED(pAC)) {
809
		SkGeY2InitPrefetchUnit( pAC, IoC, (Port == 0) ? Q_XS1 : Q_XS2,
810
				&pAC->TxPort[Port][TX_PRIO_HIGH].TxSLET);
811
	}
812
813
814
	/*
815
	** Using new values for the watermarks and the timer for
816
	** low latency optimization
817
	*/
818
	if (pAC->LowLatency) {
819
		SK_OUT8(IoC, STAT_FIFO_WM, 1);
820
		SK_OUT8(IoC, STAT_FIFO_ISR_WM, 1);
821
		SK_OUT32(IoC, STAT_LEV_TIMER_INI, 50);
822
		SK_OUT32(IoC, STAT_ISR_TIMER_INI, 10);
823
	}
824
825
826
	/*
827
	** Initialize the Port (MAC, PHY etc.)
828
	*/
829
	if (SkGeInitPort(pAC, IoC, Port)) {
830
		if (Port == 0) {
831
			printk("%s: SkGeInitPort A failed.\n",pAC->dev[0]->name);
832
		} else {
833
			printk("%s: SkGeInitPort B failed.\n",pAC->dev[1]->name);
834
		}
835
	}
836
	
837
	if (IS_GMAC(pAC)) {
838
		/* disable Rx GMAC FIFO Flush Mode */
839
		SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8) GMF_RX_F_FL_OFF);
840
	}
841
842
	/*
843
	** Initialize the MC addresses
844
	*/
845
	SkAddrMcUpdate(pAC,IoC, Port);
846
847
	SkMacRxTxEnable(pAC, IoC,Port);
848
				
849
	if (pAC->RxPort[Port].UseRxCsum) {
850
		SkGeRxCsum(pAC, IoC, Port, SK_TRUE);
851
	
852
		GET_RX_LE(pLE, &pAC->RxPort[Port].RxLET);
853
		RXLE_SET_STACS1(pLE, pAC->CsOfs1);
854
		RXLE_SET_STACS2(pLE, pAC->CsOfs2);
855
		RXLE_SET_CTRL(pLE, 0);
856
857
		RXLE_SET_OPC(pLE, OP_TCPSTART | HW_OWNER);
858
		FLUSH_OPC(pLE);
859
		if (Port == 0) {
860
			PrefetchReg=Y2_PREF_Q_ADDR(Q_R1,PREF_UNIT_PUT_IDX_REG);
861
		} else {
862
			PrefetchReg=Y2_PREF_Q_ADDR(Q_R2,PREF_UNIT_PUT_IDX_REG);
863
		}
864
		DWord = GET_PUT_IDX(&pAC->RxPort[Port].RxLET);
865
		SK_OUT32(IoC, PrefetchReg, DWord);
866
		UPDATE_HWPUT_IDX(&pAC->RxPort[Port].RxLET);
867
	}
868
869
	pAC->GIni.GP[Port].PState = SK_PRT_RUN;
870
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
871
		("<== SkY2PortStart()\n"));
872
}
873
874
/******************************************************************************
875
 *
876
 * Local Functions
877
 *
878
 *****************************************************************************/
879
880
/*****************************************************************************
881
 *
882
 *	InitPacketQueues - initialize SW settings of packet queues
883
 *
884
 * Description:
885
 *	This function will initialize the packet queues for a port.
886
 *
887
 * Returns: N/A
888
 */
889
static void InitPacketQueues(
890
SK_AC  *pAC,   /* pointer to adapter control context */
891
int     Port)  /* index of port to be initialized    */
892
{
893
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
894
		("==> InitPacketQueues(Port %c)\n", 'A' + Port));
895
	
896
	pAC->RxPort[Port].RxQ_working.pHead = NULL;
897
	pAC->RxPort[Port].RxQ_working.pTail = NULL;
898
	spin_lock_init(&pAC->RxPort[Port].RxQ_working.QueueLock);
899
	
900
	pAC->RxPort[Port].RxQ_waiting.pHead = NULL;
901
	pAC->RxPort[Port].RxQ_waiting.pTail = NULL;
902
	spin_lock_init(&pAC->RxPort[Port].RxQ_waiting.QueueLock);
903
	
904
	pAC->TxPort[Port][TX_PRIO_LOW].TxQ_free.pHead = NULL;
905
	pAC->TxPort[Port][TX_PRIO_LOW].TxQ_free.pTail = NULL;
906
	spin_lock_init(&pAC->TxPort[Port][TX_PRIO_LOW].TxQ_free.QueueLock);
907
908
	pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_working.pHead = NULL;
909
	pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_working.pTail = NULL;
910
	spin_lock_init(&pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_working.QueueLock);
911
	
912
	pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_waiting.pHead = NULL;
913
	pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_waiting.pTail = NULL;
914
	spin_lock_init(&pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_waiting.QueueLock);
915
	
916
#if USE_SYNC_TX_QUEUE
917
	pAC->TxPort[Port][TX_PRIO_LOW].TxSQ_working.pHead = NULL;
918
	pAC->TxPort[Port][TX_PRIO_LOW].TxSQ_working.pTail = NULL;
919
	spin_lock_init(&pAC->TxPort[Port][TX_PRIO_LOW].TxSQ_working.QueueLock);
920
921
	pAC->TxPort[Port][TX_PRIO_LOW].TxSQ_waiting.pHead = NULL;
922
	pAC->TxPort[Port][TX_PRIO_LOW].TxSQ_waiting.pTail = NULL;
923
	spin_lock_init(&pAC->TxPort[Port][TX_PRIO_LOW].TxSQ_waiting.QueueLock);
924
#endif
925
	
926
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
927
		("<== InitPacketQueues(Port %c)\n", 'A' + Port));
928
}	/* InitPacketQueues */
929
930
/*****************************************************************************
931
 *
932
 *	GiveTxBufferToHw - commits a previously allocated DMA area to HW
933
 *
934
 * Description:
935
 *	This functions gives transmit buffers to HW. If no list elements
936
 *	are available the buffers will be queued. 
937
 *
938
 * Notes:
939
 *       This function can run only once in a system at one time.
940
 *
941
 * Returns: N/A
942
 */
943
static void GiveTxBufferToHw(
944
SK_AC   *pAC,   /* pointer to adapter control context         */
945
SK_IOC   IoC,   /* I/O control context (address of registers) */
946
int      Port)  /* port index for which the buffer is used    */
947
{
948
	SK_HWLE         *pLE;
949
	SK_PACKET       *pSkPacket;
950
	SK_FRAG         *pFrag;
951
	SK_PKT_QUEUE    *pWorkQueue;   /* corresponding TX queue */
952
	SK_PKT_QUEUE    *pWaitQueue; 
953
	SK_LE_TABLE     *pLETab;       /* corresponding LETable  */ 
954
	SK_BOOL          SetOpcodePacketFlag;
955
	SK_U32           HighAddress;
956
	SK_U32           LowAddress;
957
	SK_U16           TcpSumStart; 
958
	SK_U16           TcpSumWrite;
959
	SK_U8            OpCode;
960
	SK_U8            Ctrl;
961
	unsigned long    Flags;
962
	unsigned long    LockFlag;
963
	int              Protocol;
964
#ifdef NETIF_F_TSO
965
	SK_U16           Mss;
966
	int              TcpOptLen;
967
	int              IpTcpLen;
968
#endif
969
#if defined(__x86_64__)
970
	long             cache0, cache1;
971
#endif
972
973
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
974
		("==> GiveTxBufferToHw\n"));
975
976
	if (IS_Q_EMPTY(&(pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_waiting))) {
977
		return;
978
	}
979
980
	spin_lock_irqsave(&pAC->TxQueueLock, LockFlag);
981
982
	/*
983
	** Initialize queue settings
984
	*/
985
	pWorkQueue = &(pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_working);
986
	pWaitQueue = &(pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_waiting);
987
	pLETab     = &(pAC->TxPort[Port][TX_PRIO_LOW].TxALET);
988
989
	POP_FIRST_PKT_FROM_QUEUE(pWaitQueue, pSkPacket);
990
	while (pSkPacket != NULL) {
991
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
992
			("\tWe have a packet to send %p\n", pSkPacket));
993
994
		/* 
995
		** the first frag of a packet gets opcode OP_PACKET 
996
		*/
997
		SetOpcodePacketFlag	= SK_TRUE;
998
		pFrag			= pSkPacket->pFrag;
999
1000
		/* 
1001
		** fill list elements with data from fragments 
1002
		*/
1003
		while (pFrag != NULL) {
1004
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1005
				("\tGet LE\n"));
1006
#ifdef NETIF_F_TSO
1007
			Mss = skb_shinfo(pSkPacket->pMBuf)->tso_size;
1008
			if (Mss) {
1009
				TcpOptLen = ((pSkPacket->pMBuf->h.th->doff - 5) * 4);
1010
				IpTcpLen  = ((pSkPacket->pMBuf->nh.iph->ihl * 4) + 
1011
						sizeof(struct tcphdr));
1012
				Mss += (TcpOptLen + IpTcpLen + C_LEN_ETHERMAC_HEADER);
1013
			}
1014
			if (pLETab->Bmu.RxTx.MssValue != Mss) {
1015
				pLETab->Bmu.RxTx.MssValue = Mss;
1016
				/* Take a new LE for TSO from the table */
1017
				GET_TX_LE(pLE, pLETab);
1018
1019
#if 0
1020
				if(pSkPacket->VlanId) {
1021
					TXLE_SET_OPC(pLE, OP_LRGLENVLAN | HW_OWNER);
1022
					TXLE_SET_VLAN(pLE, pSkPacket->VlanId);
1023
					pSkPacket->VlanId = 0;
1024
					Ctrl |= INS_VLAN;
1025
				} else {
1026
#endif
1027
					TXLE_SET_OPC(pLE, OP_LRGLEN | HW_OWNER);
1028
#if 0
1029
				}
1030
#endif
1031
				/* set maximum segment size for new packet */
1032
				TXLE_SET_LSLEN(pLE, pLETab->Bmu.RxTx.MssValue);
1033
				FLUSH_OPC(pLE) ;
1034
			}
1035
#endif
1036
			GET_TX_LE(pLE, pLETab);
1037
			Ctrl = 0;
1038
1039
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1040
				("\tGot empty LE %p idx %d\n", pLE, GET_PUT_IDX(pLETab)));
1041
1042
			SK_DBG_DUMP_TX_LE(pLE);
1043
1044
			LowAddress  = (SK_U32) (pFrag->pPhys & 0xffffffff);
1045
			HighAddress = (SK_U32) (pFrag->pPhys >> 32);
1046
			if (HighAddress != pLETab->BufHighAddr) {
1047
				/* set opcode high part of the address in one LE */
1048
				OpCode = OP_ADDR64 | HW_OWNER;
1049
	
1050
				/* Set now the 32 high bits of the address */
1051
				TXLE_SET_ADDR( pLE, HighAddress);
1052
	
1053
				/* Set the opcode into the LE */
1054
				TXLE_SET_OPC(pLE, OpCode);
1055
	
1056
				/* Flush the LE to memory */
1057
				FLUSH_OPC(pLE);
1058
	
1059
				/* remember the HighAddress we gave to the Hardware */
1060
				pLETab->BufHighAddr = HighAddress;
1061
				
1062
				/* get a new LE because we filled one with high address */
1063
				GET_TX_LE(pLE, pLETab);
1064
			}
1065
	
1066
			/*
1067
			** TCP checksum offload
1068
			*/
1069
			if ((pSkPacket->pMBuf->ip_summed == CHECKSUM_HW) && 
1070
			    (SetOpcodePacketFlag         == SK_TRUE)) {
1071
				Protocol = ((SK_U8)pSkPacket->pMBuf->data[C_OFFSET_IPPROTO] & 0xff);
1072
				/* if (Protocol & C_PROTO_ID_IP) { Ctrl = 0; } */ 
1073
				if (Protocol & C_PROTO_ID_TCP) {
1074
					Ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
1075
					/* TCP Checksum Calculation Start Position */
1076
					TcpSumStart = C_LEN_ETHERMAC_HEADER + IP_HDR_LEN;
1077
					/* TCP Checksum Write Position */
1078
					TcpSumWrite = TcpSumStart + TCP_CSUM_OFFS;
1079
				} else {
1080
					Ctrl = UDPTCP | CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
1081
					/* TCP Checksum Calculation Start Position */
1082
					TcpSumStart = ETHER_MAC_HDR_LEN + IP_HDR_LEN;
1083
					/* UDP Checksum Write Position */
1084
					TcpSumWrite = TcpSumStart + UDP_CSUM_OFFS;
1085
				}
1086
	
1087
				if ((Ctrl) && (pLETab->Bmu.RxTx.TcpWp != TcpSumWrite)) {
1088
					/* Update the last value of the write position */
1089
					pLETab->Bmu.RxTx.TcpWp = TcpSumWrite;
1090
	
1091
					/* Set the Lock field for this LE: */
1092
					/* Checksum calculation for one packet only */
1093
					TXLE_SET_LCKCS(pLE, 1);
1094
	
1095
					/* Set the start position for checksum. */
1096
					TXLE_SET_STACS(pLE, TcpSumStart);
1097
	
1098
					/* Set the position where the checksum will be writen */
1099
					TXLE_SET_WRICS(pLE, TcpSumWrite);
1100
	
1101
					/* Set the initial value for checksum */
1102
					/* PseudoHeader CS passed from Linux -> 0! */
1103
					TXLE_SET_INICS(pLE, 0);
1104
	
1105
					/* Set the opcode for tcp checksum */
1106
					TXLE_SET_OPC(pLE, OP_TCPLISW | HW_OWNER);
1107
	
1108
					/* Flush the LE to memory */
1109
					FLUSH_OPC(pLE);
1110
	
1111
					/* get a new LE because we filled one with data for checksum */
1112
					GET_TX_LE(pLE, pLETab);
1113
				}
1114
			} /* end TCP offload handling */
1115
	
1116
			TXLE_SET_ADDR(pLE, LowAddress);
1117
			TXLE_SET_LEN(pLE, pFrag->FragLen);
1118
	
1119
			if (SetOpcodePacketFlag){
1120
#ifdef NETIF_F_TSO
1121
				if (Mss) {
1122
					OpCode = OP_LARGESEND | HW_OWNER;
1123
				} else {
1124
#endif
1125
					OpCode = OP_PACKET| HW_OWNER;
1126
#ifdef NETIF_F_TSO
1127
				}
1128
#endif
1129
				SetOpcodePacketFlag = SK_FALSE;
1130
			} else {
1131
				/* Follow packet in a sequence has always OP_BUFFER */
1132
				OpCode = OP_BUFFER | HW_OWNER;
1133
			}
1134
	
1135
			pFrag = pFrag->pNext;
1136
			if (pFrag == NULL) {
1137
				/* mark last fragment */
1138
				Ctrl |= EOP;
1139
			}
1140
			TXLE_SET_CTRL(pLE, Ctrl);
1141
			TXLE_SET_OPC(pLE, OpCode);
1142
			FLUSH_OPC(pLE);
1143
			SK_DBG_DUMP_TX_LE(pLE);
1144
		}
1145
	
1146
		/* 
1147
		** Remember next LE for tx complete 
1148
		*/
1149
		pSkPacket->NextLE = GET_PUT_IDX(pLETab);
1150
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1151
			("\tNext LE for pkt %p is %d\n", pSkPacket, pSkPacket->NextLE));
1152
1153
		/* 
1154
		** Add packet to working packets queue 
1155
		*/
1156
		PUSH_PKT_AS_LAST_IN_QUEUE(pWorkQueue, pSkPacket);
1157
1158
		/* 
1159
		** give transmit start command
1160
		*/
1161
		if (HW_FEATURE(pAC, HWF_WA_DEV_42)) {
1162
			spin_lock(&pAC->SetPutIndexLock);
1163
			SkGeY2SetPutIndex(pAC, pAC->IoBase, Y2_PREF_Q_ADDR(Q_XA1,0), &pAC->TxPort[0][0].TxALET);
1164
			spin_unlock(&pAC->SetPutIndexLock);
1165
		} else {
1166
			/* write put index */
1167
			if (Port == 0) { 
1168
				SK_OUT32(pAC->IoBase, 
1169
					Y2_PREF_Q_ADDR(Q_XA1,PREF_UNIT_PUT_IDX_REG), 
1170
					GET_PUT_IDX(&pAC->TxPort[0][0].TxALET)); 
1171
				UPDATE_HWPUT_IDX(&pAC->TxPort[0][0].TxALET);
1172
			} else {
1173
				SK_OUT32(pAC->IoBase, 
1174
					Y2_PREF_Q_ADDR(Q_XA2, PREF_UNIT_PUT_IDX_REG), 
1175
					GET_PUT_IDX(&pAC->TxPort[1][0].TxALET)); 
1176
				UPDATE_HWPUT_IDX(&pAC->TxPort[1][0].TxALET);
1177
			}
1178
		}
1179
	
1180
		if (IS_Q_EMPTY(&(pAC->TxPort[Port][TX_PRIO_LOW].TxAQ_waiting))) {
1181
			break; /* get out of while */
1182
		}
1183
		POP_FIRST_PKT_FROM_QUEUE(pWaitQueue, pSkPacket);
1184
	} /* while (pSkPacket != NULL) */
1185
1186
	spin_unlock_irqrestore(&pAC->TxQueueLock, LockFlag);
1187
1188
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1189
		("<== GiveTxBufferToHw\n"));
1190
	return;
1191
}	/* GiveTxBufferToHw */
1192
1193
/***********************************************************************
1194
 *
1195
 *	GiveRxBufferToHw - commits a previously allocated DMA area to HW
1196
 *
1197
 * Description:
1198
 *	This functions gives receive buffers to HW. If no list elements
1199
 *	are available the buffers will be queued. 
1200
 *
1201
 * Notes:
1202
 *       This function can run only once in a system at one time.
1203
 *
1204
 * Returns: N/A
1205
 */
1206
static void GiveRxBufferToHw(
1207
SK_AC      *pAC,      /* pointer to adapter control context         */
1208
SK_IOC      IoC,      /* I/O control context (address of registers) */
1209
int         Port,     /* port index for which the buffer is used    */
1210
SK_PACKET  *pPacket)  /* receive buffer(s)                          */
1211
{
1212
	SK_HWLE         *pLE;
1213
	SK_LE_TABLE     *pLETab;
1214
	SK_BOOL         Done = SK_FALSE;  /* at least on LE changed? */
1215
	SK_U32          LowAddress;
1216
	SK_U32          HighAddress;
1217
	SK_U32          PrefetchReg;      /* register for Put index  */
1218
	unsigned        NumFree;
1219
	unsigned        Required;
1220
	unsigned long   Flags;
1221
#if defined(__x86_64__)
1222
	long            cache0, cache1;
1223
#endif
1224
1225
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1226
	("==> GiveRxBufferToHw(Port %c, Packet %p)\n", 'A' + Port, pPacket));
1227
1228
	pLETab	= &pAC->RxPort[Port].RxLET;
1229
1230
	if (Port == 0) {
1231
		PrefetchReg = Y2_PREF_Q_ADDR(Q_R1, PREF_UNIT_PUT_IDX_REG);
1232
	} else {
1233
		PrefetchReg = Y2_PREF_Q_ADDR(Q_R2, PREF_UNIT_PUT_IDX_REG);
1234
	} 
1235
1236
	if (pPacket != NULL) {
1237
		/*
1238
		** For the time being, we have only one packet passed
1239
		** to this function which might be changed in future!
1240
		*/
1241
		PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pPacket);
1242
	}
1243
1244
	/* 
1245
	** now pPacket contains the very first waiting packet
1246
	*/
1247
	POP_FIRST_PKT_FROM_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pPacket);
1248
	while (pPacket != NULL) {
1249
		if (HW_FEATURE(pAC, HWF_WA_DEV_420)) {
1250
			if (NbrRxBuffersInHW >= MAX_NBR_RX_BUFFERS_IN_HW) {
1251
				PUSH_PKT_AS_FIRST_IN_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pPacket);
1252
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1253
					("<== GiveRxBufferToHw()\n"));
1254
				return;
1255
			} 
1256
			NbrRxBuffersInHW++;
1257
		}
1258
1259
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1260
			("Try to add packet %p\n", pPacket));
1261
1262
		/* 
1263
		** Check whether we have enough listelements:
1264
		**
1265
		** we have to take into account that each fragment 
1266
		** may need an additional list element for the high 
1267
		** part of the address here I simplified it by 
1268
		** using MAX_FRAG_OVERHEAD maybe it's worth to split 
1269
		** this constant for Rx and Tx or to calculate the
1270
		** real number of needed LE's
1271
		*/
1272
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1273
			("\tNum %d Put %d Done %d Free %d %d\n",
1274
			pLETab->Num, pLETab->Put, pLETab->Done,
1275
			NUM_FREE_LE_IN_TABLE(pLETab),
1276
			(NUM_FREE_LE_IN_TABLE(pLETab))));
1277
1278
		Required = pPacket->NumFrags + MAX_FRAG_OVERHEAD;
1279
		NumFree = NUM_FREE_LE_IN_TABLE(pLETab);
1280
		if (NumFree) {
1281
			NumFree--;
1282
		}
1283
1284
		if (Required > NumFree ) {
1285
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
1286
				SK_DBGCAT_DRV_RX_PROGRESS | SK_DBGCAT_DRV_ERROR,
1287
				("\tOut of LEs have %d need %d\n",
1288
				NumFree, Required));
1289
1290
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1291
				("\tWaitQueue starts with packet %p\n", pPacket));
1292
			PUSH_PKT_AS_FIRST_IN_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pPacket);
1293
			if (Done) {
1294
				/*
1295
				** write Put index to BMU or Polling Unit and make the LE's
1296
				** available for the hardware
1297
				*/
1298
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1299
					("\tWrite new Put Idx\n"));
1300
1301
				SK_OUT32(IoC, PrefetchReg, GET_PUT_IDX(pLETab));
1302
				UPDATE_HWPUT_IDX(pLETab);
1303
			}
1304
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1305
				("<== GiveRxBufferToHw()\n"));
1306
			return;
1307
		} else {
1308
			if (!AllocAndMapRxBuffer(pAC, pPacket, Port)) {
1309
				/*
1310
				** Failure while allocating sk_buff might
1311
				** be due to temporary short of resources
1312
				** Maybe next time buffers are available.
1313
				** Until this, the packet remains in the 
1314
				** RX waiting queue...
1315
				*/
1316
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
1317
					SK_DBGCAT_DRV_RX_PROGRESS | SK_DBGCAT_DRV_ERROR,
1318
					("Failed to allocate Rx buffer\n"));
1319
1320
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1321
					("WaitQueue starts with packet %p\n", pPacket));
1322
				PUSH_PKT_AS_FIRST_IN_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pPacket);
1323
				if (Done) {
1324
					/*
1325
					** write Put index to BMU or Polling 
1326
					** Unit and make the LE's
1327
					** available for the hardware
1328
					*/
1329
					SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1330
						("\tWrite new Put Idx\n"));
1331
	
1332
					SK_OUT32(IoC, PrefetchReg, GET_PUT_IDX(pLETab));
1333
					UPDATE_HWPUT_IDX(pLETab);
1334
				}
1335
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1336
					("<== GiveRxBufferToHw()\n"));
1337
				return;
1338
			}
1339
		}
1340
		Done = SK_TRUE;
1341
1342
		LowAddress = (SK_U32) (pPacket->pFrag->pPhys & 0xffffffff);
1343
		HighAddress = (SK_U32) (pPacket->pFrag->pPhys >> 32);
1344
		if (HighAddress != pLETab->BufHighAddr) {
1345
			/* get a new LE for high address */
1346
			GET_RX_LE(pLE, pLETab);
1347
1348
			/* Set now the 32 high bits of the address */
1349
			RXLE_SET_ADDR(pLE, HighAddress);
1350
1351
			/* Set the control bits of the address */
1352
			RXLE_SET_CTRL(pLE, 0);
1353
1354
			/* Set the opcode into the LE */
1355
			RXLE_SET_OPC(pLE, (OP_ADDR64 | HW_OWNER));
1356
1357
			/* Flush the LE to memory */
1358
			FLUSH_OPC(pLE);
1359
1360
			/* remember the HighAddress we gave to the Hardware */
1361
			pLETab->BufHighAddr = HighAddress;
1362
		}
1363
1364
		/*
1365
		** Fill data into listelement
1366
		*/
1367
		GET_RX_LE(pLE, pLETab);
1368
		RXLE_SET_ADDR(pLE, LowAddress);
1369
		RXLE_SET_LEN(pLE, pPacket->pFrag->FragLen);
1370
		RXLE_SET_CTRL(pLE, 0);
1371
		RXLE_SET_OPC(pLE, (OP_PACKET | HW_OWNER));
1372
		FLUSH_OPC(pLE);
1373
1374
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1375
			("=== LE filled\n"));
1376
1377
		SK_DBG_DUMP_RX_LE(pLE);
1378
1379
		/* 
1380
		** Remember next LE for rx complete 
1381
		*/
1382
		pPacket->NextLE = GET_PUT_IDX(pLETab);
1383
1384
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1385
			("\tPackets Next LE is %d\n", pPacket->NextLE));
1386
1387
		/* 
1388
		** Add packet to working receive buffer queue and get
1389
		** any next packet out of the waiting queue
1390
		*/
1391
		PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->RxPort[Port].RxQ_working, pPacket);
1392
		if (IS_Q_EMPTY(&(pAC->RxPort[Port].RxQ_waiting))) {
1393
			break; /* get out of while processing */
1394
		}
1395
		POP_FIRST_PKT_FROM_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pPacket);
1396
	}
1397
1398
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1399
		("\tWaitQueue is empty\n"));
1400
1401
	if (Done) {
1402
		/*
1403
		** write Put index to BMU or Polling Unit and make the LE's
1404
		** available for the hardware
1405
		*/
1406
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1407
			("\tWrite new Put Idx\n"));
1408
1409
		/* Speed enhancement for a2 chipsets */
1410
		if (HW_FEATURE(pAC, HWF_WA_DEV_42)) {
1411
			spin_lock_irqsave(&pAC->SetPutIndexLock, Flags);
1412
			SkGeY2SetPutIndex(pAC, pAC->IoBase, Y2_PREF_Q_ADDR(Q_R1,0), pLETab);
1413
			spin_unlock_irqrestore(&pAC->SetPutIndexLock, Flags);
1414
		} else {
1415
			/* write put index */
1416
			if (Port == 0) { 
1417
				SK_OUT32(IoC, 
1418
					Y2_PREF_Q_ADDR(Q_R1, PREF_UNIT_PUT_IDX_REG), 
1419
					GET_PUT_IDX(pLETab)); 
1420
			} else {
1421
				SK_OUT32(IoC, 
1422
					Y2_PREF_Q_ADDR(Q_R2, PREF_UNIT_PUT_IDX_REG), 
1423
					GET_PUT_IDX(pLETab)); 
1424
			}
1425
1426
			/* Update put index */
1427
			UPDATE_HWPUT_IDX(pLETab);
1428
		}
1429
	}
1430
1431
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1432
		("<== GiveRxBufferToHw()\n"));
1433
}       /* GiveRxBufferToHw */
1434
1435
/***********************************************************************
1436
 *
1437
 *	FillReceiveTableYukon2 - map any waiting RX buffers to HW
1438
 *
1439
 * Description:
1440
 *	If the list element table contains more empty elements than 
1441
 *	specified this function tries to refill them.
1442
 *
1443
 * Notes:
1444
 *       This function can run only once per port in a system at one time.
1445
 *
1446
 * Returns: N/A
1447
 */
1448
static void FillReceiveTableYukon2(
1449
SK_AC   *pAC,   /* pointer to adapter control context */
1450
SK_IOC   IoC,   /* I/O control context                */
1451
int      Port)  /* port index of RX                   */
1452
{
1453
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1454
		("==> FillReceiveTableYukon2 (Port %c)\n", 'A' + Port));
1455
1456
	if (NUM_FREE_LE_IN_TABLE(&pAC->RxPort[Port].RxLET) >
1457
		pAC->MaxUnusedRxLeWorking) {
1458
1459
		/* 
1460
		** Give alle waiting receive buffers down 
1461
		** The queue holds all RX packets that
1462
		** need a fresh allocation of the sk_buff.
1463
		*/
1464
		if (pAC->RxPort[Port].RxQ_waiting.pHead != NULL) {
1465
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1466
			("Waiting queue is not empty -> give it to HW"));
1467
			GiveRxBufferToHw(pAC, IoC, Port, NULL);
1468
		}
1469
	}
1470
1471
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1472
		("<== FillReceiveTableYukon2 ()\n"));
1473
}	/* FillReceiveTableYukon2 */
1474
1475
/******************************************************************************
1476
 *
1477
 *
1478
 *	HandleReceives - will pass any ready RX packet to kernel
1479
 *
1480
 * Description:
1481
 *	This functions handles a received packet. It checks wether it is
1482
 *	valid, updates the receive list element table and gives the receive
1483
 *	buffer to Linux
1484
 *
1485
 * Notes:
1486
 *	This function can run only once per port at one time in the system.
1487
 *
1488
 * Returns: N/A
1489
 */
1490
static SK_BOOL HandleReceives(
1491
SK_AC  *pAC,          /* adapter control context                     */
1492
int     Port,         /* port on which a packet has been received    */
1493
SK_U16  Len,          /* number of bytes which was actually received */
1494
SK_U32  FrameStatus,  /* MAC frame status word                       */
1495
SK_U16  Tcp1,         /* first hw checksum                           */
1496
SK_U16  Tcp2,         /* second hw checksum                          */
1497
SK_U32  Tist,         /* timestamp                                   */
1498
SK_U16  Vlan)         /* Vlan Id                                     */
1499
{
1500
1501
	SK_PACKET       *pSkPacket;
1502
	SK_LE_TABLE     *pLETab;
1503
	SK_MBUF         *pRlmtMbuf;  /* buffer for giving RLMT frame */
1504
	struct sk_buff  *pMsg;       /* ptr to message holding frame */
1505
#ifdef __ia64__
1506
	struct sk_buff  *pNewMsg;    /* used when IP aligning        */
1507
#endif
1508
		
1509
#ifdef CONFIG_SK98LIN_NAPI
1510
	SK_BOOL         SlowPathLock = SK_FALSE;
1511
#else
1512
	SK_BOOL         SlowPathLock = SK_TRUE;
1513
#endif
1514
	SK_BOOL         IsGoodPkt;
1515
	SK_BOOL         IsBc;
1516
	SK_BOOL         IsMc;
1517
	SK_EVPARA       EvPara;      /* an event parameter union     */
1518
	SK_I16          LenToFree;   /* must be signed integer       */
1519
1520
	unsigned long   Flags;       /* for spin lock                */
1521
	unsigned int    RlmtNotifier;
1522
	unsigned short  Type;
1523
	int             IpFrameLength;
1524
	int             FrameLength; /* total length of recvd frame  */
1525
	int             HeaderLength;
1526
	int             NumBytes; 
1527
	int             Result;
1528
	int             Offset = 0;
1529
1530
#ifdef Y2_SYNC_CHECK
1531
	SK_U16		MyTcp;
1532
#endif
1533
1534
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1535
		("==> HandleReceives (Port %c)\n", 'A' + Port));
1536
1537
	/* 
1538
	** initialize vars for selected port 
1539
	*/
1540
	pLETab = &pAC->RxPort[Port].RxLET;
1541
1542
	/* 
1543
	** check whether we want to receive this packet 
1544
	*/
1545
	SK_Y2_RXSTAT_CHECK_PKT(Len, FrameStatus, IsGoodPkt);
1546
1547
	/*
1548
	** Remember length to free (in case of RxBuffer overruns;
1549
	** unlikely, but might happen once in a while)
1550
	*/
1551
	LenToFree = (SK_I16) Len;
1552
1553
	/* 
1554
	** maybe we put these two checks into the SK_RXDESC_CHECK_PKT macro too 
1555
	*/
1556
	if (Len > pAC->RxBufSize) {
1557
		IsGoodPkt = SK_FALSE;
1558
	}
1559
1560
	/*
1561
	** take first receive buffer out of working queue 
1562
	*/
1563
	POP_FIRST_PKT_FROM_QUEUE(&pAC->RxPort[Port].RxQ_working, pSkPacket);
1564
	if (pSkPacket == NULL) {
1565
 		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
1566
			SK_DBGCAT_DRV_ERROR,
1567
			("Packet not available. NULL pointer.\n"));
1568
		return(SK_TRUE);
1569
	}
1570
1571
	if (HW_FEATURE(pAC, HWF_WA_DEV_420)) {
1572
		NbrRxBuffersInHW--;
1573
	}
1574
1575
	/* 
1576
	** Verify the received length of the frame! Note that having 
1577
	** multiple RxBuffers being aware of one single receive packet
1578
	** (one packet spread over multiple RxBuffers) is not supported 
1579
	** by this driver!
1580
	*/
1581
	if ((Len > pAC->RxBufSize) || (Len > (SK_U16) pSkPacket->PacketLen)) {
1582
		IsGoodPkt = SK_FALSE;
1583
	}
1584
1585
	/* 
1586
	** Reset own bit in LE's between old and new Done index
1587
	** This is not really necessary but makes debugging easier 
1588
	*/
1589
	CLEAR_LE_OWN_FROM_DONE_TO(pLETab, pSkPacket->NextLE);
1590
1591
	/* 
1592
	** Free the list elements for new Rx buffers 
1593
	*/
1594
	SET_DONE_INDEX(pLETab, pSkPacket->NextLE);
1595
	pMsg = pSkPacket->pMBuf;
1596
	FrameLength = Len;
1597
1598
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1599
		("Received frame of length %d on port %d\n",FrameLength, Port));
1600
1601
	if (!IsGoodPkt) {
1602
		/* 
1603
		** release the DMA mapping 
1604
		*/
1605
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
1606
 		pci_dma_sync_single(pAC->PciDev,
1607
				(dma_addr_t) pSkPacket->pFrag->pPhys,
1608
				pSkPacket->pFrag->FragLen,
1609
				PCI_DMA_FROMDEVICE);
1610
1611
#else
1612
		pci_dma_sync_single_for_cpu(pAC->PciDev,
1613
				(dma_addr_t) pSkPacket->pFrag->pPhys,
1614
				pSkPacket->pFrag->FragLen,
1615
				PCI_DMA_FROMDEVICE);
1616
#endif
1617
1618
		DEV_KFREE_SKB_ANY(pSkPacket->pMBuf);
1619
		PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pSkPacket);
1620
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1621
			("<== HandleReceives (Port %c)\n", 'A' + Port));
1622
1623
		/*
1624
		** Sanity check for RxBuffer overruns...
1625
		*/
1626
		LenToFree = LenToFree - (pSkPacket->pFrag->FragLen);
1627
		while (LenToFree > 0) {
1628
			POP_FIRST_PKT_FROM_QUEUE(&pAC->RxPort[Port].RxQ_working, pSkPacket);
1629
			if (HW_FEATURE(pAC, HWF_WA_DEV_420)) {
1630
				NbrRxBuffersInHW--;
1631
			}
1632
			CLEAR_LE_OWN_FROM_DONE_TO(pLETab, pSkPacket->NextLE);
1633
			SET_DONE_INDEX(pLETab, pSkPacket->NextLE);
1634
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
1635
			pci_dma_sync_single(pAC->PciDev,
1636
					(dma_addr_t) pSkPacket->pFrag->pPhys,
1637
					pSkPacket->pFrag->FragLen,
1638
					PCI_DMA_FROMDEVICE);
1639
#else
1640
			pci_dma_sync_single_for_device(pAC->PciDev,
1641
					(dma_addr_t) pSkPacket->pFrag->pPhys,
1642
					pSkPacket->pFrag->FragLen,
1643
					PCI_DMA_FROMDEVICE); 
1644
#endif
1645
1646
			DEV_KFREE_SKB_ANY(pSkPacket->pMBuf);
1647
			PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pSkPacket);
1648
			LenToFree = LenToFree - ((SK_I16)(pSkPacket->pFrag->FragLen));
1649
			
1650
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV,
1651
				SK_DBGCAT_DRV_RX_PROGRESS | SK_DBGCAT_DRV_ERROR,
1652
				("<==HandleReceives (Port %c) drop faulty len pkt(2)\n",'A'+Port));
1653
		}
1654
		return(SK_TRUE);
1655
	} else {
1656
		/* 
1657
		** Release the DMA mapping 
1658
		*/
1659
		pci_unmap_single(pAC->PciDev,
1660
				 pSkPacket->pFrag->pPhys,
1661
				 pAC->RxBufSize,
1662
				 PCI_DMA_FROMDEVICE);
1663
1664
		skb_put(pMsg, FrameLength);		/* set message len */
1665
		pMsg->ip_summed = CHECKSUM_NONE;	/* initial default */
1666
1667
#ifdef Y2_SYNC_CHECK
1668
		pAC->FramesWithoutSyncCheck++;
1669
		if (pAC->FramesWithoutSyncCheck > Y2_RESYNC_WATERMARK) {
1670
			if ((Tcp1 != 1) && (Tcp2 != 0)) {
1671
				pAC->FramesWithoutSyncCheck = 0;
1672
				MyTcp = (SK_U16) SkCsCalculateChecksum(
1673
						&pMsg->data[14],
1674
						FrameLength - 14);
1675
				if (MyTcp != Tcp1) {
1676
					/* Queue port reset event */
1677
					SkLocalEventQueue(pAC, SKGE_DRV,
1678
					SK_DRV_RECOVER,Port,-1,SK_FALSE);
1679
				}
1680
			}
1681
		}
1682
#endif
1683
1684
		if (pAC->RxPort[Port].UseRxCsum) {
1685
			Type = ntohs(*((short*)&pMsg->data[12]));
1686
			if (Type == 0x800) {
1687
				*((char *)&(IpFrameLength)) = pMsg->data[16];
1688
				*(((char *)&(IpFrameLength))+1) = pMsg->data[17];
1689
				IpFrameLength = ntohs(IpFrameLength);
1690
				HeaderLength  = FrameLength - IpFrameLength;
1691
				if (HeaderLength == 0xe) {
1692
					Result = 
1693
					    SkCsGetReceiveInfo(pAC,&pMsg->data[14],Tcp1,Tcp2, Port);
1694
					if ((Result == SKCS_STATUS_IP_FRAGMENT) ||
1695
					    (Result == SKCS_STATUS_IP_CSUM_OK)  ||
1696
					    (Result == SKCS_STATUS_TCP_CSUM_OK) ||
1697
					    (Result == SKCS_STATUS_UDP_CSUM_OK)) {
1698
						pMsg->ip_summed = CHECKSUM_UNNECESSARY;
1699
					} else if ((Result == SKCS_STATUS_TCP_CSUM_ERROR)    ||
1700
					           (Result == SKCS_STATUS_UDP_CSUM_ERROR)    ||
1701
					           (Result == SKCS_STATUS_IP_CSUM_ERROR_UDP) ||
1702
					           (Result == SKCS_STATUS_IP_CSUM_ERROR_TCP) ||
1703
					           (Result == SKCS_STATUS_IP_CSUM_ERROR)) {
1704
						SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1705
							SK_DBGCAT_DRV_RX_PROGRESS | SK_DBGCAT_DRV_ERROR,
1706
							("skge: CRC error. Frame dropped!\n"));
1707
						DEV_KFREE_SKB_ANY(pMsg);
1708
						PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pSkPacket);
1709
						SK_DBG_MSG(pAC,SK_DBGMOD_DRV,SK_DBGCAT_DRV_RX_PROGRESS,
1710
							("<==HandleReceives(Port %c)\n",'A'+Port));
1711
						return(SK_TRUE);
1712
					} else {
1713
						pMsg->ip_summed = CHECKSUM_NONE;
1714
					}
1715
				} /* end if (HeaderLength == valid) */
1716
			} /* end if (Type == 0x800) -> IP frame */
1717
		} /* end if (pRxPort->UseRxCsum) */
1718
		
1719
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1720
			SK_DBGCAT_DRV_RX_PROGRESS,("V"));
1721
		RlmtNotifier = SK_RLMT_RX_PROTOCOL;
1722
1723
		IsBc = (FrameStatus & GMR_FS_BC) ? SK_TRUE : SK_FALSE;
1724
		SK_RLMT_PRE_LOOKAHEAD(pAC,Port,FrameLength,
1725
					IsBc,&Offset,&NumBytes);
1726
		if (NumBytes != 0) {
1727
			IsMc = (FrameStatus & GMR_FS_MC) ? SK_TRUE : SK_FALSE;
1728
			SK_RLMT_LOOKAHEAD(pAC,Port,&pMsg->data[Offset],
1729
						IsBc,IsMc,&RlmtNotifier);
1730
		}
1731
1732
		if (RlmtNotifier == SK_RLMT_RX_PROTOCOL) {
1733
			SK_DBG_MSG(NULL,SK_DBGMOD_DRV,
1734
				SK_DBGCAT_DRV_RX_PROGRESS,("W"));
1735
			if ((Port == pAC->ActivePort)||(pAC->RlmtNets == 2)) {
1736
				/* send up only frames from active port */
1737
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1738
					SK_DBGCAT_DRV_RX_PROGRESS,("U"));
1739
#ifdef xDEBUG
1740
				DumpMsg(pMsg, "Rx");
1741
#endif
1742
				SK_PNMI_CNT_RX_OCTETS_DELIVERED(pAC,
1743
					FrameLength, Port);
1744
#ifdef __ia64__
1745
				pNewMsg = alloc_skb(pMsg->len, GFP_ATOMIC);
1746
				skb_reserve(pNewMsg, 2); /* to align IP */
1747
				SK_MEMCPY(pNewMsg->data,pMsg->data,pMsg->len);
1748
				pNewMsg->ip_summed = pMsg->ip_summed;
1749
				pNewMsg->len = pMsg->len;
1750
				DEV_KFREE_SKB_ANY(pMsg);
1751
				pMsg = pNewMsg;
1752
#endif
1753
				pMsg->dev = pAC->dev[Port];
1754
				pMsg->protocol = eth_type_trans(pMsg,
1755
					pAC->dev[Port]);
1756
				netif_rx(pMsg);
1757
				pAC->dev[Port]->last_rx = jiffies;
1758
			} else { /* drop frame */
1759
				SK_DBG_MSG(NULL,SK_DBGMOD_DRV,
1760
					SK_DBGCAT_DRV_RX_PROGRESS,("D"));
1761
				DEV_KFREE_SKB_ANY(pMsg);
1762
			}
1763
		} else { /* This is an RLMT-packet! */
1764
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1765
				SK_DBGCAT_DRV_RX_PROGRESS,("R"));
1766
			pRlmtMbuf = SkDrvAllocRlmtMbuf(pAC,
1767
				pAC->IoBase, FrameLength);
1768
			if (pRlmtMbuf != NULL) {
1769
				pRlmtMbuf->pNext = NULL;
1770
				pRlmtMbuf->Length = FrameLength;
1771
				pRlmtMbuf->PortIdx = Port;
1772
				EvPara.pParaPtr = pRlmtMbuf;
1773
				SK_MEMCPY((char*)(pRlmtMbuf->pData),
1774
				          (char*)(pMsg->data),FrameLength);
1775
1776
				if (SlowPathLock == SK_TRUE) {
1777
					spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1778
					SkEventQueue(pAC, SKGE_RLMT,
1779
						SK_RLMT_PACKET_RECEIVED,
1780
						EvPara);
1781
					pAC->CheckQueue = SK_TRUE;
1782
					spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1783
				} else {
1784
					SkEventQueue(pAC, SKGE_RLMT,
1785
						SK_RLMT_PACKET_RECEIVED,
1786
						EvPara);
1787
					pAC->CheckQueue = SK_TRUE;
1788
				}
1789
1790
				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1791
					SK_DBGCAT_DRV_RX_PROGRESS,("Q"));
1792
			}
1793
			if (pAC->dev[Port]->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
1794
#ifdef __ia64__
1795
				pNewMsg = alloc_skb(pMsg->len, GFP_ATOMIC);
1796
				skb_reserve(pNewMsg, 2); /* to align IP */
1797
				SK_MEMCPY(pNewMsg->data,pMsg->data,pMsg->len);
1798
				pNewMsg->ip_summed = pMsg->ip_summed;
1799
				pNewMsg->len = pMsg->len;
1800
				DEV_KFREE_SKB_ANY(pMsg);
1801
				pMsg = pNewMsg;
1802
#endif
1803
				pMsg->dev = pAC->dev[Port];
1804
				pMsg->protocol = eth_type_trans(pMsg,pAC->dev[Port]);
1805
				netif_rx(pMsg);
1806
				pAC->dev[Port]->last_rx = jiffies;
1807
			} else {
1808
				DEV_KFREE_SKB_ANY(pMsg);
1809
			}
1810
		} /* if packet for rlmt */
1811
		PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->RxPort[Port].RxQ_waiting, pSkPacket);
1812
	} /* end if-else (IsGoodPkt) */
1813
1814
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
1815
		("<== HandleReceives (Port %c)\n", 'A' + Port));
1816
	return(SK_TRUE);
1817
1818
}	/* HandleReceives */
1819
1820
/***********************************************************************
1821
 *
1822
 * 	CheckForSendComplete - Frees any freeable Tx bufffer 
1823
 *
1824
 * Description:
1825
 *	This function checks the queues of a port for completed send
1826
 *	packets and returns these packets back to the OS.
1827
 *
1828
 * Notes:
1829
 *	This function can run simultaneously for both ports if
1830
 *	the OS function OSReturnPacket() can handle this,
1831
 *
1832
 *	Such a send complete does not mean, that the packet is really
1833
 *	out on the wire. We just know that the adapter has copied it
1834
 *	into its internal memory and the buffer in the systems memory
1835
 *	is no longer needed.
1836
 *
1837
 * Returns: N/A
1838
 */
1839
static void CheckForSendComplete(
1840
SK_AC         *pAC,     /* pointer to adapter control context  */
1841
SK_IOC         IoC,     /* I/O control context                 */
1842
int            Port,    /* port index                          */
1843
SK_PKT_QUEUE  *pPQ,     /* tx working packet queue to check    */
1844
SK_LE_TABLE   *pLETab,  /* corresponding list element table    */
1845
unsigned int   Done)    /* done index reported for this LET    */
1846
{
1847
	SK_PACKET       *pSkPacket;
1848
	SK_PKT_QUEUE     SendCmplPktQ = { NULL, NULL, SPIN_LOCK_UNLOCKED };
1849
	SK_BOOL          DoWakeQueue  = SK_FALSE;
1850
	unsigned long    Flags;
1851
	unsigned         Put;
1852
	
1853
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1854
		("==> CheckForSendComplete(Port %c)\n", 'A' + Port));
1855
1856
	/* 
1857
	** Reset own bit in LE's between old and new Done index
1858
	** This is not really necessairy but makes debugging easier 
1859
	*/
1860
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1861
		("Clear Own Bits in TxTable from %d to %d\n",
1862
		pLETab->Done, (Done == 0) ?
1863
		NUM_LE_IN_TABLE(pLETab) :
1864
		(Done - 1)));
1865
1866
	spin_lock_irqsave(&(pPQ->QueueLock), Flags);
1867
1868
	CLEAR_LE_OWN_FROM_DONE_TO(pLETab, Done);
1869
1870
	Put = GET_PUT_IDX(pLETab);
1871
1872
	/* 
1873
	** Check whether some packets have been completed 
1874
	*/
1875
	PLAIN_POP_FIRST_PKT_FROM_QUEUE(pPQ, pSkPacket);
1876
	while (pSkPacket != NULL) {
1877
		
1878
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1879
			("Check Completion of Tx packet %p\n", pSkPacket));
1880
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1881
			("Put %d NewDone %d NextLe of Packet %d\n", Put, Done,
1882
			pSkPacket->NextLE));
1883
1884
		if ((Put > Done) &&
1885
			((pSkPacket->NextLE > Put) || (pSkPacket->NextLE <= Done))) {
1886
			PLAIN_PUSH_PKT_AS_LAST_IN_QUEUE(&SendCmplPktQ, pSkPacket);
1887
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1888
				("Packet finished (a)\n"));
1889
		} else if ((Done > Put) &&
1890
			(pSkPacket->NextLE > Put) && (pSkPacket->NextLE <= Done)) {
1891
			PLAIN_PUSH_PKT_AS_LAST_IN_QUEUE(&SendCmplPktQ, pSkPacket);
1892
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1893
				("Packet finished (b)\n"));
1894
		} else if ((Done == TXA_MAX_LE-1) && (Put == 0) && (pSkPacket->NextLE == 0)) {
1895
			PLAIN_PUSH_PKT_AS_LAST_IN_QUEUE(&SendCmplPktQ, pSkPacket);
1896
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1897
				("Packet finished (b)\n"));
1898
			DoWakeQueue = SK_TRUE;
1899
		} else if (Done == Put) {
1900
			/* all packets have been sent */
1901
			PLAIN_PUSH_PKT_AS_LAST_IN_QUEUE(&SendCmplPktQ, pSkPacket);
1902
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1903
				("Packet finished (c)\n"));
1904
		} else {
1905
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1906
				("Packet not yet finished\n"));
1907
			PLAIN_PUSH_PKT_AS_FIRST_IN_QUEUE(pPQ, pSkPacket);
1908
			break;
1909
		}
1910
		PLAIN_POP_FIRST_PKT_FROM_QUEUE(pPQ, pSkPacket);
1911
	}
1912
	spin_unlock_irqrestore(&(pPQ->QueueLock), Flags);
1913
1914
	/* 
1915
	** Set new done index in list element table
1916
	*/
1917
	SET_DONE_INDEX(pLETab, Done);
1918
	 
1919
	/*
1920
	** All TX packets that are send complete should be added to
1921
	** the free queue again for new sents to come
1922
	*/
1923
	pSkPacket = SendCmplPktQ.pHead;
1924
	while (pSkPacket != NULL) {
1925
		while (pSkPacket->pFrag != NULL) {
1926
			pci_unmap_page(pAC->PciDev,
1927
					(dma_addr_t) pSkPacket->pFrag->pPhys,
1928
					pSkPacket->pFrag->FragLen,
1929
					PCI_DMA_FROMDEVICE);
1930
			pSkPacket->pFrag = pSkPacket->pFrag->pNext;
1931
		}
1932
1933
		DEV_KFREE_SKB_ANY(pSkPacket->pMBuf);
1934
		pSkPacket->pMBuf	= NULL;
1935
		pSkPacket = pSkPacket->pNext; /* get next packet */
1936
	}
1937
1938
	/*
1939
	** Append the available TX packets back to free queue
1940
	*/
1941
	if (SendCmplPktQ.pHead != NULL) { 
1942
		spin_lock_irqsave(&(pAC->TxPort[Port][0].TxQ_free.QueueLock), Flags);
1943
		if (pAC->TxPort[Port][0].TxQ_free.pTail != NULL) {
1944
			pAC->TxPort[Port][0].TxQ_free.pTail->pNext = SendCmplPktQ.pHead;
1945
			pAC->TxPort[Port][0].TxQ_free.pTail        = SendCmplPktQ.pTail;
1946
			if (pAC->TxPort[Port][0].TxQ_free.pHead->pNext == NULL) {
1947
				netif_wake_queue(pAC->dev[Port]);
1948
			}
1949
		} else {
1950
			pAC->TxPort[Port][0].TxQ_free.pHead = SendCmplPktQ.pHead;
1951
			pAC->TxPort[Port][0].TxQ_free.pTail = SendCmplPktQ.pTail; 
1952
			netif_wake_queue(pAC->dev[Port]);
1953
		}
1954
		if (Done == Put) {
1955
			netif_wake_queue(pAC->dev[Port]);
1956
		}
1957
		if (DoWakeQueue) {
1958
			netif_wake_queue(pAC->dev[Port]);
1959
			DoWakeQueue = SK_FALSE;
1960
		}
1961
		spin_unlock_irqrestore(&pAC->TxPort[Port][0].TxQ_free.QueueLock, Flags);
1962
	}
1963
1964
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1965
		("<== CheckForSendComplete()\n"));
1966
1967
	return;
1968
}	/* CheckForSendComplete */
1969
1970
/*****************************************************************************
1971
 *
1972
 *	UnmapAndFreeTxPktBuffer
1973
 *
1974
 * Description:
1975
 *      This function free any allocated space of receive buffers
1976
 *
1977
 * Arguments:
1978
 *      pAC - A pointer to the adapter context struct.
1979
 *
1980
 */
1981
static void UnmapAndFreeTxPktBuffer(
1982
SK_AC       *pAC,       /* pointer to adapter context             */
1983
SK_PACKET   *pSkPacket,	/* pointer to port struct of ring to fill */
1984
int          TxPort)    /* TX port index                          */
1985
{
1986
	SK_FRAG	 *pFrag = pSkPacket->pFrag;
1987
1988
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1989
		("--> UnmapAndFreeTxPktBuffer\n"));
1990
1991
	while (pFrag != NULL) {
1992
		pci_unmap_page(pAC->PciDev,
1993
				(dma_addr_t) pFrag->pPhys,
1994
				pFrag->FragLen,
1995
				PCI_DMA_FROMDEVICE);
1996
		pFrag = pFrag->pNext;
1997
	}
1998
1999
	DEV_KFREE_SKB_ANY(pSkPacket->pMBuf);
2000
	pSkPacket->pMBuf	= NULL;
2001
2002
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
2003
		("<-- UnmapAndFreeTxPktBuffer\n"));
2004
}
2005
2006
/*****************************************************************************
2007
 *
2008
 * 	HandleStatusLEs
2009
 *
2010
 * Description:
2011
 *	This function checks for any new status LEs that may have been 
2012
  *	received. Those status LEs may either be Rx or Tx ones.
2013
 *
2014
 * Returns:	N/A
2015
 */
2016
static SK_BOOL HandleStatusLEs(
2017
#ifdef CONFIG_SK98LIN_NAPI
2018
SK_AC *pAC,       /* pointer to adapter context   */
2019
int   *WorkDone,  /* Done counter needed for NAPI */
2020
int    WorkToDo)  /* ToDo counter for NAPI        */
2021
#else
2022
SK_AC *pAC)       /* pointer to adapter context   */
2023
#endif
2024
{
2025
	int       DoneTxA[SK_MAX_MACS];
2026
	int       DoneTxS[SK_MAX_MACS];
2027
	int       Port;
2028
	SK_BOOL   handledStatLE = SK_FALSE;
2029
	SK_BOOL   NewDone       = SK_FALSE;
2030
	SK_HWLE  *pLE;
2031
	SK_U16    HighVal;
2032
	SK_U32    LowVal;
2033
	SK_U8     OpCode;
2034
	int       i;
2035
2036
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2037
		("==> HandleStatusLEs\n"));
2038
2039
	do {
2040
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2041
			("Check next Own Bit of ST-LE[%d]: 0x%li \n",
2042
			(pAC->StatusLETable.Done + 1) % NUM_LE_IN_TABLE(&pAC->StatusLETable),
2043
			 OWN_OF_FIRST_LE(&pAC->StatusLETable)));
2044
2045
		while (OWN_OF_FIRST_LE(&pAC->StatusLETable) == HW_OWNER) {
2046
			GET_ST_LE(pLE, &pAC->StatusLETable);
2047
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2048
				("Working on finished status LE[%d]:\n",
2049
				GET_DONE_INDEX(&pAC->StatusLETable)));
2050
			SK_DBG_DUMP_ST_LE(pLE);
2051
			handledStatLE = SK_TRUE;
2052
			OpCode = STLE_GET_OPC(pLE) & ~HW_OWNER;
2053
			Port = STLE_GET_LINK(pLE);
2054
2055
#ifdef USE_TIST_FOR_RESET
2056
			if (SK_ADAPTER_WAITING_FOR_TIST(pAC)) {
2057
				/* do we just have a tist LE ? */
2058
				if ((OpCode & OP_RXTIMESTAMP) == OP_RXTIMESTAMP) {
2059
					for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2060
						if (SK_PORT_WAITING_FOR_ANY_TIST(pAC, i)) {
2061
							/* if a port is waiting for any tist it is done */
2062
							SK_CLR_STATE_FOR_PORT(pAC, i);
2063
							SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
2064
								("Got any Tist on port %c (now 0x%X!!!)\n",
2065
								'A' + i, pAC->AdapterResetState));
2066
						}
2067
						if (SK_PORT_WAITING_FOR_SPECIFIC_TIST(pAC, i)) {
2068
							Y2_GET_TIST_LOW_VAL(pAC->IoBase, &LowVal);
2069
							if ((pAC->MinTistHi != pAC->GIni.GITimeStampCnt) ||
2070
								(pAC->MinTistLo < LowVal)) {
2071
								/* time is up now */
2072
								SK_CLR_STATE_FOR_PORT(pAC, i);
2073
								SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
2074
									("Got expected Tist on Port %c (now 0x%X)!!!\n",
2075
									'A' + i, pAC->AdapterResetState));
2076
#ifdef Y2_SYNC_CHECK
2077
								pAC->FramesWithoutSyncCheck =
2078
								Y2_RESYNC_WATERMARK;						
2079
#endif
2080
							} else {
2081
								SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
2082
									("Got Tist %l:%l on Port %c but still waiting\n",
2083
									pAC->GIni.GITimeStampCnt, pAC->MinTistLo,
2084
									'A' + i));
2085
							}
2086
						}
2087
					}
2088
#ifndef Y2_RECOVERY
2089
					if (!SK_ADAPTER_WAITING_FOR_TIST(pAC)) {
2090
						/* nobody needs tist anymore - turn it off */
2091
						Y2_DISABLE_TIST(pAC->IoBase);
2092
						SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
2093
						("Turn off Tist !!!\n"));
2094
					}
2095
#endif
2096
				} else if (OpCode == OP_TXINDEXLE) {
2097
					/*
2098
					 * change OpCode to notify the folowing code
2099
					 * to ignore the done index from this LE
2100
					 * unfortunately tist LEs will be generated only
2101
					 * for RxStat LEs
2102
					 * so in order to get a safe Done index for a
2103
					 * port currently waiting for a tist we have to
2104
					 * get the done index directly from the BMU
2105
					 */
2106
					OpCode = OP_MOD_TXINDEX;
2107
					SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
2108
						("Mark unusable TX_INDEX LE!!!\n"));
2109
				} else {
2110
					if (SK_PORT_WAITING_FOR_TIST(pAC, Port)) {
2111
						SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP, 
2112
							("Ignore LE 0x%X on Port %c!!!\n",
2113
							OpCode, 'A' + Port));
2114
						OpCode = OP_MOD_LE;
2115
#ifdef Y2_LE_CHECK
2116
						/* mark entries invalid */
2117
						pAC->LastOpc = 0xFF;
2118
						pAC->LastPort = 3;
2119
#endif
2120
					}
2121
				}
2122
			} /* if (SK_ADAPTER_WAITING_FOR_TIST(pAC)) */
2123
#endif
2124
2125
2126
2127
2128
2129
#ifdef Y2_LE_CHECK
2130
			if (pAC->LastOpc != 0xFF) {
2131
				/* last opc is valid
2132
				 * check if current opcode follows last opcode
2133
				 */
2134
				if ((((OpCode & OP_RXTIMESTAMP) == OP_RXTIMESTAMP) && (pAC->LastOpc != OP_RXSTAT)) ||
2135
				    (((OpCode & OP_RXCHKS) == OP_RXCHKS) && (pAC->LastOpc != OP_RXTIMESTAMP)) ||
2136
				    ((OpCode == OP_RXSTAT) && (pAC->LastOpc != OP_RXCHKS))) {
2137
2138
					/* opcode sequence broken
2139
					 * current LE is invalid
2140
					 */
2141
2142
					if (pAC->LastOpc == OP_RXTIMESTAMP) {
2143
						/* force invalid checksum */
2144
						pLE->St.StUn.StRxTCPCSum.RxTCPSum1 = 1;
2145
						pLE->St.StUn.StRxTCPCSum.RxTCPSum2 = 0;
2146
						OpCode = pAC->LastOpc = OP_RXCHKS;
2147
						Port = pAC->LastPort;
2148
					} else if (pAC->LastOpc == OP_RXCHKS) {
2149
						/* force invalid frame */
2150
						Port = pAC->LastPort;
2151
						pLE->St.Stat.BufLen = 64;
2152
						pLE->St.StUn.StRxStatWord = GMR_FS_CRC_ERR;
2153
						OpCode = pAC->LastOpc = OP_RXSTAT;
2154
#ifdef Y2_SYNC_CHECK
2155
						/* force rx sync check */
2156
						pAC->FramesWithoutSyncCheck = Y2_RESYNC_WATERMARK;
2157
#endif
2158
					} else if (pAC->LastOpc == OP_RXSTAT) {
2159
						/* create dont care tist */
2160
						pLE->St.StUn.StRxTimeStamp = 0;
2161
						OpCode = pAC->LastOpc = OP_RXTIMESTAMP;
2162
						/* dont know the port yet */
2163
					} else {
2164
#ifdef DEBUG
2165
						SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2166
							("Unknown LastOpc %X for Timestamp on port %c.\n",
2167
							pAC->LastOpc, Port));
2168
#endif
2169
					}
2170
				}
2171
			}
2172
#endif
2173
2174
			switch (OpCode) {
2175
			case OP_RXSTAT:
2176
#ifdef Y2_RECOVERY
2177
				pAC->LastOpc = OP_RXSTAT;
2178
#endif
2179
				/* 
2180
				** This is always the last Status LE belonging
2181
				** to a received packet -> handle it...
2182
				*/
2183
				if ((Port != 0) && (Port != 1)) {
2184
				/* Unknown port */
2185
					panic("sk98lin: Unknown port %d\n",
2186
					Port);
2187
				}
2188
2189
				HandleReceives(
2190
					pAC,
2191
					Port,
2192
					STLE_GET_LEN(pLE),
2193
					STLE_GET_FRSTATUS(pLE),
2194
					pAC->StatusLETable.Bmu.Stat.TcpSum1,
2195
					pAC->StatusLETable.Bmu.Stat.TcpSum2,
2196
					pAC->StatusLETable.Bmu.Stat.RxTimeStamp,
2197
					pAC->StatusLETable.Bmu.Stat.VlanId);
2198
#ifdef CONFIG_SK98LIN_NAPI
2199
				if (*WorkDone >= WorkToDo) {
2200
					break;
2201
				}
2202
				(*WorkDone)++;
2203
#endif
2204
				break;
2205
			case OP_RXVLAN:
2206
				/* this value will be used for next RXSTAT */
2207
				pAC->StatusLETable.Bmu.Stat.VlanId = STLE_GET_VLAN(pLE);
2208
				break;
2209
			case OP_RXTIMEVLAN:
2210
				/* this value will be used for next RXSTAT */
2211
				pAC->StatusLETable.Bmu.Stat.VlanId = STLE_GET_VLAN(pLE);
2212
				/* fall through */
2213
			case OP_RXTIMESTAMP:
2214
				/* this value will be used for next RXSTAT */
2215
				pAC->StatusLETable.Bmu.Stat.RxTimeStamp = STLE_GET_TIST(pLE);
2216
#ifdef Y2_RECOVERY
2217
				pAC->LastOpc = OP_RXTIMESTAMP;
2218
				pAC->LastPort = Port;
2219
#endif
2220
				break;
2221
			case OP_RXCHKSVLAN:
2222
				/* this value will be used for next RXSTAT */
2223
				pAC->StatusLETable.Bmu.Stat.VlanId = STLE_GET_VLAN(pLE);
2224
				/* fall through */
2225
			case OP_RXCHKS:
2226
				/* this value will be used for next RXSTAT */
2227
				pAC->StatusLETable.Bmu.Stat.TcpSum1 = STLE_GET_TCP1(pLE);
2228
				pAC->StatusLETable.Bmu.Stat.TcpSum2 = STLE_GET_TCP2(pLE);
2229
#ifdef Y2_RECOVERY
2230
				pAC->LastPort = Port;
2231
				pAC->LastOpc = OP_RXCHKS;
2232
#endif
2233
				break;
2234
			case OP_RSS_HASH:
2235
				/* this value will be used for next RXSTAT */
2236
#if 0
2237
				pAC->StatusLETable.Bmu.Stat.RssHashValue = STLE_GET_RSS(pLE);
2238
#endif
2239
				break;
2240
			case OP_TXINDEXLE:
2241
				/*
2242
				** :;:; TODO
2243
				** it would be possible to check for which queues
2244
				** the index has been changed and call 
2245
				** CheckForSendComplete() only for such queues
2246
				*/
2247
				STLE_GET_DONE_IDX(pLE,LowVal,HighVal);
2248
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2249
					("LowVal: 0x%x HighVal: 0x%x\n", LowVal, HighVal));
2250
2251
				/*
2252
				** It would be possible to check whether we really
2253
				** need the values for second port or sync queue, 
2254
				** but I think checking whether we need them is 
2255
				** more expensive than the calculation
2256
				*/
2257
				DoneTxA[0] = STLE_GET_DONE_IDX_TXA1(LowVal,HighVal);
2258
				DoneTxS[0] = STLE_GET_DONE_IDX_TXS1(LowVal,HighVal);
2259
				DoneTxA[1] = STLE_GET_DONE_IDX_TXA2(LowVal,HighVal);
2260
				DoneTxS[1] = STLE_GET_DONE_IDX_TXS2(LowVal,HighVal);
2261
2262
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2263
					("DoneTxa1 0x%x DoneTxS1: 0x%x DoneTxa2 0x%x DoneTxS2: 0x%x\n",
2264
					DoneTxA[0], DoneTxS[0], DoneTxA[1], DoneTxS[1]));
2265
2266
				NewDone = SK_TRUE;
2267
				break;
2268
#ifdef USE_TIST_FOR_RESET
2269
			case OP_MOD_TXINDEX:
2270
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
2271
					("OP_MOD_TXINDEX\n"));
2272
				SK_IN16(pAC->IoBase, Q_ADDR(Q_XA1, Q_DONE), &DoneTxA[0]);
2273
				if (pAC->GIni.GIMacsFound > 1) {
2274
					SK_IN16(pAC->IoBase, Q_ADDR(Q_XA2, Q_DONE), &DoneTxA[1]);
2275
				}
2276
				NewDone = SK_TRUE;
2277
				break;
2278
			case OP_MOD_LE:
2279
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DUMP,
2280
				("Ignore marked LE on port in Reset\n"));
2281
				break;
2282
#endif
2283
2284
			default:
2285
				/* 
2286
				** Have to handle the illegal Opcode in Status LE 
2287
				*/
2288
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2289
					("Unexpected OpCode\n"));
2290
				break;
2291
			}
2292
2293
#ifdef Y2_RECOVERY
2294
			OpCode = STLE_GET_OPC(pLE) & ~HW_OWNER;
2295
			STLE_SET_OPC(pLE, OpCode);
2296
#else
2297
			/* 
2298
			** Reset own bit we have to do this in order to detect a overflow 
2299
			*/
2300
			STLE_SET_OPC(pLE, SW_OWNER);
2301
#endif
2302
		} /* while (OWN_OF_FIRST_LE(&pAC->StatusLETable) == HW_OWNER) */
2303
2304
		/* 
2305
		** Now handle any new transmit complete 
2306
		*/
2307
		if (NewDone) {
2308
			SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2309
				("Done Index for Tx BMU has been changed\n"));
2310
			for (Port = 0; Port < pAC->GIni.GIMacsFound; Port++) {
2311
				/* 
2312
				** Do we have a new Done idx ? 
2313
				*/
2314
				if (DoneTxA[Port] != GET_DONE_INDEX(&pAC->TxPort[Port][0].TxALET)) {
2315
					SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2316
						("Check TxA%d\n", Port + 1));
2317
					CheckForSendComplete(pAC, pAC->IoBase, Port,
2318
						&(pAC->TxPort[Port][0].TxAQ_working),
2319
						&pAC->TxPort[Port][0].TxALET,
2320
						DoneTxA[Port]);
2321
				} else {
2322
					SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2323
						("No changes for TxA%d\n", Port + 1));
2324
				}
2325
#if USE_SYNC_TX_QUEUE
2326
				if (HW_SYNC_TX_SUPPORTED(pAC)) {
2327
					/* 
2328
					** Do we have a new Done idx ? 
2329
					*/
2330
					if (DoneTxS[Port] !=
2331
						GET_DONE_INDEX(&pAC->TxPort[Port][0].TxSLET)) {
2332
						SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
2333
							SK_DBGCAT_DRV_INT_SRC,
2334
							("Check TxS%d\n", Port));
2335
						CheckForSendComplete(pAC, pAC->IoBase, Port,
2336
							&(pAC->TxPort[Port][0].TxSQ_working),
2337
							&pAC->TxPort[Port][0].TxSLET,
2338
							DoneTxS[Port]);
2339
					} else {
2340
						SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
2341
							SK_DBGCAT_DRV_INT_SRC,
2342
							("No changes for TxS%d\n", Port));
2343
					}
2344
				}
2345
#endif
2346
			}
2347
		}
2348
		NewDone = SK_FALSE;
2349
2350
		/* 
2351
		** Check whether we have to refill our RX table  
2352
		*/
2353
		if (HW_FEATURE(pAC, HWF_WA_DEV_420)) {
2354
			if (NbrRxBuffersInHW < MAX_NBR_RX_BUFFERS_IN_HW) {
2355
				for (Port = 0; Port < pAC->GIni.GIMacsFound; Port++) {
2356
					SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2357
						("Check for refill of RxBuffers on Port %c\n", 'A' + Port));
2358
					FillReceiveTableYukon2(pAC, pAC->IoBase, Port);
2359
				}
2360
			}
2361
		} else {
2362
			for (Port = 0; Port < pAC->GIni.GIMacsFound; Port++) {
2363
				SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
2364
					("Check for refill of RxBuffers on Port %c\n", 'A' + Port));
2365
				if (NUM_FREE_LE_IN_TABLE(&pAC->RxPort[Port].RxLET) >= 64) {
2366
					FillReceiveTableYukon2(pAC, pAC->IoBase, Port);
2367
				}
2368
			}
2369
		}
2370
#ifdef CONFIG_SK98LIN_NAPI
2371
		if (*WorkDone >= WorkToDo) {
2372
			break;
2373
		}
2374
#endif
2375
	} while (OWN_OF_FIRST_LE(&pAC->StatusLETable) == HW_OWNER);
2376
2377
	/* 
2378
	** Clear status BMU 
2379
	*/
2380
	SK_OUT32(pAC->IoBase, STAT_CTRL, SC_STAT_CLR_IRQ);
2381
2382
	return(handledStatLE);
2383
}	/* HandleStatusLEs */
2384
2385
/*****************************************************************************
2386
 *
2387
 *	AllocateAndInitLETables - allocate memory for the LETable and init
2388
 *
2389
 * Description:
2390
 *	This function will allocate space for the LETable and will also  
2391
 *	initialize them. The size of the tables must have been specified 
2392
 *	before.
2393
 *
2394
 * Arguments:
2395
 *	pAC - A pointer to the adapter context struct.
2396
 *
2397
 * Returns:
2398
 *	SK_TRUE  - all LETables initialized
2399
 *	SK_FALSE - failed
2400
 */
2401
static SK_BOOL AllocateAndInitLETables(
2402
SK_AC *pAC)  /* pointer to adapter context */
2403
{
2404
	char           *pVirtMemAddr;
2405
	dma_addr_t     pPhysMemAddr = 0;
2406
	SK_U32         CurrMac;
2407
	unsigned       Size;
2408
	unsigned       Aligned;
2409
	unsigned       Alignment;
2410
2411
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
2412
		("==> AllocateAndInitLETables()\n"));
2413
2414
	/*
2415
	** Determine how much memory we need with respect to alignment
2416
	*/
2417
	Alignment = MAX_LEN_OF_LE_TAB;
2418
	Size = 0;
2419
	for (CurrMac = 0; CurrMac < pAC->GIni.GIMacsFound; CurrMac++) {
2420
		SK_ALIGN_SIZE(LE_TAB_SIZE(RX_MAX_LE), Alignment, Aligned);
2421
		Size += Aligned;
2422
		SK_ALIGN_SIZE(LE_TAB_SIZE(TXA_MAX_LE), Alignment, Aligned);
2423
		Size += Aligned;
2424
		SK_ALIGN_SIZE(LE_TAB_SIZE(TXS_MAX_LE), Alignment, Aligned);
2425
		Size += Aligned;
2426
	}
2427
	SK_ALIGN_SIZE(LE_TAB_SIZE(ST_MAX_LE), Alignment, Aligned);
2428
	Size += Aligned;
2429
	Size += Alignment;
2430
	pAC->SizeOfAlignedLETables = Size;
2431
	
2432
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT, 
2433
			("Need %08x bytes in total\n", Size));
2434
	
2435
	/*
2436
	** Allocate the memory
2437
	*/
2438
	pVirtMemAddr = pci_alloc_consistent(pAC->PciDev, Size, &pPhysMemAddr);
2439
	if (pVirtMemAddr == NULL) {
2440
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, 
2441
			SK_DBGCAT_INIT | SK_DBGCAT_DRV_ERROR,
2442
			("AllocateAndInitLETables: kernel malloc failed!\n"));
2443
		return (SK_FALSE); 
2444
	}
2445
2446
	/* 
2447
	** Initialize the memory
2448
	*/
2449
	SK_MEMSET(pVirtMemAddr, 0, Size);
2450
	ALIGN_ADDR(pVirtMemAddr, Alignment); /* Macro defined in skgew.h */
2451
	
2452
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
2453
		("Virtual address of LETab is %8p!\n", pVirtMemAddr));
2454
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
2455
		("Phys address of LETab is %8p!\n", (void *) pPhysMemAddr));
2456
2457
	for (CurrMac = 0; CurrMac < pAC->GIni.GIMacsFound; CurrMac++) {
2458
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
2459
			("RxLeTable for Port %c", 'A' + CurrMac));
2460
		SkGeY2InitSingleLETable(
2461
			pAC,
2462
			&pAC->RxPort[CurrMac].RxLET,
2463
			RX_MAX_LE,
2464
			pVirtMemAddr,
2465
			(SK_U32) (pPhysMemAddr & 0xffffffff),
2466
			(SK_U32) (((SK_U64) pPhysMemAddr) >> 32));
2467
2468
		SK_ALIGN_SIZE(LE_TAB_SIZE(RX_MAX_LE), Alignment, Aligned);
2469
		pVirtMemAddr += Aligned;
2470
		pPhysMemAddr += Aligned;
2471
2472
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
2473
			("TxALeTable for Port %c", 'A' + CurrMac));
2474
		SkGeY2InitSingleLETable(
2475
			pAC,
2476
			&pAC->TxPort[CurrMac][0].TxALET,
2477
			TXA_MAX_LE,
2478
			pVirtMemAddr,
2479
			(SK_U32) (pPhysMemAddr & 0xffffffff),
2480
			(SK_U32) (((SK_U64) pPhysMemAddr) >> 32));
2481
2482
		SK_ALIGN_SIZE(LE_TAB_SIZE(TXA_MAX_LE), Alignment, Aligned);
2483
		pVirtMemAddr += Aligned;
2484
		pPhysMemAddr += Aligned;
2485
2486
		SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
2487
			("TxSLeTable for Port %c", 'A' + CurrMac));
2488
		SkGeY2InitSingleLETable(
2489
			pAC,
2490
			&pAC->TxPort[CurrMac][0].TxSLET,
2491
			TXS_MAX_LE,
2492
			pVirtMemAddr,
2493
			(SK_U32) (pPhysMemAddr & 0xffffffff),
2494
			(SK_U32) (((SK_U64) pPhysMemAddr) >> 32));
2495
2496
		SK_ALIGN_SIZE(LE_TAB_SIZE(TXS_MAX_LE), Alignment, Aligned);
2497
		pVirtMemAddr += Aligned;
2498
		pPhysMemAddr += Aligned;
2499
	}
2500
2501
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,("StLeTable"));
2502
2503
	SkGeY2InitSingleLETable(
2504
		pAC,
2505
		&pAC->StatusLETable,
2506
		ST_MAX_LE,
2507
		pVirtMemAddr,
2508
		(SK_U32) (pPhysMemAddr & 0xffffffff),
2509
		(SK_U32) (((SK_U64) pPhysMemAddr) >> 32));
2510
2511
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT, 
2512
		("<== AllocateAndInitLETables(OK)\n"));
2513
	return(SK_TRUE);
2514
}	/* AllocateAndInitLETables */
2515
2516
/*****************************************************************************
2517
 *
2518
 *	AllocatePacketBuffersYukon2 - allocate packet and fragment buffers
2519
 *
2520
 * Description:
2521
 *      This function will allocate space for the packets and fragments
2522
 *
2523
 * Arguments:
2524
 *      pAC - A pointer to the adapter context struct.
2525
 *
2526
 * Returns:
2527
 *      SK_TRUE  - Memory was allocated correctly
2528
 *      SK_FALSE - An error occured
2529
 */
2530
static SK_BOOL AllocatePacketBuffersYukon2(
2531
SK_AC *pAC)  /* pointer to adapter context */
2532
{
2533
	SK_PACKET       *pRxPacket;
2534
	SK_PACKET       *pTxPacket;
2535
	SK_U32           CurrBuff;
2536
	SK_U32           CurrMac;
2537
	unsigned long    Flags; /* needed for POP/PUSH functions */
2538
2539
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
2540
		("==> AllocatePacketBuffersYukon2()"));
2541
2542
	for (CurrMac = 0; CurrMac < pAC->GIni.GIMacsFound; CurrMac++) {
2543
		/* 
2544
		** Allocate RX packet space, initialize the packets and
2545
		** add them to the RX waiting queue. Waiting queue means 
2546
		** that packet and fragment are initialized, but no sk_buff
2547
		** has been assigned to it yet.
2548
		*/
2549
		pAC->RxPort[CurrMac].ReceivePacketTable = 
2550
			kmalloc((RX_MAX_NBR_BUFFERS * sizeof(SK_PACKET)), GFP_KERNEL);
2551
2552
		if (pAC->RxPort[CurrMac].ReceivePacketTable == NULL) {
2553
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_INIT | SK_DBGCAT_DRV_ERROR,
2554
				("AllocatePacketBuffersYukon2: no mem RxPkts (port %i)",CurrMac));
2555
			break;
2556
		} else {
2557
			SK_MEMSET(pAC->RxPort[CurrMac].ReceivePacketTable, 0, 
2558
				(RX_MAX_NBR_BUFFERS * sizeof(SK_PACKET)));
2559
2560
			pRxPacket = pAC->RxPort[CurrMac].ReceivePacketTable;
2561
2562
			for (CurrBuff=0;CurrBuff<RX_MAX_NBR_BUFFERS;CurrBuff++) {
2563
				pRxPacket->pFrag = &(pRxPacket->FragArray[0]);
2564
				pRxPacket->NumFrags = 1;
2565
				PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->RxPort[CurrMac].RxQ_waiting, pRxPacket);
2566
				pRxPacket++;
2567
			}
2568
		}
2569
2570
		/*
2571
		** Allocate TX packet space, initialize the packets and
2572
		** add them to the TX free queue. Free queue means that
2573
		** packet is available and initialized, but no fragment
2574
		** has been assigned to it. (Must be done at TX side)
2575
		*/
2576
		pAC->TxPort[CurrMac][0].TransmitPacketTable = 
2577
			kmalloc((TX_MAX_NBR_BUFFERS * sizeof(SK_PACKET)), GFP_KERNEL);
2578
2579
		if (pAC->TxPort[CurrMac][0].TransmitPacketTable == NULL) {
2580
			SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_INIT | SK_DBGCAT_DRV_ERROR,
2581
				("AllocatePacketBuffersYukon2: no mem TxPkts (port %i)",CurrMac));
2582
			kfree(pAC->RxPort[CurrMac].ReceivePacketTable);
2583
			return(SK_FALSE);
2584
		} else {
2585
			SK_MEMSET(pAC->TxPort[CurrMac][0].TransmitPacketTable, 0, 
2586
				(TX_MAX_NBR_BUFFERS * sizeof(SK_PACKET)));
2587
		
2588
			pTxPacket = pAC->TxPort[CurrMac][0].TransmitPacketTable;
2589
2590
			for (CurrBuff=0;CurrBuff<TX_MAX_NBR_BUFFERS;CurrBuff++) {
2591
				PUSH_PKT_AS_LAST_IN_QUEUE(&pAC->TxPort[CurrMac][0].TxQ_free, pTxPacket);
2592
				pTxPacket++;
2593
			}
2594
		}
2595
	} /* end for (CurrMac = 0; CurrMac < pAC->GIni.GIMacsFound; CurrMac++) */
2596
2597
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_INIT,
2598
		("<== AllocatePacketBuffersYukon2 (OK)\n"));
2599
	return(SK_TRUE);
2600
2601
}	/* AllocatePacketBuffersYukon2 */
2602
2603
/*****************************************************************************
2604
 *
2605
 *	FreeLETables - release allocated memory of LETables
2606
 *
2607
 * Description:
2608
 *      This function will free all resources of the LETables
2609
 *
2610
 * Arguments:
2611
 *      pAC - A pointer to the adapter context struct.
2612
 *
2613
 * Returns: N/A
2614
 */
2615
static void FreeLETables(
2616
SK_AC *pAC)  /* pointer to adapter control context */
2617
{
2618
	dma_addr_t	pPhysMemAddr;
2619
	char		*pVirtMemAddr;
2620
2621
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
2622
		("==> FreeLETables()\n"));
2623
	
2624
	/*
2625
	** The RxLETable is the first of all LET. 
2626
	** Therefore we can use its address for the input 
2627
	** of the free function.
2628
	*/
2629
	pVirtMemAddr = (char *) pAC->RxPort[0].RxLET.pLETab;
2630
	pPhysMemAddr = (((SK_U64) pAC->RxPort[0].RxLET.pPhyLETABHigh << (SK_U64) 32) | 
2631
			((SK_U64) pAC->RxPort[0].RxLET.pPhyLETABLow));
2632
2633
	/* free continuous memory */
2634
	pci_free_consistent(pAC->PciDev, pAC->SizeOfAlignedLETables,
2635
			    pVirtMemAddr, pPhysMemAddr);
2636
2637
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
2638
		("<== FreeLETables()\n"));
2639
}	/* FreeLETables */
2640
2641
/*****************************************************************************
2642
 *
2643
 *	FreePacketBuffers - free's all packet buffers of an adapter
2644
 *
2645
 * Description:
2646
 *      This function will free all previously allocated memory of the 
2647
 *	packet buffers.
2648
 *
2649
 * Arguments:
2650
 *      pAC - A pointer to the adapter context struct.
2651
 *
2652
 * Returns: N/A
2653
 */
2654
static void FreePacketBuffers(
2655
SK_AC *pAC)  /* pointer to adapter control context */
2656
{
2657
	int Port;
2658
2659
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
2660
		("==> FreePacketBuffers()\n"));
2661
	
2662
	for (Port = 0; Port < pAC->GIni.GIMacsFound; Port++) {
2663
		kfree(pAC->RxPort[Port].ReceivePacketTable);
2664
		kfree(pAC->TxPort[Port][0].TransmitPacketTable);
2665
	}
2666
2667
	SK_DBG_MSG(pAC, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MSG,
2668
		("<== FreePacketBuffers()\n"));
2669
}	/* FreePacketBuffers */
2670
2671
/*****************************************************************************
2672
 *
2673
 * 	AllocAndMapRxBuffer - fill one buffer into the receive packet/fragment
2674
 *
2675
 * Description:
2676
 *	The function allocates a new receive buffer and assigns it to the
2677
 *	the passsed receive packet/fragment
2678
 *
2679
 * Returns:
2680
 *	SK_TRUE - a buffer was allocated and assigned
2681
 *	SK_FALSE - a buffer could not be added
2682
 */
2683
static SK_BOOL AllocAndMapRxBuffer(
2684
SK_AC      *pAC,        /* pointer to the adapter control context */
2685
SK_PACKET  *pSkPacket,  /* pointer to packet that is to fill      */
2686
int         Port)       /* port the packet belongs to             */
2687
{
2688
	struct sk_buff *pMsgBlock;  /* pointer to a new message block  */
2689
	SK_U64          PhysAddr;   /* physical address of a rx buffer */
2690
2691
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
2692
		("--> AllocAndMapRxBuffer (Port: %i)\n", Port));
2693
2694
	pMsgBlock = alloc_skb(pAC->RxBufSize, GFP_ATOMIC);
2695
	if (pMsgBlock == NULL) {
2696
		SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2697
			SK_DBGCAT_DRV_RX_PROGRESS | SK_DBGCAT_DRV_ERROR,
2698
			("%s: Allocation of rx buffer failed !\n",
2699
			pAC->dev[Port]->name));
2700
		SK_PNMI_CNT_NO_RX_BUF(pAC, pAC->RxPort[Port].PortIndex);
2701
		return(SK_FALSE);
2702
	}
2703
	skb_reserve(pMsgBlock, 8);
2704
2705
	PhysAddr = (SK_U64) pci_map_page(pAC->PciDev,
2706
		virt_to_page(pMsgBlock->data),
2707
		((unsigned long) pMsgBlock->data &
2708
		~PAGE_MASK),
2709
		pAC->RxBufSize,
2710
		PCI_DMA_FROMDEVICE);
2711
2712
	pSkPacket->pFrag->pVirt   = pMsgBlock->data;
2713
	pSkPacket->pFrag->pPhys   = PhysAddr;
2714
	pSkPacket->pFrag->FragLen = pAC->RxBufSize; /* for correct unmap */
2715
	pSkPacket->pMBuf          = pMsgBlock;	
2716
	pSkPacket->PacketLen      = pAC->RxBufSize;
2717
2718
	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,
2719
		("<-- AllocAndMapRxBuffer\n"));
2720
2721
	return (SK_TRUE);
2722
}	/* AllocAndMapRxBuffer */
2723
2724
/*******************************************************************************
2725
 *
2726
 * End of file
2727
 *
2728
 ******************************************************************************/
(-)linux/drivers/net/sk98lin/sky2le.c (+510 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 *
3
 *	Name:		sky2le.c
4
 *	Project:	Gigabit Ethernet Adapters, Common Modules
5
 *	Version:	$Revision: 1.11 $
6
 *	Date:		$Date: 2004/11/22 14:21:58 $
7
 *	Purpose: 	Functions for handling List Element Tables
8
 *
9
 *****************************************************************************/
10
11
/******************************************************************************
12
 *
13
 *	(C)Copyright 2002-2004 Marvell.
14
 *
15
 *	This program is free software; you can redistribute it and/or modify
16
 *	it under the terms of the GNU General Public License as published by
17
 *	the Free Software Foundation; either version 2 of the License, or
18
 *	(at your option) any later version.
19
 *	The information in this file is provided "AS IS" without warranty.
20
 *
21
 ******************************************************************************/
22
23
/*****************************************************************************
24
 *
25
 * Description:
26
 *
27
 * This module contains the code necessary for handling List Elements.
28
 *
29
 * Supported Gigabit Ethernet Chipsets:
30
 *	Yukon-2 (PCI, PCI-X, PCI-Express)
31
 *
32
 * Include File Hierarchy:
33
 *
34
 *
35
 *****************************************************************************/
36
#include "h/skdrv1st.h"
37
#include "h/skdrv2nd.h"
38
39
/* defines *******************************************************************/
40
/* typedefs ******************************************************************/
41
/* global variables **********************************************************/
42
/* local variables ***********************************************************/
43
44
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
45
static const char SysKonnectFileId[] =
46
	"@(#) $Id: sky2le.c,v 1.11 2004/11/22 14:21:58 malthoff Exp $ (C) Marvell.";
47
#endif /* DEBUG || (!LINT && !SK_SLIM) */
48
49
/* function prototypes *******************************************************/
50
51
/*****************************************************************************
52
 *
53
 * SkGeY2InitSingleLETable() - initializes a list element table
54
 *
55
 * Description:
56
 *	This function will initialize the selected list element table.
57
 *	Should be called once during DriverInit. No InitLevel required.
58
 *
59
 * Arguments:
60
 *	pAC			- pointer to the adapter context struct.
61
 *	pLETab		- pointer to list element table structure
62
 *	NumLE		- number of list elements in this table
63
 *	pVMem		- virtual address of memory allocated for this LE table
64
 *	PMemLowAddr - physical address of memory to be used for the LE table
65
 *	PMemHighAddr
66
 *
67
 * Returns:
68
 *	nothing
69
 */
70
void SkGeY2InitSingleLETable(
71
SK_AC	*pAC,			/* pointer to adapter context */
72
SK_LE_TABLE	*pLETab,	/* pointer to list element table to be initialized */
73
unsigned int NumLE,		/* number of list elements to be filled in tab */
74
void	*pVMem,			/* virtual address of memory used for list elements */
75
SK_U32	PMemLowAddr,	/* physical addr of mem used for LE */
76
SK_U32	PMemHighAddr)
77
{
78
	unsigned int i;
79
80
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
81
		("==> SkGeY2InitSingleLETable()\n"));
82
83
#ifdef DEBUG
84
	if (NumLE != 2) {	/* not table for polling unit */
85
		if ((NumLE % MIN_LEN_OF_LE_TAB) != 0 || NumLE > MAX_LEN_OF_LE_TAB) {
86
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
87
				("ERROR: Illegal number of list elements %d\n", NumLE));
88
		}
89
	}
90
#endif /* DEBUG */
91
92
	/* special case: unused list element table */
93
	if (NumLE == 0) {
94
		PMemLowAddr = 0;
95
		PMemHighAddr = 0;
96
		pVMem = 0;
97
	}
98
99
	/*
100
	 * in order to get the best possible performance the macros to access
101
	 * list elements use & instead of %
102
	 * this requires the length of LE tables to be a power of 2
103
	 */
104
105
	/*
106
	 * this code guarantees that we use the next power of 2 below the
107
	 * value specified for NumLe - this way some LEs in the table may
108
	 * not be used but the macros work correctly
109
	 * this code does not check for bad values below 128 because in such a
110
	 * case we cannot do anything here
111
	 */
112
113
	if ((NumLE != 2) && (NumLE != 0)) {
114
		/* no check for polling unit and unused sync Tx */
115
		i = MIN_LEN_OF_LE_TAB;
116
		while (NumLE > i) {
117
			i *= 2;
118
			if (i > MAX_LEN_OF_LE_TAB) {
119
				break;
120
			}
121
		}
122
		if (NumLE != i) {
123
			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
124
				("ERROR: Illegal number of list elements %d adjusted to %d\n",
125
				NumLE, (i / 2)));
126
			NumLE = i / 2;
127
		}
128
	}
129
130
	/* set addresses */
131
	pLETab->pPhyLETABLow = PMemLowAddr;
132
	pLETab->pPhyLETABHigh = PMemHighAddr;
133
	pLETab->pLETab = pVMem;
134
135
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
136
		("contains %d LEs", NumLE));
137
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
138
		(" and starts at virt %08lx and phys %08lx:%08lx\n",
139
		pVMem, PMemHighAddr, PMemLowAddr));
140
141
	/* initialize indexes */
142
	pLETab->Done = 0;
143
	pLETab->Put = 0;
144
	pLETab->HwPut = 0;
145
	/* initialize size */
146
	pLETab->Num = NumLE;
147
148
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
149
		("<== SkGeY2InitSingleLETable()\n"));
150
}	/* SkGeY2InitSingleLETable */
151
152
/*****************************************************************************
153
 *
154
 * SkGeY2InitPrefetchUnit() - Initialize a Prefetch Unit
155
 *
156
 * Description:
157
 *	Calling this function requires an already configured list element
158
 *	table. The prefetch unit to be configured is specified in the parameter
159
 *	'Queue'. The function is able to initialze the prefetch units of
160
 *	the following queues: Q_R1, Q_R2, Q_XS1, Q_XS2, Q_XA1, Q_XA2.
161
 *	The funcution should be called before SkGeInitPort().
162
 *
163
 * Arguments:
164
 *	pAC - pointer to the adapter context struct.
165
 *	IoC - I/O context.
166
 *	Queue - I/O offset of queue e.g. Q_XA1.
167
 *	pLETab - pointer to list element table to be initialized
168
 *
169
 * Returns: N/A
170
 */
171
void SkGeY2InitPrefetchUnit(
172
SK_AC	*pAC,			/* pointer to adapter context */
173
SK_IOC	IoC,			/* I/O context */
174
unsigned int Queue,		/* Queue offset for finding the right registers */
175
SK_LE_TABLE	*pLETab)	/* pointer to list element table to be initialized */
176
{
177
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
178
		("==> SkGeY2InitPrefetchUnit()\n"));
179
180
#ifdef DEBUG
181
	if (Queue != Q_R1 && Queue != Q_R2 && Queue != Q_XS1 &&
182
		Queue != Q_XS2 && Queue != Q_XA1 && Queue != Q_XA2) {
183
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_ERR,
184
			("ERROR: Illegal queue identifier %x\n", Queue));
185
	}
186
#endif /* DEBUG */
187
188
	/* disable the prefetch unit */
189
	SK_OUT32(IoC, Y2_PREF_Q_ADDR(Queue, PREF_UNIT_CTRL_REG), PREF_UNIT_RST_SET);
190
	SK_OUT32(IoC, Y2_PREF_Q_ADDR(Queue, PREF_UNIT_CTRL_REG), PREF_UNIT_RST_CLR);
191
192
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
193
		("Base address: %08lx:%08lx\n", pLETab->pPhyLETABHigh,
194
		pLETab->pPhyLETABLow));
195
196
	/* Set the list base address  high part*/
197
	SK_OUT32(IoC, Y2_PREF_Q_ADDR(Queue, PREF_UNIT_ADDR_HI_REG),
198
		pLETab->pPhyLETABHigh);
199
200
	/* Set the list base address low part */
201
	SK_OUT32(IoC, Y2_PREF_Q_ADDR(Queue, PREF_UNIT_ADDR_LOW_REG),
202
		pLETab->pPhyLETABLow);
203
204
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
205
		("Last index: %d\n", pLETab->Num-1));
206
207
	/* Set the list last index */
208
	SK_OUT16(IoC, Y2_PREF_Q_ADDR(Queue, PREF_UNIT_LAST_IDX_REG),
209
		(SK_U16)(pLETab->Num - 1));
210
211
	/* turn on prefetch unit */
212
	SK_OUT32(IoC, Y2_PREF_Q_ADDR(Queue, PREF_UNIT_CTRL_REG), PREF_UNIT_OP_ON);
213
214
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
215
		("<== SkGeY2InitPrefetchUnit()\n"));
216
}	/* SkGeY2InitPrefetchUnit */
217
218
219
/*****************************************************************************
220
 *
221
 * SkGeY2InitStatBmu() -	Initialize the Status BMU
222
 *
223
 * Description:
224
 *	Calling this function requires an already configured list element
225
 *	table. Ensure the status BMU is only initialized once during
226
 *  DriverInit - InitLevel2 required.
227
 *
228
 * Arguments:
229
 *	pAC - pointer to the adapter context struct.
230
 *	IoC - I/O context.
231
 *	pLETab - pointer to status LE table to be initialized
232
 *
233
 * Returns: N/A
234
 */
235
void SkGeY2InitStatBmu(
236
SK_AC	*pAC,			/* pointer to adapter context */
237
SK_IOC	IoC,			/* I/O context */
238
SK_LE_TABLE	*pLETab)	/* pointer to status LE table */
239
{
240
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
241
		("==> SkGeY2InitStatBmu()\n"));
242
243
	/* disable the prefetch unit */
244
	SK_OUT32(IoC, STAT_CTRL, SC_STAT_RST_SET);
245
	SK_OUT32(IoC, STAT_CTRL, SC_STAT_RST_CLR);
246
247
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
248
		("Base address Low: %08lX\n", pLETab->pPhyLETABLow));
249
250
	/* Set the list base address */
251
	SK_OUT32(IoC, STAT_LIST_ADDR_LO, pLETab->pPhyLETABLow);
252
253
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
254
		("Base address High: %08lX\n", pLETab->pPhyLETABHigh));
255
256
	SK_OUT32(IoC, STAT_LIST_ADDR_HI, pLETab->pPhyLETABHigh);
257
258
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
259
		("Last index: %d\n", pLETab->Num - 1));
260
261
	/* Set the list last index */
262
	SK_OUT16(IoC, STAT_LAST_IDX, (SK_U16)(pLETab->Num - 1));
263
264
	if (HW_FEATURE(pAC, HWF_WA_DEV_43_418)) {
265
266
		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
267
			("Set Tx index threshold\n"));
268
		/* WA for dev. #4.3 */
269
		SK_OUT16(IoC, STAT_TX_IDX_TH, ST_TXTH_IDX_MASK);
270
271
		/* set Status-FIFO watermark */
272
		SK_OUT8(IoC, STAT_FIFO_WM, 0x21);		/* WA for dev. #4.18 */
273
274
		/* set Status-FIFO ISR watermark */
275
		SK_OUT8(IoC, STAT_FIFO_ISR_WM, 0x07);	/* WA for dev. #4.18 */
276
277
		/* WA for dev. #4.3 and #4.18 */
278
		/* set Status-FIFO Tx timer init value */
279
		SK_OUT32(IoC, STAT_TX_TIMER_INI, HW_MS_TO_TICKS(pAC, 10));
280
	}
281
	else {
282
		/*
283
		 * Further settings may be added if required...
284
		 * 1) Status-FIFO watermark (STAT_FIFO_WM, STAT_FIFO_ISR_WM)
285
		 * 2) Status-FIFO timer values (STAT_TX_TIMER_INI,
286
		 *		STAT_LEV_TIMER_INI and STAT_ISR_TIMER_INI)
287
		 * but tests shows that the default values give the best results,
288
		 * therefore the defaults are used.
289
		 */
290
291
		/*
292
		 * Theses settings should avoid the
293
		 * temporary hanging of the status BMU.
294
		 * May be not all required... still under investigation...
295
		 */
296
		SK_OUT16(IoC, STAT_TX_IDX_TH, 0x000a);
297
298
		/* set Status-FIFO watermark */
299
		SK_OUT8(IoC, STAT_FIFO_WM, 0x10);
300
301
302
		/* set Status-FIFO ISR watermark */
303
		if (HW_FEATURE(pAC, HWF_WA_DEV_4109)) {
304
			SK_OUT8(IoC, STAT_FIFO_ISR_WM, 0x10);
305
		}
306
		else {
307
			SK_OUT8(IoC, STAT_FIFO_ISR_WM, 0x04);
308
		}
309
310
		SK_OUT32(IoC, STAT_ISR_TIMER_INI, 0x0190);
311
	}
312
313
	/* start Status-FIFO timer */
314
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
315
		("Start Status FiFo timer\n"));
316
317
	/* enable the prefetch unit */
318
	/* operational bit not functional for Yukon-EC, but fixed in Yukon-2 */
319
	SK_OUT32(IoC, STAT_CTRL, SC_STAT_OP_ON);
320
321
	/* start Status-FIFO timer */
322
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
323
		("Start Status FiFo timer\n"));
324
325
	SK_OUT8(IoC, STAT_TX_TIMER_CTRL, TIM_START);
326
	SK_OUT8(IoC, STAT_LEV_TIMER_CTRL, TIM_START);
327
	SK_OUT8(IoC, STAT_ISR_TIMER_CTRL, TIM_START);
328
329
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
330
		("<== SkGeY2InitStatBmu()\n"));
331
}	/* SkGeY2InitStatBmu */
332
333
#ifdef USE_POLLING_UNIT
334
/*****************************************************************************
335
 *
336
 * SkGeY2InitPollUnit() -	Initialize the Polling Unit
337
 *
338
 * Description:
339
 *	This function will write the data of one polling LE table into the
340
 *  adapter.
341
 *
342
 * Arguments:
343
 *	pAC - pointer to the adapter context struct.
344
 *	IoC - I/O context.
345
 *	pLETab - pointer to polling LE table to be initialized
346
 *
347
 * Returns: N/A
348
 */
349
void SkGeY2InitPollUnit(
350
SK_AC	*pAC,			/* pointer to adapter context */
351
SK_IOC	IoC,			/* I/O context */
352
SK_LE_TABLE	*pLETab)	/* pointer to polling LE table */
353
{
354
	SK_HWLE	*pLE;
355
	int	i;
356
#ifdef VCPU
357
	VCPU_VARS();
358
#endif /* VCPU */
359
360
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
361
		("==> SkGeY2InitPollUnit()\n"));
362
363
#ifdef VCPU
364
	for (i = 0; i < SK_MAX_MACS; i++) {
365
		GET_PO_LE(pLE, pLETab, i);
366
		VCPU_START_AND_COPY_LE();
367
		/* initialize polling LE but leave indexes invalid */
368
		POLE_SET_OPC(pLE, OP_PUTIDX | HW_OWNER);
369
		POLE_SET_LINK(pLE, i);
370
		POLE_SET_RXIDX(pLE, 0);
371
		POLE_SET_TXAIDX(pLE, 0);
372
		POLE_SET_TXSIDX(pLE, 0);
373
		VCPU_WRITE_LE();
374
		SK_DBG_DUMP_PO_LE(pLE);
375
	}
376
#endif	/* VCPU */
377
378
	/* disable the polling unit */
379
	SK_OUT32(IoC, POLL_CTRL, PC_POLL_RST_SET);
380
	SK_OUT32(IoC, POLL_CTRL, PC_POLL_RST_CLR);
381
382
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
383
		("Base address Low: %08lX\n", pLETab->pPhyLETABLow));
384
385
	/* Set the list base address */
386
	SK_OUT32(IoC, POLL_LIST_ADDR_LO, pLETab->pPhyLETABLow);
387
388
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
389
		("Base address High: %08lX\n", pLETab->pPhyLETABHigh));
390
391
	SK_OUT32(IoC, POLL_LIST_ADDR_HI, pLETab->pPhyLETABHigh);
392
393
	/* we don't need to write the last index - it is hardwired to 1 */
394
395
	/* enable the prefetch unit */
396
	SK_OUT32(IoC, POLL_CTRL, PC_POLL_OP_ON);
397
398
	/*
399
	 * now we have to start the descriptor poll timer because it triggers
400
	 * the polling unit
401
	 */
402
403
	/*
404
	 * still playing with the value (timer runs at 125 MHz)
405
	 * descriptor poll timer is enabled by GeInit
406
	 */
407
	SK_OUT32(IoC, B28_DPT_INI,
408
		(SK_DPOLL_DEF_Y2 * (SK_U32)pAC->GIni.GIHstClkFact / 100));
409
410
	SK_OUT8(IoC, B28_DPT_CTRL, TIM_START);
411
412
	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,
413
		("<== SkGeY2InitPollUnit()\n"));
414
}	/* SkGeY2InitPollUnit */
415
#endif	/* USE_POLLING_UNIT */
416
417
418
/******************************************************************************
419
 *
420
 * SkGeY2SetPutIndex
421
 *
422
 * Description:
423
 *   This function is writing the Done index of a transmit
424
 *   list element table.
425
 *
426
 * Notes:
427
 *	Dev. Issue 4.2
428
 *
429
 * Returns: N/A
430
 */
431
void SkGeY2SetPutIndex(
432
SK_AC	*pAC,					/* pointer to adapter context */
433
SK_IOC	IoC,					/* pointer to the IO context */
434
SK_U32	StartAddrPrefetchUnit,	/* start address of the prefetch unit */
435
SK_LE_TABLE	*pLETab)			/* list element table to work with */
436
{
437
	unsigned int Put;
438
	SK_U16 EndOfListIndex;
439
	SK_U16 HwGetIndex;
440
	SK_U16 HwPutIndex;
441
442
	/* set put index we would like to write */
443
	Put = GET_PUT_IDX(pLETab);
444
445
	/*
446
	 * in this case we wrap around
447
	 * new put is lower than last put given to hw
448
	 */
449
	if (Put < pLETab->HwPut) {
450
451
		/* set put index = last index of list */
452
		EndOfListIndex = (NUM_LE_IN_TABLE(pLETab)-1);
453
454
		/* read get index of hw prefetch unit */
455
		SK_IN16(IoC, (StartAddrPrefetchUnit + PREF_UNIT_GET_IDX_REG),
456
			&HwGetIndex);
457
458
		/* read put index of hw prefetch unit */
459
		SK_IN16(IoC, (StartAddrPrefetchUnit + PREF_UNIT_PUT_IDX_REG),
460
			&HwPutIndex);
461
462
		/* prefetch unit reached end of list */
463
		/* prefetch unit reached first list element */
464
		if (HwGetIndex == 0) {
465
			/* restore watermark */
466
			SK_OUT8(IoC, StartAddrPrefetchUnit + PREF_UNIT_FIFO_WM_REG, 0xe0U);
467
			/* write put index */
468
			SK_OUT16(IoC, StartAddrPrefetchUnit + PREF_UNIT_PUT_IDX_REG,
469
				(SK_U16)Put);
470
471
			/* remember put index  we wrote to hw */
472
			pLETab->HwPut = Put;
473
		}
474
		else if (HwGetIndex == EndOfListIndex) {
475
			/* set watermark to one list element */
476
			SK_OUT8(IoC, StartAddrPrefetchUnit + PREF_UNIT_FIFO_WM_REG, 8);
477
			/* set put index to first list element */
478
			SK_OUT16(IoC, StartAddrPrefetchUnit + PREF_UNIT_PUT_IDX_REG, 0);
479
		}
480
		/* prefetch unit did not reach end of list yet */
481
		/* and we did not write put index to end of list yet */
482
		else if ((HwPutIndex != EndOfListIndex) &&
483
				 (HwGetIndex != EndOfListIndex)) {
484
			/* write put index */
485
			SK_OUT16(IoC, StartAddrPrefetchUnit + PREF_UNIT_PUT_IDX_REG,
486
				EndOfListIndex);
487
		}
488
		else {
489
			/* do nothing */
490
		}
491
	}
492
	else {
493
#ifdef XXX		/* leads in to problems in the Windows Driver */
494
		if (Put != pLETab->HwPut) {
495
			/* write put index */
496
			SK_OUT16(IoC, StartAddrPrefetchUnit + PREF_UNIT_PUT_IDX_REG,
497
				(SK_U16)Put);
498
			/* update put index */
499
			UPDATE_HWPUT_IDX(pLETab);
500
		}
501
#else
502
		/* write put index */
503
		SK_OUT16(IoC, StartAddrPrefetchUnit + PREF_UNIT_PUT_IDX_REG,
504
			(SK_U16)Put);
505
		/* update put index */
506
		UPDATE_HWPUT_IDX(pLETab);
507
#endif
508
	}
509
}	/* SkGeY2SetPutIndex */
510
(-)linux/Documentation/networking/sk98lin.txt (-45 / +158 lines)
Lines 1-38 Link Here
1
(C)Copyright 1999-2004 Marvell(R).
1
(C)Copyright 1999-2005 Marvell(R).
2
All rights reserved
2
All rights reserved.
3
===========================================================================
3
================================================================================
4
4
5
sk98lin.txt created 13-Feb-2004
5
sk98lin.txt created 30-Mar-2005
6
6
7
Readme File for sk98lin v6.23
7
Readme File for sk98lin v8.16.2.3
8
Marvell Yukon/SysKonnect SK-98xx Gigabit Ethernet Adapter family driver for LINUX
8
Marvell Yukon/SysKonnect SK-98xx Gigabit Ethernet Adapter driver for LINUX
9
9
10
This file contains
10
This file contains
11
 1  Overview
11
 1  Overview
12
 2  Required Files
12
 2  Supported Functions
13
 3  Installation
13
 3  Required Files
14
    3.1  Driver Installation
14
 4  Installation
15
    3.2  Inclusion of adapter at system start
15
    4.1  Driver Installation
16
 4  Driver Parameters
16
    4.2  Inclusion of adapter at system start
17
    4.1  Per-Port Parameters
17
 5  Driver Parameters
18
    4.2  Adapter Parameters
18
    5.1  Per-Port Parameters
19
 5  Large Frame Support
19
    5.2  Adapter Parameters
20
 6  VLAN and Link Aggregation Support (IEEE 802.1, 802.1q, 802.3ad)
20
 6  Ethtool Support
21
 7  Troubleshooting
21
 7  Large Frame Support
22
 8  VLAN and Link Aggregation Support (IEEE 802.1, 802.1q, 802.3ad)
23
 9  Wake on Lan support
24
10  Troubleshooting
22
25
23
===========================================================================
26
================================================================================
24
27
25
28
26
1  Overview
29
1  Overview
27
===========
30
===========
28
31
29
The sk98lin driver supports the Marvell Yukon and SysKonnect 
32
The sk98lin driver supports the Marvell Yukon, Yukon EC/FE, Yukon 2
30
SK-98xx/SK-95xx compliant Gigabit Ethernet Adapter on Linux. It has 
33
and SysKonnect SK-98xx/SK-95xx compliant Gigabit Ethernet Adapter on Linux.
31
been tested with Linux on Intel/x86 machines.
34
It has been tested with Linux on Intel/x86, x86_64 and IA64 machines.
32
***
35
***
33
36
37
2  Supported Functions
38
======================
39
40
The following functions are supported by the driver:
34
41
35
2  Required Files
42
   NOTE 1: The hardware support depends on the used card
43
 
44
   - RX/TX HW Checksum
45
   - Hardware interrupt moderation (static/dynamic)
46
   - Transmit poll
47
   - Zerocopy/Scatter-Gather
48
   - Ethtool support
49
   - Wake on Lan (Magic Packet only) (From suspend and APM only)
50
   - DualNet
51
 
52
53
3  Required Files
36
=================
54
=================
37
55
38
The linux kernel source.
56
The linux kernel source.
Lines 40-55 Link Here
40
***
58
***
41
59
42
60
43
3  Installation
61
4  Installation
44
===============
62
===============
45
63
46
It is recommended to download the latest version of the driver from the 
64
It is recommended to download the latest version of the driver from the 
47
SysKonnect web site www.syskonnect.com. If you have downloaded the latest
65
SysKonnect web site www.syskonnect.com. For details on Installation 
48
driver, the Linux kernel has to be patched before the driver can be 
66
Instructions for sk98lin Driver, please refer to the README.txt file.
49
installed. For details on how to patch a Linux kernel, refer to the 
50
patch.txt file.
51
67
52
3.1  Driver Installation
68
4.1  Driver Installation
53
------------------------
69
------------------------
54
70
55
The following steps describe the actions that are required to install
71
The following steps describe the actions that are required to install
Lines 110-122 Link Here
110
   
126
   
111
   NOTE 1: If you have more than one Marvell Yukon or SysKonnect SK-98xx 
127
   NOTE 1: If you have more than one Marvell Yukon or SysKonnect SK-98xx 
112
           adapter installed, the adapters will be listed as 'eth0', 
128
           adapter installed, the adapters will be listed as 'eth0', 
113
                   'eth1', 'eth2', etc.
129
           'eth1', 'eth2', etc.
114
                   For each adapter, repeat steps 3 and 4 below.
130
           For each adapter, repeat steps 3 and 4 below.
115
131
116
   NOTE 2: If you have other Ethernet adapters installed, your Marvell
132
   NOTE 2: If you have other Ethernet adapters installed, your Marvell
117
           Yukon or SysKonnect SK-98xx adapter will be mapped to the 
133
           Yukon or SysKonnect SK-98xx adapter will be mapped to the 
118
                   next available number, e.g. 'eth1'. The mapping is executed 
134
           next available number, e.g. 'eth1'. The mapping is executed 
119
                   automatically.
135
           automatically.
120
           The module installation message (displayed either in a system
136
           The module installation message (displayed either in a system
121
           log file or on the console) prints a line for each adapter 
137
           log file or on the console) prints a line for each adapter 
122
           found containing the corresponding 'ethX'.
138
           found containing the corresponding 'ethX'.
Lines 153-159 Link Here
153
1. Execute the command "ifconfig eth0 down".
169
1. Execute the command "ifconfig eth0 down".
154
2. Execute the command "rmmod sk98lin".
170
2. Execute the command "rmmod sk98lin".
155
171
156
3.2  Inclusion of adapter at system start
172
4.2  Inclusion of adapter at system start
157
-----------------------------------------
173
-----------------------------------------
158
174
159
Since a large number of different Linux distributions are 
175
Since a large number of different Linux distributions are 
Lines 165-171 Link Here
165
181
166
***
182
***
167
183
168
4  Driver Parameters
184
185
5  Driver Parameters
169
====================
186
====================
170
187
171
Parameters can be set at the command line after the module has been 
188
Parameters can be set at the command line after the module has been 
Lines 174-180 Link Here
174
to the driver module.
191
to the driver module.
175
192
176
If you use the kernel module loader, you can set driver parameters
193
If you use the kernel module loader, you can set driver parameters
177
in the file /etc/modprobe.conf (or /etc/modules.conf in 2.4 or earlier).
194
in the file /etc/modules.conf (or old name: /etc/conf.modules).
178
To set the driver parameters in this file, proceed as follows:
195
To set the driver parameters in this file, proceed as follows:
179
196
180
1. Insert a line of the form :
197
1. Insert a line of the form :
Lines 208-214 Link Here
208
      more adapters, adjust this and recompile.
225
      more adapters, adjust this and recompile.
209
226
210
227
211
4.1  Per-Port Parameters
228
5.1  Per-Port Parameters
212
------------------------
229
------------------------
213
230
214
These settings are available for each port on the adapter.
231
These settings are available for each port on the adapter.
Lines 282-288 Link Here
282
with this parameter.
299
with this parameter.
283
300
284
301
285
4.2  Adapter Parameters
302
5.2  Adapter Parameters
286
-----------------------
303
-----------------------
287
304
288
Connection Type (SK-98xx V2.0 copper adapters only)
305
Connection Type (SK-98xx V2.0 copper adapters only)
Lines 379-385 Link Here
379
is tremendous. On the other hand, selecting a very short moderation time might
396
is tremendous. On the other hand, selecting a very short moderation time might
380
compensate the use of any moderation being applied.
397
compensate the use of any moderation being applied.
381
398
382
383
Preferred Port
399
Preferred Port
384
--------------
400
--------------
385
Parameter:    PrefPort
401
Parameter:    PrefPort
Lines 429-438 Link Here
429
      where a network path between the ports on one adapter exists. 
445
      where a network path between the ports on one adapter exists. 
430
      Moreover, they are not designed to work where adapters are connected
446
      Moreover, they are not designed to work where adapters are connected
431
      back-to-back.
447
      back-to-back.
448
449
LowLatency 
450
----------
451
Parameter:    LowLatency
452
Values:       On, Off
453
Default:      Off
454
455
This is used to reduce the packet latency time of the adapter. Setting the 
456
LowLatency parameter to 'On' forces the adapter to pass any received packet
457
immediately to upper network layers and to send out any transmit packet as
458
fast as possible.
459
460
NOTE 1: The system load increases if LowLatency is set to 'On' and a lot
461
        of data packets are transmitted and received.
462
463
NOTE 2: This parameter is only used on adapters which are based on 
464
        PCI Express compatible chipsets.
432
***
465
***
433
466
434
467
435
5  Large Frame Support
468
6  Ethtool Support
469
==================
470
471
The sk98lin driver provides built-in ethtool support. The ethtool 
472
can be used to display or modify interface specific configurations.
473
474
Ethtool commands are invoked using a single parameter which reflects
475
the requested ethtool command plus an optional number of parameters 
476
which belong to the desired command.
477
478
It is not the intention of this section to explain the ethtool command
479
line tool and all its options. For further information refer to the 
480
manpage of the ethtool.  This sections describes only the sk98lin 
481
driver supported ethtool commands.
482
483
Pause Parameters
484
----------------
485
Query command:  -a
486
Set command:    -A [autoneg on|off] [rx on|off] [tx on|off]
487
Sample:         ethtool -A eth0 rx off tx off
488
489
Coalescing Parameters
490
---------------------
491
Query command:  -c
492
Set command:    -C [sample-interval I]
493
                   [rx-usecs N] [tx-usecs N]
494
                   [rx-usecs-low N] [tx-usecs-low N]
495
                   [rx-usecs-high N] [tx-usecs-high N]
496
Parameter:      I = Length of sample interval, in seconds
497
                    (supported values range from 1...10)
498
                N = Length of coalescing interval, in microseconds
499
                    (supported values range from 25...33,333)
500
Sample:         ethtool -C eth2 rx-usecs 500 tx-usecs 500
501
502
NOTE: The sk98lin driver does not support different settings
503
      for the rx and tx interrupt coalescing parameters.
504
505
Driver Information
506
------------------
507
Query command:  -i
508
Sample:         ethtool -i eth1
509
510
Checksumming Parameters
511
-----------------------
512
Query command:  -k
513
Set command:    -K [rx on|off] [tx on|off] [sg on|off]
514
Sample:         ethtool -K eth0 sg off
515
516
Locate NIC Command
517
------------------
518
Query command:  -p [N]
519
Parameter:      N = Amount of time to perform locate NIC command, in seconds
520
Sample:         ethtool -p 10 eth1
521
522
Driver-specific Statistics
523
--------------------------
524
Query command:  -S
525
Sample:         ethtool -S eth0
526
527
Setting Parameters
528
------------------
529
Set command:    -s [speed 10|100|1000] [duplex half|full] 
530
                   [autoneg on|off] [wol gd]
531
Sample:         ethtool -s eth2 wol d
532
***
533
534
535
7  Large Frame Support
436
======================
536
======================
437
537
438
The driver supports large frames (also called jumbo frames). Using large 
538
The driver supports large frames (also called jumbo frames). Using large 
Lines 444-453 Link Here
444
      ifconfig eth0 mtu 9000
544
      ifconfig eth0 mtu 9000
445
This will only work if you have two adapters connected back-to-back
545
This will only work if you have two adapters connected back-to-back
446
or if you use a switch that supports large frames. When using a switch, 
546
or if you use a switch that supports large frames. When using a switch, 
447
it should be configured to allow large frames and auto-negotiation should  
547
it should be configured to allow large frames. The setting must be 
448
be set to OFF. The setting must be configured on all adapters that can be 
548
configured on all adapters that can be reached by the large frames. 
449
reached by the large frames. If one adapter is not set to receive large 
549
If one adapter is not set to receive large frames, it will simply drop 
450
frames, it will simply drop them.
550
them.
451
551
452
You can switch back to the standard ethernet frame size by executing the 
552
You can switch back to the standard ethernet frame size by executing the 
453
following command:
553
following command:
Lines 459-465 Link Here
459
***
559
***
460
560
461
561
462
6  VLAN and Link Aggregation Support (IEEE 802.1, 802.1q, 802.3ad)
562
8  VLAN and Link Aggregation Support (IEEE 802.1, 802.1q, 802.3ad)
463
==================================================================
563
==================================================================
464
564
465
The Marvell Yukon/SysKonnect Linux drivers are able to support VLAN and 
565
The Marvell Yukon/SysKonnect Linux drivers are able to support VLAN and 
Lines 477-484 Link Here
477
      cause problems when unloading the driver.
577
      cause problems when unloading the driver.
478
578
479
579
480
7  Troubleshooting
580
9  Wake on Lan support
481
==================
581
======================
582
583
The sk98lin driver supports wake up from suspend mode with MagicPacket
584
on APM systems. Wake on Lan support is enabled by default. To disable it 
585
please use the ethtool.
586
587
NOTE 1: APM support has to be enabled in BIOS and in the kernel.
588
589
NOTE 2: Refer to the kernel documentation for additional requirements 
590
        regarding APM support.
591
592
593
10  Troubleshooting
594
===================
482
595
483
If any problems occur during the installation process, check the 
596
If any problems occur during the installation process, check the 
484
following list:
597
following list:
(-)linux/drivers/net/Kconfig (-22 / +97 lines)
Lines 1993-2011 Link Here
1993
	  It does not support the link failover and network management 
1993
	  It does not support the link failover and network management 
1994
	  features that "portable" vendor supplied sk98lin driver does.
1994
	  features that "portable" vendor supplied sk98lin driver does.
1995
	
1995
	
1996
1996
config SK98LIN
1997
config SK98LIN
1997
	tristate "Marvell Yukon Chipset / SysKonnect SK-98xx Support (DEPRECATED)"
1998
	tristate "Marvell Yukon Chipset / SysKonnect SK-98xx Support"
1998
	depends on PCI
1999
	depends on PCI
1999
	---help---
2000
	---help---
2000
	  This driver has been marked deprecated for Gentoo users, as it seems
2001
	  problematic and the new skge driver (CONFIG_SKGE) works much better.
2002
	  If you do not rely on features of this driver, please use SKGE instead.
2003
	  
2004
	  Say Y here if you have a Marvell Yukon or SysKonnect SK-98xx/SK-95xx
2001
	  Say Y here if you have a Marvell Yukon or SysKonnect SK-98xx/SK-95xx
2005
	  compliant Gigabit Ethernet Adapter. The following adapters are supported
2002
	  compliant Gigabit Ethernet Adapter. The following adapters are supported
2006
	  by this driver:
2003
	  by this driver:
2007
	    - 3Com 3C940 Gigabit LOM Ethernet Adapter
2004
	    - 3Com 3C940 Gigabit LOM Ethernet Adapter
2008
	    - 3Com 3C941 Gigabit LOM Ethernet Adapter
2005
	    - 3Com 3C941 Gigabit LOM Ethernet Adapter
2006
	    - 88E8021 Marvell 1000 Mbit PCI-X, single Port Copper 
2007
	    - 88E8021 Marvell 1000 Mbit PCI-X, single Port Fiber LX 
2008
	    - 88E8021 Marvell 1000 Mbit PCI-X, single Port Fiber SX 
2009
	    - 88E8022 Marvell 1000 Mbit PCI-X, dual Port Copper 
2010
	    - 88E8022 Marvell 1000 Mbit PCI-X, dual Port Copper (Gateway) 
2011
	    - 88E8022 Marvell 1000 Mbit PCI-X, dual Port Fiber LX 
2012
	    - 88E8022 Marvell 1000 Mbit PCI-X, dual Port Fiber SX 
2013
	    - 88E8061 Marvell 1000 Mbit PCI-E, single Port Copper 
2014
	    - 88E8061 Marvell 1000 Mbit PCI-E, single Port Fiber LX 
2015
	    - 88E8061 Marvell 1000 Mbit PCI-E, single Port Fiber SX 
2016
	    - 88E8062 Marvell 1000 Mbit PCI-E, dual Port Copper 
2017
	    - 88E8062 Marvell 1000 Mbit PCI-E, dual Port Copper (Gateway) 
2018
	    - 88E8062 Marvell 1000 Mbit PCI-E, dual Port Fiber LX 
2019
	    - 88E8062 Marvell 1000 Mbit PCI-E, dual Port Fiber SX 
2020
	    - Abocom EFE3K - 10/100 Ethernet Expresscard
2021
	    - Abocom EGE5K - Giga Ethernet Expresscard
2009
	    - Allied Telesyn AT-2970LX Gigabit Ethernet Adapter
2022
	    - Allied Telesyn AT-2970LX Gigabit Ethernet Adapter
2010
	    - Allied Telesyn AT-2970LX/2SC Gigabit Ethernet Adapter
2023
	    - Allied Telesyn AT-2970LX/2SC Gigabit Ethernet Adapter
2011
	    - Allied Telesyn AT-2970SX Gigabit Ethernet Adapter
2024
	    - Allied Telesyn AT-2970SX Gigabit Ethernet Adapter
Lines 2016-2046 Link Here
2016
	    - Allied Telesyn AT-2971T Gigabit Ethernet Adapter
2029
	    - Allied Telesyn AT-2971T Gigabit Ethernet Adapter
2017
	    - Belkin Gigabit Desktop Card 10/100/1000Base-T Adapter, Copper RJ-45
2030
	    - Belkin Gigabit Desktop Card 10/100/1000Base-T Adapter, Copper RJ-45
2018
	    - DGE-530T Gigabit Ethernet Adapter
2031
	    - DGE-530T Gigabit Ethernet Adapter
2032
	    - DGE-560T Gigabit Ethernet Adapter
2019
	    - EG1032 v2 Instant Gigabit Network Adapter
2033
	    - EG1032 v2 Instant Gigabit Network Adapter
2020
	    - EG1064 v2 Instant Gigabit Network Adapter
2034
	    - EG1064 v2 Instant Gigabit Network Adapter
2021
	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Abit)
2035
	    - Marvell 88E8001 Gigabit Ethernet Controller (Abit)
2022
	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Albatron)
2036
	    - Marvell 88E8001 Gigabit Ethernet Controller (Albatron)
2023
	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Asus)
2037
	    - Marvell 88E8001 Gigabit Ethernet Controller (Asus)
2024
	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (ECS)
2038
	    - Marvell 88E8001 Gigabit Ethernet Controller (Chaintech)
2025
	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Epox)
2039
	    - Marvell 88E8001 Gigabit Ethernet Controller (ECS)
2026
	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Foxconn)
2040
	    - Marvell 88E8001 Gigabit Ethernet Controller (Epox)
2027
	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Gigabyte)
2041
	    - Marvell 88E8001 Gigabit Ethernet Controller (Foxconn)
2028
	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Iwill)
2042
	    - Marvell 88E8001 Gigabit Ethernet Controller (Gigabyte)
2029
	    - Marvell 88E8050 Gigabit LOM Ethernet Adapter (Intel)
2043
	    - Marvell 88E8001 Gigabit Ethernet Controller (Iwill)
2044
	    - Marvell 88E8035 Fast Ethernet Controller (LGE)
2045
	    - Marvell 88E8035 Fast Ethernet Controller (Toshiba)
2046
	    - Marvell 88E8036 Fast Ethernet Controller (Arima)
2047
	    - Marvell 88E8036 Fast Ethernet Controller (Compal)
2048
	    - Marvell 88E8036 Fast Ethernet Controller (Inventec)
2049
	    - Marvell 88E8036 Fast Ethernet Controller (LGE)
2050
	    - Marvell 88E8036 Fast Ethernet Controller (Mitac)
2051
	    - Marvell 88E8036 Fast Ethernet Controller (Panasonic)
2052
	    - Marvell 88E8036 Fast Ethernet Controller (Quanta)
2053
	    - Marvell 88E8036 Fast Ethernet Controller (Toshiba)
2054
	    - Marvell 88E8036 Fast Ethernet Controller (Wistron)
2055
	    - Marvell 88E8050 Gigabit Ethernet Controller (Gateway)
2056
	    - Marvell 88E8050 Gigabit Ethernet Controller (Intel)
2057
	    - Marvell 88E8052 Gigabit Ethernet Controller (ASRock)
2058
	    - Marvell 88E8052 Gigabit Ethernet Controller (Aopen)
2059
	    - Marvell 88E8052 Gigabit Ethernet Controller (Asus)
2060
	    - Marvell 88E8052 Gigabit Ethernet Controller (Gigabyte)
2061
	    - Marvell 88E8052 Gigabit Ethernet Controller (MSI)
2062
	    - Marvell 88E8052 Gigabit Ethernet Controller (Wistron)
2063
	    - Marvell 88E8053 Gigabit Ethernet Controller (ASRock)
2064
	    - Marvell 88E8053 Gigabit Ethernet Controller (Albatron)
2065
	    - Marvell 88E8053 Gigabit Ethernet Controller (Aopen)
2066
	    - Marvell 88E8053 Gigabit Ethernet Controller (Arima)
2067
	    - Marvell 88E8053 Gigabit Ethernet Controller (Asus)
2068
	    - Marvell 88E8053 Gigabit Ethernet Controller (Chaintech)
2069
	    - Marvell 88E8053 Gigabit Ethernet Controller (Clevo)
2070
	    - Marvell 88E8053 Gigabit Ethernet Controller (Compal)
2071
	    - Marvell 88E8053 Gigabit Ethernet Controller (DFI)
2072
	    - Marvell 88E8053 Gigabit Ethernet Controller (Epox)
2073
	    - Marvell 88E8053 Gigabit Ethernet Controller (Gigabyte)
2074
	    - Marvell 88E8053 Gigabit Ethernet Controller (Inventec)
2075
	    - Marvell 88E8053 Gigabit Ethernet Controller (LGE)
2076
	    - Marvell 88E8053 Gigabit Ethernet Controller (MSI)
2077
	    - Marvell 88E8053 Gigabit Ethernet Controller (Mitac)
2078
	    - Marvell 88E8053 Gigabit Ethernet Controller (Panasonic)
2079
	    - Marvell 88E8053 Gigabit Ethernet Controller (Quanta)
2080
	    - Marvell 88E8053 Gigabit Ethernet Controller (SOYO)
2081
	    - Marvell 88E8053 Gigabit Ethernet Controller (Shuttle)
2082
	    - Marvell 88E8053 Gigabit Ethernet Controller (Toshiba)
2083
	    - Marvell 88E8053 Gigabit Ethernet Controller (Trigem)
2084
	    - Marvell RDK-8001 
2030
	    - Marvell RDK-8001 Adapter
2085
	    - Marvell RDK-8001 Adapter
2031
	    - Marvell RDK-8002 Adapter
2086
	    - Marvell RDK-8002 Adapter
2087
	    - Marvell RDK-8003 
2032
	    - Marvell RDK-8003 Adapter
2088
	    - Marvell RDK-8003 Adapter
2033
	    - Marvell RDK-8004 Adapter
2089
	    - Marvell RDK-8004 Adapter
2034
	    - Marvell RDK-8006 Adapter
2090
	    - Marvell RDK-8006 Adapter
2035
	    - Marvell RDK-8007 Adapter
2091
	    - Marvell RDK-8007 Adapter
2036
	    - Marvell RDK-8008 Adapter
2092
	    - Marvell RDK-8008 Adapter
2037
	    - Marvell RDK-8009 Adapter
2093
	    - Marvell RDK-8009 Adapter
2038
	    - Marvell RDK-8010 Adapter
2094
	    - Marvell RDK-8010 
2039
	    - Marvell RDK-8011 Adapter
2095
	    - Marvell RDK-8011 Adapter
2040
	    - Marvell RDK-8012 Adapter
2096
	    - Marvell RDK-8012 Adapter
2041
	    - Marvell RDK-8052 Adapter
2097
	    - Marvell RDK-8035 
2042
	    - Marvell Yukon Gigabit Ethernet 10/100/1000Base-T Adapter (32 bit)
2098
	    - Marvell RDK-8036 
2043
	    - Marvell Yukon Gigabit Ethernet 10/100/1000Base-T Adapter (64 bit)
2099
	    - Marvell RDK-8052 
2100
	    - Marvell RDK-8053 
2101
	    - Marvell Yukon Gigabit Ethernet 10/100/1000Base-T Controller (32 bit)
2102
	    - Marvell Yukon Gigabit Ethernet 10/100/1000Base-T Controller (64 bit)
2044
	    - N-Way PCI-Bus Giga-Card 1000/100/10Mbps(L)
2103
	    - N-Way PCI-Bus Giga-Card 1000/100/10Mbps(L)
2045
	    - SK-9521 10/100/1000Base-T Adapter
2104
	    - SK-9521 10/100/1000Base-T Adapter
2046
	    - SK-9521 V2.0 10/100/1000Base-T Adapter
2105
	    - SK-9521 V2.0 10/100/1000Base-T Adapter
Lines 2060-2080 Link Here
2060
	    - SK-9871 Gigabit Ethernet Server Adapter (SK-NET GE-ZX)
2119
	    - SK-9871 Gigabit Ethernet Server Adapter (SK-NET GE-ZX)
2061
	    - SK-9871 V2.0 Gigabit Ethernet 1000Base-ZX Adapter
2120
	    - SK-9871 V2.0 Gigabit Ethernet 1000Base-ZX Adapter
2062
	    - SK-9872 Gigabit Ethernet Server Adapter (SK-NET GE-ZX dual link)
2121
	    - SK-9872 Gigabit Ethernet Server Adapter (SK-NET GE-ZX dual link)
2122
	    - SK-9S21 Server Adapter 
2123
	    - SK-9S22 Server Adapter 
2124
	    - SK-9S24 Server Adapter 
2125
	    - SK-9S34 Server Adapter 
2126
	    - SK-9S81 Server Adapter 
2127
	    - SK-9S82 Server Adapter 
2128
	    - SK-9S91 Server Adapter 
2129
	    - SK-9S92 Server Adapter 
2063
	    - SMC EZ Card 1000 (SMC9452TXV.2)
2130
	    - SMC EZ Card 1000 (SMC9452TXV.2)
2064
	  
2131
	  
2065
	  The adapters support Jumbo Frames.
2132
	  The adapters support Jumbo Frames.
2066
	  The dual link adapters support link-failover and dual port features.
2133
	  The dual link adapters support link-failover and dual port features.
2067
	  Both Marvell Yukon and SysKonnect SK-98xx/SK-95xx adapters support 
2134
	  Both Marvell Yukon and SysKonnect SK-98xx/SK-95xx adapters support 
2068
	  the scatter-gather functionality with sendfile(). Please refer to 
2135
	  the scatter-gather functionality with sendfile(). Please refer to 
2069
	  <file:Documentation/networking/sk98lin.txt> for more information about
2136
	  Documentation/networking/sk98lin.txt for more information about
2070
	  optional driver parameters.
2137
	  optional driver parameters.
2071
	  Questions concerning this driver may be addressed to:
2138
	  Questions concerning this driver may be addressed to:
2072
	      <linux@syskonnect.de>
2139
	      linux@syskonnect.de
2073
	  
2140
	  
2074
	  If you want to compile this driver as a module ( = code which can be
2141
	  If you want to compile this driver as a module ( = code which can be
2075
	  inserted in and removed from the running kernel whenever you want),
2142
	  inserted in and removed from the running kernel whenever you want),
2076
	  say M here and read <file:Documentation/kbuild/modules.txt>. The module will
2143
	  say M here and read Documentation/modules.txt. This is recommended.
2077
	  be called sk98lin. This is recommended.
2144
	  The module will be called sk98lin. This is recommended.
2145
2146
config SK98LIN_NAPI
2147
	bool "Use Rx polling (NAPI)"
2148
	depends on SK98LIN
2149
	help
2150
	  NAPI is a new driver API designed to reduce CPU and interrupt load
2151
	  when the driver is receiving lots of packets from the card.
2152
2078
2153
2079
config VIA_VELOCITY
2154
config VIA_VELOCITY
2080
	tristate "VIA Velocity support"
2155
	tristate "VIA Velocity support"

Return to bug 93283