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
19594f37
Commit
19594f37
authored
Apr 21, 2004
by
Denis Vlasenko
Committed by
Linus Torvalds
Apr 21, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] fealnx #1: replace magic constants with enums
parent
d666b06d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
33 deletions
+42
-33
drivers/net/fealnx.c
drivers/net/fealnx.c
+42
-33
No files found.
drivers/net/fealnx.c
View file @
19594f37
...
@@ -233,15 +233,29 @@ enum intr_status_bits {
...
@@ -233,15 +233,29 @@ enum intr_status_bits {
RxErr
=
0x00000002
,
/* receive error */
RxErr
=
0x00000002
,
/* receive error */
};
};
/* Bits in the NetworkConfig register. */
/* Bits in the NetworkConfig register, W for writing, R for reading */
/* FIXME: some names are invented by me. Marked with (name?) */
/* If you have docs and know bit names, please fix 'em */
enum
rx_mode_bits
{
enum
rx_mode_bits
{
RxModeMask
=
0xe0
,
CR_W_ENH
=
0x02000000
,
/* enhanced mode (name?) */
PROM
=
0x80
,
/* promiscuous mode */
CR_W_FD
=
0x00100000
,
/* full duplex */
AB
=
0x40
,
/* accept broadcast */
CR_W_PS10
=
0x00080000
,
/* 10 mbit */
AM
=
0x20
,
/* accept mutlicast */
CR_W_TXEN
=
0x00040000
,
/* tx enable (name?) */
ARP
=
0x08
,
/* receive runt pkt */
CR_W_PS1000
=
0x00010000
,
/* 1000 mbit */
ALP
=
0x04
,
/* receive long pkt */
/* CR_W_RXBURSTMASK= 0x00000e00, Im unsure about this */
SEP
=
0x02
,
/* receive error pkt */
CR_W_RXMODEMASK
=
0x000000e0
,
CR_W_PROM
=
0x00000080
,
/* promiscuous mode */
CR_W_AB
=
0x00000040
,
/* accept broadcast */
CR_W_AM
=
0x00000020
,
/* accept mutlicast */
CR_W_ARP
=
0x00000008
,
/* receive runt pkt */
CR_W_ALP
=
0x00000004
,
/* receive long pkt */
CR_W_SEP
=
0x00000002
,
/* receive error pkt */
CR_W_RXEN
=
0x00000001
,
/* rx enable (unicast?) (name?) */
CR_R_TXSTOP
=
0x04000000
,
/* tx stopped (name?) */
CR_R_FD
=
0x00100000
,
/* full duplex detected */
CR_R_PS10
=
0x00080000
,
/* 10 mbit detected */
CR_R_RXSTOP
=
0x00008000
,
/* rx stopped (name?) */
};
};
/* The Tulip Rx and Tx buffer descriptors. */
/* The Tulip Rx and Tx buffer descriptors. */
...
@@ -375,10 +389,7 @@ enum tx_desc_control_bits {
...
@@ -375,10 +389,7 @@ enum tx_desc_control_bits {
#define LXT1000_Full 0x200
#define LXT1000_Full 0x200
// 89/12/29 add, for phy specific status register, levelone phy, (end)
// 89/12/29 add, for phy specific status register, levelone phy, (end)
/* for 3-in-1 case */
/* for 3-in-1 case, BMCRSR register */
#define PS10 0x00080000
#define FD 0x00100000
#define PS1000 0x00010000
#define LinkIsUp2 0x00040000
#define LinkIsUp2 0x00040000
/* for PHY */
/* for PHY */
...
@@ -449,13 +460,13 @@ static void reset_rx_descriptors(struct net_device *dev);
...
@@ -449,13 +460,13 @@ static void reset_rx_descriptors(struct net_device *dev);
void
stop_nic_tx
(
long
ioaddr
,
long
crvalue
)
void
stop_nic_tx
(
long
ioaddr
,
long
crvalue
)
{
{
writel
(
crvalue
&
(
~
0x40000
),
ioaddr
+
TCRRCR
);
writel
(
crvalue
&
(
~
CR_W_TXEN
),
ioaddr
+
TCRRCR
);
/* wait for tx stop */
/* wait for tx stop */
{
{
int
i
=
0
,
delay
=
0x1000
;
int
i
=
0
,
delay
=
0x1000
;
while
((
!
(
readl
(
ioaddr
+
TCRRCR
)
&
0x04000000
))
&&
(
i
<
delay
))
{
while
((
!
(
readl
(
ioaddr
+
TCRRCR
)
&
CR_R_TXSTOP
))
&&
(
i
<
delay
))
{
++
i
;
++
i
;
}
}
}
}
...
@@ -464,13 +475,13 @@ void stop_nic_tx(long ioaddr, long crvalue)
...
@@ -464,13 +475,13 @@ void stop_nic_tx(long ioaddr, long crvalue)
void
stop_nic_rx
(
long
ioaddr
,
long
crvalue
)
void
stop_nic_rx
(
long
ioaddr
,
long
crvalue
)
{
{
writel
(
crvalue
&
(
~
0x1
),
ioaddr
+
TCRRCR
);
writel
(
crvalue
&
(
~
CR_W_RXEN
),
ioaddr
+
TCRRCR
);
/* wait for rx stop */
/* wait for rx stop */
{
{
int
i
=
0
,
delay
=
0x1000
;
int
i
=
0
,
delay
=
0x1000
;
while
((
!
(
readl
(
ioaddr
+
TCRRCR
)
&
0x00008000
))
&&
(
i
<
delay
))
{
while
((
!
(
readl
(
ioaddr
+
TCRRCR
)
&
CR_R_RXSTOP
))
&&
(
i
<
delay
))
{
++
i
;
++
i
;
}
}
}
}
...
@@ -949,7 +960,7 @@ static int netdev_open(struct net_device *dev)
...
@@ -949,7 +960,7 @@ static int netdev_open(struct net_device *dev)
np
->
imrvalue
=
TUNF
|
CNTOVF
|
RBU
|
TI
|
RI
;
np
->
imrvalue
=
TUNF
|
CNTOVF
|
RBU
|
TI
|
RI
;
if
(
np
->
pci_dev
->
device
==
0x891
)
{
if
(
np
->
pci_dev
->
device
==
0x891
)
{
np
->
bcrvalue
|=
0x200
;
/* set PROG bit */
np
->
bcrvalue
|=
0x200
;
/* set PROG bit */
np
->
crvalue
|=
0x02000000
;
/* set enhanced bit */
np
->
crvalue
|=
CR_W_ENH
;
/* set enhanced bit */
np
->
imrvalue
|=
ETI
;
np
->
imrvalue
|=
ETI
;
}
}
writel
(
np
->
bcrvalue
,
ioaddr
+
BCR
);
writel
(
np
->
bcrvalue
,
ioaddr
+
BCR
);
...
@@ -1026,11 +1037,11 @@ static void getlinktype(struct net_device *dev)
...
@@ -1026,11 +1037,11 @@ static void getlinktype(struct net_device *dev)
struct
netdev_private
*
np
=
dev
->
priv
;
struct
netdev_private
*
np
=
dev
->
priv
;
if
(
np
->
PHYType
==
MysonPHY
)
{
/* 3-in-1 case */
if
(
np
->
PHYType
==
MysonPHY
)
{
/* 3-in-1 case */
if
(
readl
(
dev
->
base_addr
+
TCRRCR
)
&
FD
)
if
(
readl
(
dev
->
base_addr
+
TCRRCR
)
&
CR_R_
FD
)
np
->
duplexmode
=
2
;
/* full duplex */
np
->
duplexmode
=
2
;
/* full duplex */
else
else
np
->
duplexmode
=
1
;
/* half duplex */
np
->
duplexmode
=
1
;
/* half duplex */
if
(
readl
(
dev
->
base_addr
+
TCRRCR
)
&
PS10
)
if
(
readl
(
dev
->
base_addr
+
TCRRCR
)
&
CR_R_
PS10
)
np
->
line_speed
=
1
;
/* 10M */
np
->
line_speed
=
1
;
/* 10M */
else
else
np
->
line_speed
=
2
;
/* 100M */
np
->
line_speed
=
2
;
/* 100M */
...
@@ -1112,15 +1123,13 @@ static void getlinktype(struct net_device *dev)
...
@@ -1112,15 +1123,13 @@ static void getlinktype(struct net_device *dev)
else
else
np
->
line_speed
=
1
;
/* 10M */
np
->
line_speed
=
1
;
/* 10M */
}
}
// chage crvalue
np
->
crvalue
&=
(
~
CR_W_PS10
)
&
(
~
CR_W_FD
)
&
(
~
CR_W_PS1000
);
// np->crvalue&=(~PS10)&(~FD);
np
->
crvalue
&=
(
~
PS10
)
&
(
~
FD
)
&
(
~
PS1000
);
if
(
np
->
line_speed
==
1
)
if
(
np
->
line_speed
==
1
)
np
->
crvalue
|=
PS10
;
np
->
crvalue
|=
CR_W_
PS10
;
else
if
(
np
->
line_speed
==
3
)
else
if
(
np
->
line_speed
==
3
)
np
->
crvalue
|=
PS1000
;
np
->
crvalue
|=
CR_W_
PS1000
;
if
(
np
->
duplexmode
==
2
)
if
(
np
->
duplexmode
==
2
)
np
->
crvalue
|=
FD
;
np
->
crvalue
|=
CR_W_
FD
;
}
}
}
}
...
@@ -1168,7 +1177,7 @@ static void netdev_timer(unsigned long data)
...
@@ -1168,7 +1177,7 @@ static void netdev_timer(unsigned long data)
getlinktype
(
dev
);
getlinktype
(
dev
);
if
(
np
->
crvalue
!=
old_crvalue
)
{
if
(
np
->
crvalue
!=
old_crvalue
)
{
stop_nic_tx
(
ioaddr
,
np
->
crvalue
);
stop_nic_tx
(
ioaddr
,
np
->
crvalue
);
stop_nic_rx
(
ioaddr
,
np
->
crvalue
&
(
~
0x40000
));
stop_nic_rx
(
ioaddr
,
np
->
crvalue
&
(
~
CR_W_TXEN
));
writel
(
np
->
crvalue
,
ioaddr
+
TCRRCR
);
writel
(
np
->
crvalue
,
ioaddr
+
TCRRCR
);
}
}
}
}
...
@@ -1488,7 +1497,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
...
@@ -1488,7 +1497,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
if
(
tx_status
&
TXOWN
)
if
(
tx_status
&
TXOWN
)
break
;
break
;
if
(
!
(
np
->
crvalue
&
0x02000000
))
{
if
(
!
(
np
->
crvalue
&
CR_W_ENH
))
{
if
(
tx_status
&
(
CSL
|
LC
|
EC
|
UDF
|
HF
))
{
if
(
tx_status
&
(
CSL
|
LC
|
EC
|
UDF
|
HF
))
{
np
->
stats
.
tx_errors
++
;
np
->
stats
.
tx_errors
++
;
if
(
tx_status
&
EC
)
if
(
tx_status
&
EC
)
...
@@ -1537,7 +1546,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
...
@@ -1537,7 +1546,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
netif_wake_queue
(
dev
);
netif_wake_queue
(
dev
);
/* read transmit status for enhanced mode only */
/* read transmit status for enhanced mode only */
if
(
np
->
crvalue
&
0x02000000
)
{
if
(
np
->
crvalue
&
CR_W_ENH
)
{
long
data
;
long
data
;
data
=
readl
(
ioaddr
+
TSR
);
data
=
readl
(
ioaddr
+
TSR
);
...
@@ -1746,12 +1755,12 @@ static void set_rx_mode(struct net_device *dev)
...
@@ -1746,12 +1755,12 @@ static void set_rx_mode(struct net_device *dev)
/* Unconditionally log net taps. */
/* Unconditionally log net taps. */
printk
(
KERN_NOTICE
"%s: Promiscuous mode enabled.
\n
"
,
dev
->
name
);
printk
(
KERN_NOTICE
"%s: Promiscuous mode enabled.
\n
"
,
dev
->
name
);
memset
(
mc_filter
,
0xff
,
sizeof
(
mc_filter
));
memset
(
mc_filter
,
0xff
,
sizeof
(
mc_filter
));
rx_mode
=
PROM
|
AB
|
AM
;
rx_mode
=
CR_W_PROM
|
CR_W_AB
|
CR_W_
AM
;
}
else
if
((
dev
->
mc_count
>
multicast_filter_limit
)
}
else
if
((
dev
->
mc_count
>
multicast_filter_limit
)
||
(
dev
->
flags
&
IFF_ALLMULTI
))
{
||
(
dev
->
flags
&
IFF_ALLMULTI
))
{
/* Too many to match, or accept all multicasts. */
/* Too many to match, or accept all multicasts. */
memset
(
mc_filter
,
0xff
,
sizeof
(
mc_filter
));
memset
(
mc_filter
,
0xff
,
sizeof
(
mc_filter
));
rx_mode
=
AB
|
AM
;
rx_mode
=
CR_W_AB
|
CR_W_
AM
;
}
else
{
}
else
{
struct
dev_mc_list
*
mclist
;
struct
dev_mc_list
*
mclist
;
int
i
;
int
i
;
...
@@ -1763,15 +1772,15 @@ static void set_rx_mode(struct net_device *dev)
...
@@ -1763,15 +1772,15 @@ static void set_rx_mode(struct net_device *dev)
bit
=
(
ether_crc
(
ETH_ALEN
,
mclist
->
dmi_addr
)
>>
26
)
^
0x3F
;
bit
=
(
ether_crc
(
ETH_ALEN
,
mclist
->
dmi_addr
)
>>
26
)
^
0x3F
;
mc_filter
[
bit
>>
5
]
|=
(
1
<<
bit
);
mc_filter
[
bit
>>
5
]
|=
(
1
<<
bit
);
}
}
rx_mode
=
AB
|
AM
;
rx_mode
=
CR_W_AB
|
CR_W_
AM
;
}
}
stop_nic_tx
(
ioaddr
,
np
->
crvalue
);
stop_nic_tx
(
ioaddr
,
np
->
crvalue
);
stop_nic_rx
(
ioaddr
,
np
->
crvalue
&
(
~
0x40000
));
stop_nic_rx
(
ioaddr
,
np
->
crvalue
&
(
~
CR_W_TXEN
));
writel
(
mc_filter
[
0
],
ioaddr
+
MAR0
);
writel
(
mc_filter
[
0
],
ioaddr
+
MAR0
);
writel
(
mc_filter
[
1
],
ioaddr
+
MAR1
);
writel
(
mc_filter
[
1
],
ioaddr
+
MAR1
);
np
->
crvalue
&=
~
RxModeMask
;
np
->
crvalue
&=
~
CR_W_RXMODEMASK
;
np
->
crvalue
|=
rx_mode
;
np
->
crvalue
|=
rx_mode
;
writel
(
np
->
crvalue
,
ioaddr
+
TCRRCR
);
writel
(
np
->
crvalue
,
ioaddr
+
TCRRCR
);
}
}
...
...
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