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
767b8bf8
Commit
767b8bf8
authored
Sep 27, 2002
by
Tim Hockin
Committed by
Jeff Garzik
Sep 27, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drivers/net/natsemi.c: janitorial - whitespace, wrap, and indenting cleanup
parent
61199b1f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
218 additions
and
214 deletions
+218
-214
drivers/net/natsemi.c
drivers/net/natsemi.c
+218
-214
No files found.
drivers/net/natsemi.c
View file @
767b8bf8
/* natsemi.c: A Linux PCI Ethernet driver for the NatSemi DP8381x series. */
/* natsemi.c: A Linux PCI Ethernet driver for the NatSemi DP8381x series. */
/*
/*
Written/copyright 1999-2001 by Donald Becker.
Written/copyright 1999-2001 by Donald Becker.
Portions copyright (c) 2001 Sun Microsystems (thockin@sun.com)
Portions copyright (c) 2001,2002 Sun Microsystems (thockin@sun.com)
Portions copyright 2001,2002 Manfred Spraul (manfred@colorfullife.com)
This software may be used and distributed according to the terms of
This software may be used and distributed according to the terms of
the GNU General Public License (GPL), incorporated herein by reference.
the GNU General Public License (GPL), incorporated herein by reference.
...
@@ -174,18 +175,6 @@
...
@@ -174,18 +175,6 @@
/* Updated to recommendations in pci-skeleton v2.03. */
/* Updated to recommendations in pci-skeleton v2.03. */
/* Automatically extracted configuration info:
probe-func: natsemi_probe
config-in: tristate 'National Semiconductor DP8381x series PCI Ethernet support' CONFIG_NATSEMI
c-help-name: National Semiconductor DP8381x series PCI Ethernet support
c-help-symbol: CONFIG_NATSEMI
c-help: This driver is for the National Semiconductor DP8381x series,
c-help: including the 8381[56] chips.
c-help: More specific information and updates are available from
c-help: http://www.scyld.com/network/natsemi.html
*/
/* The user-configurable values.
/* The user-configurable values.
These may be modified when a driver module is loaded.*/
These may be modified when a driver module is loaded.*/
...
@@ -247,9 +236,11 @@ static int full_duplex[MAX_UNITS];
...
@@ -247,9 +236,11 @@ static int full_duplex[MAX_UNITS];
/* These identify the driver base version and may not be removed. */
/* These identify the driver base version and may not be removed. */
static
char
version
[]
__devinitdata
=
static
char
version
[]
__devinitdata
=
KERN_INFO
DRV_NAME
".c:v1.07 1/9/2001 Written by Donald Becker <becker@scyld.com>
\n
"
KERN_INFO
DRV_NAME
".c:v1.07 1/9/2001 Written by Donald Becker <becker@scyld.com>
\n
"
KERN_INFO
" http://www.scyld.com/network/natsemi.html
\n
"
KERN_INFO
" http://www.scyld.com/network/natsemi.html
\n
"
KERN_INFO
" (unofficial 2.4.x kernel port, version "
DRV_VERSION
", "
DRV_RELDATE
" Jeff Garzik, Tjeerd Mulder)
\n
"
;
KERN_INFO
" (unofficial 2.4.x kernel port, version "
DRV_VERSION
", "
DRV_RELDATE
" Jeff Garzik, Tjeerd Mulder)
\n
"
;
MODULE_AUTHOR
(
"Donald Becker <becker@scyld.com>"
);
MODULE_AUTHOR
(
"Donald Becker <becker@scyld.com>"
);
MODULE_DESCRIPTION
(
"National Semiconductor DP8381x series PCI Ethernet driver"
);
MODULE_DESCRIPTION
(
"National Semiconductor DP8381x series PCI Ethernet driver"
);
...
@@ -261,11 +252,14 @@ MODULE_PARM(debug, "i");
...
@@ -261,11 +252,14 @@ MODULE_PARM(debug, "i");
MODULE_PARM
(
rx_copybreak
,
"i"
);
MODULE_PARM
(
rx_copybreak
,
"i"
);
MODULE_PARM
(
options
,
"1-"
__MODULE_STRING
(
MAX_UNITS
)
"i"
);
MODULE_PARM
(
options
,
"1-"
__MODULE_STRING
(
MAX_UNITS
)
"i"
);
MODULE_PARM
(
full_duplex
,
"1-"
__MODULE_STRING
(
MAX_UNITS
)
"i"
);
MODULE_PARM
(
full_duplex
,
"1-"
__MODULE_STRING
(
MAX_UNITS
)
"i"
);
MODULE_PARM_DESC
(
max_interrupt_work
,
"DP8381x maximum events handled per interrupt"
);
MODULE_PARM_DESC
(
max_interrupt_work
,
"DP8381x maximum events handled per interrupt"
);
MODULE_PARM_DESC
(
mtu
,
"DP8381x MTU (all boards)"
);
MODULE_PARM_DESC
(
mtu
,
"DP8381x MTU (all boards)"
);
MODULE_PARM_DESC
(
debug
,
"DP8381x default debug bitmask"
);
MODULE_PARM_DESC
(
debug
,
"DP8381x default debug bitmask"
);
MODULE_PARM_DESC
(
rx_copybreak
,
"DP8381x copy breakpoint for copy-only-tiny-frames"
);
MODULE_PARM_DESC
(
rx_copybreak
,
MODULE_PARM_DESC
(
options
,
"DP8381x: Bits 0-3: media type, bit 17: full duplex"
);
"DP8381x copy breakpoint for copy-only-tiny-frames"
);
MODULE_PARM_DESC
(
options
,
"DP8381x: Bits 0-3: media type, bit 17: full duplex"
);
MODULE_PARM_DESC
(
full_duplex
,
"DP8381x full duplex setting(s) (1)"
);
MODULE_PARM_DESC
(
full_duplex
,
"DP8381x full duplex setting(s) (1)"
);
/*
/*
...
@@ -348,7 +342,7 @@ IVc. Errata
...
@@ -348,7 +342,7 @@ IVc. Errata
None characterised.
None characterised.
*/
*/
enum
pcistuff
{
enum
pcistuff
{
PCI_USES_IO
=
0x01
,
PCI_USES_IO
=
0x01
,
...
@@ -634,32 +628,36 @@ enum desc_status_bits {
...
@@ -634,32 +628,36 @@ enum desc_status_bits {
};
};
struct
netdev_private
{
struct
netdev_private
{
/* Descriptor rings first for alignment
.
*/
/* Descriptor rings first for alignment */
dma_addr_t
ring_dma
;
dma_addr_t
ring_dma
;
struct
netdev_desc
*
rx_ring
;
struct
netdev_desc
*
rx_ring
;
struct
netdev_desc
*
tx_ring
;
struct
netdev_desc
*
tx_ring
;
/* The addresses of receive-in-place skbuffs
.
*/
/* The addresses of receive-in-place skbuffs */
struct
sk_buff
*
rx_skbuff
[
RX_RING_SIZE
];
struct
sk_buff
*
rx_skbuff
[
RX_RING_SIZE
];
dma_addr_t
rx_dma
[
RX_RING_SIZE
];
dma_addr_t
rx_dma
[
RX_RING_SIZE
];
/*
The saved address of a sent-in-place packet/buffer, for later free().
*/
/*
address of a sent-in-place packet/buffer, for later free()
*/
struct
sk_buff
*
tx_skbuff
[
TX_RING_SIZE
];
struct
sk_buff
*
tx_skbuff
[
TX_RING_SIZE
];
dma_addr_t
tx_dma
[
TX_RING_SIZE
];
dma_addr_t
tx_dma
[
TX_RING_SIZE
];
struct
net_device_stats
stats
;
struct
net_device_stats
stats
;
struct
timer_list
timer
;
/* Media monitoring timer. */
/* Media monitoring timer */
/* Frequently used values: keep some adjacent for cache effect. */
struct
timer_list
timer
;
/* Frequently used values: keep some adjacent for cache effect */
struct
pci_dev
*
pci_dev
;
struct
pci_dev
*
pci_dev
;
struct
netdev_desc
*
rx_head_desc
;
struct
netdev_desc
*
rx_head_desc
;
unsigned
int
cur_rx
,
dirty_rx
;
/* Producer/consumer ring indices */
/* Producer/consumer ring indices */
unsigned
int
cur_rx
,
dirty_rx
;
unsigned
int
cur_tx
,
dirty_tx
;
unsigned
int
cur_tx
,
dirty_tx
;
unsigned
int
rx_buf_sz
;
/* Based on MTU+slack. */
/* Based on MTU+slack. */
unsigned
int
rx_buf_sz
;
int
oom
;
int
oom
;
int
hands_off
;
/* Do not touch the nic registers */
/* Do not touch the nic registers */
/* These values are keep track of the transceiver/media in use. */
int
hands_off
;
/* These values are keep track of the transceiver/media in use */
unsigned
int
full_duplex
;
unsigned
int
full_duplex
;
/* Rx filter
.
*/
/* Rx filter */
u32
cur_rx_mode
;
u32
cur_rx_mode
;
u32
rx_filter
[
16
];
u32
rx_filter
[
16
];
/* FIFO and PCI burst thresholds
.
*/
/* FIFO and PCI burst thresholds */
u32
tx_config
,
rx_config
;
u32
tx_config
,
rx_config
;
/* original contents of ClkRun register */
/* original contents of ClkRun register */
u32
SavedClkRun
;
u32
SavedClkRun
;
...
@@ -667,8 +665,8 @@ struct netdev_private {
...
@@ -667,8 +665,8 @@ struct netdev_private {
u32
srr
;
u32
srr
;
/* expected DSPCFG value */
/* expected DSPCFG value */
u16
dspcfg
;
u16
dspcfg
;
/* MII transceiver section
.
*/
/* MII transceiver section */
u16
advertising
;
/* NWay media advertisement */
u16
advertising
;
unsigned
int
iosize
;
unsigned
int
iosize
;
spinlock_t
lock
;
spinlock_t
lock
;
u32
msg_enable
;
u32
msg_enable
;
...
@@ -715,7 +713,7 @@ static int netdev_close(struct net_device *dev);
...
@@ -715,7 +713,7 @@ static int netdev_close(struct net_device *dev);
static
int
netdev_get_regs
(
struct
net_device
*
dev
,
u8
*
buf
);
static
int
netdev_get_regs
(
struct
net_device
*
dev
,
u8
*
buf
);
static
int
netdev_get_eeprom
(
struct
net_device
*
dev
,
u8
*
buf
);
static
int
netdev_get_eeprom
(
struct
net_device
*
dev
,
u8
*
buf
);
static
int
__devinit
natsemi_probe1
(
struct
pci_dev
*
pdev
,
static
int
__devinit
natsemi_probe1
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
)
const
struct
pci_device_id
*
ent
)
{
{
...
@@ -857,7 +855,8 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
...
@@ -857,7 +855,8 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
printk
(
KERN_INFO
"%s: Transceiver default autonegotiation %s "
printk
(
KERN_INFO
"%s: Transceiver default autonegotiation %s "
"10%s %s duplex.
\n
"
,
"10%s %s duplex.
\n
"
,
dev
->
name
,
dev
->
name
,
chip_config
&
CfgAnegEnable
?
"enabled, advertise"
:
"disabled, force"
,
chip_config
&
CfgAnegEnable
?
"enabled, advertise"
:
"disabled, force"
,
chip_config
&
CfgAneg100
?
"0"
:
""
,
chip_config
&
CfgAneg100
?
"0"
:
""
,
chip_config
&
CfgAnegFull
?
"full"
:
"half"
);
chip_config
&
CfgAnegFull
?
"full"
:
"half"
);
}
}
...
@@ -877,7 +876,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
...
@@ -877,7 +876,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
return
0
;
return
0
;
}
}
/* Read the EEPROM and MII Management Data I/O (MDIO) interfaces.
/* Read the EEPROM and MII Management Data I/O (MDIO) interfaces.
The EEPROM code is for the common 93c06/46 EEPROMs with 6 bit addresses. */
The EEPROM code is for the common 93c06/46 EEPROMs with 6 bit addresses. */
...
@@ -932,8 +931,8 @@ static int eeprom_read(long addr, int location)
...
@@ -932,8 +931,8 @@ static int eeprom_read(long addr, int location)
}
}
/* MII transceiver control section.
/* MII transceiver control section.
The 83815 series has an internal transceiver, and we present the
*
The 83815 series has an internal transceiver, and we present the
management registers as if they were MII connected. */
*
management registers as if they were MII connected. */
static
int
mdio_read
(
struct
net_device
*
dev
,
int
phy_id
,
int
reg
)
static
int
mdio_read
(
struct
net_device
*
dev
,
int
phy_id
,
int
reg
)
{
{
...
@@ -1030,7 +1029,6 @@ static void natsemi_reset(struct net_device *dev)
...
@@ -1030,7 +1029,6 @@ static void natsemi_reset(struct net_device *dev)
}
}
/* restore RFCR */
/* restore RFCR */
writel
(
rfcr
,
dev
->
base_addr
+
RxFilterAddr
);
writel
(
rfcr
,
dev
->
base_addr
+
RxFilterAddr
);
}
}
static
void
natsemi_reload_eeprom
(
struct
net_device
*
dev
)
static
void
natsemi_reload_eeprom
(
struct
net_device
*
dev
)
...
@@ -1543,8 +1541,7 @@ static void drain_ring(struct net_device *dev)
...
@@ -1543,8 +1541,7 @@ static void drain_ring(struct net_device *dev)
np
->
rx_ring
[
i
].
addr
=
0xBADF00D0
;
/* An invalid address. */
np
->
rx_ring
[
i
].
addr
=
0xBADF00D0
;
/* An invalid address. */
if
(
np
->
rx_skbuff
[
i
])
{
if
(
np
->
rx_skbuff
[
i
])
{
pci_unmap_single
(
np
->
pci_dev
,
pci_unmap_single
(
np
->
pci_dev
,
np
->
rx_dma
[
i
],
np
->
rx_dma
[
i
],
np
->
rx_skbuff
[
i
]
->
len
,
np
->
rx_skbuff
[
i
]
->
len
,
PCI_DMA_FROMDEVICE
);
PCI_DMA_FROMDEVICE
);
dev_kfree_skb
(
np
->
rx_skbuff
[
i
]);
dev_kfree_skb
(
np
->
rx_skbuff
[
i
]);
}
}
...
@@ -1647,7 +1644,8 @@ static void netdev_tx_done(struct net_device *dev)
...
@@ -1647,7 +1644,8 @@ static void netdev_tx_done(struct net_device *dev)
np
->
stats
.
tx_packets
++
;
np
->
stats
.
tx_packets
++
;
np
->
stats
.
tx_bytes
+=
np
->
tx_skbuff
[
entry
]
->
len
;
np
->
stats
.
tx_bytes
+=
np
->
tx_skbuff
[
entry
]
->
len
;
}
else
{
/* Various Tx errors */
}
else
{
/* Various Tx errors */
int
tx_status
=
le32_to_cpu
(
np
->
tx_ring
[
entry
].
cmd_status
);
int
tx_status
=
le32_to_cpu
(
np
->
tx_ring
[
entry
].
cmd_status
);
if
(
tx_status
&
(
DescTxAbort
|
DescTxExcColl
))
if
(
tx_status
&
(
DescTxAbort
|
DescTxExcColl
))
np
->
stats
.
tx_aborted_errors
++
;
np
->
stats
.
tx_aborted_errors
++
;
if
(
tx_status
&
DescTxFIFO
)
if
(
tx_status
&
DescTxFIFO
)
...
@@ -1688,8 +1686,10 @@ static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
...
@@ -1688,8 +1686,10 @@ static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
u32
intr_status
=
readl
(
ioaddr
+
IntrStatus
);
u32
intr_status
=
readl
(
ioaddr
+
IntrStatus
);
if
(
netif_msg_intr
(
np
))
if
(
netif_msg_intr
(
np
))
printk
(
KERN_DEBUG
"%s: Interrupt, status %#08x, mask %#08x.
\n
"
,
printk
(
KERN_DEBUG
dev
->
name
,
intr_status
,
readl
(
ioaddr
+
IntrMask
));
"%s: Interrupt, status %#08x, mask %#08x.
\n
"
,
dev
->
name
,
intr_status
,
readl
(
ioaddr
+
IntrMask
));
if
(
intr_status
==
0
)
if
(
intr_status
==
0
)
break
;
break
;
...
@@ -1715,7 +1715,8 @@ static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
...
@@ -1715,7 +1715,8 @@ static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
if
(
netif_msg_intr
(
np
))
if
(
netif_msg_intr
(
np
))
printk
(
KERN_WARNING
printk
(
KERN_WARNING
"%s: Too much work at interrupt, "
"%s: Too much work at interrupt, "
"status=%#08x.
\n
"
,
dev
->
name
,
intr_status
);
"status=%#08x.
\n
"
,
dev
->
name
,
intr_status
);
break
;
break
;
}
}
}
while
(
1
);
}
while
(
1
);
...
@@ -1772,16 +1773,19 @@ static void netdev_rx(struct net_device *dev)
...
@@ -1772,16 +1773,19 @@ static void netdev_rx(struct net_device *dev)
if
(
pkt_len
<
rx_copybreak
if
(
pkt_len
<
rx_copybreak
&&
(
skb
=
dev_alloc_skb
(
pkt_len
+
2
))
!=
NULL
)
{
&&
(
skb
=
dev_alloc_skb
(
pkt_len
+
2
))
!=
NULL
)
{
skb
->
dev
=
dev
;
skb
->
dev
=
dev
;
skb_reserve
(
skb
,
2
);
/* 16 byte align the IP header */
/* 16 byte align the IP header */
pci_dma_sync_single
(
np
->
pci_dev
,
np
->
rx_dma
[
entry
],
skb_reserve
(
skb
,
2
);
pci_dma_sync_single
(
np
->
pci_dev
,
np
->
rx_dma
[
entry
],
np
->
rx_skbuff
[
entry
]
->
len
,
np
->
rx_skbuff
[
entry
]
->
len
,
PCI_DMA_FROMDEVICE
);
PCI_DMA_FROMDEVICE
);
#if HAS_IP_COPYSUM
#if HAS_IP_COPYSUM
eth_copy_and_sum
(
skb
,
np
->
rx_skbuff
[
entry
]
->
tail
,
pkt_len
,
0
);
eth_copy_and_sum
(
skb
,
np
->
rx_skbuff
[
entry
]
->
tail
,
pkt_len
,
0
);
skb_put
(
skb
,
pkt_len
);
skb_put
(
skb
,
pkt_len
);
#else
#else
memcpy
(
skb_put
(
skb
,
pkt_len
),
np
->
rx_skbuff
[
entry
]
->
tail
,
memcpy
(
skb_put
(
skb
,
pkt_len
),
pkt_len
);
np
->
rx_skbuff
[
entry
]
->
tail
,
pkt_len
);
#endif
#endif
}
else
{
}
else
{
pci_unmap_single
(
np
->
pci_dev
,
np
->
rx_dma
[
entry
],
pci_unmap_single
(
np
->
pci_dev
,
np
->
rx_dma
[
entry
],
...
@@ -1791,7 +1795,6 @@ static void netdev_rx(struct net_device *dev)
...
@@ -1791,7 +1795,6 @@ static void netdev_rx(struct net_device *dev)
np
->
rx_skbuff
[
entry
]
=
NULL
;
np
->
rx_skbuff
[
entry
]
=
NULL
;
}
}
skb
->
protocol
=
eth_type_trans
(
skb
,
dev
);
skb
->
protocol
=
eth_type_trans
(
skb
,
dev
);
/* W/ hardware checksum: skb->ip_summed = CHECKSUM_UNNECESSARY; */
netif_rx
(
skb
);
netif_rx
(
skb
);
dev
->
last_rx
=
jiffies
;
dev
->
last_rx
=
jiffies
;
np
->
stats
.
rx_packets
++
;
np
->
stats
.
rx_packets
++
;
...
@@ -1950,7 +1953,8 @@ static void __set_rx_mode(struct net_device *dev)
...
@@ -1950,7 +1953,8 @@ static void __set_rx_mode(struct net_device *dev)
memset
(
mc_filter
,
0
,
sizeof
(
mc_filter
));
memset
(
mc_filter
,
0
,
sizeof
(
mc_filter
));
for
(
i
=
0
,
mclist
=
dev
->
mc_list
;
mclist
&&
i
<
dev
->
mc_count
;
for
(
i
=
0
,
mclist
=
dev
->
mc_list
;
mclist
&&
i
<
dev
->
mc_count
;
i
++
,
mclist
=
mclist
->
next
)
{
i
++
,
mclist
=
mclist
->
next
)
{
set_bit_le
(
dp83815_crc
(
ETH_ALEN
,
mclist
->
dmi_addr
)
&
0x1ff
,
set_bit_le
(
dp83815_crc
(
ETH_ALEN
,
mclist
->
dmi_addr
)
&
0x1ff
,
mc_filter
);
mc_filter
);
}
}
rx_mode
=
RxFilterEnable
|
AcceptBroadcast
rx_mode
=
RxFilterEnable
|
AcceptBroadcast
...
@@ -2566,7 +2570,7 @@ static int netdev_close(struct net_device *dev)
...
@@ -2566,7 +2570,7 @@ static int netdev_close(struct net_device *dev)
return
0
;
return
0
;
}
}
static
void
__devexit
natsemi_remove1
(
struct
pci_dev
*
pdev
)
static
void
__devexit
natsemi_remove1
(
struct
pci_dev
*
pdev
)
{
{
struct
net_device
*
dev
=
pci_get_drvdata
(
pdev
);
struct
net_device
*
dev
=
pci_get_drvdata
(
pdev
);
...
...
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