Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
abc9d91a
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
abc9d91a
编写于
7月 09, 2008
作者:
K
Krzysztof Hałasa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WAN: convert HD64572-based drivers to NAPI.
Signed-off-by:
N
Krzysztof Hałasa
<
khc@pm.waw.pl
>
上级
30224392
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
37 deletion
+71
-37
drivers/net/wan/hd64572.c
drivers/net/wan/hd64572.c
+67
-35
drivers/net/wan/pc300too.c
drivers/net/wan/pc300too.c
+2
-1
drivers/net/wan/pci200syn.c
drivers/net/wan/pci200syn.c
+2
-1
未找到文件。
drivers/net/wan/hd64572.c
浏览文件 @
abc9d91a
/*
* Hitachi (now Renesas) SCA-II HD64572 driver for Linux
*
* Copyright (C) 1998-200
3
Krzysztof Halasa <khc@pm.waw.pl>
* Copyright (C) 1998-200
8
Krzysztof Halasa <khc@pm.waw.pl>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License
...
...
@@ -45,6 +45,8 @@
#include <asm/uaccess.h>
#include "hd64572.h"
#define NAPI_WEIGHT 16
#define get_msci(port) (phy_node(port) ? MSCI1_OFFSET : MSCI0_OFFSET)
#define get_dmac_rx(port) (phy_node(port) ? DMAC1RX_OFFSET : DMAC0RX_OFFSET)
#define get_dmac_tx(port) (phy_node(port) ? DMAC1TX_OFFSET : DMAC0TX_OFFSET)
...
...
@@ -53,6 +55,7 @@
#define SCA_INTR_DMAC_RX(node) (node ? 0x20 : 0x02)
#define SCA_INTR_DMAC_TX(node) (node ? 0x40 : 0x04)
static
int
sca_poll
(
struct
napi_struct
*
napi
,
int
budget
);
static
inline
struct
net_device
*
port_to_dev
(
port_t
*
port
)
{
...
...
@@ -86,6 +89,20 @@ static inline port_t* dev_to_port(struct net_device *dev)
return
dev_to_hdlc
(
dev
)
->
priv
;
}
static
inline
void
enable_intr
(
port_t
*
port
)
{
/* DMA & MSCI IRQ enable */
/* IR0_TXINT | IR0_RXINTA | IR0_DMIB* | IR0_DMIA* */
sca_outl
(
sca_inl
(
IER0
,
port
->
card
)
|
(
phy_node
(
port
)
?
0x0A006600
:
0x000A0066
),
IER0
,
port
->
card
);
}
static
inline
void
disable_intr
(
port_t
*
port
)
{
sca_outl
(
sca_inl
(
IER0
,
port
->
card
)
&
(
phy_node
(
port
)
?
0x00FF00FF
:
0xFF00FF00
),
IER0
,
port
->
card
);
}
static
inline
u16
next_desc
(
port_t
*
port
,
u16
desc
,
int
transmit
)
{
return
(
desc
+
1
)
%
(
transmit
?
port_to_card
(
port
)
->
tx_ring_buffers
...
...
@@ -206,6 +223,7 @@ static void sca_init_port(port_t *port)
}
}
sca_set_carrier
(
port
);
netif_napi_add
(
port_to_dev
(
port
),
&
port
->
napi
,
sca_poll
,
NAPI_WEIGHT
);
}
...
...
@@ -256,17 +274,18 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
dev
->
stats
.
rx_packets
++
;
dev
->
stats
.
rx_bytes
+=
skb
->
len
;
skb
->
protocol
=
hdlc_type_trans
(
skb
,
dev
);
netif_r
x
(
skb
);
netif_r
eceive_skb
(
skb
);
}
/* Receive DMA
interrupt
service */
static
inline
void
sca_rx_intr
(
port_t
*
por
t
)
/* Receive DMA service */
static
inline
int
sca_rx_done
(
port_t
*
port
,
int
budge
t
)
{
struct
net_device
*
dev
=
port_to_dev
(
port
);
u16
dmac
=
get_dmac_rx
(
port
);
card_t
*
card
=
port_to_card
(
port
);
u8
stat
=
sca_in
(
DSR_RX
(
phy_node
(
port
)),
card
);
/* read DMA Status */
int
received
=
0
;
/* Reset DSR status bits */
sca_out
((
stat
&
(
DSR_EOT
|
DSR_EOM
|
DSR_BOF
|
DSR_COF
))
|
DSR_DWE
,
...
...
@@ -276,7 +295,7 @@ static inline void sca_rx_intr(port_t *port)
/* Dropped one or more frames */
dev
->
stats
.
rx_over_errors
++
;
while
(
1
)
{
while
(
received
<
budget
)
{
u32
desc_off
=
desc_offset
(
port
,
port
->
rxin
,
0
);
pkt_desc
__iomem
*
desc
;
u32
cda
=
sca_inl
(
dmac
+
CDAL
,
card
);
...
...
@@ -299,8 +318,10 @@ static inline void sca_rx_intr(port_t *port)
dev
->
stats
.
rx_crc_errors
++
;
if
(
stat
&
ST_RX_EOM
)
port
->
rxpart
=
0
;
/* received last fragment */
}
else
}
else
{
sca_rx
(
card
,
port
,
desc
,
port
->
rxin
);
received
++
;
}
/* Set new error descriptor address */
sca_outl
(
desc_off
,
dmac
+
EDAL
,
card
);
...
...
@@ -309,11 +330,12 @@ static inline void sca_rx_intr(port_t *port)
/* make sure RX DMA is enabled */
sca_out
(
DSR_DE
,
DSR_RX
(
phy_node
(
port
)),
card
);
return
received
;
}
/* Transmit DMA
interrupt
service */
static
inline
void
sca_tx_
intr
(
port_t
*
port
)
/* Transmit DMA service */
static
inline
void
sca_tx_
done
(
port_t
*
port
)
{
struct
net_device
*
dev
=
port_to_dev
(
port
);
u16
dmac
=
get_dmac_tx
(
port
);
...
...
@@ -348,27 +370,43 @@ static inline void sca_tx_intr(port_t *port)
}
static
int
sca_poll
(
struct
napi_struct
*
napi
,
int
budget
)
{
port_t
*
port
=
container_of
(
napi
,
port_t
,
napi
);
u8
stat
=
sca_intr_status
(
port
->
card
);
int
received
=
0
;
if
(
stat
&
SCA_INTR_MSCI
(
port
->
phy_node
))
sca_msci_intr
(
port
);
if
(
stat
&
SCA_INTR_DMAC_TX
(
port
->
phy_node
))
sca_tx_done
(
port
);
if
(
stat
&
SCA_INTR_DMAC_RX
(
port
->
phy_node
))
received
=
sca_rx_done
(
port
,
budget
);
if
(
received
<
budget
)
{
netif_rx_complete
(
port
->
dev
,
napi
);
enable_intr
(
port
);
}
return
received
;
}
static
irqreturn_t
sca_intr
(
int
irq
,
void
*
dev_id
)
{
card_t
*
card
=
dev_id
;
int
i
;
u8
stat
;
u8
stat
=
sca_intr_status
(
card
)
;
int
handled
=
0
;
while
((
stat
=
sca_intr_status
(
card
))
!=
0
)
{
handled
=
1
;
for
(
i
=
0
;
i
<
2
;
i
++
)
{
port_t
*
port
=
get_port
(
card
,
i
);
if
(
port
)
{
if
(
stat
&
SCA_INTR_MSCI
(
i
))
sca_msci_intr
(
port
);
if
(
stat
&
SCA_INTR_DMAC_RX
(
i
))
sca_rx_intr
(
port
);
if
(
stat
&
SCA_INTR_DMAC_TX
(
i
))
sca_tx_intr
(
port
);
}
for
(
i
=
0
;
i
<
2
;
i
++
)
{
port_t
*
port
=
get_port
(
card
,
i
);
if
(
port
&&
(
stat
&
(
SCA_INTR_MSCI
(
i
)
|
SCA_INTR_DMAC_RX
(
i
)
|
SCA_INTR_DMAC_TX
(
i
))))
{
handled
=
1
;
disable_intr
(
port
);
netif_rx_schedule
(
port
->
dev
,
&
port
->
napi
);
}
}
...
...
@@ -470,18 +508,12 @@ static void sca_open(struct net_device *dev)
sca_out
(
0x3F
,
msci
+
TNR1
,
card
);
/* +1=TX DMA deactivation condition*/
/* We're using the following interrupts:
- TXINT (DMAC completed all transmisions, underrun or DCD change)
- TXINT (DMAC completed all transmis
s
ions, underrun or DCD change)
- all DMA interrupts
*/
sca_set_carrier
(
port
);
/* MSCI TXINT and RXINTA interrupt enable */
sca_outl
(
IE0_TXINT
|
IE0_RXINTA
|
IE0_UDRN
|
IE0_CDCD
,
msci
+
IE0
,
card
);
/* DMA & MSCI IRQ enable */
sca_outl
(
sca_inl
(
IER0
,
card
)
|
(
phy_node
(
port
)
?
0x0A006600
:
0x000A0066
),
IER0
,
card
);
sca_out
(
port
->
tmc
,
msci
+
TMCR
,
card
);
sca_out
(
port
->
tmc
,
msci
+
TMCT
,
card
);
...
...
@@ -490,6 +522,9 @@ static void sca_open(struct net_device *dev)
sca_out
(
CMD_TX_ENABLE
,
msci
+
CMD
,
card
);
sca_out
(
CMD_RX_ENABLE
,
msci
+
CMD
,
card
);
sca_set_carrier
(
port
);
enable_intr
(
port
);
napi_enable
(
&
port
->
napi
);
netif_start_queue
(
dev
);
}
...
...
@@ -497,14 +532,11 @@ static void sca_open(struct net_device *dev)
static
void
sca_close
(
struct
net_device
*
dev
)
{
port_t
*
port
=
dev_to_port
(
dev
);
card_t
*
card
=
port_to_card
(
port
);
/* reset channel */
sca_out
(
CMD_RESET
,
get_msci
(
port
)
+
CMD
,
port_to_card
(
port
));
/* disable DMA & MSCI IRQ */
sca_outl
(
sca_inl
(
IER0
,
card
)
&
(
phy_node
(
port
)
?
0x00FF00FF
:
0xFF00FF00
),
IER0
,
card
);
disable_intr
(
port
);
napi_disable
(
&
port
->
napi
);
netif_stop_queue
(
dev
);
}
...
...
drivers/net/wan/pc300too.c
浏览文件 @
abc9d91a
...
...
@@ -78,6 +78,7 @@ typedef struct {
typedef
struct
port_s
{
struct
napi_struct
napi
;
struct
net_device
*
dev
;
struct
card_s
*
card
;
spinlock_t
lock
;
/* TX lock */
...
...
@@ -481,6 +482,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
else
port
->
iface
=
IF_IFACE_V35
;
sca_init_port
(
port
);
if
(
register_hdlc_device
(
dev
))
{
printk
(
KERN_ERR
"pc300: unable to register hdlc "
"device
\n
"
);
...
...
@@ -488,7 +490,6 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
pc300_pci_remove_one
(
pdev
);
return
-
ENOBUFS
;
}
sca_init_port
(
port
);
/* Set up SCA memory */
printk
(
KERN_INFO
"%s: PC300 node %d
\n
"
,
dev
->
name
,
port
->
phy_node
);
...
...
drivers/net/wan/pci200syn.c
浏览文件 @
abc9d91a
...
...
@@ -65,6 +65,7 @@ typedef struct {
typedef
struct
port_s
{
struct
napi_struct
napi
;
struct
net_device
*
dev
;
struct
card_s
*
card
;
spinlock_t
lock
;
/* TX lock */
...
...
@@ -423,6 +424,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
hdlc
->
xmit
=
sca_xmit
;
port
->
settings
.
clock_type
=
CLOCK_EXT
;
port
->
card
=
card
;
sca_init_port
(
port
);
if
(
register_hdlc_device
(
dev
))
{
printk
(
KERN_ERR
"pci200syn: unable to register hdlc "
"device
\n
"
);
...
...
@@ -430,7 +432,6 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
pci200_pci_remove_one
(
pdev
);
return
-
ENOBUFS
;
}
sca_init_port
(
port
);
/* Set up SCA memory */
printk
(
KERN_INFO
"%s: PCI200SYN node %d
\n
"
,
dev
->
name
,
port
->
phy_node
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录