Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
6b85b41b
Commit
6b85b41b
authored
Jan 10, 2004
by
Alexander Viro
Committed by
Stephen Hemminger
Jan 10, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[wan hdlc] new port_to_dev() helper
New helper in hd6457x.c: port_to_dev(). A bunch of port->hdlc eliminated.
parent
d5dc249c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
32 deletions
+49
-32
drivers/net/wan/c101.c
drivers/net/wan/c101.c
+14
-10
drivers/net/wan/hd6457x.c
drivers/net/wan/hd6457x.c
+25
-15
drivers/net/wan/n2.c
drivers/net/wan/n2.c
+10
-7
No files found.
drivers/net/wan/c101.c
View file @
6b85b41b
...
...
@@ -121,6 +121,7 @@ static inline void openwin(card_t *card, u8 page)
static
void
sca_msci_intr
(
port_t
*
port
)
{
struct
net_device
*
dev
=
port_to_dev
(
port
);
card_t
*
card
=
port_to_card
(
port
);
u8
stat
=
sca_in
(
MSCI1_OFFSET
+
ST1
,
card
);
/* read MSCI ST1 status */
...
...
@@ -128,8 +129,9 @@ static void sca_msci_intr(port_t *port)
sca_out
(
stat
&
ST1_UDRN
,
MSCI0_OFFSET
+
ST1
,
card
);
if
(
stat
&
ST1_UDRN
)
{
port
->
hdlc
.
stats
.
tx_errors
++
;
/* TX Underrun error detected */
port
->
hdlc
.
stats
.
tx_fifo_errors
++
;
struct
net_device_stats
*
stats
=
&
dev_to_hdlc
(
dev
)
->
stats
;
stats
->
tx_errors
++
;
/* TX Underrun error detected */
stats
->
tx_fifo_errors
++
;
}
/* Reset MSCI CDCD status bit - uses ch#2 DCD input */
...
...
@@ -137,7 +139,7 @@ static void sca_msci_intr(port_t *port)
if
(
stat
&
ST1_CDCD
)
hdlc_set_carrier
(
!
(
sca_in
(
MSCI1_OFFSET
+
ST3
,
card
)
&
ST3_DCD
),
&
port
->
hdlc
);
dev_to_hdlc
(
dev
)
);
}
...
...
@@ -296,6 +298,7 @@ static void c101_destroy_card(card_t *card)
static
int
__init
c101_run
(
unsigned
long
irq
,
unsigned
long
winbase
)
{
struct
net_device
*
dev
;
hdlc_device
*
hdlc
;
card_t
*
card
;
int
result
;
...
...
@@ -347,7 +350,8 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
sca_init
(
card
,
0
);
dev
=
hdlc_to_dev
(
&
card
->
hdlc
);
dev
=
port_to_dev
(
card
);
hdlc
=
dev_to_hdlc
(
dev
);
spin_lock_init
(
&
card
->
lock
);
SET_MODULE_OWNER
(
dev
);
...
...
@@ -358,11 +362,11 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
dev
->
do_ioctl
=
c101_ioctl
;
dev
->
open
=
c101_open
;
dev
->
stop
=
c101_close
;
card
->
hdlc
.
attach
=
sca_attach
;
card
->
hdlc
.
xmit
=
sca_xmit
;
hdlc
->
attach
=
sca_attach
;
hdlc
->
xmit
=
sca_xmit
;
card
->
settings
.
clock_type
=
CLOCK_EXT
;
result
=
register_hdlc_device
(
&
card
->
hdlc
);
result
=
register_hdlc_device
(
hdlc
);
if
(
result
)
{
printk
(
KERN_WARNING
"c101: unable to register hdlc device
\n
"
);
c101_destroy_card
(
card
);
...
...
@@ -371,11 +375,11 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
sca_init_sync_port
(
card
);
/* Set up C101 memory */
hdlc_set_carrier
(
!
(
sca_in
(
MSCI1_OFFSET
+
ST3
,
card
)
&
ST3_DCD
),
&
card
->
hdlc
);
dev_to_hdlc
(
dev
)
);
printk
(
KERN_INFO
"%s: Moxa C101 on IRQ%u,"
" using %u TX + %u RX packets rings
\n
"
,
hdlc_to_name
(
&
card
->
hdlc
)
,
card
->
irq
,
dev
->
name
,
card
->
irq
,
card
->
tx_ring_buffers
,
card
->
rx_ring_buffers
);
*
new_card
=
card
;
...
...
@@ -424,7 +428,7 @@ static void __exit c101_cleanup(void)
while
(
card
)
{
card_t
*
ptr
=
card
;
card
=
card
->
next_card
;
unregister_hdlc_device
(
&
ptr
->
hdlc
);
unregister_hdlc_device
(
dev_to_hdlc
(
port_to_dev
(
ptr
))
);
c101_destroy_card
(
ptr
);
}
}
...
...
drivers/net/wan/hd6457x.c
View file @
6b85b41b
...
...
@@ -73,6 +73,11 @@
#define writea(value, ptr) writel(value, ptr)
#endif
static
inline
struct
net_device
*
port_to_dev
(
port_t
*
port
)
{
return
hdlc_to_dev
(
&
port
->
hdlc
);
}
static
inline
int
sca_intr_status
(
card_t
*
card
)
{
u8
result
=
0
;
...
...
@@ -245,7 +250,7 @@ static void sca_init_sync_port(port_t *port)
}
hdlc_set_carrier
(
!
(
sca_in
(
get_msci
(
port
)
+
ST3
,
card
)
&
ST3_DCD
),
&
port
->
hdlc
);
dev_to_hdlc
(
port_to_dev
(
port
))
);
}
...
...
@@ -262,13 +267,14 @@ static inline void sca_msci_intr(port_t *port)
sca_out
(
stat
&
(
ST1_UDRN
|
ST1_CDCD
),
msci
+
ST1
,
card
);
if
(
stat
&
ST1_UDRN
)
{
port
->
hdlc
.
stats
.
tx_errors
++
;
/* TX Underrun error detected */
port
->
hdlc
.
stats
.
tx_fifo_errors
++
;
hdlc_device
*
hdlc
=
dev_to_hdlc
(
port_to_dev
(
port
));
hdlc
->
stats
.
tx_errors
++
;
/* TX Underrun error detected */
hdlc
->
stats
.
tx_fifo_errors
++
;
}
if
(
stat
&
ST1_CDCD
)
hdlc_set_carrier
(
!
(
sca_in
(
msci
+
ST3
,
card
)
&
ST3_DCD
),
&
port
->
hdlc
);
dev_to_hdlc
(
port_to_dev
(
port
))
);
}
#endif
...
...
@@ -276,6 +282,8 @@ static inline void sca_msci_intr(port_t *port)
static
inline
void
sca_rx
(
card_t
*
card
,
port_t
*
port
,
pkt_desc
*
desc
,
u16
rxin
)
{
struct
net_device
*
dev
=
port_to_dev
(
port
);
struct
net_device_stats
*
stats
=
&
dev_to_hdlc
(
dev
)
->
stats
;
struct
sk_buff
*
skb
;
u16
len
;
u32
buff
;
...
...
@@ -287,7 +295,7 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc *desc, u16 rxin)
len
=
readw
(
&
desc
->
len
);
skb
=
dev_alloc_skb
(
len
);
if
(
!
skb
)
{
port
->
hdlc
.
stats
.
rx_dropped
++
;
stats
->
rx_dropped
++
;
return
;
}
...
...
@@ -313,15 +321,15 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc *desc, u16 rxin)
#endif
skb_put
(
skb
,
len
);
#ifdef DEBUG_PKT
printk
(
KERN_DEBUG
"%s RX(%i):"
,
hdlc_to_name
(
&
port
->
hdlc
)
,
skb
->
len
);
printk
(
KERN_DEBUG
"%s RX(%i):"
,
dev
->
name
,
skb
->
len
);
debug_frame
(
skb
);
#endif
port
->
hdlc
.
stats
.
rx_packets
++
;
port
->
hdlc
.
stats
.
rx_bytes
+=
skb
->
len
;
stats
->
rx_packets
++
;
stats
->
rx_bytes
+=
skb
->
len
;
skb
->
mac
.
raw
=
skb
->
data
;
skb
->
dev
=
hdlc_to_dev
(
&
port
->
hdlc
)
;
skb
->
dev
=
dev
;
skb
->
dev
->
last_rx
=
jiffies
;
skb
->
protocol
=
hdlc_type_trans
(
skb
,
hdlc_to_dev
(
&
port
->
hdlc
)
);
skb
->
protocol
=
hdlc_type_trans
(
skb
,
dev
);
netif_rx
(
skb
);
}
...
...
@@ -333,7 +341,7 @@ static inline void sca_rx_intr(port_t *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 */
struct
net_device_stats
*
stats
=
&
port
->
hdlc
.
stats
;
struct
net_device_stats
*
stats
=
&
dev_to_hdlc
(
port_to_dev
(
port
))
->
stats
;
/* Reset DSR status bits */
sca_out
((
stat
&
(
DSR_EOT
|
DSR_EOM
|
DSR_BOF
|
DSR_COF
))
|
DSR_DWE
,
...
...
@@ -380,6 +388,8 @@ static inline void sca_rx_intr(port_t *port)
/* Transmit DMA interrupt service */
static
inline
void
sca_tx_intr
(
port_t
*
port
)
{
struct
net_device
*
dev
=
port_to_dev
(
port
);
struct
net_device_stats
*
stats
=
&
dev_to_hdlc
(
dev
)
->
stats
;
u16
dmac
=
get_dmac_tx
(
port
);
card_t
*
card
=
port_to_card
(
port
);
u8
stat
;
...
...
@@ -401,13 +411,13 @@ static inline void sca_tx_intr(port_t *port)
break
;
/* Transmitter is/will_be sending this frame */
desc
=
desc_address
(
port
,
port
->
txlast
,
1
);
port
->
hdlc
.
stats
.
tx_packets
++
;
port
->
hdlc
.
stats
.
tx_bytes
+=
readw
(
&
desc
->
len
);
stats
->
tx_packets
++
;
stats
->
tx_bytes
+=
readw
(
&
desc
->
len
);
writeb
(
0
,
&
desc
->
stat
);
/* Free descriptor */
port
->
txlast
=
next_desc
(
port
,
port
->
txlast
,
1
);
}
netif_wake_queue
(
hdlc_to_dev
(
&
port
->
hdlc
)
);
netif_wake_queue
(
dev
);
spin_unlock
(
&
port
->
lock
);
}
...
...
@@ -790,7 +800,7 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev)
desc
=
desc_address
(
port
,
port
->
txin
+
1
,
1
);
if
(
readb
(
&
desc
->
stat
))
/* allow 1 packet gap */
netif_stop_queue
(
hdlc_to_dev
(
&
port
->
hdlc
)
);
netif_stop_queue
(
dev
);
spin_unlock_irq
(
&
port
->
lock
);
...
...
drivers/net/wan/n2.c
View file @
6b85b41b
...
...
@@ -312,8 +312,10 @@ static void n2_destroy_card(card_t *card)
int
cnt
;
for
(
cnt
=
0
;
cnt
<
2
;
cnt
++
)
if
(
card
->
ports
[
cnt
].
card
)
unregister_hdlc_device
(
&
card
->
ports
[
cnt
].
hdlc
);
if
(
card
->
ports
[
cnt
].
card
)
{
struct
net_device
*
dev
=
port_to_dev
(
&
card
->
ports
[
cnt
]);
unregister_hdlc_device
(
dev_to_hdlc
(
dev
));
}
if
(
card
->
irq
)
free_irq
(
card
->
irq
,
card
);
...
...
@@ -435,7 +437,8 @@ static int __init n2_run(unsigned long io, unsigned long irq,
sca_init
(
card
,
0
);
for
(
cnt
=
0
;
cnt
<
2
;
cnt
++
)
{
port_t
*
port
=
&
card
->
ports
[
cnt
];
struct
net_device
*
dev
=
hdlc_to_dev
(
&
port
->
hdlc
);
struct
net_device
*
dev
=
port_to_dev
(
port
);
hdlc_device
*
hdlc
=
dev_to_hdlc
(
dev
);
if
((
cnt
==
0
&&
!
valid0
)
||
(
cnt
==
1
&&
!
valid1
))
continue
;
...
...
@@ -455,11 +458,11 @@ static int __init n2_run(unsigned long io, unsigned long irq,
dev
->
do_ioctl
=
n2_ioctl
;
dev
->
open
=
n2_open
;
dev
->
stop
=
n2_close
;
port
->
hdlc
.
attach
=
sca_attach
;
port
->
hdlc
.
xmit
=
sca_xmit
;
hdlc
->
attach
=
sca_attach
;
hdlc
->
xmit
=
sca_xmit
;
port
->
settings
.
clock_type
=
CLOCK_EXT
;
if
(
register_hdlc_device
(
&
port
->
hdlc
))
{
if
(
register_hdlc_device
(
hdlc
))
{
printk
(
KERN_WARNING
"n2: unable to register hdlc "
"device
\n
"
);
n2_destroy_card
(
card
);
...
...
@@ -469,7 +472,7 @@ static int __init n2_run(unsigned long io, unsigned long irq,
sca_init_sync_port
(
port
);
/* Set up SCA memory */
printk
(
KERN_INFO
"%s: RISCom/N2 node %d
\n
"
,
hdlc_to_name
(
&
port
->
hdlc
)
,
port
->
phy_node
);
dev
->
name
,
port
->
phy_node
);
}
*
new_card
=
card
;
...
...
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