Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
173a9b29
Commit
173a9b29
authored
Jun 03, 2003
by
Alexander Viro
Committed by
David S. Miller
Jun 03, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET]: Move sk98lin driver away from init_etherdev().
parent
19e4e57a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
195 additions
and
383 deletions
+195
-383
drivers/net/sk98lin/h/skdrv2nd.h
drivers/net/sk98lin/h/skdrv2nd.h
+1
-0
drivers/net/sk98lin/skge.c
drivers/net/sk98lin/skge.c
+49
-28
drivers/net/sk98lin/skproc.c
drivers/net/sk98lin/skproc.c
+145
-355
No files found.
drivers/net/sk98lin/h/skdrv2nd.h
View file @
173a9b29
...
@@ -383,6 +383,7 @@ struct s_DevNet {
...
@@ -383,6 +383,7 @@ struct s_DevNet {
int
Mtu
;
int
Mtu
;
int
Up
;
int
Up
;
SK_AC
*
pAC
;
SK_AC
*
pAC
;
struct
proc_dir_entry
*
proc
;
};
};
typedef
struct
s_TxPort
TX_PORT
;
typedef
struct
s_TxPort
TX_PORT
;
...
...
drivers/net/sk98lin/skge.c
View file @
173a9b29
...
@@ -351,11 +351,7 @@ static int SkGeIocMib(DEV_NET*, unsigned int, int);
...
@@ -351,11 +351,7 @@ static int SkGeIocMib(DEV_NET*, unsigned int, int);
static
const
char
SK_Root_Dir_entry
[]
=
"sk98lin"
;
static
const
char
SK_Root_Dir_entry
[]
=
"sk98lin"
;
static
struct
proc_dir_entry
*
pSkRootDir
;
static
struct
proc_dir_entry
*
pSkRootDir
;
extern
struct
file_operations
sk_proc_fops
;
//extern struct proc_dir_entry Our_Proc_Dir;
extern
int
sk_proc_read
(
char
*
buffer
,
char
**
buffer_location
,
off_t
offset
,
int
buffer_length
,
int
*
eof
,
void
*
data
);
#ifdef DEBUG
#ifdef DEBUG
static
void
DumpMsg
(
struct
sk_buff
*
,
char
*
);
static
void
DumpMsg
(
struct
sk_buff
*
,
char
*
);
...
@@ -399,7 +395,6 @@ static int __init skge_probe (void)
...
@@ -399,7 +395,6 @@ static int __init skge_probe (void)
struct
pci_dev
*
pdev
=
NULL
;
struct
pci_dev
*
pdev
=
NULL
;
unsigned
long
base_address
;
unsigned
long
base_address
;
struct
net_device
*
dev
=
NULL
;
struct
net_device
*
dev
=
NULL
;
struct
proc_dir_entry
*
pProcFile
;
if
(
probed
)
if
(
probed
)
return
-
ENODEV
;
return
-
ENODEV
;
...
@@ -420,7 +415,6 @@ static int __init skge_probe (void)
...
@@ -420,7 +415,6 @@ static int __init skge_probe (void)
while
((
pdev
=
pci_find_device
(
PCI_VENDOR_ID_SYSKONNECT
,
while
((
pdev
=
pci_find_device
(
PCI_VENDOR_ID_SYSKONNECT
,
PCI_DEVICE_ID_SYSKONNECT_GE
,
pdev
))
!=
NULL
)
{
PCI_DEVICE_ID_SYSKONNECT_GE
,
pdev
))
!=
NULL
)
{
dev
=
NULL
;
pNet
=
NULL
;
pNet
=
NULL
;
if
(
pci_enable_device
(
pdev
))
if
(
pci_enable_device
(
pdev
))
...
@@ -431,7 +425,8 @@ static int __init skge_probe (void)
...
@@ -431,7 +425,8 @@ static int __init skge_probe (void)
pci_set_dma_mask
(
pdev
,
(
u64
)
0xffffffff
))
pci_set_dma_mask
(
pdev
,
(
u64
)
0xffffffff
))
continue
;
continue
;
if
((
dev
=
init_etherdev
(
dev
,
sizeof
(
DEV_NET
)))
==
0
)
{
dev
=
alloc_etherdev
(
sizeof
(
DEV_NET
));
if
(
!
dev
)
{
printk
(
KERN_ERR
"Unable to allocate etherdev "
printk
(
KERN_ERR
"Unable to allocate etherdev "
"structure!
\n
"
);
"structure!
\n
"
);
break
;
break
;
...
@@ -440,7 +435,7 @@ static int __init skge_probe (void)
...
@@ -440,7 +435,7 @@ static int __init skge_probe (void)
pNet
=
dev
->
priv
;
pNet
=
dev
->
priv
;
pNet
->
pAC
=
kmalloc
(
sizeof
(
SK_AC
),
GFP_KERNEL
);
pNet
->
pAC
=
kmalloc
(
sizeof
(
SK_AC
),
GFP_KERNEL
);
if
(
pNet
->
pAC
==
NULL
){
if
(
pNet
->
pAC
==
NULL
){
kfree
(
dev
->
priv
);
kfree
(
dev
);
printk
(
KERN_ERR
"Unable to allocate adapter "
printk
(
KERN_ERR
"Unable to allocate adapter "
"structure!
\n
"
);
"structure!
\n
"
);
break
;
break
;
...
@@ -477,15 +472,6 @@ static int __init skge_probe (void)
...
@@ -477,15 +472,6 @@ static int __init skge_probe (void)
proc_root_initialized
=
1
;
proc_root_initialized
=
1
;
}
}
pProcFile
=
create_proc_entry
(
dev
->
name
,
S_IFREG
|
0444
,
pSkRootDir
);
pProcFile
->
read_proc
=
sk_proc_read
;
pProcFile
->
write_proc
=
NULL
;
pProcFile
->
nlink
=
1
;
pProcFile
->
size
=
sizeof
(
dev
->
name
+
1
);
pProcFile
->
data
=
(
void
*
)
pProcFile
;
pProcFile
->
owner
=
THIS_MODULE
;
/*
/*
* Dummy value.
* Dummy value.
*/
*/
...
@@ -532,11 +518,29 @@ static int __init skge_probe (void)
...
@@ -532,11 +518,29 @@ static int __init skge_probe (void)
pNet
->
PortNr
=
0
;
pNet
->
PortNr
=
0
;
pNet
->
NetNr
=
0
;
pNet
->
NetNr
=
0
;
if
(
register_netdev
(
dev
)
!=
0
)
{
printk
(
KERN_ERR
"Unable to register etherdev
\n
"
);
sk98lin_root_dev
=
pAC
->
Next
;
remove_proc_entry
(
dev
->
name
,
pSkRootDir
);
FreeResources
(
dev
);
kfree
(
dev
);
continue
;
}
pNet
->
proc
=
create_proc_entry
(
dev
->
name
,
S_IFREG
|
0444
,
pSkRootDir
);
if
(
pNet
->
proc
)
{
pNet
->
proc
->
data
=
dev
;
pNet
->
proc
->
owner
=
THIS_MODULE
;
pNet
->
proc
->
proc_fops
=
&
sk_proc_fops
;
}
boards_found
++
;
boards_found
++
;
/* More then one port found */
/* More then one port found */
if
((
pAC
->
GIni
.
GIMacsFound
==
2
)
&&
(
pAC
->
RlmtNets
==
2
))
{
if
((
pAC
->
GIni
.
GIMacsFound
==
2
)
&&
(
pAC
->
RlmtNets
==
2
))
{
if
((
dev
=
init_etherdev
(
NULL
,
sizeof
(
DEV_NET
)))
==
0
)
{
dev
=
alloc_etherdev
(
sizeof
(
DEV_NET
));
if
(
!
dev
)
{
printk
(
KERN_ERR
"Unable to allocate etherdev "
printk
(
KERN_ERR
"Unable to allocate etherdev "
"structure!
\n
"
);
"structure!
\n
"
);
break
;
break
;
...
@@ -559,20 +563,25 @@ static int __init skge_probe (void)
...
@@ -559,20 +563,25 @@ static int __init skge_probe (void)
dev
->
do_ioctl
=
&
SkGeIoctl
;
dev
->
do_ioctl
=
&
SkGeIoctl
;
dev
->
change_mtu
=
&
SkGeChangeMtu
;
dev
->
change_mtu
=
&
SkGeChangeMtu
;
pProcFile
=
create_proc_entry
(
dev
->
name
,
S_IFREG
|
0444
,
pSkRootDir
);
pProcFile
->
read_proc
=
sk_proc_read
;
pProcFile
->
write_proc
=
NULL
;
pProcFile
->
nlink
=
1
;
pProcFile
->
size
=
sizeof
(
dev
->
name
+
1
);
pProcFile
->
data
=
(
void
*
)
pProcFile
;
pProcFile
->
owner
=
THIS_MODULE
;
memcpy
((
caddr_t
)
&
dev
->
dev_addr
,
memcpy
((
caddr_t
)
&
dev
->
dev_addr
,
(
caddr_t
)
&
pAC
->
Addr
.
Net
[
1
].
CurrentMacAddress
,
6
);
(
caddr_t
)
&
pAC
->
Addr
.
Net
[
1
].
CurrentMacAddress
,
6
);
printk
(
"%s: %s
\n
"
,
dev
->
name
,
pAC
->
DeviceStr
);
printk
(
"%s: %s
\n
"
,
dev
->
name
,
pAC
->
DeviceStr
);
printk
(
" PrefPort:B RlmtMode:Dual Check Link State
\n
"
);
printk
(
" PrefPort:B RlmtMode:Dual Check Link State
\n
"
);
if
(
register_netdev
(
dev
)
!=
0
)
{
printk
(
KERN_ERR
"Unable to register etherdev
\n
"
);
kfree
(
dev
);
break
;
}
pNet
->
proc
=
create_proc_entry
(
dev
->
name
,
S_IFREG
|
0444
,
pSkRootDir
);
if
(
pNet
->
proc
)
{
pNet
->
proc
->
data
=
dev
;
pNet
->
proc
->
owner
=
THIS_MODULE
;
pNet
->
proc
->
proc_fops
=
&
sk_proc_fops
;
}
}
}
...
@@ -740,6 +749,7 @@ static int __init skge_init_module(void)
...
@@ -740,6 +749,7 @@ static int __init skge_init_module(void)
return
cards
?
0
:
-
ENODEV
;
return
cards
?
0
:
-
ENODEV
;
}
/* skge_init_module */
}
/* skge_init_module */
spinlock_t
sk_devs_lock
=
SPIN_LOCK_UNLOCKED
;
/*****************************************************************************
/*****************************************************************************
*
*
...
@@ -766,6 +776,11 @@ SK_EVPARA EvPara;
...
@@ -766,6 +776,11 @@ SK_EVPARA EvPara;
netif_stop_queue
(
sk98lin_root_dev
);
netif_stop_queue
(
sk98lin_root_dev
);
SkGeYellowLED
(
pAC
,
pAC
->
IoBase
,
0
);
SkGeYellowLED
(
pAC
,
pAC
->
IoBase
,
0
);
if
(
pNet
->
proc
)
{
spin_lock
(
&
sk_devs_lock
);
pNet
->
proc
->
data
=
NULL
;
spin_unlock
(
&
sk_devs_lock
);
}
if
(
pAC
->
BoardLevel
==
2
)
{
if
(
pAC
->
BoardLevel
==
2
)
{
/* board is still alive */
/* board is still alive */
...
@@ -792,6 +807,12 @@ SK_EVPARA EvPara;
...
@@ -792,6 +807,12 @@ SK_EVPARA EvPara;
}
}
if
((
pAC
->
GIni
.
GIMacsFound
==
2
)
&&
pAC
->
RlmtNets
==
2
){
if
((
pAC
->
GIni
.
GIMacsFound
==
2
)
&&
pAC
->
RlmtNets
==
2
){
pNet
=
(
DEV_NET
*
)
pAC
->
dev
[
1
]
->
priv
;
if
(
pNet
->
proc
)
{
spin_lock
(
&
sk_devs_lock
);
pNet
->
proc
->
data
=
NULL
;
spin_unlock
(
&
sk_devs_lock
);
}
unregister_netdev
(
pAC
->
dev
[
1
]);
unregister_netdev
(
pAC
->
dev
[
1
]);
kfree
(
pAC
->
dev
[
1
]);
kfree
(
pAC
->
dev
[
1
]);
}
}
...
...
drivers/net/sk98lin/skproc.c
View file @
173a9b29
...
@@ -46,378 +46,168 @@
...
@@ -46,378 +46,168 @@
#include "h/skdrv1st.h"
#include "h/skdrv1st.h"
#include "h/skdrv2nd.h"
#include "h/skdrv2nd.h"
#define ZEROPAD 1
/* pad with zero */
#define SIGN 2
/* unsigned/signed long */
#define PLUS 4
/* show plus */
#define SPACE 8
/* space if plus */
#define LEFT 16
/* left justified */
//#define SPECIAL 32 /* 0x */
#define LARGE 64
extern
char
*
SkNumber
(
char
*
str
,
long
long
num
,
int
base
,
int
size
,
extern
spinlock_t
sk_devs_lock
;
int
precision
,
int
type
);
int
proc_read
(
char
*
buffer
,
char
**
buffer_location
,
off_t
offset
,
int
buffer_length
,
int
*
eof
,
void
*
data
);
static
int
sk_show_dev
(
struct
net_device
*
dev
,
char
*
buf
)
extern
struct
net_device
*
sk98lin_root_dev
;
/*****************************************************************************
*
* proc_read - print "summaries" entry
*
* Description:
* This function fills the proc entry with statistic data about
* the ethernet device.
*
*
* Returns: buffer with statistic data
*
*/
int
sk_proc_read
(
char
*
buffer
,
char
**
buffer_location
,
off_t
offset
,
int
buffer_length
,
int
*
eof
,
void
*
data
)
{
{
DEV_NET
*
pNet
=
(
DEV_NET
*
)
dev
->
priv
;
SK_AC
*
pAC
=
pNet
->
pAC
;
int
t
=
pNet
->
PortNr
;
SK_RLMT_NET
*
rlmt
=
&
pAC
->
Rlmt
.
Net
[
t
];
unsigned
long
Flags
;
unsigned
Size
;
int
len
=
0
;
int
len
=
0
;
int
t
;
int
i
;
int
i
;
DEV_NET
*
pNet
;
SK_AC
*
pAC
;
char
test_buf
[
100
];
unsigned
long
Flags
;
unsigned
int
Size
;
struct
net_device
*
next
;
struct
net_device
*
SkgeProcDev
=
sk98lin_root_dev
;
SK_PNMI_STRUCT_DATA
*
pPnmiStruct
;
SK_PNMI_STRUCT_DATA
*
pPnmiStruct
=
&
pAC
->
PnmiStruct
;
SK_PNMI_STAT
*
pPnmiStat
;
SK_PNMI_STAT
*
pPnmiStat
;
struct
proc_dir_entry
*
file
=
(
struct
proc_dir_entry
*
)
data
;
while
(
SkgeProcDev
)
{
pNet
=
(
DEV_NET
*
)
SkgeProcDev
->
priv
;
pAC
=
pNet
->
pAC
;
next
=
pAC
->
Next
;
pPnmiStruct
=
&
pAC
->
PnmiStruct
;
/* NetIndex in GetStruct is now required, zero is only dummy */
for
(
t
=
pAC
->
GIni
.
GIMacsFound
;
t
>
0
;
t
--
)
{
spin_lock_irqsave
(
&
pAC
->
SlowPathLock
,
Flags
);
if
((
pAC
->
GIni
.
GIMacsFound
==
2
)
&&
pAC
->
RlmtNets
==
1
)
Size
=
SK_PNMI_STRUCT_SIZE
;
t
--
;
SkPnmiGetStruct
(
pAC
,
pAC
->
IoBase
,
pPnmiStruct
,
&
Size
,
t
);
spin_unlock_irqrestore
(
&
pAC
->
SlowPathLock
,
Flags
);
spin_lock_irqsave
(
&
pAC
->
SlowPathLock
,
Flags
);
Size
=
SK_PNMI_STRUCT_SIZE
;
pPnmiStat
=
&
pPnmiStruct
->
Stat
[
0
];
SkPnmiGetStruct
(
pAC
,
pAC
->
IoBase
,
pPnmiStruct
,
&
Size
,
t
-
1
);
len
=
sprintf
(
buf
,
"
\n
Detailed statistic for device %s
\n
"
,
dev
->
name
);
spin_unlock_irqrestore
(
&
pAC
->
SlowPathLock
,
Flags
);
len
+=
sprintf
(
buf
+
len
,
"==================================
\n
"
);
if
(
strcmp
(
pAC
->
dev
[
t
-
1
]
->
name
,
file
->
name
)
==
0
)
{
/* Board statistics */
pPnmiStat
=
&
pPnmiStruct
->
Stat
[
0
];
len
+=
sprintf
(
buf
+
len
,
"
\n
Board statistics
\n\n
"
);
len
=
sprintf
(
buffer
,
len
+=
sprintf
(
buf
+
len
,
"Active Port %c
\n
"
,
"
\n
Detailed statistic for device %s
\n
"
,
'A'
+
rlmt
->
Port
[
rlmt
->
ActivePort
]
->
PortNumber
);
pAC
->
dev
[
t
-
1
]
->
name
);
len
+=
sprintf
(
buf
+
len
,
"Preferred Port %c
\n
"
,
len
+=
sprintf
(
buffer
+
len
,
'A'
+
rlmt
->
Port
[
rlmt
->
PrefPort
]
->
PortNumber
);
"==================================
\n
"
);
len
+=
sprintf
(
buf
+
len
,
"Bus speed (Mhz) %d
\n
"
,
/* Board statistics */
pPnmiStruct
->
BusSpeed
);
len
+=
sprintf
(
buffer
+
len
,
"
\n
Board statistics
\n\n
"
);
len
+=
sprintf
(
buf
+
len
,
"Bus width (Bit) %d
\n
"
,
len
+=
sprintf
(
buffer
+
len
,
pPnmiStruct
->
BusWidth
);
"Active Port %c
\n
"
,
'A'
+
pAC
->
Rlmt
.
Net
[
t
-
1
].
Port
[
pAC
->
Rlmt
.
for
(
i
=
0
;
i
<
SK_MAX_SENSORS
;
i
++
)
{
Net
[
t
-
1
].
PrefPort
]
->
PortNumber
);
SK_SENSOR
*
sens
=
&
pAC
->
I2c
.
SenTable
[
i
];
len
+=
sprintf
(
buffer
+
len
,
SK_I32
val
=
sens
->
SenValue
;
"Preferred Port %c
\n
"
,
if
(
strcmp
(
sens
->
SenDesc
,
"Temperature"
)
==
0
)
{
'A'
+
pAC
->
Rlmt
.
Net
[
t
-
1
].
Port
[
pAC
->
Rlmt
.
len
+=
sprintf
(
buf
+
len
,
Net
[
t
-
1
].
PrefPort
]
->
PortNumber
);
"Temperature (C) %d.%d
\n
"
,
val
/
10
,
val
%
10
);
len
+=
sprintf
(
buffer
+
len
,
val
=
val
*
18
+
3200
;
"Bus speed (Mhz) %d
\n
"
,
len
+=
sprintf
(
buf
+
len
,
pPnmiStruct
->
BusSpeed
);
"Temperature (F) %d.%d
\n
"
,
val
/
100
,
val
%
10
);
len
+=
sprintf
(
buffer
+
len
,
}
else
if
(
strcmp
(
sens
->
SenDesc
,
"Speed Fan"
)
==
0
)
{
"Bus width (Bit) %d
\n
"
,
len
+=
sprintf
(
buf
+
len
,
pPnmiStruct
->
BusWidth
);
"Speed Fan %d
\n
"
,
val
);
for
(
i
=
0
;
i
<
SK_MAX_SENSORS
;
i
++
)
{
}
else
{
if
(
strcmp
(
pAC
->
I2c
.
SenTable
[
i
].
SenDesc
,
len
+=
sprintf
(
buf
+
len
,
"Temperature"
)
==
0
)
{
"%-20s %d.%d
\n
"
,
len
+=
sprintf
(
buffer
+
len
,
sens
->
SenDesc
,
val
/
1000
,
val
%
1000
);
"Temperature (C) %d.%d
\n
"
,
pAC
->
I2c
.
SenTable
[
i
].
SenValue
/
10
,
pAC
->
I2c
.
SenTable
[
i
].
SenValue
%
10
);
len
+=
sprintf
(
buffer
+
len
,
"Temperature (F) %d.%d
\n
"
,
((((
pAC
->
I2c
.
SenTable
[
i
].
SenValue
)
*
10
)
*
9
)
/
5
+
3200
)
/
100
,
((((
pAC
->
I2c
.
SenTable
[
i
].
SenValue
)
*
10
)
*
9
)
/
5
+
3200
)
%
10
);
}
else
if
(
strcmp
(
pAC
->
I2c
.
SenTable
[
i
].
SenDesc
,
"Speed Fan"
)
==
0
)
{
len
+=
sprintf
(
buffer
+
len
,
"Speed Fan %d
\n
"
,
pAC
->
I2c
.
SenTable
[
i
].
SenValue
);
}
else
{
len
+=
sprintf
(
buffer
+
len
,
"%-20s %d.%d
\n
"
,
pAC
->
I2c
.
SenTable
[
i
].
SenDesc
,
pAC
->
I2c
.
SenTable
[
i
].
SenValue
/
1000
,
pAC
->
I2c
.
SenTable
[
i
].
SenValue
%
1000
);
}
}
/*Receive statistics */
len
+=
sprintf
(
buffer
+
len
,
"
\n
Receive statistics
\n\n
"
);
len
+=
sprintf
(
buffer
+
len
,
"Received bytes %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxOctetsOkCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Received packets %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxOkCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Received errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxFcsCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Received dropped %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStruct
->
RxNoBufCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Received multicast %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxMulticastOkCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Received errors types
\n
"
);
len
+=
sprintf
(
buffer
+
len
,
" length errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxRuntCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
" over errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxFifoOverflowCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
" crc errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxFcsCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
" frame errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxFramingCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
" fifo errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxFifoOverflowCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
" missed errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatRxMissedCts
,
10
,
0
,
-
1
,
0
));
/*Transmit statistics */
len
+=
sprintf
(
buffer
+
len
,
"
\n
Transmit statistics
\n\n
"
);
len
+=
sprintf
(
buffer
+
len
,
"Transmit bytes %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatTxOctetsOkCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Transmit packets %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatTxOkCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Transmit errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatTxSingleCollisionCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Transmit dropped %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStruct
->
TxNoBufCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Transmit collisions %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatTxSingleCollisionCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
"Transmited errors types
\n
"
);
len
+=
sprintf
(
buffer
+
len
,
" aborted errors %ld
\n
"
,
pAC
->
stats
.
tx_aborted_errors
);
len
+=
sprintf
(
buffer
+
len
,
" carrier errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatTxCarrierCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
" fifo errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatTxFifoUnderrunCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
" heartbeat errors %s
\n
"
,
SkNumber
(
test_buf
,
pPnmiStat
->
StatTxCarrierCts
,
10
,
0
,
-
1
,
0
));
len
+=
sprintf
(
buffer
+
len
,
" window errors %ld
\n
"
,
pAC
->
stats
.
tx_window_errors
);
}
}
}
SkgeProcDev
=
next
;
}
if
(
offset
>=
len
)
{
*
eof
=
1
;
return
0
;
}
}
*
buffer_location
=
buffer
+
offset
;
/*Receive statistics */
if
(
buffer_length
>=
len
-
offset
)
{
*
eof
=
1
;
len
+=
sprintf
(
buf
+
len
,
"
\n
Receive statistics
\n\n
"
);
}
return
(
min_t
(
int
,
buffer_length
,
len
-
offset
));
len
+=
sprintf
(
buf
+
len
,
"Received bytes %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxOctetsOkCts
);
len
+=
sprintf
(
buf
+
len
,
"Received packets %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxOkCts
);
len
+=
sprintf
(
buf
+
len
,
"Received errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxFcsCts
);
len
+=
sprintf
(
buf
+
len
,
"Received dropped %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStruct
->
RxNoBufCts
);
len
+=
sprintf
(
buf
+
len
,
"Received multicast %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxMulticastOkCts
);
len
+=
sprintf
(
buf
+
len
,
"Received errors types
\n
"
);
len
+=
sprintf
(
buf
+
len
,
" length errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxRuntCts
);
len
+=
sprintf
(
buf
+
len
,
" over errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxFifoOverflowCts
);
len
+=
sprintf
(
buf
+
len
,
" crc errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxFcsCts
);
len
+=
sprintf
(
buf
+
len
,
" frame errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxFramingCts
);
len
+=
sprintf
(
buf
+
len
,
" fifo errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxFifoOverflowCts
);
len
+=
sprintf
(
buf
+
len
,
" missed errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatRxMissedCts
);
/*Transmit statistics */
len
+=
sprintf
(
buf
+
len
,
"
\n
Transmit statistics
\n\n
"
);
len
+=
sprintf
(
buf
+
len
,
"Transmit bytes %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatTxOctetsOkCts
);
len
+=
sprintf
(
buf
+
len
,
"Transmit packets %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatTxOkCts
);
len
+=
sprintf
(
buf
+
len
,
"Transmit errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatTxSingleCollisionCts
);
len
+=
sprintf
(
buf
+
len
,
"Transmit dropped %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStruct
->
TxNoBufCts
);
len
+=
sprintf
(
buf
+
len
,
"Transmit collisions %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatTxSingleCollisionCts
);
len
+=
sprintf
(
buf
+
len
,
"Transmited errors types
\n
"
);
len
+=
sprintf
(
buf
+
len
,
" aborted errors %ld
\n
"
,
pAC
->
stats
.
tx_aborted_errors
);
len
+=
sprintf
(
buf
+
len
,
" carrier errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatTxCarrierCts
);
len
+=
sprintf
(
buf
+
len
,
" fifo errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatTxFifoUnderrunCts
);
len
+=
sprintf
(
buf
+
len
,
" heartbeat errors %Ld
\n
"
,
(
unsigned
long
long
)
pPnmiStat
->
StatTxCarrierCts
);
len
+=
sprintf
(
buf
+
len
,
" window errors %ld
\n
"
,
pAC
->
stats
.
tx_window_errors
);
return
len
;
}
}
static
ssize_t
sk_read
(
struct
file
*
file
,
char
*
buf
,
size_t
nbytes
,
loff_t
*
ppos
)
/*****************************************************************************
*
* SkDoDiv - convert 64bit number
*
* Description:
* This function "converts" a long long number.
*
* Returns:
* remainder of division
*/
static
long
SkDoDiv
(
long
long
Dividend
,
int
Divisor
,
long
long
*
pErg
)
{
{
long
Rest
;
struct
inode
*
inode
=
file
->
f_dentry
->
d_inode
;
long
long
Ergebnis
;
struct
proc_dir_entry
*
entry
=
PDE
(
inode
);
long
Akku
;
char
*
page
=
(
char
*
)
__get_free_page
(
GFP_KERNEL
);
struct
net_device
*
dev
;
loff_t
pos
=
*
ppos
;
Akku
=
Dividend
>>
32
;
ssize_t
res
=
0
;
int
len
=
0
;
Ergebnis
=
((
long
long
)
(
Akku
/
Divisor
))
<<
32
;
Rest
=
Akku
%
Divisor
;
Akku
=
Rest
<<
16
;
Akku
|=
((
Dividend
&
0xFFFF0000
)
>>
16
);
Ergebnis
+=
((
long
long
)
(
Akku
/
Divisor
))
<<
16
;
Rest
=
Akku
%
Divisor
;
Akku
=
Rest
<<
16
;
Akku
|=
(
Dividend
&
0xFFFF
);
Ergebnis
+=
(
Akku
/
Divisor
);
Rest
=
Akku
%
Divisor
;
*
pErg
=
Ergebnis
;
if
(
!
page
)
return
(
Rest
);
return
-
ENOMEM
;
spin_lock
(
&
sk_devs_lock
);
dev
=
entry
->
data
;
if
(
dev
)
len
=
sk_show_dev
(
dev
,
page
);
spin_unlock
(
&
sk_devs_lock
);
if
(
pos
>=
0
&&
pos
<
len
)
{
res
=
nbytes
;
if
(
res
>
len
-
pos
)
res
=
len
-
pos
;
if
(
copy_to_user
(
page
+
pos
,
buf
,
nbytes
))
res
=
-
EFAULT
;
else
*
ppos
=
pos
+
res
;
}
free_page
((
unsigned
long
)
page
);
return
nbytes
;
}
}
static
loff_t
sk_lseek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
)
#if 0
#define do_div(n,base) ({ \
long long __res; \
__res = ((unsigned long long) n) % (unsigned) base; \
n = ((unsigned long long) n) / (unsigned) base; \
__res; })
#endif
/*****************************************************************************
*
* SkNumber - Print results
*
* Description:
* This function converts a long long number into a string.
*
* Returns:
* number as string
*/
char
*
SkNumber
(
char
*
str
,
long
long
num
,
int
base
,
int
size
,
int
precision
,
int
type
)
{
{
char
c
,
sign
,
tmp
[
66
],
*
strorg
=
str
;
switch
(
orig
)
{
const
char
*
digits
=
"0123456789abcdefghijklmnopqrstuvwxyz"
;
case
1
:
int
i
;
offset
+=
file
->
f_pos
;
case
0
:
if
(
type
&
LARGE
)
if
(
offset
>=
0
)
digits
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
return
file
->
f_pos
=
offset
;
if
(
type
&
LEFT
)
type
&=
~
ZEROPAD
;
if
(
base
<
2
||
base
>
36
)
return
0
;
c
=
(
type
&
ZEROPAD
)
?
'0'
:
' '
;
sign
=
0
;
if
(
type
&
SIGN
)
{
if
(
num
<
0
)
{
sign
=
'-'
;
num
=
-
num
;
size
--
;
}
else
if
(
type
&
PLUS
)
{
sign
=
'+'
;
size
--
;
}
else
if
(
type
&
SPACE
)
{
sign
=
' '
;
size
--
;
}
}
if
(
type
&
SPECIAL
)
{
if
(
base
==
16
)
size
-=
2
;
else
if
(
base
==
8
)
size
--
;
}
}
i
=
0
;
return
-
EINVAL
;
if
(
num
==
0
)
tmp
[
i
++
]
=
'0'
;
else
while
(
num
!=
0
)
tmp
[
i
++
]
=
digits
[
SkDoDiv
(
num
,
base
,
&
num
)];
if
(
i
>
precision
)
precision
=
i
;
size
-=
precision
;
if
(
!
(
type
&
(
ZEROPAD
+
LEFT
)))
while
(
size
-->
0
)
*
str
++
=
' '
;
if
(
sign
)
*
str
++
=
sign
;
if
(
type
&
SPECIAL
)
{
if
(
base
==
8
)
*
str
++
=
'0'
;
else
if
(
base
==
16
)
{
*
str
++
=
'0'
;
*
str
++
=
digits
[
33
];
}
}
if
(
!
(
type
&
LEFT
))
while
(
size
--
>
0
)
*
str
++
=
c
;
while
(
i
<
precision
--
)
*
str
++
=
'0'
;
while
(
i
--
>
0
)
*
str
++
=
tmp
[
i
];
while
(
size
--
>
0
)
*
str
++
=
' '
;
str
[
0
]
=
'\0'
;
return
strorg
;
}
}
struct
file_operations
sk_proc_fops
=
{
.
read
=
sk_read
,
.
llseek
=
sk_lseek
,
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment