Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
abc9d91a
Commit
abc9d91a
authored
Jul 09, 2008
by
Krzysztof Hałasa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WAN: convert HD64572-based drivers to NAPI.
Signed-off-by:
Krzysztof Hałasa
<
khc@pm.waw.pl
>
parent
30224392
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
37 deletions
+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
No files found.
drivers/net/wan/hd64572.c
View file @
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
);
}
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
View file @
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
View file @
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment