Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
3859069b
cloud-kernel
项目概览
openanolis
/
cloud-kernel
接近 2 年 前同步成功
通知
169
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3859069b
编写于
8月 07, 2008
作者:
J
Jeff Garzik
提交者:
Jeff Garzik
8月 07, 2008
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'for-jeff' of
git://git.kernel.org/pub/scm/linux/kernel/git/chris/linux-2.6
into tmp
上级
e2c709b0
867240f7
变更
36
展开全部
隐藏空白更改
内联
并排
Showing
36 changed file
with
1245 addition
and
1918 deletion
+1245
-1918
Documentation/DocBook/z8530book.tmpl
Documentation/DocBook/z8530book.tmpl
+12
-26
drivers/char/pcmcia/synclink_cs.c
drivers/char/pcmcia/synclink_cs.c
+0
-4
drivers/char/synclink.c
drivers/char/synclink.c
+0
-4
drivers/char/synclink_gt.c
drivers/char/synclink_gt.c
+0
-5
drivers/char/synclinkmp.c
drivers/char/synclinkmp.c
+0
-4
drivers/net/wan/Kconfig
drivers/net/wan/Kconfig
+6
-7
drivers/net/wan/Makefile
drivers/net/wan/Makefile
+5
-6
drivers/net/wan/cosa.c
drivers/net/wan/cosa.c
+128
-165
drivers/net/wan/dscc4.c
drivers/net/wan/dscc4.c
+0
-1
drivers/net/wan/farsync.c
drivers/net/wan/farsync.c
+1
-4
drivers/net/wan/farsync.h
drivers/net/wan/farsync.h
+0
-6
drivers/net/wan/hdlc.c
drivers/net/wan/hdlc.c
+12
-13
drivers/net/wan/hdlc_cisco.c
drivers/net/wan/hdlc_cisco.c
+14
-15
drivers/net/wan/hdlc_fr.c
drivers/net/wan/hdlc_fr.c
+9
-10
drivers/net/wan/hdlc_ppp.c
drivers/net/wan/hdlc_ppp.c
+7
-8
drivers/net/wan/hdlc_raw.c
drivers/net/wan/hdlc_raw.c
+7
-8
drivers/net/wan/hdlc_raw_eth.c
drivers/net/wan/hdlc_raw_eth.c
+8
-9
drivers/net/wan/hdlc_x25.c
drivers/net/wan/hdlc_x25.c
+8
-9
drivers/net/wan/hostess_sv11.c
drivers/net/wan/hostess_sv11.c
+154
-228
drivers/net/wan/lmc/lmc.h
drivers/net/wan/lmc/lmc.h
+5
-6
drivers/net/wan/lmc/lmc_debug.c
drivers/net/wan/lmc/lmc_debug.c
+3
-4
drivers/net/wan/lmc/lmc_debug.h
drivers/net/wan/lmc/lmc_debug.h
+3
-3
drivers/net/wan/lmc/lmc_ioctl.h
drivers/net/wan/lmc/lmc_ioctl.h
+1
-1
drivers/net/wan/lmc/lmc_main.c
drivers/net/wan/lmc/lmc_main.c
+294
-378
drivers/net/wan/lmc/lmc_media.c
drivers/net/wan/lmc/lmc_media.c
+27
-39
drivers/net/wan/lmc/lmc_proto.c
drivers/net/wan/lmc/lmc_proto.c
+25
-121
drivers/net/wan/lmc/lmc_proto.h
drivers/net/wan/lmc/lmc_proto.h
+8
-6
drivers/net/wan/lmc/lmc_var.h
drivers/net/wan/lmc/lmc_var.h
+130
-230
drivers/net/wan/pc300.h
drivers/net/wan/pc300.h
+91
-137
drivers/net/wan/pc300_drv.c
drivers/net/wan/pc300_drv.c
+64
-82
drivers/net/wan/sealevel.c
drivers/net/wan/sealevel.c
+142
-219
drivers/net/wan/syncppp.c
drivers/net/wan/syncppp.c
+0
-9
drivers/net/wan/z85230.c
drivers/net/wan/z85230.c
+77
-116
drivers/net/wan/z85230.h
drivers/net/wan/z85230.h
+4
-6
include/net/syncppp.h
include/net/syncppp.h
+0
-2
net/wanrouter/wanmain.c
net/wanrouter/wanmain.c
+0
-27
未找到文件。
Documentation/DocBook/z8530book.tmpl
浏览文件 @
3859069b
...
...
@@ -69,12 +69,6 @@
device to be used as both a tty interface and as a synchronous
controller is a project for Linux post the 2.4 release
</para>
<para>
The support code handles most common card configurations and
supports running both Cisco HDLC and Synchronous PPP. With extra
glue the frame relay and X.25 protocols can also be used with this
driver.
</para>
</chapter>
<chapter
id=
"Driver_Modes"
>
...
...
@@ -179,35 +173,27 @@
<para>
If you wish to use the network interface facilities of the driver,
then you need to attach a network device to each channel that is
present and in use. In addition to use the
SyncPPP and Cisco
HDLC
present and in use. In addition to use the
generic
HDLC
you need to follow some additional plumbing rules. They may seem
complex but a look at the example hostess_sv11 driver should
reassure you.
</para>
<para>
The network device used for each channel should be pointed to by
the netdevice field of each channel. The
dev
-
>
priv field of the
the netdevice field of each channel. The
hdlc
-
>
priv field of the
network device points to your private data - you will need to be
able to find your ppp device from this. In addition to use the
sync ppp layer the private data must start with a void * pointer
to the syncppp structures.
able to find your private data from this.
</para>
<para>
The way most drivers approach this particular problem is to
create a structure holding the Z8530 device definition and
put that and the syncppp pointer into the private field of
the network device. The network device fields of the channels
then point back to the network devices. The ppp_device can also
be put in the private structure conveniently.
put that into the private field of the network device. The
network device fields of the channels then point back to the
network devices.
</para>
<para>
If you wish to use the synchronous ppp then you need to attach
the syncppp layer to the network device. You should do this before
you register the network device. The
<function>
sppp_attach
</function>
requires that the first void *
pointer in your private data is pointing to an empty struct
ppp_device. The function fills in the initial data for the
ppp/hdlc layer.
If you wish to use the generic HDLC then you need to register
the HDLC device.
</para>
<para>
Before you register your network device you will also need to
...
...
@@ -314,10 +300,10 @@
buffer in sk_buff format and queues it for transmission. The
caller must provide the entire packet with the exception of the
bitstuffing and CRC. This is normally done by the caller via
the
syncppp interface layer. It returns 0 if the buffer has been
queued and non zero values for queue full. If the function accepts
the buffer it becomes property of the Z8530 layer and the caller
should not free it.
the
generic HDLC interface layer. It returns 0 if the buffer has been
queued and non zero values for queue full. If the function accepts
the buffer it becomes property of the Z8530 layer and the caller
should not free it.
</para>
<para>
The function
<function>
z8530_get_stats
</function>
returns a pointer
...
...
drivers/char/pcmcia/synclink_cs.c
浏览文件 @
3859069b
...
...
@@ -232,7 +232,6 @@ typedef struct _mgslpc_info {
/* SPPP/Cisco HDLC device parts */
int
netcount
;
int
dosyncppp
;
spinlock_t
netlock
;
#if SYNCLINK_GENERIC_HDLC
...
...
@@ -459,13 +458,11 @@ static int ttymajor=0;
static
int
debug_level
=
0
;
static
int
maxframe
[
MAX_DEVICE_COUNT
]
=
{
0
,};
static
int
dosyncppp
[
MAX_DEVICE_COUNT
]
=
{
1
,
1
,
1
,
1
};
module_param
(
break_on_load
,
bool
,
0
);
module_param
(
ttymajor
,
int
,
0
);
module_param
(
debug_level
,
int
,
0
);
module_param_array
(
maxframe
,
int
,
NULL
,
0
);
module_param_array
(
dosyncppp
,
int
,
NULL
,
0
);
MODULE_LICENSE
(
"GPL"
);
...
...
@@ -2915,7 +2912,6 @@ static void mgslpc_add_device(MGSLPC_INFO *info)
if
(
info
->
line
<
MAX_DEVICE_COUNT
)
{
if
(
maxframe
[
info
->
line
])
info
->
max_frame_size
=
maxframe
[
info
->
line
];
info
->
dosyncppp
=
dosyncppp
[
info
->
line
];
}
mgslpc_device_count
++
;
...
...
drivers/char/synclink.c
浏览文件 @
3859069b
...
...
@@ -304,7 +304,6 @@ struct mgsl_struct {
/* generic HDLC device parts */
int
netcount
;
int
dosyncppp
;
spinlock_t
netlock
;
#if SYNCLINK_GENERIC_HDLC
...
...
@@ -868,7 +867,6 @@ static int irq[MAX_ISA_DEVICES];
static
int
dma
[
MAX_ISA_DEVICES
];
static
int
debug_level
;
static
int
maxframe
[
MAX_TOTAL_DEVICES
];
static
int
dosyncppp
[
MAX_TOTAL_DEVICES
];
static
int
txdmabufs
[
MAX_TOTAL_DEVICES
];
static
int
txholdbufs
[
MAX_TOTAL_DEVICES
];
...
...
@@ -879,7 +877,6 @@ module_param_array(irq, int, NULL, 0);
module_param_array
(
dma
,
int
,
NULL
,
0
);
module_param
(
debug_level
,
int
,
0
);
module_param_array
(
maxframe
,
int
,
NULL
,
0
);
module_param_array
(
dosyncppp
,
int
,
NULL
,
0
);
module_param_array
(
txdmabufs
,
int
,
NULL
,
0
);
module_param_array
(
txholdbufs
,
int
,
NULL
,
0
);
...
...
@@ -4258,7 +4255,6 @@ static void mgsl_add_device( struct mgsl_struct *info )
if
(
info
->
line
<
MAX_TOTAL_DEVICES
)
{
if
(
maxframe
[
info
->
line
])
info
->
max_frame_size
=
maxframe
[
info
->
line
];
info
->
dosyncppp
=
dosyncppp
[
info
->
line
];
if
(
txdmabufs
[
info
->
line
])
{
info
->
num_tx_dma_buffers
=
txdmabufs
[
info
->
line
];
...
...
drivers/char/synclink_gt.c
浏览文件 @
3859069b
...
...
@@ -128,17 +128,14 @@ static int slgt_device_count;
static
int
ttymajor
;
static
int
debug_level
;
static
int
maxframe
[
MAX_DEVICES
];
static
int
dosyncppp
[
MAX_DEVICES
];
module_param
(
ttymajor
,
int
,
0
);
module_param
(
debug_level
,
int
,
0
);
module_param_array
(
maxframe
,
int
,
NULL
,
0
);
module_param_array
(
dosyncppp
,
int
,
NULL
,
0
);
MODULE_PARM_DESC
(
ttymajor
,
"TTY major device number override: 0=auto assigned"
);
MODULE_PARM_DESC
(
debug_level
,
"Debug syslog output: 0=disabled, 1 to 5=increasing detail"
);
MODULE_PARM_DESC
(
maxframe
,
"Maximum frame size used by device (4096 to 65535)"
);
MODULE_PARM_DESC
(
dosyncppp
,
"Enable synchronous net device, 0=disable 1=enable"
);
/*
* tty support and callbacks
...
...
@@ -349,7 +346,6 @@ struct slgt_info {
/* SPPP/Cisco HDLC device parts */
int
netcount
;
int
dosyncppp
;
spinlock_t
netlock
;
#if SYNCLINK_GENERIC_HDLC
struct
net_device
*
netdev
;
...
...
@@ -3405,7 +3401,6 @@ static void add_device(struct slgt_info *info)
if
(
info
->
line
<
MAX_DEVICES
)
{
if
(
maxframe
[
info
->
line
])
info
->
max_frame_size
=
maxframe
[
info
->
line
];
info
->
dosyncppp
=
dosyncppp
[
info
->
line
];
}
slgt_device_count
++
;
...
...
drivers/char/synclinkmp.c
浏览文件 @
3859069b
...
...
@@ -270,7 +270,6 @@ typedef struct _synclinkmp_info {
/* SPPP/Cisco HDLC device parts */
int
netcount
;
int
dosyncppp
;
spinlock_t
netlock
;
#if SYNCLINK_GENERIC_HDLC
...
...
@@ -469,13 +468,11 @@ static int ttymajor = 0;
*/
static
int
debug_level
=
0
;
static
int
maxframe
[
MAX_DEVICES
]
=
{
0
,};
static
int
dosyncppp
[
MAX_DEVICES
]
=
{
0
,};
module_param
(
break_on_load
,
bool
,
0
);
module_param
(
ttymajor
,
int
,
0
);
module_param
(
debug_level
,
int
,
0
);
module_param_array
(
maxframe
,
int
,
NULL
,
0
);
module_param_array
(
dosyncppp
,
int
,
NULL
,
0
);
static
char
*
driver_name
=
"SyncLink MultiPort driver"
;
static
char
*
driver_version
=
"$Revision: 4.38 $"
;
...
...
@@ -3752,7 +3749,6 @@ static void add_device(SLMP_INFO *info)
if
(
info
->
line
<
MAX_DEVICES
)
{
if
(
maxframe
[
info
->
line
])
info
->
max_frame_size
=
maxframe
[
info
->
line
];
info
->
dosyncppp
=
dosyncppp
[
info
->
line
];
}
synclinkmp_device_count
++
;
...
...
drivers/net/wan/Kconfig
浏览文件 @
3859069b
...
...
@@ -25,7 +25,7 @@ if WAN
# There is no way to detect a comtrol sv11 - force it modular for now.
config HOSTESS_SV11
tristate "Comtrol Hostess SV-11 support"
depends on ISA && m && ISA_DMA_API && INET
depends on ISA && m && ISA_DMA_API && INET
&& HDLC
help
Driver for Comtrol Hostess SV-11 network card which
operates on low speed synchronous serial links at up to
...
...
@@ -37,7 +37,7 @@ config HOSTESS_SV11
# The COSA/SRP driver has not been tested as non-modular yet.
config COSA
tristate "COSA/SRP sync serial boards support"
depends on ISA && m && ISA_DMA_API
depends on ISA && m && ISA_DMA_API
&& HDLC
---help---
Driver for COSA and SRP synchronous serial boards.
...
...
@@ -61,7 +61,7 @@ config COSA
#
config LANMEDIA
tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards"
depends on PCI && VIRT_TO_BUS
depends on PCI && VIRT_TO_BUS
&& HDLC
---help---
Driver for the following Lan Media family of serial boards:
...
...
@@ -78,9 +78,8 @@ config LANMEDIA
- LMC 5245 board connects directly to a T3 circuit saving the
additional external hardware.
To change setting such as syncPPP vs Cisco HDLC or clock source you
will need lmcctl. It is available at <ftp://ftp.lanmedia.com/>
(broken link).
To change setting such as clock source you will need lmcctl.
It is available at <ftp://ftp.lanmedia.com/> (broken link).
To compile this driver as a module, choose M here: the
module will be called lmc.
...
...
@@ -88,7 +87,7 @@ config LANMEDIA
# There is no way to detect a Sealevel board. Force it modular
config SEALEVEL_4021
tristate "Sealevel Systems 4021 support"
depends on ISA && m && ISA_DMA_API && INET
depends on ISA && m && ISA_DMA_API && INET
&& HDLC
help
This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
...
...
drivers/net/wan/Makefile
浏览文件 @
3859069b
...
...
@@ -21,12 +21,11 @@ pc300-y := pc300_drv.o
pc300-$(CONFIG_PC300_MLPPP)
+=
pc300_tty.o
pc300-objs
:=
$
(
pc300-y
)
obj-$(CONFIG_HOSTESS_SV11)
+=
z85230.o syncppp.o hostess_sv11.o
obj-$(CONFIG_SEALEVEL_4021)
+=
z85230.o syncppp.o sealevel.o
obj-$(CONFIG_COSA)
+=
syncppp.o cosa.o
obj-$(CONFIG_FARSYNC)
+=
syncppp.o farsync.o
obj-$(CONFIG_DSCC4)
+=
dscc4.o
obj-$(CONFIG_LANMEDIA)
+=
syncppp.o
obj-$(CONFIG_HOSTESS_SV11)
+=
z85230.o hostess_sv11.o
obj-$(CONFIG_SEALEVEL_4021)
+=
z85230.o sealevel.o
obj-$(CONFIG_COSA)
+=
cosa.o
obj-$(CONFIG_FARSYNC)
+=
farsync.o
obj-$(CONFIG_DSCC4)
+=
dscc4.o
obj-$(CONFIG_X25_ASY)
+=
x25_asy.o
obj-$(CONFIG_LANMEDIA)
+=
lmc/
...
...
drivers/net/wan/cosa.c
浏览文件 @
3859069b
...
...
@@ -2,6 +2,7 @@
/*
* Copyright (C) 1995-1997 Jan "Yenya" Kasprzak <kas@fi.muni.cz>
* Generic HDLC port Copyright (C) 2008 Krzysztof Halasa <khc@pm.waw.pl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -54,7 +55,7 @@
*
* The Linux driver (unlike the present *BSD drivers :-) can work even
* for the COSA and SRP in one computer and allows each channel to work
* in one of the t
hree modes (character device, Cisco HDLC, Sync PPP
).
* in one of the t
wo modes (character or network device
).
*
* AUTHOR
*
...
...
@@ -72,12 +73,6 @@
* The Comtrol Hostess SV11 driver by Alan Cox
* The Sync PPP/Cisco HDLC layer (syncppp.c) ported to Linux by Alan Cox
*/
/*
* 5/25/1999 : Marcelo Tosatti <marcelo@conectiva.com.br>
* fixed a deadlock in cosa_sppp_open
*/
/* ---------- Headers, macros, data structures ---------- */
#include <linux/module.h>
#include <linux/kernel.h>
...
...
@@ -86,6 +81,7 @@
#include <linux/fs.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/hdlc.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/netdevice.h>
...
...
@@ -93,14 +89,12 @@
#include <linux/mutex.h>
#include <linux/device.h>
#include <linux/smp_lock.h>
#undef COSA_SLOW_IO
/* for testing purposes only */
#include <asm/io.h>
#include <asm/dma.h>
#include <asm/byteorder.h>
#include <net/syncppp.h>
#undef COSA_SLOW_IO
/* for testing purposes only */
#include "cosa.h"
/* Maximum length of the identification string. */
...
...
@@ -112,7 +106,6 @@
/* Per-channel data structure */
struct
channel_data
{
void
*
if_ptr
;
/* General purpose pointer (used by SPPP) */
int
usage
;
/* Usage count; >0 for chrdev, -1 for netdev */
int
num
;
/* Number of the channel */
struct
cosa_data
*
cosa
;
/* Pointer to the per-card structure */
...
...
@@ -136,10 +129,9 @@ struct channel_data {
wait_queue_head_t
txwaitq
,
rxwaitq
;
int
tx_status
,
rx_status
;
/*
SPPP/
HDLC device parts */
struct
ppp_device
ppp
dev
;
/*
generic
HDLC device parts */
struct
net_device
*
net
dev
;
struct
sk_buff
*
rx_skb
,
*
tx_skb
;
struct
net_device_stats
stats
;
};
/* cosa->firmware_status bits */
...
...
@@ -281,21 +273,19 @@ static int cosa_start_tx(struct channel_data *channel, char *buf, int size);
static
void
cosa_kick
(
struct
cosa_data
*
cosa
);
static
int
cosa_dma_able
(
struct
channel_data
*
chan
,
char
*
buf
,
int
data
);
/* SPPP/HDLC stuff */
static
void
sppp_channel_init
(
struct
channel_data
*
chan
);
static
void
sppp_channel_delete
(
struct
channel_data
*
chan
);
static
int
cosa_sppp_open
(
struct
net_device
*
d
);
static
int
cosa_sppp_close
(
struct
net_device
*
d
);
static
void
cosa_sppp_timeout
(
struct
net_device
*
d
);
static
int
cosa_sppp_tx
(
struct
sk_buff
*
skb
,
struct
net_device
*
d
);
static
char
*
sppp_setup_rx
(
struct
channel_data
*
channel
,
int
size
);
static
int
sppp_rx_done
(
struct
channel_data
*
channel
);
static
int
sppp_tx_done
(
struct
channel_data
*
channel
,
int
size
);
static
int
cosa_sppp_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
,
int
cmd
);
static
struct
net_device_stats
*
cosa_net_stats
(
struct
net_device
*
dev
);
/* Network device stuff */
static
int
cosa_net_attach
(
struct
net_device
*
dev
,
unsigned
short
encoding
,
unsigned
short
parity
);
static
int
cosa_net_open
(
struct
net_device
*
d
);
static
int
cosa_net_close
(
struct
net_device
*
d
);
static
void
cosa_net_timeout
(
struct
net_device
*
d
);
static
int
cosa_net_tx
(
struct
sk_buff
*
skb
,
struct
net_device
*
d
);
static
char
*
cosa_net_setup_rx
(
struct
channel_data
*
channel
,
int
size
);
static
int
cosa_net_rx_done
(
struct
channel_data
*
channel
);
static
int
cosa_net_tx_done
(
struct
channel_data
*
channel
,
int
size
);
static
int
cosa_net_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
,
int
cmd
);
/* Character device */
static
void
chardev_channel_init
(
struct
channel_data
*
chan
);
static
char
*
chrdev_setup_rx
(
struct
channel_data
*
channel
,
int
size
);
static
int
chrdev_rx_done
(
struct
channel_data
*
channel
);
static
int
chrdev_tx_done
(
struct
channel_data
*
channel
,
int
size
);
...
...
@@ -357,17 +347,17 @@ static void debug_status_in(struct cosa_data *cosa, int status);
static
void
debug_status_out
(
struct
cosa_data
*
cosa
,
int
status
);
#endif
static
inline
struct
channel_data
*
dev_to_chan
(
struct
net_device
*
dev
)
{
return
(
struct
channel_data
*
)
dev_to_hdlc
(
dev
)
->
priv
;
}
/* ---------- Initialization stuff ---------- */
static
int
__init
cosa_init
(
void
)
{
int
i
,
err
=
0
;
printk
(
KERN_INFO
"cosa v1.08 (c) 1997-2000 Jan Kasprzak <kas@fi.muni.cz>
\n
"
);
#ifdef CONFIG_SMP
printk
(
KERN_INFO
"cosa: SMP found. Please mail any success/failure reports to the author.
\n
"
);
#endif
if
(
cosa_major
>
0
)
{
if
(
register_chrdev
(
cosa_major
,
"cosa"
,
&
cosa_fops
))
{
printk
(
KERN_WARNING
"cosa: unable to get major %d
\n
"
,
...
...
@@ -402,7 +392,7 @@ static int __init cosa_init(void)
NULL
,
"cosa%d"
,
i
);
err
=
0
;
goto
out
;
out_chrdev:
unregister_chrdev
(
cosa_major
,
"cosa"
);
out:
...
...
@@ -414,43 +404,29 @@ static void __exit cosa_exit(void)
{
struct
cosa_data
*
cosa
;
int
i
;
printk
(
KERN_INFO
"Unloading the cosa module
\n
"
);
for
(
i
=
0
;
i
<
nr_cards
;
i
++
)
for
(
i
=
0
;
i
<
nr_cards
;
i
++
)
device_destroy
(
cosa_class
,
MKDEV
(
cosa_major
,
i
));
class_destroy
(
cosa_class
);
for
(
cosa
=
cosa_cards
;
nr_cards
--
;
cosa
++
)
{
for
(
cosa
=
cosa_cards
;
nr_cards
--
;
cosa
++
)
{
/* Clean up the per-channel data */
for
(
i
=
0
;
i
<
cosa
->
nchannels
;
i
++
)
{
for
(
i
=
0
;
i
<
cosa
->
nchannels
;
i
++
)
{
/* Chardev driver has no alloc'd per-channel data */
sppp_channel_delete
(
cosa
->
chan
+
i
);
unregister_hdlc_device
(
cosa
->
chan
[
i
].
netdev
);
free_netdev
(
cosa
->
chan
[
i
].
netdev
);
}
/* Clean up the per-card data */
kfree
(
cosa
->
chan
);
kfree
(
cosa
->
bouncebuf
);
free_irq
(
cosa
->
irq
,
cosa
);
free_dma
(
cosa
->
dma
);
release_region
(
cosa
->
datareg
,
is_8bit
(
cosa
)
?
2
:
4
);
release_region
(
cosa
->
datareg
,
is_8bit
(
cosa
)
?
2
:
4
);
}
unregister_chrdev
(
cosa_major
,
"cosa"
);
}
module_exit
(
cosa_exit
);
/*
* This function should register all the net devices needed for the
* single channel.
*/
static
__inline__
void
channel_init
(
struct
channel_data
*
chan
)
{
sprintf
(
chan
->
name
,
"cosa%dc%d"
,
chan
->
cosa
->
num
,
chan
->
num
);
/* Initialize the chardev data structures */
chardev_channel_init
(
chan
);
/* Register the sppp interface */
sppp_channel_init
(
chan
);
}
static
int
cosa_probe
(
int
base
,
int
irq
,
int
dma
)
{
struct
cosa_data
*
cosa
=
cosa_cards
+
nr_cards
;
...
...
@@ -576,13 +552,43 @@ static int cosa_probe(int base, int irq, int dma)
/* Initialize the per-channel data */
cosa
->
chan
=
kcalloc
(
cosa
->
nchannels
,
sizeof
(
struct
channel_data
),
GFP_KERNEL
);
if
(
!
cosa
->
chan
)
{
err
=
-
ENOMEM
;
err
=
-
ENOMEM
;
goto
err_out3
;
}
for
(
i
=
0
;
i
<
cosa
->
nchannels
;
i
++
)
{
cosa
->
chan
[
i
].
cosa
=
cosa
;
cosa
->
chan
[
i
].
num
=
i
;
channel_init
(
cosa
->
chan
+
i
);
for
(
i
=
0
;
i
<
cosa
->
nchannels
;
i
++
)
{
struct
channel_data
*
chan
=
&
cosa
->
chan
[
i
];
chan
->
cosa
=
cosa
;
chan
->
num
=
i
;
sprintf
(
chan
->
name
,
"cosa%dc%d"
,
chan
->
cosa
->
num
,
i
);
/* Initialize the chardev data structures */
mutex_init
(
&
chan
->
rlock
);
init_MUTEX
(
&
chan
->
wsem
);
/* Register the network interface */
if
(
!
(
chan
->
netdev
=
alloc_hdlcdev
(
chan
)))
{
printk
(
KERN_WARNING
"%s: alloc_hdlcdev failed.
\n
"
,
chan
->
name
);
goto
err_hdlcdev
;
}
dev_to_hdlc
(
chan
->
netdev
)
->
attach
=
cosa_net_attach
;
dev_to_hdlc
(
chan
->
netdev
)
->
xmit
=
cosa_net_tx
;
chan
->
netdev
->
open
=
cosa_net_open
;
chan
->
netdev
->
stop
=
cosa_net_close
;
chan
->
netdev
->
do_ioctl
=
cosa_net_ioctl
;
chan
->
netdev
->
tx_timeout
=
cosa_net_timeout
;
chan
->
netdev
->
watchdog_timeo
=
TX_TIMEOUT
;
chan
->
netdev
->
base_addr
=
chan
->
cosa
->
datareg
;
chan
->
netdev
->
irq
=
chan
->
cosa
->
irq
;
chan
->
netdev
->
dma
=
chan
->
cosa
->
dma
;
if
(
register_hdlc_device
(
chan
->
netdev
))
{
printk
(
KERN_WARNING
"%s: register_hdlc_device()"
" failed.
\n
"
,
chan
->
netdev
->
name
);
free_netdev
(
chan
->
netdev
);
goto
err_hdlcdev
;
}
}
printk
(
KERN_INFO
"cosa%d: %s (%s at 0x%x irq %d dma %d), %d channels
\n
"
,
...
...
@@ -590,13 +596,20 @@ static int cosa_probe(int base, int irq, int dma)
cosa
->
datareg
,
cosa
->
irq
,
cosa
->
dma
,
cosa
->
nchannels
);
return
nr_cards
++
;
err_hdlcdev:
while
(
i
--
>
0
)
{
unregister_hdlc_device
(
cosa
->
chan
[
i
].
netdev
);
free_netdev
(
cosa
->
chan
[
i
].
netdev
);
}
kfree
(
cosa
->
chan
);
err_out3:
kfree
(
cosa
->
bouncebuf
);
err_out2:
free_dma
(
cosa
->
dma
);
err_out1:
free_irq
(
cosa
->
irq
,
cosa
);
err_out:
err_out:
release_region
(
cosa
->
datareg
,
is_8bit
(
cosa
)
?
2
:
4
);
printk
(
KERN_NOTICE
"cosa%d: allocating resources failed
\n
"
,
cosa
->
num
);
...
...
@@ -604,54 +617,19 @@ static int cosa_probe(int base, int irq, int dma)
}
/*----------
SPPP/HDLC net
device ---------- */
/*----------
network
device ---------- */
static
void
cosa_setup
(
struct
net_device
*
d
)
static
int
cosa_net_attach
(
struct
net_device
*
dev
,
unsigned
short
encoding
,
unsigned
short
parity
)
{
d
->
open
=
cosa_sppp_open
;
d
->
stop
=
cosa_sppp_close
;
d
->
hard_start_xmit
=
cosa_sppp_tx
;
d
->
do_ioctl
=
cosa_sppp_ioctl
;
d
->
get_stats
=
cosa_net_stats
;
d
->
tx_timeout
=
cosa_sppp_timeout
;
d
->
watchdog_timeo
=
TX_TIMEOUT
;
}
static
void
sppp_channel_init
(
struct
channel_data
*
chan
)
{
struct
net_device
*
d
;
chan
->
if_ptr
=
&
chan
->
pppdev
;
d
=
alloc_netdev
(
0
,
chan
->
name
,
cosa_setup
);
if
(
!
d
)
{
printk
(
KERN_WARNING
"%s: alloc_netdev failed.
\n
"
,
chan
->
name
);
return
;
}
chan
->
pppdev
.
dev
=
d
;
d
->
base_addr
=
chan
->
cosa
->
datareg
;
d
->
irq
=
chan
->
cosa
->
irq
;
d
->
dma
=
chan
->
cosa
->
dma
;
d
->
ml_priv
=
chan
;
sppp_attach
(
&
chan
->
pppdev
);
if
(
register_netdev
(
d
))
{
printk
(
KERN_WARNING
"%s: register_netdev failed.
\n
"
,
d
->
name
);
sppp_detach
(
d
);
free_netdev
(
d
);
chan
->
pppdev
.
dev
=
NULL
;
return
;
}
}
static
void
sppp_channel_delete
(
struct
channel_data
*
chan
)
{
unregister_netdev
(
chan
->
pppdev
.
dev
);
sppp_detach
(
chan
->
pppdev
.
dev
);
free_netdev
(
chan
->
pppdev
.
dev
);
chan
->
pppdev
.
dev
=
NULL
;
if
(
encoding
==
ENCODING_NRZ
&&
parity
==
PARITY_CRC16_PR1_CCITT
)
return
0
;
return
-
EINVAL
;
}
static
int
cosa_
sppp_open
(
struct
net_device
*
d
)
static
int
cosa_
net_open
(
struct
net_device
*
dev
)
{
struct
channel_data
*
chan
=
d
->
ml_priv
;
struct
channel_data
*
chan
=
d
ev_to_chan
(
dev
)
;
int
err
;
unsigned
long
flags
;
...
...
@@ -662,36 +640,35 @@ static int cosa_sppp_open(struct net_device *d)
}
spin_lock_irqsave
(
&
chan
->
cosa
->
lock
,
flags
);
if
(
chan
->
usage
!=
0
)
{
printk
(
KERN_WARNING
"%s:
sppp_open called with usage count %d
\n
"
,
chan
->
name
,
chan
->
usage
);
printk
(
KERN_WARNING
"%s:
cosa_net_open called with usage count"
" %d
\n
"
,
chan
->
name
,
chan
->
usage
);
spin_unlock_irqrestore
(
&
chan
->
cosa
->
lock
,
flags
);
return
-
EBUSY
;
}
chan
->
setup_rx
=
sppp
_setup_rx
;
chan
->
tx_done
=
sppp
_tx_done
;
chan
->
rx_done
=
sppp
_rx_done
;
chan
->
usage
=
-
1
;
chan
->
setup_rx
=
cosa_net
_setup_rx
;
chan
->
tx_done
=
cosa_net
_tx_done
;
chan
->
rx_done
=
cosa_net
_rx_done
;
chan
->
usage
=
-
1
;
chan
->
cosa
->
usage
++
;
spin_unlock_irqrestore
(
&
chan
->
cosa
->
lock
,
flags
);
err
=
sppp_open
(
d
);
err
=
hdlc_open
(
dev
);
if
(
err
)
{
spin_lock_irqsave
(
&
chan
->
cosa
->
lock
,
flags
);
chan
->
usage
=
0
;
chan
->
usage
=
0
;
chan
->
cosa
->
usage
--
;
spin_unlock_irqrestore
(
&
chan
->
cosa
->
lock
,
flags
);
return
err
;
}
netif_start_queue
(
d
);
netif_start_queue
(
d
ev
);
cosa_enable_rx
(
chan
);
return
0
;
}
static
int
cosa_
sppp
_tx
(
struct
sk_buff
*
skb
,
struct
net_device
*
dev
)
static
int
cosa_
net
_tx
(
struct
sk_buff
*
skb
,
struct
net_device
*
dev
)
{
struct
channel_data
*
chan
=
dev
->
ml_priv
;
struct
channel_data
*
chan
=
dev
_to_chan
(
dev
)
;
netif_stop_queue
(
dev
);
...
...
@@ -700,16 +677,16 @@ static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev)
return
0
;
}
static
void
cosa_
sppp
_timeout
(
struct
net_device
*
dev
)
static
void
cosa_
net
_timeout
(
struct
net_device
*
dev
)
{
struct
channel_data
*
chan
=
dev
->
ml_priv
;
struct
channel_data
*
chan
=
dev
_to_chan
(
dev
)
;
if
(
test_bit
(
RXBIT
,
&
chan
->
cosa
->
rxtx
))
{
chan
->
stats
.
rx_errors
++
;
chan
->
stats
.
rx_missed_errors
++
;
chan
->
netdev
->
stats
.
rx_errors
++
;
chan
->
netdev
->
stats
.
rx_missed_errors
++
;
}
else
{
chan
->
stats
.
tx_errors
++
;
chan
->
stats
.
tx_aborted_errors
++
;
chan
->
netdev
->
stats
.
tx_errors
++
;
chan
->
netdev
->
stats
.
tx_aborted_errors
++
;
}
cosa_kick
(
chan
->
cosa
);
if
(
chan
->
tx_skb
)
{
...
...
@@ -719,13 +696,13 @@ static void cosa_sppp_timeout(struct net_device *dev)
netif_wake_queue
(
dev
);
}
static
int
cosa_
sppp_close
(
struct
net_device
*
d
)
static
int
cosa_
net_close
(
struct
net_device
*
dev
)
{
struct
channel_data
*
chan
=
d
->
ml_priv
;
struct
channel_data
*
chan
=
d
ev_to_chan
(
dev
)
;
unsigned
long
flags
;
netif_stop_queue
(
d
);
sppp_close
(
d
);
netif_stop_queue
(
d
ev
);
hdlc_close
(
dev
);
cosa_disable_rx
(
chan
);
spin_lock_irqsave
(
&
chan
->
cosa
->
lock
,
flags
);
if
(
chan
->
rx_skb
)
{
...
...
@@ -736,13 +713,13 @@ static int cosa_sppp_close(struct net_device *d)
kfree_skb
(
chan
->
tx_skb
);
chan
->
tx_skb
=
NULL
;
}
chan
->
usage
=
0
;
chan
->
usage
=
0
;
chan
->
cosa
->
usage
--
;
spin_unlock_irqrestore
(
&
chan
->
cosa
->
lock
,
flags
);
return
0
;
}
static
char
*
sppp
_setup_rx
(
struct
channel_data
*
chan
,
int
size
)
static
char
*
cosa_net
_setup_rx
(
struct
channel_data
*
chan
,
int
size
)
{
/*
* We can safely fall back to non-dma-able memory, because we have
...
...
@@ -754,66 +731,53 @@ static char *sppp_setup_rx(struct channel_data *chan, int size)
if
(
chan
->
rx_skb
==
NULL
)
{
printk
(
KERN_NOTICE
"%s: Memory squeeze, dropping packet
\n
"
,
chan
->
name
);
chan
->
stats
.
rx_dropped
++
;
chan
->
netdev
->
stats
.
rx_dropped
++
;
return
NULL
;
}
chan
->
pppdev
.
dev
->
trans_start
=
jiffies
;
chan
->
net
dev
->
trans_start
=
jiffies
;
return
skb_put
(
chan
->
rx_skb
,
size
);
}
static
int
sppp
_rx_done
(
struct
channel_data
*
chan
)
static
int
cosa_net
_rx_done
(
struct
channel_data
*
chan
)
{
if
(
!
chan
->
rx_skb
)
{
printk
(
KERN_WARNING
"%s: rx_done with empty skb!
\n
"
,
chan
->
name
);
chan
->
stats
.
rx_errors
++
;
chan
->
stats
.
rx_frame_errors
++
;
chan
->
netdev
->
stats
.
rx_errors
++
;
chan
->
netdev
->
stats
.
rx_frame_errors
++
;
return
0
;
}
chan
->
rx_skb
->
protocol
=
h
tons
(
ETH_P_WAN_PPP
);
chan
->
rx_skb
->
dev
=
chan
->
pppdev
.
dev
;
chan
->
rx_skb
->
protocol
=
h
dlc_type_trans
(
chan
->
rx_skb
,
chan
->
netdev
);
chan
->
rx_skb
->
dev
=
chan
->
net
dev
;
skb_reset_mac_header
(
chan
->
rx_skb
);
chan
->
stats
.
rx_packets
++
;
chan
->
stats
.
rx_bytes
+=
chan
->
cosa
->
rxsize
;
chan
->
netdev
->
stats
.
rx_packets
++
;
chan
->
netdev
->
stats
.
rx_bytes
+=
chan
->
cosa
->
rxsize
;
netif_rx
(
chan
->
rx_skb
);
chan
->
rx_skb
=
NULL
;
chan
->
pppdev
.
dev
->
last_rx
=
jiffies
;
chan
->
net
dev
->
last_rx
=
jiffies
;
return
0
;
}
/* ARGSUSED */
static
int
sppp
_tx_done
(
struct
channel_data
*
chan
,
int
size
)
static
int
cosa_net
_tx_done
(
struct
channel_data
*
chan
,
int
size
)
{
if
(
!
chan
->
tx_skb
)
{
printk
(
KERN_WARNING
"%s: tx_done with empty skb!
\n
"
,
chan
->
name
);
chan
->
stats
.
tx_errors
++
;
chan
->
stats
.
tx_aborted_errors
++
;
chan
->
netdev
->
stats
.
tx_errors
++
;
chan
->
netdev
->
stats
.
tx_aborted_errors
++
;
return
1
;
}
dev_kfree_skb_irq
(
chan
->
tx_skb
);
chan
->
tx_skb
=
NULL
;
chan
->
stats
.
tx_packets
++
;
chan
->
stats
.
tx_bytes
+=
size
;
netif_wake_queue
(
chan
->
pppdev
.
dev
);
chan
->
netdev
->
stats
.
tx_packets
++
;
chan
->
netdev
->
stats
.
tx_bytes
+=
size
;
netif_wake_queue
(
chan
->
net
dev
);
return
1
;
}
static
struct
net_device_stats
*
cosa_net_stats
(
struct
net_device
*
dev
)
{
struct
channel_data
*
chan
=
dev
->
ml_priv
;
return
&
chan
->
stats
;
}
/*---------- Character device ---------- */
static
void
chardev_channel_init
(
struct
channel_data
*
chan
)
{
mutex_init
(
&
chan
->
rlock
);
init_MUTEX
(
&
chan
->
wsem
);
}
static
ssize_t
cosa_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
...
...
@@ -1223,16 +1187,15 @@ static int cosa_ioctl_common(struct cosa_data *cosa,
return
-
ENOIOCTLCMD
;
}
static
int
cosa_sppp_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
,
int
cmd
)
static
int
cosa_net_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
,
int
cmd
)
{
int
rv
;
struct
channel_data
*
chan
=
dev
->
ml_priv
;
rv
=
cosa_ioctl_common
(
chan
->
cosa
,
chan
,
cmd
,
(
unsigned
long
)
ifr
->
ifr_data
);
if
(
rv
==
-
ENOIOCTLCMD
)
{
return
sppp_do_ioctl
(
dev
,
ifr
,
cmd
);
}
return
rv
;
struct
channel_data
*
chan
=
dev
_to_chan
(
dev
)
;
rv
=
cosa_ioctl_common
(
chan
->
cosa
,
chan
,
cmd
,
(
unsigned
long
)
ifr
->
ifr_data
);
if
(
rv
!=
-
ENOIOCTLCMD
)
return
rv
;
return
hdlc_ioctl
(
dev
,
ifr
,
cmd
)
;
}
static
int
cosa_chardev_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
...
...
drivers/net/wan/dscc4.c
浏览文件 @
3859069b
...
...
@@ -103,7 +103,6 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/delay.h>
#include <net/syncppp.h>
#include <linux/hdlc.h>
#include <linux/mutex.h>
...
...
drivers/net/wan/farsync.c
浏览文件 @
3859069b
...
...
@@ -47,10 +47,7 @@ MODULE_LICENSE("GPL");
/* Default parameters for the link
*/
#define FST_TX_QUEUE_LEN 100
/* At 8Mbps a longer queue length is
* useful, the syncppp module forces
* this down assuming a slower line I
* guess.
*/
* useful */
#define FST_TXQ_DEPTH 16
/* This one is for the buffering
* of frames on the way down to the card
* so that we can keep the card busy
...
...
drivers/net/wan/farsync.h
浏览文件 @
3859069b
...
...
@@ -54,9 +54,6 @@
/* Ioctl call command values
*
* The first three private ioctls are used by the sync-PPP module,
* allowing a little room for expansion we start our numbering at 10.
*/
#define FSTWRITE (SIOCDEVPRIVATE+10)
#define FSTCPURESET (SIOCDEVPRIVATE+11)
...
...
@@ -202,9 +199,6 @@ struct fstioc_info {
#define J1 7
/* "proto" */
#define FST_HDLC 1
/* Cisco compatible HDLC */
#define FST_PPP 2
/* Sync PPP */
#define FST_MONITOR 3
/* Monitor only (raw packet reception) */
#define FST_RAW 4
/* Two way raw packets */
#define FST_GEN_HDLC 5
/* Using "Generic HDLC" module */
...
...
drivers/net/wan/hdlc.c
浏览文件 @
3859069b
...
...
@@ -22,20 +22,19 @@
* - proto->start() and stop() are called with spin_lock_irq held.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/errno.h>
#include <linux/hdlc.h>
#include <linux/if_arp.h>
#include <linux/inetdevice.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/pkt_sched.h>
#include <linux/inetdevice.h>
#include <linux/lapb.h>
#include <linux/poll.h>
#include <linux/rtnetlink.h>
#include <linux/
notifier
.h>
#include <linux/
hdlc
.h>
#include <linux/
skbuff
.h>
#include <linux/
slab
.h>
#include <net/net_namespace.h>
...
...
@@ -109,7 +108,7 @@ static int hdlc_device_event(struct notifier_block *this, unsigned long event,
if
(
dev
->
get_stats
!=
hdlc_get_stats
)
return
NOTIFY_DONE
;
/* not an HDLC device */
if
(
event
!=
NETDEV_CHANGE
)
return
NOTIFY_DONE
;
/* Only interrested in carrier changes */
...
...
@@ -357,7 +356,7 @@ static struct packet_type hdlc_packet_type = {
static
struct
notifier_block
hdlc_notifier
=
{
.
notifier_call
=
hdlc_device_event
,
.
notifier_call
=
hdlc_device_event
,
};
...
...
@@ -367,8 +366,8 @@ static int __init hdlc_module_init(void)
printk
(
KERN_INFO
"%s
\n
"
,
version
);
if
((
result
=
register_netdevice_notifier
(
&
hdlc_notifier
))
!=
0
)
return
result
;
dev_add_pack
(
&
hdlc_packet_type
);
return
result
;
dev_add_pack
(
&
hdlc_packet_type
);
return
0
;
}
...
...
drivers/net/wan/hdlc_cisco.c
浏览文件 @
3859069b
...
...
@@ -9,19 +9,18 @@
* as published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/errno.h>
#include <linux/hdlc.h>
#include <linux/if_arp.h>
#include <linux/inetdevice.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pkt_sched.h>
#include <linux/inetdevice.h>
#include <linux/lapb.h>
#include <linux/poll.h>
#include <linux/rtnetlink.h>
#include <linux/hdlc.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#undef DEBUG_HARD_HEADER
...
...
@@ -68,9 +67,9 @@ struct cisco_state {
static
int
cisco_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
);
static
inline
struct
cisco_state
*
state
(
hdlc_device
*
hdlc
)
static
inline
struct
cisco_state
*
state
(
hdlc_device
*
hdlc
)
{
return
(
struct
cisco_state
*
)(
hdlc
->
state
)
;
return
(
struct
cisco_state
*
)
hdlc
->
state
;
}
...
...
@@ -172,7 +171,7 @@ static int cisco_rx(struct sk_buff *skb)
data
->
address
!=
CISCO_UNICAST
)
goto
rx_error
;
switch
(
ntohs
(
data
->
protocol
))
{
switch
(
ntohs
(
data
->
protocol
))
{
case
CISCO_SYS_INFO
:
/* Packet is not needed, drop it. */
dev_kfree_skb_any
(
skb
);
...
...
@@ -336,7 +335,7 @@ static struct hdlc_proto proto = {
static
const
struct
header_ops
cisco_header_ops
=
{
.
create
=
cisco_hard_header
,
};
static
int
cisco_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
)
{
cisco_proto
__user
*
cisco_s
=
ifr
->
ifr_settings
.
ifs_ifsu
.
cisco
;
...
...
@@ -359,10 +358,10 @@ static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
return
0
;
case
IF_PROTO_CISCO
:
if
(
!
capable
(
CAP_NET_ADMIN
))
if
(
!
capable
(
CAP_NET_ADMIN
))
return
-
EPERM
;
if
(
dev
->
flags
&
IFF_UP
)
if
(
dev
->
flags
&
IFF_UP
)
return
-
EBUSY
;
if
(
copy_from_user
(
&
new_settings
,
cisco_s
,
size
))
...
...
@@ -372,7 +371,7 @@ static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
new_settings
.
timeout
<
2
)
return
-
EINVAL
;
result
=
hdlc
->
attach
(
dev
,
ENCODING_NRZ
,
PARITY_CRC16_PR1_CCITT
);
result
=
hdlc
->
attach
(
dev
,
ENCODING_NRZ
,
PARITY_CRC16_PR1_CCITT
);
if
(
result
)
return
result
;
...
...
drivers/net/wan/hdlc_fr.c
浏览文件 @
3859069b
...
...
@@ -33,20 +33,19 @@
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/hdlc.h>
#include <linux/if_arp.h>
#include <linux/inetdevice.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pkt_sched.h>
#include <linux/inetdevice.h>
#include <linux/lapb.h>
#include <linux/poll.h>
#include <linux/rtnetlink.h>
#include <linux/
etherdevice
.h>
#include <linux/
hdlc
.h>
#include <linux/
skbuff
.h>
#include <linux/
slab
.h>
#undef DEBUG_PKT
#undef DEBUG_ECN
...
...
@@ -96,7 +95,7 @@ typedef struct {
unsigned
ea1
:
1
;
unsigned
cr
:
1
;
unsigned
dlcih
:
6
;
unsigned
ea2
:
1
;
unsigned
de
:
1
;
unsigned
becn
:
1
;
...
...
drivers/net/wan/hdlc_ppp.c
浏览文件 @
3859069b
...
...
@@ -9,19 +9,18 @@
* as published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/errno.h>
#include <linux/hdlc.h>
#include <linux/if_arp.h>
#include <linux/inetdevice.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pkt_sched.h>
#include <linux/inetdevice.h>
#include <linux/lapb.h>
#include <linux/poll.h>
#include <linux/rtnetlink.h>
#include <linux/hdlc.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <net/syncppp.h>
struct
ppp_state
{
...
...
drivers/net/wan/hdlc_raw.c
浏览文件 @
3859069b
...
...
@@ -9,19 +9,18 @@
* as published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/errno.h>
#include <linux/hdlc.h>
#include <linux/if_arp.h>
#include <linux/inetdevice.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pkt_sched.h>
#include <linux/inetdevice.h>
#include <linux/lapb.h>
#include <linux/poll.h>
#include <linux/rtnetlink.h>
#include <linux/hdlc.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
static
int
raw_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
);
...
...
drivers/net/wan/hdlc_raw_eth.c
浏览文件 @
3859069b
...
...
@@ -9,20 +9,19 @@
* as published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/hdlc.h>
#include <linux/if_arp.h>
#include <linux/inetdevice.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pkt_sched.h>
#include <linux/inetdevice.h>
#include <linux/lapb.h>
#include <linux/poll.h>
#include <linux/rtnetlink.h>
#include <linux/
etherdevice
.h>
#include <linux/
hdlc
.h>
#include <linux/
skbuff
.h>
#include <linux/
slab
.h>
static
int
raw_eth_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
);
...
...
drivers/net/wan/hdlc_x25.c
浏览文件 @
3859069b
...
...
@@ -9,20 +9,19 @@
* as published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/errno.h>
#include <linux/hdlc.h>
#include <linux/if_arp.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/pkt_sched.h>
#include <linux/inetdevice.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/lapb.h>
#include <linux/module.h>
#include <linux/pkt_sched.h>
#include <linux/poll.h>
#include <linux/rtnetlink.h>
#include <linux/
hdlc
.h>
#include <linux/
skbuff
.h>
#include <linux/slab.h>
#include <net/x25device.h>
static
int
x25_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
);
...
...
drivers/net/wan/hostess_sv11.c
浏览文件 @
3859069b
...
...
@@ -16,6 +16,8 @@
* touching control registers.
*
* Port B isnt wired (why - beats me)
*
* Generic HDLC port Copyright (C) 2008 Krzysztof Halasa <khc@pm.waw.pl>
*/
#include <linux/module.h>
...
...
@@ -26,6 +28,7 @@
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/delay.h>
#include <linux/hdlc.h>
#include <linux/ioport.h>
#include <net/arp.h>
...
...
@@ -33,34 +36,31 @@
#include <asm/io.h>
#include <asm/dma.h>
#include <asm/byteorder.h>
#include <net/syncppp.h>
#include "z85230.h"
static
int
dma
;
struct
sv11_device
{
void
*
if_ptr
;
/* General purpose pointer (used by SPPP) */
struct
z8530_dev
sync
;
struct
ppp_device
netdev
;
};
/*
* Network driver support routines
*/
static
inline
struct
z8530_dev
*
dev_to_sv
(
struct
net_device
*
dev
)
{
return
(
struct
z8530_dev
*
)
dev_to_hdlc
(
dev
)
->
priv
;
}
/*
* Frame receive. Simple for our card as we do
sync ppp
and there
* Frame receive. Simple for our card as we do
HDLC
and there
* is no funny garbage involved
*/
static
void
hostess_input
(
struct
z8530_channel
*
c
,
struct
sk_buff
*
skb
)
{
/* Drop the CRC - it's not a good idea to try and negotiate it ;) */
skb_trim
(
skb
,
skb
->
len
-
2
);
skb
->
protocol
=
__constant_htons
(
ETH_P_WAN_PPP
);
skb_trim
(
skb
,
skb
->
len
-
2
);
skb
->
protocol
=
hdlc_type_trans
(
skb
,
c
->
netdevice
);
skb_reset_mac_header
(
skb
);
skb
->
dev
=
c
->
netdevice
;
skb
->
dev
=
c
->
netdevice
;
/*
* Send it to the PPP layer. We don't have time to process
* it right now.
...
...
@@ -68,56 +68,51 @@ static void hostess_input(struct z8530_channel *c, struct sk_buff *skb)
netif_rx
(
skb
);
c
->
netdevice
->
last_rx
=
jiffies
;
}
/*
* We've been placed in the UP state
*/
*/
static
int
hostess_open
(
struct
net_device
*
d
)
{
struct
sv11_device
*
sv11
=
d
->
ml_priv
;
struct
z8530_dev
*
sv11
=
dev_to_sv
(
d
)
;
int
err
=
-
1
;
/*
* Link layer up
*/
switch
(
dma
)
{
switch
(
dma
)
{
case
0
:
err
=
z8530_sync_open
(
d
,
&
sv11
->
sync
.
chanA
);
err
=
z8530_sync_open
(
d
,
&
sv11
->
chanA
);
break
;
case
1
:
err
=
z8530_sync_dma_open
(
d
,
&
sv11
->
sync
.
chanA
);
err
=
z8530_sync_dma_open
(
d
,
&
sv11
->
chanA
);
break
;
case
2
:
err
=
z8530_sync_txdma_open
(
d
,
&
sv11
->
sync
.
chanA
);
err
=
z8530_sync_txdma_open
(
d
,
&
sv11
->
chanA
);
break
;
}
if
(
err
)
if
(
err
)
return
err
;
/*
* Begin PPP
*/
err
=
sppp_open
(
d
);
if
(
err
)
{
switch
(
dma
)
{
err
=
hdlc_open
(
d
);
if
(
err
)
{
switch
(
dma
)
{
case
0
:
z8530_sync_close
(
d
,
&
sv11
->
sync
.
chanA
);
z8530_sync_close
(
d
,
&
sv11
->
chanA
);
break
;
case
1
:
z8530_sync_dma_close
(
d
,
&
sv11
->
sync
.
chanA
);
z8530_sync_dma_close
(
d
,
&
sv11
->
chanA
);
break
;
case
2
:
z8530_sync_txdma_close
(
d
,
&
sv11
->
sync
.
chanA
);
z8530_sync_txdma_close
(
d
,
&
sv11
->
chanA
);
break
;
}
}
return
err
;
}
sv11
->
sync
.
chanA
.
rx_function
=
hostess_input
;
sv11
->
chanA
.
rx_function
=
hostess_input
;
/*
* Go go go
*/
...
...
@@ -128,30 +123,24 @@ static int hostess_open(struct net_device *d)
static
int
hostess_close
(
struct
net_device
*
d
)
{
struct
sv11_device
*
sv11
=
d
->
ml_priv
;
struct
z8530_dev
*
sv11
=
dev_to_sv
(
d
)
;
/*
* Discard new frames
*/
sv11
->
sync
.
chanA
.
rx_function
=
z8530_null_rx
;
/*
* PPP off
*/
sppp_close
(
d
);
/*
* Link layer down
*/
sv11
->
chanA
.
rx_function
=
z8530_null_rx
;
hdlc_close
(
d
);
netif_stop_queue
(
d
);
switch
(
dma
)
{
switch
(
dma
)
{
case
0
:
z8530_sync_close
(
d
,
&
sv11
->
sync
.
chanA
);
z8530_sync_close
(
d
,
&
sv11
->
chanA
);
break
;
case
1
:
z8530_sync_dma_close
(
d
,
&
sv11
->
sync
.
chanA
);
z8530_sync_dma_close
(
d
,
&
sv11
->
chanA
);
break
;
case
2
:
z8530_sync_txdma_close
(
d
,
&
sv11
->
sync
.
chanA
);
z8530_sync_txdma_close
(
d
,
&
sv11
->
chanA
);
break
;
}
return
0
;
...
...
@@ -159,232 +148,174 @@ static int hostess_close(struct net_device *d)
static
int
hostess_ioctl
(
struct
net_device
*
d
,
struct
ifreq
*
ifr
,
int
cmd
)
{
/* struct sv11_device *sv11=d->ml_priv;
z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */
return
sppp_do_ioctl
(
d
,
ifr
,
cmd
);
}
static
struct
net_device_stats
*
hostess_get_stats
(
struct
net_device
*
d
)
{
struct
sv11_device
*
sv11
=
d
->
ml_priv
;
if
(
sv11
)
return
z8530_get_stats
(
&
sv11
->
sync
.
chanA
);
else
return
NULL
;
/* struct z8530_dev *sv11=dev_to_sv(d);
z8530_ioctl(d,&sv11->chanA,ifr,cmd) */
return
hdlc_ioctl
(
d
,
ifr
,
cmd
);
}
/*
* Passed
PPP
frames, fire them downwind.
* Passed
network
frames, fire them downwind.
*/
static
int
hostess_queue_xmit
(
struct
sk_buff
*
skb
,
struct
net_device
*
d
)
{
struct
sv11_device
*
sv11
=
d
->
ml_priv
;
return
z8530_queue_xmit
(
&
sv11
->
sync
.
chanA
,
skb
);
return
z8530_queue_xmit
(
&
dev_to_sv
(
d
)
->
chanA
,
skb
);
}
static
int
hostess_neigh_setup
(
struct
neighbour
*
n
)
static
int
hostess_attach
(
struct
net_device
*
dev
,
unsigned
short
encoding
,
unsigned
short
parity
)
{
if
(
n
->
nud_state
==
NUD_NONE
)
{
n
->
ops
=
&
arp_broken_ops
;
n
->
output
=
n
->
ops
->
output
;
}
return
0
;
}
static
int
hostess_neigh_setup_dev
(
struct
net_device
*
dev
,
struct
neigh_parms
*
p
)
{
if
(
p
->
tbl
->
family
==
AF_INET
)
{
p
->
neigh_setup
=
hostess_neigh_setup
;
p
->
ucast_probes
=
0
;
p
->
mcast_probes
=
0
;
}
return
0
;
}
static
void
sv11_setup
(
struct
net_device
*
dev
)
{
dev
->
open
=
hostess_open
;
dev
->
stop
=
hostess_close
;
dev
->
hard_start_xmit
=
hostess_queue_xmit
;
dev
->
get_stats
=
hostess_get_stats
;
dev
->
do_ioctl
=
hostess_ioctl
;
dev
->
neigh_setup
=
hostess_neigh_setup_dev
;
if
(
encoding
==
ENCODING_NRZ
&&
parity
==
PARITY_CRC16_PR1_CCITT
)
return
0
;
return
-
EINVAL
;
}
/*
* Description block for a Comtrol Hostess SV11 card
*/
static
struct
sv11_device
*
sv11_init
(
int
iobase
,
int
irq
)
static
struct
z8530_dev
*
sv11_init
(
int
iobase
,
int
irq
)
{
struct
z8530_dev
*
dev
;
struct
sv11_device
*
sv
;
struct
z8530_dev
*
sv
;
struct
net_device
*
netdev
;
/*
* Get the needed I/O space
*/
if
(
!
request_region
(
iobase
,
8
,
"Comtrol SV11"
))
{
printk
(
KERN_WARNING
"hostess: I/O 0x%X already in use.
\n
"
,
iobase
);
if
(
!
request_region
(
iobase
,
8
,
"Comtrol SV11"
))
{
printk
(
KERN_WARNING
"hostess: I/O 0x%X already in use.
\n
"
,
iobase
);
return
NULL
;
}
sv
=
kzalloc
(
sizeof
(
struct
sv11_device
),
GFP_KERNEL
);
if
(
!
sv
)
goto
fail3
;
sv
->
if_ptr
=&
sv
->
netdev
;
sv
->
netdev
.
dev
=
alloc_netdev
(
0
,
"hdlc%d"
,
sv11_setup
);
if
(
!
sv
->
netdev
.
dev
)
goto
fail2
;
dev
=&
sv
->
sync
;
sv
=
kzalloc
(
sizeof
(
struct
z8530_dev
),
GFP_KERNEL
);
if
(
!
sv
)
goto
err_kzalloc
;
/*
* Stuff in the I/O addressing
*/
de
v
->
active
=
0
;
dev
->
chanA
.
ctrlio
=
iobase
+
1
;
dev
->
chanA
.
dataio
=
iobase
+
3
;
dev
->
chanB
.
ctrlio
=
-
1
;
dev
->
chanB
.
dataio
=
-
1
;
dev
->
chanA
.
irqs
=
&
z8530_nop
;
dev
->
chanB
.
irqs
=
&
z8530_nop
;
outb
(
0
,
iobase
+
4
);
/* DMA off */
s
v
->
active
=
0
;
sv
->
chanA
.
ctrlio
=
iobase
+
1
;
sv
->
chanA
.
dataio
=
iobase
+
3
;
sv
->
chanB
.
ctrlio
=
-
1
;
sv
->
chanB
.
dataio
=
-
1
;
sv
->
chanA
.
irqs
=
&
z8530_nop
;
sv
->
chanB
.
irqs
=
&
z8530_nop
;
outb
(
0
,
iobase
+
4
);
/* DMA off */
/* We want a fast IRQ for this device. Actually we'd like an even faster
IRQ ;) - This is one driver RtLinux is made for */
if
(
request_irq
(
irq
,
&
z8530_interrupt
,
IRQF_DISABLED
,
"Hostess SV11"
,
dev
)
<
0
)
{
if
(
request_irq
(
irq
,
&
z8530_interrupt
,
IRQF_DISABLED
,
"Hostess SV11"
,
sv
)
<
0
)
{
printk
(
KERN_WARNING
"hostess: IRQ %d already in use.
\n
"
,
irq
);
goto
fail1
;
goto
err_irq
;
}
dev
->
irq
=
irq
;
dev
->
chanA
.
private
=
sv
;
dev
->
chanA
.
netdevice
=
sv
->
netdev
.
dev
;
dev
->
chanA
.
dev
=
dev
;
dev
->
chanB
.
dev
=
dev
;
if
(
dma
)
{
sv
->
irq
=
irq
;
sv
->
chanA
.
private
=
sv
;
sv
->
chanA
.
dev
=
sv
;
sv
->
chanB
.
dev
=
sv
;
if
(
dma
)
{
/*
* You can have DMA off or 1 and 3 thats the lot
* on the Comtrol.
*/
dev
->
chanA
.
txdma
=
3
;
dev
->
chanA
.
rxdma
=
1
;
outb
(
0x03
|
0x08
,
iobase
+
4
);
/* DMA on */
if
(
request_dma
(
dev
->
chanA
.
txdma
,
"Hostess SV/11 (TX)"
)
!=
0
)
goto
fail
;
if
(
dma
==
1
)
{
if
(
request_dma
(
dev
->
chanA
.
rxdma
,
"Hostess SV/11 (RX)"
)
!=
0
)
goto
dmafail
;
}
sv
->
chanA
.
txdma
=
3
;
sv
->
chanA
.
rxdma
=
1
;
outb
(
0x03
|
0x08
,
iobase
+
4
);
/* DMA on */
if
(
request_dma
(
sv
->
chanA
.
txdma
,
"Hostess SV/11 (TX)"
))
goto
err_txdma
;
if
(
dma
==
1
)
if
(
request_dma
(
sv
->
chanA
.
rxdma
,
"Hostess SV/11 (RX)"
))
goto
err_rxdma
;
}
/* Kill our private IRQ line the hostess can end up chattering
until the configuration is set */
disable_irq
(
irq
);
/*
* Begin normal initialise
*/
if
(
z8530_init
(
dev
)
!=
0
)
{
if
(
z8530_init
(
sv
))
{
printk
(
KERN_ERR
"Z8530 series device not found.
\n
"
);
enable_irq
(
irq
);
goto
dmafail2
;
goto
free_dma
;
}
z8530_channel_load
(
&
de
v
->
chanB
,
z8530_dead_port
);
if
(
dev
->
type
==
Z85C30
)
z8530_channel_load
(
&
de
v
->
chanA
,
z8530_hdlc_kilostream
);
z8530_channel_load
(
&
s
v
->
chanB
,
z8530_dead_port
);
if
(
sv
->
type
==
Z85C30
)
z8530_channel_load
(
&
s
v
->
chanA
,
z8530_hdlc_kilostream
);
else
z8530_channel_load
(
&
de
v
->
chanA
,
z8530_hdlc_kilostream_85230
);
z8530_channel_load
(
&
s
v
->
chanA
,
z8530_hdlc_kilostream_85230
);
enable_irq
(
irq
);
/*
* Now we can take the IRQ
*/
if
(
dev_alloc_name
(
dev
->
chanA
.
netdevice
,
"hdlc%d"
)
>=
0
)
{
struct
net_device
*
d
=
dev
->
chanA
.
netdevice
;
/*
* Initialise the PPP components
*/
d
->
ml_priv
=
sv
;
sppp_attach
(
&
sv
->
netdev
);
/*
* Local fields
*/
d
->
base_addr
=
iobase
;
d
->
irq
=
irq
;
if
(
register_netdev
(
d
))
{
printk
(
KERN_ERR
"%s: unable to register device.
\n
"
,
d
->
name
);
sppp_detach
(
d
);
goto
dmafail2
;
}
sv
->
chanA
.
netdevice
=
netdev
=
alloc_hdlcdev
(
sv
);
if
(
!
netdev
)
goto
free_dma
;
z8530_describe
(
dev
,
"I/O"
,
iobase
);
dev
->
active
=
1
;
return
sv
;
dev_to_hdlc
(
netdev
)
->
attach
=
hostess_attach
;
dev_to_hdlc
(
netdev
)
->
xmit
=
hostess_queue_xmit
;
netdev
->
open
=
hostess_open
;
netdev
->
stop
=
hostess_close
;
netdev
->
do_ioctl
=
hostess_ioctl
;
netdev
->
base_addr
=
iobase
;
netdev
->
irq
=
irq
;
if
(
register_hdlc_device
(
netdev
))
{
printk
(
KERN_ERR
"hostess: unable to register HDLC device.
\n
"
);
free_netdev
(
netdev
);
goto
free_dma
;
}
dmafail2:
if
(
dma
==
1
)
free_dma
(
dev
->
chanA
.
rxdma
);
dmafail:
if
(
dma
)
free_dma
(
dev
->
chanA
.
txdma
);
fail:
free_irq
(
irq
,
dev
);
fail1:
free_netdev
(
sv
->
netdev
.
dev
);
fail2:
z8530_describe
(
sv
,
"I/O"
,
iobase
);
sv
->
active
=
1
;
return
sv
;
free_dma:
if
(
dma
==
1
)
free_dma
(
sv
->
chanA
.
rxdma
);
err_rxdma:
if
(
dma
)
free_dma
(
sv
->
chanA
.
txdma
);
err_txdma:
free_irq
(
irq
,
sv
);
err_irq:
kfree
(
sv
);
fail3
:
release_region
(
iobase
,
8
);
err_kzalloc
:
release_region
(
iobase
,
8
);
return
NULL
;
}
static
void
sv11_shutdown
(
struct
sv11_device
*
dev
)
static
void
sv11_shutdown
(
struct
z8530_dev
*
dev
)
{
sppp_detach
(
dev
->
netdev
.
dev
);
unregister_netdev
(
dev
->
netdev
.
dev
);
z8530_shutdown
(
&
dev
->
sync
);
free_irq
(
dev
->
sync
.
irq
,
dev
);
if
(
dma
)
{
if
(
dma
==
1
)
free_dma
(
dev
->
sync
.
chanA
.
rxdma
);
free_dma
(
dev
->
sync
.
chanA
.
txdma
);
unregister_hdlc_device
(
dev
->
chanA
.
netdevice
);
z8530_shutdown
(
dev
);
free_irq
(
dev
->
irq
,
dev
);
if
(
dma
)
{
if
(
dma
==
1
)
free_dma
(
dev
->
chanA
.
rxdma
);
free_dma
(
dev
->
chanA
.
txdma
);
}
release_region
(
dev
->
sync
.
chanA
.
ctrlio
-
1
,
8
);
free_netdev
(
dev
->
netdev
.
dev
);
release_region
(
dev
->
chanA
.
ctrlio
-
1
,
8
);
free_netdev
(
dev
->
chanA
.
netdevice
);
kfree
(
dev
);
}
#ifdef MODULE
static
int
io
=
0x200
;
static
int
irq
=
9
;
static
int
io
=
0x200
;
static
int
irq
=
9
;
module_param
(
io
,
int
,
0
);
MODULE_PARM_DESC
(
io
,
"The I/O base of the Comtrol Hostess SV11 card"
);
...
...
@@ -397,22 +328,17 @@ MODULE_AUTHOR("Alan Cox");
MODULE_LICENSE
(
"GPL"
);
MODULE_DESCRIPTION
(
"Modular driver for the Comtrol Hostess SV11"
);
static
struct
sv11_device
*
sv11_unit
;
static
struct
z8530_dev
*
sv11_unit
;
int
init_module
(
void
)
{
printk
(
KERN_INFO
"SV-11 Z85230 Synchronous Driver v 0.03.
\n
"
);
printk
(
KERN_INFO
"(c) Copyright 2001, Red Hat Inc.
\n
"
);
if
((
sv11_unit
=
sv11_init
(
io
,
irq
))
==
NULL
)
if
((
sv11_unit
=
sv11_init
(
io
,
irq
))
==
NULL
)
return
-
ENODEV
;
return
0
;
}
void
cleanup_module
(
void
)
{
if
(
sv11_unit
)
if
(
sv11_unit
)
sv11_shutdown
(
sv11_unit
);
}
#endif
drivers/net/wan/lmc/lmc.h
浏览文件 @
3859069b
...
...
@@ -11,12 +11,12 @@ unsigned lmc_mii_readreg(lmc_softc_t * const sc, unsigned
devaddr
,
unsigned
regno
);
void
lmc_mii_writereg
(
lmc_softc_t
*
const
sc
,
unsigned
devaddr
,
unsigned
regno
,
unsigned
data
);
void
lmc_led_on
(
lmc_softc_t
*
const
,
u
_int32_t
);
void
lmc_led_off
(
lmc_softc_t
*
const
,
u
_int32_t
);
void
lmc_led_on
(
lmc_softc_t
*
const
,
u
32
);
void
lmc_led_off
(
lmc_softc_t
*
const
,
u
32
);
unsigned
lmc_mii_readreg
(
lmc_softc_t
*
const
,
unsigned
,
unsigned
);
void
lmc_mii_writereg
(
lmc_softc_t
*
const
,
unsigned
,
unsigned
,
unsigned
);
void
lmc_gpio_mkinput
(
lmc_softc_t
*
const
sc
,
u
_int32_t
bits
);
void
lmc_gpio_mkoutput
(
lmc_softc_t
*
const
sc
,
u
_int32_t
bits
);
void
lmc_gpio_mkinput
(
lmc_softc_t
*
const
sc
,
u
32
bits
);
void
lmc_gpio_mkoutput
(
lmc_softc_t
*
const
sc
,
u
32
bits
);
int
lmc_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
ifr
,
int
cmd
);
...
...
@@ -26,8 +26,7 @@ extern lmc_media_t lmc_t1_media;
extern
lmc_media_t
lmc_hssi_media
;
#ifdef _DBG_EVENTLOG
static
void
lmcEventLog
(
u_int32_t
EventNum
,
u_int32_t
arg2
,
u_int32_t
arg3
);
static
void
lmcEventLog
(
u32
EventNum
,
u32
arg2
,
u32
arg3
);
#endif
#endif
drivers/net/wan/lmc/lmc_debug.c
浏览文件 @
3859069b
#include <linux/types.h>
#include <linux/netdevice.h>
#include <linux/interrupt.h>
...
...
@@ -48,10 +47,10 @@ void lmcConsoleLog(char *type, unsigned char *ucData, int iLen)
#endif
#ifdef DEBUG
u
_int32_t
lmcEventLogIndex
=
0
;
u
_int32_t
lmcEventLogBuf
[
LMC_EVENTLOGSIZE
*
LMC_EVENTLOGARGS
];
u
32
lmcEventLogIndex
;
u
32
lmcEventLogBuf
[
LMC_EVENTLOGSIZE
*
LMC_EVENTLOGARGS
];
void
lmcEventLog
(
u_int32_t
EventNum
,
u_int32_t
arg2
,
u_int32_t
arg3
)
void
lmcEventLog
(
u32
EventNum
,
u32
arg2
,
u32
arg3
)
{
lmcEventLogBuf
[
lmcEventLogIndex
++
]
=
EventNum
;
lmcEventLogBuf
[
lmcEventLogIndex
++
]
=
arg2
;
...
...
drivers/net/wan/lmc/lmc_debug.h
浏览文件 @
3859069b
...
...
@@ -38,15 +38,15 @@
#ifdef DEBUG
extern
u
_int32_t
lmcEventLogIndex
;
extern
u
_int32_t
lmcEventLogBuf
[
LMC_EVENTLOGSIZE
*
LMC_EVENTLOGARGS
];
extern
u
32
lmcEventLogIndex
;
extern
u
32
lmcEventLogBuf
[
LMC_EVENTLOGSIZE
*
LMC_EVENTLOGARGS
];
#define LMC_EVENT_LOG(x, y, z) lmcEventLog((x), (y), (z))
#else
#define LMC_EVENT_LOG(x,y,z)
#endif
/* end ifdef _DBG_EVENTLOG */
void
lmcConsoleLog
(
char
*
type
,
unsigned
char
*
ucData
,
int
iLen
);
void
lmcEventLog
(
u_int32_t
EventNum
,
u_int32_t
arg2
,
u_int32_t
arg3
);
void
lmcEventLog
(
u32
EventNum
,
u32
arg2
,
u32
arg3
);
void
lmc_trace
(
struct
net_device
*
dev
,
char
*
msg
);
#endif
drivers/net/wan/lmc/lmc_ioctl.h
浏览文件 @
3859069b
...
...
@@ -61,7 +61,7 @@
/*
* IFTYPE defines
*/
#define LMC_PPP 1
/* use
sppp
interface */
#define LMC_PPP 1
/* use
generic HDLC
interface */
#define LMC_NET 2
/* use direct net interface */
#define LMC_RAW 3
/* use direct net interface */
...
...
drivers/net/wan/lmc/lmc_main.c
浏览文件 @
3859069b
此差异已折叠。
点击以展开。
drivers/net/wan/lmc/lmc_media.c
浏览文件 @
3859069b
...
...
@@ -16,8 +16,6 @@
#include <linux/inet.h>
#include <linux/bitops.h>
#include <net/syncppp.h>
#include <asm/processor.h>
/* Processor type for cache alignment. */
#include <asm/io.h>
#include <asm/dma.h>
...
...
@@ -95,8 +93,7 @@ static void lmc_dummy_set_1 (lmc_softc_t * const, int);
static
void
lmc_dummy_set2_1
(
lmc_softc_t
*
const
,
lmc_ctl_t
*
);
static
inline
void
write_av9110_bit
(
lmc_softc_t
*
,
int
);
static
void
write_av9110
(
lmc_softc_t
*
,
u_int32_t
,
u_int32_t
,
u_int32_t
,
u_int32_t
,
u_int32_t
);
static
void
write_av9110
(
lmc_softc_t
*
,
u32
,
u32
,
u32
,
u32
,
u32
);
lmc_media_t
lmc_ds3_media
=
{
lmc_ds3_init
,
/* special media init stuff */
...
...
@@ -427,7 +424,7 @@ lmc_ds3_set_scram (lmc_softc_t * const sc, int ie)
static
int
lmc_ds3_get_link_status
(
lmc_softc_t
*
const
sc
)
{
u
_int16_t
link_status
,
link_status_11
;
u
16
link_status
,
link_status_11
;
int
ret
=
1
;
lmc_mii_writereg
(
sc
,
0
,
17
,
7
);
...
...
@@ -449,7 +446,7 @@ lmc_ds3_get_link_status (lmc_softc_t * const sc)
(
link_status
&
LMC_FRAMER_REG0_OOFS
)){
ret
=
0
;
if
(
sc
->
last_led_err
[
3
]
!=
1
){
u16
r1
;
u16
r1
;
lmc_mii_writereg
(
sc
,
0
,
17
,
01
);
/* Turn on Xbit error as our cisco does */
r1
=
lmc_mii_readreg
(
sc
,
0
,
18
);
r1
&=
0xfe
;
...
...
@@ -462,7 +459,7 @@ lmc_ds3_get_link_status (lmc_softc_t * const sc)
else
{
lmc_led_off
(
sc
,
LMC_DS3_LED3
);
/* turn on red LED */
if
(
sc
->
last_led_err
[
3
]
==
1
){
u16
r1
;
u16
r1
;
lmc_mii_writereg
(
sc
,
0
,
17
,
01
);
/* Turn off Xbit error */
r1
=
lmc_mii_readreg
(
sc
,
0
,
18
);
r1
|=
0x01
;
...
...
@@ -540,20 +537,19 @@ lmc_ds3_watchdog (lmc_softc_t * const sc)
* SSI methods
*/
static
void
lmc_ssi_init
(
lmc_softc_t
*
const
sc
)
static
void
lmc_ssi_init
(
lmc_softc_t
*
const
sc
)
{
u_int16_t
mii17
;
int
cable
;
u16
mii17
;
int
cable
;
sc
->
ictl
.
cardtype
=
LMC_CTL_CARDTYPE_LMC1000
;
sc
->
ictl
.
cardtype
=
LMC_CTL_CARDTYPE_LMC1000
;
mii17
=
lmc_mii_readreg
(
sc
,
0
,
17
);
mii17
=
lmc_mii_readreg
(
sc
,
0
,
17
);
cable
=
(
mii17
&
LMC_MII17_SSI_CABLE_MASK
)
>>
LMC_MII17_SSI_CABLE_SHIFT
;
sc
->
ictl
.
cable_type
=
cable
;
cable
=
(
mii17
&
LMC_MII17_SSI_CABLE_MASK
)
>>
LMC_MII17_SSI_CABLE_SHIFT
;
sc
->
ictl
.
cable_type
=
cable
;
lmc_gpio_mkoutput
(
sc
,
LMC_GEP_SSI_TXCLOCK
);
lmc_gpio_mkoutput
(
sc
,
LMC_GEP_SSI_TXCLOCK
);
}
static
void
...
...
@@ -681,11 +677,11 @@ lmc_ssi_set_speed (lmc_softc_t * const sc, lmc_ctl_t * ctl)
static
int
lmc_ssi_get_link_status
(
lmc_softc_t
*
const
sc
)
{
u
_int16_t
link_status
;
u
_int32_t
ticks
;
u
16
link_status
;
u
32
ticks
;
int
ret
=
1
;
int
hw_hdsk
=
1
;
/*
* missing CTS? Hmm. If we require CTS on, we may never get the
* link to come up, so omit it in this test.
...
...
@@ -720,9 +716,9 @@ lmc_ssi_get_link_status (lmc_softc_t * const sc)
}
else
if
(
ticks
==
0
)
{
/* no clock found ? */
ret
=
0
;
if
(
sc
->
last_led_err
[
3
]
!=
1
)
{
sc
->
stats
.
tx_lossOfClockCnt
++
;
printk
(
KERN_WARNING
"%s: Lost Clock, Link Down
\n
"
,
sc
->
name
);
if
(
sc
->
last_led_err
[
3
]
!=
1
)
{
sc
->
extra_
stats
.
tx_lossOfClockCnt
++
;
printk
(
KERN_WARNING
"%s: Lost Clock, Link Down
\n
"
,
sc
->
name
);
}
sc
->
last_led_err
[
3
]
=
1
;
lmc_led_on
(
sc
,
LMC_MII16_LED3
);
/* turn ON red LED */
...
...
@@ -838,9 +834,7 @@ write_av9110_bit (lmc_softc_t * sc, int c)
LMC_CSR_WRITE
(
sc
,
csr_gp
,
sc
->
lmc_gpio
);
}
static
void
write_av9110
(
lmc_softc_t
*
sc
,
u_int32_t
n
,
u_int32_t
m
,
u_int32_t
v
,
u_int32_t
x
,
u_int32_t
r
)
static
void
write_av9110
(
lmc_softc_t
*
sc
,
u32
n
,
u32
m
,
u32
v
,
u32
x
,
u32
r
)
{
int
i
;
...
...
@@ -887,19 +881,13 @@ write_av9110 (lmc_softc_t * sc, u_int32_t n, u_int32_t m, u_int32_t v,
|
LMC_GEP_SSI_GENERATOR
));
}
static
void
lmc_ssi_watchdog
(
lmc_softc_t
*
const
sc
)
static
void
lmc_ssi_watchdog
(
lmc_softc_t
*
const
sc
)
{
u_int16_t
mii17
=
lmc_mii_readreg
(
sc
,
0
,
17
);
if
(((
mii17
>>
3
)
&
7
)
==
7
)
{
lmc_led_off
(
sc
,
LMC_MII16_LED2
);
}
else
{
lmc_led_on
(
sc
,
LMC_MII16_LED2
);
}
u16
mii17
=
lmc_mii_readreg
(
sc
,
0
,
17
);
if
(((
mii17
>>
3
)
&
7
)
==
7
)
lmc_led_off
(
sc
,
LMC_MII16_LED2
);
else
lmc_led_on
(
sc
,
LMC_MII16_LED2
);
}
/*
...
...
@@ -929,7 +917,7 @@ lmc_t1_read (lmc_softc_t * const sc, int a)
static
void
lmc_t1_init
(
lmc_softc_t
*
const
sc
)
{
u
_int16_t
mii16
;
u
16
mii16
;
int
i
;
sc
->
ictl
.
cardtype
=
LMC_CTL_CARDTYPE_LMC1200
;
...
...
@@ -1028,7 +1016,7 @@ lmc_t1_set_status (lmc_softc_t * const sc, lmc_ctl_t * ctl)
*/
static
int
lmc_t1_get_link_status
(
lmc_softc_t
*
const
sc
)
{
u
_int16_t
link_status
;
u
16
link_status
;
int
ret
=
1
;
/* LMC5245 (DS3) & LMC1200 (DS1) LED definitions
...
...
drivers/net/wan/lmc/lmc_proto.c
浏览文件 @
3859069b
...
...
@@ -36,9 +36,6 @@
#include <linux/workqueue.h>
#include <linux/proc_fs.h>
#include <linux/bitops.h>
#include <net/syncppp.h>
#include <asm/processor.h>
/* Processor type for cache alignment. */
#include <asm/io.h>
#include <asm/dma.h>
...
...
@@ -50,48 +47,6 @@
#include "lmc_ioctl.h"
#include "lmc_proto.h"
/*
* The compile-time variable SPPPSTUP causes the module to be
* compiled without referencing any of the sync ppp routines.
*/
#ifdef SPPPSTUB
#define SPPP_detach(d) (void)0
#define SPPP_open(d) 0
#define SPPP_reopen(d) (void)0
#define SPPP_close(d) (void)0
#define SPPP_attach(d) (void)0
#define SPPP_do_ioctl(d,i,c) -EOPNOTSUPP
#else
#define SPPP_attach(x) sppp_attach((x)->pd)
#define SPPP_detach(x) sppp_detach((x)->pd->dev)
#define SPPP_open(x) sppp_open((x)->pd->dev)
#define SPPP_reopen(x) sppp_reopen((x)->pd->dev)
#define SPPP_close(x) sppp_close((x)->pd->dev)
#define SPPP_do_ioctl(x, y, z) sppp_do_ioctl((x)->pd->dev, (y), (z))
#endif
// init
void
lmc_proto_init
(
lmc_softc_t
*
sc
)
/*FOLD00*/
{
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_init in"
);
switch
(
sc
->
if_type
){
case
LMC_PPP
:
sc
->
pd
=
kmalloc
(
sizeof
(
struct
ppp_device
),
GFP_KERNEL
);
if
(
!
sc
->
pd
)
{
printk
(
"lmc_proto_init(): kmalloc failure!
\n
"
);
return
;
}
sc
->
pd
->
dev
=
sc
->
lmc_device
;
sc
->
if_ptr
=
sc
->
pd
;
break
;
case
LMC_RAW
:
break
;
default:
break
;
}
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_init out"
);
}
// attach
void
lmc_proto_attach
(
lmc_softc_t
*
sc
)
/*FOLD00*/
{
...
...
@@ -100,7 +55,6 @@ void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
case
LMC_PPP
:
{
struct
net_device
*
dev
=
sc
->
lmc_device
;
SPPP_attach
(
sc
);
dev
->
do_ioctl
=
lmc_ioctl
;
}
break
;
...
...
@@ -108,7 +62,7 @@ void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
{
struct
net_device
*
dev
=
sc
->
lmc_device
;
/*
* They set a few basics because they don't use sync_ppp
* They set a few basics because they don't use HDLC
*/
dev
->
flags
|=
IFF_POINTOPOINT
;
...
...
@@ -124,88 +78,39 @@ void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_attach out"
);
}
// detach
void
lmc_proto_detach
(
lmc_softc_t
*
sc
)
/*FOLD00*/
int
lmc_proto_ioctl
(
lmc_softc_t
*
sc
,
struct
ifreq
*
ifr
,
int
cmd
)
{
switch
(
sc
->
if_type
){
case
LMC_PPP
:
SPPP_detach
(
sc
);
break
;
case
LMC_RAW
:
/* Tell someone we're detaching? */
break
;
default:
break
;
}
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_ioctl"
);
if
(
sc
->
if_type
==
LMC_PPP
)
return
hdlc_ioctl
(
sc
->
lmc_device
,
ifr
,
cmd
);
return
-
EOPNOTSUPP
;
}
// reopen
void
lmc_proto_reopen
(
lmc_softc_t
*
sc
)
/*FOLD00*/
int
lmc_proto_open
(
lmc_softc_t
*
sc
)
{
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_reopen in"
);
switch
(
sc
->
if_type
){
case
LMC_PPP
:
SPPP_reopen
(
sc
);
break
;
case
LMC_RAW
:
/* Reset the interface after being down, prerape to receive packets again */
break
;
default:
break
;
}
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_reopen out"
);
}
int
ret
=
0
;
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_open in"
);
// ioctl
int
lmc_proto_ioctl
(
lmc_softc_t
*
sc
,
struct
ifreq
*
ifr
,
int
cmd
)
/*FOLD00*/
{
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_ioctl out"
);
switch
(
sc
->
if_type
){
case
LMC_PPP
:
return
SPPP_do_ioctl
(
sc
,
ifr
,
cmd
);
break
;
default:
return
-
EOPNOTSUPP
;
break
;
}
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_ioctl out"
);
if
(
sc
->
if_type
==
LMC_PPP
)
{
ret
=
hdlc_open
(
sc
->
lmc_device
);
if
(
ret
<
0
)
printk
(
KERN_WARNING
"%s: HDLC open failed: %d
\n
"
,
sc
->
name
,
ret
);
}
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_open out"
);
return
ret
;
}
// open
void
lmc_proto_open
(
lmc_softc_t
*
sc
)
/*FOLD00*/
void
lmc_proto_close
(
lmc_softc_t
*
sc
)
{
int
ret
;
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_close in"
)
;
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_open in"
);
switch
(
sc
->
if_type
){
case
LMC_PPP
:
ret
=
SPPP_open
(
sc
);
if
(
ret
<
0
)
printk
(
"%s: syncPPP open failed: %d
\n
"
,
sc
->
name
,
ret
);
break
;
case
LMC_RAW
:
/* We're about to start getting packets! */
break
;
default:
break
;
}
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_open out"
);
}
// close
if
(
sc
->
if_type
==
LMC_PPP
)
hdlc_close
(
sc
->
lmc_device
);
void
lmc_proto_close
(
lmc_softc_t
*
sc
)
/*FOLD00*/
{
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_close in"
);
switch
(
sc
->
if_type
){
case
LMC_PPP
:
SPPP_close
(
sc
);
break
;
case
LMC_RAW
:
/* Interface going down */
break
;
default:
break
;
}
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_close out"
);
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_close out"
);
}
__be16
lmc_proto_type
(
lmc_softc_t
*
sc
,
struct
sk_buff
*
skb
)
/*FOLD00*/
...
...
@@ -213,8 +118,8 @@ __be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_type in"
);
switch
(
sc
->
if_type
){
case
LMC_PPP
:
return
htons
(
ETH_P_WAN_PPP
);
break
;
return
hdlc_type_trans
(
skb
,
sc
->
lmc_device
);
break
;
case
LMC_NET
:
return
htons
(
ETH_P_802_2
);
break
;
...
...
@@ -245,4 +150,3 @@ void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
}
lmc_trace
(
sc
->
lmc_device
,
"lmc_proto_netif out"
);
}
drivers/net/wan/lmc/lmc_proto.h
浏览文件 @
3859069b
#ifndef _LMC_PROTO_H_
#define _LMC_PROTO_H_
void
lmc_proto_init
(
lmc_softc_t
*
sc
);
#include <linux/hdlc.h>
void
lmc_proto_attach
(
lmc_softc_t
*
sc
);
void
lmc_proto_detach
(
lmc_softc_t
*
sc
);
void
lmc_proto_reopen
(
lmc_softc_t
*
sc
);
int
lmc_proto_ioctl
(
lmc_softc_t
*
sc
,
struct
ifreq
*
ifr
,
int
cmd
);
void
lmc_proto_open
(
lmc_softc_t
*
sc
);
int
lmc_proto_open
(
lmc_softc_t
*
sc
);
void
lmc_proto_close
(
lmc_softc_t
*
sc
);
__be16
lmc_proto_type
(
lmc_softc_t
*
sc
,
struct
sk_buff
*
skb
);
void
lmc_proto_netif
(
lmc_softc_t
*
sc
,
struct
sk_buff
*
skb
);
int
lmc_skb_rawpackets
(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
len
,
int
unused
);
#endif
static
inline
lmc_softc_t
*
dev_to_sc
(
struct
net_device
*
dev
)
{
return
(
lmc_softc_t
*
)
dev_to_hdlc
(
dev
)
->
priv
;
}
#endif
drivers/net/wan/lmc/lmc_var.h
浏览文件 @
3859069b
#ifndef _LMC_VAR_H_
#define _LMC_VAR_H_
/* $Id: lmc_var.h,v 1.17 2000/04/06 12:16:47 asj Exp $ */
/*
* Copyright (c) 1997-2000 LAN Media Corporation (LMC)
* All rights reserved. www.lanmedia.com
...
...
@@ -19,23 +17,6 @@
#include <linux/timer.h>
#ifndef __KERNEL__
typedef
signed
char
s8
;
typedef
unsigned
char
u8
;
typedef
signed
short
s16
;
typedef
unsigned
short
u16
;
typedef
signed
int
s32
;
typedef
unsigned
int
u32
;
typedef
signed
long
long
s64
;
typedef
unsigned
long
long
u64
;
#define BITS_PER_LONG 32
#endif
/*
* basic definitions used in lmc include files
*/
...
...
@@ -45,9 +26,6 @@ typedef struct lmc___media lmc_media_t;
typedef
struct
lmc___ctl
lmc_ctl_t
;
#define lmc_csrptr_t unsigned long
#define u_int16_t u16
#define u_int8_t u8
#define tulip_uint32_t u32
#define LMC_REG_RANGE 0x80
...
...
@@ -122,45 +100,45 @@ struct lmc_regfile_t {
* used to define bits in the second tulip_desc_t field (length)
* for the transmit descriptor -baz */
#define LMC_TDES_FIRST_BUFFER_SIZE ((u
_int32_t
)(0x000007FF))
#define LMC_TDES_SECOND_BUFFER_SIZE ((u
_int32_t
)(0x003FF800))
#define LMC_TDES_HASH_FILTERING ((u
_int32_t
)(0x00400000))
#define LMC_TDES_DISABLE_PADDING ((u
_int32_t
)(0x00800000))
#define LMC_TDES_SECOND_ADDR_CHAINED ((u
_int32_t
)(0x01000000))
#define LMC_TDES_END_OF_RING ((u
_int32_t
)(0x02000000))
#define LMC_TDES_ADD_CRC_DISABLE ((u
_int32_t
)(0x04000000))
#define LMC_TDES_SETUP_PACKET ((u
_int32_t
)(0x08000000))
#define LMC_TDES_INVERSE_FILTERING ((u
_int32_t
)(0x10000000))
#define LMC_TDES_FIRST_SEGMENT ((u
_int32_t
)(0x20000000))
#define LMC_TDES_LAST_SEGMENT ((u
_int32_t
)(0x40000000))
#define LMC_TDES_INTERRUPT_ON_COMPLETION ((u
_int32_t
)(0x80000000))
#define LMC_TDES_FIRST_BUFFER_SIZE ((u
32
)(0x000007FF))
#define LMC_TDES_SECOND_BUFFER_SIZE ((u
32
)(0x003FF800))
#define LMC_TDES_HASH_FILTERING ((u
32
)(0x00400000))
#define LMC_TDES_DISABLE_PADDING ((u
32
)(0x00800000))
#define LMC_TDES_SECOND_ADDR_CHAINED ((u
32
)(0x01000000))
#define LMC_TDES_END_OF_RING ((u
32
)(0x02000000))
#define LMC_TDES_ADD_CRC_DISABLE ((u
32
)(0x04000000))
#define LMC_TDES_SETUP_PACKET ((u
32
)(0x08000000))
#define LMC_TDES_INVERSE_FILTERING ((u
32
)(0x10000000))
#define LMC_TDES_FIRST_SEGMENT ((u
32
)(0x20000000))
#define LMC_TDES_LAST_SEGMENT ((u
32
)(0x40000000))
#define LMC_TDES_INTERRUPT_ON_COMPLETION ((u
32
)(0x80000000))
#define TDES_SECOND_BUFFER_SIZE_BIT_NUMBER 11
#define TDES_COLLISION_COUNT_BIT_NUMBER 3
/* Constants for the RCV descriptor RDES */
#define LMC_RDES_OVERFLOW ((u
_int32_t
)(0x00000001))
#define LMC_RDES_CRC_ERROR ((u
_int32_t
)(0x00000002))
#define LMC_RDES_DRIBBLING_BIT
((u_int32_t
)(0x00000004))
#define LMC_RDES_REPORT_ON_MII_ERR ((u
_int32_t
)(0x00000008))
#define LMC_RDES_RCV_WATCHDOG_TIMEOUT ((u
_int32_t
)(0x00000010))
#define LMC_RDES_FRAME_TYPE ((u
_int32_t
)(0x00000020))
#define LMC_RDES_COLLISION_SEEN ((u
_int32_t
)(0x00000040))
#define LMC_RDES_FRAME_TOO_LONG ((u
_int32_t
)(0x00000080))
#define LMC_RDES_LAST_DESCRIPTOR ((u
_int32_t
)(0x00000100))
#define LMC_RDES_FIRST_DESCRIPTOR ((u
_int32_t
)(0x00000200))
#define LMC_RDES_MULTICAST_FRAME ((u
_int32_t
)(0x00000400))
#define LMC_RDES_RUNT_FRAME ((u
_int32_t
)(0x00000800))
#define LMC_RDES_DATA_TYPE ((u
_int32_t
)(0x00003000))
#define LMC_RDES_LENGTH_ERROR ((u
_int32_t
)(0x00004000))
#define LMC_RDES_ERROR_SUMMARY ((u
_int32_t
)(0x00008000))
#define LMC_RDES_FRAME_LENGTH ((u
_int32_t
)(0x3FFF0000))
#define LMC_RDES_OWN_BIT ((u
_int32_t
)(0x80000000))
#define LMC_RDES_OVERFLOW ((u
32
)(0x00000001))
#define LMC_RDES_CRC_ERROR ((u
32
)(0x00000002))
#define LMC_RDES_DRIBBLING_BIT
((u32
)(0x00000004))
#define LMC_RDES_REPORT_ON_MII_ERR ((u
32
)(0x00000008))
#define LMC_RDES_RCV_WATCHDOG_TIMEOUT ((u
32
)(0x00000010))
#define LMC_RDES_FRAME_TYPE ((u
32
)(0x00000020))
#define LMC_RDES_COLLISION_SEEN ((u
32
)(0x00000040))
#define LMC_RDES_FRAME_TOO_LONG ((u
32
)(0x00000080))
#define LMC_RDES_LAST_DESCRIPTOR ((u
32
)(0x00000100))
#define LMC_RDES_FIRST_DESCRIPTOR ((u
32
)(0x00000200))
#define LMC_RDES_MULTICAST_FRAME ((u
32
)(0x00000400))
#define LMC_RDES_RUNT_FRAME ((u
32
)(0x00000800))
#define LMC_RDES_DATA_TYPE ((u
32
)(0x00003000))
#define LMC_RDES_LENGTH_ERROR ((u
32
)(0x00004000))
#define LMC_RDES_ERROR_SUMMARY ((u
32
)(0x00008000))
#define LMC_RDES_FRAME_LENGTH ((u
32
)(0x3FFF0000))
#define LMC_RDES_OWN_BIT ((u
32
)(0x80000000))
#define RDES_FRAME_LENGTH_BIT_NUMBER 16
#define LMC_RDES_ERROR_MASK ( (u
_int32_t
)( \
#define LMC_RDES_ERROR_MASK ( (u
32
)( \
LMC_RDES_OVERFLOW \
| LMC_RDES_DRIBBLING_BIT \
| LMC_RDES_REPORT_ON_MII_ERR \
...
...
@@ -172,32 +150,32 @@ struct lmc_regfile_t {
*/
typedef
struct
{
u
_int32_t
n
;
u
_int32_t
m
;
u
_int32_t
v
;
u
_int32_t
x
;
u
_int32_t
r
;
u
_int32_t
f
;
u
_int32_t
exact
;
u
32
n
;
u
32
m
;
u
32
v
;
u
32
x
;
u
32
r
;
u
32
f
;
u
32
exact
;
}
lmc_av9110_t
;
/*
* Common structure passed to the ioctl code.
*/
struct
lmc___ctl
{
u
_int32_t
cardtype
;
u
_int32_t
clock_source
;
/* HSSI, T1 */
u
_int32_t
clock_rate
;
/* T1 */
u
_int32_t
crc_length
;
u
_int32_t
cable_length
;
/* DS3 */
u
_int32_t
scrambler_onoff
;
/* DS3 */
u
_int32_t
cable_type
;
/* T1 */
u
_int32_t
keepalive_onoff
;
/* protocol */
u
_int32_t
ticks
;
/* ticks/sec */
u
32
cardtype
;
u
32
clock_source
;
/* HSSI, T1 */
u
32
clock_rate
;
/* T1 */
u
32
crc_length
;
u
32
cable_length
;
/* DS3 */
u
32
scrambler_onoff
;
/* DS3 */
u
32
cable_type
;
/* T1 */
u
32
keepalive_onoff
;
/* protocol */
u
32
ticks
;
/* ticks/sec */
union
{
lmc_av9110_t
ssi
;
}
cardspec
;
u
_int32_t
circuit_type
;
/* T1 or E1 */
u
32
circuit_type
;
/* T1 or E1 */
};
...
...
@@ -244,108 +222,69 @@ struct lmc___media {
#define STATCHECK 0xBEEFCAFE
/* Included in this structure are first
* - standard net_device_stats
* - some other counters used for debug and driver performance
* evaluation -baz
*/
struct
lmc_statistics
struct
lmc_extra_statistics
{
unsigned
long
rx_packets
;
/* total packets received */
unsigned
long
tx_packets
;
/* total packets transmitted */
unsigned
long
rx_bytes
;
unsigned
long
tx_bytes
;
unsigned
long
rx_errors
;
/* bad packets received */
unsigned
long
tx_errors
;
/* packet transmit problems */
unsigned
long
rx_dropped
;
/* no space in linux buffers */
unsigned
long
tx_dropped
;
/* no space available in linux */
unsigned
long
multicast
;
/* multicast packets received */
unsigned
long
collisions
;
/* detailed rx_errors: */
unsigned
long
rx_length_errors
;
unsigned
long
rx_over_errors
;
/* receiver ring buff overflow */
unsigned
long
rx_crc_errors
;
/* recved pkt with crc error */
unsigned
long
rx_frame_errors
;
/* recv'd frame alignment error */
unsigned
long
rx_fifo_errors
;
/* recv'r fifo overrun */
unsigned
long
rx_missed_errors
;
/* receiver missed packet */
/* detailed tx_errors */
unsigned
long
tx_aborted_errors
;
unsigned
long
tx_carrier_errors
;
unsigned
long
tx_fifo_errors
;
unsigned
long
tx_heartbeat_errors
;
unsigned
long
tx_window_errors
;
/* for cslip etc */
unsigned
long
rx_compressed
;
unsigned
long
tx_compressed
;
/* -------------------------------------
* Custom stats & counters follow -baz */
u_int32_t
version_size
;
u_int32_t
lmc_cardtype
;
u_int32_t
tx_ProcTimeout
;
u_int32_t
tx_IntTimeout
;
u_int32_t
tx_NoCompleteCnt
;
u_int32_t
tx_MaxXmtsB4Int
;
u_int32_t
tx_TimeoutCnt
;
u_int32_t
tx_OutOfSyncPtr
;
u_int32_t
tx_tbusy0
;
u_int32_t
tx_tbusy1
;
u_int32_t
tx_tbusy_calls
;
u_int32_t
resetCount
;
u_int32_t
lmc_txfull
;
u_int32_t
tbusy
;
u_int32_t
dirtyTx
;
u_int32_t
lmc_next_tx
;
u_int32_t
otherTypeCnt
;
u_int32_t
lastType
;
u_int32_t
lastTypeOK
;
u_int32_t
txLoopCnt
;
u_int32_t
usedXmtDescripCnt
;
u_int32_t
txIndexCnt
;
u_int32_t
rxIntLoopCnt
;
u_int32_t
rx_SmallPktCnt
;
u_int32_t
rx_BadPktSurgeCnt
;
u_int32_t
rx_BuffAllocErr
;
u_int32_t
tx_lossOfClockCnt
;
/* T1 error counters */
u_int32_t
framingBitErrorCount
;
u_int32_t
lineCodeViolationCount
;
u_int32_t
lossOfFrameCount
;
u_int32_t
changeOfFrameAlignmentCount
;
u_int32_t
severelyErroredFrameCount
;
u_int32_t
check
;
u32
version_size
;
u32
lmc_cardtype
;
u32
tx_ProcTimeout
;
u32
tx_IntTimeout
;
u32
tx_NoCompleteCnt
;
u32
tx_MaxXmtsB4Int
;
u32
tx_TimeoutCnt
;
u32
tx_OutOfSyncPtr
;
u32
tx_tbusy0
;
u32
tx_tbusy1
;
u32
tx_tbusy_calls
;
u32
resetCount
;
u32
lmc_txfull
;
u32
tbusy
;
u32
dirtyTx
;
u32
lmc_next_tx
;
u32
otherTypeCnt
;
u32
lastType
;
u32
lastTypeOK
;
u32
txLoopCnt
;
u32
usedXmtDescripCnt
;
u32
txIndexCnt
;
u32
rxIntLoopCnt
;
u32
rx_SmallPktCnt
;
u32
rx_BadPktSurgeCnt
;
u32
rx_BuffAllocErr
;
u32
tx_lossOfClockCnt
;
/* T1 error counters */
u32
framingBitErrorCount
;
u32
lineCodeViolationCount
;
u32
lossOfFrameCount
;
u32
changeOfFrameAlignmentCount
;
u32
severelyErroredFrameCount
;
u32
check
;
};
typedef
struct
lmc_xinfo
{
u_int32_t
Magic0
;
/* BEEFCAFE */
u32
Magic0
;
/* BEEFCAFE */
u_int32_t
PciCardType
;
u_int32_t
PciSlotNumber
;
/* PCI slot number */
u32
PciCardType
;
u32
PciSlotNumber
;
/* PCI slot number */
u_int16_t
DriverMajorVersion
;
u_int16_t
DriverMinorVersion
;
u_int16_t
DriverSubVersion
;
u16
DriverMajorVersion
;
u16
DriverMinorVersion
;
u16
DriverSubVersion
;
u_int16_t
XilinxRevisionNumber
;
u_int16_t
MaxFrameSize
;
u16
XilinxRevisionNumber
;
u16
MaxFrameSize
;
u_int16_t
t1_alarm1_status
;
u_int16_t
t1_alarm2_status
;
u16
t1_alarm1_status
;
u16
t1_alarm2_status
;
int
link_status
;
u_int32_t
mii_reg16
;
int
link_status
;
u32
mii_reg16
;
u_int32_t
Magic1
;
/* DEADBEEF */
u32
Magic1
;
/* DEADBEEF */
}
LMC_XINFO
;
...
...
@@ -353,23 +292,22 @@ typedef struct lmc_xinfo {
* forward decl
*/
struct
lmc___softc
{
void
*
if_ptr
;
/* General purpose pointer (used by SPPP) */
char
*
name
;
u8
board_idx
;
struct
lmc_
statistics
stats
;
struct
net_device
*
lmc_device
;
struct
lmc_
extra_statistics
extra_
stats
;
struct
net_device
*
lmc_device
;
int
hang
,
rxdesc
,
bad_packet
,
some_counter
;
u
_int32_t
txgo
;
u
32
txgo
;
struct
lmc_regfile_t
lmc_csrs
;
volatile
u
_int32_t
lmc_txtick
;
volatile
u
_int32_t
lmc_rxtick
;
u
_int32_t
lmc_flags
;
u
_int32_t
lmc_intrmask
;
/* our copy of csr_intr */
u
_int32_t
lmc_cmdmode
;
/* our copy of csr_cmdmode */
u
_int32_t
lmc_busmode
;
/* our copy of csr_busmode */
u
_int32_t
lmc_gpio_io
;
/* state of in/out settings */
u
_int32_t
lmc_gpio
;
/* state of outputs */
volatile
u
32
lmc_txtick
;
volatile
u
32
lmc_rxtick
;
u
32
lmc_flags
;
u
32
lmc_intrmask
;
/* our copy of csr_intr */
u
32
lmc_cmdmode
;
/* our copy of csr_cmdmode */
u
32
lmc_busmode
;
/* our copy of csr_busmode */
u
32
lmc_gpio_io
;
/* state of in/out settings */
u
32
lmc_gpio
;
/* state of outputs */
struct
sk_buff
*
lmc_txq
[
LMC_TXDESCS
];
struct
sk_buff
*
lmc_rxq
[
LMC_RXDESCS
];
volatile
...
...
@@ -381,42 +319,41 @@ struct lmc___softc {
unsigned
int
lmc_taint_tx
,
lmc_taint_rx
;
int
lmc_tx_start
,
lmc_txfull
;
int
lmc_txbusy
;
u
_int16_t
lmc_miireg16
;
u
16
lmc_miireg16
;
int
lmc_ok
;
int
last_link_status
;
int
lmc_cardtype
;
u
_int32_t
last_frameerr
;
u
32
last_frameerr
;
lmc_media_t
*
lmc_media
;
struct
timer_list
timer
;
lmc_ctl_t
ictl
;
u
_int32_t
TxDescriptControlInit
;
u
32
TxDescriptControlInit
;
int
tx_TimeoutInd
;
/* additional driver state */
int
tx_TimeoutDisplay
;
unsigned
int
lastlmc_taint_tx
;
int
lasttx_packets
;
u
_int32_t
tx_clockState
;
u
_int32_t
lmc_crcSize
;
LMC_XINFO
lmc_xinfo
;
u
32
tx_clockState
;
u
32
lmc_crcSize
;
LMC_XINFO
lmc_xinfo
;
char
lmc_yel
,
lmc_blue
,
lmc_red
;
/* for T1 and DS3 */
char
lmc_timing
;
/* for HSSI and SSI */
int
got_irq
;
char
lmc_timing
;
/* for HSSI and SSI */
int
got_irq
;
char
last_led_err
[
4
];
char
last_led_err
[
4
];
u32
last_int
;
u32
num_int
;
u32
last_int
;
u32
num_int
;
spinlock_t
lmc_lock
;
u_int16_t
if_type
;
/* PPP or NET */
struct
ppp_device
*
pd
;
u16
if_type
;
/* HDLC/PPP or NET */
/* Failure cases */
u8
failed_ring
;
u8
failed_recv_alloc
;
/* Failure cases */
u8
failed_ring
;
u8
failed_recv_alloc
;
/* Structure check */
u32
check
;
/* Structure check */
u32
check
;
};
#define LMC_PCI_TIME 1
...
...
@@ -512,8 +449,8 @@ struct lmc___softc {
| TULIP_STS_TXUNDERFLOW\
| TULIP_STS_RXSTOPPED )
#define DESC_OWNED_BY_SYSTEM ((u
_int32_t
)(0x00000000))
#define DESC_OWNED_BY_DC21X4 ((u
_int32_t
)(0x80000000))
#define DESC_OWNED_BY_SYSTEM ((u
32
)(0x00000000))
#define DESC_OWNED_BY_DC21X4 ((u
32
)(0x80000000))
#ifndef TULIP_CMD_RECEIVEALL
#define TULIP_CMD_RECEIVEALL 0x40000000L
...
...
@@ -525,46 +462,9 @@ struct lmc___softc {
#define LMC_ADAP_SSI 4
#define LMC_ADAP_T1 5
#define HDLC_HDR_LEN 4
#define HDLC_ADDR_LEN 1
#define HDLC_SLARP 0x8035
#define LMC_MTU 1500
#define SLARP_LINECHECK 2
#define LMC_CRC_LEN_16 2
/* 16-bit CRC */
#define LMC_CRC_LEN_32 4
#ifdef LMC_HDLC
/* definition of an hdlc header. */
struct
hdlc_hdr
{
u8
address
;
u8
control
;
u16
type
;
};
/* definition of a slarp header. */
struct
slarp
{
long
code
;
union
sl
{
struct
{
ulong
address
;
ulong
mask
;
ushort
unused
;
}
add
;
struct
{
ulong
mysequence
;
ulong
yoursequence
;
ushort
reliability
;
ulong
time
;
}
chk
;
}
t
;
};
#endif
/* LMC_HDLC */
#endif
/* _LMC_VAR_H_ */
drivers/net/wan/pc300.h
浏览文件 @
3859069b
...
...
@@ -100,31 +100,14 @@
#define _PC300_H
#include <linux/hdlc.h>
#include <net/syncppp.h>
#include "hd64572.h"
#include "pc300-falc-lh.h"
#ifndef CY_TYPES
#define CY_TYPES
typedef
__u64
ucdouble
;
/* 64 bits, unsigned */
typedef
__u32
uclong
;
/* 32 bits, unsigned */
typedef
__u16
ucshort
;
/* 16 bits, unsigned */
typedef
__u8
ucchar
;
/* 8 bits, unsigned */
#endif
/* CY_TYPES */
#define PC300_PROTO_MLPPP 1
#define PC300_PROTO_MLPPP 1
#define PC300_KERNEL "2.4.x"
/* Kernel supported by this driver */
#define PC300_DEVNAME "hdlc"
/* Dev. name base (for hdlc0, hdlc1, etc.) */
#define PC300_MAXINDEX 100
/* Max dev. name index (the '0' in hdlc0) */
#define PC300_MAXCARDS 4
/* Max number of cards per system */
#define PC300_MAXCHAN 2
/* Number of channels per card */
#define PC300_PLX_WIN 0x80
/* PLX control window size (128b) */
#define PC300_RAMSIZE 0x40000
/* RAM window size (256Kb) */
#define PC300_SCASIZE 0x400
/* SCA window size (1Kb) */
#define PC300_FALCSIZE 0x400
/* FALC window size (1Kb) */
#define PC300_OSC_CLOCK 24576000
...
...
@@ -160,26 +143,14 @@ typedef __u8 ucchar; /* 8 bits, unsigned */
* Memory access functions/macros *
* (required to support Alpha systems) *
***************************************/
#ifdef __KERNEL__
#define cpc_writeb(port,val) {writeb((ucchar)(val),(port)); mb();}
#define cpc_writeb(port,val) {writeb((u8)(val),(port)); mb();}
#define cpc_writew(port,val) {writew((ushort)(val),(port)); mb();}
#define cpc_writel(port,val) {writel((u
clong
)(val),(port)); mb();}
#define cpc_writel(port,val) {writel((u
32
)(val),(port)); mb();}
#define cpc_readb(port) readb(port)
#define cpc_readw(port) readw(port)
#define cpc_readl(port) readl(port)
#else
/* __KERNEL__ */
#define cpc_writeb(port,val) (*(volatile ucchar *)(port) = (ucchar)(val))
#define cpc_writew(port,val) (*(volatile ucshort *)(port) = (ucshort)(val))
#define cpc_writel(port,val) (*(volatile uclong *)(port) = (uclong)(val))
#define cpc_readb(port) (*(volatile ucchar *)(port))
#define cpc_readw(port) (*(volatile ucshort *)(port))
#define cpc_readl(port) (*(volatile uclong *)(port))
#endif
/* __KERNEL__ */
/****** Data Structures *****************************************************/
/*
...
...
@@ -188,15 +159,15 @@ typedef __u8 ucchar; /* 8 bits, unsigned */
* (memory mapped).
*/
struct
RUNTIME_9050
{
u
clong
loc_addr_range
[
4
];
/* 00-0Ch : Local Address Ranges */
u
clong
loc_rom_range
;
/* 10h : Local ROM Range */
u
clong
loc_addr_base
[
4
];
/* 14-20h : Local Address Base Addrs */
u
clong
loc_rom_base
;
/* 24h : Local ROM Base */
u
clong
loc_bus_descr
[
4
];
/* 28-34h : Local Bus Descriptors */
u
clong
rom_bus_descr
;
/* 38h : ROM Bus Descriptor */
u
clong
cs_base
[
4
];
/* 3C-48h : Chip Select Base Addrs */
u
clong
intr_ctrl_stat
;
/* 4Ch : Interrupt Control/Status */
u
clong
init_ctrl
;
/* 50h : EEPROM ctrl, Init Ctrl, etc */
u
32
loc_addr_range
[
4
];
/* 00-0Ch : Local Address Ranges */
u
32
loc_rom_range
;
/* 10h : Local ROM Range */
u
32
loc_addr_base
[
4
];
/* 14-20h : Local Address Base Addrs */
u
32
loc_rom_base
;
/* 24h : Local ROM Base */
u
32
loc_bus_descr
[
4
];
/* 28-34h : Local Bus Descriptors */
u
32
rom_bus_descr
;
/* 38h : ROM Bus Descriptor */
u
32
cs_base
[
4
];
/* 3C-48h : Chip Select Base Addrs */
u
32
intr_ctrl_stat
;
/* 4Ch : Interrupt Control/Status */
u
32
init_ctrl
;
/* 50h : EEPROM ctrl, Init Ctrl, etc */
};
#define PLX_9050_LINT1_ENABLE 0x01
...
...
@@ -240,66 +211,66 @@ struct RUNTIME_9050 {
#define PC300_FALC_MAXLOOP 0x0000ffff
/* for falc_issue_cmd() */
typedef
struct
falc
{
u
cchar
sync
;
/* If true FALC is synchronized */
u
cchar
active
;
/* if TRUE then already active */
u
cchar
loop_active
;
/* if TRUE a line loopback UP was received */
u
cchar
loop_gen
;
/* if TRUE a line loopback UP was issued */
u
8
sync
;
/* If true FALC is synchronized */
u
8
active
;
/* if TRUE then already active */
u
8
loop_active
;
/* if TRUE a line loopback UP was received */
u
8
loop_gen
;
/* if TRUE a line loopback UP was issued */
u
cchar
num_channels
;
u
cchar
offset
;
/* 1 for T1, 0 for E1 */
u
cchar
full_bandwidth
;
u
8
num_channels
;
u
8
offset
;
/* 1 for T1, 0 for E1 */
u
8
full_bandwidth
;
u
cchar
xmb_cause
;
u
cchar
multiframe_mode
;
u
8
xmb_cause
;
u
8
multiframe_mode
;
/* Statistics */
u
cshort
pden
;
/* Pulse Density violation count */
u
cshort
los
;
/* Loss of Signal count */
u
cshort
losr
;
/* Loss of Signal recovery count */
u
cshort
lfa
;
/* Loss of frame alignment count */
u
cshort
farec
;
/* Frame Alignment Recovery count */
u
cshort
lmfa
;
/* Loss of multiframe alignment count */
u
cshort
ais
;
/* Remote Alarm indication Signal count */
u
cshort
sec
;
/* One-second timer */
u
cshort
es
;
/* Errored second */
u
cshort
rai
;
/* remote alarm received */
u
cshort
bec
;
u
cshort
fec
;
u
cshort
cvc
;
u
cshort
cec
;
u
cshort
ebc
;
u
16
pden
;
/* Pulse Density violation count */
u
16
los
;
/* Loss of Signal count */
u
16
losr
;
/* Loss of Signal recovery count */
u
16
lfa
;
/* Loss of frame alignment count */
u
16
farec
;
/* Frame Alignment Recovery count */
u
16
lmfa
;
/* Loss of multiframe alignment count */
u
16
ais
;
/* Remote Alarm indication Signal count */
u
16
sec
;
/* One-second timer */
u
16
es
;
/* Errored second */
u
16
rai
;
/* remote alarm received */
u
16
bec
;
u
16
fec
;
u
16
cvc
;
u
16
cec
;
u
16
ebc
;
/* Status */
u
cchar
red_alarm
;
u
cchar
blue_alarm
;
u
cchar
loss_fa
;
u
cchar
yellow_alarm
;
u
cchar
loss_mfa
;
u
cchar
prbs
;
u
8
red_alarm
;
u
8
blue_alarm
;
u
8
loss_fa
;
u
8
yellow_alarm
;
u
8
loss_mfa
;
u
8
prbs
;
}
falc_t
;
typedef
struct
falc_status
{
u
cchar
sync
;
/* If true FALC is synchronized */
u
cchar
red_alarm
;
u
cchar
blue_alarm
;
u
cchar
loss_fa
;
u
cchar
yellow_alarm
;
u
cchar
loss_mfa
;
u
cchar
prbs
;
u
8
sync
;
/* If true FALC is synchronized */
u
8
red_alarm
;
u
8
blue_alarm
;
u
8
loss_fa
;
u
8
yellow_alarm
;
u
8
loss_mfa
;
u
8
prbs
;
}
falc_status_t
;
typedef
struct
rsv_x21_status
{
u
cchar
dcd
;
u
cchar
dsr
;
u
cchar
cts
;
u
cchar
rts
;
u
cchar
dtr
;
u
8
dcd
;
u
8
dsr
;
u
8
cts
;
u
8
rts
;
u
8
dtr
;
}
rsv_x21_status_t
;
typedef
struct
pc300stats
{
int
hw_type
;
u
clong
line_on
;
u
clong
line_off
;
u
32
line_on
;
u
32
line_off
;
struct
net_device_stats
gen_stats
;
falc_t
te_stats
;
}
pc300stats_t
;
...
...
@@ -317,28 +288,19 @@ typedef struct pc300loopback {
typedef
struct
pc300patterntst
{
char
patrntst_on
;
/* 0 - off; 1 - on; 2 - read num_errors */
u
cshort
num_errors
;
u
16
num_errors
;
}
pc300patterntst_t
;
typedef
struct
pc300dev
{
void
*
if_ptr
;
/* General purpose pointer */
struct
pc300ch
*
chan
;
ucchar
trace_on
;
uclong
line_on
;
/* DCD(X.21, RSV) / sync(TE) change counters */
uclong
line_off
;
#ifdef __KERNEL__
u8
trace_on
;
u32
line_on
;
/* DCD(X.21, RSV) / sync(TE) change counters */
u32
line_off
;
char
name
[
16
];
struct
net_device
*
dev
;
void
*
private
;
struct
sk_buff
*
tx_skb
;
union
{
/* This union has all the protocol-specific structures */
struct
ppp_device
pppdev
;
}
ifu
;
#ifdef CONFIG_PC300_MLPPP
void
*
cpc_tty
;
/* information to PC300 TTY driver */
#endif
#endif
/* __KERNEL__ */
}
pc300dev_t
;
typedef
struct
pc300hw
{
...
...
@@ -346,43 +308,42 @@ typedef struct pc300hw {
int
bus
;
/* Bus (PCI, PMC, etc.) */
int
nchan
;
/* number of channels */
int
irq
;
/* interrupt request level */
u
clong
clock
;
/* Board clock */
u
cchar
cpld_id
;
/* CPLD ID (TE only) */
u
cshort
cpld_reg1
;
/* CPLD reg 1 (TE only) */
u
cshort
cpld_reg2
;
/* CPLD reg 2 (TE only) */
u
cshort
gpioc_reg
;
/* PLX GPIOC reg */
u
cshort
intctl_reg
;
/* PLX Int Ctrl/Status reg */
u
clong
iophys
;
/* PLX registers I/O base */
u
clong
iosize
;
/* PLX registers I/O size */
u
clong
plxphys
;
/* PLX registers MMIO base (physical) */
u
32
clock
;
/* Board clock */
u
8
cpld_id
;
/* CPLD ID (TE only) */
u
16
cpld_reg1
;
/* CPLD reg 1 (TE only) */
u
16
cpld_reg2
;
/* CPLD reg 2 (TE only) */
u
16
gpioc_reg
;
/* PLX GPIOC reg */
u
16
intctl_reg
;
/* PLX Int Ctrl/Status reg */
u
32
iophys
;
/* PLX registers I/O base */
u
32
iosize
;
/* PLX registers I/O size */
u
32
plxphys
;
/* PLX registers MMIO base (physical) */
void
__iomem
*
plxbase
;
/* PLX registers MMIO base (virtual) */
u
clong
plxsize
;
/* PLX registers MMIO size */
u
clong
scaphys
;
/* SCA registers MMIO base (physical) */
u
32
plxsize
;
/* PLX registers MMIO size */
u
32
scaphys
;
/* SCA registers MMIO base (physical) */
void
__iomem
*
scabase
;
/* SCA registers MMIO base (virtual) */
u
clong
scasize
;
/* SCA registers MMIO size */
u
clong
ramphys
;
/* On-board RAM MMIO base (physical) */
u
32
scasize
;
/* SCA registers MMIO size */
u
32
ramphys
;
/* On-board RAM MMIO base (physical) */
void
__iomem
*
rambase
;
/* On-board RAM MMIO base (virtual) */
u
clong
alloc_ramsize
;
/* RAM MMIO size allocated by the PCI bridge */
u
clong
ramsize
;
/* On-board RAM MMIO size */
u
clong
falcphys
;
/* FALC registers MMIO base (physical) */
u
32
alloc_ramsize
;
/* RAM MMIO size allocated by the PCI bridge */
u
32
ramsize
;
/* On-board RAM MMIO size */
u
32
falcphys
;
/* FALC registers MMIO base (physical) */
void
__iomem
*
falcbase
;
/* FALC registers MMIO base (virtual) */
u
clong
falcsize
;
/* FALC registers MMIO size */
u
32
falcsize
;
/* FALC registers MMIO size */
}
pc300hw_t
;
typedef
struct
pc300chconf
{
sync_serial_settings
phys_settings
;
/* Clock type/rate (in bps),
sync_serial_settings
phys_settings
;
/* Clock type/rate (in bps),
loopback mode */
raw_hdlc_proto
proto_settings
;
/* Encoding, parity (CRC) */
uclong
media
;
/* HW media (RS232, V.35, etc.) */
uclong
proto
;
/* Protocol (PPP, X.25, etc.) */
ucchar
monitor
;
/* Monitor mode (0 = off, !0 = on) */
u32
media
;
/* HW media (RS232, V.35, etc.) */
u32
proto
;
/* Protocol (PPP, X.25, etc.) */
/* TE-specific parameters */
u
cchar
lcode
;
/* Line Code (AMI, B8ZS, etc.) */
u
cchar
fr_mode
;
/* Frame Mode (ESF, D4, etc.) */
u
cchar
lbo
;
/* Line Build Out */
u
cchar
rx_sens
;
/* Rx Sensitivity (long- or short-haul) */
u
clong
tslot_bitmap
;
/* bit[i]=1 => timeslot _i_ is active */
u
8
lcode
;
/* Line Code (AMI, B8ZS, etc.) */
u
8
fr_mode
;
/* Frame Mode (ESF, D4, etc.) */
u
8
lbo
;
/* Line Build Out */
u
8
rx_sens
;
/* Rx Sensitivity (long- or short-haul) */
u
32
tslot_bitmap
;
/* bit[i]=1 => timeslot _i_ is active */
}
pc300chconf_t
;
typedef
struct
pc300ch
{
...
...
@@ -390,20 +351,18 @@ typedef struct pc300ch {
int
channel
;
pc300dev_t
d
;
pc300chconf_t
conf
;
u
cchar
tx_first_bd
;
/* First TX DMA block descr. w/ data */
u
cchar
tx_next_bd
;
/* Next free TX DMA block descriptor */
u
cchar
rx_first_bd
;
/* First free RX DMA block descriptor */
u
cchar
rx_last_bd
;
/* Last free RX DMA block descriptor */
u
cchar
nfree_tx_bd
;
/* Number of free TX DMA block descriptors */
falc_t
falc
;
/* FALC structure (TE only) */
u
8
tx_first_bd
;
/* First TX DMA block descr. w/ data */
u
8
tx_next_bd
;
/* Next free TX DMA block descriptor */
u
8
rx_first_bd
;
/* First free RX DMA block descriptor */
u
8
rx_last_bd
;
/* Last free RX DMA block descriptor */
u
8
nfree_tx_bd
;
/* Number of free TX DMA block descriptors */
falc_t
falc
;
/* FALC structure (TE only) */
}
pc300ch_t
;
typedef
struct
pc300
{
pc300hw_t
hw
;
/* hardware config. */
pc300ch_t
chan
[
PC300_MAXCHAN
];
#ifdef __KERNEL__
spinlock_t
card_lock
;
#endif
/* __KERNEL__ */
}
pc300_t
;
typedef
struct
pc300conf
{
...
...
@@ -471,12 +430,7 @@ enum pc300_loopback_cmds {
#define PC300_TX_QUEUE_LEN 100
#define PC300_DEF_MTU 1600
#ifdef __KERNEL__
/* Function Prototypes */
void
tx_dma_start
(
pc300_t
*
,
int
);
int
cpc_open
(
struct
net_device
*
dev
);
int
cpc_set_media
(
hdlc_device
*
,
int
);
#endif
/* __KERNEL__ */
#endif
/* _PC300_H */
drivers/net/wan/pc300_drv.c
浏览文件 @
3859069b
...
...
@@ -227,8 +227,6 @@ static char rcsid[] =
#include <linux/netdevice.h>
#include <linux/spinlock.h>
#include <linux/if.h>
#include <net/syncppp.h>
#include <net/arp.h>
#include <asm/io.h>
...
...
@@ -285,8 +283,8 @@ static void rx_dma_buf_init(pc300_t *, int);
static
void
tx_dma_buf_check
(
pc300_t
*
,
int
);
static
void
rx_dma_buf_check
(
pc300_t
*
,
int
);
static
irqreturn_t
cpc_intr
(
int
,
void
*
);
static
int
clock_rate_calc
(
u
clong
,
uclong
,
int
*
);
static
u
clong
detect_ram
(
pc300_t
*
);
static
int
clock_rate_calc
(
u
32
,
u32
,
int
*
);
static
u
32
detect_ram
(
pc300_t
*
);
static
void
plx_init
(
pc300_t
*
);
static
void
cpc_trace
(
struct
net_device
*
,
struct
sk_buff
*
,
char
);
static
int
cpc_attach
(
struct
net_device
*
,
unsigned
short
,
unsigned
short
);
...
...
@@ -311,10 +309,10 @@ static void tx_dma_buf_pt_init(pc300_t * card, int ch)
+
DMA_TX_BD_BASE
+
ch_factor
*
sizeof
(
pcsca_bd_t
));
for
(
i
=
0
;
i
<
N_DMA_TX_BUF
;
i
++
,
ptdescr
++
)
{
cpc_writel
(
&
ptdescr
->
next
,
(
u
clong
)
(
DMA_TX_BD_BASE
+
cpc_writel
(
&
ptdescr
->
next
,
(
u
32
)
(
DMA_TX_BD_BASE
+
(
ch_factor
+
((
i
+
1
)
&
(
N_DMA_TX_BUF
-
1
)))
*
sizeof
(
pcsca_bd_t
)));
cpc_writel
(
&
ptdescr
->
ptbuf
,
(
uclong
)
(
DMA_TX_BASE
+
(
ch_factor
+
i
)
*
BD_DEF_LEN
));
cpc_writel
(
&
ptdescr
->
ptbuf
,
(
u32
)
(
DMA_TX_BASE
+
(
ch_factor
+
i
)
*
BD_DEF_LEN
));
}
}
...
...
@@ -341,10 +339,10 @@ static void rx_dma_buf_pt_init(pc300_t * card, int ch)
+
DMA_RX_BD_BASE
+
ch_factor
*
sizeof
(
pcsca_bd_t
));
for
(
i
=
0
;
i
<
N_DMA_RX_BUF
;
i
++
,
ptdescr
++
)
{
cpc_writel
(
&
ptdescr
->
next
,
(
u
clong
)
(
DMA_RX_BD_BASE
+
(
ch_factor
+
((
i
+
1
)
&
(
N_DMA_RX_BUF
-
1
)))
*
sizeof
(
pcsca_bd_t
)));
cpc_writel
(
&
ptdescr
->
next
,
(
u
32
)
(
DMA_RX_BD_BASE
+
(
ch_factor
+
((
i
+
1
)
&
(
N_DMA_RX_BUF
-
1
)))
*
sizeof
(
pcsca_bd_t
)));
cpc_writel
(
&
ptdescr
->
ptbuf
,
(
u
clong
)
(
DMA_RX_BASE
+
(
ch_factor
+
i
)
*
BD_DEF_LEN
));
(
u
32
)
(
DMA_RX_BASE
+
(
ch_factor
+
i
)
*
BD_DEF_LEN
));
}
}
...
...
@@ -367,8 +365,8 @@ static void tx_dma_buf_check(pc300_t * card, int ch)
{
volatile
pcsca_bd_t
__iomem
*
ptdescr
;
int
i
;
u
cshort
first_bd
=
card
->
chan
[
ch
].
tx_first_bd
;
u
cshort
next_bd
=
card
->
chan
[
ch
].
tx_next_bd
;
u
16
first_bd
=
card
->
chan
[
ch
].
tx_first_bd
;
u
16
next_bd
=
card
->
chan
[
ch
].
tx_next_bd
;
printk
(
"#CH%d: f_bd = %d(0x%08zx), n_bd = %d(0x%08zx)
\n
"
,
ch
,
first_bd
,
TX_BD_ADDR
(
ch
,
first_bd
),
...
...
@@ -392,9 +390,9 @@ static void tx1_dma_buf_check(pc300_t * card, int ch)
{
volatile
pcsca_bd_t
__iomem
*
ptdescr
;
int
i
;
u
cshort
first_bd
=
card
->
chan
[
ch
].
tx_first_bd
;
u
cshort
next_bd
=
card
->
chan
[
ch
].
tx_next_bd
;
u
clong
scabase
=
card
->
hw
.
scabase
;
u
16
first_bd
=
card
->
chan
[
ch
].
tx_first_bd
;
u
16
next_bd
=
card
->
chan
[
ch
].
tx_next_bd
;
u
32
scabase
=
card
->
hw
.
scabase
;
printk
(
"
\n
nfree_tx_bd = %d
\n
"
,
card
->
chan
[
ch
].
nfree_tx_bd
);
printk
(
"#CH%d: f_bd = %d(0x%08x), n_bd = %d(0x%08x)
\n
"
,
ch
,
...
...
@@ -413,13 +411,13 @@ static void tx1_dma_buf_check(pc300_t * card, int ch)
printk
(
"
\n
"
);
}
#endif
static
void
rx_dma_buf_check
(
pc300_t
*
card
,
int
ch
)
{
volatile
pcsca_bd_t
__iomem
*
ptdescr
;
int
i
;
u
cshort
first_bd
=
card
->
chan
[
ch
].
rx_first_bd
;
u
cshort
last_bd
=
card
->
chan
[
ch
].
rx_last_bd
;
u
16
first_bd
=
card
->
chan
[
ch
].
rx_first_bd
;
u
16
last_bd
=
card
->
chan
[
ch
].
rx_last_bd
;
int
ch_factor
;
ch_factor
=
ch
*
N_DMA_RX_BUF
;
...
...
@@ -440,9 +438,9 @@ static void rx_dma_buf_check(pc300_t * card, int ch)
static
int
dma_get_rx_frame_size
(
pc300_t
*
card
,
int
ch
)
{
volatile
pcsca_bd_t
__iomem
*
ptdescr
;
u
cshort
first_bd
=
card
->
chan
[
ch
].
rx_first_bd
;
u
16
first_bd
=
card
->
chan
[
ch
].
rx_first_bd
;
int
rcvd
=
0
;
volatile
u
cchar
status
;
volatile
u
8
status
;
ptdescr
=
(
card
->
hw
.
rambase
+
RX_BD_ADDR
(
ch
,
first_bd
));
while
((
status
=
cpc_readb
(
&
ptdescr
->
status
))
&
DST_OSB
)
{
...
...
@@ -462,12 +460,12 @@ static int dma_get_rx_frame_size(pc300_t * card, int ch)
* dma_buf_write: writes a frame to the Tx DMA buffers
* NOTE: this function writes one frame at a time.
*/
static
int
dma_buf_write
(
pc300_t
*
card
,
int
ch
,
ucchar
*
ptdata
,
int
len
)
static
int
dma_buf_write
(
pc300_t
*
card
,
int
ch
,
u8
*
ptdata
,
int
len
)
{
int
i
,
nchar
;
volatile
pcsca_bd_t
__iomem
*
ptdescr
;
int
tosend
=
len
;
u
cchar
nbuf
=
((
len
-
1
)
/
BD_DEF_LEN
)
+
1
;
u
8
nbuf
=
((
len
-
1
)
/
BD_DEF_LEN
)
+
1
;
if
(
nbuf
>=
card
->
chan
[
ch
].
nfree_tx_bd
)
{
return
-
ENOMEM
;
...
...
@@ -509,7 +507,7 @@ static int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
pc300ch_t
*
chan
=
(
pc300ch_t
*
)
&
card
->
chan
[
ch
];
volatile
pcsca_bd_t
__iomem
*
ptdescr
;
int
rcvd
=
0
;
volatile
u
cchar
status
;
volatile
u
8
status
;
ptdescr
=
(
card
->
hw
.
rambase
+
RX_BD_ADDR
(
ch
,
chan
->
rx_first_bd
));
...
...
@@ -563,8 +561,8 @@ static int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
static
void
tx_dma_stop
(
pc300_t
*
card
,
int
ch
)
{
void
__iomem
*
scabase
=
card
->
hw
.
scabase
;
u
cchar
drr_ena_bit
=
1
<<
(
5
+
2
*
ch
);
u
cchar
drr_rst_bit
=
1
<<
(
1
+
2
*
ch
);
u
8
drr_ena_bit
=
1
<<
(
5
+
2
*
ch
);
u
8
drr_rst_bit
=
1
<<
(
1
+
2
*
ch
);
/* Disable DMA */
cpc_writeb
(
scabase
+
DRR
,
drr_ena_bit
);
...
...
@@ -574,8 +572,8 @@ static void tx_dma_stop(pc300_t * card, int ch)
static
void
rx_dma_stop
(
pc300_t
*
card
,
int
ch
)
{
void
__iomem
*
scabase
=
card
->
hw
.
scabase
;
u
cchar
drr_ena_bit
=
1
<<
(
4
+
2
*
ch
);
u
cchar
drr_rst_bit
=
1
<<
(
2
*
ch
);
u
8
drr_ena_bit
=
1
<<
(
4
+
2
*
ch
);
u
8
drr_rst_bit
=
1
<<
(
2
*
ch
);
/* Disable DMA */
cpc_writeb
(
scabase
+
DRR
,
drr_ena_bit
);
...
...
@@ -607,7 +605,7 @@ static void rx_dma_start(pc300_t * card, int ch)
/*************************/
/*** FALC Routines ***/
/*************************/
static
void
falc_issue_cmd
(
pc300_t
*
card
,
int
ch
,
ucchar
cmd
)
static
void
falc_issue_cmd
(
pc300_t
*
card
,
int
ch
,
u8
cmd
)
{
void
__iomem
*
falcbase
=
card
->
hw
.
falcbase
;
unsigned
long
i
=
0
;
...
...
@@ -675,7 +673,7 @@ static void falc_intr_enable(pc300_t * card, int ch)
static
void
falc_open_timeslot
(
pc300_t
*
card
,
int
ch
,
int
timeslot
)
{
void
__iomem
*
falcbase
=
card
->
hw
.
falcbase
;
u
cchar
tshf
=
card
->
chan
[
ch
].
falc
.
offset
;
u
8
tshf
=
card
->
chan
[
ch
].
falc
.
offset
;
cpc_writeb
(
falcbase
+
F_REG
((
ICB1
+
(
timeslot
-
tshf
)
/
8
),
ch
),
cpc_readb
(
falcbase
+
F_REG
((
ICB1
+
(
timeslot
-
tshf
)
/
8
),
ch
))
&
...
...
@@ -691,7 +689,7 @@ static void falc_open_timeslot(pc300_t * card, int ch, int timeslot)
static
void
falc_close_timeslot
(
pc300_t
*
card
,
int
ch
,
int
timeslot
)
{
void
__iomem
*
falcbase
=
card
->
hw
.
falcbase
;
u
cchar
tshf
=
card
->
chan
[
ch
].
falc
.
offset
;
u
8
tshf
=
card
->
chan
[
ch
].
falc
.
offset
;
cpc_writeb
(
falcbase
+
F_REG
((
ICB1
+
(
timeslot
-
tshf
)
/
8
),
ch
),
cpc_readb
(
falcbase
+
F_REG
((
ICB1
+
(
timeslot
-
tshf
)
/
8
),
ch
))
|
...
...
@@ -812,7 +810,7 @@ static void falc_init_t1(pc300_t * card, int ch)
pc300chconf_t
*
conf
=
(
pc300chconf_t
*
)
&
chan
->
conf
;
falc_t
*
pfalc
=
(
falc_t
*
)
&
chan
->
falc
;
void
__iomem
*
falcbase
=
card
->
hw
.
falcbase
;
u
cchar
dja
=
(
ch
?
(
LIM2_DJA2
|
LIM2_DJA1
)
:
0
);
u
8
dja
=
(
ch
?
(
LIM2_DJA2
|
LIM2_DJA1
)
:
0
);
/* Switch to T1 mode (PCM 24) */
cpc_writeb
(
falcbase
+
F_REG
(
FMR1
,
ch
),
FMR1_PMOD
);
...
...
@@ -981,7 +979,7 @@ static void falc_init_e1(pc300_t * card, int ch)
pc300chconf_t
*
conf
=
(
pc300chconf_t
*
)
&
chan
->
conf
;
falc_t
*
pfalc
=
(
falc_t
*
)
&
chan
->
falc
;
void
__iomem
*
falcbase
=
card
->
hw
.
falcbase
;
u
cchar
dja
=
(
ch
?
(
LIM2_DJA2
|
LIM2_DJA1
)
:
0
);
u
8
dja
=
(
ch
?
(
LIM2_DJA2
|
LIM2_DJA1
)
:
0
);
/* Switch to E1 mode (PCM 30) */
cpc_writeb
(
falcbase
+
F_REG
(
FMR1
,
ch
),
...
...
@@ -1187,7 +1185,7 @@ static void te_config(pc300_t * card, int ch)
pc300chconf_t
*
conf
=
(
pc300chconf_t
*
)
&
chan
->
conf
;
falc_t
*
pfalc
=
(
falc_t
*
)
&
chan
->
falc
;
void
__iomem
*
falcbase
=
card
->
hw
.
falcbase
;
u
cchar
dummy
;
u
8
dummy
;
unsigned
long
flags
;
memset
(
pfalc
,
0
,
sizeof
(
falc_t
));
...
...
@@ -1403,7 +1401,7 @@ static void falc_update_stats(pc300_t * card, int ch)
pc300chconf_t
*
conf
=
(
pc300chconf_t
*
)
&
chan
->
conf
;
falc_t
*
pfalc
=
(
falc_t
*
)
&
chan
->
falc
;
void
__iomem
*
falcbase
=
card
->
hw
.
falcbase
;
u
cshort
counter
;
u
16
counter
;
counter
=
cpc_readb
(
falcbase
+
F_REG
(
FECL
,
ch
));
counter
|=
cpc_readb
(
falcbase
+
F_REG
(
FECH
,
ch
))
<<
8
;
...
...
@@ -1729,7 +1727,7 @@ static void falc_pattern_test(pc300_t * card, int ch, unsigned int activate)
* Description: This routine returns the bit error counter value
*----------------------------------------------------------------------------
*/
static
u
cshort
falc_pattern_test_error
(
pc300_t
*
card
,
int
ch
)
static
u
16
falc_pattern_test_error
(
pc300_t
*
card
,
int
ch
)
{
pc300ch_t
*
chan
=
(
pc300ch_t
*
)
&
card
->
chan
[
ch
];
falc_t
*
pfalc
=
(
falc_t
*
)
&
chan
->
falc
;
...
...
@@ -1776,7 +1774,7 @@ static void cpc_tx_timeout(struct net_device *dev)
pc300_t
*
card
=
(
pc300_t
*
)
chan
->
card
;
int
ch
=
chan
->
channel
;
unsigned
long
flags
;
u
cchar
ilar
;
u
8
ilar
;
dev
->
stats
.
tx_errors
++
;
dev
->
stats
.
tx_aborted_errors
++
;
...
...
@@ -1807,11 +1805,7 @@ static int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
int
i
;
#endif
if
(
chan
->
conf
.
monitor
)
{
/* In monitor mode no Tx is done: ignore packet */
dev_kfree_skb
(
skb
);
return
0
;
}
else
if
(
!
netif_carrier_ok
(
dev
))
{
if
(
!
netif_carrier_ok
(
dev
))
{
/* DCD must be OFF: drop packet */
dev_kfree_skb
(
skb
);
dev
->
stats
.
tx_errors
++
;
...
...
@@ -1836,7 +1830,7 @@ static int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
}
/* Write buffer to DMA buffers */
if
(
dma_buf_write
(
card
,
ch
,
(
u
cchar
*
)
skb
->
data
,
skb
->
len
)
!=
0
)
{
if
(
dma_buf_write
(
card
,
ch
,
(
u
8
*
)
skb
->
data
,
skb
->
len
)
!=
0
)
{
// printk("%s: write error. Dropping TX packet.\n", dev->name);
netif_stop_queue
(
dev
);
dev_kfree_skb
(
skb
);
...
...
@@ -2001,7 +1995,7 @@ static void sca_tx_intr(pc300dev_t *dev)
static
void
sca_intr
(
pc300_t
*
card
)
{
void
__iomem
*
scabase
=
card
->
hw
.
scabase
;
volatile
u
clong
status
;
volatile
u
32
status
;
int
ch
;
int
intr_count
=
0
;
unsigned
char
dsr_rx
;
...
...
@@ -2016,7 +2010,7 @@ static void sca_intr(pc300_t * card)
/**** Reception ****/
if
(
status
&
IR0_DRX
((
IR0_DMIA
|
IR0_DMIB
),
ch
))
{
u
cchar
drx_stat
=
cpc_readb
(
scabase
+
DSR_RX
(
ch
));
u
8
drx_stat
=
cpc_readb
(
scabase
+
DSR_RX
(
ch
));
/* Clear RX interrupts */
cpc_writeb
(
scabase
+
DSR_RX
(
ch
),
drx_stat
|
DSR_DWE
);
...
...
@@ -2090,7 +2084,7 @@ static void sca_intr(pc300_t * card)
/**** Transmission ****/
if
(
status
&
IR0_DTX
((
IR0_EFT
|
IR0_DMIA
|
IR0_DMIB
),
ch
))
{
u
cchar
dtx_stat
=
cpc_readb
(
scabase
+
DSR_TX
(
ch
));
u
8
dtx_stat
=
cpc_readb
(
scabase
+
DSR_TX
(
ch
));
/* Clear TX interrupts */
cpc_writeb
(
scabase
+
DSR_TX
(
ch
),
dtx_stat
|
DSR_DWE
);
...
...
@@ -2134,7 +2128,7 @@ static void sca_intr(pc300_t * card)
/**** MSCI ****/
if
(
status
&
IR0_M
(
IR0_RXINTA
,
ch
))
{
u
cchar
st1
=
cpc_readb
(
scabase
+
M_REG
(
ST1
,
ch
));
u
8
st1
=
cpc_readb
(
scabase
+
M_REG
(
ST1
,
ch
));
/* Clear MSCI interrupts */
cpc_writeb
(
scabase
+
M_REG
(
ST1
,
ch
),
st1
);
...
...
@@ -2176,7 +2170,7 @@ static void sca_intr(pc300_t * card)
}
}
static
void
falc_t1_loop_detection
(
pc300_t
*
card
,
int
ch
,
ucchar
frs1
)
static
void
falc_t1_loop_detection
(
pc300_t
*
card
,
int
ch
,
u8
frs1
)
{
pc300ch_t
*
chan
=
(
pc300ch_t
*
)
&
card
->
chan
[
ch
];
falc_t
*
pfalc
=
(
falc_t
*
)
&
chan
->
falc
;
...
...
@@ -2201,7 +2195,7 @@ static void falc_t1_loop_detection(pc300_t * card, int ch, ucchar frs1)
}
}
static
void
falc_e1_loop_detection
(
pc300_t
*
card
,
int
ch
,
ucchar
rsp
)
static
void
falc_e1_loop_detection
(
pc300_t
*
card
,
int
ch
,
u8
rsp
)
{
pc300ch_t
*
chan
=
(
pc300ch_t
*
)
&
card
->
chan
[
ch
];
falc_t
*
pfalc
=
(
falc_t
*
)
&
chan
->
falc
;
...
...
@@ -2231,8 +2225,8 @@ static void falc_t1_intr(pc300_t * card, int ch)
pc300ch_t
*
chan
=
(
pc300ch_t
*
)
&
card
->
chan
[
ch
];
falc_t
*
pfalc
=
(
falc_t
*
)
&
chan
->
falc
;
void
__iomem
*
falcbase
=
card
->
hw
.
falcbase
;
u
cchar
isr0
,
isr3
,
gis
;
u
cchar
dummy
;
u
8
isr0
,
isr3
,
gis
;
u
8
dummy
;
while
((
gis
=
cpc_readb
(
falcbase
+
F_REG
(
GIS
,
ch
)))
!=
0
)
{
if
(
gis
&
GIS_ISR0
)
{
...
...
@@ -2278,8 +2272,8 @@ static void falc_e1_intr(pc300_t * card, int ch)
pc300ch_t
*
chan
=
(
pc300ch_t
*
)
&
card
->
chan
[
ch
];
falc_t
*
pfalc
=
(
falc_t
*
)
&
chan
->
falc
;
void
__iomem
*
falcbase
=
card
->
hw
.
falcbase
;
u
cchar
isr1
,
isr2
,
isr3
,
gis
,
rsp
;
u
cchar
dummy
;
u
8
isr1
,
isr2
,
isr3
,
gis
,
rsp
;
u
8
dummy
;
while
((
gis
=
cpc_readb
(
falcbase
+
F_REG
(
GIS
,
ch
)))
!=
0
)
{
rsp
=
cpc_readb
(
falcbase
+
F_REG
(
RSP
,
ch
));
...
...
@@ -2361,7 +2355,7 @@ static void falc_intr(pc300_t * card)
static
irqreturn_t
cpc_intr
(
int
irq
,
void
*
dev_id
)
{
pc300_t
*
card
=
dev_id
;
volatile
u
cchar
plx_status
;
volatile
u
8
plx_status
;
if
(
!
card
)
{
#ifdef PC300_DEBUG_INTR
...
...
@@ -2400,7 +2394,7 @@ static irqreturn_t cpc_intr(int irq, void *dev_id)
static
void
cpc_sca_status
(
pc300_t
*
card
,
int
ch
)
{
u
cchar
ilar
;
u
8
ilar
;
void
__iomem
*
scabase
=
card
->
hw
.
scabase
;
unsigned
long
flags
;
...
...
@@ -2818,7 +2812,7 @@ static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
}
}
static
int
clock_rate_calc
(
u
clong
rate
,
uclong
clock
,
int
*
br_io
)
static
int
clock_rate_calc
(
u
32
rate
,
u32
clock
,
int
*
br_io
)
{
int
br
,
tc
;
int
br_pwr
,
error
;
...
...
@@ -2855,12 +2849,12 @@ static int ch_config(pc300dev_t * d)
void
__iomem
*
scabase
=
card
->
hw
.
scabase
;
void
__iomem
*
plxbase
=
card
->
hw
.
plxbase
;
int
ch
=
chan
->
channel
;
u
clong
clkrate
=
chan
->
conf
.
phys_settings
.
clock_rate
;
u
clong
clktype
=
chan
->
conf
.
phys_settings
.
clock_type
;
u
cshort
encoding
=
chan
->
conf
.
proto_settings
.
encoding
;
u
cshort
parity
=
chan
->
conf
.
proto_settings
.
parity
;
u
cchar
md0
,
md2
;
u
32
clkrate
=
chan
->
conf
.
phys_settings
.
clock_rate
;
u
32
clktype
=
chan
->
conf
.
phys_settings
.
clock_type
;
u
16
encoding
=
chan
->
conf
.
proto_settings
.
encoding
;
u
16
parity
=
chan
->
conf
.
proto_settings
.
parity
;
u
8
md0
,
md2
;
/* Reset the channel */
cpc_writeb
(
scabase
+
M_REG
(
CMD
,
ch
),
CMD_CH_RST
);
...
...
@@ -3152,19 +3146,10 @@ int cpc_open(struct net_device *dev)
printk
(
"pc300: cpc_open"
);
#endif
#ifdef FIXME
if
(
hdlc
->
proto
.
id
==
IF_PROTO_PPP
)
{
d
->
if_ptr
=
&
hdlc
->
state
.
ppp
.
pppdev
;
}
#endif
result
=
hdlc_open
(
dev
);
if
(
/* FIXME hdlc->proto.id == IF_PROTO_PPP*/
0
)
{
dev
->
priv
=
d
;
}
if
(
result
)
{
if
(
result
)
return
result
;
}
sprintf
(
ifr
.
ifr_name
,
"%s"
,
dev
->
name
);
result
=
cpc_opench
(
d
);
...
...
@@ -3197,9 +3182,7 @@ static int cpc_close(struct net_device *dev)
CPC_UNLOCK
(
card
,
flags
);
hdlc_close
(
dev
);
if
(
/* FIXME hdlc->proto.id == IF_PROTO_PPP*/
0
)
{
d
->
if_ptr
=
NULL
;
}
#ifdef CONFIG_PC300_MLPPP
if
(
chan
->
conf
.
proto
==
PC300_PROTO_MLPPP
)
{
cpc_tty_unregister_service
(
d
);
...
...
@@ -3210,16 +3193,16 @@ static int cpc_close(struct net_device *dev)
return
0
;
}
static
u
clong
detect_ram
(
pc300_t
*
card
)
static
u
32
detect_ram
(
pc300_t
*
card
)
{
u
clong
i
;
u
cchar
data
;
u
32
i
;
u
8
data
;
void
__iomem
*
rambase
=
card
->
hw
.
rambase
;
card
->
hw
.
ramsize
=
PC300_RAMSIZE
;
/* Let's find out how much RAM is present on this board */
for
(
i
=
0
;
i
<
card
->
hw
.
ramsize
;
i
++
)
{
data
=
(
u
cchar
)
(
i
&
0xff
);
data
=
(
u
8
)
(
i
&
0xff
);
cpc_writeb
(
rambase
+
i
,
data
);
if
(
cpc_readb
(
rambase
+
i
)
!=
data
)
{
break
;
...
...
@@ -3296,7 +3279,7 @@ static void cpc_init_card(pc300_t * card)
cpc_writeb
(
card
->
hw
.
scabase
+
DMER
,
0x80
);
if
(
card
->
hw
.
type
==
PC300_TE
)
{
u
cchar
reg1
;
u
8
reg1
;
/* Check CPLD version */
reg1
=
cpc_readb
(
card
->
hw
.
falcbase
+
CPLD_REG1
);
...
...
@@ -3360,7 +3343,6 @@ static void cpc_init_card(pc300_t * card)
chan
->
nfree_tx_bd
=
N_DMA_TX_BUF
;
d
->
chan
=
chan
;
d
->
tx_skb
=
NULL
;
d
->
trace_on
=
0
;
d
->
line_on
=
0
;
d
->
line_off
=
0
;
...
...
@@ -3431,7 +3413,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
static
int
first_time
=
1
;
int
err
,
eeprom_outdated
=
0
;
u
cshort
device_id
;
u
16
device_id
;
pc300_t
*
card
;
if
(
first_time
)
{
...
...
drivers/net/wan/sealevel.c
浏览文件 @
3859069b
...
...
@@ -8,6 +8,7 @@
*
* (c) Copyright 1999, 2001 Alan Cox
* (c) Copyright 2001 Red Hat Inc.
* Generic HDLC port Copyright (C) 2008 Krzysztof Halasa <khc@pm.waw.pl>
*
*/
...
...
@@ -19,6 +20,7 @@
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/delay.h>
#include <linux/hdlc.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <net/arp.h>
...
...
@@ -27,22 +29,19 @@
#include <asm/io.h>
#include <asm/dma.h>
#include <asm/byteorder.h>
#include <net/syncppp.h>
#include "z85230.h"
struct
slvl_device
{
void
*
if_ptr
;
/* General purpose pointer (used by SPPP) */
struct
z8530_channel
*
chan
;
struct
ppp_device
pppdev
;
int
channel
;
};
struct
slvl_board
{
struct
slvl_device
*
dev
[
2
];
struct
slvl_device
dev
[
2
];
struct
z8530_dev
board
;
int
iobase
;
};
...
...
@@ -51,72 +50,69 @@ struct slvl_board
* Network driver support routines
*/
static
inline
struct
slvl_device
*
dev_to_chan
(
struct
net_device
*
dev
)
{
return
(
struct
slvl_device
*
)
dev_to_hdlc
(
dev
)
->
priv
;
}
/*
* Frame receive. Simple for our card as we do
sync ppp
and there
* Frame receive. Simple for our card as we do
HDLC
and there
* is no funny garbage involved
*/
static
void
sealevel_input
(
struct
z8530_channel
*
c
,
struct
sk_buff
*
skb
)
{
/* Drop the CRC - it's not a good idea to try and negotiate it ;) */
skb_trim
(
skb
,
skb
->
len
-
2
);
skb
->
protocol
=
htons
(
ETH_P_WAN_PPP
);
skb_trim
(
skb
,
skb
->
len
-
2
);
skb
->
protocol
=
hdlc_type_trans
(
skb
,
c
->
netdevice
);
skb_reset_mac_header
(
skb
);
skb
->
dev
=
c
->
netdevice
;
/*
* Send it to the PPP layer. We don't have time to process
* it right now.
*/
skb
->
dev
=
c
->
netdevice
;
netif_rx
(
skb
);
c
->
netdevice
->
last_rx
=
jiffies
;
}
/*
* We've been placed in the UP state
*/
*/
static
int
sealevel_open
(
struct
net_device
*
d
)
{
struct
slvl_device
*
slvl
=
d
->
priv
;
struct
slvl_device
*
slvl
=
dev_to_chan
(
d
)
;
int
err
=
-
1
;
int
unit
=
slvl
->
channel
;
/*
* Link layer up.
* Link layer up.
*/
switch
(
unit
)
switch
(
unit
)
{
case
0
:
err
=
z8530_sync_dma_open
(
d
,
slvl
->
chan
);
err
=
z8530_sync_dma_open
(
d
,
slvl
->
chan
);
break
;
case
1
:
err
=
z8530_sync_open
(
d
,
slvl
->
chan
);
err
=
z8530_sync_open
(
d
,
slvl
->
chan
);
break
;
}
if
(
err
)
if
(
err
)
return
err
;
/*
* Begin PPP
*/
err
=
sppp_open
(
d
);
if
(
err
)
{
switch
(
unit
)
{
err
=
hdlc_open
(
d
);
if
(
err
)
{
switch
(
unit
)
{
case
0
:
z8530_sync_dma_close
(
d
,
slvl
->
chan
);
break
;
case
1
:
z8530_sync_close
(
d
,
slvl
->
chan
);
break
;
}
}
return
err
;
}
slvl
->
chan
->
rx_function
=
sealevel_input
;
slvl
->
chan
->
rx_function
=
sealevel_input
;
/*
* Go go go
*/
...
...
@@ -126,26 +122,19 @@ static int sealevel_open(struct net_device *d)
static
int
sealevel_close
(
struct
net_device
*
d
)
{
struct
slvl_device
*
slvl
=
d
->
priv
;
struct
slvl_device
*
slvl
=
dev_to_chan
(
d
)
;
int
unit
=
slvl
->
channel
;
/*
* Discard new frames
*/
slvl
->
chan
->
rx_function
=
z8530_null_rx
;
/*
* PPP off
*/
sppp_close
(
d
);
/*
* Link layer down
*/
slvl
->
chan
->
rx_function
=
z8530_null_rx
;
hdlc_close
(
d
);
netif_stop_queue
(
d
);
switch
(
unit
)
switch
(
unit
)
{
case
0
:
z8530_sync_dma_close
(
d
,
slvl
->
chan
);
...
...
@@ -159,210 +148,153 @@ static int sealevel_close(struct net_device *d)
static
int
sealevel_ioctl
(
struct
net_device
*
d
,
struct
ifreq
*
ifr
,
int
cmd
)
{
/* struct slvl_device *slvl=d
->priv
;
/* struct slvl_device *slvl=d
ev_to_chan(d)
;
z8530_ioctl(d,&slvl->sync.chanA,ifr,cmd) */
return
sppp_do_ioctl
(
d
,
ifr
,
cmd
);
}
static
struct
net_device_stats
*
sealevel_get_stats
(
struct
net_device
*
d
)
{
struct
slvl_device
*
slvl
=
d
->
priv
;
if
(
slvl
)
return
z8530_get_stats
(
slvl
->
chan
);
else
return
NULL
;
return
hdlc_ioctl
(
d
,
ifr
,
cmd
);
}
/*
* Passed
PPP
frames, fire them downwind.
* Passed
network
frames, fire them downwind.
*/
static
int
sealevel_queue_xmit
(
struct
sk_buff
*
skb
,
struct
net_device
*
d
)
{
struct
slvl_device
*
slvl
=
d
->
priv
;
return
z8530_queue_xmit
(
slvl
->
chan
,
skb
);
return
z8530_queue_xmit
(
dev_to_chan
(
d
)
->
chan
,
skb
);
}
static
int
sealevel_neigh_setup
(
struct
neighbour
*
n
)
static
int
sealevel_attach
(
struct
net_device
*
dev
,
unsigned
short
encoding
,
unsigned
short
parity
)
{
if
(
n
->
nud_state
==
NUD_NONE
)
{
n
->
ops
=
&
arp_broken_ops
;
n
->
output
=
n
->
ops
->
output
;
}
return
0
;
if
(
encoding
==
ENCODING_NRZ
&&
parity
==
PARITY_CRC16_PR1_CCITT
)
return
0
;
return
-
EINVAL
;
}
static
int
s
ealevel_neigh_setup_dev
(
struct
net_device
*
dev
,
struct
neigh_parms
*
p
)
static
int
s
lvl_setup
(
struct
slvl_device
*
sv
,
int
iobase
,
int
irq
)
{
if
(
p
->
tbl
->
family
==
AF_INET
)
{
p
->
neigh_setup
=
sealevel_neigh_setup
;
p
->
ucast_probes
=
0
;
p
->
mcast_probes
=
0
;
struct
net_device
*
dev
=
alloc_hdlcdev
(
sv
);
if
(
!
dev
)
return
-
1
;
dev_to_hdlc
(
dev
)
->
attach
=
sealevel_attach
;
dev_to_hdlc
(
dev
)
->
xmit
=
sealevel_queue_xmit
;
dev
->
open
=
sealevel_open
;
dev
->
stop
=
sealevel_close
;
dev
->
do_ioctl
=
sealevel_ioctl
;
dev
->
base_addr
=
iobase
;
dev
->
irq
=
irq
;
if
(
register_hdlc_device
(
dev
))
{
printk
(
KERN_ERR
"sealevel: unable to register HDLC device
\n
"
);
free_netdev
(
dev
);
return
-
1
;
}
return
0
;
}
static
int
sealevel_attach
(
struct
net_device
*
dev
)
{
struct
slvl_device
*
sv
=
dev
->
priv
;
sppp_attach
(
&
sv
->
pppdev
);
sv
->
chan
->
netdevice
=
dev
;
return
0
;
}
static
void
sealevel_detach
(
struct
net_device
*
dev
)
{
sppp_detach
(
dev
);
}
static
void
slvl_setup
(
struct
net_device
*
d
)
{
d
->
open
=
sealevel_open
;
d
->
stop
=
sealevel_close
;
d
->
init
=
sealevel_attach
;
d
->
uninit
=
sealevel_detach
;
d
->
hard_start_xmit
=
sealevel_queue_xmit
;
d
->
get_stats
=
sealevel_get_stats
;
d
->
set_multicast_list
=
NULL
;
d
->
do_ioctl
=
sealevel_ioctl
;
d
->
neigh_setup
=
sealevel_neigh_setup_dev
;
d
->
set_mac_address
=
NULL
;
}
static
inline
struct
slvl_device
*
slvl_alloc
(
int
iobase
,
int
irq
)
{
struct
net_device
*
d
;
struct
slvl_device
*
sv
;
d
=
alloc_netdev
(
sizeof
(
struct
slvl_device
),
"hdlc%d"
,
slvl_setup
);
if
(
!
d
)
return
NULL
;
sv
=
d
->
priv
;
d
->
ml_priv
=
sv
;
sv
->
if_ptr
=
&
sv
->
pppdev
;
sv
->
pppdev
.
dev
=
d
;
d
->
base_addr
=
iobase
;
d
->
irq
=
irq
;
return
sv
;
}
/*
* Allocate and setup Sealevel board.
*/
static
__init
struct
slvl_board
*
slvl_init
(
int
iobase
,
int
irq
,
static
__init
struct
slvl_board
*
slvl_init
(
int
iobase
,
int
irq
,
int
txdma
,
int
rxdma
,
int
slow
)
{
struct
z8530_dev
*
dev
;
struct
slvl_board
*
b
;
/*
* Get the needed I/O space
*/
if
(
!
request_region
(
iobase
,
8
,
"Sealevel 4021"
))
{
printk
(
KERN_WARNING
"sealevel: I/O 0x%X already in use.
\n
"
,
iobase
);
if
(
!
request_region
(
iobase
,
8
,
"Sealevel 4021"
))
{
printk
(
KERN_WARNING
"sealevel: I/O 0x%X already in use.
\n
"
,
iobase
);
return
NULL
;
}
b
=
kzalloc
(
sizeof
(
struct
slvl_board
),
GFP_KERNEL
);
if
(
!
b
)
goto
fail3
;
if
(
!
(
b
->
dev
[
0
]
=
slvl_alloc
(
iobase
,
irq
)))
goto
fail2
;
b
=
kzalloc
(
sizeof
(
struct
slvl_board
),
GFP_KERNEL
);
if
(
!
b
)
goto
err_kzalloc
;
b
->
dev
[
0
]
->
chan
=
&
b
->
board
.
chanA
;
b
->
dev
[
0
]
->
channel
=
0
;
if
(
!
(
b
->
dev
[
1
]
=
slvl_alloc
(
iobase
,
irq
)))
goto
fail1_0
;
b
->
dev
[
0
].
chan
=
&
b
->
board
.
chanA
;
b
->
dev
[
0
].
channel
=
0
;
b
->
dev
[
1
]
->
chan
=
&
b
->
board
.
chanB
;
b
->
dev
[
1
]
->
channel
=
1
;
b
->
dev
[
1
]
.
chan
=
&
b
->
board
.
chanB
;
b
->
dev
[
1
]
.
channel
=
1
;
dev
=
&
b
->
board
;
/*
* Stuff in the I/O addressing
*/
dev
->
active
=
0
;
b
->
iobase
=
iobase
;
/*
* Select 8530 delays for the old board
*/
if
(
slow
)
if
(
slow
)
iobase
|=
Z8530_PORT_SLEEP
;
dev
->
chanA
.
ctrlio
=
iobase
+
1
;
dev
->
chanA
.
dataio
=
iobase
;
dev
->
chanB
.
ctrlio
=
iobase
+
3
;
dev
->
chanB
.
dataio
=
iobase
+
2
;
dev
->
chanA
.
irqs
=
&
z8530_nop
;
dev
->
chanB
.
irqs
=
&
z8530_nop
;
dev
->
chanA
.
ctrlio
=
iobase
+
1
;
dev
->
chanA
.
dataio
=
iobase
;
dev
->
chanB
.
ctrlio
=
iobase
+
3
;
dev
->
chanB
.
dataio
=
iobase
+
2
;
dev
->
chanA
.
irqs
=
&
z8530_nop
;
dev
->
chanB
.
irqs
=
&
z8530_nop
;
/*
* Assert DTR enable DMA
*/
outb
(
3
|
(
1
<<
7
),
b
->
iobase
+
4
);
outb
(
3
|
(
1
<<
7
),
b
->
iobase
+
4
);
/* We want a fast IRQ for this device. Actually we'd like an even faster
IRQ ;) - This is one driver RtLinux is made for */
if
(
request_irq
(
irq
,
&
z8530_interrupt
,
IRQF_DISABLED
,
"SeaLevel"
,
dev
)
<
0
)
{
if
(
request_irq
(
irq
,
&
z8530_interrupt
,
IRQF_DISABLED
,
"SeaLevel"
,
dev
)
<
0
)
{
printk
(
KERN_WARNING
"sealevel: IRQ %d already in use.
\n
"
,
irq
);
goto
fail1_1
;
goto
err_request_irq
;
}
dev
->
irq
=
irq
;
dev
->
chanA
.
private
=&
b
->
dev
[
0
];
dev
->
chanB
.
private
=&
b
->
dev
[
1
];
dev
->
chanA
.
netdevice
=
b
->
dev
[
0
]
->
pppdev
.
dev
;
dev
->
chanB
.
netdevice
=
b
->
dev
[
1
]
->
pppdev
.
dev
;
dev
->
chanA
.
dev
=
dev
;
dev
->
chanB
.
dev
=
dev
;
dev
->
chanA
.
txdma
=
3
;
dev
->
chanA
.
rxdma
=
1
;
if
(
request_dma
(
dev
->
chanA
.
txdma
,
"SeaLevel (TX)"
)
!=
0
)
goto
fail
;
if
(
request_dma
(
dev
->
chanA
.
rxdma
,
"SeaLevel (RX)"
)
!=
0
)
goto
dmafail
;
dev
->
irq
=
irq
;
dev
->
chanA
.
private
=
&
b
->
dev
[
0
];
dev
->
chanB
.
private
=
&
b
->
dev
[
1
];
dev
->
chanA
.
dev
=
dev
;
dev
->
chanB
.
dev
=
dev
;
dev
->
chanA
.
txdma
=
3
;
dev
->
chanA
.
rxdma
=
1
;
if
(
request_dma
(
dev
->
chanA
.
txdma
,
"SeaLevel (TX)"
))
goto
err_dma_tx
;
if
(
request_dma
(
dev
->
chanA
.
rxdma
,
"SeaLevel (RX)"
))
goto
err_dma_rx
;
disable_irq
(
irq
);
/*
* Begin normal initialise
*/
if
(
z8530_init
(
dev
)
!=
0
)
{
if
(
z8530_init
(
dev
)
!=
0
)
{
printk
(
KERN_ERR
"Z8530 series device not found.
\n
"
);
enable_irq
(
irq
);
goto
dmafail2
;
goto
free_hw
;
}
if
(
dev
->
type
==
Z85C30
)
{
if
(
dev
->
type
==
Z85C30
)
{
z8530_channel_load
(
&
dev
->
chanA
,
z8530_hdlc_kilostream
);
z8530_channel_load
(
&
dev
->
chanB
,
z8530_hdlc_kilostream
);
}
else
{
}
else
{
z8530_channel_load
(
&
dev
->
chanA
,
z8530_hdlc_kilostream_85230
);
z8530_channel_load
(
&
dev
->
chanB
,
z8530_hdlc_kilostream_85230
);
}
...
...
@@ -370,36 +302,31 @@ static __init struct slvl_board *slvl_init(int iobase, int irq,
/*
* Now we can take the IRQ
*/
enable_irq
(
irq
);
if
(
register_netdev
(
b
->
dev
[
0
]
->
pppdev
.
dev
))
goto
dmafail2
;
if
(
register_netdev
(
b
->
dev
[
1
]
->
pppdev
.
dev
))
goto
fail_unit
;
if
(
slvl_setup
(
&
b
->
dev
[
0
],
iobase
,
irq
))
goto
free_hw
;
if
(
slvl_setup
(
&
b
->
dev
[
1
],
iobase
,
irq
))
goto
free_netdev0
;
z8530_describe
(
dev
,
"I/O"
,
iobase
);
dev
->
active
=
1
;
dev
->
active
=
1
;
return
b
;
f
ail_unit
:
unregister_
netdev
(
b
->
dev
[
0
]
->
pppdev
.
dev
);
dmafail2
:
f
ree_netdev0
:
unregister_
hdlc_device
(
b
->
dev
[
0
].
chan
->
netdevice
);
free_netdev
(
b
->
dev
[
0
].
chan
->
netdevice
);
free_hw
:
free_dma
(
dev
->
chanA
.
rxdma
);
dmafail
:
err_dma_rx
:
free_dma
(
dev
->
chanA
.
txdma
);
fail
:
err_dma_tx
:
free_irq
(
irq
,
dev
);
fail1_1:
free_netdev
(
b
->
dev
[
1
]
->
pppdev
.
dev
);
fail1_0:
free_netdev
(
b
->
dev
[
0
]
->
pppdev
.
dev
);
fail2:
err_request_irq:
kfree
(
b
);
fail3
:
release_region
(
iobase
,
8
);
err_kzalloc
:
release_region
(
iobase
,
8
);
return
NULL
;
}
...
...
@@ -408,14 +335,14 @@ static void __exit slvl_shutdown(struct slvl_board *b)
int
u
;
z8530_shutdown
(
&
b
->
board
);
for
(
u
=
0
;
u
<
2
;
u
++
)
for
(
u
=
0
;
u
<
2
;
u
++
)
{
struct
net_device
*
d
=
b
->
dev
[
u
]
->
pppdev
.
dev
;
unregister_
netdev
(
d
);
struct
net_device
*
d
=
b
->
dev
[
u
]
.
chan
->
netdevice
;
unregister_
hdlc_device
(
d
);
free_netdev
(
d
);
}
free_irq
(
b
->
board
.
irq
,
&
b
->
board
);
free_dma
(
b
->
board
.
chanA
.
rxdma
);
free_dma
(
b
->
board
.
chanA
.
txdma
);
...
...
@@ -451,10 +378,6 @@ static struct slvl_board *slvl_unit;
static
int
__init
slvl_init_module
(
void
)
{
#ifdef MODULE
printk
(
KERN_INFO
"SeaLevel Z85230 Synchronous Driver v 0.02.
\n
"
);
printk
(
KERN_INFO
"(c) Copyright 1998, Building Number Three Ltd.
\n
"
);
#endif
slvl_unit
=
slvl_init
(
io
,
irq
,
txdma
,
rxdma
,
slow
);
return
slvl_unit
?
0
:
-
ENODEV
;
...
...
drivers/net/wan/syncppp.c
浏览文件 @
3859069b
...
...
@@ -230,13 +230,6 @@ static void sppp_input (struct net_device *dev, struct sk_buff *skb)
skb
->
dev
=
dev
;
skb_reset_mac_header
(
skb
);
if
(
dev
->
flags
&
IFF_RUNNING
)
{
/* Count received bytes, add FCS and one flag */
sp
->
ibytes
+=
skb
->
len
+
3
;
sp
->
ipkts
++
;
}
if
(
!
pskb_may_pull
(
skb
,
PPP_HEADER_LEN
))
{
/* Too small packet, drop it. */
if
(
sp
->
pp_flags
&
PP_DEBUG
)
...
...
@@ -832,7 +825,6 @@ static void sppp_cp_send (struct sppp *sp, u16 proto, u8 type,
sppp_print_bytes
((
u8
*
)
(
lh
+
1
),
len
);
printk
(
">
\n
"
);
}
sp
->
obytes
+=
skb
->
len
;
/* Control is high priority so it doesn't get queued behind data */
skb
->
priority
=
TC_PRIO_CONTROL
;
skb
->
dev
=
dev
;
...
...
@@ -875,7 +867,6 @@ static void sppp_cisco_send (struct sppp *sp, int type, u32 par1, u32 par2)
printk
(
KERN_WARNING
"%s: cisco output: <%xh %xh %xh %xh %xh-%xh>
\n
"
,
dev
->
name
,
ntohl
(
ch
->
type
),
ch
->
par1
,
ch
->
par2
,
ch
->
rel
,
ch
->
time0
,
ch
->
time1
);
sp
->
obytes
+=
skb
->
len
;
skb
->
priority
=
TC_PRIO_CONTROL
;
skb
->
dev
=
dev
;
skb_queue_tail
(
&
tx_queue
,
skb
);
...
...
drivers/net/wan/z85230.c
浏览文件 @
3859069b
此差异已折叠。
点击以展开。
drivers/net/wan/z85230.h
浏览文件 @
3859069b
此差异已折叠。
点击以展开。
include/net/syncppp.h
浏览文件 @
3859069b
...
...
@@ -43,8 +43,6 @@ struct sppp
u32
pp_rseq
;
/* remote sequence number */
struct
slcp
lcp
;
/* LCP params */
struct
sipcp
ipcp
;
/* IPCP params */
u32
ibytes
,
obytes
;
/* Bytes in/out */
u32
ipkts
,
opkts
;
/* Packets in/out */
struct
timer_list
pp_timer
;
struct
net_device
*
pp_if
;
char
pp_link_state
;
/* Link status */
...
...
net/wanrouter/wanmain.c
浏览文件 @
3859069b
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录