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
cbec8fba
Commit
cbec8fba
authored
Jun 03, 2003
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge davem@nuts.ninka.net:/home/davem/src/BK/net-2.5
into kernel.bkbits.net:/home/davem/net-2.5
parents
c2e2d4f7
d171187b
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
1088 additions
and
1354 deletions
+1088
-1354
Documentation/networking/ip-sysctl.txt
Documentation/networking/ip-sysctl.txt
+24
-0
arch/um/drivers/net_kern.c
arch/um/drivers/net_kern.c
+3
-3
crypto/Kconfig
crypto/Kconfig
+0
-10
drivers/atm/he.c
drivers/atm/he.c
+195
-217
drivers/char/n_hdlc.c
drivers/char/n_hdlc.c
+224
-262
drivers/net/3c509.c
drivers/net/3c509.c
+66
-31
drivers/net/hamradio/dmascc.c
drivers/net/hamradio/dmascc.c
+7
-29
drivers/net/setup.c
drivers/net/setup.c
+0
-6
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
drivers/net/wan/sdla.c
drivers/net/wan/sdla.c
+2
-0
include/linux/rtnetlink.h
include/linux/rtnetlink.h
+1
-1
include/net/ip6_fib.h
include/net/ip6_fib.h
+2
-1
include/net/snmp.h
include/net/snmp.h
+23
-0
net/core/dst.c
net/core/dst.c
+2
-2
net/core/dv.c
net/core/dv.c
+0
-2
net/core/filter.c
net/core/filter.c
+239
-306
net/core/iovec.c
net/core/iovec.c
+58
-82
net/ipv4/Kconfig
net/ipv4/Kconfig
+11
-0
net/ipv4/Makefile
net/ipv4/Makefile
+2
-2
net/ipv4/ah4.c
net/ipv4/ah4.c
+0
-0
net/ipv4/esp4.c
net/ipv4/esp4.c
+0
-0
net/ipv6/Kconfig
net/ipv6/Kconfig
+13
-0
net/ipv6/addrconf.c
net/ipv6/addrconf.c
+3
-2
net/ipv6/af_inet6.c
net/ipv6/af_inet6.c
+1
-1
net/ipv6/ip6_fib.c
net/ipv6/ip6_fib.c
+3
-3
net/ipv6/route.c
net/ipv6/route.c
+4
-3
net/ipv6/udp.c
net/ipv6/udp.c
+9
-7
net/ipv6/xfrm6_policy.c
net/ipv6/xfrm6_policy.c
+1
-1
No files found.
Documentation/networking/ip-sysctl.txt
View file @
cbec8fba
...
...
@@ -31,6 +31,11 @@ ipfrag_low_thresh - INTEGER
ipfrag_time - INTEGER
Time in seconds to keep an IP fragment in memory.
ipfrag_secret_interval - INTEGER
Regeneration interval (in seconds) of the hash secret (or lifetime
for the hash secret) for IP fragments.
Default: 600
INET peer storage:
inet_peer_threshold - INTEGER
...
...
@@ -515,6 +520,25 @@ bindv6only - BOOLEAN
Default: FALSE (as specified in RFC2553bis)
IPv6 Fragmentation:
ip6frag_high_thresh - INTEGER
Maximum memory used to reassemble IPv6 fragments. When
ip6frag_high_thresh bytes of memory is allocated for this purpose,
the fragment handler will toss packets until ip6frag_low_thresh
is reached.
ip6frag_low_thresh - INTEGER
See ip6frag_high_thresh
ip6frag_time - INTEGER
Time in seconds to keep an IPv6 fragment in memory.
ip6frag_secret_interval - INTEGER
Regeneration interval (in seconds) of the hash secret (or lifetime
for the hash secret) for IPv6 fragments.
Default: 600
conf/default/*:
Change the interface-specific default settings.
...
...
arch/um/drivers/net_kern.c
View file @
cbec8fba
...
...
@@ -304,7 +304,7 @@ static int eth_configure(int n, void *init, char *mac,
}
memset
(
device
,
0
,
sizeof
(
*
device
));
device
->
list
=
INIT_LIST_HEAD
(
device
->
list
);
INIT_LIST_HEAD
(
&
device
->
list
);
device
->
index
=
n
;
spin_lock
(
&
devices_lock
);
...
...
@@ -362,7 +362,7 @@ static int eth_configure(int n, void *init, char *mac,
return
1
;
lp
=
dev
->
priv
;
lp
->
list
=
INIT_LIST_HEAD
(
lp
->
list
);
INIT_LIST_HEAD
(
&
lp
->
list
);
spin_lock_init
(
&
lp
->
lock
);
lp
->
dev
=
dev
;
lp
->
fd
=
-
1
;
...
...
@@ -537,7 +537,7 @@ static int eth_setup(char *str)
return
(
1
);
}
new
->
list
=
INIT_LIST_HEAD
(
new
->
list
);
INIT_LIST_HEAD
(
&
new
->
list
);
new
->
index
=
n
;
new
->
init
=
str
;
...
...
crypto/Kconfig
View file @
cbec8fba
...
...
@@ -6,16 +6,12 @@ menu "Cryptographic options"
config CRYPTO
bool "Cryptographic API"
default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m || INET6_AH=y || INET6_AH=m || \
INET6_ESP=y || INET6_ESP=m || INET6_IPCOMP=y || INET6_IPCOMP=m || IPV6_PRIVACY=y
help
This option provides the core Cryptographic API.
config CRYPTO_HMAC
bool "HMAC support"
depends on CRYPTO
default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m || INET6_AH=y || INET6_AH=m || \
INET6_ESP=y || INET6_ESP=m
help
HMAC: Keyed-Hashing for Message Authentication (RFC2104).
This is required for IPSec.
...
...
@@ -35,16 +31,12 @@ config CRYPTO_MD4
config CRYPTO_MD5
tristate "MD5 digest algorithm"
depends on CRYPTO
default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m || INET6_AH=y || INET6_AH=m || \
INET6_ESP=y || INET6_ESP=m || IPV6_PRIVACY=y
help
MD5 message digest algorithm (RFC1321).
config CRYPTO_SHA1
tristate "SHA1 digest algorithm"
depends on CRYPTO
default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m || INET6_AH=y || INET6_AH=m || \
INET6_ESP=y || INET6_ESP=m
help
SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2).
...
...
@@ -72,7 +64,6 @@ config CRYPTO_SHA512
config CRYPTO_DES
tristate "DES and Triple DES EDE cipher algorithms"
depends on CRYPTO
default y if INET_ESP=y || INET_ESP=m || INET6_ESP=y || INET6_ESP=m
help
DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
...
...
@@ -138,7 +129,6 @@ config CRYPTO_AES
config CRYPTO_DEFLATE
tristate "Deflate compression algorithm"
depends on CRYPTO
default y if INET_IPCOMP=y || INET_IPCOMP=m || INET6_IPCOMP=y || INET6_IPCOMP=m
help
This is the Deflate algorithm (RFC1951), specified for use in
IPSec with the IPCOMP protocol (RFC3173, RFC2394).
...
...
drivers/atm/he.c
View file @
cbec8fba
...
...
@@ -77,14 +77,6 @@
#include <linux/atmdev.h>
#include <linux/atm.h>
#include <linux/sonet.h>
#ifndef ATM_OC12_PCR
#define ATM_OC12_PCR (622080000/1080*1040/8/53)
#endif
#ifdef BUS_INT_WAR
void
sn_add_polled_interrupt
(
int
irq
,
int
interval
);
void
sn_delete_polled_interrupt
(
int
irq
);
#endif
#define USE_TASKLET
#define USE_HE_FIND_VCC
...
...
@@ -171,22 +163,17 @@ static short sdh = 1;
static
struct
atmdev_ops
he_ops
=
{
open:
he_open
,
close:
he_close
,
ioctl:
he_ioctl
,
send:
he_send
,
sg_send:
he_sg_send
,
phy_put:
he_phy_put
,
phy_get:
he_phy_get
,
proc_read:
he_proc_read
,
owner:
THIS_MODULE
.
open
=
he_open
,
.
close
=
he_close
,
.
ioctl
=
he_ioctl
,
.
send
=
he_send
,
.
sg_send
=
he_sg_send
,
.
phy_put
=
he_phy_put
,
.
phy_get
=
he_phy_get
,
.
proc_read
=
he_proc_read
,
.
owner
=
THIS_MODULE
};
/* see the comments in he.h about global_lock */
#define HE_SPIN_LOCK(dev, flags) spin_lock_irqsave(&(dev)->global_lock, flags)
#define HE_SPIN_UNLOCK(dev, flags) spin_unlock_irqrestore(&(dev)->global_lock, flags)
#define he_writel(dev, val, reg) do { writel(val, (dev)->membase + (reg)); wmb(); } while (0)
#define he_readl(dev, reg) readl((dev)->membase + (reg))
...
...
@@ -233,26 +220,26 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
/* figure 2.2 connection id */
#define he_mkcid(dev, vpi, vci) (((vpi
<<
(dev)->vcibits) | vci) & 0x1fff)
#define he_mkcid(dev, vpi, vci) (((vpi
<<
(dev)->vcibits) | vci) & 0x1fff)
/* 2.5.1 per connection transmit state registers */
#define he_writel_tsr0(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 0)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 0)
#define he_readl_tsr0(dev, cid) \
he_readl_tcm(dev, CONFIG_TSRA | (cid
<<
3) | 0)
he_readl_tcm(dev, CONFIG_TSRA | (cid
<<
3) | 0)
#define he_writel_tsr1(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 1)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 1)
#define he_writel_tsr2(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 2)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 2)
#define he_writel_tsr3(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 3)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 3)
#define he_writel_tsr4(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 4)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 4)
/* from page 2-20
*
...
...
@@ -263,43 +250,43 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
*/
#define he_writel_tsr4_upper(dev, val, cid) \
he_writel_internal(dev, val, CONFIG_TSRA | (cid
<<
3) | 4, \
he_writel_internal(dev, val, CONFIG_TSRA | (cid
<<
3) | 4, \
CON_CTL_TCM \
| CON_BYTE_DISABLE_2 \
| CON_BYTE_DISABLE_1 \
| CON_BYTE_DISABLE_0)
#define he_readl_tsr4(dev, cid) \
he_readl_tcm(dev, CONFIG_TSRA | (cid
<<
3) | 4)
he_readl_tcm(dev, CONFIG_TSRA | (cid
<<
3) | 4)
#define he_writel_tsr5(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 5)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 5)
#define he_writel_tsr6(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 6)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 6)
#define he_writel_tsr7(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 7)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid
<<
3) | 7)
#define he_writel_tsr8(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid
<<
2) | 0)
he_writel_tcm(dev, val, CONFIG_TSRB | (cid
<<
2) | 0)
#define he_writel_tsr9(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid
<<
2) | 1)
he_writel_tcm(dev, val, CONFIG_TSRB | (cid
<<
2) | 1)
#define he_writel_tsr10(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid
<<
2) | 2)
he_writel_tcm(dev, val, CONFIG_TSRB | (cid
<<
2) | 2)
#define he_writel_tsr11(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid
<<
2) | 3)
he_writel_tcm(dev, val, CONFIG_TSRB | (cid
<<
2) | 3)
#define he_writel_tsr12(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRC | (cid
<<
1) | 0)
he_writel_tcm(dev, val, CONFIG_TSRC | (cid
<<
1) | 0)
#define he_writel_tsr13(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRC | (cid
<<
1) | 1)
he_writel_tcm(dev, val, CONFIG_TSRC | (cid
<<
1) | 1)
#define he_writel_tsr14(dev, val, cid) \
...
...
@@ -315,30 +302,30 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
/* 2.7.1 per connection receive state registers */
#define he_writel_rsr0(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 0)
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 0)
#define he_readl_rsr0(dev, cid) \
he_readl_rcm(dev, 0x00000 | (cid
<<
3) | 0)
he_readl_rcm(dev, 0x00000 | (cid
<<
3) | 0)
#define he_writel_rsr1(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 1)
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 1)
#define he_writel_rsr2(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 2)
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 2)
#define he_writel_rsr3(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 3)
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 3)
#define he_writel_rsr4(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 4)
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 4)
#define he_writel_rsr5(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 5)
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 5)
#define he_writel_rsr6(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 6)
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 6)
#define he_writel_rsr7(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 7)
he_writel_rcm(dev, val, 0x00000 | (cid
<<
3) | 7)
static
__inline__
struct
atm_vcc
*
he_find_vcc
(
struct
he_dev
*
he_dev
,
unsigned
cid
)
...
...
@@ -349,7 +336,7 @@ he_find_vcc(struct he_dev *he_dev, unsigned cid)
int
vci
;
vpi
=
cid
>>
he_dev
->
vcibits
;
vci
=
cid
&
((
1
<<
he_dev
->
vcibits
)
-
1
);
vci
=
cid
&
((
1
<<
he_dev
->
vcibits
)
-
1
);
spin_lock_irqsave
(
&
he_dev
->
atm_dev
->
lock
,
flags
);
for
(
vcc
=
he_dev
->
atm_dev
->
vccs
;
vcc
;
vcc
=
vcc
->
next
)
...
...
@@ -443,112 +430,112 @@ he_remove_one (struct pci_dev *pci_dev)
static
unsigned
rate_to_atmf
(
unsigned
rate
)
/* cps to atm forum format */
{
#define NONZERO (1
<<
14)
#define NONZERO (1
<<
14)
unsigned
exp
=
0
;
unsigned
exp
=
0
;
if
(
rate
==
0
)
return
(
0
)
;
if
(
rate
==
0
)
return
0
;
rate
<<=
9
;
while
(
rate
>
0x3ff
)
{
++
exp
;
rate
>>=
1
;
}
rate
<<=
9
;
while
(
rate
>
0x3ff
)
{
++
exp
;
rate
>>=
1
;
}
return
(
NONZERO
|
(
exp
<<
9
)
|
(
rate
&
0x1ff
));
return
(
NONZERO
|
(
exp
<<
9
)
|
(
rate
&
0x1ff
));
}
static
void
__init
he_init_rx_lbfp0
(
struct
he_dev
*
he_dev
)
{
unsigned
i
,
lbm_offset
,
lbufd_index
,
lbuf_addr
,
lbuf_count
;
unsigned
lbufs_per_row
=
he_dev
->
cells_per_row
/
he_dev
->
cells_per_lbuf
;
unsigned
lbuf_bufsize
=
he_dev
->
cells_per_lbuf
*
ATM_CELL_PAYLOAD
;
unsigned
row_offset
=
he_dev
->
r0_startrow
*
he_dev
->
bytes_per_row
;
unsigned
i
,
lbm_offset
,
lbufd_index
,
lbuf_addr
,
lbuf_count
;
unsigned
lbufs_per_row
=
he_dev
->
cells_per_row
/
he_dev
->
cells_per_lbuf
;
unsigned
lbuf_bufsize
=
he_dev
->
cells_per_lbuf
*
ATM_CELL_PAYLOAD
;
unsigned
row_offset
=
he_dev
->
r0_startrow
*
he_dev
->
bytes_per_row
;
lbufd_index
=
0
;
lbm_offset
=
he_readl
(
he_dev
,
RCMLBM_BA
);
lbm_offset
=
he_readl
(
he_dev
,
RCMLBM_BA
);
he_writel
(
he_dev
,
lbufd_index
,
RLBF0_H
);
for
(
i
=
0
,
lbuf_count
=
0
;
i
<
he_dev
->
r0_numbuffs
;
++
i
)
{
for
(
i
=
0
,
lbuf_count
=
0
;
i
<
he_dev
->
r0_numbuffs
;
++
i
)
{
lbufd_index
+=
2
;
lbuf_addr
=
(
row_offset
+
(
lbuf_count
*
lbuf_bufsize
))
/
32
;
lbuf_addr
=
(
row_offset
+
(
lbuf_count
*
lbuf_bufsize
))
/
32
;
he_writel_rcm
(
he_dev
,
lbuf_addr
,
lbm_offset
);
he_writel_rcm
(
he_dev
,
lbufd_index
,
lbm_offset
+
1
);
if
(
++
lbuf_count
==
lbufs_per_row
)
{
lbuf_count
=
0
;
row_offset
+=
he_dev
->
bytes_per_row
;
}
if
(
++
lbuf_count
==
lbufs_per_row
)
{
lbuf_count
=
0
;
row_offset
+=
he_dev
->
bytes_per_row
;
}
lbm_offset
+=
4
;
}
he_writel
(
he_dev
,
lbufd_index
-
2
,
RLBF0_T
);
}
he_writel
(
he_dev
,
lbufd_index
-
2
,
RLBF0_T
);
he_writel
(
he_dev
,
he_dev
->
r0_numbuffs
,
RLBF0_C
);
}
static
void
__init
he_init_rx_lbfp1
(
struct
he_dev
*
he_dev
)
{
unsigned
i
,
lbm_offset
,
lbufd_index
,
lbuf_addr
,
lbuf_count
;
unsigned
lbufs_per_row
=
he_dev
->
cells_per_row
/
he_dev
->
cells_per_lbuf
;
unsigned
lbuf_bufsize
=
he_dev
->
cells_per_lbuf
*
ATM_CELL_PAYLOAD
;
unsigned
row_offset
=
he_dev
->
r1_startrow
*
he_dev
->
bytes_per_row
;
unsigned
i
,
lbm_offset
,
lbufd_index
,
lbuf_addr
,
lbuf_count
;
unsigned
lbufs_per_row
=
he_dev
->
cells_per_row
/
he_dev
->
cells_per_lbuf
;
unsigned
lbuf_bufsize
=
he_dev
->
cells_per_lbuf
*
ATM_CELL_PAYLOAD
;
unsigned
row_offset
=
he_dev
->
r1_startrow
*
he_dev
->
bytes_per_row
;
lbufd_index
=
1
;
lbm_offset
=
he_readl
(
he_dev
,
RCMLBM_BA
)
+
(
2
*
lbufd_index
);
lbm_offset
=
he_readl
(
he_dev
,
RCMLBM_BA
)
+
(
2
*
lbufd_index
);
he_writel
(
he_dev
,
lbufd_index
,
RLBF1_H
);
for
(
i
=
0
,
lbuf_count
=
0
;
i
<
he_dev
->
r1_numbuffs
;
++
i
)
{
for
(
i
=
0
,
lbuf_count
=
0
;
i
<
he_dev
->
r1_numbuffs
;
++
i
)
{
lbufd_index
+=
2
;
lbuf_addr
=
(
row_offset
+
(
lbuf_count
*
lbuf_bufsize
))
/
32
;
lbuf_addr
=
(
row_offset
+
(
lbuf_count
*
lbuf_bufsize
))
/
32
;
he_writel_rcm
(
he_dev
,
lbuf_addr
,
lbm_offset
);
he_writel_rcm
(
he_dev
,
lbufd_index
,
lbm_offset
+
1
);
if
(
++
lbuf_count
==
lbufs_per_row
)
{
lbuf_count
=
0
;
row_offset
+=
he_dev
->
bytes_per_row
;
}
if
(
++
lbuf_count
==
lbufs_per_row
)
{
lbuf_count
=
0
;
row_offset
+=
he_dev
->
bytes_per_row
;
}
lbm_offset
+=
4
;
}
he_writel
(
he_dev
,
lbufd_index
-
2
,
RLBF1_T
);
}
he_writel
(
he_dev
,
lbufd_index
-
2
,
RLBF1_T
);
he_writel
(
he_dev
,
he_dev
->
r1_numbuffs
,
RLBF1_C
);
}
static
void
__init
he_init_tx_lbfp
(
struct
he_dev
*
he_dev
)
{
unsigned
i
,
lbm_offset
,
lbufd_index
,
lbuf_addr
,
lbuf_count
;
unsigned
lbufs_per_row
=
he_dev
->
cells_per_row
/
he_dev
->
cells_per_lbuf
;
unsigned
lbuf_bufsize
=
he_dev
->
cells_per_lbuf
*
ATM_CELL_PAYLOAD
;
unsigned
row_offset
=
he_dev
->
tx_startrow
*
he_dev
->
bytes_per_row
;
unsigned
i
,
lbm_offset
,
lbufd_index
,
lbuf_addr
,
lbuf_count
;
unsigned
lbufs_per_row
=
he_dev
->
cells_per_row
/
he_dev
->
cells_per_lbuf
;
unsigned
lbuf_bufsize
=
he_dev
->
cells_per_lbuf
*
ATM_CELL_PAYLOAD
;
unsigned
row_offset
=
he_dev
->
tx_startrow
*
he_dev
->
bytes_per_row
;
lbufd_index
=
he_dev
->
r0_numbuffs
+
he_dev
->
r1_numbuffs
;
lbm_offset
=
he_readl
(
he_dev
,
RCMLBM_BA
)
+
(
2
*
lbufd_index
);
lbm_offset
=
he_readl
(
he_dev
,
RCMLBM_BA
)
+
(
2
*
lbufd_index
);
he_writel
(
he_dev
,
lbufd_index
,
TLBF_H
);
for
(
i
=
0
,
lbuf_count
=
0
;
i
<
he_dev
->
tx_numbuffs
;
++
i
)
{
for
(
i
=
0
,
lbuf_count
=
0
;
i
<
he_dev
->
tx_numbuffs
;
++
i
)
{
lbufd_index
+=
1
;
lbuf_addr
=
(
row_offset
+
(
lbuf_count
*
lbuf_bufsize
))
/
32
;
lbuf_addr
=
(
row_offset
+
(
lbuf_count
*
lbuf_bufsize
))
/
32
;
he_writel_rcm
(
he_dev
,
lbuf_addr
,
lbm_offset
);
he_writel_rcm
(
he_dev
,
lbufd_index
,
lbm_offset
+
1
);
if
(
++
lbuf_count
==
lbufs_per_row
)
{
lbuf_count
=
0
;
row_offset
+=
he_dev
->
bytes_per_row
;
}
if
(
++
lbuf_count
==
lbufs_per_row
)
{
lbuf_count
=
0
;
row_offset
+=
he_dev
->
bytes_per_row
;
}
lbm_offset
+=
2
;
}
he_writel
(
he_dev
,
lbufd_index
-
1
,
TLBF_T
);
}
he_writel
(
he_dev
,
lbufd_index
-
1
,
TLBF_T
);
}
static
int
__init
...
...
@@ -678,7 +665,7 @@ he_init_cs_block_rcm(struct he_dev *he_dev)
unsigned
rate_atmf
,
exp
,
man
;
unsigned
long
long
rate_cps
;
int
mult
,
buf
,
buf_limit
=
4
;
int
mult
,
buf
,
buf_limit
=
4
;
rategrid
=
kmalloc
(
sizeof
(
unsigned
)
*
16
*
16
,
GFP_KERNEL
);
if
(
!
rategrid
)
...
...
@@ -757,30 +744,31 @@ he_init_cs_block_rcm(struct he_dev *he_dev)
*/
#ifdef notdef
buf
=
rate_cps
*
he_dev
->
tx_numbuffs
/
buf
=
rate_cps
*
he_dev
->
tx_numbuffs
/
(
he_dev
->
atm_dev
->
link_rate
*
2
);
#else
/* this is pretty, but avoids _divdu3 and is mostly correct */
buf
=
0
;
mult
=
he_dev
->
atm_dev
->
link_rate
/
ATM_OC3_PCR
;
if
(
rate_cps
>
(
68
*
mult
))
buf
=
1
;
if
(
rate_cps
>
(
136
*
mult
))
buf
=
2
;
if
(
rate_cps
>
(
204
*
mult
))
buf
=
3
;
if
(
rate_cps
>
(
272
*
mult
))
mult
=
he_dev
->
atm_dev
->
link_rate
/
ATM_OC3_PCR
;
if
(
rate_cps
>
(
272
*
mult
))
buf
=
4
;
else
if
(
rate_cps
>
(
204
*
mult
))
buf
=
3
;
else
if
(
rate_cps
>
(
136
*
mult
))
buf
=
2
;
else
if
(
rate_cps
>
(
68
*
mult
))
buf
=
1
;
else
buf
=
0
;
#endif
if
(
buf
>
buf_limit
)
if
(
buf
>
buf_limit
)
buf
=
buf_limit
;
reg
=
(
reg
<<
16
)
|
((
i
<<
8
)
|
buf
);
reg
=
(
reg
<<
16
)
|
((
i
<<
8
)
|
buf
);
#define RTGTBL_OFFSET 0x400
if
(
rate_atmf
&
0x1
)
he_writel_rcm
(
he_dev
,
reg
,
CONFIG_RCMABR
+
RTGTBL_OFFSET
+
(
rate_atmf
>>
1
));
CONFIG_RCMABR
+
RTGTBL_OFFSET
+
(
rate_atmf
>>
1
));
++
rate_atmf
;
}
...
...
@@ -839,7 +827,7 @@ he_init_group(struct he_dev *he_dev, int group)
he_dev
->
rbps_base
[
i
].
phys
=
dma_handle
;
}
he_dev
->
rbps_tail
=
&
he_dev
->
rbps_base
[
CONFIG_RBPS_SIZE
-
1
];
he_dev
->
rbps_tail
=
&
he_dev
->
rbps_base
[
CONFIG_RBPS_SIZE
-
1
];
he_writel
(
he_dev
,
he_dev
->
rbps_phys
,
G0_RBPS_S
+
(
group
*
32
));
he_writel
(
he_dev
,
RBPS_MASK
(
he_dev
->
rbps_tail
),
...
...
@@ -848,7 +836,7 @@ he_init_group(struct he_dev *he_dev, int group)
G0_RBPS_BS
+
(
group
*
32
));
he_writel
(
he_dev
,
RBP_THRESH
(
CONFIG_RBPS_THRESH
)
|
RBP_QSIZE
(
CONFIG_RBPS_SIZE
-
1
)
|
RBP_QSIZE
(
CONFIG_RBPS_SIZE
-
1
)
|
RBP_INT_ENB
,
G0_RBPS_QI
+
(
group
*
32
));
#else
/* !USE_RBPS */
...
...
@@ -902,7 +890,7 @@ he_init_group(struct he_dev *he_dev, int group)
he_dev
->
rbpl_base
[
i
].
status
=
RBP_LOANED
|
(
i
<<
RBP_INDEX_OFF
);
he_dev
->
rbpl_base
[
i
].
phys
=
dma_handle
;
}
he_dev
->
rbpl_tail
=
&
he_dev
->
rbpl_base
[
CONFIG_RBPL_SIZE
-
1
];
he_dev
->
rbpl_tail
=
&
he_dev
->
rbpl_base
[
CONFIG_RBPL_SIZE
-
1
];
he_writel
(
he_dev
,
he_dev
->
rbpl_phys
,
G0_RBPL_S
+
(
group
*
32
));
he_writel
(
he_dev
,
RBPL_MASK
(
he_dev
->
rbpl_tail
),
...
...
@@ -911,7 +899,7 @@ he_init_group(struct he_dev *he_dev, int group)
G0_RBPL_BS
+
(
group
*
32
));
he_writel
(
he_dev
,
RBP_THRESH
(
CONFIG_RBPL_THRESH
)
|
RBP_QSIZE
(
CONFIG_RBPL_SIZE
-
1
)
|
RBP_QSIZE
(
CONFIG_RBPL_SIZE
-
1
)
|
RBP_INT_ENB
,
G0_RBPL_QI
+
(
group
*
32
));
...
...
@@ -929,7 +917,7 @@ he_init_group(struct he_dev *he_dev, int group)
he_writel
(
he_dev
,
he_dev
->
rbrq_phys
,
G0_RBRQ_ST
+
(
group
*
16
));
he_writel
(
he_dev
,
0
,
G0_RBRQ_H
+
(
group
*
16
));
he_writel
(
he_dev
,
RBRQ_THRESH
(
CONFIG_RBRQ_THRESH
)
|
RBRQ_SIZE
(
CONFIG_RBRQ_SIZE
-
1
),
RBRQ_THRESH
(
CONFIG_RBRQ_THRESH
)
|
RBRQ_SIZE
(
CONFIG_RBRQ_SIZE
-
1
),
G0_RBRQ_Q
+
(
group
*
16
));
if
(
irq_coalesce
)
{
hprintk
(
"coalescing interrupts
\n
"
);
...
...
@@ -967,7 +955,7 @@ he_init_irq(struct he_dev *he_dev)
/* 2.9.3.5 tail offset for each interrupt queue is located after the
end of the interrupt queue */
he_dev
->
irq_base
=
pci_alloc_consistent
(
he_dev
->
pci_dev
,
he_dev
->
irq_base
=
pci_alloc_consistent
(
he_dev
->
pci_dev
,
(
CONFIG_IRQ_SIZE
+
1
)
*
sizeof
(
struct
he_irq
),
&
he_dev
->
irq_phys
);
if
(
he_dev
->
irq_base
==
NULL
)
{
hprintk
(
"failed to allocate irq
\n
"
);
...
...
@@ -979,7 +967,7 @@ he_init_irq(struct he_dev *he_dev)
he_dev
->
irq_head
=
he_dev
->
irq_base
;
he_dev
->
irq_tail
=
he_dev
->
irq_base
;
for
(
i
=
0
;
i
<
CONFIG_IRQ_SIZE
;
++
i
)
for
(
i
=
0
;
i
<
CONFIG_IRQ_SIZE
;
++
i
)
he_dev
->
irq_base
[
i
].
isw
=
ITYPE_INVALID
;
he_writel
(
he_dev
,
he_dev
->
irq_phys
,
IRQ0_BASE
);
...
...
@@ -1014,23 +1002,18 @@ he_init_irq(struct he_dev *he_dev)
if
(
request_irq
(
he_dev
->
pci_dev
->
irq
,
he_irq_handler
,
SA_INTERRUPT
|
SA_SHIRQ
,
DEV_LABEL
,
he_dev
))
{
hprintk
(
"irq %d already in use
\n
"
,
he_dev
->
pci_dev
->
irq
);
return
-
EINVAL
;
}
}
he_dev
->
irq
=
he_dev
->
pci_dev
->
irq
;
#ifdef BUS_INT_WAR
HPRINTK
(
"sn_add_polled_interrupt(irq %d, 1)
\n
"
,
he_dev
->
irq
);
sn_add_polled_interrupt
(
he_dev
->
irq
,
1
);
#endif
return
0
;
}
static
int
__init
he_start
(
struct
atm_dev
*
dev
)
{
struct
he_dev
*
he_dev
;
struct
pci_dev
*
pci_dev
;
struct
he_dev
*
he_dev
;
struct
pci_dev
*
pci_dev
;
u16
command
;
u32
gen_cntl_0
,
host_cntl
,
lb_swap
;
...
...
@@ -1040,8 +1023,8 @@ he_start(struct atm_dev *dev)
unsigned
int
status
,
reg
;
int
i
,
group
;
he_dev
=
HE_DEV
(
dev
);
pci_dev
=
he_dev
->
pci_dev
;
he_dev
=
HE_DEV
(
dev
);
pci_dev
=
he_dev
->
pci_dev
;
he_dev
->
membase
=
pci_dev
->
resource
[
0
].
start
;
HPRINTK
(
"membase = 0x%lx irq = %d.
\n
"
,
he_dev
->
membase
,
pci_dev
->
irq
);
...
...
@@ -1108,7 +1091,7 @@ he_start(struct atm_dev *dev)
hprintk
(
"can't set up page mapping
\n
"
);
return
-
EINVAL
;
}
/* 4.4 card reset */
he_writel
(
he_dev
,
0x0
,
RESET_CNTL
);
he_writel
(
he_dev
,
0xff
,
RESET_CNTL
);
...
...
@@ -1138,12 +1121,12 @@ he_start(struct atm_dev *dev)
pci_write_config_dword
(
pci_dev
,
GEN_CNTL_0
,
gen_cntl_0
);
/* 4.7 read prom contents */
for
(
i
=
0
;
i
<
PROD_ID_LEN
;
++
i
)
for
(
i
=
0
;
i
<
PROD_ID_LEN
;
++
i
)
he_dev
->
prod_id
[
i
]
=
read_prom_byte
(
he_dev
,
PROD_ID
+
i
);
he_dev
->
media
=
read_prom_byte
(
he_dev
,
MEDIA
);
for
(
i
=
0
;
i
<
6
;
++
i
)
for
(
i
=
0
;
i
<
6
;
++
i
)
dev
->
esi
[
i
]
=
read_prom_byte
(
he_dev
,
MAC_ADDR
+
i
);
hprintk
(
"%s%s, %x:%x:%x:%x:%x:%x
\n
"
,
...
...
@@ -1323,15 +1306,15 @@ he_start(struct atm_dev *dev)
he_writel
(
he_dev
,
0x0
,
TXAAL5_PROTO
);
he_writel
(
he_dev
,
PHY_INT_ENB
|
(
he_is622
(
he_dev
)
?
PTMR_PRE
(
67
-
1
)
:
PTMR_PRE
(
50
-
1
)),
(
he_is622
(
he_dev
)
?
PTMR_PRE
(
67
-
1
)
:
PTMR_PRE
(
50
-
1
)),
RH_CONFIG
);
/* 5.1.3 initialize connection memory */
for
(
i
=
0
;
i
<
TCM_MEM_SIZE
;
++
i
)
for
(
i
=
0
;
i
<
TCM_MEM_SIZE
;
++
i
)
he_writel_tcm
(
he_dev
,
0
,
i
);
for
(
i
=
0
;
i
<
RCM_MEM_SIZE
;
++
i
)
for
(
i
=
0
;
i
<
RCM_MEM_SIZE
;
++
i
)
he_writel_rcm
(
he_dev
,
0
,
i
);
/*
...
...
@@ -1512,7 +1495,7 @@ he_start(struct atm_dev *dev)
}
he_dev
->
tpd_head
=
he_dev
->
tpd_base
;
he_dev
->
tpd_end
=
&
he_dev
->
tpd_base
[
CONFIG_NUMTPDS
-
1
];
he_dev
->
tpd_end
=
&
he_dev
->
tpd_base
[
CONFIG_NUMTPDS
-
1
];
#endif
if
(
he_init_group
(
he_dev
,
0
)
!=
0
)
...
...
@@ -1608,8 +1591,8 @@ he_start(struct atm_dev *dev)
he_dev
->
irq_peak
=
0
;
he_dev
->
rbrq_peak
=
0
;
he_dev
->
rbpl_peak
=
0
;
he_dev
->
tbrq_peak
=
0
;
he_dev
->
rbpl_peak
=
0
;
he_dev
->
tbrq_peak
=
0
;
HPRINTK
(
"hell bent for leather!
\n
"
);
...
...
@@ -1652,12 +1635,8 @@ he_stop(struct he_dev *he_dev)
he_dev
->
atm_dev
->
phy
->
stop
(
he_dev
->
atm_dev
);
#endif
/* CONFIG_ATM_HE_USE_SUNI */
if
(
he_dev
->
irq
)
{
#ifdef BUS_INT_WAR
sn_delete_polled_interrupt
(
he_dev
->
irq
);
#endif
if
(
he_dev
->
irq
)
free_irq
(
he_dev
->
irq
,
he_dev
);
}
if
(
he_dev
->
irq_base
)
pci_free_consistent
(
he_dev
->
pci_dev
,
(
CONFIG_IRQ_SIZE
+
1
)
...
...
@@ -1669,7 +1648,7 @@ he_stop(struct he_dev *he_dev)
if
(
he_dev
->
rbpl_base
)
{
#ifdef USE_RBPL_POOL
for
(
i
=
0
;
i
<
CONFIG_RBPL_SIZE
;
++
i
)
{
for
(
i
=
0
;
i
<
CONFIG_RBPL_SIZE
;
++
i
)
{
void
*
cpuaddr
=
he_dev
->
rbpl_virt
[
i
].
virt
;
dma_addr_t
dma_handle
=
he_dev
->
rbpl_base
[
i
].
phys
;
...
...
@@ -1691,7 +1670,7 @@ he_stop(struct he_dev *he_dev)
#ifdef USE_RBPS
if
(
he_dev
->
rbps_base
)
{
#ifdef USE_RBPS_POOL
for
(
i
=
0
;
i
<
CONFIG_RBPS_SIZE
;
++
i
)
{
for
(
i
=
0
;
i
<
CONFIG_RBPS_SIZE
;
++
i
)
{
void
*
cpuaddr
=
he_dev
->
rbps_virt
[
i
].
virt
;
dma_addr_t
dma_handle
=
he_dev
->
rbps_base
[
i
].
phys
;
...
...
@@ -1790,7 +1769,7 @@ __alloc_tpd(struct he_dev *he_dev)
}
#define AAL5_LEN(buf,len) \
((((unsigned char *)(buf))[(len)-6]
<<
8) | \
((((unsigned char *)(buf))[(len)-6]
<<
8) | \
(((unsigned char *)(buf))[(len)-5]))
/* 2.10.1.2 receive
...
...
@@ -1800,7 +1779,7 @@ __alloc_tpd(struct he_dev *he_dev)
*/
#define TCP_CKSUM(buf,len) \
((((unsigned char *)(buf))[(len)-2]
<<
8) | \
((((unsigned char *)(buf))[(len)-2]
<<
8) | \
(((unsigned char *)(buf))[(len-1)]))
static
int
...
...
@@ -2123,7 +2102,7 @@ he_service_rbpl(struct he_dev *he_dev, int group)
if
(
moved
)
{
he_writel
(
he_dev
,
RBPL_MASK
(
he_dev
->
rbpl_tail
),
G0_RBPL_T
);
#ifdef CONFIG_IA64_SGI_SN2
(
void
)
he_readl
(
he_dev
,
G0_RBPL_T
);
(
void
)
he_readl
(
he_dev
,
G0_RBPL_T
);
#endif
}
}
...
...
@@ -2155,7 +2134,7 @@ he_service_rbps(struct he_dev *he_dev, int group)
if
(
moved
)
{
he_writel
(
he_dev
,
RBPS_MASK
(
he_dev
->
rbps_tail
),
G0_RBPS_T
);
#ifdef CONFIG_IA64_SGI_SN2
(
void
)
he_readl
(
he_dev
,
G0_RBPS_T
);
(
void
)
he_readl
(
he_dev
,
G0_RBPS_T
);
#endif
}
}
...
...
@@ -2171,7 +2150,7 @@ he_tasklet(unsigned long data)
HPRINTK
(
"tasklet (0x%lx)
\n
"
,
data
);
#ifdef USE_TASKLET
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
#endif
while
(
he_dev
->
irq_head
!=
he_dev
->
irq_tail
)
{
...
...
@@ -2209,10 +2188,10 @@ he_tasklet(unsigned long data)
case
ITYPE_PHY
:
HPRINTK
(
"phy interrupt
\n
"
);
#ifdef CONFIG_ATM_HE_USE_SUNI
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
if
(
he_dev
->
atm_dev
->
phy
&&
he_dev
->
atm_dev
->
phy
->
interrupt
)
he_dev
->
atm_dev
->
phy
->
interrupt
(
he_dev
->
atm_dev
);
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
#endif
break
;
case
ITYPE_OTHER
:
...
...
@@ -2257,7 +2236,7 @@ he_tasklet(unsigned long data)
(
void
)
he_readl
(
he_dev
,
INT_FIFO
);
/* 8.1.2 controller errata */
}
#ifdef USE_TASKLET
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
#endif
}
...
...
@@ -2271,7 +2250,7 @@ he_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
if
(
he_dev
==
NULL
)
return
IRQ_NONE
;
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
he_dev
->
irq_tail
=
(
struct
he_irq
*
)
(((
unsigned
long
)
he_dev
->
irq_base
)
|
(
*
he_dev
->
irq_tailoffset
<<
2
));
...
...
@@ -2301,7 +2280,7 @@ he_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
(
void
)
he_readl
(
he_dev
,
INT_FIFO
);
#endif
}
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
return
IRQ_RETVAL
(
handled
);
}
...
...
@@ -2416,11 +2395,11 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
if
(
vcc
->
qos
.
txtp
.
traffic_class
!=
ATM_NONE
)
{
int
pcr_goal
;
pcr_goal
=
atm_pcr_goal
(
&
vcc
->
qos
.
txtp
);
if
(
pcr_goal
==
0
)
pcr_goal
=
he_dev
->
atm_dev
->
link_rate
;
if
(
pcr_goal
<
0
)
/* means round down, technically */
pcr_goal
=
-
pcr_goal
;
pcr_goal
=
atm_pcr_goal
(
&
vcc
->
qos
.
txtp
);
if
(
pcr_goal
==
0
)
pcr_goal
=
he_dev
->
atm_dev
->
link_rate
;
if
(
pcr_goal
<
0
)
/* means round down, technically */
pcr_goal
=
-
pcr_goal
;
HPRINTK
(
"open tx cid 0x%x pcr_goal %d
\n
"
,
cid
,
pcr_goal
);
...
...
@@ -2438,9 +2417,9 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto
open_failed
;
}
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
tsr0
=
he_readl_tsr0
(
he_dev
,
cid
);
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
if
(
TSR0_CONN_STATE
(
tsr0
)
!=
0
)
{
hprintk
(
"cid 0x%x not idle (tsr0 = 0x%x)
\n
"
,
cid
,
tsr0
);
...
...
@@ -2467,7 +2446,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto
open_failed
;
}
HE_SPIN_LOCK
(
he_dev
,
flags
);
/* also protects he_dev->cs_stper[] */
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
/* also protects he_dev->cs_stper[] */
/* find an unused cs_stper register */
for
(
reg
=
0
;
reg
<
HE_NUM_CS_STPER
;
++
reg
)
...
...
@@ -2477,7 +2456,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
if
(
reg
==
HE_NUM_CS_STPER
)
{
err
=
-
EBUSY
;
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
goto
open_failed
;
}
...
...
@@ -2495,7 +2474,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
he_writel_mbox
(
he_dev
,
rate_to_atmf
(
period
/
2
),
CS_STPER0
+
reg
);
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
tsr0
=
TSR0_CBR
|
TSR0_GROUP
(
0
)
|
tsr0_aal
|
TSR0_RC_INDEX
(
reg
);
...
...
@@ -2506,7 +2485,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto
open_failed
;
}
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
he_writel_tsr0
(
he_dev
,
tsr0
,
cid
);
he_writel_tsr4
(
he_dev
,
tsr4
|
1
,
cid
);
...
...
@@ -2528,7 +2507,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
#ifdef CONFIG_IA64_SGI_SN2
(
void
)
he_readl_tsr0
(
he_dev
,
cid
);
#endif
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
}
if
(
vcc
->
qos
.
rxtp
.
traffic_class
!=
ATM_NONE
)
{
...
...
@@ -2549,11 +2528,11 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto
open_failed
;
}
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
rsr0
=
he_readl_rsr0
(
he_dev
,
cid
);
if
(
rsr0
&
RSR0_OPEN_CONN
)
{
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
hprintk
(
"cid 0x%x not idle (rsr0 = 0x%x)
\n
"
,
cid
,
rsr0
);
err
=
-
EBUSY
;
...
...
@@ -2578,14 +2557,14 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
he_writel_rsr4
(
he_dev
,
rsr4
,
cid
);
he_writel_rsr1
(
he_dev
,
rsr1
,
cid
);
/* 5.1.11 last parameter initialized should be
the open/closed indication in rsr0 */
the open/closed indication in rsr0 */
he_writel_rsr0
(
he_dev
,
rsr0
|
RSR0_START_PDU
|
RSR0_OPEN_CONN
|
aal
,
cid
);
#ifdef CONFIG_IA64_SGI_SN2
(
void
)
he_readl_rsr0
(
he_dev
,
cid
);
#endif
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
#ifndef USE_HE_FIND_VCC
HE_LOOKUP_VCC
(
he_dev
,
cid
)
=
vcc
;
...
...
@@ -2631,7 +2610,7 @@ he_close(struct atm_vcc *vcc)
/* wait for previous close (if any) to finish */
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
while
(
he_readl
(
he_dev
,
RCC_STAT
)
&
RCC_BUSY
)
{
HPRINTK
(
"close cid 0x%x RCC_BUSY
\n
"
,
cid
);
udelay
(
250
);
...
...
@@ -2645,7 +2624,7 @@ he_close(struct atm_vcc *vcc)
(
void
)
he_readl_rsr0
(
he_dev
,
cid
);
#endif
he_writel_mbox
(
he_dev
,
cid
,
RXCON_CLOSE
);
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
timeout
=
schedule_timeout
(
30
*
HZ
);
...
...
@@ -2693,7 +2672,7 @@ he_close(struct atm_vcc *vcc)
/* 2.3.1.1 generic close operations with flush */
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
he_writel_tsr4_upper
(
he_dev
,
TSR4_FLUSH_CONN
,
cid
);
/* also clears TSR4_SESSION_ENDED */
#ifdef CONFIG_IA64_SGI_SN2
...
...
@@ -2724,7 +2703,7 @@ he_close(struct atm_vcc *vcc)
add_wait_queue
(
&
he_vcc
->
tx_waitq
,
&
wait
);
set_current_state
(
TASK_UNINTERRUPTIBLE
);
__enqueue_tpd
(
he_dev
,
tpd
,
cid
);
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
timeout
=
schedule_timeout
(
30
*
HZ
);
...
...
@@ -2736,7 +2715,7 @@ he_close(struct atm_vcc *vcc)
goto
close_tx_incomplete
;
}
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
while
(
!
((
tsr4
=
he_readl_tsr4
(
he_dev
,
cid
))
&
TSR4_SESSION_ENDED
))
{
HPRINTK
(
"close tx cid 0x%x !TSR4_SESSION_ENDED (tsr4 = 0x%x)
\n
"
,
cid
,
tsr4
);
udelay
(
250
);
...
...
@@ -2761,7 +2740,7 @@ he_close(struct atm_vcc *vcc)
he_dev
->
total_bw
-=
he_dev
->
cs_stper
[
reg
].
pcr
;
}
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
HPRINTK
(
"close tx cid 0x%x complete
\n
"
,
cid
);
}
...
...
@@ -2818,7 +2797,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
return
-
EINVAL
;
}
#endif
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
tpd
=
__alloc_tpd
(
he_dev
);
if
(
tpd
==
NULL
)
{
...
...
@@ -2827,7 +2806,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
else
dev_kfree_skb_any
(
skb
);
atomic_inc
(
&
vcc
->
stats
->
tx_err
);
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
return
-
ENOMEM
;
}
...
...
@@ -2869,7 +2848,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
else
dev_kfree_skb_any
(
skb
);
atomic_inc
(
&
vcc
->
stats
->
tx_err
);
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
return
-
ENOMEM
;
}
tpd
->
status
|=
TPD_USERCELL
;
...
...
@@ -2884,7 +2863,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
}
tpd
->
iovec
[
slot
-
1
].
len
|=
TPD_LST
;
tpd
->
iovec
[
slot
-
1
].
len
|=
TPD_LST
;
#else
tpd
->
address0
=
pci_map_single
(
he_dev
->
pci_dev
,
skb
->
data
,
skb
->
len
,
PCI_DMA_TODEVICE
);
tpd
->
length0
=
skb
->
len
|
TPD_LST
;
...
...
@@ -2897,7 +2876,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
ATM_SKB
(
skb
)
->
vcc
=
vcc
;
__enqueue_tpd
(
he_dev
,
tpd
,
cid
);
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
atomic_inc
(
&
vcc
->
stats
->
tx
);
...
...
@@ -2919,7 +2898,7 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void *arg)
copy_from_user
(
&
reg
,
(
struct
he_ioctl_reg
*
)
arg
,
sizeof
(
struct
he_ioctl_reg
));
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
switch
(
reg
.
type
)
{
case
HE_REGTYPE_PCI
:
reg
.
val
=
he_readl
(
he_dev
,
reg
.
addr
);
...
...
@@ -2940,7 +2919,7 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void *arg)
err
=
-
EINVAL
;
break
;
}
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
if
(
err
==
0
)
copy_to_user
((
struct
he_ioctl_reg
*
)
arg
,
&
reg
,
sizeof
(
struct
he_ioctl_reg
));
...
...
@@ -2966,15 +2945,15 @@ he_phy_put(struct atm_dev *atm_dev, unsigned char val, unsigned long addr)
HPRINTK
(
"phy_put(val 0x%x, addr 0x%lx)
\n
"
,
val
,
addr
);
HE_SPIN_LOCK
(
he_dev
,
flags
);
he_writel
(
he_dev
,
val
,
FRAMER
+
(
addr
*
4
));
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
he_writel
(
he_dev
,
val
,
FRAMER
+
(
addr
*
4
));
#ifdef CONFIG_IA64_SGI_SN2
(
void
)
he_readl
(
he_dev
,
FRAMER
+
(
addr
*
4
));
#endif
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
}
static
unsigned
char
he_phy_get
(
struct
atm_dev
*
atm_dev
,
unsigned
long
addr
)
{
...
...
@@ -2982,9 +2961,9 @@ he_phy_get(struct atm_dev *atm_dev, unsigned long addr)
struct
he_dev
*
he_dev
=
HE_DEV
(
atm_dev
);
unsigned
reg
;
HE_SPIN_LOCK
(
he_dev
,
flags
);
reg
=
he_readl
(
he_dev
,
FRAMER
+
(
addr
*
4
));
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
reg
=
he_readl
(
he_dev
,
FRAMER
+
(
addr
*
4
));
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
HPRINTK
(
"phy_get(addr 0x%lx) =0x%x
\n
"
,
addr
,
reg
);
return
reg
;
...
...
@@ -2999,7 +2978,7 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
#ifdef notdef
struct
he_rbrq
*
rbrq_tail
;
struct
he_tpdrq
*
tpdrq_head
;
int
rbpl_head
,
rbpl_tail
;
int
rbpl_head
,
rbpl_tail
;
#endif
static
long
mcc
=
0
,
oec
=
0
,
dcc
=
0
,
cec
=
0
;
...
...
@@ -3015,12 +2994,12 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
if
(
!
left
--
)
return
sprintf
(
page
,
"Mismatched Cells VPI/VCI Not Open Dropped Cells RCM Dropped Cells
\n
"
);
HE_SPIN_LOCK
(
he_dev
,
flags
);
spin_lock_irqsave
(
&
he_dev
->
global_lock
,
flags
);
mcc
+=
he_readl
(
he_dev
,
MCC
);
oec
+=
he_readl
(
he_dev
,
OEC
);
dcc
+=
he_readl
(
he_dev
,
DCC
);
cec
+=
he_readl
(
he_dev
,
CEC
);
HE_SPIN_UNLOCK
(
he_dev
,
flags
);
spin_unlock_irqrestore
(
&
he_dev
->
global_lock
,
flags
);
if
(
!
left
--
)
return
sprintf
(
page
,
"%16ld %16ld %13ld %17ld
\n\n
"
,
...
...
@@ -3044,8 +3023,8 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
#ifdef notdef
rbpl_head
=
RBPL_MASK
(
he_readl
(
he_dev
,
G0_RBPL_S
));
rbpl_tail
=
RBPL_MASK
(
he_readl
(
he_dev
,
G0_RBPL_T
));
rbpl_head
=
RBPL_MASK
(
he_readl
(
he_dev
,
G0_RBPL_S
));
rbpl_tail
=
RBPL_MASK
(
he_readl
(
he_dev
,
G0_RBPL_T
));
inuse
=
rbpl_head
-
rbpl_tail
;
if
(
inuse
<
0
)
...
...
@@ -3090,32 +3069,31 @@ read_prom_byte(struct he_dev *he_dev, int addr)
he_writel
(
he_dev
,
val
,
HOST_CNTL
);
/* Send READ instruction */
for
(
i
=
0
;
i
<
sizeof
(
readtab
)
/
sizeof
(
readtab
[
0
]);
i
++
)
{
for
(
i
=
0
;
i
<
sizeof
(
readtab
)
/
sizeof
(
readtab
[
0
]);
i
++
)
{
he_writel
(
he_dev
,
val
|
readtab
[
i
],
HOST_CNTL
);
udelay
(
EEPROM_DELAY
);
}
/* Next, we need to send the byte address to read from */
for
(
i
=
7
;
i
>=
0
;
i
--
)
{
/* Next, we need to send the byte address to read from */
for
(
i
=
7
;
i
>=
0
;
i
--
)
{
he_writel
(
he_dev
,
val
|
clocktab
[
j
++
]
|
(((
addr
>>
i
)
&
1
)
<<
9
),
HOST_CNTL
);
udelay
(
EEPROM_DELAY
);
he_writel
(
he_dev
,
val
|
clocktab
[
j
++
]
|
(((
addr
>>
i
)
&
1
)
<<
9
),
HOST_CNTL
);
udelay
(
EEPROM_DELAY
);
}
j
=
0
;
j
=
0
;
val
&=
0xFFFFF7FF
;
/* Turn off write enable */
he_writel
(
he_dev
,
val
,
HOST_CNTL
);
/* Now, we can read data from the EEPROM by clocking it in */
for
(
i
=
7
;
i
>=
0
;
i
--
)
{
for
(
i
=
7
;
i
>=
0
;
i
--
)
{
he_writel
(
he_dev
,
val
|
clocktab
[
j
++
],
HOST_CNTL
);
udelay
(
EEPROM_DELAY
);
tmp_read
=
he_readl
(
he_dev
,
HOST_CNTL
);
byte_read
|=
(
unsigned
char
)
((
tmp_read
&
ID_DOUT
)
>>
ID_DOFFSET
<<
i
);
udelay
(
EEPROM_DELAY
);
tmp_read
=
he_readl
(
he_dev
,
HOST_CNTL
);
byte_read
|=
(
unsigned
char
)
((
tmp_read
&
ID_DOUT
)
>>
ID_DOFFSET
<<
i
);
he_writel
(
he_dev
,
val
|
clocktab
[
j
++
],
HOST_CNTL
);
udelay
(
EEPROM_DELAY
);
}
...
...
@@ -3123,7 +3101,7 @@ read_prom_byte(struct he_dev *he_dev, int addr)
he_writel
(
he_dev
,
val
|
ID_CS
,
HOST_CNTL
);
udelay
(
EEPROM_DELAY
);
return
(
byte_read
)
;
return
byte_read
;
}
MODULE_LICENSE
(
"GPL"
);
...
...
@@ -3145,7 +3123,7 @@ MODULE_PARM_DESC(sdh, "use SDH framing (default 0)");
static
struct
pci_device_id
he_pci_tbl
[]
__devinitdata
=
{
{
PCI_VENDOR_ID_FORE
,
PCI_DEVICE_ID_FORE_HE
,
PCI_ANY_ID
,
PCI_ANY_ID
,
0
,
0
,
0
},
{
0
,
}
{
0
,
}
};
static
struct
pci_driver
he_driver
=
{
...
...
@@ -3157,12 +3135,12 @@ static struct pci_driver he_driver = {
static
int
__init
he_init
(
void
)
{
return
pci_module_init
(
&
he_driver
);
return
pci_module_init
(
&
he_driver
);
}
static
void
__exit
he_cleanup
(
void
)
{
pci_unregister_driver
(
&
he_driver
);
pci_unregister_driver
(
&
he_driver
);
}
module_init
(
he_init
);
...
...
drivers/char/n_hdlc.c
View file @
cbec8fba
...
...
@@ -6,7 +6,8 @@
* Microgate and SyncLink are registered trademarks of Microgate Corporation
*
* Adapted from ppp.c, written by Michael Callahan <callahan@maths.ox.ac.uk>,
* Al Longyear <longyear@netcom.com>, Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
* Al Longyear <longyear@netcom.com>,
* Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
*
* Original release 01/11/99
* $Id: n_hdlc.c,v 4.8 2003/05/06 21:18:51 paulkf Exp $
...
...
@@ -96,32 +97,19 @@
#include <linux/poll.h>
#include <linux/in.h>
#include <linux/ioctl.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/errno.h>
#include <linux/string.h>
/* used in new tty drivers */
#include <linux/signal.h>
/* used in new tty drivers */
#include <linux/if.h>
#include <asm/system.h>
#include <asm/bitops.h>
#include <asm/termios.h>
#include <linux/if.h>
#include <linux/ioctl.h>
#ifdef CONFIG_KERNELD
#include <linux/kerneld.h>
#endif
#define GET_USER(error,value,addr) error = get_user(value,addr)
#define COPY_FROM_USER(error,dest,src,size) error = copy_from_user(dest,src,size) ? -EFAULT : 0
#define PUT_USER(error,value,addr) error = put_user(value,addr)
#define COPY_TO_USER(error,dest,src,size) error = copy_to_user(dest,src,size) ? -EFAULT : 0
#include <asm/uaccess.h>
typedef
ssize_t
rw_ret_t
;
typedef
size_t
rw_count_t
;
/*
* Buffers for individual HDLC frames
*/
...
...
@@ -130,91 +118,90 @@ typedef size_t rw_count_t;
#define MAX_RX_BUF_COUNT 60
#define DEFAULT_TX_BUF_COUNT 1
struct
n_hdlc_buf
{
struct
n_hdlc_buf
*
link
;
int
count
;
char
buf
[
1
];
};
typedef
struct
_n_hdlc_buf
{
struct
_n_hdlc_buf
*
link
;
int
count
;
char
buf
[
1
];
}
N_HDLC_BUF
;
#define N_HDLC_BUF_SIZE (sizeof(N_HDLC_BUF)+maxframe)
#define N_HDLC_BUF_SIZE (sizeof(struct n_hdlc_buf) + maxframe)
typedef
struct
_n_hdlc_buf_list
{
N_HDLC_BUF
*
head
;
N_HDLC_BUF
*
tail
;
int
count
;
spinlock_t
spinlock
;
}
N_HDLC_BUF_LIST
;
struct
n_hdlc_buf_list
{
struct
n_hdlc_buf
*
head
;
struct
n_hdlc_buf
*
tail
;
int
count
;
spinlock_t
spinlock
;
};
/*
* Per device instance data structure
/**
* struct n_hdlc - per device instance data structure
* @magic - magic value for structure
* @flags - miscellaneous control flags
* @tty - ptr to TTY structure
* @backup_tty - TTY to use if tty gets closed
* @tbusy - reentrancy flag for tx wakeup code
* @woke_up - FIXME: describe this field
* @tbuf - currently transmitting tx buffer
* @tx_buf_list - list of pending transmit frame buffers
* @rx_buf_list - list of received frame buffers
* @tx_free_buf_list - list unused transmit frame buffers
* @rx_free_buf_list - list unused received frame buffers
*/
struct
n_hdlc
{
int
magic
;
/* magic value for structure */
__u32
flags
;
/* miscellaneous control flags */
struct
tty_struct
*
tty
;
/* ptr to TTY structure */
struct
tty_struct
*
backup_tty
;
/* TTY to use if tty gets closed */
int
tbusy
;
/* reentrancy flag for tx wakeup code */
int
woke_up
;
N_HDLC_BUF
*
tbuf
;
/* currently transmitting tx buffer */
N_HDLC_BUF_LIST
tx_buf_list
;
/* list of pending transmit frame buffers */
N_HDLC_BUF_LIST
rx_buf_list
;
/* list of received frame buffers */
N_HDLC_BUF_LIST
tx_free_buf_list
;
/* list unused transmit frame buffers */
N_HDLC_BUF_LIST
rx_free_buf_list
;
/* list unused received frame buffers */
int
magic
;
__u32
flags
;
struct
tty_struct
*
tty
;
struct
tty_struct
*
backup_tty
;
int
tbusy
;
int
woke_up
;
struct
n_hdlc_buf
*
tbuf
;
struct
n_hdlc_buf_list
tx_buf_list
;
struct
n_hdlc_buf_list
rx_buf_list
;
struct
n_hdlc_buf_list
tx_free_buf_list
;
struct
n_hdlc_buf_list
rx_free_buf_list
;
};
/*
* HDLC buffer list manipulation functions
*/
static
void
n_hdlc_buf_list_init
(
N_HDLC_BUF_LIST
*
list
);
static
void
n_hdlc_buf_put
(
N_HDLC_BUF_LIST
*
list
,
N_HDLC_BUF
*
buf
);
static
N_HDLC_BUF
*
n_hdlc_buf_get
(
N_HDLC_BUF_LIST
*
list
);
static
void
n_hdlc_buf_list_init
(
struct
n_hdlc_buf_list
*
list
);
static
void
n_hdlc_buf_put
(
struct
n_hdlc_buf_list
*
list
,
struct
n_hdlc_buf
*
buf
);
static
struct
n_hdlc_buf
*
n_hdlc_buf_get
(
struct
n_hdlc_buf_list
*
list
);
/* Local functions */
static
struct
n_hdlc
*
n_hdlc_alloc
(
void
);
MODULE_PARM
(
debuglevel
,
"i"
);
MODULE_PARM
(
maxframe
,
"i"
);
/* debug level can be set by insmod for debugging purposes */
#define DEBUG_LEVEL_INFO 1
static
int
debuglevel
;
/* max frame size for memory allocations */
static
ssize_t
maxframe
=
4096
;
static
ssize_t
maxframe
=
4096
;
/* TTY callbacks */
static
rw_ret_t
n_hdlc_tty_read
(
struct
tty_struct
*
,
struct
file
*
,
__u8
*
,
rw_count_t
);
static
rw_ret_t
n_hdlc_tty_write
(
struct
tty_struct
*
,
struct
file
*
,
const
__u8
*
,
rw_count_t
);
static
int
n_hdlc_tty_ioctl
(
struct
tty_struct
*
,
struct
file
*
,
unsigned
int
,
unsigned
lon
g
);
static
unsigned
int
n_hdlc_tty_poll
(
struct
tty_struct
*
tty
,
struct
file
*
filp
,
poll_table
*
wait
);
static
int
n_hdlc_tty_open
(
struct
tty_struct
*
);
static
void
n_hdlc_tty_close
(
struct
tty_struct
*
);
static
int
n_hdlc_tty_room
(
struct
tty_struct
*
tty
);
static
void
n_hdlc_tty_receive
(
struct
tty_struct
*
tty
,
const
__u8
*
cp
,
char
*
fp
,
int
count
);
static
void
n_hdlc_tty_wakeup
(
struct
tty_struct
*
tty
);
static
int
n_hdlc_tty_read
(
struct
tty_struct
*
tty
,
struct
file
*
file
,
__u8
*
buf
,
size_t
nr
);
static
int
n_hdlc_tty_write
(
struct
tty_struct
*
tty
,
struct
file
*
file
,
const
__u8
*
buf
,
size_t
nr
);
static
int
n_hdlc_tty_ioctl
(
struct
tty_struct
*
tty
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
ar
g
);
static
unsigned
int
n_hdlc_tty_poll
(
struct
tty_struct
*
tty
,
struct
file
*
filp
,
poll_table
*
wait
);
static
int
n_hdlc_tty_open
(
struct
tty_struct
*
tty
);
static
void
n_hdlc_tty_close
(
struct
tty_struct
*
tty
);
static
int
n_hdlc_tty_room
(
struct
tty_struct
*
tty
);
static
void
n_hdlc_tty_receive
(
struct
tty_struct
*
tty
,
const
__u8
*
cp
,
char
*
fp
,
int
count
);
static
void
n_hdlc_tty_wakeup
(
struct
tty_struct
*
tty
);
#define bset(p,b) ((p)[(b) >> 5] |= (1 << ((b) & 0x1f)))
#define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data))
#define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty)
/* Define this string only once for all macro invocations */
static
char
szVersion
[]
=
HDLC_VERSION
;
static
struct
tty_ldisc
n_hdlc_ldisc
=
{
.
owner
=
THIS_MODULE
,
.
magic
=
TTY_LDISC_MAGIC
,
...
...
@@ -230,15 +217,14 @@ static struct tty_ldisc n_hdlc_ldisc = {
.
write_wakeup
=
n_hdlc_tty_wakeup
,
};
/* n_hdlc_release()
*
* release an n_hdlc per device line discipline info structure
*
/**
* n_hdlc_release - release an n_hdlc per device line discipline info structure
* @n_hdlc - per device line discipline info structure
*/
static
void
n_hdlc_release
(
struct
n_hdlc
*
n_hdlc
)
static
void
n_hdlc_release
(
struct
n_hdlc
*
n_hdlc
)
{
struct
tty_struct
*
tty
=
n_hdlc2tty
(
n_hdlc
);
N_HDLC_BUF
*
buf
;
struct
n_hdlc_buf
*
buf
;
if
(
debuglevel
>=
DEBUG_LEVEL_INFO
)
printk
(
"%s(%d)n_hdlc_release() called
\n
"
,
__FILE__
,
__LINE__
);
...
...
@@ -285,10 +271,12 @@ static void n_hdlc_release (struct n_hdlc *n_hdlc)
}
/* end of n_hdlc_release() */
/* n_hdlc_tty_close()
/**
* n_hdlc_tty_close - line discipline close
* @tty - pointer to tty info structure
*
*
Called when the line discipline is changed to something
*
else, the tty is closed, or the tty detects a hangup.
*
Called when the line discipline is changed to something
*
else, the tty is closed, or the tty detects a hangup.
*/
static
void
n_hdlc_tty_close
(
struct
tty_struct
*
tty
)
{
...
...
@@ -322,12 +310,11 @@ static void n_hdlc_tty_close(struct tty_struct *tty)
}
/* end of n_hdlc_tty_close() */
/* n_hdlc_tty_open
*
* called when line discipline changed to n_hdlc
*
* Arguments: tty pointer to tty info structure
* Return Value: 0 if success, otherwise error code
/**
* n_hdlc_tty_open - called when line discipline changed to n_hdlc
* @tty - pointer to tty info structure
*
* Returns 0 if success, otherwise error code
*/
static
int
n_hdlc_tty_open
(
struct
tty_struct
*
tty
)
{
...
...
@@ -373,22 +360,20 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
}
/* end of n_tty_hdlc_open() */
/* n_hdlc_send_frames()
*
* send frames on pending send buffer list until the
* driver does not accept a frame (busy)
* this function is called after adding a frame to the
* send buffer list and by the tty wakeup callback
*
* Arguments: n_hdlc pointer to ldisc instance data
* tty pointer to tty instance data
* Return Value: None
/**
* n_hdlc_send_frames - send frames on pending send buffer list
* @n_hdlc - pointer to ldisc instance data
* @tty - pointer to tty instance data
*
* Send frames on pending send buffer list until the driver does not accept a
* frame (busy) this function is called after adding a frame to the send buffer
* list and by the tty wakeup callback.
*/
static
void
n_hdlc_send_frames
(
struct
n_hdlc
*
n_hdlc
,
struct
tty_struct
*
tty
)
static
void
n_hdlc_send_frames
(
struct
n_hdlc
*
n_hdlc
,
struct
tty_struct
*
tty
)
{
register
int
actual
;
unsigned
long
flags
;
N_HDLC_BUF
*
tbuf
;
struct
n_hdlc_buf
*
tbuf
;
if
(
debuglevel
>=
DEBUG_LEVEL_INFO
)
printk
(
"%s(%d)n_hdlc_send_frames() called
\n
"
,
__FILE__
,
__LINE__
);
...
...
@@ -431,7 +416,7 @@ static void n_hdlc_send_frames (struct n_hdlc *n_hdlc, struct tty_struct *tty)
__FILE__
,
__LINE__
,
tbuf
);
/* free current transmit buffer */
n_hdlc_buf_put
(
&
n_hdlc
->
tx_free_buf_list
,
tbuf
);
n_hdlc_buf_put
(
&
n_hdlc
->
tx_free_buf_list
,
tbuf
);
/* this tx buffer is done */
n_hdlc
->
tbuf
=
NULL
;
...
...
@@ -469,17 +454,15 @@ static void n_hdlc_send_frames (struct n_hdlc *n_hdlc, struct tty_struct *tty)
}
/* end of n_hdlc_send_frames() */
/* n_hdlc_tty_wakeup()
/**
* n_hdlc_tty_wakeup - Callback for transmit wakeup
* @tty - pointer to associated tty instance data
*
* Callback for transmit wakeup. Called when low level
* device driver can accept more send data.
*
* Arguments: tty pointer to associated tty instance data
* Return Value: None
* Called when low level device driver can accept more send data.
*/
static
void
n_hdlc_tty_wakeup
(
struct
tty_struct
*
tty
)
static
void
n_hdlc_tty_wakeup
(
struct
tty_struct
*
tty
)
{
struct
n_hdlc
*
n_hdlc
=
tty2n_hdlc
(
tty
);
struct
n_hdlc
*
n_hdlc
=
tty2n_hdlc
(
tty
);
if
(
debuglevel
>=
DEBUG_LEVEL_INFO
)
printk
(
"%s(%d)n_hdlc_tty_wakeup() called
\n
"
,
__FILE__
,
__LINE__
);
...
...
@@ -496,16 +479,14 @@ static void n_hdlc_tty_wakeup (struct tty_struct *tty)
}
/* end of n_hdlc_tty_wakeup() */
/* n_hdlc_tty_room()
*
* Callback function from tty driver. Return the amount of
* space left in the receiver's buffer to decide if remote
* transmitter is to be throttled.
/**
* n_hdlc_tty_room - Return the amount of space left in the receiver's buffer
* @tty - pointer to associated tty instance data
*
*
Arguments: tty pointer to associated tty instance data
*
Return Value: number of bytes left in receive buffer
*
Callback function from tty driver. Return the amount of space left in the
*
receiver's buffer to decide if remote transmitter is to be throttled.
*/
static
int
n_hdlc_tty_room
(
struct
tty_struct
*
tty
)
static
int
n_hdlc_tty_room
(
struct
tty_struct
*
tty
)
{
if
(
debuglevel
>=
DEBUG_LEVEL_INFO
)
printk
(
"%s(%d)n_hdlc_tty_room() called
\n
"
,
__FILE__
,
__LINE__
);
...
...
@@ -514,23 +495,21 @@ static int n_hdlc_tty_room (struct tty_struct *tty)
return
65536
;
}
/* end of n_hdlc_tty_root() */
/* n_hdlc_tty_receive()
*
* Called by tty low level driver when receive data is
* available. Data is interpreted as one HDLC frame.
*
* Arguments: tty pointer to tty isntance data
* data pointer to received data
* flags pointer to flags for data
* count count of received data in bytes
*
* Return Value: None
/**
* n_hdlc_tty_receive - Called by tty driver when receive data is available
* @tty - pointer to tty instance data
* @data - pointer to received data
* @flags - pointer to flags for data
* @count - count of received data in bytes
*
* Called by tty low level driver when receive data is available. Data is
* interpreted as one HDLC frame.
*/
static
void
n_hdlc_tty_receive
(
struct
tty_struct
*
tty
,
const
__u8
*
data
,
char
*
flags
,
int
count
)
static
void
n_hdlc_tty_receive
(
struct
tty_struct
*
tty
,
const
__u8
*
data
,
char
*
flags
,
int
count
)
{
register
struct
n_hdlc
*
n_hdlc
=
tty2n_hdlc
(
tty
);
register
N_HDLC_BUF
*
buf
;
register
struct
n_hdlc_buf
*
buf
;
if
(
debuglevel
>=
DEBUG_LEVEL_INFO
)
printk
(
"%s(%d)n_hdlc_tty_receive() called count=%d
\n
"
,
...
...
@@ -560,7 +539,7 @@ static void n_hdlc_tty_receive(struct tty_struct *tty,
/* no buffers in free list, attempt to allocate another rx buffer */
/* unless the maximum count has been reached */
if
(
n_hdlc
->
rx_buf_list
.
count
<
MAX_RX_BUF_COUNT
)
buf
=
(
N_HDLC_BUF
*
)
kmalloc
(
N_HDLC_BUF_SIZE
,
GFP_ATOMIC
);
buf
=
kmalloc
(
N_HDLC_BUF_SIZE
,
GFP_ATOMIC
);
}
if
(
!
buf
)
{
...
...
@@ -575,7 +554,7 @@ static void n_hdlc_tty_receive(struct tty_struct *tty,
buf
->
count
=
count
;
/* add HDLC buffer to list of received frames */
n_hdlc_buf_put
(
&
n_hdlc
->
rx_buf_list
,
buf
);
n_hdlc_buf_put
(
&
n_hdlc
->
rx_buf_list
,
buf
);
/* wake up any blocked reads and perform async signalling */
wake_up_interruptible
(
&
tty
->
read_wait
);
...
...
@@ -584,28 +563,22 @@ static void n_hdlc_tty_receive(struct tty_struct *tty,
}
/* end of n_hdlc_tty_receive() */
/* n_hdlc_tty_read()
*
* Called to retreive one frame of data (if available)
/**
* n_hdlc_tty_read - Called to retreive one frame of data (if available)
* @tty - pointer to tty instance data
* @file - pointer to open file object
* @buf - pointer to returned data buffer
* @nr - size of returned data buffer
*
* Arguments:
*
* tty pointer to tty instance data
* file pointer to open file object
* buf pointer to returned data buffer
* nr size of returned data buffer
*
* Return Value:
*
* Number of bytes returned or error code
* Returns the number of bytes returned or error code.
*/
static
rw_ret_t
n_hdlc_tty_read
(
struct
tty_struct
*
tty
,
struct
file
*
file
,
__u8
*
buf
,
rw_count
_t
nr
)
static
int
n_hdlc_tty_read
(
struct
tty_struct
*
tty
,
struct
file
*
file
,
__u8
*
buf
,
size
_t
nr
)
{
struct
n_hdlc
*
n_hdlc
=
tty2n_hdlc
(
tty
);
int
error
;
rw_ret_
t
ret
;
N_HDLC_BUF
*
rbuf
;
in
t
ret
;
struct
n_hdlc_buf
*
rbuf
;
if
(
debuglevel
>=
DEBUG_LEVEL_INFO
)
printk
(
"%s(%d)n_hdlc_tty_read() called
\n
"
,
__FILE__
,
__LINE__
);
...
...
@@ -644,16 +617,15 @@ static rw_ret_t n_hdlc_tty_read (struct tty_struct *tty,
return
-
EINTR
;
}
if
(
rbuf
->
count
>
nr
)
{
if
(
rbuf
->
count
>
nr
)
/* frame too large for caller's buffer (discard frame) */
ret
=
(
rw_ret_t
)
-
EOVERFLOW
;
}
else
{
ret
=
-
EOVERFLOW
;
else
{
/* Copy the data to the caller's buffer */
COPY_TO_USER
(
error
,
buf
,
rbuf
->
buf
,
rbuf
->
count
);
if
(
error
)
ret
=
(
rw_ret_t
)
error
;
if
(
copy_to_user
(
buf
,
rbuf
->
buf
,
rbuf
->
count
))
ret
=
-
EFAULT
;
else
ret
=
(
rw_ret_t
)
rbuf
->
count
;
ret
=
rbuf
->
count
;
}
/* return HDLC buffer to free list unless the free list */
...
...
@@ -668,24 +640,22 @@ static rw_ret_t n_hdlc_tty_read (struct tty_struct *tty,
}
/* end of n_hdlc_tty_read() */
/* n_hdlc_tty_write()
*
* write a single frame of data to device
*
* Arguments: tty pointer to associated tty device instance data
* file pointer to file object data
* data pointer to transmit data (one frame)
* count size of transmit frame in bytes
/**
* n_hdlc_tty_write - write a single frame of data to device
* @tty - pointer to associated tty device instance data
* @file - pointer to file object data
* @data - pointer to transmit data (one frame)
* @count - size of transmit frame in bytes
*
* Return
Value: number of bytes written (or error code)
* Return
s the number of bytes written (or error code).
*/
static
rw_ret_t
n_hdlc_tty_write
(
struct
tty_struct
*
tty
,
struct
file
*
file
,
const
__u8
*
data
,
rw_count
_t
count
)
static
int
n_hdlc_tty_write
(
struct
tty_struct
*
tty
,
struct
file
*
file
,
const
__u8
*
data
,
size
_t
count
)
{
struct
n_hdlc
*
n_hdlc
=
tty2n_hdlc
(
tty
);
int
error
=
0
;
DECLARE_WAITQUEUE
(
wait
,
current
);
N_HDLC_BUF
*
tbuf
;
struct
n_hdlc_buf
*
tbuf
;
if
(
debuglevel
>=
DEBUG_LEVEL_INFO
)
printk
(
"%s(%d)n_hdlc_tty_write() called count=%d
\n
"
,
...
...
@@ -735,10 +705,10 @@ static rw_ret_t n_hdlc_tty_write (struct tty_struct *tty, struct file *file,
if
(
!
error
)
{
/* Retrieve the user's buffer */
COPY_FROM_USER
(
error
,
tbuf
->
buf
,
data
,
count
);
if
(
error
)
{
if
(
copy_from_user
(
tbuf
->
buf
,
data
,
count
))
{
/* return tx buffer to free list */
n_hdlc_buf_put
(
&
n_hdlc
->
tx_free_buf_list
,
tbuf
);
error
=
-
EFAULT
;
}
else
{
/* Send the data */
tbuf
->
count
=
error
=
count
;
...
...
@@ -751,21 +721,17 @@ static rw_ret_t n_hdlc_tty_write (struct tty_struct *tty, struct file *file,
}
/* end of n_hdlc_tty_write() */
/* n_hdlc_tty_ioctl()
/**
* n_hdlc_tty_ioctl - process IOCTL system call for the tty device.
* @tty - pointer to tty instance data
* @file - pointer to open file object for device
* @cmd - IOCTL command code
* @arg - argument for IOCTL call (cmd dependent)
*
* Process IOCTL system call for the tty device.
*
* Arguments:
*
* tty pointer to tty instance data
* file pointer to open file object for device
* cmd IOCTL command code
* arg argument for IOCTL call (cmd dependent)
*
* Return Value: Command dependent
* Returns command dependent result.
*/
static
int
n_hdlc_tty_ioctl
(
struct
tty_struct
*
tty
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
static
int
n_hdlc_tty_ioctl
(
struct
tty_struct
*
tty
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
struct
n_hdlc
*
n_hdlc
=
tty2n_hdlc
(
tty
);
int
error
=
0
;
...
...
@@ -790,7 +756,7 @@ static int n_hdlc_tty_ioctl (struct tty_struct *tty, struct file * file,
else
count
=
0
;
spin_unlock_irqrestore
(
&
n_hdlc
->
rx_buf_list
.
spinlock
,
flags
);
PUT_USER
(
error
,
count
,
(
int
*
)
arg
);
error
=
put_user
(
count
,
(
int
*
)
arg
);
break
;
case
TIOCOUTQ
:
...
...
@@ -802,7 +768,7 @@ static int n_hdlc_tty_ioctl (struct tty_struct *tty, struct file * file,
if
(
n_hdlc
->
tx_buf_list
.
head
)
count
+=
n_hdlc
->
tx_buf_list
.
head
->
count
;
spin_unlock_irqrestore
(
&
n_hdlc
->
tx_buf_list
.
spinlock
,
flags
);
PUT_USER
(
error
,
count
,
(
int
*
)
arg
);
error
=
put_user
(
count
,
(
int
*
)
arg
);
break
;
default:
...
...
@@ -813,24 +779,18 @@ static int n_hdlc_tty_ioctl (struct tty_struct *tty, struct file * file,
}
/* end of n_hdlc_tty_ioctl() */
/* n_hdlc_tty_poll()
*
* TTY callback for poll system call. Determine which
* operations (read/write) will not block and return
* info to caller.
*
* Arguments:
/**
* n_hdlc_tty_poll - TTY callback for poll system call
* @tty - pointer to tty instance data
* @filp - pointer to open file object for device
* @poll_table - wait queue for operations
*
* tty pointer to tty instance data
* filp pointer to open file object for device
* poll_table wait queue for operations
*
* Return Value:
*
* bit mask containing info on which ops will not block
* Determine which operations (read/write) will not block and return info
* to caller.
* Returns a bit mask containing info on which ops will not block.
*/
static
unsigned
int
n_hdlc_tty_poll
(
struct
tty_struct
*
tty
,
struct
file
*
filp
,
poll_table
*
wait
)
static
unsigned
int
n_hdlc_tty_poll
(
struct
tty_struct
*
tty
,
struct
file
*
filp
,
poll_table
*
wait
)
{
struct
n_hdlc
*
n_hdlc
=
tty2n_hdlc
(
tty
);
unsigned
int
mask
=
0
;
...
...
@@ -858,20 +818,17 @@ static unsigned int n_hdlc_tty_poll (struct tty_struct *tty,
return
mask
;
}
/* end of n_hdlc_tty_poll() */
/* n_hdlc_alloc()
*
* Allocate an n_hdlc instance data structure
/**
* n_hdlc_alloc - allocate an n_hdlc instance data structure
*
* Arguments: None
* Return Value: pointer to structure if success, otherwise 0
* Returns a pointer to newly created structure if success, otherwise %NULL
*/
static
struct
n_hdlc
*
n_hdlc_alloc
(
void
)
static
struct
n_hdlc
*
n_hdlc_alloc
(
void
)
{
struct
n_hdlc
*
n_hdlc
;
N_HDLC_BUF
*
buf
;
int
i
;
n_hdlc
=
(
struct
n_hdlc
*
)
kmalloc
(
sizeof
(
struct
n_hdlc
),
GFP_KERNEL
);
struct
n_hdlc_buf
*
buf
;
int
i
;
struct
n_hdlc
*
n_hdlc
=
kmalloc
(
sizeof
(
*
n_hdlc
),
GFP_KERNEL
);
if
(
!
n_hdlc
)
return
0
;
...
...
@@ -884,7 +841,7 @@ static struct n_hdlc *n_hdlc_alloc (void)
/* allocate free rx buffer list */
for
(
i
=
0
;
i
<
DEFAULT_RX_BUF_COUNT
;
i
++
)
{
buf
=
(
N_HDLC_BUF
*
)
kmalloc
(
N_HDLC_BUF_SIZE
,
GFP_KERNEL
);
buf
=
kmalloc
(
N_HDLC_BUF_SIZE
,
GFP_KERNEL
);
if
(
buf
)
n_hdlc_buf_put
(
&
n_hdlc
->
rx_free_buf_list
,
buf
);
else
if
(
debuglevel
>=
DEBUG_LEVEL_INFO
)
...
...
@@ -893,7 +850,7 @@ static struct n_hdlc *n_hdlc_alloc (void)
/* allocate free tx buffer list */
for
(
i
=
0
;
i
<
DEFAULT_TX_BUF_COUNT
;
i
++
)
{
buf
=
(
N_HDLC_BUF
*
)
kmalloc
(
N_HDLC_BUF_SIZE
,
GFP_KERNEL
);
buf
=
kmalloc
(
N_HDLC_BUF_SIZE
,
GFP_KERNEL
);
if
(
buf
)
n_hdlc_buf_put
(
&
n_hdlc
->
tx_free_buf_list
,
buf
);
else
if
(
debuglevel
>=
DEBUG_LEVEL_INFO
)
...
...
@@ -908,31 +865,23 @@ static struct n_hdlc *n_hdlc_alloc (void)
}
/* end of n_hdlc_alloc() */
/* n_hdlc_buf_list_init()
*
* initialize specified HDLC buffer list
*
* Arguments: list pointer to buffer list
* Return Value: None
/**
* n_hdlc_buf_list_init - initialize specified HDLC buffer list
* @list - pointer to buffer list
*/
static
void
n_hdlc_buf_list_init
(
N_HDLC_BUF_LIST
*
list
)
static
void
n_hdlc_buf_list_init
(
struct
n_hdlc_buf_list
*
list
)
{
memset
(
list
,
0
,
sizeof
(
N_HDLC_BUF_LIST
));
memset
(
list
,
0
,
sizeof
(
*
list
));
spin_lock_init
(
&
list
->
spinlock
);
}
/* end of n_hdlc_buf_list_init() */
/* n_hdlc_buf_put()
*
* add specified HDLC buffer to tail of specified list
*
* Arguments:
*
* list pointer to buffer list
* buf pointer to buffer
*
* Return Value: None
/**
* n_hdlc_buf_put - add specified HDLC buffer to tail of specified list
* @list - pointer to buffer list
* @buf - pointer to buffer
*/
static
void
n_hdlc_buf_put
(
N_HDLC_BUF_LIST
*
list
,
N_HDLC_BUF
*
buf
)
static
void
n_hdlc_buf_put
(
struct
n_hdlc_buf_list
*
list
,
struct
n_hdlc_buf
*
buf
)
{
unsigned
long
flags
;
spin_lock_irqsave
(
&
list
->
spinlock
,
flags
);
...
...
@@ -949,23 +898,18 @@ static void n_hdlc_buf_put(N_HDLC_BUF_LIST *list,N_HDLC_BUF *buf)
}
/* end of n_hdlc_buf_put() */
/* n_hdlc_buf_get()
/**
* n_hdlc_buf_get - remove and return an HDLC buffer from list
* @list - pointer to HDLC buffer list
*
* remove and return an HDLC buffer from the
* head of the specified HDLC buffer list
*
* Arguments:
*
* list pointer to HDLC buffer list
*
* Return Value:
*
* pointer to HDLC buffer if available, otherwise NULL
* Remove and return an HDLC buffer from the head of the specified HDLC buffer
* list.
* Returns a pointer to HDLC buffer if available, otherwise %NULL.
*/
static
N_HDLC_BUF
*
n_hdlc_buf_get
(
N_HDLC_BUF_LIST
*
list
)
static
struct
n_hdlc_buf
*
n_hdlc_buf_get
(
struct
n_hdlc_buf_list
*
list
)
{
unsigned
long
flags
;
N_HDLC_BUF
*
buf
;
struct
n_hdlc_buf
*
buf
;
spin_lock_irqsave
(
&
list
->
spinlock
,
flags
);
buf
=
list
->
head
;
...
...
@@ -981,42 +925,60 @@ static N_HDLC_BUF* n_hdlc_buf_get(N_HDLC_BUF_LIST *list)
}
/* end of n_hdlc_buf_get() */
static
char
hdlc_banner
[]
__initdata
=
KERN_INFO
"HDLC line discipline: version "
HDLC_VERSION
", maxframe=%u
\n
"
;
static
char
hdlc_register_ok
[]
__initdata
=
KERN_INFO
"N_HDLC line discipline registered.
\n
"
;
static
char
hdlc_register_fail
[]
__initdata
=
KERN_ERR
"error registering line discipline: %d
\n
"
;
static
char
hdlc_init_fail
[]
__initdata
=
KERN_INFO
"N_HDLC: init failure %d
\n
"
;
static
int
__init
n_hdlc_init
(
void
)
{
int
status
;
int
status
;
/* range check maxframe arg */
if
(
maxframe
<
4096
)
maxframe
=
4096
;
else
if
(
maxframe
>
65535
)
maxframe
=
65535
;
if
(
maxframe
<
4096
)
maxframe
=
4096
;
else
if
(
maxframe
>
65535
)
maxframe
=
65535
;
printk
(
"HDLC line discipline: version %s, maxframe=%u
\n
"
,
szVersion
,
maxframe
);
printk
(
hdlc_banner
,
maxframe
);
status
=
tty_register_ldisc
(
N_HDLC
,
&
n_hdlc_ldisc
);
if
(
!
status
)
printk
(
KERN_INFO
"N_HDLC line discipline registered.
\n
"
);
printk
(
hdlc_register_ok
);
else
printk
(
KERN_ERR
"error registering line discipline: %d
\n
"
,
status
);
printk
(
hdlc_register_fail
,
status
);
if
(
status
)
printk
(
KERN_INFO
"N_HDLC: init failure %d
\n
"
,
status
);
return
(
status
)
;
printk
(
hdlc_init_fail
,
status
);
return
status
;
}
/* end of init_module() */
static
char
hdlc_unregister_ok
[]
__exitdata
=
KERN_INFO
"N_HDLC: line discipline unregistered
\n
"
;
static
char
hdlc_unregister_fail
[]
__exitdata
=
KERN_ERR
"N_HDLC: can't unregister line discipline (err = %d)
\n
"
;
static
void
__exit
n_hdlc_exit
(
void
)
{
int
status
;
/* Release tty registration of line discipline */
if
((
status
=
tty_register_ldisc
(
N_HDLC
,
NULL
)))
printk
(
"N_HDLC: can't unregister line discipline (err = %d)
\n
"
,
status
);
int
status
=
tty_register_ldisc
(
N_HDLC
,
NULL
);
if
(
status
)
printk
(
hdlc_unregister_fail
,
status
);
else
printk
(
"N_HDLC: line discipline unregistered
\n
"
);
printk
(
hdlc_unregister_ok
);
}
module_init
(
n_hdlc_init
);
module_exit
(
n_hdlc_exit
);
MODULE_LICENSE
(
"GPL"
);
MODULE_AUTHOR
(
"Paul Fulghum paulkf@microgate.com"
);
MODULE_PARM
(
debuglevel
,
"i"
);
MODULE_PARM
(
maxframe
,
"i"
);
drivers/net/3c509.c
View file @
cbec8fba
...
...
@@ -300,17 +300,11 @@ static int nopnp;
*
* Both call el3_common_init/el3_common_remove. */
static
int
__init
el3_common_init
(
struct
net_device
*
dev
)
static
void
__init
el3_common_init
(
struct
net_device
*
dev
)
{
struct
el3_private
*
lp
=
dev
->
priv
;
short
i
;
el3_cards
++
;
if
(
!
lp
->
dev
)
/* probed devices are not chained */
{
lp
->
next_dev
=
el3_root_dev
;
el3_root_dev
=
dev
;
}
spin_lock_init
(
&
lp
->
lock
);
if
(
dev
->
mem_start
&
0x05
)
{
/* xcvr codes 1/3/4/12 */
...
...
@@ -343,8 +337,6 @@ static int __init el3_common_init (struct net_device *dev)
dev
->
tx_timeout
=
el3_tx_timeout
;
dev
->
watchdog_timeo
=
TX_TIMEOUT
;
dev
->
do_ioctl
=
netdev_ioctl
;
return
0
;
}
static
void
el3_common_remove
(
struct
net_device
*
dev
)
...
...
@@ -374,6 +366,7 @@ static int __init el3_probe(int card_idx)
int
ioaddr
,
irq
,
if_port
;
u16
phys_addr
[
3
];
static
int
current_tag
;
int
err
=
-
ENODEV
;
#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
static
int
pnp_cards
;
struct
pnp_dev
*
idev
=
NULL
;
...
...
@@ -413,7 +406,8 @@ static int __init el3_probe(int card_idx)
phys_addr
[
j
]
=
htons
(
read_eeprom
(
ioaddr
,
j
));
if_port
=
read_eeprom
(
ioaddr
,
8
)
>>
14
;
if
(
!
(
dev
=
init_etherdev
(
NULL
,
sizeof
(
struct
el3_private
))))
{
dev
=
alloc_etherdev
(
sizeof
(
struct
el3_private
));
if
(
!
dev
)
{
release_region
(
ioaddr
,
EL3_IO_EXTENT
);
pnp_device_detach
(
idev
);
return
-
ENOMEM
;
...
...
@@ -421,6 +415,8 @@ static int __init el3_probe(int card_idx)
SET_MODULE_OWNER
(
dev
);
pnp_cards
++
;
netdev_boot_setup_check
(
dev
);
goto
found
;
}
}
...
...
@@ -514,28 +510,29 @@ static int __init el3_probe(int card_idx)
irq
=
13
;
#endif
if
(
!
(
dev
=
init_etherdev
(
NULL
,
sizeof
(
struct
el3_private
))))
return
-
ENOMEM
;
dev
=
alloc_etherdev
(
sizeof
(
struct
el3_private
));
if
(
!
dev
)
return
-
ENOMEM
;
SET_MODULE_OWNER
(
dev
);
netdev_boot_setup_check
(
dev
);
/* Set passed-in IRQ or I/O Addr. */
if
(
dev
->
irq
>
1
&&
dev
->
irq
<
16
)
irq
=
dev
->
irq
;
if
(
dev
->
base_addr
)
{
if
(
dev
->
mem_end
==
0x3c509
/* Magic key */
&&
dev
->
base_addr
>=
0x200
&&
dev
->
base_addr
<=
0x3e0
)
ioaddr
=
dev
->
base_addr
&
0x3f0
;
else
if
(
dev
->
base_addr
!=
ioaddr
)
{
unregister_netdev
(
dev
);
return
-
ENODEV
;
}
if
(
dev
->
mem_end
==
0x3c509
/* Magic key */
&&
dev
->
base_addr
>=
0x200
&&
dev
->
base_addr
<=
0x3e0
)
ioaddr
=
dev
->
base_addr
&
0x3f0
;
else
if
(
dev
->
base_addr
!=
ioaddr
)
goto
out
;
}
if
(
!
request_region
(
ioaddr
,
EL3_IO_EXTENT
,
"3c509"
))
{
unregister_netdev
(
dev
)
;
return
-
EBUSY
;
err
=
-
EBUSY
;
goto
out
;
}
/* Set the adaptor tag so that the next card can be found. */
...
...
@@ -549,11 +546,8 @@ static int __init el3_probe(int card_idx)
#endif
EL3WINDOW
(
0
);
if
(
inw
(
ioaddr
)
!=
0x6d50
)
{
unregister_netdev
(
dev
);
release_region
(
ioaddr
,
EL3_IO_EXTENT
);
return
-
ENODEV
;
}
if
(
inw
(
ioaddr
)
!=
0x6d50
)
goto
out1
;
/* Free the interrupt so that some other card can use it. */
outw
(
0x0f00
,
ioaddr
+
WN0_IRQ
);
...
...
@@ -570,6 +564,11 @@ static int __init el3_probe(int card_idx)
#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
lp
->
dev
=
&
idev
->
dev
;
#endif
el3_common_init
(
dev
);
err
=
register_netdev
(
dev
);
if
(
err
)
goto
out1
;
#ifdef CONFIG_PM
/* register power management */
...
...
@@ -581,7 +580,22 @@ static int __init el3_probe(int card_idx)
}
#endif
return
el3_common_init
(
dev
);
el3_cards
++
;
#if !defined(__ISAPNP__) || defined(CONFIG_X86_PC9800)
lp
->
next_dev
=
el3_root_dev
;
el3_root_dev
=
dev
;
#endif
return
0
;
out1:
release_region
(
ioaddr
,
EL3_IO_EXTENT
);
#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
if
(
idev
)
pnp_device_detach
(
idev
);
#endif
out:
kfree
(
dev
);
return
err
;
}
#ifdef CONFIG_MCA
...
...
@@ -602,6 +616,7 @@ static int __init el3_mca_probe(struct device *device) {
u_char
pos4
,
pos5
;
struct
mca_device
*
mdev
=
to_mca_device
(
device
);
int
slot
=
mdev
->
slot
;
int
err
;
pos4
=
mca_device_read_stored_pos
(
mdev
,
4
);
pos5
=
mca_device_read_stored_pos
(
mdev
,
5
);
...
...
@@ -630,13 +645,14 @@ static int __init el3_mca_probe(struct device *device) {
phys_addr
[
i
]
=
htons
(
read_eeprom
(
ioaddr
,
i
));
}
dev
=
init_etherdev
(
NULL
,
sizeof
(
struct
el3_private
));
dev
=
alloc_etherdev
(
sizeof
(
struct
el3_private
));
if
(
dev
==
NULL
)
{
release_region
(
ioaddr
,
EL3_IO_EXTENT
);
return
-
ENOMEM
;
}
SET_MODULE_OWNER
(
dev
);
netdev_boot_setup_check
(
dev
);
memcpy
(
dev
->
dev_addr
,
phys_addr
,
sizeof
(
phys_addr
));
dev
->
base_addr
=
ioaddr
;
...
...
@@ -646,8 +662,16 @@ static int __init el3_mca_probe(struct device *device) {
lp
->
dev
=
device
;
lp
->
type
=
EL3_MCA
;
device
->
driver_data
=
dev
;
el3_common_init
(
dev
);
err
=
register_netdev
(
dev
);
if
(
err
)
{
release_region
(
ioaddr
,
EL3_IO_EXTENT
);
return
-
ENOMEM
;
}
return
el3_common_init
(
dev
);
el3_cards
++
;
return
0
;
}
#endif
/* CONFIG_MCA */
...
...
@@ -661,6 +685,7 @@ static int __init el3_eisa_probe (struct device *device)
u16
phys_addr
[
3
];
struct
net_device
*
dev
=
NULL
;
struct
eisa_device
*
edev
;
int
err
;
/* Yeepee, The driver framework is calling us ! */
edev
=
to_eisa_device
(
device
);
...
...
@@ -680,7 +705,7 @@ static int __init el3_eisa_probe (struct device *device)
/* Restore the "Product ID" to the EEPROM read register. */
read_eeprom
(
ioaddr
,
3
);
dev
=
init_etherdev
(
NULL
,
sizeof
(
struct
el3_private
));
dev
=
alloc_etherdev
(
sizeof
(
struct
el3_private
));
if
(
dev
==
NULL
)
{
release_region
(
ioaddr
,
EL3_IO_EXTENT
);
return
-
ENOMEM
;
...
...
@@ -688,6 +713,8 @@ static int __init el3_eisa_probe (struct device *device)
SET_MODULE_OWNER
(
dev
);
netdev_boot_setup_check
(
dev
);
memcpy
(
dev
->
dev_addr
,
phys_addr
,
sizeof
(
phys_addr
));
dev
->
base_addr
=
ioaddr
;
dev
->
irq
=
irq
;
...
...
@@ -696,8 +723,16 @@ static int __init el3_eisa_probe (struct device *device)
lp
->
dev
=
device
;
lp
->
type
=
EL3_EISA
;
eisa_set_drvdata
(
edev
,
dev
);
el3_common_init
(
dev
);
err
=
register_netdev
(
dev
);
if
(
err
)
{
release_region
(
ioaddr
,
EL3_IO_EXTENT
);
return
err
;
}
return
el3_common_init
(
dev
);
el3_cards
++
;
return
0
;
}
#endif
...
...
drivers/net/hamradio/dmascc.c
View file @
cbec8fba
...
...
@@ -250,8 +250,6 @@ struct scc_info {
/* Function declarations */
int
dmascc_init
(
void
)
__init
;
static
int
setup_adapter
(
int
card_base
,
int
type
,
int
n
)
__init
;
static
void
write_scc
(
struct
scc_priv
*
priv
,
int
reg
,
int
val
);
...
...
@@ -299,23 +297,12 @@ static struct scc_info *first;
static
unsigned
long
rand
;
/* Module functions */
#ifdef MODULE
MODULE_AUTHOR
(
"Klaus Kudielka"
);
MODULE_DESCRIPTION
(
"Driver for high-speed SCC boards"
);
MODULE_PARM
(
io
,
"1-"
__MODULE_STRING
(
MAX_NUM_DEVS
)
"i"
);
MODULE_LICENSE
(
"GPL"
);
int
init_module
(
void
)
{
return
dmascc_init
();
}
void
cleanup_module
(
void
)
{
static
void
__exit
dmascc_exit
(
void
)
{
int
i
;
struct
scc_info
*
info
;
...
...
@@ -341,24 +328,16 @@ void cleanup_module(void) {
}
}
#else
#ifndef MODULE
void
__init
dmascc_setup
(
char
*
str
,
int
*
ints
)
{
int
i
;
for
(
i
=
0
;
i
<
MAX_NUM_DEVS
&&
i
<
ints
[
0
];
i
++
)
io
[
i
]
=
ints
[
i
+
1
];
}
#endif
/* Initialization functions */
int
__init
dmascc_init
(
void
)
{
static
int
__init
dmascc_init
(
void
)
{
int
h
,
i
,
j
,
n
;
int
base
[
MAX_NUM_DEVS
],
tcmd
[
MAX_NUM_DEVS
],
t0
[
MAX_NUM_DEVS
],
t1
[
MAX_NUM_DEVS
];
...
...
@@ -461,6 +440,9 @@ int __init dmascc_init(void) {
return
-
EIO
;
}
module_init
(
dmascc_init
);
module_exit
(
dmascc_exit
);
int
__init
setup_adapter
(
int
card_base
,
int
type
,
int
n
)
{
int
i
,
irq
,
chip
;
...
...
@@ -580,6 +562,7 @@ int __init setup_adapter(int card_base, int type, int n) {
if
(
sizeof
(
dev
->
name
)
==
sizeof
(
char
*
))
dev
->
name
=
priv
->
name
;
#endif
sprintf
(
dev
->
name
,
"dmascc%i"
,
2
*
n
+
i
);
SET_MODULE_OWNER
(
dev
);
dev
->
base_addr
=
card_base
;
dev
->
irq
=
irq
;
dev
->
open
=
scc_open
;
...
...
@@ -707,12 +690,9 @@ static int scc_open(struct net_device *dev) {
struct
scc_info
*
info
=
priv
->
info
;
int
card_base
=
priv
->
card_base
;
MOD_INC_USE_COUNT
;
/* Request IRQ if not already used by other channel */
if
(
!
info
->
irq_used
)
{
if
(
request_irq
(
dev
->
irq
,
scc_isr
,
0
,
"dmascc"
,
info
))
{
MOD_DEC_USE_COUNT
;
return
-
EAGAIN
;
}
}
...
...
@@ -722,7 +702,6 @@ static int scc_open(struct net_device *dev) {
if
(
priv
->
param
.
dma
>=
0
)
{
if
(
request_dma
(
priv
->
param
.
dma
,
"dmascc"
))
{
if
(
--
info
->
irq_used
==
0
)
free_irq
(
dev
->
irq
,
info
);
MOD_DEC_USE_COUNT
;
return
-
EAGAIN
;
}
else
{
unsigned
long
flags
=
claim_dma_lock
();
...
...
@@ -866,7 +845,6 @@ static int scc_close(struct net_device *dev) {
}
if
(
--
info
->
irq_used
==
0
)
free_irq
(
dev
->
irq
,
info
);
MOD_DEC_USE_COUNT
;
return
0
;
}
...
...
drivers/net/setup.c
View file @
cbec8fba
...
...
@@ -9,8 +9,6 @@
#include <linux/init.h>
#include <linux/netlink.h>
extern
int
dmascc_init
(
void
);
extern
int
scc_enet_init
(
void
);
extern
int
fec_enet_init
(
void
);
...
...
@@ -29,10 +27,6 @@ static struct net_probe pci_probes[] __initdata = {
/*
* Early setup devices
*/
#if defined(CONFIG_DMASCC)
{
dmascc_init
,
0
},
#endif
#if defined(CONFIG_SCC_ENET)
{
scc_enet_init
,
0
},
#endif
...
...
drivers/net/sk98lin/h/skdrv2nd.h
View file @
cbec8fba
...
...
@@ -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 @
cbec8fba
...
...
@@ -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 @
cbec8fba
...
...
@@ -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
,
};
drivers/net/wan/sdla.c
View file @
cbec8fba
...
...
@@ -1682,11 +1682,13 @@ static int __init init_sdla(void)
static
void
__exit
exit_sdla
(
void
)
{
#ifdef MODULE
unregister_netdev
(
&
sdla0
);
if
(
sdla0
.
priv
)
kfree
(
sdla0
.
priv
);
if
(
sdla0
.
irq
)
free_irq
(
sdla0
.
irq
,
&
sdla0
);
#endif
}
MODULE_LICENSE
(
"GPL"
);
...
...
include/linux/rtnetlink.h
View file @
cbec8fba
...
...
@@ -50,7 +50,7 @@
#define RTM_MAX (RTM_BASE+31)
/*
Generic structure for encapsulation optional route information.
Generic structure for encapsulation o
f o
ptional route information.
It is reminiscent of sockaddr, but with sa_family replaced
with attribute type.
*/
...
...
include/net/ip6_fib.h
View file @
cbec8fba
...
...
@@ -111,9 +111,10 @@ static inline void fib6_walker_unlink(struct fib6_walker_t *w)
struct
rt6_statistics
{
__u32
fib_nodes
;
__u32
fib_route_nodes
;
__u32
fib_rt_alloc
;
/* permanet routes */
__u32
fib_rt_alloc
;
/* permane
n
t routes */
__u32
fib_rt_entries
;
/* rt entries in table */
__u32
fib_rt_cache
;
/* cache routes */
__u32
fib_discarded_routes
;
};
#define RTN_TL_ROOT 0x0001
...
...
include/net/snmp.h
View file @
cbec8fba
...
...
@@ -42,6 +42,11 @@
*/
/*
* RFC 1213: MIB-II
* RFC 2011 (updates 1213): SNMPv2-MIB-IP
* RFC 2863: Interfaces Group MIB
*/
struct
ip_mib
{
unsigned
long
IpInReceives
;
...
...
@@ -64,6 +69,9 @@ struct ip_mib
unsigned
long
__pad
[
0
];
};
/*
* RFC 2465: IPv6 MIB: General Group
*/
struct
ipv6_mib
{
unsigned
long
Ip6InReceives
;
...
...
@@ -91,6 +99,10 @@ struct ipv6_mib
unsigned
long
__pad
[
0
];
};
/*
* RFC 1213: MIB-II ICMP Group
* RFC 2011 (updates 1213): SNMPv2 MIB for IP: ICMP group
*/
struct
icmp_mib
{
unsigned
long
IcmpInMsgs
;
...
...
@@ -123,6 +135,9 @@ struct icmp_mib
unsigned
long
__pad
[
0
];
};
/*
* RFC 2466: ICMPv6-MIB
*/
struct
icmpv6_mib
{
unsigned
long
Icmp6InMsgs
;
...
...
@@ -161,6 +176,10 @@ struct icmpv6_mib
unsigned
long
__pad
[
0
];
};
/*
* RFC 1213: MIB-II TCP group
* RFC 2012 (updates 1213): SNMPv2-MIB-TCP
*/
struct
tcp_mib
{
unsigned
long
TcpRtoAlgorithm
;
...
...
@@ -180,6 +199,10 @@ struct tcp_mib
unsigned
long
__pad
[
0
];
};
/*
* RFC 1213: MIB-II UDP group
* RFC 2013 (updates 1213): SNMPv2-MIB-UDP
*/
struct
udp_mib
{
unsigned
long
UdpInDatagrams
;
...
...
net/core/dst.c
View file @
cbec8fba
/*
* net/dst.c Protocol independent destination cache.
* net/
core/
dst.c Protocol independent destination cache.
*
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
* Authors:
Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
*
*/
...
...
net/core/dv.c
View file @
cbec8fba
...
...
@@ -5,8 +5,6 @@
*
* Generic frame diversion
*
* Version: @(#)eth.c 0.41 09/09/2000
*
* Authors:
* Benoit LOCHER: initial integration within the kernel with support for ethernet
* Dave Miller: improvement on the code (correctness, performance and source files)
...
...
net/core/filter.c
View file @
cbec8fba
...
...
@@ -36,14 +36,13 @@
#include <linux/filter.h>
/* No hurry in this branch */
static
u8
*
load_pointer
(
struct
sk_buff
*
skb
,
int
k
)
{
u8
*
ptr
=
NULL
;
if
(
k
>=
SKF_NET_OFF
)
if
(
k
>=
SKF_NET_OFF
)
ptr
=
skb
->
nh
.
raw
+
k
-
SKF_NET_OFF
;
else
if
(
k
>=
SKF_LL_OFF
)
else
if
(
k
>=
SKF_LL_OFF
)
ptr
=
skb
->
mac
.
raw
+
k
-
SKF_LL_OFF
;
if
(
ptr
>=
skb
->
head
&&
ptr
<
skb
->
tail
)
...
...
@@ -80,268 +79,224 @@ int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen)
/*
* Process array of filter instructions.
*/
for
(
pc
=
0
;
pc
<
flen
;
pc
++
)
{
for
(
pc
=
0
;
pc
<
flen
;
pc
++
)
{
fentry
=
&
filter
[
pc
];
switch
(
fentry
->
code
)
{
case
BPF_ALU
|
BPF_ADD
|
BPF_X
:
A
+=
X
;
continue
;
case
BPF_ALU
|
BPF_ADD
|
BPF_K
:
A
+=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_SUB
|
BPF_X
:
A
-=
X
;
continue
;
case
BPF_ALU
|
BPF_SUB
|
BPF_K
:
A
-=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_MUL
|
BPF_X
:
A
*=
X
;
continue
;
case
BPF_ALU
|
BPF_MUL
|
BPF_K
:
A
*=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_DIV
|
BPF_X
:
if
(
X
==
0
)
return
(
0
);
A
/=
X
;
continue
;
case
BPF_ALU
|
BPF_DIV
|
BPF_K
:
if
(
fentry
->
k
==
0
)
return
(
0
);
A
/=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_AND
|
BPF_X
:
A
&=
X
;
continue
;
case
BPF_ALU
|
BPF_AND
|
BPF_K
:
A
&=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_OR
|
BPF_X
:
A
|=
X
;
continue
;
case
BPF_ALU
|
BPF_OR
|
BPF_K
:
A
|=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_LSH
|
BPF_X
:
A
<<=
X
;
continue
;
case
BPF_ALU
|
BPF_LSH
|
BPF_K
:
A
<<=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_RSH
|
BPF_X
:
A
>>=
X
;
continue
;
case
BPF_ALU
|
BPF_RSH
|
BPF_K
:
A
>>=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_NEG
:
A
=
-
A
;
continue
;
case
BPF_JMP
|
BPF_JA
:
pc
+=
fentry
->
k
;
continue
;
case
BPF_JMP
|
BPF_JGT
|
BPF_K
:
pc
+=
(
A
>
fentry
->
k
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JGE
|
BPF_K
:
pc
+=
(
A
>=
fentry
->
k
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JEQ
|
BPF_K
:
pc
+=
(
A
==
fentry
->
k
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JSET
|
BPF_K
:
pc
+=
(
A
&
fentry
->
k
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JGT
|
BPF_X
:
pc
+=
(
A
>
X
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JGE
|
BPF_X
:
pc
+=
(
A
>=
X
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JEQ
|
BPF_X
:
pc
+=
(
A
==
X
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JSET
|
BPF_X
:
pc
+=
(
A
&
X
)
?
fentry
->
jt
:
fentry
->
jf
;
switch
(
fentry
->
code
)
{
case
BPF_ALU
|
BPF_ADD
|
BPF_X
:
A
+=
X
;
continue
;
case
BPF_ALU
|
BPF_ADD
|
BPF_K
:
A
+=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_SUB
|
BPF_X
:
A
-=
X
;
continue
;
case
BPF_ALU
|
BPF_SUB
|
BPF_K
:
A
-=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_MUL
|
BPF_X
:
A
*=
X
;
continue
;
case
BPF_ALU
|
BPF_MUL
|
BPF_K
:
A
*=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_DIV
|
BPF_X
:
if
(
X
==
0
)
return
0
;
A
/=
X
;
continue
;
case
BPF_ALU
|
BPF_DIV
|
BPF_K
:
if
(
fentry
->
k
==
0
)
return
0
;
A
/=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_AND
|
BPF_X
:
A
&=
X
;
continue
;
case
BPF_ALU
|
BPF_AND
|
BPF_K
:
A
&=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_OR
|
BPF_X
:
A
|=
X
;
continue
;
case
BPF_ALU
|
BPF_OR
|
BPF_K
:
A
|=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_LSH
|
BPF_X
:
A
<<=
X
;
continue
;
case
BPF_ALU
|
BPF_LSH
|
BPF_K
:
A
<<=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_RSH
|
BPF_X
:
A
>>=
X
;
continue
;
case
BPF_ALU
|
BPF_RSH
|
BPF_K
:
A
>>=
fentry
->
k
;
continue
;
case
BPF_ALU
|
BPF_NEG
:
A
=
-
A
;
continue
;
case
BPF_JMP
|
BPF_JA
:
pc
+=
fentry
->
k
;
continue
;
case
BPF_JMP
|
BPF_JGT
|
BPF_K
:
pc
+=
(
A
>
fentry
->
k
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JGE
|
BPF_K
:
pc
+=
(
A
>=
fentry
->
k
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JEQ
|
BPF_K
:
pc
+=
(
A
==
fentry
->
k
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JSET
|
BPF_K
:
pc
+=
(
A
&
fentry
->
k
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JGT
|
BPF_X
:
pc
+=
(
A
>
X
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JGE
|
BPF_X
:
pc
+=
(
A
>=
X
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JEQ
|
BPF_X
:
pc
+=
(
A
==
X
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_JMP
|
BPF_JSET
|
BPF_X
:
pc
+=
(
A
&
X
)
?
fentry
->
jt
:
fentry
->
jf
;
continue
;
case
BPF_LD
|
BPF_W
|
BPF_ABS
:
k
=
fentry
->
k
;
load_w:
if
(
k
>=
0
&&
(
unsigned
int
)(
k
+
sizeof
(
u32
))
<=
len
)
{
A
=
ntohl
(
*
(
u32
*
)
&
data
[
k
]);
continue
;
case
BPF_LD
|
BPF_W
|
BPF_ABS
:
k
=
fentry
->
k
;
load_w:
if
(
k
>=
0
&&
(
unsigned
int
)(
k
+
sizeof
(
u32
))
<=
len
)
{
A
=
ntohl
(
*
(
u32
*
)
&
data
[
k
]);
}
if
(
k
<
0
)
{
u8
*
ptr
;
if
(
k
>=
SKF_AD_OFF
)
break
;
ptr
=
load_pointer
(
skb
,
k
);
if
(
ptr
)
{
A
=
ntohl
(
*
(
u32
*
)
ptr
);
continue
;
}
if
(
k
<
0
)
{
u8
*
ptr
;
if
(
k
>=
SKF_AD_OFF
)
break
;
if
((
ptr
=
load_pointer
(
skb
,
k
))
!=
NULL
)
{
A
=
ntohl
(
*
(
u32
*
)
ptr
);
continue
;
}
}
else
{
u32
tmp
;
if
(
!
skb_copy_bits
(
skb
,
k
,
&
tmp
,
4
))
{
A
=
ntohl
(
tmp
);
continue
;
}
}
else
{
u32
tmp
;
if
(
!
skb_copy_bits
(
skb
,
k
,
&
tmp
,
4
))
{
A
=
ntohl
(
tmp
);
continue
;
}
return
0
;
case
BPF_LD
|
BPF_H
|
BPF_ABS
:
k
=
fentry
->
k
;
load_h:
if
(
k
>=
0
&&
(
unsigned
int
)
(
k
+
sizeof
(
u16
))
<=
len
)
{
A
=
ntohs
(
*
(
u16
*
)
&
data
[
k
]);
}
return
0
;
case
BPF_LD
|
BPF_H
|
BPF_ABS
:
k
=
fentry
->
k
;
load_h:
if
(
k
>=
0
&&
(
unsigned
int
)(
k
+
sizeof
(
u16
))
<=
len
)
{
A
=
ntohs
(
*
(
u16
*
)
&
data
[
k
]);
continue
;
}
if
(
k
<
0
)
{
u8
*
ptr
;
if
(
k
>=
SKF_AD_OFF
)
break
;
ptr
=
load_pointer
(
skb
,
k
);
if
(
ptr
)
{
A
=
ntohs
(
*
(
u16
*
)
ptr
);
continue
;
}
if
(
k
<
0
)
{
u8
*
ptr
;
if
(
k
>=
SKF_AD_OFF
)
break
;
if
((
ptr
=
load_pointer
(
skb
,
k
))
!=
NULL
)
{
A
=
ntohs
(
*
(
u16
*
)
ptr
);
continue
;
}
}
else
{
u16
tmp
;
if
(
!
skb_copy_bits
(
skb
,
k
,
&
tmp
,
2
))
{
A
=
ntohs
(
tmp
);
continue
;
}
}
else
{
u16
tmp
;
if
(
!
skb_copy_bits
(
skb
,
k
,
&
tmp
,
2
))
{
A
=
ntohs
(
tmp
);
continue
;
}
return
0
;
case
BPF_LD
|
BPF_B
|
BPF_ABS
:
k
=
fentry
->
k
;
}
return
0
;
case
BPF_LD
|
BPF_B
|
BPF_ABS
:
k
=
fentry
->
k
;
load_b:
if
(
k
>=
0
&&
(
unsigned
int
)
k
<
len
)
{
A
=
data
[
k
];
if
(
k
>=
0
&&
(
unsigned
int
)
k
<
len
)
{
A
=
data
[
k
];
continue
;
}
if
(
k
<
0
)
{
u8
*
ptr
;
if
(
k
>=
SKF_AD_OFF
)
break
;
ptr
=
load_pointer
(
skb
,
k
);
if
(
ptr
)
{
A
=
*
ptr
;
continue
;
}
if
(
k
<
0
)
{
u8
*
ptr
;
if
(
k
>=
SKF_AD_OFF
)
break
;
if
((
ptr
=
load_pointer
(
skb
,
k
))
!=
NULL
)
{
A
=
*
ptr
;
continue
;
}
}
else
{
u8
tmp
;
if
(
!
skb_copy_bits
(
skb
,
k
,
&
tmp
,
1
))
{
A
=
tmp
;
continue
;
}
}
else
{
u8
tmp
;
if
(
!
skb_copy_bits
(
skb
,
k
,
&
tmp
,
1
))
{
A
=
tmp
;
continue
;
}
}
return
0
;
case
BPF_LD
|
BPF_W
|
BPF_LEN
:
A
=
len
;
continue
;
case
BPF_LDX
|
BPF_W
|
BPF_LEN
:
X
=
len
;
continue
;
case
BPF_LD
|
BPF_W
|
BPF_IND
:
k
=
X
+
fentry
->
k
;
goto
load_w
;
case
BPF_LD
|
BPF_H
|
BPF_IND
:
k
=
X
+
fentry
->
k
;
goto
load_h
;
case
BPF_LD
|
BPF_B
|
BPF_IND
:
k
=
X
+
fentry
->
k
;
goto
load_b
;
case
BPF_LDX
|
BPF_B
|
BPF_MSH
:
k
=
fentry
->
k
;
if
(
k
>=
0
&&
(
unsigned
int
)
k
>=
len
)
return
0
;
case
BPF_LD
|
BPF_W
|
BPF_LEN
:
A
=
len
;
continue
;
case
BPF_LDX
|
BPF_W
|
BPF_LEN
:
X
=
len
;
continue
;
case
BPF_LD
|
BPF_W
|
BPF_IND
:
k
=
X
+
fentry
->
k
;
goto
load_w
;
case
BPF_LD
|
BPF_H
|
BPF_IND
:
k
=
X
+
fentry
->
k
;
goto
load_h
;
case
BPF_LD
|
BPF_B
|
BPF_IND
:
k
=
X
+
fentry
->
k
;
goto
load_b
;
case
BPF_LDX
|
BPF_B
|
BPF_MSH
:
k
=
fentry
->
k
;
if
(
k
>=
0
&&
(
unsigned
int
)
k
>=
len
)
return
(
0
);
X
=
(
data
[
k
]
&
0xf
)
<<
2
;
continue
;
case
BPF_LD
|
BPF_IMM
:
A
=
fentry
->
k
;
continue
;
case
BPF_LDX
|
BPF_IMM
:
X
=
fentry
->
k
;
continue
;
case
BPF_LD
|
BPF_MEM
:
A
=
mem
[
fentry
->
k
];
continue
;
case
BPF_LDX
|
BPF_MEM
:
X
=
mem
[
fentry
->
k
];
continue
;
case
BPF_MISC
|
BPF_TAX
:
X
=
A
;
continue
;
case
BPF_MISC
|
BPF_TXA
:
A
=
X
;
continue
;
case
BPF_RET
|
BPF_K
:
return
((
unsigned
int
)
fentry
->
k
);
case
BPF_RET
|
BPF_A
:
return
((
unsigned
int
)
A
);
case
BPF_ST
:
mem
[
fentry
->
k
]
=
A
;
continue
;
case
BPF_STX
:
mem
[
fentry
->
k
]
=
X
;
continue
;
default:
/* Invalid instruction counts as RET */
return
(
0
);
X
=
(
data
[
k
]
&
0xf
)
<<
2
;
continue
;
case
BPF_LD
|
BPF_IMM
:
A
=
fentry
->
k
;
continue
;
case
BPF_LDX
|
BPF_IMM
:
X
=
fentry
->
k
;
continue
;
case
BPF_LD
|
BPF_MEM
:
A
=
mem
[
fentry
->
k
];
continue
;
case
BPF_LDX
|
BPF_MEM
:
X
=
mem
[
fentry
->
k
];
continue
;
case
BPF_MISC
|
BPF_TAX
:
X
=
A
;
continue
;
case
BPF_MISC
|
BPF_TXA
:
A
=
X
;
continue
;
case
BPF_RET
|
BPF_K
:
return
((
unsigned
int
)
fentry
->
k
);
case
BPF_RET
|
BPF_A
:
return
((
unsigned
int
)
A
);
case
BPF_ST
:
mem
[
fentry
->
k
]
=
A
;
continue
;
case
BPF_STX
:
mem
[
fentry
->
k
]
=
X
;
continue
;
default:
/* Invalid instruction counts as RET */
return
0
;
}
/* Handle ancillary data, which are impossible
(or very difficult) to get parsing packet contents.
/*
* Handle ancillary data, which are impossible
* (or very difficult) to get parsing packet contents.
*/
switch
(
k
-
SKF_AD_OFF
)
{
case
SKF_AD_PROTOCOL
:
...
...
@@ -358,7 +313,7 @@ int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen)
}
}
return
(
0
)
;
return
0
;
}
/**
...
...
@@ -373,75 +328,55 @@ int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen)
*
* Returns 0 if the rule set is legal or a negative errno code if not.
*/
int
sk_chk_filter
(
struct
sock_filter
*
filter
,
int
flen
)
{
struct
sock_filter
*
ftest
;
int
pc
;
int
pc
;
if
((
unsigned
int
)
flen
>=
(
~
0U
/
sizeof
(
struct
sock_filter
)))
if
((
unsigned
int
)
flen
>=
(
~
0U
/
sizeof
(
struct
sock_filter
)))
return
-
EINVAL
;
/*
* Check the filter code now.
*/
for
(
pc
=
0
;
pc
<
flen
;
pc
++
)
{
/*
* All jumps are forward as they are not signed
*/
ftest
=
&
filter
[
pc
];
if
(
BPF_CLASS
(
ftest
->
code
)
==
BPF_JMP
)
{
/*
* But they mustn't jump off the end.
*/
if
(
BPF_OP
(
ftest
->
code
)
==
BPF_JA
)
{
/* Note, the large ftest->k might cause
loops. Compare this with conditional
jumps below, where offsets are limited. --ANK (981016)
/* check the filter code now */
for
(
pc
=
0
;
pc
<
flen
;
pc
++
)
{
/* all jumps are forward as they are not signed */
ftest
=
&
filter
[
pc
];
if
(
BPF_CLASS
(
ftest
->
code
)
==
BPF_JMP
)
{
/* but they mustn't jump off the end */
if
(
BPF_OP
(
ftest
->
code
)
==
BPF_JA
)
{
/*
* Note, the large ftest->k might cause loops.
* Compare this with conditional jumps below,
* where offsets are limited. --ANK (981016)
*/
if
(
ftest
->
k
>=
(
unsigned
)(
flen
-
pc
-
1
))
return
-
EINVAL
;
}
else
{
/*
* For conditionals both must be safe
*/
if
(
pc
+
ftest
->
jt
+
1
>=
flen
||
pc
+
ftest
->
jf
+
1
>=
flen
)
}
else
{
/* for conditionals both must be safe */
if
(
pc
+
ftest
->
jt
+
1
>=
flen
||
pc
+
ftest
->
jf
+
1
>=
flen
)
return
-
EINVAL
;
}
}
}
/*
* Check that memory operations use valid addresses.
*/
if
(
ftest
->
k
>=
BPF_MEMWORDS
)
{
/*
* But it might not be a memory operation...
*/
/* check that memory operations use valid addresses. */
if
(
ftest
->
k
>=
BPF_MEMWORDS
)
{
/* but it might not be a memory operation... */
switch
(
ftest
->
code
)
{
case
BPF_ST
:
case
BPF_STX
:
case
BPF_LD
|
BPF_MEM
:
case
BPF_LDX
|
BPF_MEM
:
return
-
EINVAL
;
return
-
EINVAL
;
}
}
}
}
/*
*
The program must end with a return. We don't care where they
*
jumped within the script (its always forwards) but in the
*
end
they _will_ hit this.
*
The program must end with a return. We don't care where they
*
jumped within the script (its always forwards) but in the end
* they _will_ hit this.
*/
return
(
BPF_CLASS
(
filter
[
flen
-
1
].
code
)
==
BPF_RET
)
?
0
:-
EINVAL
;
return
(
BPF_CLASS
(
filter
[
flen
-
1
].
code
)
==
BPF_RET
)
?
0
:
-
EINVAL
;
}
/**
...
...
@@ -454,7 +389,6 @@ int sk_chk_filter(struct sock_filter *filter, int flen)
* occurs or there is insufficient memory for the filter a negative
* errno code is returned. On success the return is zero.
*/
int
sk_attach_filter
(
struct
sock_fprog
*
fprog
,
struct
sock
*
sk
)
{
struct
sk_filter
*
fp
;
...
...
@@ -463,12 +397,11 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
/* Make sure new filter is there and in the right amounts. */
if
(
fprog
->
filter
==
NULL
||
fprog
->
len
>
BPF_MAXINSNS
)
return
(
-
EINVAL
);
fp
=
(
struct
sk_filter
*
)
sock_kmalloc
(
sk
,
fsize
+
sizeof
(
*
fp
),
GFP_KERNEL
);
if
(
fp
==
NULL
)
return
(
-
ENOMEM
);
return
-
EINVAL
;
fp
=
sock_kmalloc
(
sk
,
fsize
+
sizeof
(
*
fp
),
GFP_KERNEL
);
if
(
!
fp
)
return
-
ENOMEM
;
if
(
copy_from_user
(
fp
->
insns
,
fprog
->
filter
,
fsize
))
{
sock_kfree_s
(
sk
,
fp
,
fsize
+
sizeof
(
*
fp
));
return
-
EFAULT
;
...
...
@@ -477,7 +410,8 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
atomic_set
(
&
fp
->
refcnt
,
1
);
fp
->
len
=
fprog
->
len
;
if
((
err
=
sk_chk_filter
(
fp
->
insns
,
fp
->
len
))
==
0
)
{
err
=
sk_chk_filter
(
fp
->
insns
,
fp
->
len
);
if
(
!
err
)
{
struct
sk_filter
*
old_fp
;
spin_lock_bh
(
&
sk
->
lock
.
slock
);
...
...
@@ -489,6 +423,5 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
if
(
fp
)
sk_filter_release
(
sk
,
fp
);
return
(
err
);
return
err
;
}
net/core/iovec.c
View file @
cbec8fba
...
...
@@ -41,35 +41,35 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode)
{
int
size
,
err
,
ct
;
if
(
m
->
msg_namelen
)
{
if
(
mode
==
VERIFY_READ
)
{
err
=
move_addr_to_kernel
(
m
->
msg_name
,
m
->
msg_namelen
,
address
);
if
(
err
<
0
)
goto
out
;
}
m
->
msg_name
=
address
;
}
else
m
->
msg_name
=
NULL
;
if
(
m
->
msg_namelen
)
{
if
(
mode
==
VERIFY_READ
)
{
err
=
move_addr_to_kernel
(
m
->
msg_name
,
m
->
msg_namelen
,
address
);
if
(
err
<
0
)
return
err
;
m
->
msg_name
=
address
;
}
else
m
->
msg_name
=
NULL
;
}
err
=
-
EFAULT
;
size
=
m
->
msg_iovlen
*
sizeof
(
struct
iovec
);
if
(
copy_from_user
(
iov
,
m
->
msg_iov
,
size
))
goto
out
;
m
->
msg_iov
=
iov
;
return
-
EFAULT
;
for
(
err
=
0
,
ct
=
0
;
ct
<
m
->
msg_iovlen
;
ct
++
)
{
m
->
msg_iov
=
iov
;
err
=
0
;
for
(
ct
=
0
;
ct
<
m
->
msg_iovlen
;
ct
++
)
{
err
+=
iov
[
ct
].
iov_len
;
/* Goal is not to verify user data, but to prevent returning
negative value, which is interpreted as errno.
Overflow is still possible, but it is harmless.
/*
* Goal is not to verify user data, but to prevent returning
* negative value, which is interpreted as errno.
* Overflow is still possible, but it is harmless.
*/
if
(
err
<
0
)
return
-
EMSGSIZE
;
}
out:
return
err
;
}
...
...
@@ -81,25 +81,20 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode)
int
memcpy_toiovec
(
struct
iovec
*
iov
,
unsigned
char
*
kdata
,
int
len
)
{
int
err
=
-
EFAULT
;
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
int
copy
=
min_t
(
unsigned
int
,
iov
->
iov_len
,
len
);
if
(
copy_to_user
(
iov
->
iov_base
,
kdata
,
copy
))
goto
out
;
kdata
+=
copy
;
len
-=
copy
;
iov
->
iov_len
-=
copy
;
iov
->
iov_base
+=
copy
;
return
-
EFAULT
;
kdata
+=
copy
;
len
-=
copy
;
iov
->
iov_len
-=
copy
;
iov
->
iov_base
+=
copy
;
}
iov
++
;
}
err
=
0
;
out:
return
err
;
return
0
;
}
/*
...
...
@@ -110,16 +105,14 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
void
memcpy_tokerneliovec
(
struct
iovec
*
iov
,
unsigned
char
*
kdata
,
int
len
)
{
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
int
copy
=
min_t
(
unsigned
int
,
iov
->
iov_len
,
len
);
memcpy
(
iov
->
iov_base
,
kdata
,
copy
);
kdata
+=
copy
;
len
-=
copy
;
iov
->
iov_len
-=
copy
;
iov
->
iov_base
+=
copy
;
kdata
+=
copy
;
len
-=
copy
;
iov
->
iov_len
-=
copy
;
iov
->
iov_base
+=
copy
;
}
iov
++
;
}
...
...
@@ -134,59 +127,47 @@ void memcpy_tokerneliovec(struct iovec *iov, unsigned char *kdata, int len)
int
memcpy_fromiovec
(
unsigned
char
*
kdata
,
struct
iovec
*
iov
,
int
len
)
{
int
err
=
-
EFAULT
;
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
int
copy
=
min_t
(
unsigned
int
,
len
,
iov
->
iov_len
);
if
(
copy_from_user
(
kdata
,
iov
->
iov_base
,
copy
))
goto
out
;
len
-=
copy
;
kdata
+=
copy
;
iov
->
iov_base
+=
copy
;
iov
->
iov_len
-=
copy
;
return
-
EFAULT
;
len
-=
copy
;
kdata
+=
copy
;
iov
->
iov_base
+=
copy
;
iov
->
iov_len
-=
copy
;
}
iov
++
;
}
err
=
0
;
out:
return
err
;
}
return
0
;
}
/*
* For use with ip_build_xmit
*/
int
memcpy_fromiovecend
(
unsigned
char
*
kdata
,
struct
iovec
*
iov
,
int
offset
,
int
len
)
{
int
err
=
-
EFAULT
;
/* Skip over the finished iovecs */
while
(
offset
>=
iov
->
iov_len
)
{
while
(
offset
>=
iov
->
iov_len
)
{
offset
-=
iov
->
iov_len
;
iov
++
;
}
while
(
len
>
0
)
{
while
(
len
>
0
)
{
u8
*
base
=
iov
->
iov_base
+
offset
;
int
copy
=
min_t
(
unsigned
int
,
len
,
iov
->
iov_len
-
offset
);
offset
=
0
;
if
(
copy_from_user
(
kdata
,
base
,
copy
))
goto
out
;
len
-=
copy
;
return
-
EFAULT
;
len
-=
copy
;
kdata
+=
copy
;
iov
++
;
}
err
=
0
;
out:
return
err
;
return
0
;
}
/*
...
...
@@ -197,7 +178,6 @@ int memcpy_fromiovecend(unsigned char *kdata, struct iovec *iov, int offset,
* ip_build_xmit must ensure that when fragmenting only the last
* call to this function will be unaligned also.
*/
int
csum_partial_copy_fromiovecend
(
unsigned
char
*
kdata
,
struct
iovec
*
iov
,
int
offset
,
unsigned
int
len
,
int
*
csump
)
{
...
...
@@ -205,21 +185,19 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
int
partial_cnt
=
0
,
err
=
0
;
/* Skip over the finished iovecs */
while
(
offset
>=
iov
->
iov_len
)
{
while
(
offset
>=
iov
->
iov_len
)
{
offset
-=
iov
->
iov_len
;
iov
++
;
}
while
(
len
>
0
)
{
while
(
len
>
0
)
{
u8
*
base
=
iov
->
iov_base
+
offset
;
int
copy
=
min_t
(
unsigned
int
,
len
,
iov
->
iov_len
-
offset
);
offset
=
0
;
/* There is a remnant from previous iov. */
if
(
partial_cnt
)
{
if
(
partial_cnt
)
{
int
par_len
=
4
-
partial_cnt
;
/* iov component is too short ... */
...
...
@@ -227,9 +205,9 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
if
(
copy_from_user
(
kdata
,
base
,
copy
))
goto
out_fault
;
kdata
+=
copy
;
base
+=
copy
;
base
+=
copy
;
partial_cnt
+=
copy
;
len
-=
copy
;
len
-=
copy
;
iov
++
;
if
(
len
)
continue
;
...
...
@@ -247,11 +225,9 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
partial_cnt
=
0
;
}
if
(
len
>
copy
)
{
if
(
len
>
copy
)
{
partial_cnt
=
copy
%
4
;
if
(
partial_cnt
)
{
if
(
partial_cnt
)
{
copy
-=
partial_cnt
;
if
(
copy_from_user
(
kdata
+
copy
,
base
+
copy
,
partial_cnt
))
...
...
net/ipv4/Kconfig
View file @
cbec8fba
...
...
@@ -343,6 +343,10 @@ config SYN_COOKIES
config INET_AH
tristate "IP: AH transformation"
select CRYPTO
select CRYPTO_HMAC
select CRYPTO_MD5
select CRYPTO_SHA1
---help---
Support for IPsec AH.
...
...
@@ -350,6 +354,11 @@ config INET_AH
config INET_ESP
tristate "IP: ESP transformation"
select CRYPTO
select CRYPTO_HMAC
select CRYPTO_MD5
select CRYPTO_SHA1
select CRYPTO_DES
---help---
Support for IPsec ESP.
...
...
@@ -357,6 +366,8 @@ config INET_ESP
config INET_IPCOMP
tristate "IP: IPComp transformation"
select CRYPTO
select CRYPTO_DEFLATE
---help---
Support for IP Paylod Compression (RFC3173), typically needed
for IPsec.
...
...
net/ipv4/Makefile
View file @
cbec8fba
...
...
@@ -16,8 +16,8 @@ obj-$(CONFIG_IP_MROUTE) += ipmr.o
obj-$(CONFIG_NET_IPIP)
+=
ipip.o
obj-$(CONFIG_NET_IPGRE)
+=
ip_gre.o
obj-$(CONFIG_SYN_COOKIES)
+=
syncookies.o
obj-$(CONFIG_INET_AH)
+=
ah.o
obj-$(CONFIG_INET_ESP)
+=
esp.o
obj-$(CONFIG_INET_AH)
+=
ah
4
.o
obj-$(CONFIG_INET_ESP)
+=
esp
4
.o
obj-$(CONFIG_INET_IPCOMP)
+=
ipcomp.o
obj-$(CONFIG_IP_PNP)
+=
ipconfig.o
obj-$(CONFIG_NETFILTER)
+=
netfilter/
...
...
net/ipv4/ah.c
→
net/ipv4/ah
4
.c
View file @
cbec8fba
File moved
net/ipv4/esp.c
→
net/ipv4/esp
4
.c
View file @
cbec8fba
File moved
net/ipv6/Kconfig
View file @
cbec8fba
...
...
@@ -4,6 +4,8 @@
config IPV6_PRIVACY
bool "IPv6: Privacy Extensions (RFC 3041) support"
depends on IPV6
select CRYPTO
select CRYPTO_MD5
---help---
Privacy Extensions for Stateless Address Autoconfiguration in IPv6
support. With this option, additional periodically-alter
...
...
@@ -20,6 +22,10 @@ config IPV6_PRIVACY
config INET6_AH
tristate "IPv6: AH transformation"
depends on IPV6
select CRYPTO
select CRYPTO_HMAC
select CRYPTO_MD5
select CRYPTO_SHA1
---help---
Support for IPsec AH.
...
...
@@ -28,6 +34,11 @@ config INET6_AH
config INET6_ESP
tristate "IPv6: ESP transformation"
depends on IPV6
select CRYPTO
select CRYPTO_HMAC
select CRYPTO_MD5
select CRYPTO_SHA1
select CRYPTO_DES
---help---
Support for IPsec ESP.
...
...
@@ -36,6 +47,8 @@ config INET6_ESP
config INET6_IPCOMP
tristate "IPv6: IPComp transformation"
depends on IPV6
select CRYPTO
select CRYPTO_DEFLATE
---help---
Support for IP Paylod Compression (RFC3173), typically needed
for IPsec.
...
...
net/ipv6/addrconf.c
View file @
cbec8fba
...
...
@@ -19,7 +19,7 @@
*
* Janos Farkas : delete timer on ifdown
* <chexum@bankinf.banki.hu>
* Andi Kleen : kill doube kfree on module
* Andi Kleen : kill doub
l
e kfree on module
* unload.
* Maciej W. Rozycki : FDDI support
* sekiya@USAGI : Don't send too many RS
...
...
@@ -343,6 +343,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
"%s(): cannot create /proc/net/dev_snmp6/%s
\n
"
,
__FUNCTION__
,
dev
->
name
));
neigh_parms_release
(
&
nd_tbl
,
ndev
->
nd_parms
);
ndev
->
dead
=
1
;
in6_dev_finish_destroy
(
ndev
);
return
NULL
;
}
...
...
@@ -1256,7 +1257,7 @@ static void sit_route_add(struct net_device *dev)
rtmsg
.
rtmsg_type
=
RTMSG_NEWROUTE
;
rtmsg
.
rtmsg_metric
=
IP6_RT_PRIO_ADDRCONF
;
/* prefix length - 96 b
yte
s "::d.d.d.d" */
/* prefix length - 96 b
it
s "::d.d.d.d" */
rtmsg
.
rtmsg_dst_len
=
96
;
rtmsg
.
rtmsg_flags
=
RTF_UP
|
RTF_NONEXTHOP
;
rtmsg
.
rtmsg_ifindex
=
dev
->
ifindex
;
...
...
net/ipv6/af_inet6.c
View file @
cbec8fba
...
...
@@ -310,7 +310,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
}
else
{
if
(
addr_type
!=
IPV6_ADDR_ANY
)
{
/* ipv4 addr of the socket is invalid. Only the
* unpecified and mapped address have a v4 equivalent.
* un
s
pecified and mapped address have a v4 equivalent.
*/
v4addr
=
LOOPBACK4_IPV6
;
if
(
!
(
addr_type
&
IPV6_ADDR_MULTICAST
))
{
...
...
net/ipv6/ip6_fib.c
View file @
cbec8fba
...
...
@@ -40,7 +40,6 @@
#include <net/ip6_route.h>
#define RT6_DEBUG 2
#undef CONFIG_IPV6_SUBTREES
#if RT6_DEBUG >= 3
#define RT6_TRACE(x...) printk(KERN_DEBUG x)
...
...
@@ -594,8 +593,8 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nlmsghdr *nlh,
is orphan. If it is, shoot it.
*/
st_failure:
if
(
fn
&&
!
(
fn
->
fn_flags
&
RTN_RTINFO
|
RTN_ROOT
))
fib_repair_tree
(
fn
);
if
(
fn
&&
!
(
fn
->
fn_flags
&
(
RTN_RTINFO
|
RTN_ROOT
)
))
fib
6
_repair_tree
(
fn
);
dst_free
(
&
rt
->
u
.
dst
);
return
err
;
#endif
...
...
@@ -896,6 +895,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
*
rtp
=
rt
->
u
.
next
;
rt
->
rt6i_node
=
NULL
;
rt6_stats
.
fib_rt_entries
--
;
rt6_stats
.
fib_discarded_routes
++
;
/* Adjust walkers */
read_lock
(
&
fib6_walker_lock
);
...
...
net/ipv6/route.c
View file @
cbec8fba
...
...
@@ -336,7 +336,7 @@ static int rt6_ins(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr)
return
err
;
}
/* No rt6_lock! If COW faild, the function returns dead route entry
/* No rt6_lock! If COW fail
e
d, the function returns dead route entry
with dst->error set to errno value.
*/
...
...
@@ -1786,11 +1786,12 @@ extern struct rt6_statistics rt6_stats;
static
int
rt6_stats_seq_show
(
struct
seq_file
*
seq
,
void
*
v
)
{
seq_printf
(
seq
,
"%04x %04x %04x %04x %04x %04x
\n
"
,
seq_printf
(
seq
,
"%04x %04x %04x %04x %04x %04x
%04x
\n
"
,
rt6_stats
.
fib_nodes
,
rt6_stats
.
fib_route_nodes
,
rt6_stats
.
fib_rt_alloc
,
rt6_stats
.
fib_rt_entries
,
rt6_stats
.
fib_rt_cache
,
atomic_read
(
&
ip6_dst_ops
.
entries
));
atomic_read
(
&
ip6_dst_ops
.
entries
),
rt6_stats
.
fib_discarded_routes
);
return
0
;
}
...
...
net/ipv6/udp.c
View file @
cbec8fba
...
...
@@ -254,7 +254,6 @@ int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
struct
inet_opt
*
inet
=
inet_sk
(
sk
);
struct
ipv6_pinfo
*
np
=
inet6_sk
(
sk
);
struct
in6_addr
*
daddr
;
struct
in6_addr
saddr
;
struct
dst_entry
*
dst
;
struct
flowi
fl
;
struct
ip6_flowlabel
*
flowlabel
=
NULL
;
...
...
@@ -355,7 +354,7 @@ int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
fl
.
proto
=
IPPROTO_UDP
;
ipv6_addr_copy
(
&
fl
.
fl6_dst
,
&
np
->
daddr
);
ipv6_addr_copy
(
&
fl
.
fl6_src
,
&
saddr
);
ipv6_addr_copy
(
&
fl
.
fl6_src
,
&
np
->
saddr
);
fl
.
oif
=
sk
->
bound_dev_if
;
fl
.
fl_ip_dport
=
inet
->
dport
;
fl
.
fl_ip_sport
=
inet
->
sport
;
...
...
@@ -381,20 +380,23 @@ int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
return
err
;
}
ip6_dst_store
(
sk
,
dst
,
&
fl
.
fl6_dst
);
/* get the source address used in the appropriate device */
err
=
ipv6_get_saddr
(
dst
,
daddr
,
&
saddr
);
err
=
ipv6_get_saddr
(
dst
,
daddr
,
&
fl
.
fl6_src
);
if
(
err
==
0
)
{
if
(
ipv6_addr_any
(
&
np
->
saddr
))
ipv6_addr_copy
(
&
np
->
saddr
,
&
saddr
);
ipv6_addr_copy
(
&
np
->
saddr
,
&
fl
.
fl6_src
);
if
(
ipv6_addr_any
(
&
np
->
rcv_saddr
))
{
ipv6_addr_copy
(
&
np
->
rcv_saddr
,
&
saddr
);
ipv6_addr_copy
(
&
np
->
rcv_saddr
,
&
fl
.
fl6_src
);
inet
->
rcv_saddr
=
LOOPBACK4_IPV6
;
}
ip6_dst_store
(
sk
,
dst
,
!
ipv6_addr_cmp
(
&
fl
.
fl6_dst
,
&
np
->
daddr
)
?
&
np
->
daddr
:
NULL
);
sk
->
state
=
TCP_ESTABLISHED
;
}
fl6_sock_release
(
flowlabel
);
...
...
net/ipv6/xfrm6_policy.c
View file @
cbec8fba
...
...
@@ -146,7 +146,7 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
memcpy
(
&
dst_prev
->
metrics
,
&
rt
->
u
.
dst
.
metrics
,
sizeof
(
dst_prev
->
metrics
));
dst_prev
->
path
=
&
rt
->
u
.
dst
;
/* Copy neighbou
t
for reachability confirmation */
/* Copy neighbou
r
for reachability confirmation */
dst_prev
->
neighbour
=
neigh_clone
(
rt
->
u
.
dst
.
neighbour
);
dst_prev
->
input
=
rt
->
u
.
dst
.
input
;
dst_prev
->
output
=
dst_prev
->
xfrm
->
type
->
output
;
...
...
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