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 {
int
Mtu
;
int
Up
;
SK_AC
*
pAC
;
struct
proc_dir_entry
*
proc
;
};
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);
static
const
char
SK_Root_Dir_entry
[]
=
"sk98lin"
;
static
struct
proc_dir_entry
*
pSkRootDir
;
//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
);
extern
struct
file_operations
sk_proc_fops
;
#ifdef DEBUG
static
void
DumpMsg
(
struct
sk_buff
*
,
char
*
);
...
...
@@ -399,7 +395,6 @@ static int __init skge_probe (void)
struct
pci_dev
*
pdev
=
NULL
;
unsigned
long
base_address
;
struct
net_device
*
dev
=
NULL
;
struct
proc_dir_entry
*
pProcFile
;
if
(
probed
)
return
-
ENODEV
;
...
...
@@ -420,7 +415,6 @@ static int __init skge_probe (void)
while
((
pdev
=
pci_find_device
(
PCI_VENDOR_ID_SYSKONNECT
,
PCI_DEVICE_ID_SYSKONNECT_GE
,
pdev
))
!=
NULL
)
{
dev
=
NULL
;
pNet
=
NULL
;
if
(
pci_enable_device
(
pdev
))
...
...
@@ -431,7 +425,8 @@ static int __init skge_probe (void)
pci_set_dma_mask
(
pdev
,
(
u64
)
0xffffffff
))
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 "
"structure!
\n
"
);
break
;
...
...
@@ -440,7 +435,7 @@ static int __init skge_probe (void)
pNet
=
dev
->
priv
;
pNet
->
pAC
=
kmalloc
(
sizeof
(
SK_AC
),
GFP_KERNEL
);
if
(
pNet
->
pAC
==
NULL
){
kfree
(
dev
->
priv
);
kfree
(
dev
);
printk
(
KERN_ERR
"Unable to allocate adapter "
"structure!
\n
"
);
break
;
...
...
@@ -477,15 +472,6 @@ static int __init skge_probe (void)
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.
*/
...
...
@@ -532,11 +518,29 @@ static int __init skge_probe (void)
pNet
->
PortNr
=
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
++
;
/* More then one port found */
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 "
"structure!
\n
"
);
break
;
...
...
@@ -559,20 +563,25 @@ static int __init skge_probe (void)
dev
->
do_ioctl
=
&
SkGeIoctl
;
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
,
(
caddr_t
)
&
pAC
->
Addr
.
Net
[
1
].
CurrentMacAddress
,
6
);
printk
(
"%s: %s
\n
"
,
dev
->
name
,
pAC
->
DeviceStr
);
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)
return
cards
?
0
:
-
ENODEV
;
}
/* skge_init_module */
spinlock_t
sk_devs_lock
=
SPIN_LOCK_UNLOCKED
;
/*****************************************************************************
*
...
...
@@ -766,6 +776,11 @@ SK_EVPARA EvPara;
netif_stop_queue
(
sk98lin_root_dev
);
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
)
{
/* board is still alive */
...
...
@@ -792,6 +807,12 @@ SK_EVPARA EvPara;
}
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
]);
kfree
(
pAC
->
dev
[
1
]);
}
...
...
drivers/net/sk98lin/skproc.c
View file @
173a9b29
...
...
@@ -46,378 +46,168 @@
#include "h/skdrv1st.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
,
int
precision
,
int
type
);
int
proc_read
(
char
*
buffer
,
char
**
buffer_location
,
off_t
offset
,
int
buffer_length
,
int
*
eof
,
void
*
data
);
extern
spinlock_t
sk_devs_lock
;
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
)
static
int
sk_show_dev
(
struct
net_device
*
dev
,
char
*
buf
)
{
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
t
;
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
;
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
--
)
{
if
((
pAC
->
GIni
.
GIMacsFound
==
2
)
&&
pAC
->
RlmtNets
==
1
)
t
--
;
spin_lock_irqsave
(
&
pAC
->
SlowPathLock
,
Flags
);
Size
=
SK_PNMI_STRUCT_SIZE
;
SkPnmiGetStruct
(
pAC
,
pAC
->
IoBase
,
pPnmiStruct
,
&
Size
,
t
-
1
);
spin_unlock_irqrestore
(
&
pAC
->
SlowPathLock
,
Flags
);
if
(
strcmp
(
pAC
->
dev
[
t
-
1
]
->
name
,
file
->
name
)
==
0
)
{
pPnmiStat
=
&
pPnmiStruct
->
Stat
[
0
];
len
=
sprintf
(
buffer
,
"
\n
Detailed statistic for device %s
\n
"
,
pAC
->
dev
[
t
-
1
]
->
name
);
len
+=
sprintf
(
buffer
+
len
,
"==================================
\n
"
);
/* Board statistics */
len
+=
sprintf
(
buffer
+
len
,
"
\n
Board statistics
\n\n
"
);
len
+=
sprintf
(
buffer
+
len
,
"Active Port %c
\n
"
,
'A'
+
pAC
->
Rlmt
.
Net
[
t
-
1
].
Port
[
pAC
->
Rlmt
.
Net
[
t
-
1
].
PrefPort
]
->
PortNumber
);
len
+=
sprintf
(
buffer
+
len
,
"Preferred Port %c
\n
"
,
'A'
+
pAC
->
Rlmt
.
Net
[
t
-
1
].
Port
[
pAC
->
Rlmt
.
Net
[
t
-
1
].
PrefPort
]
->
PortNumber
);
len
+=
sprintf
(
buffer
+
len
,
"Bus speed (Mhz) %d
\n
"
,
pPnmiStruct
->
BusSpeed
);
len
+=
sprintf
(
buffer
+
len
,
"Bus width (Bit) %d
\n
"
,
pPnmiStruct
->
BusWidth
);
for
(
i
=
0
;
i
<
SK_MAX_SENSORS
;
i
++
)
{
if
(
strcmp
(
pAC
->
I2c
.
SenTable
[
i
].
SenDesc
,
"Temperature"
)
==
0
)
{
len
+=
sprintf
(
buffer
+
len
,
"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
);
}
spin_lock_irqsave
(
&
pAC
->
SlowPathLock
,
Flags
);
Size
=
SK_PNMI_STRUCT_SIZE
;
SkPnmiGetStruct
(
pAC
,
pAC
->
IoBase
,
pPnmiStruct
,
&
Size
,
t
);
spin_unlock_irqrestore
(
&
pAC
->
SlowPathLock
,
Flags
);
pPnmiStat
=
&
pPnmiStruct
->
Stat
[
0
];
len
=
sprintf
(
buf
,
"
\n
Detailed statistic for device %s
\n
"
,
dev
->
name
);
len
+=
sprintf
(
buf
+
len
,
"==================================
\n
"
);
/* Board statistics */
len
+=
sprintf
(
buf
+
len
,
"
\n
Board statistics
\n\n
"
);
len
+=
sprintf
(
buf
+
len
,
"Active Port %c
\n
"
,
'A'
+
rlmt
->
Port
[
rlmt
->
ActivePort
]
->
PortNumber
);
len
+=
sprintf
(
buf
+
len
,
"Preferred Port %c
\n
"
,
'A'
+
rlmt
->
Port
[
rlmt
->
PrefPort
]
->
PortNumber
);
len
+=
sprintf
(
buf
+
len
,
"Bus speed (Mhz) %d
\n
"
,
pPnmiStruct
->
BusSpeed
);
len
+=
sprintf
(
buf
+
len
,
"Bus width (Bit) %d
\n
"
,
pPnmiStruct
->
BusWidth
);
for
(
i
=
0
;
i
<
SK_MAX_SENSORS
;
i
++
)
{
SK_SENSOR
*
sens
=
&
pAC
->
I2c
.
SenTable
[
i
];
SK_I32
val
=
sens
->
SenValue
;
if
(
strcmp
(
sens
->
SenDesc
,
"Temperature"
)
==
0
)
{
len
+=
sprintf
(
buf
+
len
,
"Temperature (C) %d.%d
\n
"
,
val
/
10
,
val
%
10
);
val
=
val
*
18
+
3200
;
len
+=
sprintf
(
buf
+
len
,
"Temperature (F) %d.%d
\n
"
,
val
/
100
,
val
%
10
);
}
else
if
(
strcmp
(
sens
->
SenDesc
,
"Speed Fan"
)
==
0
)
{
len
+=
sprintf
(
buf
+
len
,
"Speed Fan %d
\n
"
,
val
);
}
else
{
len
+=
sprintf
(
buf
+
len
,
"%-20s %d.%d
\n
"
,
sens
->
SenDesc
,
val
/
1000
,
val
%
1000
);
}
SkgeProcDev
=
next
;
}
if
(
offset
>=
len
)
{
*
eof
=
1
;
return
0
;
}
*
buffer_location
=
buffer
+
offset
;
if
(
buffer_length
>=
len
-
offset
)
{
*
eof
=
1
;
}
return
(
min_t
(
int
,
buffer_length
,
len
-
offset
));
/*Receive statistics */
len
+=
sprintf
(
buf
+
len
,
"
\n
Receive statistics
\n\n
"
);
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
;
}
/*****************************************************************************
*
* 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
)
static
ssize_t
sk_read
(
struct
file
*
file
,
char
*
buf
,
size_t
nbytes
,
loff_t
*
ppos
)
{
long
Rest
;
long
long
Ergebnis
;
long
Akku
;
Akku
=
Dividend
>>
32
;
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
;
struct
inode
*
inode
=
file
->
f_dentry
->
d_inode
;
struct
proc_dir_entry
*
entry
=
PDE
(
inode
);
char
*
page
=
(
char
*
)
__get_free_page
(
GFP_KERNEL
);
struct
net_device
*
dev
;
loff_t
pos
=
*
ppos
;
ssize_t
res
=
0
;
int
len
=
0
;
*
pErg
=
Ergebnis
;
return
(
Rest
);
if
(
!
page
)
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
;
}
#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
)
static
loff_t
sk_lseek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
)
{
char
c
,
sign
,
tmp
[
66
],
*
strorg
=
str
;
const
char
*
digits
=
"0123456789abcdefghijklmnopqrstuvwxyz"
;
int
i
;
if
(
type
&
LARGE
)
digits
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
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
--
;
switch
(
orig
)
{
case
1
:
offset
+=
file
->
f_pos
;
case
0
:
if
(
offset
>=
0
)
return
file
->
f_pos
=
offset
;
}
i
=
0
;
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
;
return
-
EINVAL
;
}
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