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
8dd55211
Commit
8dd55211
authored
Jul 02, 2004
by
Jeff Garzik
Browse files
Options
Browse Files
Download
Plain Diff
Merge pobox.com:/spare/repo/linux-2.6
into pobox.com:/spare/repo/netdev-2.6/velocity
parents
004a3668
a0ba2c5d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
279 additions
and
189 deletions
+279
-189
drivers/net/via-velocity.c
drivers/net/via-velocity.c
+276
-187
drivers/net/via-velocity.h
drivers/net/via-velocity.h
+2
-2
include/linux/pci_ids.h
include/linux/pci_ids.h
+1
-0
No files found.
drivers/net/via-velocity.c
View file @
8dd55211
...
...
@@ -226,7 +226,10 @@ VELOCITY_PARAM(wol_opts, "Wake On Lan options");
VELOCITY_PARAM
(
int_works
,
"Number of packets per interrupt services"
);
static
int
velocity_found1
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
);
static
int
rx_copybreak
=
200
;
MODULE_PARM
(
rx_copybreak
,
"i"
);
MODULE_PARM_DESC
(
rx_copybreak
,
"Copy breakpoint for copy-only-tiny-frames"
);
static
void
velocity_init_info
(
struct
pci_dev
*
pdev
,
struct
velocity_info
*
vptr
,
struct
velocity_info_tbl
*
info
);
static
int
velocity_get_pci_info
(
struct
velocity_info
*
,
struct
pci_dev
*
pdev
);
static
void
velocity_print_info
(
struct
velocity_info
*
vptr
);
...
...
@@ -238,10 +241,8 @@ static void velocity_set_multi(struct net_device *dev);
static
struct
net_device_stats
*
velocity_get_stats
(
struct
net_device
*
dev
);
static
int
velocity_ioctl
(
struct
net_device
*
dev
,
struct
ifreq
*
rq
,
int
cmd
);
static
int
velocity_close
(
struct
net_device
*
dev
);
static
int
velocity_rx_srv
(
struct
velocity_info
*
vptr
,
int
status
);
static
int
velocity_receive_frame
(
struct
velocity_info
*
,
int
idx
);
static
int
velocity_alloc_rx_buf
(
struct
velocity_info
*
,
int
idx
);
static
void
velocity_init_registers
(
struct
velocity_info
*
vptr
,
enum
velocity_init_type
type
);
static
void
velocity_free_rd_ring
(
struct
velocity_info
*
vptr
);
static
void
velocity_free_tx_buf
(
struct
velocity_info
*
vptr
,
struct
velocity_td_info
*
);
static
int
velocity_soft_reset
(
struct
velocity_info
*
vptr
);
...
...
@@ -254,12 +255,8 @@ static void enable_flow_control_ability(struct velocity_info *vptr);
static
void
enable_mii_autopoll
(
struct
mac_regs
*
regs
);
static
int
velocity_mii_read
(
struct
mac_regs
*
,
u8
byIdx
,
u16
*
pdata
);
static
int
velocity_mii_write
(
struct
mac_regs
*
,
u8
byMiiAddr
,
u16
data
);
static
int
velocity_set_wol
(
struct
velocity_info
*
vptr
);
static
void
velocity_save_context
(
struct
velocity_info
*
vptr
,
struct
velocity_context
*
context
);
static
void
velocity_restore_context
(
struct
velocity_info
*
vptr
,
struct
velocity_context
*
context
);
static
u32
mii_check_media_mode
(
struct
mac_regs
*
regs
);
static
u32
check_connection_type
(
struct
mac_regs
*
regs
);
static
void
velocity_init_cam_filter
(
struct
velocity_info
*
vptr
);
static
int
velocity_set_media_mode
(
struct
velocity_info
*
vptr
,
u32
mii_status
);
#ifdef CONFIG_PM
...
...
@@ -269,8 +266,9 @@ static int velocity_resume(struct pci_dev *pdev);
static
int
velocity_netdev_event
(
struct
notifier_block
*
nb
,
unsigned
long
notification
,
void
*
ptr
);
static
struct
notifier_block
velocity_inetaddr_notifier
=
{
notifier_call:
velocity_netdev_event
,
.
notifier_call
=
velocity_netdev_event
,
};
static
int
velocity_notifier_registered
;
#endif
/* CONFIG_PM */
...
...
@@ -289,8 +287,9 @@ static struct velocity_info_tbl chip_info_table[] = {
*/
static
struct
pci_device_id
velocity_id_table
[]
__devinitdata
=
{
{
0x1106
,
0x3119
,
PCI_ANY_ID
,
PCI_ANY_ID
,
0
,
0
,
(
unsigned
long
)
&
chip_info_table
[
0
]},
{
0
,}
{
PCI_VENDOR_ID_VIA
,
PCI_DEVICE_ID_VIA_612X
,
PCI_ANY_ID
,
PCI_ANY_ID
,
0
,
0
,
(
unsigned
long
)
chip_info_table
},
{
0
,
}
};
MODULE_DEVICE_TABLE
(
pci
,
velocity_id_table
);
...
...
@@ -463,6 +462,12 @@ static void velocity_init_cam_filter(struct velocity_info *vptr)
}
}
static
inline
void
velocity_give_rx_desc
(
struct
rx_desc
*
rd
)
{
*
(
u32
*
)
&
rd
->
rdesc0
=
0
;
rd
->
rdesc0
.
owner
=
cpu_to_le32
(
OWNED_BY_NIC
);
}
/**
* velocity_rx_reset - handle a receive reset
* @vptr: velocity we are resetting
...
...
@@ -477,13 +482,13 @@ static void velocity_rx_reset(struct velocity_info *vptr)
struct
mac_regs
*
regs
=
vptr
->
mac_regs
;
int
i
;
vptr
->
rd_
us
ed
=
vptr
->
rd_curr
=
0
;
vptr
->
rd_
dirty
=
vptr
->
rd_fill
ed
=
vptr
->
rd_curr
=
0
;
/*
* Init state, all RD entries belong to the NIC
*/
for
(
i
=
0
;
i
<
vptr
->
options
.
numrx
;
++
i
)
v
ptr
->
rd_ring
[
i
].
rdesc0
.
owner
=
cpu_to_le32
(
OWNED_BY_NIC
);
v
elocity_give_rx_desc
(
vptr
->
rd_ring
+
i
);
writew
(
vptr
->
options
.
numrx
,
&
regs
->
RBRDU
);
writel
(
vptr
->
rd_pool_dma
,
&
regs
->
RDBaseLo
);
...
...
@@ -776,6 +781,12 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
pci_set_power_state
(
pdev
,
3
);
out:
#ifdef CONFIG_PM
if
(
ret
==
0
&&
!
velocity_notifier_registered
)
{
velocity_notifier_registered
=
1
;
register_inetaddr_notifier
(
&
velocity_inetaddr_notifier
);
}
#endif
return
ret
;
err_iounmap:
...
...
@@ -966,6 +977,60 @@ static void velocity_free_rings(struct velocity_info *vptr)
pci_free_consistent
(
vptr
->
pdev
,
size
,
vptr
->
tx_bufs
,
vptr
->
tx_bufs_dma
);
}
static
inline
void
velocity_give_many_rx_descs
(
struct
velocity_info
*
vptr
)
{
struct
mac_regs
*
regs
=
vptr
->
mac_regs
;
int
avail
,
dirty
,
unusable
;
/*
* RD number must be equal to 4X per hardware spec
* (programming guide rev 1.20, p.13)
*/
if
(
vptr
->
rd_filled
<
4
)
return
;
wmb
();
unusable
=
vptr
->
rd_filled
|
0x0003
;
dirty
=
vptr
->
rd_dirty
-
unusable
+
1
;
for
(
avail
=
vptr
->
rd_filled
&
0xfffc
;
avail
;
avail
--
)
{
dirty
=
(
dirty
>
0
)
?
dirty
-
1
:
vptr
->
options
.
numrx
-
1
;
velocity_give_rx_desc
(
vptr
->
rd_ring
+
dirty
);
}
writew
(
vptr
->
rd_filled
&
0xfffc
,
&
regs
->
RBRDU
);
vptr
->
rd_filled
=
unusable
;
}
static
int
velocity_rx_refill
(
struct
velocity_info
*
vptr
)
{
int
dirty
=
vptr
->
rd_dirty
,
done
=
0
,
ret
=
0
;
do
{
struct
rx_desc
*
rd
=
vptr
->
rd_ring
+
dirty
;
/* Fine for an all zero Rx desc at init time as well */
if
(
rd
->
rdesc0
.
owner
==
cpu_to_le32
(
OWNED_BY_NIC
))
break
;
if
(
!
vptr
->
rd_info
[
dirty
].
skb
)
{
ret
=
velocity_alloc_rx_buf
(
vptr
,
dirty
);
if
(
ret
<
0
)
break
;
}
done
++
;
dirty
=
(
dirty
<
vptr
->
options
.
numrx
-
1
)
?
dirty
+
1
:
0
;
}
while
(
dirty
!=
vptr
->
rd_curr
);
if
(
done
)
{
vptr
->
rd_dirty
=
dirty
;
vptr
->
rd_filled
+=
done
;
velocity_give_many_rx_descs
(
vptr
);
}
return
ret
;
}
/**
* velocity_init_rd_ring - set up receive ring
* @vptr: velocity to configure
...
...
@@ -976,9 +1041,7 @@ static void velocity_free_rings(struct velocity_info *vptr)
static
int
velocity_init_rd_ring
(
struct
velocity_info
*
vptr
)
{
int
i
,
ret
=
-
ENOMEM
;
struct
rx_desc
*
rd
;
struct
velocity_rd_info
*
rd_info
;
int
ret
=
-
ENOMEM
;
unsigned
int
rsize
=
sizeof
(
struct
velocity_rd_info
)
*
vptr
->
options
.
numrx
;
...
...
@@ -987,22 +1050,14 @@ static int velocity_init_rd_ring(struct velocity_info *vptr)
goto
out
;
memset
(
vptr
->
rd_info
,
0
,
rsize
);
/* Init the RD ring entries */
for
(
i
=
0
;
i
<
vptr
->
options
.
numrx
;
i
++
)
{
rd
=
&
(
vptr
->
rd_ring
[
i
]);
rd_info
=
&
(
vptr
->
rd_info
[
i
]);
vptr
->
rd_filled
=
vptr
->
rd_dirty
=
vptr
->
rd_curr
=
0
;
ret
=
velocity_alloc_rx_buf
(
vptr
,
i
);
ret
=
velocity_rx_refill
(
vptr
);
if
(
ret
<
0
)
{
VELOCITY_PRT
(
MSG_LEVEL_ERR
,
KERN_ERR
"%s: failed to allocate RX buffer.
\n
"
,
vptr
->
dev
->
name
);
"%s: failed to allocate RX buffer.
\n
"
,
vptr
->
dev
->
name
);
velocity_free_rd_ring
(
vptr
);
goto
out
;
}
rd
->
rdesc0
.
owner
=
OWNED_BY_NIC
;
}
vptr
->
rd_used
=
vptr
->
rd_curr
=
0
;
out:
return
ret
;
}
...
...
@@ -1025,7 +1080,7 @@ static void velocity_free_rd_ring(struct velocity_info *vptr)
for
(
i
=
0
;
i
<
vptr
->
options
.
numrx
;
i
++
)
{
struct
velocity_rd_info
*
rd_info
=
&
(
vptr
->
rd_info
[
i
]);
if
(
!
rd_info
->
skb
_dma
)
if
(
!
rd_info
->
skb
)
continue
;
pci_unmap_single
(
vptr
->
pdev
,
rd_info
->
skb_dma
,
vptr
->
rx_buf_sz
,
PCI_DMA_FROMDEVICE
);
...
...
@@ -1146,22 +1201,14 @@ static void velocity_free_td_ring(struct velocity_info *vptr)
static
int
velocity_rx_srv
(
struct
velocity_info
*
vptr
,
int
status
)
{
struct
rx_desc
*
rd
;
struct
net_device_stats
*
stats
=
&
vptr
->
stats
;
struct
mac_regs
*
regs
=
vptr
->
mac_regs
;
int
rd_curr
=
vptr
->
rd_curr
;
int
works
=
0
;
while
(
1
)
{
struct
rx_desc
*
rd
=
vptr
->
rd_ring
+
rd_curr
;
rd
=
&
(
vptr
->
rd_ring
[
rd_curr
]);
if
((
vptr
->
rd_info
[
rd_curr
]).
skb
==
NULL
)
{
if
(
velocity_alloc_rx_buf
(
vptr
,
rd_curr
)
<
0
)
break
;
}
if
(
works
++
>
15
)
if
(
!
vptr
->
rd_info
[
rd_curr
].
skb
||
(
works
++
>
15
))
break
;
if
(
rd
->
rdesc0
.
owner
==
OWNED_BY_NIC
)
...
...
@@ -1169,17 +1216,10 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)
/*
* Don't drop CE or RL error frame although RXOK is off
* FIXME: need to handle copybreak
*/
if
((
rd
->
rdesc0
.
RSR
&
RSR_RXOK
)
||
(
!
(
rd
->
rdesc0
.
RSR
&
RSR_RXOK
)
&&
(
rd
->
rdesc0
.
RSR
&
(
RSR_CE
|
RSR_RL
))))
{
if
(
velocity_receive_frame
(
vptr
,
rd_curr
)
==
0
)
{
if
(
velocity_alloc_rx_buf
(
vptr
,
rd_curr
)
<
0
)
{
VELOCITY_PRT
(
MSG_LEVEL_ERR
,
KERN_ERR
"%s: can not allocate rx buf
\n
"
,
vptr
->
dev
->
name
);
break
;
}
}
else
{
if
(
velocity_receive_frame
(
vptr
,
rd_curr
)
<
0
)
stats
->
rx_dropped
++
;
}
}
else
{
if
(
rd
->
rdesc0
.
RSR
&
RSR_CRC
)
stats
->
rx_crc_errors
++
;
...
...
@@ -1191,25 +1231,18 @@ static int velocity_rx_srv(struct velocity_info *vptr, int status)
rd
->
inten
=
1
;
if
(
++
vptr
->
rd_used
>=
4
)
{
int
i
,
rd_prev
=
rd_curr
;
for
(
i
=
0
;
i
<
4
;
i
++
)
{
if
(
--
rd_prev
<
0
)
rd_prev
=
vptr
->
options
.
numrx
-
1
;
rd
=
&
(
vptr
->
rd_ring
[
rd_prev
]);
rd
->
rdesc0
.
owner
=
OWNED_BY_NIC
;
}
writew
(
4
,
&
(
regs
->
RBRDU
));
vptr
->
rd_used
-=
4
;
}
vptr
->
dev
->
last_rx
=
jiffies
;
rd_curr
++
;
if
(
rd_curr
>=
vptr
->
options
.
numrx
)
rd_curr
=
0
;
}
if
(
velocity_rx_refill
(
vptr
)
<
0
)
{
VELOCITY_PRT
(
MSG_LEVEL_ERR
,
KERN_ERR
"%s: rx buf allocation failure
\n
"
,
vptr
->
dev
->
name
);
}
vptr
->
rd_curr
=
rd_curr
;
VAR_USED
(
stats
);
return
works
;
...
...
@@ -1241,6 +1274,65 @@ static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb)
}
}
/**
* velocity_rx_copy - in place Rx copy for small packets
* @rx_skb: network layer packet buffer candidate
* @pkt_size: received data size
* @rd: receive packet descriptor
* @dev: network device
*
* Replace the current skb that is scheduled for Rx processing by a
* shorter, immediatly allocated skb, if the received packet is small
* enough. This function returns a negative value if the received
* packet is too big or if memory is exhausted.
*/
static
inline
int
velocity_rx_copy
(
struct
sk_buff
**
rx_skb
,
int
pkt_size
,
struct
velocity_info
*
vptr
)
{
int
ret
=
-
1
;
if
(
pkt_size
<
rx_copybreak
)
{
struct
sk_buff
*
new_skb
;
new_skb
=
dev_alloc_skb
(
pkt_size
+
2
);
if
(
new_skb
)
{
new_skb
->
dev
=
vptr
->
dev
;
new_skb
->
ip_summed
=
rx_skb
[
0
]
->
ip_summed
;
if
(
vptr
->
flags
&
VELOCITY_FLAGS_IP_ALIGN
)
skb_reserve
(
new_skb
,
2
);
memcpy
(
new_skb
->
data
,
rx_skb
[
0
]
->
tail
,
pkt_size
);
*
rx_skb
=
new_skb
;
ret
=
0
;
}
}
return
ret
;
}
/**
* velocity_iph_realign - IP header alignment
* @vptr: velocity we are handling
* @skb: network layer packet buffer
* @pkt_size: received data size
*
* Align IP header on a 2 bytes boundary. This behavior can be
* configured by the user.
*/
static
inline
void
velocity_iph_realign
(
struct
velocity_info
*
vptr
,
struct
sk_buff
*
skb
,
int
pkt_size
)
{
/* FIXME - memmove ? */
if
(
vptr
->
flags
&
VELOCITY_FLAGS_IP_ALIGN
)
{
int
i
;
for
(
i
=
pkt_size
;
i
>=
0
;
i
--
)
*
(
skb
->
data
+
i
+
2
)
=
*
(
skb
->
data
+
i
);
skb_reserve
(
skb
,
2
);
}
}
/**
* velocity_receive_frame - received packet processor
* @vptr: velocity we are handling
...
...
@@ -1252,9 +1344,11 @@ static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb)
static
int
velocity_receive_frame
(
struct
velocity_info
*
vptr
,
int
idx
)
{
void
(
*
pci_action
)(
struct
pci_dev
*
,
dma_addr_t
,
size_t
,
int
);
struct
net_device_stats
*
stats
=
&
vptr
->
stats
;
struct
velocity_rd_info
*
rd_info
=
&
(
vptr
->
rd_info
[
idx
]);
struct
rx_desc
*
rd
=
&
(
vptr
->
rd_ring
[
idx
]);
int
pkt_len
=
rd
->
rdesc0
.
len
;
struct
sk_buff
*
skb
;
if
(
rd
->
rdesc0
.
RSR
&
(
RSR_STP
|
RSR_EDP
))
{
...
...
@@ -1269,22 +1363,8 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
skb
=
rd_info
->
skb
;
skb
->
dev
=
vptr
->
dev
;
pci_unmap_single
(
vptr
->
pdev
,
rd_info
->
skb_dma
,
vptr
->
rx_buf_sz
,
PCI_DMA_FROMDEVICE
);
rd_info
->
skb_dma
=
(
dma_addr_t
)
NULL
;
rd_info
->
skb
=
NULL
;
/* FIXME - memmove ? */
if
(
vptr
->
flags
&
VELOCITY_FLAGS_IP_ALIGN
)
{
int
i
;
for
(
i
=
rd
->
rdesc0
.
len
+
4
;
i
>=
0
;
i
--
)
*
(
skb
->
data
+
i
+
2
)
=
*
(
skb
->
data
+
i
);
skb
->
data
+=
2
;
skb
->
tail
+=
2
;
}
skb_put
(
skb
,
(
rd
->
rdesc0
.
len
-
4
));
skb
->
protocol
=
eth_type_trans
(
skb
,
skb
->
dev
);
pci_dma_sync_single_for_cpu
(
vptr
->
pdev
,
rd_info
->
skb_dma
,
vptr
->
rx_buf_sz
,
PCI_DMA_FROMDEVICE
);
/*
* Drop frame not meeting IEEE 802.3
...
...
@@ -1297,13 +1377,23 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
}
}
pci_action
=
pci_dma_sync_single_for_device
;
velocity_rx_csum
(
rd
,
skb
);
/*
* FIXME: need rx_copybreak handling
*/
if
(
velocity_rx_copy
(
&
skb
,
pkt_len
,
vptr
)
<
0
)
{
velocity_iph_realign
(
vptr
,
skb
,
pkt_len
);
pci_action
=
pci_unmap_single
;
rd_info
->
skb
=
NULL
;
}
stats
->
rx_bytes
+=
skb
->
len
;
pci_action
(
vptr
->
pdev
,
rd_info
->
skb_dma
,
vptr
->
rx_buf_sz
,
PCI_DMA_FROMDEVICE
);
skb_put
(
skb
,
pkt_len
-
4
);
skb
->
protocol
=
eth_type_trans
(
skb
,
skb
->
dev
);
stats
->
rx_bytes
+=
pkt_len
;
netif_rx
(
skb
);
return
0
;
...
...
@@ -2123,13 +2213,13 @@ static int velocity_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
*/
static
struct
pci_driver
velocity_driver
=
{
name:
VELOCITY_NAME
,
id_table:
velocity_id_table
,
probe:
velocity_found1
,
remove:
velocity_remove1
,
.
name
=
VELOCITY_NAME
,
.
id_table
=
velocity_id_table
,
.
probe
=
velocity_found1
,
.
remove
=
__devexit_p
(
velocity_remove1
)
,
#ifdef CONFIG_PM
suspend:
velocity_suspend
,
resume:
velocity_resume
,
.
suspend
=
velocity_suspend
,
.
resume
=
velocity_resume
,
#endif
};
...
...
@@ -2147,9 +2237,6 @@ static int __init velocity_init_module(void)
int
ret
;
ret
=
pci_module_init
(
&
velocity_driver
);
#ifdef CONFIG_PM
register_inetaddr_notifier
(
&
velocity_inetaddr_notifier
);
#endif
return
ret
;
}
...
...
@@ -2165,7 +2252,10 @@ static int __init velocity_init_module(void)
static
void
__exit
velocity_cleanup_module
(
void
)
{
#ifdef CONFIG_PM
if
(
velocity_notifier_registered
)
{
unregister_inetaddr_notifier
(
&
velocity_inetaddr_notifier
);
velocity_notifier_registered
=
0
;
}
#endif
pci_unregister_driver
(
&
velocity_driver
);
}
...
...
@@ -2992,89 +3082,6 @@ static void velocity_restore_context(struct velocity_info *vptr, struct velocity
}
static
int
velocity_suspend
(
struct
pci_dev
*
pdev
,
u32
state
)
{
struct
velocity_info
*
vptr
=
pci_get_drvdata
(
pdev
);
unsigned
long
flags
;
if
(
!
netif_running
(
vptr
->
dev
))
return
0
;
netif_device_detach
(
vptr
->
dev
);
spin_lock_irqsave
(
&
vptr
->
lock
,
flags
);
pci_save_state
(
pdev
,
vptr
->
pci_state
);
#ifdef ETHTOOL_GWOL
if
(
vptr
->
flags
&
VELOCITY_FLAGS_WOL_ENABLED
)
{
velocity_get_ip
(
vptr
);
velocity_save_context
(
vptr
,
&
vptr
->
context
);
velocity_shutdown
(
vptr
);
velocity_set_wol
(
vptr
);
pci_enable_wake
(
pdev
,
3
,
1
);
pci_set_power_state
(
pdev
,
3
);
}
else
{
velocity_save_context
(
vptr
,
&
vptr
->
context
);
velocity_shutdown
(
vptr
);
pci_disable_device
(
pdev
);
pci_set_power_state
(
pdev
,
state
);
}
#else
pci_set_power_state
(
pdev
,
state
);
#endif
spin_unlock_irqrestore
(
&
vptr
->
lock
,
flags
);
return
0
;
}
static
int
velocity_resume
(
struct
pci_dev
*
pdev
)
{
struct
velocity_info
*
vptr
=
pci_get_drvdata
(
pdev
);
unsigned
long
flags
;
int
i
;
if
(
!
netif_running
(
vptr
->
dev
))
return
0
;
pci_set_power_state
(
pdev
,
0
);
pci_enable_wake
(
pdev
,
0
,
0
);
pci_restore_state
(
pdev
,
vptr
->
pci_state
);
mac_wol_reset
(
vptr
->
mac_regs
);
spin_lock_irqsave
(
&
vptr
->
lock
,
flags
);
velocity_restore_context
(
vptr
,
&
vptr
->
context
);
velocity_init_registers
(
vptr
,
VELOCITY_INIT_WOL
);
mac_disable_int
(
vptr
->
mac_regs
);
velocity_tx_srv
(
vptr
,
0
);
for
(
i
=
0
;
i
<
vptr
->
num_txq
;
i
++
)
{
if
(
vptr
->
td_used
[
i
])
{
mac_tx_queue_wake
(
vptr
->
mac_regs
,
i
);
}
}
mac_enable_int
(
vptr
->
mac_regs
);
spin_unlock_irqrestore
(
&
vptr
->
lock
,
flags
);
netif_device_attach
(
vptr
->
dev
);
return
0
;
}
static
int
velocity_netdev_event
(
struct
notifier_block
*
nb
,
unsigned
long
notification
,
void
*
ptr
)
{
struct
in_ifaddr
*
ifa
=
(
struct
in_ifaddr
*
)
ptr
;
struct
net_device
*
dev
;
struct
velocity_info
*
vptr
;
if
(
ifa
)
{
dev
=
ifa
->
ifa_dev
->
dev
;
vptr
=
dev
->
priv
;
velocity_get_ip
(
vptr
);
}
return
NOTIFY_DONE
;
}
#endif
/*
* Purpose: Functions to set WOL.
*/
...
...
@@ -3114,12 +3121,6 @@ const static unsigned short crc16_tab[256] = {
0x7bc7
,
0x6a4e
,
0x58d5
,
0x495c
,
0x3de3
,
0x2c6a
,
0x1ef1
,
0x0f78
};
static
u32
mask_pattern
[
2
][
4
]
=
{
{
0x00203000
,
0x000003C0
,
0x00000000
,
0x0000000
},
/* ARP */
{
0xfffff000
,
0xffffffff
,
0xffffffff
,
0x000ffff
}
/* Magic Packet */
};
/**
* ether_crc16 - compute ethernet CRC
* @len: buffer length
...
...
@@ -3210,6 +3211,11 @@ static int velocity_set_wol(struct velocity_info *vptr)
static
u8
buf
[
256
];
int
i
;
static
u32
mask_pattern
[
2
][
4
]
=
{
{
0x00203000
,
0x000003C0
,
0x00000000
,
0x0000000
},
/* ARP */
{
0xfffff000
,
0xffffffff
,
0xffffffff
,
0x000ffff
}
/* Magic Packet */
};
writew
(
0xFFFF
,
&
regs
->
WOLCRClr
);
writeb
(
WOLCFG_SAB
|
WOLCFG_SAM
,
&
regs
->
WOLCFGSet
);
writew
(
WOLCR_MAGIC_EN
,
&
regs
->
WOLCRSet
);
...
...
@@ -3236,7 +3242,8 @@ static int velocity_set_wol(struct velocity_info *vptr)
memcpy
(
arp
->
ar_tip
,
vptr
->
ip_addr
,
4
);
crc
=
wol_calc_crc
((
sizeof
(
struct
arp_packet
)
+
7
)
/
8
,
buf
,
(
u8
*
)
&
mask_pattern
[
0
][
0
]);
crc
=
wol_calc_crc
((
sizeof
(
struct
arp_packet
)
+
7
)
/
8
,
buf
,
(
u8
*
)
&
mask_pattern
[
0
][
0
]);
writew
(
crc
,
&
regs
->
PatternCRC
[
0
]);
writew
(
WOLCR_ARP_EN
,
&
regs
->
WOLCRSet
);
...
...
@@ -3275,3 +3282,85 @@ static int velocity_set_wol(struct velocity_info *vptr)
return
0
;
}
static
int
velocity_suspend
(
struct
pci_dev
*
pdev
,
u32
state
)
{
struct
velocity_info
*
vptr
=
pci_get_drvdata
(
pdev
);
unsigned
long
flags
;
if
(
!
netif_running
(
vptr
->
dev
))
return
0
;
netif_device_detach
(
vptr
->
dev
);
spin_lock_irqsave
(
&
vptr
->
lock
,
flags
);
pci_save_state
(
pdev
,
vptr
->
pci_state
);
#ifdef ETHTOOL_GWOL
if
(
vptr
->
flags
&
VELOCITY_FLAGS_WOL_ENABLED
)
{
velocity_get_ip
(
vptr
);
velocity_save_context
(
vptr
,
&
vptr
->
context
);
velocity_shutdown
(
vptr
);
velocity_set_wol
(
vptr
);
pci_enable_wake
(
pdev
,
3
,
1
);
pci_set_power_state
(
pdev
,
3
);
}
else
{
velocity_save_context
(
vptr
,
&
vptr
->
context
);
velocity_shutdown
(
vptr
);
pci_disable_device
(
pdev
);
pci_set_power_state
(
pdev
,
state
);
}
#else
pci_set_power_state
(
pdev
,
state
);
#endif
spin_unlock_irqrestore
(
&
vptr
->
lock
,
flags
);
return
0
;
}
static
int
velocity_resume
(
struct
pci_dev
*
pdev
)
{
struct
velocity_info
*
vptr
=
pci_get_drvdata
(
pdev
);
unsigned
long
flags
;
int
i
;
if
(
!
netif_running
(
vptr
->
dev
))
return
0
;
pci_set_power_state
(
pdev
,
0
);
pci_enable_wake
(
pdev
,
0
,
0
);
pci_restore_state
(
pdev
,
vptr
->
pci_state
);
mac_wol_reset
(
vptr
->
mac_regs
);
spin_lock_irqsave
(
&
vptr
->
lock
,
flags
);
velocity_restore_context
(
vptr
,
&
vptr
->
context
);
velocity_init_registers
(
vptr
,
VELOCITY_INIT_WOL
);
mac_disable_int
(
vptr
->
mac_regs
);
velocity_tx_srv
(
vptr
,
0
);
for
(
i
=
0
;
i
<
vptr
->
num_txq
;
i
++
)
{
if
(
vptr
->
td_used
[
i
])
{
mac_tx_queue_wake
(
vptr
->
mac_regs
,
i
);
}
}
mac_enable_int
(
vptr
->
mac_regs
);
spin_unlock_irqrestore
(
&
vptr
->
lock
,
flags
);
netif_device_attach
(
vptr
->
dev
);
return
0
;
}
static
int
velocity_netdev_event
(
struct
notifier_block
*
nb
,
unsigned
long
notification
,
void
*
ptr
)
{
struct
in_ifaddr
*
ifa
=
(
struct
in_ifaddr
*
)
ptr
;
struct
net_device
*
dev
;
struct
velocity_info
*
vptr
;
if
(
ifa
)
{
dev
=
ifa
->
ifa_dev
->
dev
;
vptr
=
dev
->
priv
;
velocity_get_ip
(
vptr
);
}
return
NOTIFY_DONE
;
}
#endif
drivers/net/via-velocity.h
View file @
8dd55211
...
...
@@ -37,7 +37,6 @@
#define OPTION_DEFAULT { [0 ... MAX_UNITS-1] = -1}
#define REV_ID_VT6110 (0)
#define DEVICE_ID (0x3119)
#define BYTE_REG_BITS_ON(x,p) do { writeb(readb((p))|(x),(p));} while (0)
#define WORD_REG_BITS_ON(x,p) do { writew(readw((p))|(x),(p));} while (0)
...
...
@@ -1772,7 +1771,8 @@ struct velocity_info {
struct
velocity_td_info
*
td_infos
[
TX_QUEUE_NO
];
int
rd_curr
;
int
rd_used
;
int
rd_dirty
;
u32
rd_filled
;
struct
rx_desc
*
rd_ring
;
struct
velocity_rd_info
*
rd_info
;
/* It's an array */
...
...
include/linux/pci_ids.h
View file @
8dd55211
...
...
@@ -1218,6 +1218,7 @@
#define PCI_DEVICE_ID_VIA_8233C_0 0x3109
#define PCI_DEVICE_ID_VIA_8361 0x3112
#define PCI_DEVICE_ID_VIA_XM266 0x3116
#define PCI_DEVICE_ID_VIA_612X 0x3119
#define PCI_DEVICE_ID_VIA_862X_0 0x3123
#define PCI_DEVICE_ID_VIA_8753_0 0x3128
#define PCI_DEVICE_ID_VIA_8233A 0x3147
...
...
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