mirror of
https://github.com/joel16/android_kernel_sony_msm8994.git
synced 2024-12-01 08:00:42 +00:00
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (867 commits) [SKY2]: status polling loop (post merge) [NET]: Fix NAPI completion handling in some drivers. [TCP]: Limit processing lost_retrans loop to work-to-do cases [TCP]: Fix lost_retrans loop vs fastpath problems [TCP]: No need to re-count fackets_out/sacked_out at RTO [TCP]: Extract tcp_match_queue_to_sack from sacktag code [TCP]: Kill almost unused variable pcount from sacktag [TCP]: Fix mark_head_lost to ignore R-bit when trying to mark L [TCP]: Add bytes_acked (ABC) clearing to FRTO too [IPv6]: Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493, try2 [NETFILTER]: x_tables: add missing ip6t_modulename aliases [NETFILTER]: nf_conntrack_tcp: fix connection reopening [QETH]: fix qeth_main.c [NETLINK]: fib_frontend build fixes [IPv6]: Export userland ND options through netlink (RDNSS support) [9P]: build fix with !CONFIG_SYSCTL [NET]: Fix dev_put() and dev_hold() comments [NET]: make netlink user -> kernel interface synchronious [NET]: unify netlink kernel socket recognition [NET]: cleanup 3rd argument in netlink_sendskb ... Fix up conflicts manually in Documentation/feature-removal-schedule.txt and my new least favourite crap, the "mod_devicetable" support in the files include/linux/mod_devicetable.h and scripts/mod/file2alias.c. (The latter files seem to be explicitly _designed_ to get conflicts when different subsystems work with them - that have an absolutely horrid lack of subsystem separation!) Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
commit
038a5008b2
31
CREDITS
31
CREDITS
@ -665,6 +665,11 @@ D: Minor updates to SCSI types, added /proc/pid/maps protection
|
||||
S: (ask for current address)
|
||||
S: USA
|
||||
|
||||
N: Robin Cornelius
|
||||
E: robincornelius@users.sourceforge.net
|
||||
D: Ralink rt2x00 WLAN driver
|
||||
S: Cornwall, U.K.
|
||||
|
||||
N: Mark Corner
|
||||
E: mcorner@umich.edu
|
||||
W: http://www.eecs.umich.edu/~mcorner/
|
||||
@ -679,6 +684,11 @@ D: Kernel module SMART utilities
|
||||
S: Santa Cruz, California
|
||||
S: USA
|
||||
|
||||
N: Luis Correia
|
||||
E: lfcorreia@users.sf.net
|
||||
D: Ralink rt2x00 WLAN driver
|
||||
S: Belas, Portugal
|
||||
|
||||
N: Alan Cox
|
||||
W: http://www.linux.org.uk/diary/
|
||||
D: Linux Networking (0.99.10->2.0.29)
|
||||
@ -833,6 +843,12 @@ S: Lancs
|
||||
S: PR4 6AX
|
||||
S: United Kingdom
|
||||
|
||||
N: Ivo van Doorn
|
||||
E: IvDoorn@gmail.com
|
||||
W: http://www.mendiosus.nl
|
||||
D: Ralink rt2x00 WLAN driver
|
||||
S: Haarlem, The Netherlands
|
||||
|
||||
N: John G Dorsey
|
||||
E: john+@cs.cmu.edu
|
||||
D: ARM Linux ports to Assabet/Neponset, Spot
|
||||
@ -3517,6 +3533,12 @@ S: Maastrichterweg 63
|
||||
S: 5554 GG Valkenswaard
|
||||
S: The Netherlands
|
||||
|
||||
N: Mark Wallis
|
||||
E: mwallis@serialmonkey.com
|
||||
W: http://mark.serialmonkey.com
|
||||
D: Ralink rt2x00 WLAN driver
|
||||
S: Newcastle, Australia
|
||||
|
||||
N: Peter Shaobo Wang
|
||||
E: pwang@mmdcorp.com
|
||||
W: http://www.mmdcorp.com/pw/linux
|
||||
@ -3651,6 +3673,15 @@ S: Alte Regensburger Str. 11a
|
||||
S: 93149 Nittenau
|
||||
S: Germany
|
||||
|
||||
N: Gertjan van Wingerde
|
||||
E: gwingerde@home.nl
|
||||
D: Ralink rt2x00 WLAN driver
|
||||
D: Minix V2 file-system
|
||||
D: Misc fixes
|
||||
S: Geessinkweg 177
|
||||
S: 7544 TX Enschede
|
||||
S: The Netherlands
|
||||
|
||||
N: Lars Wirzenius
|
||||
E: liw@iki.fi
|
||||
D: Linux System Administrator's Guide, author, former maintainer
|
||||
|
@ -240,17 +240,23 @@ X!Ilib/string.c
|
||||
<sect1><title>Driver Support</title>
|
||||
!Enet/core/dev.c
|
||||
!Enet/ethernet/eth.c
|
||||
!Enet/sched/sch_generic.c
|
||||
!Iinclude/linux/etherdevice.h
|
||||
!Iinclude/linux/netdevice.h
|
||||
</sect1>
|
||||
<sect1><title>PHY Support</title>
|
||||
!Edrivers/net/phy/phy.c
|
||||
!Idrivers/net/phy/phy.c
|
||||
!Edrivers/net/phy/phy_device.c
|
||||
!Idrivers/net/phy/phy_device.c
|
||||
!Edrivers/net/phy/mdio_bus.c
|
||||
!Idrivers/net/phy/mdio_bus.c
|
||||
<!-- FIXME: Removed for now since no structured comments in source
|
||||
X!Enet/core/wireless.c
|
||||
-->
|
||||
</sect1>
|
||||
<!-- FIXME: Removed for now since no structured comments in source
|
||||
<sect1><title>Wireless</title>
|
||||
X!Enet/core/wireless.c
|
||||
</sect1>
|
||||
-->
|
||||
<sect1><title>Synchronous PPP</title>
|
||||
!Edrivers/net/wan/syncppp.c
|
||||
</sect1>
|
||||
|
@ -314,3 +314,16 @@ Why: The i386/x86_64 merge provides a symlink to the old bzImage
|
||||
location so not yet updated user space tools, e.g. package
|
||||
scripts, do not break.
|
||||
Who: Thomas Gleixner <tglx@linutronix.de>
|
||||
|
||||
---------------------------
|
||||
|
||||
What: shaper network driver
|
||||
When: January 2008
|
||||
Files: drivers/net/shaper.c, include/linux/if_shaper.h
|
||||
Why: This driver has been marked obsolete for many years.
|
||||
It was only designed to work on lower speed links and has design
|
||||
flaws that lead to machine crashes. The qdisc infrastructure in
|
||||
2.4 or later kernels, provides richer features and is more robust.
|
||||
Who: Stephen Hemminger <shemminger@linux-foundation.org>
|
||||
|
||||
---------------------------
|
||||
|
@ -1,766 +0,0 @@
|
||||
HISTORY:
|
||||
February 16/2002 -- revision 0.2.1:
|
||||
COR typo corrected
|
||||
February 10/2002 -- revision 0.2:
|
||||
some spell checking ;->
|
||||
January 12/2002 -- revision 0.1
|
||||
This is still work in progress so may change.
|
||||
To keep up to date please watch this space.
|
||||
|
||||
Introduction to NAPI
|
||||
====================
|
||||
|
||||
NAPI is a proven (www.cyberus.ca/~hadi/usenix-paper.tgz) technique
|
||||
to improve network performance on Linux. For more details please
|
||||
read that paper.
|
||||
NAPI provides a "inherent mitigation" which is bound by system capacity
|
||||
as can be seen from the following data collected by Robert on Gigabit
|
||||
ethernet (e1000):
|
||||
|
||||
Psize Ipps Tput Rxint Txint Done Ndone
|
||||
---------------------------------------------------------------
|
||||
60 890000 409362 17 27622 7 6823
|
||||
128 758150 464364 21 9301 10 7738
|
||||
256 445632 774646 42 15507 21 12906
|
||||
512 232666 994445 241292 19147 241192 1062
|
||||
1024 119061 1000003 872519 19258 872511 0
|
||||
1440 85193 1000003 946576 19505 946569 0
|
||||
|
||||
|
||||
Legend:
|
||||
"Ipps" stands for input packets per second.
|
||||
"Tput" == packets out of total 1M that made it out.
|
||||
"txint" == transmit completion interrupts seen
|
||||
"Done" == The number of times that the poll() managed to pull all
|
||||
packets out of the rx ring. Note from this that the lower the
|
||||
load the more we could clean up the rxring
|
||||
"Ndone" == is the converse of "Done". Note again, that the higher
|
||||
the load the more times we couldn't clean up the rxring.
|
||||
|
||||
Observe that:
|
||||
when the NIC receives 890Kpackets/sec only 17 rx interrupts are generated.
|
||||
The system cant handle the processing at 1 interrupt/packet at that load level.
|
||||
At lower rates on the other hand, rx interrupts go up and therefore the
|
||||
interrupt/packet ratio goes up (as observable from that table). So there is
|
||||
possibility that under low enough input, you get one poll call for each
|
||||
input packet caused by a single interrupt each time. And if the system
|
||||
cant handle interrupt per packet ratio of 1, then it will just have to
|
||||
chug along ....
|
||||
|
||||
|
||||
0) Prerequisites:
|
||||
==================
|
||||
A driver MAY continue using the old 2.4 technique for interfacing
|
||||
to the network stack and not benefit from the NAPI changes.
|
||||
NAPI additions to the kernel do not break backward compatibility.
|
||||
NAPI, however, requires the following features to be available:
|
||||
|
||||
A) DMA ring or enough RAM to store packets in software devices.
|
||||
|
||||
B) Ability to turn off interrupts or maybe events that send packets up
|
||||
the stack.
|
||||
|
||||
NAPI processes packet events in what is known as dev->poll() method.
|
||||
Typically, only packet receive events are processed in dev->poll().
|
||||
The rest of the events MAY be processed by the regular interrupt handler
|
||||
to reduce processing latency (justified also because there are not that
|
||||
many of them).
|
||||
Note, however, NAPI does not enforce that dev->poll() only processes
|
||||
receive events.
|
||||
Tests with the tulip driver indicated slightly increased latency if
|
||||
all of the interrupt handler is moved to dev->poll(). Also MII handling
|
||||
gets a little trickier.
|
||||
The example used in this document is to move the receive processing only
|
||||
to dev->poll(); this is shown with the patch for the tulip driver.
|
||||
For an example of code that moves all the interrupt driver to
|
||||
dev->poll() look at the ported e1000 code.
|
||||
|
||||
There are caveats that might force you to go with moving everything to
|
||||
dev->poll(). Different NICs work differently depending on their status/event
|
||||
acknowledgement setup.
|
||||
There are two types of event register ACK mechanisms.
|
||||
I) what is known as Clear-on-read (COR).
|
||||
when you read the status/event register, it clears everything!
|
||||
The natsemi and sunbmac NICs are known to do this.
|
||||
In this case your only choice is to move all to dev->poll()
|
||||
|
||||
II) Clear-on-write (COW)
|
||||
i) you clear the status by writing a 1 in the bit-location you want.
|
||||
These are the majority of the NICs and work the best with NAPI.
|
||||
Put only receive events in dev->poll(); leave the rest in
|
||||
the old interrupt handler.
|
||||
ii) whatever you write in the status register clears every thing ;->
|
||||
Cant seem to find any supported by Linux which do this. If
|
||||
someone knows such a chip email us please.
|
||||
Move all to dev->poll()
|
||||
|
||||
C) Ability to detect new work correctly.
|
||||
NAPI works by shutting down event interrupts when there's work and
|
||||
turning them on when there's none.
|
||||
New packets might show up in the small window while interrupts were being
|
||||
re-enabled (refer to appendix 2). A packet might sneak in during the period
|
||||
we are enabling interrupts. We only get to know about such a packet when the
|
||||
next new packet arrives and generates an interrupt.
|
||||
Essentially, there is a small window of opportunity for a race condition
|
||||
which for clarity we'll refer to as the "rotting packet".
|
||||
|
||||
This is a very important topic and appendix 2 is dedicated for more
|
||||
discussion.
|
||||
|
||||
Locking rules and environmental guarantees
|
||||
==========================================
|
||||
|
||||
-Guarantee: Only one CPU at any time can call dev->poll(); this is because
|
||||
only one CPU can pick the initial interrupt and hence the initial
|
||||
netif_rx_schedule(dev);
|
||||
- The core layer invokes devices to send packets in a round robin format.
|
||||
This implies receive is totally lockless because of the guarantee that only
|
||||
one CPU is executing it.
|
||||
- contention can only be the result of some other CPU accessing the rx
|
||||
ring. This happens only in close() and suspend() (when these methods
|
||||
try to clean the rx ring);
|
||||
****guarantee: driver authors need not worry about this; synchronization
|
||||
is taken care for them by the top net layer.
|
||||
-local interrupts are enabled (if you dont move all to dev->poll()). For
|
||||
example link/MII and txcomplete continue functioning just same old way.
|
||||
This improves the latency of processing these events. It is also assumed that
|
||||
the receive interrupt is the largest cause of noise. Note this might not
|
||||
always be true.
|
||||
[according to Manfred Spraul, the winbond insists on sending one
|
||||
txmitcomplete interrupt for each packet (although this can be mitigated)].
|
||||
For these broken drivers, move all to dev->poll().
|
||||
|
||||
For the rest of this text, we'll assume that dev->poll() only
|
||||
processes receive events.
|
||||
|
||||
new methods introduce by NAPI
|
||||
=============================
|
||||
|
||||
a) netif_rx_schedule(dev)
|
||||
Called by an IRQ handler to schedule a poll for device
|
||||
|
||||
b) netif_rx_schedule_prep(dev)
|
||||
puts the device in a state which allows for it to be added to the
|
||||
CPU polling list if it is up and running. You can look at this as
|
||||
the first half of netif_rx_schedule(dev) above; the second half
|
||||
being c) below.
|
||||
|
||||
c) __netif_rx_schedule(dev)
|
||||
Add device to the poll list for this CPU; assuming that _prep above
|
||||
has already been called and returned 1.
|
||||
|
||||
d) netif_rx_reschedule(dev, undo)
|
||||
Called to reschedule polling for device specifically for some
|
||||
deficient hardware. Read Appendix 2 for more details.
|
||||
|
||||
e) netif_rx_complete(dev)
|
||||
|
||||
Remove interface from the CPU poll list: it must be in the poll list
|
||||
on current cpu. This primitive is called by dev->poll(), when
|
||||
it completes its work. The device cannot be out of poll list at this
|
||||
call, if it is then clearly it is a BUG(). You'll know ;->
|
||||
|
||||
All of the above methods are used below, so keep reading for clarity.
|
||||
|
||||
Device driver changes to be made when porting NAPI
|
||||
==================================================
|
||||
|
||||
Below we describe what kind of changes are required for NAPI to work.
|
||||
|
||||
1) introduction of dev->poll() method
|
||||
=====================================
|
||||
|
||||
This is the method that is invoked by the network core when it requests
|
||||
for new packets from the driver. A driver is allowed to send upto
|
||||
dev->quota packets by the current CPU before yielding to the network
|
||||
subsystem (so other devices can also get opportunity to send to the stack).
|
||||
|
||||
dev->poll() prototype looks as follows:
|
||||
int my_poll(struct net_device *dev, int *budget)
|
||||
|
||||
budget is the remaining number of packets the network subsystem on the
|
||||
current CPU can send up the stack before yielding to other system tasks.
|
||||
*Each driver is responsible for decrementing budget by the total number of
|
||||
packets sent.
|
||||
Total number of packets cannot exceed dev->quota.
|
||||
|
||||
dev->poll() method is invoked by the top layer, the driver just sends if it
|
||||
can to the stack the packet quantity requested.
|
||||
|
||||
more on dev->poll() below after the interrupt changes are explained.
|
||||
|
||||
2) registering dev->poll() method
|
||||
===================================
|
||||
|
||||
dev->poll should be set in the dev->probe() method.
|
||||
e.g:
|
||||
dev->open = my_open;
|
||||
.
|
||||
.
|
||||
/* two new additions */
|
||||
/* first register my poll method */
|
||||
dev->poll = my_poll;
|
||||
/* next register my weight/quanta; can be overridden in /proc */
|
||||
dev->weight = 16;
|
||||
.
|
||||
.
|
||||
dev->stop = my_close;
|
||||
|
||||
|
||||
|
||||
3) scheduling dev->poll()
|
||||
=============================
|
||||
This involves modifying the interrupt handler and the code
|
||||
path which takes the packet off the NIC and sends them to the
|
||||
stack.
|
||||
|
||||
it's important at this point to introduce the classical D Becker
|
||||
interrupt processor:
|
||||
|
||||
------------------
|
||||
static irqreturn_t
|
||||
netdevice_interrupt(int irq, void *dev_id, struct pt_regs *regs)
|
||||
{
|
||||
|
||||
struct net_device *dev = (struct net_device *)dev_instance;
|
||||
struct my_private *tp = (struct my_private *)dev->priv;
|
||||
|
||||
int work_count = my_work_count;
|
||||
status = read_interrupt_status_reg();
|
||||
if (status == 0)
|
||||
return IRQ_NONE; /* Shared IRQ: not us */
|
||||
if (status == 0xffff)
|
||||
return IRQ_HANDLED; /* Hot unplug */
|
||||
if (status & error)
|
||||
do_some_error_handling()
|
||||
|
||||
do {
|
||||
acknowledge_ints_ASAP();
|
||||
|
||||
if (status & link_interrupt) {
|
||||
spin_lock(&tp->link_lock);
|
||||
do_some_link_stat_stuff();
|
||||
spin_lock(&tp->link_lock);
|
||||
}
|
||||
|
||||
if (status & rx_interrupt) {
|
||||
receive_packets(dev);
|
||||
}
|
||||
|
||||
if (status & rx_nobufs) {
|
||||
make_rx_buffs_avail();
|
||||
}
|
||||
|
||||
if (status & tx_related) {
|
||||
spin_lock(&tp->lock);
|
||||
tx_ring_free(dev);
|
||||
if (tx_died)
|
||||
restart_tx();
|
||||
spin_unlock(&tp->lock);
|
||||
}
|
||||
|
||||
status = read_interrupt_status_reg();
|
||||
|
||||
} while (!(status & error) || more_work_to_be_done);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
We now change this to what is shown below to NAPI-enable it:
|
||||
|
||||
----------------------------------------------------------------------
|
||||
static irqreturn_t
|
||||
netdevice_interrupt(int irq, void *dev_id, struct pt_regs *regs)
|
||||
{
|
||||
struct net_device *dev = (struct net_device *)dev_instance;
|
||||
struct my_private *tp = (struct my_private *)dev->priv;
|
||||
|
||||
status = read_interrupt_status_reg();
|
||||
if (status == 0)
|
||||
return IRQ_NONE; /* Shared IRQ: not us */
|
||||
if (status == 0xffff)
|
||||
return IRQ_HANDLED; /* Hot unplug */
|
||||
if (status & error)
|
||||
do_some_error_handling();
|
||||
|
||||
do {
|
||||
/************************ start note *********************************/
|
||||
acknowledge_ints_ASAP(); // dont ack rx and rxnobuff here
|
||||
/************************ end note *********************************/
|
||||
|
||||
if (status & link_interrupt) {
|
||||
spin_lock(&tp->link_lock);
|
||||
do_some_link_stat_stuff();
|
||||
spin_unlock(&tp->link_lock);
|
||||
}
|
||||
/************************ start note *********************************/
|
||||
if (status & rx_interrupt || (status & rx_nobuffs)) {
|
||||
if (netif_rx_schedule_prep(dev)) {
|
||||
|
||||
/* disable interrupts caused
|
||||
* by arriving packets */
|
||||
disable_rx_and_rxnobuff_ints();
|
||||
/* tell system we have work to be done. */
|
||||
__netif_rx_schedule(dev);
|
||||
} else {
|
||||
printk("driver bug! interrupt while in poll\n");
|
||||
/* FIX by disabling interrupts */
|
||||
disable_rx_and_rxnobuff_ints();
|
||||
}
|
||||
}
|
||||
/************************ end note note *********************************/
|
||||
|
||||
if (status & tx_related) {
|
||||
spin_lock(&tp->lock);
|
||||
tx_ring_free(dev);
|
||||
|
||||
if (tx_died)
|
||||
restart_tx();
|
||||
spin_unlock(&tp->lock);
|
||||
}
|
||||
|
||||
status = read_interrupt_status_reg();
|
||||
|
||||
/************************ start note *********************************/
|
||||
} while (!(status & error) || more_work_to_be_done(status));
|
||||
/************************ end note note *********************************/
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
||||
We note several things from above:
|
||||
|
||||
I) Any interrupt source which is caused by arriving packets is now
|
||||
turned off when it occurs. Depending on the hardware, there could be
|
||||
several reasons that arriving packets would cause interrupts; these are the
|
||||
interrupt sources we wish to avoid. The two common ones are a) a packet
|
||||
arriving (rxint) b) a packet arriving and finding no DMA buffers available
|
||||
(rxnobuff) .
|
||||
This means also acknowledge_ints_ASAP() will not clear the status
|
||||
register for those two items above; clearing is done in the place where
|
||||
proper work is done within NAPI; at the poll() and refill_rx_ring()
|
||||
discussed further below.
|
||||
netif_rx_schedule_prep() returns 1 if device is in running state and
|
||||
gets successfully added to the core poll list. If we get a zero value
|
||||
we can _almost_ assume are already added to the list (instead of not running.
|
||||
Logic based on the fact that you shouldn't get interrupt if not running)
|
||||
We rectify this by disabling rx and rxnobuf interrupts.
|
||||
|
||||
II) that receive_packets(dev) and make_rx_buffs_avail() may have disappeared.
|
||||
These functionalities are still around actually......
|
||||
|
||||
infact, receive_packets(dev) is very close to my_poll() and
|
||||
make_rx_buffs_avail() is invoked from my_poll()
|
||||
|
||||
4) converting receive_packets() to dev->poll()
|
||||
===============================================
|
||||
|
||||
We need to convert the classical D Becker receive_packets(dev) to my_poll()
|
||||
|
||||
First the typical receive_packets() below:
|
||||
-------------------------------------------------------------------
|
||||
|
||||
/* this is called by interrupt handler */
|
||||
static void receive_packets (struct net_device *dev)
|
||||
{
|
||||
|
||||
struct my_private *tp = (struct my_private *)dev->priv;
|
||||
rx_ring = tp->rx_ring;
|
||||
cur_rx = tp->cur_rx;
|
||||
int entry = cur_rx % RX_RING_SIZE;
|
||||
int received = 0;
|
||||
int rx_work_limit = tp->dirty_rx + RX_RING_SIZE - tp->cur_rx;
|
||||
|
||||
while (rx_ring_not_empty) {
|
||||
u32 rx_status;
|
||||
unsigned int rx_size;
|
||||
unsigned int pkt_size;
|
||||
struct sk_buff *skb;
|
||||
/* read size+status of next frame from DMA ring buffer */
|
||||
/* the number 16 and 4 are just examples */
|
||||
rx_status = le32_to_cpu (*(u32 *) (rx_ring + ring_offset));
|
||||
rx_size = rx_status >> 16;
|
||||
pkt_size = rx_size - 4;
|
||||
|
||||
/* process errors */
|
||||
if ((rx_size > (MAX_ETH_FRAME_SIZE+4)) ||
|
||||
(!(rx_status & RxStatusOK))) {
|
||||
netdrv_rx_err (rx_status, dev, tp, ioaddr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (--rx_work_limit < 0)
|
||||
break;
|
||||
|
||||
/* grab a skb */
|
||||
skb = dev_alloc_skb (pkt_size + 2);
|
||||
if (skb) {
|
||||
.
|
||||
.
|
||||
netif_rx (skb);
|
||||
.
|
||||
.
|
||||
} else { /* OOM */
|
||||
/*seems very driver specific ... some just pass
|
||||
whatever is on the ring already. */
|
||||
}
|
||||
|
||||
/* move to the next skb on the ring */
|
||||
entry = (++tp->cur_rx) % RX_RING_SIZE;
|
||||
received++ ;
|
||||
|
||||
}
|
||||
|
||||
/* store current ring pointer state */
|
||||
tp->cur_rx = cur_rx;
|
||||
|
||||
/* Refill the Rx ring buffers if they are needed */
|
||||
refill_rx_ring();
|
||||
.
|
||||
.
|
||||
|
||||
}
|
||||
-------------------------------------------------------------------
|
||||
We change it to a new one below; note the additional parameter in
|
||||
the call.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
/* this is called by the network core */
|
||||
static int my_poll (struct net_device *dev, int *budget)
|
||||
{
|
||||
|
||||
struct my_private *tp = (struct my_private *)dev->priv;
|
||||
rx_ring = tp->rx_ring;
|
||||
cur_rx = tp->cur_rx;
|
||||
int entry = cur_rx % RX_BUF_LEN;
|
||||
/* maximum packets to send to the stack */
|
||||
/************************ note note *********************************/
|
||||
int rx_work_limit = dev->quota;
|
||||
|
||||
/************************ end note note *********************************/
|
||||
do { // outer beginning loop starts here
|
||||
|
||||
clear_rx_status_register_bit();
|
||||
|
||||
while (rx_ring_not_empty) {
|
||||
u32 rx_status;
|
||||
unsigned int rx_size;
|
||||
unsigned int pkt_size;
|
||||
struct sk_buff *skb;
|
||||
/* read size+status of next frame from DMA ring buffer */
|
||||
/* the number 16 and 4 are just examples */
|
||||
rx_status = le32_to_cpu (*(u32 *) (rx_ring + ring_offset));
|
||||
rx_size = rx_status >> 16;
|
||||
pkt_size = rx_size - 4;
|
||||
|
||||
/* process errors */
|
||||
if ((rx_size > (MAX_ETH_FRAME_SIZE+4)) ||
|
||||
(!(rx_status & RxStatusOK))) {
|
||||
netdrv_rx_err (rx_status, dev, tp, ioaddr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/************************ note note *********************************/
|
||||
if (--rx_work_limit < 0) { /* we got packets, but no quota */
|
||||
/* store current ring pointer state */
|
||||
tp->cur_rx = cur_rx;
|
||||
|
||||
/* Refill the Rx ring buffers if they are needed */
|
||||
refill_rx_ring(dev);
|
||||
goto not_done;
|
||||
}
|
||||
/********************** end note **********************************/
|
||||
|
||||
/* grab a skb */
|
||||
skb = dev_alloc_skb (pkt_size + 2);
|
||||
if (skb) {
|
||||
.
|
||||
.
|
||||
/************************ note note *********************************/
|
||||
netif_receive_skb (skb);
|
||||
/********************** end note **********************************/
|
||||
.
|
||||
.
|
||||
} else { /* OOM */
|
||||
/*seems very driver specific ... common is just pass
|
||||
whatever is on the ring already. */
|
||||
}
|
||||
|
||||
/* move to the next skb on the ring */
|
||||
entry = (++tp->cur_rx) % RX_RING_SIZE;
|
||||
received++ ;
|
||||
|
||||
}
|
||||
|
||||
/* store current ring pointer state */
|
||||
tp->cur_rx = cur_rx;
|
||||
|
||||
/* Refill the Rx ring buffers if they are needed */
|
||||
refill_rx_ring(dev);
|
||||
|
||||
/* no packets on ring; but new ones can arrive since we last
|
||||
checked */
|
||||
status = read_interrupt_status_reg();
|
||||
if (rx status is not set) {
|
||||
/* If something arrives in this narrow window,
|
||||
an interrupt will be generated */
|
||||
goto done;
|
||||
}
|
||||
/* done! at least that's what it looks like ;->
|
||||
if new packets came in after our last check on status bits
|
||||
they'll be caught by the while check and we go back and clear them
|
||||
since we havent exceeded our quota */
|
||||
} while (rx_status_is_set);
|
||||
|
||||
done:
|
||||
|
||||
/************************ note note *********************************/
|
||||
dev->quota -= received;
|
||||
*budget -= received;
|
||||
|
||||
/* If RX ring is not full we are out of memory. */
|
||||
if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
|
||||
goto oom;
|
||||
|
||||
/* we are happy/done, no more packets on ring; put us back
|
||||
to where we can start processing interrupts again */
|
||||
netif_rx_complete(dev);
|
||||
enable_rx_and_rxnobuf_ints();
|
||||
|
||||
/* The last op happens after poll completion. Which means the following:
|
||||
* 1. it can race with disabling irqs in irq handler (which are done to
|
||||
* schedule polls)
|
||||
* 2. it can race with dis/enabling irqs in other poll threads
|
||||
* 3. if an irq raised after the beginning of the outer beginning
|
||||
* loop (marked in the code above), it will be immediately
|
||||
* triggered here.
|
||||
*
|
||||
* Summarizing: the logic may result in some redundant irqs both
|
||||
* due to races in masking and due to too late acking of already
|
||||
* processed irqs. The good news: no events are ever lost.
|
||||
*/
|
||||
|
||||
return 0; /* done */
|
||||
|
||||
not_done:
|
||||
if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/2 ||
|
||||
tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
|
||||
refill_rx_ring(dev);
|
||||
|
||||
if (!received) {
|
||||
printk("received==0\n");
|
||||
received = 1;
|
||||
}
|
||||
dev->quota -= received;
|
||||
*budget -= received;
|
||||
return 1; /* not_done */
|
||||
|
||||
oom:
|
||||
/* Start timer, stop polling, but do not enable rx interrupts. */
|
||||
start_poll_timer(dev);
|
||||
return 0; /* we'll take it from here so tell core "done"*/
|
||||
|
||||
/************************ End note note *********************************/
|
||||
}
|
||||
-------------------------------------------------------------------
|
||||
|
||||
From above we note that:
|
||||
0) rx_work_limit = dev->quota
|
||||
1) refill_rx_ring() is in charge of clearing the bit for rxnobuff when
|
||||
it does the work.
|
||||
2) We have a done and not_done state.
|
||||
3) instead of netif_rx() we call netif_receive_skb() to pass the skb.
|
||||
4) we have a new way of handling oom condition
|
||||
5) A new outer for (;;) loop has been added. This serves the purpose of
|
||||
ensuring that if a new packet has come in, after we are all set and done,
|
||||
and we have not exceeded our quota that we continue sending packets up.
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
Poll timer code will need to do the following:
|
||||
|
||||
a)
|
||||
|
||||
if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/2 ||
|
||||
tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
|
||||
refill_rx_ring(dev);
|
||||
|
||||
/* If RX ring is not full we are still out of memory.
|
||||
Restart the timer again. Else we re-add ourselves
|
||||
to the master poll list.
|
||||
*/
|
||||
|
||||
if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
|
||||
restart_timer();
|
||||
|
||||
else netif_rx_schedule(dev); /* we are back on the poll list */
|
||||
|
||||
5) dev->close() and dev->suspend() issues
|
||||
==========================================
|
||||
The driver writer needn't worry about this; the top net layer takes
|
||||
care of it.
|
||||
|
||||
6) Adding new Stats to /proc
|
||||
=============================
|
||||
In order to debug some of the new features, we introduce new stats
|
||||
that need to be collected.
|
||||
TODO: Fill this later.
|
||||
|
||||
APPENDIX 1: discussion on using ethernet HW FC
|
||||
==============================================
|
||||
Most chips with FC only send a pause packet when they run out of Rx buffers.
|
||||
Since packets are pulled off the DMA ring by a softirq in NAPI,
|
||||
if the system is slow in grabbing them and we have a high input
|
||||
rate (faster than the system's capacity to remove packets), then theoretically
|
||||
there will only be one rx interrupt for all packets during a given packetstorm.
|
||||
Under low load, we might have a single interrupt per packet.
|
||||
FC should be programmed to apply in the case when the system cant pull out
|
||||
packets fast enough i.e send a pause only when you run out of rx buffers.
|
||||
Note FC in itself is a good solution but we have found it to not be
|
||||
much of a commodity feature (both in NICs and switches) and hence falls
|
||||
under the same category as using NIC based mitigation. Also, experiments
|
||||
indicate that it's much harder to resolve the resource allocation
|
||||
issue (aka lazy receiving that NAPI offers) and hence quantify its usefulness
|
||||
proved harder. In any case, FC works even better with NAPI but is not
|
||||
necessary.
|
||||
|
||||
|
||||
APPENDIX 2: the "rotting packet" race-window avoidance scheme
|
||||
=============================================================
|
||||
|
||||
There are two types of associations seen here
|
||||
|
||||
1) status/int which honors level triggered IRQ
|
||||
|
||||
If a status bit for receive or rxnobuff is set and the corresponding
|
||||
interrupt-enable bit is not on, then no interrupts will be generated. However,
|
||||
as soon as the "interrupt-enable" bit is unmasked, an immediate interrupt is
|
||||
generated. [assuming the status bit was not turned off].
|
||||
Generally the concept of level triggered IRQs in association with a status and
|
||||
interrupt-enable CSR register set is used to avoid the race.
|
||||
|
||||
If we take the example of the tulip:
|
||||
"pending work" is indicated by the status bit(CSR5 in tulip).
|
||||
the corresponding interrupt bit (CSR7 in tulip) might be turned off (but
|
||||
the CSR5 will continue to be turned on with new packet arrivals even if
|
||||
we clear it the first time)
|
||||
Very important is the fact that if we turn on the interrupt bit on when
|
||||
status is set that an immediate irq is triggered.
|
||||
|
||||
If we cleared the rx ring and proclaimed there was "no more work
|
||||
to be done" and then went on to do a few other things; then when we enable
|
||||
interrupts, there is a possibility that a new packet might sneak in during
|
||||
this phase. It helps to look at the pseudo code for the tulip poll
|
||||
routine:
|
||||
|
||||
--------------------------
|
||||
do {
|
||||
ACK;
|
||||
while (ring_is_not_empty()) {
|
||||
work-work-work
|
||||
if quota is exceeded: exit, no touching irq status/mask
|
||||
}
|
||||
/* No packets, but new can arrive while we are doing this*/
|
||||
CSR5 := read
|
||||
if (CSR5 is not set) {
|
||||
/* If something arrives in this narrow window here,
|
||||
* where the comments are ;-> irq will be generated */
|
||||
unmask irqs;
|
||||
exit poll;
|
||||
}
|
||||
} while (rx_status_is_set);
|
||||
------------------------
|
||||
|
||||
CSR5 bit of interest is only the rx status.
|
||||
If you look at the last if statement:
|
||||
you just finished grabbing all the packets from the rx ring .. you check if
|
||||
status bit says there are more packets just in ... it says none; you then
|
||||
enable rx interrupts again; if a new packet just came in during this check,
|
||||
we are counting that CSR5 will be set in that small window of opportunity
|
||||
and that by re-enabling interrupts, we would actually trigger an interrupt
|
||||
to register the new packet for processing.
|
||||
|
||||
[The above description nay be very verbose, if you have better wording
|
||||
that will make this more understandable, please suggest it.]
|
||||
|
||||
2) non-capable hardware
|
||||
|
||||
These do not generally respect level triggered IRQs. Normally,
|
||||
irqs may be lost while being masked and the only way to leave poll is to do
|
||||
a double check for new input after netif_rx_complete() is invoked
|
||||
and re-enable polling (after seeing this new input).
|
||||
|
||||
Sample code:
|
||||
|
||||
---------
|
||||
.
|
||||
.
|
||||
restart_poll:
|
||||
while (ring_is_not_empty()) {
|
||||
work-work-work
|
||||
if quota is exceeded: exit, not touching irq status/mask
|
||||
}
|
||||
.
|
||||
.
|
||||
.
|
||||
enable_rx_interrupts()
|
||||
netif_rx_complete(dev);
|
||||
if (ring_has_new_packet() && netif_rx_reschedule(dev, received)) {
|
||||
disable_rx_and_rxnobufs()
|
||||
goto restart_poll
|
||||
} while (rx_status_is_set);
|
||||
---------
|
||||
|
||||
Basically netif_rx_complete() removes us from the poll list, but because a
|
||||
new packet which will never be caught due to the possibility of a race
|
||||
might come in, we attempt to re-add ourselves to the poll list.
|
||||
|
||||
|
||||
|
||||
|
||||
APPENDIX 3: Scheduling issues.
|
||||
==============================
|
||||
As seen NAPI moves processing to softirq level. Linux uses the ksoftirqd as the
|
||||
general solution to schedule softirq's to run before next interrupt and by putting
|
||||
them under scheduler control. Also this prevents consecutive softirq's from
|
||||
monopolize the CPU. This also have the effect that the priority of ksoftirq needs
|
||||
to be considered when running very CPU-intensive applications and networking to
|
||||
get the proper balance of softirq/user balance. Increasing ksoftirq priority to 0
|
||||
(eventually more) is reported cure problems with low network performance at high
|
||||
CPU load.
|
||||
|
||||
Most used processes in a GIGE router:
|
||||
USER PID %CPU %MEM SIZE RSS TTY STAT START TIME COMMAND
|
||||
root 3 0.2 0.0 0 0 ? RWN Aug 15 602:00 (ksoftirqd_CPU0)
|
||||
root 232 0.0 7.9 41400 40884 ? S Aug 15 74:12 gated
|
||||
|
||||
--------------------------------------------------------------------
|
||||
|
||||
relevant sites:
|
||||
==================
|
||||
ftp://robur.slu.se/pub/Linux/net-development/NAPI/
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
TODO: Write net-skeleton.c driver.
|
||||
-------------------------------------------------------------
|
||||
|
||||
Authors:
|
||||
========
|
||||
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
|
||||
Jamal Hadi Salim <hadi@cyberus.ca>
|
||||
Robert Olsson <Robert.Olsson@data.slu.se>
|
||||
|
||||
Acknowledgements:
|
||||
================
|
||||
People who made this document better:
|
||||
|
||||
Lennert Buytenhek <buytenh@gnu.org>
|
||||
Andrew Morton <akpm@zip.com.au>
|
||||
Manfred Spraul <manfred@colorfullife.com>
|
||||
Donald Becker <becker@scyld.com>
|
||||
Jeff Garzik <jgarzik@pobox.com>
|
@ -38,8 +38,13 @@ Socket options
|
||||
DCCP_SOCKOPT_SERVICE sets the service. The specification mandates use of
|
||||
service codes (RFC 4340, sec. 8.1.2); if this socket option is not set,
|
||||
the socket will fall back to 0 (which means that no meaningful service code
|
||||
is present). Connecting sockets set at most one service option; for
|
||||
listening sockets, multiple service codes can be specified.
|
||||
is present). On active sockets this is set before connect(); specifying more
|
||||
than one code has no effect (all subsequent service codes are ignored). The
|
||||
case is different for passive sockets, where multiple service codes (up to 32)
|
||||
can be set before calling bind().
|
||||
|
||||
DCCP_SOCKOPT_GET_CUR_MPS is read-only and retrieves the current maximum packet
|
||||
size (application payload size) in bytes, see RFC 4340, section 14.
|
||||
|
||||
DCCP_SOCKOPT_SEND_CSCOV and DCCP_SOCKOPT_RECV_CSCOV are used for setting the
|
||||
partial checksum coverage (RFC 4340, sec. 9.2). The default is that checksums
|
||||
@ -50,12 +55,13 @@ be enabled at the receiver, too with suitable choice of CsCov.
|
||||
DCCP_SOCKOPT_SEND_CSCOV sets the sender checksum coverage. Values in the
|
||||
range 0..15 are acceptable. The default setting is 0 (full coverage),
|
||||
values between 1..15 indicate partial coverage.
|
||||
DCCP_SOCKOPT_SEND_CSCOV is for the receiver and has a different meaning: it
|
||||
DCCP_SOCKOPT_RECV_CSCOV is for the receiver and has a different meaning: it
|
||||
sets a threshold, where again values 0..15 are acceptable. The default
|
||||
of 0 means that all packets with a partial coverage will be discarded.
|
||||
Values in the range 1..15 indicate that packets with minimally such a
|
||||
coverage value are also acceptable. The higher the number, the more
|
||||
restrictive this setting (see [RFC 4340, sec. 9.2.1]).
|
||||
restrictive this setting (see [RFC 4340, sec. 9.2.1]). Partial coverage
|
||||
settings are inherited to the child socket after accept().
|
||||
|
||||
The following two options apply to CCID 3 exclusively and are getsockopt()-only.
|
||||
In either case, a TFRC info struct (defined in <linux/tfrc.h>) is returned.
|
||||
@ -112,9 +118,14 @@ tx_qlen = 5
|
||||
The size of the transmit buffer in packets. A value of 0 corresponds
|
||||
to an unbounded transmit buffer.
|
||||
|
||||
sync_ratelimit = 125 ms
|
||||
The timeout between subsequent DCCP-Sync packets sent in response to
|
||||
sequence-invalid packets on the same socket (RFC 4340, 7.5.4). The unit
|
||||
of this parameter is milliseconds; a value of 0 disables rate-limiting.
|
||||
|
||||
Notes
|
||||
=====
|
||||
|
||||
DCCP does not travel through NAT successfully at present on many boxes. This is
|
||||
because the checksum covers the psuedo-header as per TCP and UDP. Linux NAT
|
||||
because the checksum covers the pseudo-header as per TCP and UDP. Linux NAT
|
||||
support for DCCP has been added.
|
||||
|
@ -1,52 +0,0 @@
|
||||
The Digi International RightSwitch SE-X (dgrs) Device Driver
|
||||
|
||||
This is a Linux driver for the Digi International RightSwitch SE-X
|
||||
EISA and PCI boards. These are 4 (EISA) or 6 (PCI) port Ethernet
|
||||
switches and a NIC combined into a single board. This driver can
|
||||
be compiled into the kernel statically or as a loadable module.
|
||||
|
||||
There is also a companion management tool, called "xrightswitch".
|
||||
The management tool lets you watch the performance graphically,
|
||||
as well as set the SNMP agent IP and IPX addresses, IEEE Spanning
|
||||
Tree, and Aging time. These can also be set from the command line
|
||||
when the driver is loaded. The driver command line options are:
|
||||
|
||||
debug=NNN Debug printing level
|
||||
dma=0/1 Disable/Enable DMA on PCI card
|
||||
spantree=0/1 Disable/Enable IEEE spanning tree
|
||||
hashexpire=NNN Change address aging time (default 300 seconds)
|
||||
ipaddr=A,B,C,D Set SNMP agent IP address i.e. 199,86,8,221
|
||||
iptrap=A,B,C,D Set SNMP agent IP trap address i.e. 199,86,8,221
|
||||
ipxnet=NNN Set SNMP agent IPX network number
|
||||
nicmode=0/1 Disable/Enable multiple NIC mode
|
||||
|
||||
There is also a tool for setting up input and output packet filters
|
||||
on each port, called "dgrsfilt".
|
||||
|
||||
Both the management tool and the filtering tool are available
|
||||
separately from the following FTP site:
|
||||
|
||||
ftp://ftp.dgii.com/drivers/rightswitch/linux/
|
||||
|
||||
When nicmode=1, the board and driver operate as 4 or 6 individual
|
||||
NIC ports (eth0...eth5) instead of as a switch. All switching
|
||||
functions are disabled. In the future, the board firmware may include
|
||||
a routing cache when in this mode.
|
||||
|
||||
Copyright 1995-1996 Digi International Inc.
|
||||
|
||||
This software may be used and distributed according to the terms
|
||||
of the GNU General Public License, incorporated herein by reference.
|
||||
|
||||
For information on purchasing a RightSwitch SE-4 or SE-6
|
||||
board, please contact Digi's sales department at 1-612-912-3444
|
||||
or 1-800-DIGIBRD. Outside the U.S., please check our Web page at:
|
||||
|
||||
http://www.dgii.com
|
||||
|
||||
for sales offices worldwide. Tech support is also available through
|
||||
the channels listed on the Web site, although as long as I am
|
||||
employed on networking products at Digi I will be happy to provide
|
||||
any bug fixes that may be needed.
|
||||
|
||||
-Rick Richardson, rick@dgii.com
|
@ -180,13 +180,20 @@ tcp_fin_timeout - INTEGER
|
||||
to live longer. Cf. tcp_max_orphans.
|
||||
|
||||
tcp_frto - INTEGER
|
||||
Enables F-RTO, an enhanced recovery algorithm for TCP retransmission
|
||||
Enables Forward RTO-Recovery (F-RTO) defined in RFC4138.
|
||||
F-RTO is an enhanced recovery algorithm for TCP retransmission
|
||||
timeouts. It is particularly beneficial in wireless environments
|
||||
where packet loss is typically due to random radio interference
|
||||
rather than intermediate router congestion. If set to 1, basic
|
||||
version is enabled. 2 enables SACK enhanced F-RTO, which is
|
||||
EXPERIMENTAL. The basic version can be used also when SACK is
|
||||
enabled for a flow through tcp_sack sysctl.
|
||||
rather than intermediate router congestion. FRTO is sender-side
|
||||
only modification. Therefore it does not require any support from
|
||||
the peer, but in a typical case, however, where wireless link is
|
||||
the local access link and most of the data flows downlink, the
|
||||
faraway servers should have FRTO enabled to take advantage of it.
|
||||
If set to 1, basic version is enabled. 2 enables SACK enhanced
|
||||
F-RTO if flow uses SACK. The basic version can be used also when
|
||||
SACK is in use though scenario(s) with it exists where FRTO
|
||||
interacts badly with the packet counting of the SACK enabled TCP
|
||||
flow.
|
||||
|
||||
tcp_frto_response - INTEGER
|
||||
When F-RTO has detected that a TCP retransmission timeout was
|
||||
|
@ -13,15 +13,35 @@ The radiotap format is discussed in
|
||||
./Documentation/networking/radiotap-headers.txt.
|
||||
|
||||
Despite 13 radiotap argument types are currently defined, most only make sense
|
||||
to appear on received packets. Currently three kinds of argument are used by
|
||||
the injection code, although it knows to skip any other arguments that are
|
||||
present (facilitating replay of captured radiotap headers directly):
|
||||
to appear on received packets. The following information is parsed from the
|
||||
radiotap headers and used to control injection:
|
||||
|
||||
- IEEE80211_RADIOTAP_RATE - u8 arg in 500kbps units (0x02 --> 1Mbps)
|
||||
* IEEE80211_RADIOTAP_RATE
|
||||
|
||||
- IEEE80211_RADIOTAP_ANTENNA - u8 arg, 0x00 = ant1, 0x01 = ant2
|
||||
rate in 500kbps units, automatic if invalid or not present
|
||||
|
||||
- IEEE80211_RADIOTAP_DBM_TX_POWER - u8 arg, dBm
|
||||
|
||||
* IEEE80211_RADIOTAP_ANTENNA
|
||||
|
||||
antenna to use, automatic if not present
|
||||
|
||||
|
||||
* IEEE80211_RADIOTAP_DBM_TX_POWER
|
||||
|
||||
transmit power in dBm, automatic if not present
|
||||
|
||||
|
||||
* IEEE80211_RADIOTAP_FLAGS
|
||||
|
||||
IEEE80211_RADIOTAP_F_FCS: FCS will be removed and recalculated
|
||||
IEEE80211_RADIOTAP_F_WEP: frame will be encrypted if key available
|
||||
IEEE80211_RADIOTAP_F_FRAG: frame will be fragmented if longer than the
|
||||
current fragmentation threshold. Note that
|
||||
this flag is only reliable when software
|
||||
fragmentation is enabled)
|
||||
|
||||
The injection code can also skip all other currently defined radiotap fields
|
||||
facilitating replay of captured radiotap headers directly.
|
||||
|
||||
Here is an example valid radiotap header defining these three parameters
|
||||
|
||||
|
@ -3,6 +3,10 @@ started by Ingo Molnar <mingo@redhat.com>, 2001.09.17
|
||||
2.6 port and netpoll api by Matt Mackall <mpm@selenic.com>, Sep 9 2003
|
||||
|
||||
Please send bug reports to Matt Mackall <mpm@selenic.com>
|
||||
and Satyam Sharma <satyam.sharma@gmail.com>
|
||||
|
||||
Introduction:
|
||||
=============
|
||||
|
||||
This module logs kernel printk messages over UDP allowing debugging of
|
||||
problem where disk logging fails and serial consoles are impractical.
|
||||
@ -13,6 +17,9 @@ the specified interface as soon as possible. While this doesn't allow
|
||||
capture of early kernel panics, it does capture most of the boot
|
||||
process.
|
||||
|
||||
Sender and receiver configuration:
|
||||
==================================
|
||||
|
||||
It takes a string configuration parameter "netconsole" in the
|
||||
following format:
|
||||
|
||||
@ -34,21 +41,113 @@ Examples:
|
||||
|
||||
insmod netconsole netconsole=@/,@10.0.0.2/
|
||||
|
||||
It also supports logging to multiple remote agents by specifying
|
||||
parameters for the multiple agents separated by semicolons and the
|
||||
complete string enclosed in "quotes", thusly:
|
||||
|
||||
modprobe netconsole netconsole="@/,@10.0.0.2/;@/eth1,6892@10.0.0.3/"
|
||||
|
||||
Built-in netconsole starts immediately after the TCP stack is
|
||||
initialized and attempts to bring up the supplied dev at the supplied
|
||||
address.
|
||||
|
||||
The remote host can run either 'netcat -u -l -p <port>' or syslogd.
|
||||
|
||||
Dynamic reconfiguration:
|
||||
========================
|
||||
|
||||
Dynamic reconfigurability is a useful addition to netconsole that enables
|
||||
remote logging targets to be dynamically added, removed, or have their
|
||||
parameters reconfigured at runtime from a configfs-based userspace interface.
|
||||
[ Note that the parameters of netconsole targets that were specified/created
|
||||
from the boot/module option are not exposed via this interface, and hence
|
||||
cannot be modified dynamically. ]
|
||||
|
||||
To include this feature, select CONFIG_NETCONSOLE_DYNAMIC when building the
|
||||
netconsole module (or kernel, if netconsole is built-in).
|
||||
|
||||
Some examples follow (where configfs is mounted at the /sys/kernel/config
|
||||
mountpoint).
|
||||
|
||||
To add a remote logging target (target names can be arbitrary):
|
||||
|
||||
cd /sys/kernel/config/netconsole/
|
||||
mkdir target1
|
||||
|
||||
Note that newly created targets have default parameter values (as mentioned
|
||||
above) and are disabled by default -- they must first be enabled by writing
|
||||
"1" to the "enabled" attribute (usually after setting parameters accordingly)
|
||||
as described below.
|
||||
|
||||
To remove a target:
|
||||
|
||||
rmdir /sys/kernel/config/netconsole/othertarget/
|
||||
|
||||
The interface exposes these parameters of a netconsole target to userspace:
|
||||
|
||||
enabled Is this target currently enabled? (read-write)
|
||||
dev_name Local network interface name (read-write)
|
||||
local_port Source UDP port to use (read-write)
|
||||
remote_port Remote agent's UDP port (read-write)
|
||||
local_ip Source IP address to use (read-write)
|
||||
remote_ip Remote agent's IP address (read-write)
|
||||
local_mac Local interface's MAC address (read-only)
|
||||
remote_mac Remote agent's MAC address (read-write)
|
||||
|
||||
The "enabled" attribute is also used to control whether the parameters of
|
||||
a target can be updated or not -- you can modify the parameters of only
|
||||
disabled targets (i.e. if "enabled" is 0).
|
||||
|
||||
To update a target's parameters:
|
||||
|
||||
cat enabled # check if enabled is 1
|
||||
echo 0 > enabled # disable the target (if required)
|
||||
echo eth2 > dev_name # set local interface
|
||||
echo 10.0.0.4 > remote_ip # update some parameter
|
||||
echo cb:a9:87:65:43:21 > remote_mac # update more parameters
|
||||
echo 1 > enabled # enable target again
|
||||
|
||||
You can also update the local interface dynamically. This is especially
|
||||
useful if you want to use interfaces that have newly come up (and may not
|
||||
have existed when netconsole was loaded / initialized).
|
||||
|
||||
Miscellaneous notes:
|
||||
====================
|
||||
|
||||
WARNING: the default target ethernet setting uses the broadcast
|
||||
ethernet address to send packets, which can cause increased load on
|
||||
other systems on the same ethernet segment.
|
||||
|
||||
TIP: some LAN switches may be configured to suppress ethernet broadcasts
|
||||
so it is advised to explicitly specify the remote agents' MAC addresses
|
||||
from the config parameters passed to netconsole.
|
||||
|
||||
TIP: to find out the MAC address of, say, 10.0.0.2, you may try using:
|
||||
|
||||
ping -c 1 10.0.0.2 ; /sbin/arp -n | grep 10.0.0.2
|
||||
|
||||
TIP: in case the remote logging agent is on a separate LAN subnet than
|
||||
the sender, it is suggested to try specifying the MAC address of the
|
||||
default gateway (you may use /sbin/route -n to find it out) as the
|
||||
remote MAC address instead.
|
||||
|
||||
NOTE: the network device (eth1 in the above case) can run any kind
|
||||
of other network traffic, netconsole is not intrusive. Netconsole
|
||||
might cause slight delays in other traffic if the volume of kernel
|
||||
messages is high, but should have no other impact.
|
||||
|
||||
NOTE: if you find that the remote logging agent is not receiving or
|
||||
printing all messages from the sender, it is likely that you have set
|
||||
the "console_loglevel" parameter (on the sender) to only send high
|
||||
priority messages to the console. You can change this at runtime using:
|
||||
|
||||
dmesg -n 8
|
||||
|
||||
or by specifying "debug" on the kernel command line at boot, to send
|
||||
all kernel messages to the console. A specific value for this parameter
|
||||
can also be set using the "loglevel" kernel boot option. See the
|
||||
dmesg(8) man page and Documentation/kernel-parameters.txt for details.
|
||||
|
||||
Netconsole was designed to be as instantaneous as possible, to
|
||||
enable the logging of even the most critical kernel bugs. It works
|
||||
from IRQ contexts as well, and does not enable interrupts while
|
||||
|
@ -73,7 +73,8 @@ dev->hard_start_xmit:
|
||||
has to lock by itself when needed. It is recommended to use a try lock
|
||||
for this and return NETDEV_TX_LOCKED when the spin lock fails.
|
||||
The locking there should also properly protect against
|
||||
set_multicast_list.
|
||||
set_multicast_list. Note that the use of NETIF_F_LLTX is deprecated.
|
||||
Dont use it for new drivers.
|
||||
|
||||
Context: Process with BHs disabled or BH (timer),
|
||||
will be called with interrupts disabled by netconsole.
|
||||
@ -95,9 +96,13 @@ dev->set_multicast_list:
|
||||
Synchronization: netif_tx_lock spinlock.
|
||||
Context: BHs disabled
|
||||
|
||||
dev->poll:
|
||||
Synchronization: __LINK_STATE_RX_SCHED bit in dev->state. See
|
||||
dev_close code and comments in net/core/dev.c for more info.
|
||||
struct napi_struct synchronization rules
|
||||
========================================
|
||||
napi->poll:
|
||||
Synchronization: NAPI_STATE_SCHED bit in napi->state. Device
|
||||
driver's dev->close method will invoke napi_disable() on
|
||||
all NAPI instances which will do a sleeping poll on the
|
||||
NAPI_STATE_SCHED napi->state bit, waiting for all pending
|
||||
NAPI activity to cease.
|
||||
Context: softirq
|
||||
will be called with interrupts disabled by netconsole.
|
||||
|
||||
|
@ -1824,6 +1824,162 @@ platforms are moved over to use the flattened-device-tree model.
|
||||
fsl,has-rstcr;
|
||||
};
|
||||
|
||||
|
||||
h) 4xx/Axon EMAC ethernet nodes
|
||||
|
||||
The EMAC ethernet controller in IBM and AMCC 4xx chips, and also
|
||||
the Axon bridge. To operate this needs to interact with a ths
|
||||
special McMAL DMA controller, and sometimes an RGMII or ZMII
|
||||
interface. In addition to the nodes and properties described
|
||||
below, the node for the OPB bus on which the EMAC sits must have a
|
||||
correct clock-frequency property.
|
||||
|
||||
i) The EMAC node itself
|
||||
|
||||
Required properties:
|
||||
- device_type : "network"
|
||||
|
||||
- compatible : compatible list, contains 2 entries, first is
|
||||
"ibm,emac-CHIP" where CHIP is the host ASIC (440gx,
|
||||
405gp, Axon) and second is either "ibm,emac" or
|
||||
"ibm,emac4". For Axon, thus, we have: "ibm,emac-axon",
|
||||
"ibm,emac4"
|
||||
- interrupts : <interrupt mapping for EMAC IRQ and WOL IRQ>
|
||||
- interrupt-parent : optional, if needed for interrupt mapping
|
||||
- reg : <registers mapping>
|
||||
- local-mac-address : 6 bytes, MAC address
|
||||
- mal-device : phandle of the associated McMAL node
|
||||
- mal-tx-channel : 1 cell, index of the tx channel on McMAL associated
|
||||
with this EMAC
|
||||
- mal-rx-channel : 1 cell, index of the rx channel on McMAL associated
|
||||
with this EMAC
|
||||
- cell-index : 1 cell, hardware index of the EMAC cell on a given
|
||||
ASIC (typically 0x0 and 0x1 for EMAC0 and EMAC1 on
|
||||
each Axon chip)
|
||||
- max-frame-size : 1 cell, maximum frame size supported in bytes
|
||||
- rx-fifo-size : 1 cell, Rx fifo size in bytes for 10 and 100 Mb/sec
|
||||
operations.
|
||||
For Axon, 2048
|
||||
- tx-fifo-size : 1 cell, Tx fifo size in bytes for 10 and 100 Mb/sec
|
||||
operations.
|
||||
For Axon, 2048.
|
||||
- fifo-entry-size : 1 cell, size of a fifo entry (used to calculate
|
||||
thresholds).
|
||||
For Axon, 0x00000010
|
||||
- mal-burst-size : 1 cell, MAL burst size (used to calculate thresholds)
|
||||
in bytes.
|
||||
For Axon, 0x00000100 (I think ...)
|
||||
- phy-mode : string, mode of operations of the PHY interface.
|
||||
Supported values are: "mii", "rmii", "smii", "rgmii",
|
||||
"tbi", "gmii", rtbi", "sgmii".
|
||||
For Axon on CAB, it is "rgmii"
|
||||
- mdio-device : 1 cell, required iff using shared MDIO registers
|
||||
(440EP). phandle of the EMAC to use to drive the
|
||||
MDIO lines for the PHY used by this EMAC.
|
||||
- zmii-device : 1 cell, required iff connected to a ZMII. phandle of
|
||||
the ZMII device node
|
||||
- zmii-channel : 1 cell, required iff connected to a ZMII. Which ZMII
|
||||
channel or 0xffffffff if ZMII is only used for MDIO.
|
||||
- rgmii-device : 1 cell, required iff connected to an RGMII. phandle
|
||||
of the RGMII device node.
|
||||
For Axon: phandle of plb5/plb4/opb/rgmii
|
||||
- rgmii-channel : 1 cell, required iff connected to an RGMII. Which
|
||||
RGMII channel is used by this EMAC.
|
||||
Fox Axon: present, whatever value is appropriate for each
|
||||
EMAC, that is the content of the current (bogus) "phy-port"
|
||||
property.
|
||||
|
||||
Recommended properties:
|
||||
- linux,network-index : This is the intended "index" of this
|
||||
network device. This is used by the bootwrapper to interpret
|
||||
MAC addresses passed by the firmware when no information other
|
||||
than indices is available to associate an address with a device.
|
||||
|
||||
Optional properties:
|
||||
- phy-address : 1 cell, optional, MDIO address of the PHY. If absent,
|
||||
a search is performed.
|
||||
- phy-map : 1 cell, optional, bitmap of addresses to probe the PHY
|
||||
for, used if phy-address is absent. bit 0x00000001 is
|
||||
MDIO address 0.
|
||||
For Axon it can be absent, thouugh my current driver
|
||||
doesn't handle phy-address yet so for now, keep
|
||||
0x00ffffff in it.
|
||||
- rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec
|
||||
operations (if absent the value is the same as
|
||||
rx-fifo-size). For Axon, either absent or 2048.
|
||||
- tx-fifo-size-gige : 1 cell, Tx fifo size in bytes for 1000 Mb/sec
|
||||
operations (if absent the value is the same as
|
||||
tx-fifo-size). For Axon, either absent or 2048.
|
||||
- tah-device : 1 cell, optional. If connected to a TAH engine for
|
||||
offload, phandle of the TAH device node.
|
||||
- tah-channel : 1 cell, optional. If appropriate, channel used on the
|
||||
TAH engine.
|
||||
|
||||
Example:
|
||||
|
||||
EMAC0: ethernet@40000800 {
|
||||
linux,network-index = <0>;
|
||||
device_type = "network";
|
||||
compatible = "ibm,emac-440gp", "ibm,emac";
|
||||
interrupt-parent = <&UIC1>;
|
||||
interrupts = <1c 4 1d 4>;
|
||||
reg = <40000800 70>;
|
||||
local-mac-address = [00 04 AC E3 1B 1E];
|
||||
mal-device = <&MAL0>;
|
||||
mal-tx-channel = <0 1>;
|
||||
mal-rx-channel = <0>;
|
||||
cell-index = <0>;
|
||||
max-frame-size = <5dc>;
|
||||
rx-fifo-size = <1000>;
|
||||
tx-fifo-size = <800>;
|
||||
phy-mode = "rmii";
|
||||
phy-map = <00000001>;
|
||||
zmii-device = <&ZMII0>;
|
||||
zmii-channel = <0>;
|
||||
};
|
||||
|
||||
ii) McMAL node
|
||||
|
||||
Required properties:
|
||||
- device_type : "dma-controller"
|
||||
- compatible : compatible list, containing 2 entries, first is
|
||||
"ibm,mcmal-CHIP" where CHIP is the host ASIC (like
|
||||
emac) and the second is either "ibm,mcmal" or
|
||||
"ibm,mcmal2".
|
||||
For Axon, "ibm,mcmal-axon","ibm,mcmal2"
|
||||
- interrupts : <interrupt mapping for the MAL interrupts sources:
|
||||
5 sources: tx_eob, rx_eob, serr, txde, rxde>.
|
||||
For Axon: This is _different_ from the current
|
||||
firmware. We use the "delayed" interrupts for txeob
|
||||
and rxeob. Thus we end up with mapping those 5 MPIC
|
||||
interrupts, all level positive sensitive: 10, 11, 32,
|
||||
33, 34 (in decimal)
|
||||
- dcr-reg : < DCR registers range >
|
||||
- dcr-parent : if needed for dcr-reg
|
||||
- num-tx-chans : 1 cell, number of Tx channels
|
||||
- num-rx-chans : 1 cell, number of Rx channels
|
||||
|
||||
iii) ZMII node
|
||||
|
||||
Required properties:
|
||||
- compatible : compatible list, containing 2 entries, first is
|
||||
"ibm,zmii-CHIP" where CHIP is the host ASIC (like
|
||||
EMAC) and the second is "ibm,zmii".
|
||||
For Axon, there is no ZMII node.
|
||||
- reg : <registers mapping>
|
||||
|
||||
iv) RGMII node
|
||||
|
||||
Required properties:
|
||||
- compatible : compatible list, containing 2 entries, first is
|
||||
"ibm,rgmii-CHIP" where CHIP is the host ASIC (like
|
||||
EMAC) and the second is "ibm,rgmii".
|
||||
For Axon, "ibm,rgmii-axon","ibm,rgmii"
|
||||
- reg : <registers mapping>
|
||||
- revision : as provided by the RGMII new version register if
|
||||
available.
|
||||
For Axon: 0x0000012a
|
||||
|
||||
More devices will be defined as this spec matures.
|
||||
|
||||
VII - Specifying interrupt information for devices
|
||||
|
89
Documentation/rfkill.txt
Normal file
89
Documentation/rfkill.txt
Normal file
@ -0,0 +1,89 @@
|
||||
rfkill - RF switch subsystem support
|
||||
====================================
|
||||
|
||||
1 Implementation details
|
||||
2 Driver support
|
||||
3 Userspace support
|
||||
|
||||
===============================================================================
|
||||
1: Implementation details
|
||||
|
||||
The rfkill switch subsystem offers support for keys often found on laptops
|
||||
to enable wireless devices like WiFi and Bluetooth.
|
||||
|
||||
This is done by providing the user 3 possibilities:
|
||||
1 - The rfkill system handles all events; userspace is not aware of events.
|
||||
2 - The rfkill system handles all events; userspace is informed about the events.
|
||||
3 - The rfkill system does not handle events; userspace handles all events.
|
||||
|
||||
The buttons to enable and disable the wireless radios are important in
|
||||
situations where the user is for example using his laptop on a location where
|
||||
wireless radios _must_ be disabled (e.g. airplanes).
|
||||
Because of this requirement, userspace support for the keys should not be
|
||||
made mandatory. Because userspace might want to perform some additional smarter
|
||||
tasks when the key is pressed, rfkill still provides userspace the possibility
|
||||
to take over the task to handle the key events.
|
||||
|
||||
The system inside the kernel has been split into 2 separate sections:
|
||||
1 - RFKILL
|
||||
2 - RFKILL_INPUT
|
||||
|
||||
The first option enables rfkill support and will make sure userspace will
|
||||
be notified of any events through the input device. It also creates several
|
||||
sysfs entries which can be used by userspace. See section "Userspace support".
|
||||
|
||||
The second option provides an rfkill input handler. This handler will
|
||||
listen to all rfkill key events and will toggle the radio accordingly.
|
||||
With this option enabled userspace could either do nothing or simply
|
||||
perform monitoring tasks.
|
||||
|
||||
====================================
|
||||
2: Driver support
|
||||
|
||||
To build a driver with rfkill subsystem support, the driver should
|
||||
depend on the Kconfig symbol RFKILL; it should _not_ depend on
|
||||
RKFILL_INPUT.
|
||||
|
||||
Unless key events trigger an interrupt to which the driver listens, polling
|
||||
will be required to determine the key state changes. For this the input
|
||||
layer providers the input-polldev handler.
|
||||
|
||||
A driver should implement a few steps to correctly make use of the
|
||||
rfkill subsystem. First for non-polling drivers:
|
||||
|
||||
- rfkill_allocate()
|
||||
- input_allocate_device()
|
||||
- rfkill_register()
|
||||
- input_register_device()
|
||||
|
||||
For polling drivers:
|
||||
|
||||
- rfkill_allocate()
|
||||
- input_allocate_polled_device()
|
||||
- rfkill_register()
|
||||
- input_register_polled_device()
|
||||
|
||||
When a key event has been detected, the correct event should be
|
||||
sent over the input device which has been registered by the driver.
|
||||
|
||||
====================================
|
||||
3: Userspace support
|
||||
|
||||
For each key an input device will be created which will send out the correct
|
||||
key event when the rfkill key has been pressed.
|
||||
|
||||
The following sysfs entries will be created:
|
||||
|
||||
name: Name assigned by driver to this key (interface or driver name).
|
||||
type: Name of the key type ("wlan", "bluetooth", etc).
|
||||
state: Current state of the key. 1: On, 0: Off.
|
||||
claim: 1: Userspace handles events, 0: Kernel handles events
|
||||
|
||||
Both the "state" and "claim" entries are also writable. For the "state" entry
|
||||
this means that when 1 or 0 is written all radios, not yet in the requested
|
||||
state, will be will be toggled accordingly.
|
||||
For the "claim" entry writing 1 to it means that the kernel no longer handles
|
||||
key events even though RFKILL_INPUT input was enabled. When "claim" has been
|
||||
set to 0, userspace should make sure that it listens for the input events or
|
||||
check the sysfs "state" entry regularly to correctly perform the required
|
||||
tasks when the rkfill key is pressed.
|
101
MAINTAINERS
101
MAINTAINERS
@ -284,6 +284,14 @@ M: corentin.labbe@geomatys.fr
|
||||
L: lm-sensors@lm-sensors.org
|
||||
S: Maintained
|
||||
|
||||
ADM8211 WIRELESS DRIVER
|
||||
P: Michael Wu
|
||||
M: flamingice@sourmilk.net
|
||||
L: linux-wireless@vger.kernel.org
|
||||
W: http://linuxwireless.org/
|
||||
T: git kernel.org:/pub/scm/linux/kernel/git/mwu/mac80211-drivers.git
|
||||
S: Maintained
|
||||
|
||||
ADT746X FAN DRIVER
|
||||
P: Colin Leroy
|
||||
M: colin@colino.net
|
||||
@ -761,6 +769,22 @@ L: linux-hams@vger.kernel.org
|
||||
W: http://www.baycom.org/~tom/ham/ham.html
|
||||
S: Maintained
|
||||
|
||||
B43 WIRELESS DRIVER
|
||||
P: Michael Buesch
|
||||
M: mb@bu3sch.de
|
||||
P: Stefano Brivio
|
||||
M: st3@riseup.net
|
||||
L: linux-wireless@vger.kernel.org
|
||||
W: http://bcm43xx.berlios.de/
|
||||
S: Maintained
|
||||
|
||||
B43LEGACY WIRELESS DRIVER
|
||||
P: Larry Finger
|
||||
M: Larry.Finger@lwfinger.net
|
||||
L: linux-wireless@vger.kernel.org
|
||||
W: http://bcm43xx.berlios.de/
|
||||
S: Maintained
|
||||
|
||||
BCM43XX WIRELESS DRIVER (SOFTMAC BASED VERSION)
|
||||
P: Larry Finger
|
||||
M: Larry.Finger@lwfinger.net
|
||||
@ -1224,12 +1248,6 @@ L: Eng.Linux@digi.com
|
||||
W: http://www.digi.com
|
||||
S: Orphaned
|
||||
|
||||
DIGI RIGHTSWITCH NETWORK DRIVER
|
||||
P: Rick Richardson
|
||||
L: netdev@vger.kernel.org
|
||||
W: http://www.digi.com
|
||||
S: Orphaned
|
||||
|
||||
DIRECTORY NOTIFICATION
|
||||
P: Stephen Rothwell
|
||||
M: sfr@canb.auug.org.au
|
||||
@ -1996,16 +2014,14 @@ W: http://sourceforge.net/projects/e1000/
|
||||
S: Supported
|
||||
|
||||
INTEL PRO/10GbE SUPPORT
|
||||
P: Jeff Kirsher
|
||||
M: jeffrey.t.kirsher@intel.com
|
||||
P: Ayyappan Veeraiyan
|
||||
M: ayyappan.veeraiyan@intel.com
|
||||
P: John Ronciak
|
||||
M: john.ronciak@intel.com
|
||||
P: Jesse Brandeburg
|
||||
M: jesse.brandeburg@intel.com
|
||||
P: Auke Kok
|
||||
M: auke-jan.h.kok@intel.com
|
||||
P: Jesse Brandeburg
|
||||
M: jesse.brandeburg@intel.com
|
||||
P: John Ronciak
|
||||
M: john.ronciak@intel.com
|
||||
L: e1000-devel@lists.sourceforge.net
|
||||
W: http://sourceforge.net/projects/e1000/
|
||||
S: Supported
|
||||
@ -2032,6 +2048,15 @@ L: http://lists.sourceforge.net/mailman/listinfo/ipw2100-devel
|
||||
W: http://ipw2200.sourceforge.net
|
||||
S: Supported
|
||||
|
||||
INTEL WIRELESS WIFI LINK (iwlwifi)
|
||||
P: Zhu Yi
|
||||
M: yi.zhu@intel.com
|
||||
L: linux-wireless@vger.kernel.org
|
||||
L: ipw3945-devel@lists.sourceforge.net
|
||||
W: http://intellinuxwireless.org
|
||||
T: git git://intellinuxwireless.org/repos/iwlwifi
|
||||
S: Supported
|
||||
|
||||
IOC3 ETHERNET DRIVER
|
||||
P: Ralf Baechle
|
||||
M: ralf@linux-mips.org
|
||||
@ -2049,6 +2074,16 @@ P: Juanjo Ciarlante
|
||||
M: jjciarla@raiz.uncu.edu.ar
|
||||
S: Maintained
|
||||
|
||||
IP1000A 10/100/1000 GIGABIT ETHERNET DRIVER
|
||||
P: Francois Romieu
|
||||
M: romieu@fr.zoreil.com
|
||||
P: Sorbica Shieh
|
||||
M: sorbica@icplus.com.tw
|
||||
P: Jesse Huang
|
||||
M: jesse@icplus.com.tw
|
||||
L: netdev@vger.kernel.org
|
||||
S: Maintained
|
||||
|
||||
IPATH DRIVER:
|
||||
P: Arthur Jones
|
||||
M: infinipath@qlogic.com
|
||||
@ -2999,6 +3034,14 @@ L: kpreempt-tech@lists.sourceforge.net
|
||||
W: ftp://ftp.kernel.org/pub/linux/kernel/people/rml/preempt-kernel
|
||||
S: Supported
|
||||
|
||||
P54 WIRELESS DRIVER
|
||||
P: Michael Wu
|
||||
M: flamingice@sourmilk.net
|
||||
L: linux-wireless@vger.kernel.org
|
||||
W: http://prism54.org
|
||||
T: git kernel.org:/pub/scm/linux/kernel/git/mwu/mac80211-drivers.git
|
||||
S: Maintained
|
||||
|
||||
PRISM54 WIRELESS DRIVER
|
||||
P: Luis R. Rodriguez
|
||||
M: mcgrof@gmail.com
|
||||
@ -3086,6 +3129,14 @@ M: corey@world.std.com
|
||||
L: linux-wireless@vger.kernel.org
|
||||
S: Maintained
|
||||
|
||||
RALINK RT2X00 WLAN DRIVER
|
||||
P: rt2x00 project
|
||||
L: linux-wireless@vger.kernel.org
|
||||
L: rt2400-devel@lists.sourceforge.net
|
||||
W: http://rt2x00.serialmonkey.com/
|
||||
S: Maintained
|
||||
F: drivers/net/wireless/rt2x00/
|
||||
|
||||
RANDOM NUMBER DRIVER
|
||||
P: Matt Mackall
|
||||
M: mpm@selenic.com
|
||||
@ -3171,8 +3222,8 @@ W: http://www.ibm.com/developerworks/linux/linux390/
|
||||
S: Supported
|
||||
|
||||
S390 NETWORK DRIVERS
|
||||
P: Frank Pavlic
|
||||
M: fpavlic@de.ibm.com
|
||||
P: Ursula Braun
|
||||
M: ubraun@linux.vnet.ibm.com
|
||||
M: linux390@de.ibm.com
|
||||
L: linux-s390@vger.kernel.org
|
||||
W: http://www.ibm.com/developerworks/linux/linux390/
|
||||
@ -3186,6 +3237,14 @@ L: linux-s390@vger.kernel.org
|
||||
W: http://www.ibm.com/developerworks/linux/linux390/
|
||||
S: Supported
|
||||
|
||||
S390 IUCV NETWORK LAYER
|
||||
P: Ursula Braun
|
||||
M: ubraun@linux.vnet.ibm.com
|
||||
M: linux390@de.ibm.com
|
||||
L: linux-s390@vger.kernel.org
|
||||
W: http://www.ibm.com/developerworks/linux/linux390/
|
||||
S: Supported
|
||||
|
||||
SAA7146 VIDEO4LINUX-2 DRIVER
|
||||
P: Michael Hunold
|
||||
M: michael@mihu.de
|
||||
@ -3410,6 +3469,12 @@ M: tsbogend@alpha.franken.de
|
||||
L: netdev@vger.kernel.org
|
||||
S: Maintained
|
||||
|
||||
SONICS SILICON BACKPLANE DRIVER (SSB)
|
||||
P: Michael Buesch
|
||||
M: mb@bu3sch.de
|
||||
L: netdev@vger.kernel.org
|
||||
S: Maintained
|
||||
|
||||
SONY VAIO CONTROL DEVICE DRIVER
|
||||
P: Mattia Dongili
|
||||
M: malattia@linux.it
|
||||
@ -3594,6 +3659,14 @@ M: hlhung3i@gmail.com
|
||||
W: http://tcp-lp-mod.sourceforge.net/
|
||||
S: Maintained
|
||||
|
||||
TEHUTI ETHERNET DRIVER
|
||||
P: Alexander Indenbaum
|
||||
M: baum@tehutinetworks.net
|
||||
P: Andy Gospodarek
|
||||
M: andy@greyhouse.net
|
||||
L: netdev@vger.kernel.org
|
||||
S: Supported
|
||||
|
||||
TI FLASH MEDIA INTERFACE DRIVER
|
||||
P: Alex Dubov
|
||||
M: oakad@yahoo.com
|
||||
|
@ -294,6 +294,9 @@ simeth_device_event(struct notifier_block *this,unsigned long event, void *ptr)
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
if (dev->nd_net != &init_net)
|
||||
return NOTIFY_DONE;
|
||||
|
||||
if ( event != NETDEV_UP && event != NETDEV_DOWN ) return NOTIFY_DONE;
|
||||
|
||||
/*
|
||||
|
@ -573,7 +573,7 @@ CONFIG_MII=y
|
||||
# CONFIG_HAMACHI is not set
|
||||
# CONFIG_YELLOWFIN is not set
|
||||
# CONFIG_R8169 is not set
|
||||
CONFIG_NET_SB1250_MAC=y
|
||||
CONFIG_SB1250_MAC=y
|
||||
# CONFIG_SIS190 is not set
|
||||
# CONFIG_SKGE is not set
|
||||
# CONFIG_SKY2 is not set
|
||||
|
@ -565,7 +565,7 @@ CONFIG_MII=y
|
||||
# CONFIG_HAMACHI is not set
|
||||
# CONFIG_YELLOWFIN is not set
|
||||
# CONFIG_R8169 is not set
|
||||
CONFIG_NET_SB1250_MAC=y
|
||||
CONFIG_SB1250_MAC=y
|
||||
# CONFIG_SIS190 is not set
|
||||
# CONFIG_SKGE is not set
|
||||
# CONFIG_SKY2 is not set
|
||||
|
@ -395,7 +395,6 @@ void do_softirq(void)
|
||||
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
EXPORT_SYMBOL(do_softirq);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -38,8 +38,7 @@ config 440EP
|
||||
|
||||
config 440GP
|
||||
bool
|
||||
# Disabled until the new EMAC Driver is merged.
|
||||
# select IBM_NEW_EMAC_ZMII
|
||||
select IBM_NEW_EMAC_ZMII
|
||||
|
||||
config 440GX
|
||||
bool
|
||||
|
@ -10,6 +10,10 @@ config PPC_CELL_NATIVE
|
||||
select PPC_INDIRECT_IO
|
||||
select PPC_NATIVE
|
||||
select MPIC
|
||||
select IBM_NEW_EMAC_EMAC4
|
||||
select IBM_NEW_EMAC_RGMII
|
||||
select IBM_NEW_EMAC_ZMII #test only
|
||||
select IBM_NEW_EMAC_TAH #test only
|
||||
default n
|
||||
|
||||
config PPC_IBM_CELL_BLADE
|
||||
|
@ -18,6 +18,16 @@ config PPC_PASEMI_IOMMU
|
||||
help
|
||||
IOMMU support for PA6T-1682M
|
||||
|
||||
config PPC_PASEMI_IOMMU_DMA_FORCE
|
||||
bool "Force DMA engine to use IOMMU"
|
||||
depends on PPC_PASEMI_IOMMU
|
||||
help
|
||||
This option forces the use of the IOMMU also for the
|
||||
DMA engine. Otherwise the kernel will use it only when
|
||||
running under a hypervisor.
|
||||
|
||||
If in doubt, say "N".
|
||||
|
||||
config PPC_PASEMI_MDIO
|
||||
depends on PHYLIB
|
||||
tristate "MDIO support via GPIO"
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <asm/iommu.h>
|
||||
#include <asm/machdep.h>
|
||||
#include <asm/abs_addr.h>
|
||||
#include <asm/firmware.h>
|
||||
|
||||
|
||||
#define IOBMAP_PAGE_SHIFT 12
|
||||
@ -175,13 +176,17 @@ static void pci_dma_dev_setup_pasemi(struct pci_dev *dev)
|
||||
{
|
||||
pr_debug("pci_dma_dev_setup, dev %p (%s)\n", dev, pci_name(dev));
|
||||
|
||||
/* DMA device is untranslated, but all other PCI-e goes through
|
||||
* the IOMMU
|
||||
#if !defined(CONFIG_PPC_PASEMI_IOMMU_DMA_FORCE)
|
||||
/* For non-LPAR environment, don't translate anything for the DMA
|
||||
* engine. The exception to this is if the user has enabled
|
||||
* CONFIG_PPC_PASEMI_IOMMU_DMA_FORCE at build time.
|
||||
*/
|
||||
if (dev->vendor == 0x1959 && dev->device == 0xa007)
|
||||
if (dev->vendor == 0x1959 && dev->device == 0xa007 &&
|
||||
!firmware_has_feature(FW_FEATURE_LPAR))
|
||||
dev->dev.archdata.dma_ops = &dma_direct_ops;
|
||||
else
|
||||
dev->dev.archdata.dma_data = &iommu_table_iobmap;
|
||||
#endif
|
||||
|
||||
dev->dev.archdata.dma_data = &iommu_table_iobmap;
|
||||
}
|
||||
|
||||
static void pci_dma_bus_setup_null(struct pci_bus *b) { }
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <linux/errno.h>
|
||||
#include <linux/kernel_stat.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <net/net_namespace.h>
|
||||
|
||||
#include "appldata.h"
|
||||
|
||||
@ -107,7 +108,7 @@ static void appldata_get_net_sum_data(void *data)
|
||||
tx_dropped = 0;
|
||||
collisions = 0;
|
||||
read_lock(&dev_base_lock);
|
||||
for_each_netdev(dev) {
|
||||
for_each_netdev(&init_net, dev) {
|
||||
stats = dev->get_stats(dev);
|
||||
rx_packets += stats->rx_packets;
|
||||
tx_packets += stats->tx_packets;
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Copyright IBM Corp. 2005,2007
|
||||
* Author(s): Jan Glauber (jang@de.ibm.com)
|
||||
*
|
||||
* Derived from "crypto/aes.c"
|
||||
* Derived from "crypto/aes_generic.c"
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
|
@ -12,7 +12,7 @@
|
||||
* Author(s): Thomas Spatzier
|
||||
* Jan Glauber (jan.glauber@de.ibm.com)
|
||||
*
|
||||
* Derived from "crypto/sha1.c"
|
||||
* Derived from "crypto/sha1_generic.c"
|
||||
* Copyright (c) Alan Smithee.
|
||||
* Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
|
||||
* Copyright (c) Jean-Francois Dive <jef@linuxbe.org>
|
||||
@ -26,12 +26,10 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <crypto/sha.h>
|
||||
|
||||
#include "crypt_s390.h"
|
||||
|
||||
#define SHA1_DIGEST_SIZE 20
|
||||
#define SHA1_BLOCK_SIZE 64
|
||||
|
||||
struct s390_sha1_ctx {
|
||||
u64 count; /* message length */
|
||||
u32 state[5];
|
||||
@ -42,11 +40,11 @@ static void sha1_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct s390_sha1_ctx *sctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
sctx->state[0] = 0x67452301;
|
||||
sctx->state[1] = 0xEFCDAB89;
|
||||
sctx->state[2] = 0x98BADCFE;
|
||||
sctx->state[3] = 0x10325476;
|
||||
sctx->state[4] = 0xC3D2E1F0;
|
||||
sctx->state[0] = SHA1_H0;
|
||||
sctx->state[1] = SHA1_H1;
|
||||
sctx->state[2] = SHA1_H2;
|
||||
sctx->state[3] = SHA1_H3;
|
||||
sctx->state[4] = SHA1_H4;
|
||||
sctx->count = 0;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Copyright IBM Corp. 2005,2007
|
||||
* Author(s): Jan Glauber (jang@de.ibm.com)
|
||||
*
|
||||
* Derived from "crypto/sha256.c"
|
||||
* Derived from "crypto/sha256_generic.c"
|
||||
* and "arch/s390/crypto/sha1_s390.c"
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@ -19,12 +19,10 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <crypto/sha.h>
|
||||
|
||||
#include "crypt_s390.h"
|
||||
|
||||
#define SHA256_DIGEST_SIZE 32
|
||||
#define SHA256_BLOCK_SIZE 64
|
||||
|
||||
struct s390_sha256_ctx {
|
||||
u64 count; /* message length */
|
||||
u32 state[8];
|
||||
@ -35,14 +33,14 @@ static void sha256_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct s390_sha256_ctx *sctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
sctx->state[0] = 0x6a09e667;
|
||||
sctx->state[1] = 0xbb67ae85;
|
||||
sctx->state[2] = 0x3c6ef372;
|
||||
sctx->state[3] = 0xa54ff53a;
|
||||
sctx->state[4] = 0x510e527f;
|
||||
sctx->state[5] = 0x9b05688c;
|
||||
sctx->state[6] = 0x1f83d9ab;
|
||||
sctx->state[7] = 0x5be0cd19;
|
||||
sctx->state[0] = SHA256_H0;
|
||||
sctx->state[1] = SHA256_H1;
|
||||
sctx->state[2] = SHA256_H2;
|
||||
sctx->state[3] = SHA256_H3;
|
||||
sctx->state[4] = SHA256_H4;
|
||||
sctx->state[5] = SHA256_H5;
|
||||
sctx->state[6] = SHA256_H6;
|
||||
sctx->state[7] = SHA256_H7;
|
||||
sctx->count = 0;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,6 @@ asmlinkage void do_softirq(void)
|
||||
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
EXPORT_SYMBOL(do_softirq);
|
||||
|
||||
void init_irq_proc(void)
|
||||
{
|
||||
|
@ -245,7 +245,6 @@ asmlinkage void do_softirq(void)
|
||||
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
EXPORT_SYMBOL(do_softirq);
|
||||
#endif
|
||||
|
||||
void __init init_IRQ(void)
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <linux/compat.h>
|
||||
|
||||
#include <net/sock.h>
|
||||
#include <net/net_namespace.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/termios.h>
|
||||
@ -686,7 +687,7 @@ static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg)
|
||||
int i = 0;
|
||||
|
||||
read_lock_bh(&dev_base_lock);
|
||||
for_each_netdev(d)
|
||||
for_each_netdev(&init_net, d)
|
||||
i++;
|
||||
read_unlock_bh(&dev_base_lock);
|
||||
|
||||
|
@ -231,8 +231,6 @@ asmlinkage void do_softirq(void)
|
||||
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(do_softirq);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -210,4 +210,3 @@ asmlinkage void do_softirq(void)
|
||||
}
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
EXPORT_SYMBOL(do_softirq);
|
||||
|
@ -28,6 +28,10 @@ config CRYPTO_ABLKCIPHER
|
||||
tristate
|
||||
select CRYPTO_BLKCIPHER
|
||||
|
||||
config CRYPTO_AEAD
|
||||
tristate
|
||||
select CRYPTO_ALGAPI
|
||||
|
||||
config CRYPTO_BLKCIPHER
|
||||
tristate
|
||||
select CRYPTO_ALGAPI
|
||||
@ -146,7 +150,6 @@ config CRYPTO_ECB
|
||||
tristate "ECB support"
|
||||
select CRYPTO_BLKCIPHER
|
||||
select CRYPTO_MANAGER
|
||||
default m
|
||||
help
|
||||
ECB: Electronic CodeBook mode
|
||||
This is the simplest block cipher algorithm. It simply encrypts
|
||||
@ -156,7 +159,6 @@ config CRYPTO_CBC
|
||||
tristate "CBC support"
|
||||
select CRYPTO_BLKCIPHER
|
||||
select CRYPTO_MANAGER
|
||||
default m
|
||||
help
|
||||
CBC: Cipher Block Chaining mode
|
||||
This block cipher algorithm is required for IPSec.
|
||||
@ -165,7 +167,6 @@ config CRYPTO_PCBC
|
||||
tristate "PCBC support"
|
||||
select CRYPTO_BLKCIPHER
|
||||
select CRYPTO_MANAGER
|
||||
default m
|
||||
help
|
||||
PCBC: Propagating Cipher Block Chaining mode
|
||||
This block cipher algorithm is required for RxRPC.
|
||||
@ -183,6 +184,17 @@ config CRYPTO_LRW
|
||||
The first 128, 192 or 256 bits in the key are used for AES and the
|
||||
rest is used to tie each cipher block to its logical position.
|
||||
|
||||
config CRYPTO_XTS
|
||||
tristate "XTS support (EXPERIMENTAL)"
|
||||
depends on EXPERIMENTAL
|
||||
select CRYPTO_BLKCIPHER
|
||||
select CRYPTO_MANAGER
|
||||
select CRYPTO_GF128MUL
|
||||
help
|
||||
XTS: IEEE1619/D16 narrow block cipher use with aes-xts-plain,
|
||||
key size 256, 384 or 512 bits. This implementation currently
|
||||
can't handle a sectorsize which is not a multiple of 16 bytes.
|
||||
|
||||
config CRYPTO_CRYPTD
|
||||
tristate "Software async crypto daemon"
|
||||
select CRYPTO_ABLKCIPHER
|
||||
@ -415,6 +427,20 @@ config CRYPTO_ANUBIS
|
||||
<https://www.cosic.esat.kuleuven.ac.be/nessie/reports/>
|
||||
<http://planeta.terra.com.br/informatica/paulobarreto/AnubisPage.html>
|
||||
|
||||
config CRYPTO_SEED
|
||||
tristate "SEED cipher algorithm"
|
||||
select CRYPTO_ALGAPI
|
||||
help
|
||||
SEED cipher algorithm (RFC4269).
|
||||
|
||||
SEED is a 128-bit symmetric key block cipher that has been
|
||||
developed by KISA (Korea Information Security Agency) as a
|
||||
national standard encryption algorithm of the Republic of Korea.
|
||||
It is a 16 round block cipher with the key size of 128 bit.
|
||||
|
||||
See also:
|
||||
<http://www.kisa.or.kr/kisa/seed/jsp/seed_eng.jsp>
|
||||
|
||||
|
||||
config CRYPTO_DEFLATE
|
||||
tristate "Deflate compression algorithm"
|
||||
@ -468,6 +494,14 @@ config CRYPTO_TEST
|
||||
help
|
||||
Quick & dirty crypto test module.
|
||||
|
||||
config CRYPTO_AUTHENC
|
||||
tristate "Authenc support"
|
||||
select CRYPTO_AEAD
|
||||
select CRYPTO_MANAGER
|
||||
help
|
||||
Authenc: Combined mode wrapper for IPsec.
|
||||
This is required for IPSec.
|
||||
|
||||
source "drivers/crypto/Kconfig"
|
||||
|
||||
endif # if CRYPTO
|
||||
|
@ -2,13 +2,14 @@
|
||||
# Cryptographic API
|
||||
#
|
||||
|
||||
obj-$(CONFIG_CRYPTO) += api.o scatterwalk.o cipher.o digest.o compress.o
|
||||
obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o
|
||||
|
||||
crypto_algapi-$(CONFIG_PROC_FS) += proc.o
|
||||
crypto_algapi-objs := algapi.o $(crypto_algapi-y)
|
||||
crypto_algapi-objs := algapi.o scatterwalk.o $(crypto_algapi-y)
|
||||
obj-$(CONFIG_CRYPTO_ALGAPI) += crypto_algapi.o
|
||||
|
||||
obj-$(CONFIG_CRYPTO_ABLKCIPHER) += ablkcipher.o
|
||||
obj-$(CONFIG_CRYPTO_AEAD) += aead.o
|
||||
obj-$(CONFIG_CRYPTO_BLKCIPHER) += blkcipher.o
|
||||
|
||||
crypto_hash-objs := hash.o
|
||||
@ -20,8 +21,8 @@ obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
|
||||
obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
|
||||
obj-$(CONFIG_CRYPTO_MD4) += md4.o
|
||||
obj-$(CONFIG_CRYPTO_MD5) += md5.o
|
||||
obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
|
||||
obj-$(CONFIG_CRYPTO_SHA256) += sha256.o
|
||||
obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o
|
||||
obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o
|
||||
obj-$(CONFIG_CRYPTO_SHA512) += sha512.o
|
||||
obj-$(CONFIG_CRYPTO_WP512) += wp512.o
|
||||
obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
|
||||
@ -30,14 +31,15 @@ obj-$(CONFIG_CRYPTO_ECB) += ecb.o
|
||||
obj-$(CONFIG_CRYPTO_CBC) += cbc.o
|
||||
obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
|
||||
obj-$(CONFIG_CRYPTO_LRW) += lrw.o
|
||||
obj-$(CONFIG_CRYPTO_XTS) += xts.o
|
||||
obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
|
||||
obj-$(CONFIG_CRYPTO_DES) += des.o
|
||||
obj-$(CONFIG_CRYPTO_DES) += des_generic.o
|
||||
obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
|
||||
obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
|
||||
obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
|
||||
obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
|
||||
obj-$(CONFIG_CRYPTO_SERPENT) += serpent.o
|
||||
obj-$(CONFIG_CRYPTO_AES) += aes.o
|
||||
obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
|
||||
obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia.o
|
||||
obj-$(CONFIG_CRYPTO_CAST5) += cast5.o
|
||||
obj-$(CONFIG_CRYPTO_CAST6) += cast6.o
|
||||
@ -45,9 +47,11 @@ obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
|
||||
obj-$(CONFIG_CRYPTO_TEA) += tea.o
|
||||
obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
|
||||
obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
|
||||
obj-$(CONFIG_CRYPTO_SEED) += seed.o
|
||||
obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
|
||||
obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
|
||||
obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o
|
||||
obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o
|
||||
|
||||
obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
|
||||
|
||||
|
@ -16,10 +16,13 @@
|
||||
#include <crypto/algapi.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
static int setkey_unaligned(struct crypto_ablkcipher *tfm, const u8 *key, unsigned int keylen)
|
||||
static int setkey_unaligned(struct crypto_ablkcipher *tfm, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct ablkcipher_alg *cipher = crypto_ablkcipher_alg(tfm);
|
||||
unsigned long alignmask = crypto_ablkcipher_alignmask(tfm);
|
||||
@ -91,10 +94,6 @@ static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg)
|
||||
seq_printf(m, "min keysize : %u\n", ablkcipher->min_keysize);
|
||||
seq_printf(m, "max keysize : %u\n", ablkcipher->max_keysize);
|
||||
seq_printf(m, "ivsize : %u\n", ablkcipher->ivsize);
|
||||
if (ablkcipher->queue) {
|
||||
seq_printf(m, "qlen : %u\n", ablkcipher->queue->qlen);
|
||||
seq_printf(m, "max qlen : %u\n", ablkcipher->queue->max_qlen);
|
||||
}
|
||||
}
|
||||
|
||||
const struct crypto_type crypto_ablkcipher_type = {
|
||||
|
101
crypto/aead.c
Normal file
101
crypto/aead.c
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* AEAD: Authenticated Encryption with Associated Data
|
||||
*
|
||||
* This file provides API support for AEAD algorithms.
|
||||
*
|
||||
* Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
static int setkey_unaligned(struct crypto_aead *tfm, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct aead_alg *aead = crypto_aead_alg(tfm);
|
||||
unsigned long alignmask = crypto_aead_alignmask(tfm);
|
||||
int ret;
|
||||
u8 *buffer, *alignbuffer;
|
||||
unsigned long absize;
|
||||
|
||||
absize = keylen + alignmask;
|
||||
buffer = kmalloc(absize, GFP_ATOMIC);
|
||||
if (!buffer)
|
||||
return -ENOMEM;
|
||||
|
||||
alignbuffer = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
|
||||
memcpy(alignbuffer, key, keylen);
|
||||
ret = aead->setkey(tfm, alignbuffer, keylen);
|
||||
memset(alignbuffer, 0, keylen);
|
||||
kfree(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen)
|
||||
{
|
||||
struct aead_alg *aead = crypto_aead_alg(tfm);
|
||||
unsigned long alignmask = crypto_aead_alignmask(tfm);
|
||||
|
||||
if ((unsigned long)key & alignmask)
|
||||
return setkey_unaligned(tfm, key, keylen);
|
||||
|
||||
return aead->setkey(tfm, key, keylen);
|
||||
}
|
||||
|
||||
static unsigned int crypto_aead_ctxsize(struct crypto_alg *alg, u32 type,
|
||||
u32 mask)
|
||||
{
|
||||
return alg->cra_ctxsize;
|
||||
}
|
||||
|
||||
static int crypto_init_aead_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
|
||||
{
|
||||
struct aead_alg *alg = &tfm->__crt_alg->cra_aead;
|
||||
struct aead_tfm *crt = &tfm->crt_aead;
|
||||
|
||||
if (max(alg->authsize, alg->ivsize) > PAGE_SIZE / 8)
|
||||
return -EINVAL;
|
||||
|
||||
crt->setkey = setkey;
|
||||
crt->encrypt = alg->encrypt;
|
||||
crt->decrypt = alg->decrypt;
|
||||
crt->ivsize = alg->ivsize;
|
||||
crt->authsize = alg->authsize;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg)
|
||||
__attribute__ ((unused));
|
||||
static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg)
|
||||
{
|
||||
struct aead_alg *aead = &alg->cra_aead;
|
||||
|
||||
seq_printf(m, "type : aead\n");
|
||||
seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
|
||||
seq_printf(m, "ivsize : %u\n", aead->ivsize);
|
||||
seq_printf(m, "authsize : %u\n", aead->authsize);
|
||||
}
|
||||
|
||||
const struct crypto_type crypto_aead_type = {
|
||||
.ctxsize = crypto_aead_ctxsize,
|
||||
.init = crypto_init_aead_ops,
|
||||
#ifdef CONFIG_PROC_FS
|
||||
.show = crypto_aead_show,
|
||||
#endif
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(crypto_aead_type);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Authenticated Encryption with Associated Data (AEAD)");
|
@ -453,4 +453,4 @@ module_exit(aes_fini);
|
||||
|
||||
MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
|
||||
MODULE_ALIAS("aes");
|
@ -63,9 +63,6 @@ static int crypto_check_alg(struct crypto_alg *alg)
|
||||
if (alg->cra_alignmask & (alg->cra_alignmask + 1))
|
||||
return -EINVAL;
|
||||
|
||||
if (alg->cra_alignmask & alg->cra_blocksize)
|
||||
return -EINVAL;
|
||||
|
||||
if (alg->cra_blocksize > PAGE_SIZE / 8)
|
||||
return -EINVAL;
|
||||
|
||||
@ -152,6 +149,11 @@ static int __crypto_register_alg(struct crypto_alg *alg,
|
||||
if (crypto_is_larval(q)) {
|
||||
struct crypto_larval *larval = (void *)q;
|
||||
|
||||
/*
|
||||
* Check to see if either our generic name or
|
||||
* specific name can satisfy the name requested
|
||||
* by the larval entry q.
|
||||
*/
|
||||
if (strcmp(alg->cra_name, q->cra_name) &&
|
||||
strcmp(alg->cra_driver_name, q->cra_name))
|
||||
continue;
|
||||
@ -439,13 +441,15 @@ EXPORT_SYMBOL_GPL(crypto_unregister_notifier);
|
||||
|
||||
struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb)
|
||||
{
|
||||
struct rtattr *rta = tb[CRYPTOA_TYPE - 1];
|
||||
struct rtattr *rta = tb[0];
|
||||
struct crypto_attr_type *algt;
|
||||
|
||||
if (!rta)
|
||||
return ERR_PTR(-ENOENT);
|
||||
if (RTA_PAYLOAD(rta) < sizeof(*algt))
|
||||
return ERR_PTR(-EINVAL);
|
||||
if (rta->rta_type != CRYPTOA_TYPE)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
algt = RTA_DATA(rta);
|
||||
|
||||
@ -468,22 +472,41 @@ int crypto_check_attr_type(struct rtattr **tb, u32 type)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_check_attr_type);
|
||||
|
||||
struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, u32 type, u32 mask)
|
||||
struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask)
|
||||
{
|
||||
struct rtattr *rta = tb[CRYPTOA_ALG - 1];
|
||||
struct crypto_attr_alg *alga;
|
||||
|
||||
if (!rta)
|
||||
return ERR_PTR(-ENOENT);
|
||||
if (RTA_PAYLOAD(rta) < sizeof(*alga))
|
||||
return ERR_PTR(-EINVAL);
|
||||
if (rta->rta_type != CRYPTOA_ALG)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
alga = RTA_DATA(rta);
|
||||
alga->name[CRYPTO_MAX_ALG_NAME - 1] = 0;
|
||||
|
||||
return crypto_alg_mod_lookup(alga->name, type, mask);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_get_attr_alg);
|
||||
EXPORT_SYMBOL_GPL(crypto_attr_alg);
|
||||
|
||||
int crypto_attr_u32(struct rtattr *rta, u32 *num)
|
||||
{
|
||||
struct crypto_attr_u32 *nu32;
|
||||
|
||||
if (!rta)
|
||||
return -ENOENT;
|
||||
if (RTA_PAYLOAD(rta) < sizeof(*nu32))
|
||||
return -EINVAL;
|
||||
if (rta->rta_type != CRYPTOA_U32)
|
||||
return -EINVAL;
|
||||
|
||||
nu32 = RTA_DATA(rta);
|
||||
*num = nu32->num;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_attr_u32);
|
||||
|
||||
struct crypto_instance *crypto_alloc_instance(const char *name,
|
||||
struct crypto_alg *alg)
|
||||
|
400
crypto/authenc.c
Normal file
400
crypto/authenc.c
Normal file
@ -0,0 +1,400 @@
|
||||
/*
|
||||
* Authenc: Simple AEAD wrapper for IPsec
|
||||
*
|
||||
* Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
#include "scatterwalk.h"
|
||||
|
||||
struct authenc_instance_ctx {
|
||||
struct crypto_spawn auth;
|
||||
struct crypto_spawn enc;
|
||||
|
||||
unsigned int authsize;
|
||||
unsigned int enckeylen;
|
||||
};
|
||||
|
||||
struct crypto_authenc_ctx {
|
||||
spinlock_t auth_lock;
|
||||
struct crypto_hash *auth;
|
||||
struct crypto_ablkcipher *enc;
|
||||
};
|
||||
|
||||
static int crypto_authenc_setkey(struct crypto_aead *authenc, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct authenc_instance_ctx *ictx =
|
||||
crypto_instance_ctx(crypto_aead_alg_instance(authenc));
|
||||
unsigned int enckeylen = ictx->enckeylen;
|
||||
unsigned int authkeylen;
|
||||
struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc);
|
||||
struct crypto_hash *auth = ctx->auth;
|
||||
struct crypto_ablkcipher *enc = ctx->enc;
|
||||
int err = -EINVAL;
|
||||
|
||||
if (keylen < enckeylen) {
|
||||
crypto_aead_set_flags(authenc, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
||||
goto out;
|
||||
}
|
||||
authkeylen = keylen - enckeylen;
|
||||
|
||||
crypto_hash_clear_flags(auth, CRYPTO_TFM_REQ_MASK);
|
||||
crypto_hash_set_flags(auth, crypto_aead_get_flags(authenc) &
|
||||
CRYPTO_TFM_REQ_MASK);
|
||||
err = crypto_hash_setkey(auth, key, authkeylen);
|
||||
crypto_aead_set_flags(authenc, crypto_hash_get_flags(auth) &
|
||||
CRYPTO_TFM_RES_MASK);
|
||||
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
crypto_ablkcipher_clear_flags(enc, CRYPTO_TFM_REQ_MASK);
|
||||
crypto_ablkcipher_set_flags(enc, crypto_aead_get_flags(authenc) &
|
||||
CRYPTO_TFM_REQ_MASK);
|
||||
err = crypto_ablkcipher_setkey(enc, key + authkeylen, enckeylen);
|
||||
crypto_aead_set_flags(authenc, crypto_ablkcipher_get_flags(enc) &
|
||||
CRYPTO_TFM_RES_MASK);
|
||||
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int crypto_authenc_hash(struct aead_request *req)
|
||||
{
|
||||
struct crypto_aead *authenc = crypto_aead_reqtfm(req);
|
||||
struct authenc_instance_ctx *ictx =
|
||||
crypto_instance_ctx(crypto_aead_alg_instance(authenc));
|
||||
struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc);
|
||||
struct crypto_hash *auth = ctx->auth;
|
||||
struct hash_desc desc = {
|
||||
.tfm = auth,
|
||||
};
|
||||
u8 *hash = aead_request_ctx(req);
|
||||
struct scatterlist *dst;
|
||||
unsigned int cryptlen;
|
||||
int err;
|
||||
|
||||
hash = (u8 *)ALIGN((unsigned long)hash + crypto_hash_alignmask(auth),
|
||||
crypto_hash_alignmask(auth) + 1);
|
||||
|
||||
spin_lock_bh(&ctx->auth_lock);
|
||||
err = crypto_hash_init(&desc);
|
||||
if (err)
|
||||
goto auth_unlock;
|
||||
|
||||
err = crypto_hash_update(&desc, req->assoc, req->assoclen);
|
||||
if (err)
|
||||
goto auth_unlock;
|
||||
|
||||
cryptlen = req->cryptlen;
|
||||
dst = req->dst;
|
||||
err = crypto_hash_update(&desc, dst, cryptlen);
|
||||
if (err)
|
||||
goto auth_unlock;
|
||||
|
||||
err = crypto_hash_final(&desc, hash);
|
||||
auth_unlock:
|
||||
spin_unlock_bh(&ctx->auth_lock);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
scatterwalk_map_and_copy(hash, dst, cryptlen, ictx->authsize, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void crypto_authenc_encrypt_done(struct crypto_async_request *req,
|
||||
int err)
|
||||
{
|
||||
if (!err)
|
||||
err = crypto_authenc_hash(req->data);
|
||||
|
||||
aead_request_complete(req->data, err);
|
||||
}
|
||||
|
||||
static int crypto_authenc_encrypt(struct aead_request *req)
|
||||
{
|
||||
struct crypto_aead *authenc = crypto_aead_reqtfm(req);
|
||||
struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc);
|
||||
struct ablkcipher_request *abreq = aead_request_ctx(req);
|
||||
int err;
|
||||
|
||||
ablkcipher_request_set_tfm(abreq, ctx->enc);
|
||||
ablkcipher_request_set_callback(abreq, aead_request_flags(req),
|
||||
crypto_authenc_encrypt_done, req);
|
||||
ablkcipher_request_set_crypt(abreq, req->src, req->dst, req->cryptlen,
|
||||
req->iv);
|
||||
|
||||
err = crypto_ablkcipher_encrypt(abreq);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return crypto_authenc_hash(req);
|
||||
}
|
||||
|
||||
static int crypto_authenc_verify(struct aead_request *req)
|
||||
{
|
||||
struct crypto_aead *authenc = crypto_aead_reqtfm(req);
|
||||
struct authenc_instance_ctx *ictx =
|
||||
crypto_instance_ctx(crypto_aead_alg_instance(authenc));
|
||||
struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc);
|
||||
struct crypto_hash *auth = ctx->auth;
|
||||
struct hash_desc desc = {
|
||||
.tfm = auth,
|
||||
.flags = aead_request_flags(req),
|
||||
};
|
||||
u8 *ohash = aead_request_ctx(req);
|
||||
u8 *ihash;
|
||||
struct scatterlist *src;
|
||||
unsigned int cryptlen;
|
||||
unsigned int authsize;
|
||||
int err;
|
||||
|
||||
ohash = (u8 *)ALIGN((unsigned long)ohash + crypto_hash_alignmask(auth),
|
||||
crypto_hash_alignmask(auth) + 1);
|
||||
ihash = ohash + crypto_hash_digestsize(auth);
|
||||
|
||||
spin_lock_bh(&ctx->auth_lock);
|
||||
err = crypto_hash_init(&desc);
|
||||
if (err)
|
||||
goto auth_unlock;
|
||||
|
||||
err = crypto_hash_update(&desc, req->assoc, req->assoclen);
|
||||
if (err)
|
||||
goto auth_unlock;
|
||||
|
||||
cryptlen = req->cryptlen;
|
||||
src = req->src;
|
||||
err = crypto_hash_update(&desc, src, cryptlen);
|
||||
if (err)
|
||||
goto auth_unlock;
|
||||
|
||||
err = crypto_hash_final(&desc, ohash);
|
||||
auth_unlock:
|
||||
spin_unlock_bh(&ctx->auth_lock);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
authsize = ictx->authsize;
|
||||
scatterwalk_map_and_copy(ihash, src, cryptlen, authsize, 0);
|
||||
return memcmp(ihash, ohash, authsize) ? -EINVAL : 0;
|
||||
}
|
||||
|
||||
static void crypto_authenc_decrypt_done(struct crypto_async_request *req,
|
||||
int err)
|
||||
{
|
||||
aead_request_complete(req->data, err);
|
||||
}
|
||||
|
||||
static int crypto_authenc_decrypt(struct aead_request *req)
|
||||
{
|
||||
struct crypto_aead *authenc = crypto_aead_reqtfm(req);
|
||||
struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc);
|
||||
struct ablkcipher_request *abreq = aead_request_ctx(req);
|
||||
int err;
|
||||
|
||||
err = crypto_authenc_verify(req);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ablkcipher_request_set_tfm(abreq, ctx->enc);
|
||||
ablkcipher_request_set_callback(abreq, aead_request_flags(req),
|
||||
crypto_authenc_decrypt_done, req);
|
||||
ablkcipher_request_set_crypt(abreq, req->src, req->dst, req->cryptlen,
|
||||
req->iv);
|
||||
|
||||
return crypto_ablkcipher_decrypt(abreq);
|
||||
}
|
||||
|
||||
static int crypto_authenc_init_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct crypto_instance *inst = (void *)tfm->__crt_alg;
|
||||
struct authenc_instance_ctx *ictx = crypto_instance_ctx(inst);
|
||||
struct crypto_authenc_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
struct crypto_hash *auth;
|
||||
struct crypto_ablkcipher *enc;
|
||||
unsigned int digestsize;
|
||||
int err;
|
||||
|
||||
auth = crypto_spawn_hash(&ictx->auth);
|
||||
if (IS_ERR(auth))
|
||||
return PTR_ERR(auth);
|
||||
|
||||
err = -EINVAL;
|
||||
digestsize = crypto_hash_digestsize(auth);
|
||||
if (ictx->authsize > digestsize)
|
||||
goto err_free_hash;
|
||||
|
||||
enc = crypto_spawn_ablkcipher(&ictx->enc);
|
||||
err = PTR_ERR(enc);
|
||||
if (IS_ERR(enc))
|
||||
goto err_free_hash;
|
||||
|
||||
ctx->auth = auth;
|
||||
ctx->enc = enc;
|
||||
tfm->crt_aead.reqsize = max_t(unsigned int,
|
||||
(crypto_hash_alignmask(auth) &
|
||||
~(crypto_tfm_ctx_alignment() - 1)) +
|
||||
digestsize * 2,
|
||||
sizeof(struct ablkcipher_request) +
|
||||
crypto_ablkcipher_reqsize(enc));
|
||||
|
||||
spin_lock_init(&ctx->auth_lock);
|
||||
|
||||
return 0;
|
||||
|
||||
err_free_hash:
|
||||
crypto_free_hash(auth);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void crypto_authenc_exit_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct crypto_authenc_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
crypto_free_hash(ctx->auth);
|
||||
crypto_free_ablkcipher(ctx->enc);
|
||||
}
|
||||
|
||||
static struct crypto_instance *crypto_authenc_alloc(struct rtattr **tb)
|
||||
{
|
||||
struct crypto_instance *inst;
|
||||
struct crypto_alg *auth;
|
||||
struct crypto_alg *enc;
|
||||
struct authenc_instance_ctx *ctx;
|
||||
unsigned int authsize;
|
||||
unsigned int enckeylen;
|
||||
int err;
|
||||
|
||||
err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_AEAD);
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
auth = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_HASH,
|
||||
CRYPTO_ALG_TYPE_HASH_MASK);
|
||||
if (IS_ERR(auth))
|
||||
return ERR_PTR(PTR_ERR(auth));
|
||||
|
||||
err = crypto_attr_u32(tb[2], &authsize);
|
||||
inst = ERR_PTR(err);
|
||||
if (err)
|
||||
goto out_put_auth;
|
||||
|
||||
enc = crypto_attr_alg(tb[3], CRYPTO_ALG_TYPE_BLKCIPHER,
|
||||
CRYPTO_ALG_TYPE_MASK);
|
||||
inst = ERR_PTR(PTR_ERR(enc));
|
||||
if (IS_ERR(enc))
|
||||
goto out_put_auth;
|
||||
|
||||
err = crypto_attr_u32(tb[4], &enckeylen);
|
||||
if (err)
|
||||
goto out_put_enc;
|
||||
|
||||
inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
|
||||
err = -ENOMEM;
|
||||
if (!inst)
|
||||
goto out_put_enc;
|
||||
|
||||
err = -ENAMETOOLONG;
|
||||
if (snprintf(inst->alg.cra_name, CRYPTO_MAX_ALG_NAME,
|
||||
"authenc(%s,%u,%s,%u)", auth->cra_name, authsize,
|
||||
enc->cra_name, enckeylen) >= CRYPTO_MAX_ALG_NAME)
|
||||
goto err_free_inst;
|
||||
|
||||
if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,
|
||||
"authenc(%s,%u,%s,%u)", auth->cra_driver_name,
|
||||
authsize, enc->cra_driver_name, enckeylen) >=
|
||||
CRYPTO_MAX_ALG_NAME)
|
||||
goto err_free_inst;
|
||||
|
||||
ctx = crypto_instance_ctx(inst);
|
||||
ctx->authsize = authsize;
|
||||
ctx->enckeylen = enckeylen;
|
||||
|
||||
err = crypto_init_spawn(&ctx->auth, auth, inst, CRYPTO_ALG_TYPE_MASK);
|
||||
if (err)
|
||||
goto err_free_inst;
|
||||
|
||||
err = crypto_init_spawn(&ctx->enc, enc, inst, CRYPTO_ALG_TYPE_MASK);
|
||||
if (err)
|
||||
goto err_drop_auth;
|
||||
|
||||
inst->alg.cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC;
|
||||
inst->alg.cra_priority = enc->cra_priority * 10 + auth->cra_priority;
|
||||
inst->alg.cra_blocksize = enc->cra_blocksize;
|
||||
inst->alg.cra_alignmask = max(auth->cra_alignmask, enc->cra_alignmask);
|
||||
inst->alg.cra_type = &crypto_aead_type;
|
||||
|
||||
inst->alg.cra_aead.ivsize = enc->cra_blkcipher.ivsize;
|
||||
inst->alg.cra_aead.authsize = authsize;
|
||||
|
||||
inst->alg.cra_ctxsize = sizeof(struct crypto_authenc_ctx);
|
||||
|
||||
inst->alg.cra_init = crypto_authenc_init_tfm;
|
||||
inst->alg.cra_exit = crypto_authenc_exit_tfm;
|
||||
|
||||
inst->alg.cra_aead.setkey = crypto_authenc_setkey;
|
||||
inst->alg.cra_aead.encrypt = crypto_authenc_encrypt;
|
||||
inst->alg.cra_aead.decrypt = crypto_authenc_decrypt;
|
||||
|
||||
out:
|
||||
crypto_mod_put(enc);
|
||||
out_put_auth:
|
||||
crypto_mod_put(auth);
|
||||
return inst;
|
||||
|
||||
err_drop_auth:
|
||||
crypto_drop_spawn(&ctx->auth);
|
||||
err_free_inst:
|
||||
kfree(inst);
|
||||
out_put_enc:
|
||||
inst = ERR_PTR(err);
|
||||
goto out;
|
||||
}
|
||||
|
||||
static void crypto_authenc_free(struct crypto_instance *inst)
|
||||
{
|
||||
struct authenc_instance_ctx *ctx = crypto_instance_ctx(inst);
|
||||
|
||||
crypto_drop_spawn(&ctx->enc);
|
||||
crypto_drop_spawn(&ctx->auth);
|
||||
kfree(inst);
|
||||
}
|
||||
|
||||
static struct crypto_template crypto_authenc_tmpl = {
|
||||
.name = "authenc",
|
||||
.alloc = crypto_authenc_alloc,
|
||||
.free = crypto_authenc_free,
|
||||
.module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int __init crypto_authenc_module_init(void)
|
||||
{
|
||||
return crypto_register_template(&crypto_authenc_tmpl);
|
||||
}
|
||||
|
||||
static void __exit crypto_authenc_module_exit(void)
|
||||
{
|
||||
crypto_unregister_template(&crypto_authenc_tmpl);
|
||||
}
|
||||
|
||||
module_init(crypto_authenc_module_init);
|
||||
module_exit(crypto_authenc_module_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Simple AEAD wrapper for IPsec");
|
@ -65,7 +65,7 @@ static inline void blkcipher_unmap_dst(struct blkcipher_walk *walk)
|
||||
static inline u8 *blkcipher_get_spot(u8 *start, unsigned int len)
|
||||
{
|
||||
u8 *end_page = (u8 *)(((unsigned long)(start + len - 1)) & PAGE_MASK);
|
||||
return start > end_page ? start : end_page;
|
||||
return max(start, end_page);
|
||||
}
|
||||
|
||||
static inline unsigned int blkcipher_done_slow(struct crypto_blkcipher *tfm,
|
||||
@ -84,8 +84,6 @@ static inline unsigned int blkcipher_done_slow(struct crypto_blkcipher *tfm,
|
||||
static inline unsigned int blkcipher_done_fast(struct blkcipher_walk *walk,
|
||||
unsigned int n)
|
||||
{
|
||||
n = walk->nbytes - n;
|
||||
|
||||
if (walk->flags & BLKCIPHER_WALK_COPY) {
|
||||
blkcipher_map_dst(walk);
|
||||
memcpy(walk->dst.virt.addr, walk->page, n);
|
||||
@ -109,13 +107,15 @@ int blkcipher_walk_done(struct blkcipher_desc *desc,
|
||||
unsigned int nbytes = 0;
|
||||
|
||||
if (likely(err >= 0)) {
|
||||
unsigned int bsize = crypto_blkcipher_blocksize(tfm);
|
||||
unsigned int n;
|
||||
unsigned int n = walk->nbytes - err;
|
||||
|
||||
if (likely(!(walk->flags & BLKCIPHER_WALK_SLOW)))
|
||||
n = blkcipher_done_fast(walk, err);
|
||||
else
|
||||
n = blkcipher_done_slow(tfm, walk, bsize);
|
||||
n = blkcipher_done_fast(walk, n);
|
||||
else if (WARN_ON(err)) {
|
||||
err = -EINVAL;
|
||||
goto err;
|
||||
} else
|
||||
n = blkcipher_done_slow(tfm, walk, n);
|
||||
|
||||
nbytes = walk->total - n;
|
||||
err = 0;
|
||||
@ -132,6 +132,7 @@ int blkcipher_walk_done(struct blkcipher_desc *desc,
|
||||
return blkcipher_walk_next(desc, walk);
|
||||
}
|
||||
|
||||
err:
|
||||
if (walk->iv != desc->info)
|
||||
memcpy(desc->info, walk->iv, crypto_blkcipher_ivsize(tfm));
|
||||
if (walk->buffer != walk->page)
|
||||
@ -149,6 +150,7 @@ static inline int blkcipher_next_slow(struct blkcipher_desc *desc,
|
||||
unsigned int alignmask)
|
||||
{
|
||||
unsigned int n;
|
||||
unsigned aligned_bsize = ALIGN(bsize, alignmask + 1);
|
||||
|
||||
if (walk->buffer)
|
||||
goto ok;
|
||||
@ -157,7 +159,7 @@ static inline int blkcipher_next_slow(struct blkcipher_desc *desc,
|
||||
if (walk->buffer)
|
||||
goto ok;
|
||||
|
||||
n = bsize * 3 - (alignmask + 1) +
|
||||
n = aligned_bsize * 3 - (alignmask + 1) +
|
||||
(alignmask & ~(crypto_tfm_ctx_alignment() - 1));
|
||||
walk->buffer = kmalloc(n, GFP_ATOMIC);
|
||||
if (!walk->buffer)
|
||||
@ -167,8 +169,8 @@ ok:
|
||||
walk->dst.virt.addr = (u8 *)ALIGN((unsigned long)walk->buffer,
|
||||
alignmask + 1);
|
||||
walk->dst.virt.addr = blkcipher_get_spot(walk->dst.virt.addr, bsize);
|
||||
walk->src.virt.addr = blkcipher_get_spot(walk->dst.virt.addr + bsize,
|
||||
bsize);
|
||||
walk->src.virt.addr = blkcipher_get_spot(walk->dst.virt.addr +
|
||||
aligned_bsize, bsize);
|
||||
|
||||
scatterwalk_copychunks(walk->src.virt.addr, &walk->in, bsize, 0);
|
||||
|
||||
@ -224,12 +226,12 @@ static int blkcipher_walk_next(struct blkcipher_desc *desc,
|
||||
{
|
||||
struct crypto_blkcipher *tfm = desc->tfm;
|
||||
unsigned int alignmask = crypto_blkcipher_alignmask(tfm);
|
||||
unsigned int bsize = crypto_blkcipher_blocksize(tfm);
|
||||
unsigned int bsize;
|
||||
unsigned int n;
|
||||
int err;
|
||||
|
||||
n = walk->total;
|
||||
if (unlikely(n < bsize)) {
|
||||
if (unlikely(n < crypto_blkcipher_blocksize(tfm))) {
|
||||
desc->flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
|
||||
return blkcipher_walk_done(desc, walk, -EINVAL);
|
||||
}
|
||||
@ -246,6 +248,7 @@ static int blkcipher_walk_next(struct blkcipher_desc *desc,
|
||||
}
|
||||
}
|
||||
|
||||
bsize = min(walk->blocksize, n);
|
||||
n = scatterwalk_clamp(&walk->in, n);
|
||||
n = scatterwalk_clamp(&walk->out, n);
|
||||
|
||||
@ -276,9 +279,11 @@ static inline int blkcipher_copy_iv(struct blkcipher_walk *walk,
|
||||
struct crypto_blkcipher *tfm,
|
||||
unsigned int alignmask)
|
||||
{
|
||||
unsigned bs = crypto_blkcipher_blocksize(tfm);
|
||||
unsigned bs = walk->blocksize;
|
||||
unsigned int ivsize = crypto_blkcipher_ivsize(tfm);
|
||||
unsigned int size = bs * 2 + ivsize + max(bs, ivsize) - (alignmask + 1);
|
||||
unsigned aligned_bs = ALIGN(bs, alignmask + 1);
|
||||
unsigned int size = aligned_bs * 2 + ivsize + max(aligned_bs, ivsize) -
|
||||
(alignmask + 1);
|
||||
u8 *iv;
|
||||
|
||||
size += alignmask & ~(crypto_tfm_ctx_alignment() - 1);
|
||||
@ -287,8 +292,8 @@ static inline int blkcipher_copy_iv(struct blkcipher_walk *walk,
|
||||
return -ENOMEM;
|
||||
|
||||
iv = (u8 *)ALIGN((unsigned long)walk->buffer, alignmask + 1);
|
||||
iv = blkcipher_get_spot(iv, bs) + bs;
|
||||
iv = blkcipher_get_spot(iv, bs) + bs;
|
||||
iv = blkcipher_get_spot(iv, bs) + aligned_bs;
|
||||
iv = blkcipher_get_spot(iv, bs) + aligned_bs;
|
||||
iv = blkcipher_get_spot(iv, ivsize);
|
||||
|
||||
walk->iv = memcpy(iv, walk->iv, ivsize);
|
||||
@ -299,6 +304,7 @@ int blkcipher_walk_virt(struct blkcipher_desc *desc,
|
||||
struct blkcipher_walk *walk)
|
||||
{
|
||||
walk->flags &= ~BLKCIPHER_WALK_PHYS;
|
||||
walk->blocksize = crypto_blkcipher_blocksize(desc->tfm);
|
||||
return blkcipher_walk_first(desc, walk);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blkcipher_walk_virt);
|
||||
@ -307,6 +313,7 @@ int blkcipher_walk_phys(struct blkcipher_desc *desc,
|
||||
struct blkcipher_walk *walk)
|
||||
{
|
||||
walk->flags |= BLKCIPHER_WALK_PHYS;
|
||||
walk->blocksize = crypto_blkcipher_blocksize(desc->tfm);
|
||||
return blkcipher_walk_first(desc, walk);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blkcipher_walk_phys);
|
||||
@ -339,7 +346,18 @@ static int blkcipher_walk_first(struct blkcipher_desc *desc,
|
||||
return blkcipher_walk_next(desc, walk);
|
||||
}
|
||||
|
||||
static int setkey_unaligned(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
|
||||
int blkcipher_walk_virt_block(struct blkcipher_desc *desc,
|
||||
struct blkcipher_walk *walk,
|
||||
unsigned int blocksize)
|
||||
{
|
||||
walk->flags &= ~BLKCIPHER_WALK_PHYS;
|
||||
walk->blocksize = blocksize;
|
||||
return blkcipher_walk_first(desc, walk);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blkcipher_walk_virt_block);
|
||||
|
||||
static int setkey_unaligned(struct crypto_tfm *tfm, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct blkcipher_alg *cipher = &tfm->__crt_alg->cra_blkcipher;
|
||||
unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
|
||||
@ -360,8 +378,7 @@ static int setkey_unaligned(struct crypto_tfm *tfm, const u8 *key, unsigned int
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int setkey(struct crypto_tfm *tfm, const u8 *key,
|
||||
unsigned int keylen)
|
||||
static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
|
||||
{
|
||||
struct blkcipher_alg *cipher = &tfm->__crt_alg->cra_blkcipher;
|
||||
unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
|
||||
|
@ -16,11 +16,12 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include "internal.h"
|
||||
|
||||
static int setkey_unaligned(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
|
||||
static int setkey_unaligned(struct crypto_tfm *tfm, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct cipher_alg *cia = &tfm->__crt_alg->cra_cipher;
|
||||
unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
|
||||
|
@ -131,7 +131,7 @@ static int cryptd_blkcipher_enqueue(struct ablkcipher_request *req,
|
||||
req->base.complete = complete;
|
||||
|
||||
spin_lock_bh(&state->lock);
|
||||
err = ablkcipher_enqueue_request(crypto_ablkcipher_alg(tfm), req);
|
||||
err = ablkcipher_enqueue_request(&state->queue, req);
|
||||
spin_unlock_bh(&state->lock);
|
||||
|
||||
wake_up_process(state->task);
|
||||
@ -173,7 +173,8 @@ static void cryptd_blkcipher_exit_tfm(struct crypto_tfm *tfm)
|
||||
int active;
|
||||
|
||||
mutex_lock(&state->mutex);
|
||||
active = ablkcipher_tfm_in_queue(__crypto_ablkcipher_cast(tfm));
|
||||
active = ablkcipher_tfm_in_queue(&state->queue,
|
||||
__crypto_ablkcipher_cast(tfm));
|
||||
mutex_unlock(&state->mutex);
|
||||
|
||||
BUG_ON(active);
|
||||
@ -251,8 +252,6 @@ static struct crypto_instance *cryptd_alloc_blkcipher(
|
||||
inst->alg.cra_ablkcipher.encrypt = cryptd_blkcipher_encrypt_enqueue;
|
||||
inst->alg.cra_ablkcipher.decrypt = cryptd_blkcipher_decrypt_enqueue;
|
||||
|
||||
inst->alg.cra_ablkcipher.queue = &state->queue;
|
||||
|
||||
out_put_alg:
|
||||
crypto_mod_put(alg);
|
||||
return inst;
|
||||
|
@ -24,22 +24,26 @@
|
||||
#include "internal.h"
|
||||
|
||||
struct cryptomgr_param {
|
||||
struct rtattr *tb[CRYPTOA_MAX];
|
||||
struct rtattr *tb[CRYPTO_MAX_ATTRS + 2];
|
||||
|
||||
struct {
|
||||
struct rtattr attr;
|
||||
struct crypto_attr_type data;
|
||||
} type;
|
||||
|
||||
struct {
|
||||
union {
|
||||
struct rtattr attr;
|
||||
struct crypto_attr_alg data;
|
||||
} alg;
|
||||
|
||||
struct {
|
||||
char name[CRYPTO_MAX_ALG_NAME];
|
||||
} larval;
|
||||
struct {
|
||||
struct rtattr attr;
|
||||
struct crypto_attr_alg data;
|
||||
} alg;
|
||||
struct {
|
||||
struct rtattr attr;
|
||||
struct crypto_attr_u32 data;
|
||||
} nu32;
|
||||
} attrs[CRYPTO_MAX_ATTRS];
|
||||
|
||||
char larval[CRYPTO_MAX_ALG_NAME];
|
||||
char template[CRYPTO_MAX_ALG_NAME];
|
||||
};
|
||||
|
||||
@ -72,7 +76,7 @@ out:
|
||||
module_put_and_exit(0);
|
||||
|
||||
err:
|
||||
crypto_larval_error(param->larval.name, param->type.data.type,
|
||||
crypto_larval_error(param->larval, param->type.data.type,
|
||||
param->type.data.mask);
|
||||
goto out;
|
||||
}
|
||||
@ -84,6 +88,7 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
|
||||
const char *name = larval->alg.cra_name;
|
||||
const char *p;
|
||||
unsigned int len;
|
||||
int i;
|
||||
|
||||
if (!try_module_get(THIS_MODULE))
|
||||
goto err;
|
||||
@ -101,33 +106,74 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
|
||||
|
||||
memcpy(param->template, name, len);
|
||||
|
||||
name = p + 1;
|
||||
len = 0;
|
||||
for (p = name; *p; p++) {
|
||||
for (; isalnum(*p) || *p == '-' || *p == '_' || *p == '('; p++)
|
||||
;
|
||||
i = 0;
|
||||
for (;;) {
|
||||
int notnum = 0;
|
||||
|
||||
if (*p != ')')
|
||||
goto err_free_param;
|
||||
name = ++p;
|
||||
len = 0;
|
||||
|
||||
for (; isalnum(*p) || *p == '-' || *p == '_'; p++)
|
||||
notnum |= !isdigit(*p);
|
||||
|
||||
if (*p == '(') {
|
||||
int recursion = 0;
|
||||
|
||||
for (;;) {
|
||||
if (!*++p)
|
||||
goto err_free_param;
|
||||
if (*p == '(')
|
||||
recursion++;
|
||||
else if (*p == ')' && !recursion--)
|
||||
break;
|
||||
}
|
||||
|
||||
notnum = 1;
|
||||
p++;
|
||||
}
|
||||
|
||||
len = p - name;
|
||||
if (!len)
|
||||
goto err_free_param;
|
||||
|
||||
if (notnum) {
|
||||
param->attrs[i].alg.attr.rta_len =
|
||||
sizeof(param->attrs[i].alg);
|
||||
param->attrs[i].alg.attr.rta_type = CRYPTOA_ALG;
|
||||
memcpy(param->attrs[i].alg.data.name, name, len);
|
||||
} else {
|
||||
param->attrs[i].nu32.attr.rta_len =
|
||||
sizeof(param->attrs[i].nu32);
|
||||
param->attrs[i].nu32.attr.rta_type = CRYPTOA_U32;
|
||||
param->attrs[i].nu32.data.num =
|
||||
simple_strtol(name, NULL, 0);
|
||||
}
|
||||
|
||||
param->tb[i + 1] = ¶m->attrs[i].attr;
|
||||
i++;
|
||||
|
||||
if (i >= CRYPTO_MAX_ATTRS)
|
||||
goto err_free_param;
|
||||
|
||||
if (*p == ')')
|
||||
break;
|
||||
|
||||
if (*p != ',')
|
||||
goto err_free_param;
|
||||
}
|
||||
|
||||
if (!len || name[len + 1])
|
||||
if (!i)
|
||||
goto err_free_param;
|
||||
|
||||
param->tb[i + 1] = NULL;
|
||||
|
||||
param->type.attr.rta_len = sizeof(param->type);
|
||||
param->type.attr.rta_type = CRYPTOA_TYPE;
|
||||
param->type.data.type = larval->alg.cra_flags;
|
||||
param->type.data.mask = larval->mask;
|
||||
param->tb[CRYPTOA_TYPE - 1] = ¶m->type.attr;
|
||||
param->tb[0] = ¶m->type.attr;
|
||||
|
||||
param->alg.attr.rta_len = sizeof(param->alg);
|
||||
param->alg.attr.rta_type = CRYPTOA_ALG;
|
||||
memcpy(param->alg.data.name, name, len);
|
||||
param->tb[CRYPTOA_ALG - 1] = ¶m->alg.attr;
|
||||
|
||||
memcpy(param->larval.name, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME);
|
||||
memcpy(param->larval, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME);
|
||||
|
||||
thread = kthread_run(cryptomgr_probe, param, "cryptomgr");
|
||||
if (IS_ERR(thread))
|
||||
|
@ -1009,3 +1009,4 @@ module_exit(fini);
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("DES & Triple DES EDE Cipher Algorithms");
|
||||
MODULE_AUTHOR("Dag Arne Osvik <da@osvik.no>");
|
||||
MODULE_ALIAS("des");
|
@ -142,6 +142,17 @@ static void gf128mul_x_bbe(be128 *r, const be128 *x)
|
||||
r->b = cpu_to_be64((b << 1) ^ _tt);
|
||||
}
|
||||
|
||||
void gf128mul_x_ble(be128 *r, const be128 *x)
|
||||
{
|
||||
u64 a = le64_to_cpu(x->a);
|
||||
u64 b = le64_to_cpu(x->b);
|
||||
u64 _tt = gf128mul_table_bbe[b >> 63];
|
||||
|
||||
r->a = cpu_to_le64((a << 1) ^ _tt);
|
||||
r->b = cpu_to_le64((b << 1) | (a >> 63));
|
||||
}
|
||||
EXPORT_SYMBOL(gf128mul_x_ble);
|
||||
|
||||
static void gf128mul_x8_lle(be128 *x)
|
||||
{
|
||||
u64 a = be64_to_cpu(x->a);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <linux/errno.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
#include "internal.h"
|
||||
@ -46,7 +47,7 @@ static int hash_setkey_unaligned(struct crypto_hash *crt, const u8 *key,
|
||||
}
|
||||
|
||||
static int hash_setkey(struct crypto_hash *crt, const u8 *key,
|
||||
unsigned int keylen)
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct crypto_tfm *tfm = crypto_hash_tfm(crt);
|
||||
struct hash_alg *alg = &tfm->__crt_alg->cra_hash;
|
||||
|
@ -50,11 +50,16 @@ extern struct list_head crypto_alg_list;
|
||||
extern struct rw_semaphore crypto_alg_sem;
|
||||
extern struct blocking_notifier_head crypto_chain;
|
||||
|
||||
extern enum km_type crypto_km_types[];
|
||||
|
||||
static inline enum km_type crypto_kmap_type(int out)
|
||||
{
|
||||
return crypto_km_types[(in_softirq() ? 2 : 0) + out];
|
||||
enum km_type type;
|
||||
|
||||
if (in_softirq())
|
||||
type = out * (KM_SOFTIRQ1 - KM_SOFTIRQ0) + KM_SOFTIRQ0;
|
||||
else
|
||||
type = out * (KM_USER1 - KM_USER0) + KM_USER0;
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static inline void *crypto_kmap(struct page *page, int out)
|
||||
|
@ -23,14 +23,6 @@
|
||||
#include "internal.h"
|
||||
#include "scatterwalk.h"
|
||||
|
||||
enum km_type crypto_km_types[] = {
|
||||
KM_USER0,
|
||||
KM_USER1,
|
||||
KM_SOFTIRQ0,
|
||||
KM_SOFTIRQ1,
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(crypto_km_types);
|
||||
|
||||
static inline void memcpy_dir(void *buf, void *sgdata, size_t nbytes, int out)
|
||||
{
|
||||
void *src = out ? buf : sgdata;
|
||||
@ -107,3 +99,25 @@ void scatterwalk_copychunks(void *buf, struct scatter_walk *walk,
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(scatterwalk_copychunks);
|
||||
|
||||
void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
|
||||
unsigned int start, unsigned int nbytes, int out)
|
||||
{
|
||||
struct scatter_walk walk;
|
||||
unsigned int offset = 0;
|
||||
|
||||
for (;;) {
|
||||
scatterwalk_start(&walk, sg);
|
||||
|
||||
if (start < offset + sg->length)
|
||||
break;
|
||||
|
||||
offset += sg->length;
|
||||
sg = sg_next(sg);
|
||||
}
|
||||
|
||||
scatterwalk_advance(&walk, start - offset);
|
||||
scatterwalk_copychunks(buf, &walk, nbytes, out);
|
||||
scatterwalk_done(&walk, out, 0);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(scatterwalk_map_and_copy);
|
||||
|
@ -74,4 +74,7 @@ void scatterwalk_copychunks(void *buf, struct scatter_walk *walk,
|
||||
void *scatterwalk_map(struct scatter_walk *walk, int out);
|
||||
void scatterwalk_done(struct scatter_walk *walk, int out, int more);
|
||||
|
||||
void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
|
||||
unsigned int start, unsigned int nbytes, int out);
|
||||
|
||||
#endif /* _CRYPTO_SCATTERWALK_H */
|
||||
|
479
crypto/seed.c
Normal file
479
crypto/seed.c
Normal file
@ -0,0 +1,479 @@
|
||||
/*
|
||||
* Cryptographic API.
|
||||
*
|
||||
* SEED Cipher Algorithm.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Documentation of SEED can be found in RFC 4269.
|
||||
* Copyright (C) 2007 Korea Information Security Agency (KISA).
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#define SEED_NUM_KCONSTANTS 16
|
||||
#define SEED_KEY_SIZE 16
|
||||
#define SEED_BLOCK_SIZE 16
|
||||
#define SEED_KEYSCHED_LEN 32
|
||||
|
||||
/*
|
||||
* #define byte(x, nr) ((unsigned char)((x) >> (nr*8)))
|
||||
*/
|
||||
static inline u8
|
||||
byte(const u32 x, const unsigned n)
|
||||
{
|
||||
return x >> (n << 3);
|
||||
}
|
||||
|
||||
struct seed_ctx {
|
||||
u32 keysched[SEED_KEYSCHED_LEN];
|
||||
};
|
||||
|
||||
static const u32 SS0[256] = {
|
||||
0x2989a1a8, 0x05858184, 0x16c6d2d4, 0x13c3d3d0,
|
||||
0x14445054, 0x1d0d111c, 0x2c8ca0ac, 0x25052124,
|
||||
0x1d4d515c, 0x03434340, 0x18081018, 0x1e0e121c,
|
||||
0x11415150, 0x3cccf0fc, 0x0acac2c8, 0x23436360,
|
||||
0x28082028, 0x04444044, 0x20002020, 0x1d8d919c,
|
||||
0x20c0e0e0, 0x22c2e2e0, 0x08c8c0c8, 0x17071314,
|
||||
0x2585a1a4, 0x0f8f838c, 0x03030300, 0x3b4b7378,
|
||||
0x3b8bb3b8, 0x13031310, 0x12c2d2d0, 0x2ecee2ec,
|
||||
0x30407070, 0x0c8c808c, 0x3f0f333c, 0x2888a0a8,
|
||||
0x32023230, 0x1dcdd1dc, 0x36c6f2f4, 0x34447074,
|
||||
0x2ccce0ec, 0x15859194, 0x0b0b0308, 0x17475354,
|
||||
0x1c4c505c, 0x1b4b5358, 0x3d8db1bc, 0x01010100,
|
||||
0x24042024, 0x1c0c101c, 0x33437370, 0x18889098,
|
||||
0x10001010, 0x0cccc0cc, 0x32c2f2f0, 0x19c9d1d8,
|
||||
0x2c0c202c, 0x27c7e3e4, 0x32427270, 0x03838380,
|
||||
0x1b8b9398, 0x11c1d1d0, 0x06868284, 0x09c9c1c8,
|
||||
0x20406060, 0x10405050, 0x2383a3a0, 0x2bcbe3e8,
|
||||
0x0d0d010c, 0x3686b2b4, 0x1e8e929c, 0x0f4f434c,
|
||||
0x3787b3b4, 0x1a4a5258, 0x06c6c2c4, 0x38487078,
|
||||
0x2686a2a4, 0x12021210, 0x2f8fa3ac, 0x15c5d1d4,
|
||||
0x21416160, 0x03c3c3c0, 0x3484b0b4, 0x01414140,
|
||||
0x12425250, 0x3d4d717c, 0x0d8d818c, 0x08080008,
|
||||
0x1f0f131c, 0x19899198, 0x00000000, 0x19091118,
|
||||
0x04040004, 0x13435350, 0x37c7f3f4, 0x21c1e1e0,
|
||||
0x3dcdf1fc, 0x36467274, 0x2f0f232c, 0x27072324,
|
||||
0x3080b0b0, 0x0b8b8388, 0x0e0e020c, 0x2b8ba3a8,
|
||||
0x2282a2a0, 0x2e4e626c, 0x13839390, 0x0d4d414c,
|
||||
0x29496168, 0x3c4c707c, 0x09090108, 0x0a0a0208,
|
||||
0x3f8fb3bc, 0x2fcfe3ec, 0x33c3f3f0, 0x05c5c1c4,
|
||||
0x07878384, 0x14041014, 0x3ecef2fc, 0x24446064,
|
||||
0x1eced2dc, 0x2e0e222c, 0x0b4b4348, 0x1a0a1218,
|
||||
0x06060204, 0x21012120, 0x2b4b6368, 0x26466264,
|
||||
0x02020200, 0x35c5f1f4, 0x12829290, 0x0a8a8288,
|
||||
0x0c0c000c, 0x3383b3b0, 0x3e4e727c, 0x10c0d0d0,
|
||||
0x3a4a7278, 0x07474344, 0x16869294, 0x25c5e1e4,
|
||||
0x26062224, 0x00808080, 0x2d8da1ac, 0x1fcfd3dc,
|
||||
0x2181a1a0, 0x30003030, 0x37073334, 0x2e8ea2ac,
|
||||
0x36063234, 0x15051114, 0x22022220, 0x38083038,
|
||||
0x34c4f0f4, 0x2787a3a4, 0x05454144, 0x0c4c404c,
|
||||
0x01818180, 0x29c9e1e8, 0x04848084, 0x17879394,
|
||||
0x35053134, 0x0bcbc3c8, 0x0ecec2cc, 0x3c0c303c,
|
||||
0x31417170, 0x11011110, 0x07c7c3c4, 0x09898188,
|
||||
0x35457174, 0x3bcbf3f8, 0x1acad2d8, 0x38c8f0f8,
|
||||
0x14849094, 0x19495158, 0x02828280, 0x04c4c0c4,
|
||||
0x3fcff3fc, 0x09494148, 0x39093138, 0x27476364,
|
||||
0x00c0c0c0, 0x0fcfc3cc, 0x17c7d3d4, 0x3888b0b8,
|
||||
0x0f0f030c, 0x0e8e828c, 0x02424240, 0x23032320,
|
||||
0x11819190, 0x2c4c606c, 0x1bcbd3d8, 0x2484a0a4,
|
||||
0x34043034, 0x31c1f1f0, 0x08484048, 0x02c2c2c0,
|
||||
0x2f4f636c, 0x3d0d313c, 0x2d0d212c, 0x00404040,
|
||||
0x3e8eb2bc, 0x3e0e323c, 0x3c8cb0bc, 0x01c1c1c0,
|
||||
0x2a8aa2a8, 0x3a8ab2b8, 0x0e4e424c, 0x15455154,
|
||||
0x3b0b3338, 0x1cccd0dc, 0x28486068, 0x3f4f737c,
|
||||
0x1c8c909c, 0x18c8d0d8, 0x0a4a4248, 0x16465254,
|
||||
0x37477374, 0x2080a0a0, 0x2dcde1ec, 0x06464244,
|
||||
0x3585b1b4, 0x2b0b2328, 0x25456164, 0x3acaf2f8,
|
||||
0x23c3e3e0, 0x3989b1b8, 0x3181b1b0, 0x1f8f939c,
|
||||
0x1e4e525c, 0x39c9f1f8, 0x26c6e2e4, 0x3282b2b0,
|
||||
0x31013130, 0x2acae2e8, 0x2d4d616c, 0x1f4f535c,
|
||||
0x24c4e0e4, 0x30c0f0f0, 0x0dcdc1cc, 0x08888088,
|
||||
0x16061214, 0x3a0a3238, 0x18485058, 0x14c4d0d4,
|
||||
0x22426260, 0x29092128, 0x07070304, 0x33033330,
|
||||
0x28c8e0e8, 0x1b0b1318, 0x05050104, 0x39497178,
|
||||
0x10809090, 0x2a4a6268, 0x2a0a2228, 0x1a8a9298,
|
||||
};
|
||||
|
||||
static const u32 SS1[256] = {
|
||||
0x38380830, 0xe828c8e0, 0x2c2d0d21, 0xa42686a2,
|
||||
0xcc0fcfc3, 0xdc1eced2, 0xb03383b3, 0xb83888b0,
|
||||
0xac2f8fa3, 0x60204060, 0x54154551, 0xc407c7c3,
|
||||
0x44044440, 0x6c2f4f63, 0x682b4b63, 0x581b4b53,
|
||||
0xc003c3c3, 0x60224262, 0x30330333, 0xb43585b1,
|
||||
0x28290921, 0xa02080a0, 0xe022c2e2, 0xa42787a3,
|
||||
0xd013c3d3, 0x90118191, 0x10110111, 0x04060602,
|
||||
0x1c1c0c10, 0xbc3c8cb0, 0x34360632, 0x480b4b43,
|
||||
0xec2fcfe3, 0x88088880, 0x6c2c4c60, 0xa82888a0,
|
||||
0x14170713, 0xc404c4c0, 0x14160612, 0xf434c4f0,
|
||||
0xc002c2c2, 0x44054541, 0xe021c1e1, 0xd416c6d2,
|
||||
0x3c3f0f33, 0x3c3d0d31, 0x8c0e8e82, 0x98188890,
|
||||
0x28280820, 0x4c0e4e42, 0xf436c6f2, 0x3c3e0e32,
|
||||
0xa42585a1, 0xf839c9f1, 0x0c0d0d01, 0xdc1fcfd3,
|
||||
0xd818c8d0, 0x282b0b23, 0x64264662, 0x783a4a72,
|
||||
0x24270723, 0x2c2f0f23, 0xf031c1f1, 0x70324272,
|
||||
0x40024242, 0xd414c4d0, 0x40014141, 0xc000c0c0,
|
||||
0x70334373, 0x64274763, 0xac2c8ca0, 0x880b8b83,
|
||||
0xf437c7f3, 0xac2d8da1, 0x80008080, 0x1c1f0f13,
|
||||
0xc80acac2, 0x2c2c0c20, 0xa82a8aa2, 0x34340430,
|
||||
0xd012c2d2, 0x080b0b03, 0xec2ecee2, 0xe829c9e1,
|
||||
0x5c1d4d51, 0x94148490, 0x18180810, 0xf838c8f0,
|
||||
0x54174753, 0xac2e8ea2, 0x08080800, 0xc405c5c1,
|
||||
0x10130313, 0xcc0dcdc1, 0x84068682, 0xb83989b1,
|
||||
0xfc3fcff3, 0x7c3d4d71, 0xc001c1c1, 0x30310131,
|
||||
0xf435c5f1, 0x880a8a82, 0x682a4a62, 0xb03181b1,
|
||||
0xd011c1d1, 0x20200020, 0xd417c7d3, 0x00020202,
|
||||
0x20220222, 0x04040400, 0x68284860, 0x70314171,
|
||||
0x04070703, 0xd81bcbd3, 0x9c1d8d91, 0x98198991,
|
||||
0x60214161, 0xbc3e8eb2, 0xe426c6e2, 0x58194951,
|
||||
0xdc1dcdd1, 0x50114151, 0x90108090, 0xdc1cccd0,
|
||||
0x981a8a92, 0xa02383a3, 0xa82b8ba3, 0xd010c0d0,
|
||||
0x80018181, 0x0c0f0f03, 0x44074743, 0x181a0a12,
|
||||
0xe023c3e3, 0xec2ccce0, 0x8c0d8d81, 0xbc3f8fb3,
|
||||
0x94168692, 0x783b4b73, 0x5c1c4c50, 0xa02282a2,
|
||||
0xa02181a1, 0x60234363, 0x20230323, 0x4c0d4d41,
|
||||
0xc808c8c0, 0x9c1e8e92, 0x9c1c8c90, 0x383a0a32,
|
||||
0x0c0c0c00, 0x2c2e0e22, 0xb83a8ab2, 0x6c2e4e62,
|
||||
0x9c1f8f93, 0x581a4a52, 0xf032c2f2, 0x90128292,
|
||||
0xf033c3f3, 0x48094941, 0x78384870, 0xcc0cccc0,
|
||||
0x14150511, 0xf83bcbf3, 0x70304070, 0x74354571,
|
||||
0x7c3f4f73, 0x34350531, 0x10100010, 0x00030303,
|
||||
0x64244460, 0x6c2d4d61, 0xc406c6c2, 0x74344470,
|
||||
0xd415c5d1, 0xb43484b0, 0xe82acae2, 0x08090901,
|
||||
0x74364672, 0x18190911, 0xfc3ecef2, 0x40004040,
|
||||
0x10120212, 0xe020c0e0, 0xbc3d8db1, 0x04050501,
|
||||
0xf83acaf2, 0x00010101, 0xf030c0f0, 0x282a0a22,
|
||||
0x5c1e4e52, 0xa82989a1, 0x54164652, 0x40034343,
|
||||
0x84058581, 0x14140410, 0x88098981, 0x981b8b93,
|
||||
0xb03080b0, 0xe425c5e1, 0x48084840, 0x78394971,
|
||||
0x94178793, 0xfc3cccf0, 0x1c1e0e12, 0x80028282,
|
||||
0x20210121, 0x8c0c8c80, 0x181b0b13, 0x5c1f4f53,
|
||||
0x74374773, 0x54144450, 0xb03282b2, 0x1c1d0d11,
|
||||
0x24250521, 0x4c0f4f43, 0x00000000, 0x44064642,
|
||||
0xec2dcde1, 0x58184850, 0x50124252, 0xe82bcbe3,
|
||||
0x7c3e4e72, 0xd81acad2, 0xc809c9c1, 0xfc3dcdf1,
|
||||
0x30300030, 0x94158591, 0x64254561, 0x3c3c0c30,
|
||||
0xb43686b2, 0xe424c4e0, 0xb83b8bb3, 0x7c3c4c70,
|
||||
0x0c0e0e02, 0x50104050, 0x38390931, 0x24260622,
|
||||
0x30320232, 0x84048480, 0x68294961, 0x90138393,
|
||||
0x34370733, 0xe427c7e3, 0x24240420, 0xa42484a0,
|
||||
0xc80bcbc3, 0x50134353, 0x080a0a02, 0x84078783,
|
||||
0xd819c9d1, 0x4c0c4c40, 0x80038383, 0x8c0f8f83,
|
||||
0xcc0ecec2, 0x383b0b33, 0x480a4a42, 0xb43787b3,
|
||||
};
|
||||
|
||||
static const u32 SS2[256] = {
|
||||
0xa1a82989, 0x81840585, 0xd2d416c6, 0xd3d013c3,
|
||||
0x50541444, 0x111c1d0d, 0xa0ac2c8c, 0x21242505,
|
||||
0x515c1d4d, 0x43400343, 0x10181808, 0x121c1e0e,
|
||||
0x51501141, 0xf0fc3ccc, 0xc2c80aca, 0x63602343,
|
||||
0x20282808, 0x40440444, 0x20202000, 0x919c1d8d,
|
||||
0xe0e020c0, 0xe2e022c2, 0xc0c808c8, 0x13141707,
|
||||
0xa1a42585, 0x838c0f8f, 0x03000303, 0x73783b4b,
|
||||
0xb3b83b8b, 0x13101303, 0xd2d012c2, 0xe2ec2ece,
|
||||
0x70703040, 0x808c0c8c, 0x333c3f0f, 0xa0a82888,
|
||||
0x32303202, 0xd1dc1dcd, 0xf2f436c6, 0x70743444,
|
||||
0xe0ec2ccc, 0x91941585, 0x03080b0b, 0x53541747,
|
||||
0x505c1c4c, 0x53581b4b, 0xb1bc3d8d, 0x01000101,
|
||||
0x20242404, 0x101c1c0c, 0x73703343, 0x90981888,
|
||||
0x10101000, 0xc0cc0ccc, 0xf2f032c2, 0xd1d819c9,
|
||||
0x202c2c0c, 0xe3e427c7, 0x72703242, 0x83800383,
|
||||
0x93981b8b, 0xd1d011c1, 0x82840686, 0xc1c809c9,
|
||||
0x60602040, 0x50501040, 0xa3a02383, 0xe3e82bcb,
|
||||
0x010c0d0d, 0xb2b43686, 0x929c1e8e, 0x434c0f4f,
|
||||
0xb3b43787, 0x52581a4a, 0xc2c406c6, 0x70783848,
|
||||
0xa2a42686, 0x12101202, 0xa3ac2f8f, 0xd1d415c5,
|
||||
0x61602141, 0xc3c003c3, 0xb0b43484, 0x41400141,
|
||||
0x52501242, 0x717c3d4d, 0x818c0d8d, 0x00080808,
|
||||
0x131c1f0f, 0x91981989, 0x00000000, 0x11181909,
|
||||
0x00040404, 0x53501343, 0xf3f437c7, 0xe1e021c1,
|
||||
0xf1fc3dcd, 0x72743646, 0x232c2f0f, 0x23242707,
|
||||
0xb0b03080, 0x83880b8b, 0x020c0e0e, 0xa3a82b8b,
|
||||
0xa2a02282, 0x626c2e4e, 0x93901383, 0x414c0d4d,
|
||||
0x61682949, 0x707c3c4c, 0x01080909, 0x02080a0a,
|
||||
0xb3bc3f8f, 0xe3ec2fcf, 0xf3f033c3, 0xc1c405c5,
|
||||
0x83840787, 0x10141404, 0xf2fc3ece, 0x60642444,
|
||||
0xd2dc1ece, 0x222c2e0e, 0x43480b4b, 0x12181a0a,
|
||||
0x02040606, 0x21202101, 0x63682b4b, 0x62642646,
|
||||
0x02000202, 0xf1f435c5, 0x92901282, 0x82880a8a,
|
||||
0x000c0c0c, 0xb3b03383, 0x727c3e4e, 0xd0d010c0,
|
||||
0x72783a4a, 0x43440747, 0x92941686, 0xe1e425c5,
|
||||
0x22242606, 0x80800080, 0xa1ac2d8d, 0xd3dc1fcf,
|
||||
0xa1a02181, 0x30303000, 0x33343707, 0xa2ac2e8e,
|
||||
0x32343606, 0x11141505, 0x22202202, 0x30383808,
|
||||
0xf0f434c4, 0xa3a42787, 0x41440545, 0x404c0c4c,
|
||||
0x81800181, 0xe1e829c9, 0x80840484, 0x93941787,
|
||||
0x31343505, 0xc3c80bcb, 0xc2cc0ece, 0x303c3c0c,
|
||||
0x71703141, 0x11101101, 0xc3c407c7, 0x81880989,
|
||||
0x71743545, 0xf3f83bcb, 0xd2d81aca, 0xf0f838c8,
|
||||
0x90941484, 0x51581949, 0x82800282, 0xc0c404c4,
|
||||
0xf3fc3fcf, 0x41480949, 0x31383909, 0x63642747,
|
||||
0xc0c000c0, 0xc3cc0fcf, 0xd3d417c7, 0xb0b83888,
|
||||
0x030c0f0f, 0x828c0e8e, 0x42400242, 0x23202303,
|
||||
0x91901181, 0x606c2c4c, 0xd3d81bcb, 0xa0a42484,
|
||||
0x30343404, 0xf1f031c1, 0x40480848, 0xc2c002c2,
|
||||
0x636c2f4f, 0x313c3d0d, 0x212c2d0d, 0x40400040,
|
||||
0xb2bc3e8e, 0x323c3e0e, 0xb0bc3c8c, 0xc1c001c1,
|
||||
0xa2a82a8a, 0xb2b83a8a, 0x424c0e4e, 0x51541545,
|
||||
0x33383b0b, 0xd0dc1ccc, 0x60682848, 0x737c3f4f,
|
||||
0x909c1c8c, 0xd0d818c8, 0x42480a4a, 0x52541646,
|
||||
0x73743747, 0xa0a02080, 0xe1ec2dcd, 0x42440646,
|
||||
0xb1b43585, 0x23282b0b, 0x61642545, 0xf2f83aca,
|
||||
0xe3e023c3, 0xb1b83989, 0xb1b03181, 0x939c1f8f,
|
||||
0x525c1e4e, 0xf1f839c9, 0xe2e426c6, 0xb2b03282,
|
||||
0x31303101, 0xe2e82aca, 0x616c2d4d, 0x535c1f4f,
|
||||
0xe0e424c4, 0xf0f030c0, 0xc1cc0dcd, 0x80880888,
|
||||
0x12141606, 0x32383a0a, 0x50581848, 0xd0d414c4,
|
||||
0x62602242, 0x21282909, 0x03040707, 0x33303303,
|
||||
0xe0e828c8, 0x13181b0b, 0x01040505, 0x71783949,
|
||||
0x90901080, 0x62682a4a, 0x22282a0a, 0x92981a8a,
|
||||
};
|
||||
|
||||
static const u32 SS3[256] = {
|
||||
0x08303838, 0xc8e0e828, 0x0d212c2d, 0x86a2a426,
|
||||
0xcfc3cc0f, 0xced2dc1e, 0x83b3b033, 0x88b0b838,
|
||||
0x8fa3ac2f, 0x40606020, 0x45515415, 0xc7c3c407,
|
||||
0x44404404, 0x4f636c2f, 0x4b63682b, 0x4b53581b,
|
||||
0xc3c3c003, 0x42626022, 0x03333033, 0x85b1b435,
|
||||
0x09212829, 0x80a0a020, 0xc2e2e022, 0x87a3a427,
|
||||
0xc3d3d013, 0x81919011, 0x01111011, 0x06020406,
|
||||
0x0c101c1c, 0x8cb0bc3c, 0x06323436, 0x4b43480b,
|
||||
0xcfe3ec2f, 0x88808808, 0x4c606c2c, 0x88a0a828,
|
||||
0x07131417, 0xc4c0c404, 0x06121416, 0xc4f0f434,
|
||||
0xc2c2c002, 0x45414405, 0xc1e1e021, 0xc6d2d416,
|
||||
0x0f333c3f, 0x0d313c3d, 0x8e828c0e, 0x88909818,
|
||||
0x08202828, 0x4e424c0e, 0xc6f2f436, 0x0e323c3e,
|
||||
0x85a1a425, 0xc9f1f839, 0x0d010c0d, 0xcfd3dc1f,
|
||||
0xc8d0d818, 0x0b23282b, 0x46626426, 0x4a72783a,
|
||||
0x07232427, 0x0f232c2f, 0xc1f1f031, 0x42727032,
|
||||
0x42424002, 0xc4d0d414, 0x41414001, 0xc0c0c000,
|
||||
0x43737033, 0x47636427, 0x8ca0ac2c, 0x8b83880b,
|
||||
0xc7f3f437, 0x8da1ac2d, 0x80808000, 0x0f131c1f,
|
||||
0xcac2c80a, 0x0c202c2c, 0x8aa2a82a, 0x04303434,
|
||||
0xc2d2d012, 0x0b03080b, 0xcee2ec2e, 0xc9e1e829,
|
||||
0x4d515c1d, 0x84909414, 0x08101818, 0xc8f0f838,
|
||||
0x47535417, 0x8ea2ac2e, 0x08000808, 0xc5c1c405,
|
||||
0x03131013, 0xcdc1cc0d, 0x86828406, 0x89b1b839,
|
||||
0xcff3fc3f, 0x4d717c3d, 0xc1c1c001, 0x01313031,
|
||||
0xc5f1f435, 0x8a82880a, 0x4a62682a, 0x81b1b031,
|
||||
0xc1d1d011, 0x00202020, 0xc7d3d417, 0x02020002,
|
||||
0x02222022, 0x04000404, 0x48606828, 0x41717031,
|
||||
0x07030407, 0xcbd3d81b, 0x8d919c1d, 0x89919819,
|
||||
0x41616021, 0x8eb2bc3e, 0xc6e2e426, 0x49515819,
|
||||
0xcdd1dc1d, 0x41515011, 0x80909010, 0xccd0dc1c,
|
||||
0x8a92981a, 0x83a3a023, 0x8ba3a82b, 0xc0d0d010,
|
||||
0x81818001, 0x0f030c0f, 0x47434407, 0x0a12181a,
|
||||
0xc3e3e023, 0xcce0ec2c, 0x8d818c0d, 0x8fb3bc3f,
|
||||
0x86929416, 0x4b73783b, 0x4c505c1c, 0x82a2a022,
|
||||
0x81a1a021, 0x43636023, 0x03232023, 0x4d414c0d,
|
||||
0xc8c0c808, 0x8e929c1e, 0x8c909c1c, 0x0a32383a,
|
||||
0x0c000c0c, 0x0e222c2e, 0x8ab2b83a, 0x4e626c2e,
|
||||
0x8f939c1f, 0x4a52581a, 0xc2f2f032, 0x82929012,
|
||||
0xc3f3f033, 0x49414809, 0x48707838, 0xccc0cc0c,
|
||||
0x05111415, 0xcbf3f83b, 0x40707030, 0x45717435,
|
||||
0x4f737c3f, 0x05313435, 0x00101010, 0x03030003,
|
||||
0x44606424, 0x4d616c2d, 0xc6c2c406, 0x44707434,
|
||||
0xc5d1d415, 0x84b0b434, 0xcae2e82a, 0x09010809,
|
||||
0x46727436, 0x09111819, 0xcef2fc3e, 0x40404000,
|
||||
0x02121012, 0xc0e0e020, 0x8db1bc3d, 0x05010405,
|
||||
0xcaf2f83a, 0x01010001, 0xc0f0f030, 0x0a22282a,
|
||||
0x4e525c1e, 0x89a1a829, 0x46525416, 0x43434003,
|
||||
0x85818405, 0x04101414, 0x89818809, 0x8b93981b,
|
||||
0x80b0b030, 0xc5e1e425, 0x48404808, 0x49717839,
|
||||
0x87939417, 0xccf0fc3c, 0x0e121c1e, 0x82828002,
|
||||
0x01212021, 0x8c808c0c, 0x0b13181b, 0x4f535c1f,
|
||||
0x47737437, 0x44505414, 0x82b2b032, 0x0d111c1d,
|
||||
0x05212425, 0x4f434c0f, 0x00000000, 0x46424406,
|
||||
0xcde1ec2d, 0x48505818, 0x42525012, 0xcbe3e82b,
|
||||
0x4e727c3e, 0xcad2d81a, 0xc9c1c809, 0xcdf1fc3d,
|
||||
0x00303030, 0x85919415, 0x45616425, 0x0c303c3c,
|
||||
0x86b2b436, 0xc4e0e424, 0x8bb3b83b, 0x4c707c3c,
|
||||
0x0e020c0e, 0x40505010, 0x09313839, 0x06222426,
|
||||
0x02323032, 0x84808404, 0x49616829, 0x83939013,
|
||||
0x07333437, 0xc7e3e427, 0x04202424, 0x84a0a424,
|
||||
0xcbc3c80b, 0x43535013, 0x0a02080a, 0x87838407,
|
||||
0xc9d1d819, 0x4c404c0c, 0x83838003, 0x8f838c0f,
|
||||
0xcec2cc0e, 0x0b33383b, 0x4a42480a, 0x87b3b437,
|
||||
};
|
||||
|
||||
static const u32 KC[SEED_NUM_KCONSTANTS] = {
|
||||
0x9e3779b9, 0x3c6ef373, 0x78dde6e6, 0xf1bbcdcc,
|
||||
0xe3779b99, 0xc6ef3733, 0x8dde6e67, 0x1bbcdccf,
|
||||
0x3779b99e, 0x6ef3733c, 0xdde6e678, 0xbbcdccf1,
|
||||
0x779b99e3, 0xef3733c6, 0xde6e678d, 0xbcdccf1b,
|
||||
};
|
||||
|
||||
#define OP(X1, X2, X3, X4, rbase) \
|
||||
t0 = X3 ^ ks[rbase]; \
|
||||
t1 = X4 ^ ks[rbase+1]; \
|
||||
t1 ^= t0; \
|
||||
t1 = SS0[byte(t1, 0)] ^ SS1[byte(t1, 1)] ^ \
|
||||
SS2[byte(t1, 2)] ^ SS3[byte(t1, 3)]; \
|
||||
t0 += t1; \
|
||||
t0 = SS0[byte(t0, 0)] ^ SS1[byte(t0, 1)] ^ \
|
||||
SS2[byte(t0, 2)] ^ SS3[byte(t0, 3)]; \
|
||||
t1 += t0; \
|
||||
t1 = SS0[byte(t1, 0)] ^ SS1[byte(t1, 1)] ^ \
|
||||
SS2[byte(t1, 2)] ^ SS3[byte(t1, 3)]; \
|
||||
t0 += t1; \
|
||||
X1 ^= t0; \
|
||||
X2 ^= t1;
|
||||
|
||||
static int seed_set_key(struct crypto_tfm *tfm, const u8 *in_key,
|
||||
unsigned int key_len)
|
||||
{
|
||||
struct seed_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
u32 *keyout = ctx->keysched;
|
||||
const __be32 *key = (const __be32 *)in_key;
|
||||
u32 i, t0, t1, x1, x2, x3, x4;
|
||||
|
||||
x1 = be32_to_cpu(key[0]);
|
||||
x2 = be32_to_cpu(key[1]);
|
||||
x3 = be32_to_cpu(key[2]);
|
||||
x4 = be32_to_cpu(key[3]);
|
||||
|
||||
for (i = 0; i < SEED_NUM_KCONSTANTS; i++) {
|
||||
t0 = x1 + x3 - KC[i];
|
||||
t1 = x2 + KC[i] - x4;
|
||||
*(keyout++) = SS0[byte(t0, 0)] ^ SS1[byte(t0, 1)] ^
|
||||
SS2[byte(t0, 2)] ^ SS3[byte(t0, 3)];
|
||||
*(keyout++) = SS0[byte(t1, 0)] ^ SS1[byte(t1, 1)] ^
|
||||
SS2[byte(t1, 2)] ^ SS3[byte(t1, 3)];
|
||||
|
||||
if (i % 2 == 0) {
|
||||
t0 = x1;
|
||||
x1 = (x1 >> 8) ^ (x2 << 24);
|
||||
x2 = (x2 >> 8) ^ (t0 << 24);
|
||||
} else {
|
||||
t0 = x3;
|
||||
x3 = (x3 << 8) ^ (x4 >> 24);
|
||||
x4 = (x4 << 8) ^ (t0 >> 24);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* encrypt a block of text */
|
||||
|
||||
static void seed_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
|
||||
{
|
||||
const struct seed_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
const __be32 *src = (const __be32 *)in;
|
||||
__be32 *dst = (__be32 *)out;
|
||||
u32 x1, x2, x3, x4, t0, t1;
|
||||
const u32 *ks = ctx->keysched;
|
||||
|
||||
x1 = be32_to_cpu(src[0]);
|
||||
x2 = be32_to_cpu(src[1]);
|
||||
x3 = be32_to_cpu(src[2]);
|
||||
x4 = be32_to_cpu(src[3]);
|
||||
|
||||
OP(x1, x2, x3, x4, 0);
|
||||
OP(x3, x4, x1, x2, 2);
|
||||
OP(x1, x2, x3, x4, 4);
|
||||
OP(x3, x4, x1, x2, 6);
|
||||
OP(x1, x2, x3, x4, 8);
|
||||
OP(x3, x4, x1, x2, 10);
|
||||
OP(x1, x2, x3, x4, 12);
|
||||
OP(x3, x4, x1, x2, 14);
|
||||
OP(x1, x2, x3, x4, 16);
|
||||
OP(x3, x4, x1, x2, 18);
|
||||
OP(x1, x2, x3, x4, 20);
|
||||
OP(x3, x4, x1, x2, 22);
|
||||
OP(x1, x2, x3, x4, 24);
|
||||
OP(x3, x4, x1, x2, 26);
|
||||
OP(x1, x2, x3, x4, 28);
|
||||
OP(x3, x4, x1, x2, 30);
|
||||
|
||||
dst[0] = cpu_to_be32(x3);
|
||||
dst[1] = cpu_to_be32(x4);
|
||||
dst[2] = cpu_to_be32(x1);
|
||||
dst[3] = cpu_to_be32(x2);
|
||||
}
|
||||
|
||||
/* decrypt a block of text */
|
||||
|
||||
static void seed_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
|
||||
{
|
||||
const struct seed_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
const __be32 *src = (const __be32 *)in;
|
||||
__be32 *dst = (__be32 *)out;
|
||||
u32 x1, x2, x3, x4, t0, t1;
|
||||
const u32 *ks = ctx->keysched;
|
||||
|
||||
x1 = be32_to_cpu(src[0]);
|
||||
x2 = be32_to_cpu(src[1]);
|
||||
x3 = be32_to_cpu(src[2]);
|
||||
x4 = be32_to_cpu(src[3]);
|
||||
|
||||
OP(x1, x2, x3, x4, 30);
|
||||
OP(x3, x4, x1, x2, 28);
|
||||
OP(x1, x2, x3, x4, 26);
|
||||
OP(x3, x4, x1, x2, 24);
|
||||
OP(x1, x2, x3, x4, 22);
|
||||
OP(x3, x4, x1, x2, 20);
|
||||
OP(x1, x2, x3, x4, 18);
|
||||
OP(x3, x4, x1, x2, 16);
|
||||
OP(x1, x2, x3, x4, 14);
|
||||
OP(x3, x4, x1, x2, 12);
|
||||
OP(x1, x2, x3, x4, 10);
|
||||
OP(x3, x4, x1, x2, 8);
|
||||
OP(x1, x2, x3, x4, 6);
|
||||
OP(x3, x4, x1, x2, 4);
|
||||
OP(x1, x2, x3, x4, 2);
|
||||
OP(x3, x4, x1, x2, 0);
|
||||
|
||||
dst[0] = cpu_to_be32(x3);
|
||||
dst[1] = cpu_to_be32(x4);
|
||||
dst[2] = cpu_to_be32(x1);
|
||||
dst[3] = cpu_to_be32(x2);
|
||||
}
|
||||
|
||||
|
||||
static struct crypto_alg seed_alg = {
|
||||
.cra_name = "seed",
|
||||
.cra_driver_name = "seed-generic",
|
||||
.cra_priority = 100,
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = SEED_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct seed_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(seed_alg.cra_list),
|
||||
.cra_u = {
|
||||
.cipher = {
|
||||
.cia_min_keysize = SEED_KEY_SIZE,
|
||||
.cia_max_keysize = SEED_KEY_SIZE,
|
||||
.cia_setkey = seed_set_key,
|
||||
.cia_encrypt = seed_encrypt,
|
||||
.cia_decrypt = seed_decrypt
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static int __init seed_init(void)
|
||||
{
|
||||
return crypto_register_alg(&seed_alg);
|
||||
}
|
||||
|
||||
static void __exit seed_fini(void)
|
||||
{
|
||||
crypto_unregister_alg(&seed_alg);
|
||||
}
|
||||
|
||||
module_init(seed_init);
|
||||
module_exit(seed_fini);
|
||||
|
||||
MODULE_DESCRIPTION("SEED Cipher Algorithm");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Hye-Shik Chang <perky@FreeBSD.org>, Kim Hyun <hkim@kisa.or.kr>");
|
@ -22,12 +22,10 @@
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/cryptohash.h>
|
||||
#include <linux/types.h>
|
||||
#include <crypto/sha.h>
|
||||
#include <asm/scatterlist.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#define SHA1_DIGEST_SIZE 20
|
||||
#define SHA1_HMAC_BLOCK_SIZE 64
|
||||
|
||||
struct sha1_ctx {
|
||||
u64 count;
|
||||
u32 state[5];
|
||||
@ -39,7 +37,7 @@ static void sha1_init(struct crypto_tfm *tfm)
|
||||
struct sha1_ctx *sctx = crypto_tfm_ctx(tfm);
|
||||
static const struct sha1_ctx initstate = {
|
||||
0,
|
||||
{ 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 },
|
||||
{ SHA1_H0, SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 },
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
@ -111,7 +109,7 @@ static struct crypto_alg alg = {
|
||||
.cra_name = "sha1",
|
||||
.cra_driver_name= "sha1-generic",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_DIGEST,
|
||||
.cra_blocksize = SHA1_HMAC_BLOCK_SIZE,
|
||||
.cra_blocksize = SHA1_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct sha1_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_alignmask = 3,
|
||||
@ -139,4 +137,4 @@ module_exit(fini);
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm");
|
||||
|
||||
MODULE_ALIAS("sha1-generic");
|
||||
MODULE_ALIAS("sha1");
|
@ -21,12 +21,10 @@
|
||||
#include <linux/mm.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/types.h>
|
||||
#include <crypto/sha.h>
|
||||
#include <asm/scatterlist.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#define SHA256_DIGEST_SIZE 32
|
||||
#define SHA256_HMAC_BLOCK_SIZE 64
|
||||
|
||||
struct sha256_ctx {
|
||||
u32 count[2];
|
||||
u32 state[8];
|
||||
@ -48,15 +46,6 @@ static inline u32 Maj(u32 x, u32 y, u32 z)
|
||||
#define s0(x) (ror32(x, 7) ^ ror32(x,18) ^ (x >> 3))
|
||||
#define s1(x) (ror32(x,17) ^ ror32(x,19) ^ (x >> 10))
|
||||
|
||||
#define H0 0x6a09e667
|
||||
#define H1 0xbb67ae85
|
||||
#define H2 0x3c6ef372
|
||||
#define H3 0xa54ff53a
|
||||
#define H4 0x510e527f
|
||||
#define H5 0x9b05688c
|
||||
#define H6 0x1f83d9ab
|
||||
#define H7 0x5be0cd19
|
||||
|
||||
static inline void LOAD_OP(int I, u32 *W, const u8 *input)
|
||||
{
|
||||
W[I] = __be32_to_cpu( ((__be32*)(input))[I] );
|
||||
@ -233,14 +222,14 @@ static void sha256_transform(u32 *state, const u8 *input)
|
||||
static void sha256_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct sha256_ctx *sctx = crypto_tfm_ctx(tfm);
|
||||
sctx->state[0] = H0;
|
||||
sctx->state[1] = H1;
|
||||
sctx->state[2] = H2;
|
||||
sctx->state[3] = H3;
|
||||
sctx->state[4] = H4;
|
||||
sctx->state[5] = H5;
|
||||
sctx->state[6] = H6;
|
||||
sctx->state[7] = H7;
|
||||
sctx->state[0] = SHA256_H0;
|
||||
sctx->state[1] = SHA256_H1;
|
||||
sctx->state[2] = SHA256_H2;
|
||||
sctx->state[3] = SHA256_H3;
|
||||
sctx->state[4] = SHA256_H4;
|
||||
sctx->state[5] = SHA256_H5;
|
||||
sctx->state[6] = SHA256_H6;
|
||||
sctx->state[7] = SHA256_H7;
|
||||
sctx->count[0] = sctx->count[1] = 0;
|
||||
}
|
||||
|
||||
@ -311,7 +300,7 @@ static struct crypto_alg alg = {
|
||||
.cra_name = "sha256",
|
||||
.cra_driver_name= "sha256-generic",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_DIGEST,
|
||||
.cra_blocksize = SHA256_HMAC_BLOCK_SIZE,
|
||||
.cra_blocksize = SHA256_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct sha256_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_alignmask = 3,
|
||||
@ -339,4 +328,4 @@ module_exit(fini);
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("SHA256 Secure Hash Algorithm");
|
||||
|
||||
MODULE_ALIAS("sha256-generic");
|
||||
MODULE_ALIAS("sha256");
|
@ -13,20 +13,15 @@
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <linux/mm.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/types.h>
|
||||
#include <crypto/sha.h>
|
||||
|
||||
#include <asm/scatterlist.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#define SHA384_DIGEST_SIZE 48
|
||||
#define SHA512_DIGEST_SIZE 64
|
||||
#define SHA384_HMAC_BLOCK_SIZE 128
|
||||
#define SHA512_HMAC_BLOCK_SIZE 128
|
||||
|
||||
struct sha512_ctx {
|
||||
u64 state[8];
|
||||
u32 count[4];
|
||||
@ -84,26 +79,6 @@ static const u64 sha512_K[80] = {
|
||||
#define s0(x) (RORu64(x, 1) ^ RORu64(x, 8) ^ (x >> 7))
|
||||
#define s1(x) (RORu64(x,19) ^ RORu64(x,61) ^ (x >> 6))
|
||||
|
||||
/* H* initial state for SHA-512 */
|
||||
#define H0 0x6a09e667f3bcc908ULL
|
||||
#define H1 0xbb67ae8584caa73bULL
|
||||
#define H2 0x3c6ef372fe94f82bULL
|
||||
#define H3 0xa54ff53a5f1d36f1ULL
|
||||
#define H4 0x510e527fade682d1ULL
|
||||
#define H5 0x9b05688c2b3e6c1fULL
|
||||
#define H6 0x1f83d9abfb41bd6bULL
|
||||
#define H7 0x5be0cd19137e2179ULL
|
||||
|
||||
/* H'* initial state for SHA-384 */
|
||||
#define HP0 0xcbbb9d5dc1059ed8ULL
|
||||
#define HP1 0x629a292a367cd507ULL
|
||||
#define HP2 0x9159015a3070dd17ULL
|
||||
#define HP3 0x152fecd8f70e5939ULL
|
||||
#define HP4 0x67332667ffc00b31ULL
|
||||
#define HP5 0x8eb44a8768581511ULL
|
||||
#define HP6 0xdb0c2e0d64f98fa7ULL
|
||||
#define HP7 0x47b5481dbefa4fa4ULL
|
||||
|
||||
static inline void LOAD_OP(int I, u64 *W, const u8 *input)
|
||||
{
|
||||
W[I] = __be64_to_cpu( ((__be64*)(input))[I] );
|
||||
@ -164,14 +139,14 @@ static void
|
||||
sha512_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct sha512_ctx *sctx = crypto_tfm_ctx(tfm);
|
||||
sctx->state[0] = H0;
|
||||
sctx->state[1] = H1;
|
||||
sctx->state[2] = H2;
|
||||
sctx->state[3] = H3;
|
||||
sctx->state[4] = H4;
|
||||
sctx->state[5] = H5;
|
||||
sctx->state[6] = H6;
|
||||
sctx->state[7] = H7;
|
||||
sctx->state[0] = SHA512_H0;
|
||||
sctx->state[1] = SHA512_H1;
|
||||
sctx->state[2] = SHA512_H2;
|
||||
sctx->state[3] = SHA512_H3;
|
||||
sctx->state[4] = SHA512_H4;
|
||||
sctx->state[5] = SHA512_H5;
|
||||
sctx->state[6] = SHA512_H6;
|
||||
sctx->state[7] = SHA512_H7;
|
||||
sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0;
|
||||
}
|
||||
|
||||
@ -179,14 +154,14 @@ static void
|
||||
sha384_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct sha512_ctx *sctx = crypto_tfm_ctx(tfm);
|
||||
sctx->state[0] = HP0;
|
||||
sctx->state[1] = HP1;
|
||||
sctx->state[2] = HP2;
|
||||
sctx->state[3] = HP3;
|
||||
sctx->state[4] = HP4;
|
||||
sctx->state[5] = HP5;
|
||||
sctx->state[6] = HP6;
|
||||
sctx->state[7] = HP7;
|
||||
sctx->state[0] = SHA384_H0;
|
||||
sctx->state[1] = SHA384_H1;
|
||||
sctx->state[2] = SHA384_H2;
|
||||
sctx->state[3] = SHA384_H3;
|
||||
sctx->state[4] = SHA384_H4;
|
||||
sctx->state[5] = SHA384_H5;
|
||||
sctx->state[6] = SHA384_H6;
|
||||
sctx->state[7] = SHA384_H7;
|
||||
sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0;
|
||||
}
|
||||
|
||||
@ -275,7 +250,7 @@ static void sha384_final(struct crypto_tfm *tfm, u8 *hash)
|
||||
static struct crypto_alg sha512 = {
|
||||
.cra_name = "sha512",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_DIGEST,
|
||||
.cra_blocksize = SHA512_HMAC_BLOCK_SIZE,
|
||||
.cra_blocksize = SHA512_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct sha512_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_alignmask = 3,
|
||||
@ -291,7 +266,7 @@ static struct crypto_alg sha512 = {
|
||||
static struct crypto_alg sha384 = {
|
||||
.cra_name = "sha384",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_DIGEST,
|
||||
.cra_blocksize = SHA384_HMAC_BLOCK_SIZE,
|
||||
.cra_blocksize = SHA384_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct sha512_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
|
@ -78,7 +78,7 @@ static char *check[] = {
|
||||
"twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6",
|
||||
"arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
|
||||
"khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
|
||||
"camellia", NULL
|
||||
"camellia", "seed", NULL
|
||||
};
|
||||
|
||||
static void hexdump(unsigned char *buf, unsigned int len)
|
||||
@ -955,6 +955,10 @@ static void do_test(void)
|
||||
AES_LRW_ENC_TEST_VECTORS);
|
||||
test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
|
||||
AES_LRW_DEC_TEST_VECTORS);
|
||||
test_cipher("xts(aes)", ENCRYPT, aes_xts_enc_tv_template,
|
||||
AES_XTS_ENC_TEST_VECTORS);
|
||||
test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
|
||||
AES_XTS_DEC_TEST_VECTORS);
|
||||
|
||||
//CAST5
|
||||
test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template,
|
||||
@ -1029,6 +1033,12 @@ static void do_test(void)
|
||||
camellia_cbc_dec_tv_template,
|
||||
CAMELLIA_CBC_DEC_TEST_VECTORS);
|
||||
|
||||
//SEED
|
||||
test_cipher("ecb(seed)", ENCRYPT, seed_enc_tv_template,
|
||||
SEED_ENC_TEST_VECTORS);
|
||||
test_cipher("ecb(seed)", DECRYPT, seed_dec_tv_template,
|
||||
SEED_DEC_TEST_VECTORS);
|
||||
|
||||
test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
|
||||
test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
|
||||
test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
|
||||
@ -1132,6 +1142,10 @@ static void do_test(void)
|
||||
AES_LRW_ENC_TEST_VECTORS);
|
||||
test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
|
||||
AES_LRW_DEC_TEST_VECTORS);
|
||||
test_cipher("xts(aes)", ENCRYPT, aes_xts_enc_tv_template,
|
||||
AES_XTS_ENC_TEST_VECTORS);
|
||||
test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
|
||||
AES_XTS_DEC_TEST_VECTORS);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
@ -1307,6 +1321,10 @@ static void do_test(void)
|
||||
aes_lrw_speed_template);
|
||||
test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
|
||||
aes_lrw_speed_template);
|
||||
test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
|
||||
aes_xts_speed_template);
|
||||
test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
|
||||
aes_xts_speed_template);
|
||||
break;
|
||||
|
||||
case 201:
|
||||
|
507
crypto/tcrypt.h
507
crypto/tcrypt.h
@ -2144,6 +2144,8 @@ static struct cipher_testvec cast6_dec_tv_template[] = {
|
||||
#define AES_CBC_DEC_TEST_VECTORS 2
|
||||
#define AES_LRW_ENC_TEST_VECTORS 8
|
||||
#define AES_LRW_DEC_TEST_VECTORS 8
|
||||
#define AES_XTS_ENC_TEST_VECTORS 4
|
||||
#define AES_XTS_DEC_TEST_VECTORS 4
|
||||
|
||||
static struct cipher_testvec aes_enc_tv_template[] = {
|
||||
{ /* From FIPS-197 */
|
||||
@ -2784,6 +2786,400 @@ static struct cipher_testvec aes_lrw_dec_tv_template[] = {
|
||||
}
|
||||
};
|
||||
|
||||
static struct cipher_testvec aes_xts_enc_tv_template[] = {
|
||||
/* http://grouper.ieee.org/groups/1619/email/pdf00086.pdf */
|
||||
{ /* XTS-AES 1 */
|
||||
.key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.klen = 32,
|
||||
.iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.ilen = 32,
|
||||
.result = { 0x91, 0x7c, 0xf6, 0x9e, 0xbd, 0x68, 0xb2, 0xec,
|
||||
0x9b, 0x9f, 0xe9, 0xa3, 0xea, 0xdd, 0xa6, 0x92,
|
||||
0xcd, 0x43, 0xd2, 0xf5, 0x95, 0x98, 0xed, 0x85,
|
||||
0x8c, 0x02, 0xc2, 0x65, 0x2f, 0xbf, 0x92, 0x2e },
|
||||
.rlen = 32,
|
||||
}, { /* XTS-AES 2 */
|
||||
.key = { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 },
|
||||
.klen = 32,
|
||||
.iv = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.input = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 },
|
||||
.ilen = 32,
|
||||
.result = { 0xc4, 0x54, 0x18, 0x5e, 0x6a, 0x16, 0x93, 0x6e,
|
||||
0x39, 0x33, 0x40, 0x38, 0xac, 0xef, 0x83, 0x8b,
|
||||
0xfb, 0x18, 0x6f, 0xff, 0x74, 0x80, 0xad, 0xc4,
|
||||
0x28, 0x93, 0x82, 0xec, 0xd6, 0xd3, 0x94, 0xf0 },
|
||||
.rlen = 32,
|
||||
}, { /* XTS-AES 3 */
|
||||
.key = { 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
|
||||
0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 },
|
||||
.klen = 32,
|
||||
.iv = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.input = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 },
|
||||
.ilen = 32,
|
||||
.result = { 0xaf, 0x85, 0x33, 0x6b, 0x59, 0x7a, 0xfc, 0x1a,
|
||||
0x90, 0x0b, 0x2e, 0xb2, 0x1e, 0xc9, 0x49, 0xd2,
|
||||
0x92, 0xdf, 0x4c, 0x04, 0x7e, 0x0b, 0x21, 0x53,
|
||||
0x21, 0x86, 0xa5, 0x97, 0x1a, 0x22, 0x7a, 0x89 },
|
||||
.rlen = 32,
|
||||
}, { /* XTS-AES 4 */
|
||||
.key = { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
|
||||
0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
|
||||
0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
|
||||
0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95 },
|
||||
.klen = 32,
|
||||
.iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
|
||||
.ilen = 512,
|
||||
.result = { 0x27, 0xa7, 0x47, 0x9b, 0xef, 0xa1, 0xd4, 0x76,
|
||||
0x48, 0x9f, 0x30, 0x8c, 0xd4, 0xcf, 0xa6, 0xe2,
|
||||
0xa9, 0x6e, 0x4b, 0xbe, 0x32, 0x08, 0xff, 0x25,
|
||||
0x28, 0x7d, 0xd3, 0x81, 0x96, 0x16, 0xe8, 0x9c,
|
||||
0xc7, 0x8c, 0xf7, 0xf5, 0xe5, 0x43, 0x44, 0x5f,
|
||||
0x83, 0x33, 0xd8, 0xfa, 0x7f, 0x56, 0x00, 0x00,
|
||||
0x05, 0x27, 0x9f, 0xa5, 0xd8, 0xb5, 0xe4, 0xad,
|
||||
0x40, 0xe7, 0x36, 0xdd, 0xb4, 0xd3, 0x54, 0x12,
|
||||
0x32, 0x80, 0x63, 0xfd, 0x2a, 0xab, 0x53, 0xe5,
|
||||
0xea, 0x1e, 0x0a, 0x9f, 0x33, 0x25, 0x00, 0xa5,
|
||||
0xdf, 0x94, 0x87, 0xd0, 0x7a, 0x5c, 0x92, 0xcc,
|
||||
0x51, 0x2c, 0x88, 0x66, 0xc7, 0xe8, 0x60, 0xce,
|
||||
0x93, 0xfd, 0xf1, 0x66, 0xa2, 0x49, 0x12, 0xb4,
|
||||
0x22, 0x97, 0x61, 0x46, 0xae, 0x20, 0xce, 0x84,
|
||||
0x6b, 0xb7, 0xdc, 0x9b, 0xa9, 0x4a, 0x76, 0x7a,
|
||||
0xae, 0xf2, 0x0c, 0x0d, 0x61, 0xad, 0x02, 0x65,
|
||||
0x5e, 0xa9, 0x2d, 0xc4, 0xc4, 0xe4, 0x1a, 0x89,
|
||||
0x52, 0xc6, 0x51, 0xd3, 0x31, 0x74, 0xbe, 0x51,
|
||||
0xa1, 0x0c, 0x42, 0x11, 0x10, 0xe6, 0xd8, 0x15,
|
||||
0x88, 0xed, 0xe8, 0x21, 0x03, 0xa2, 0x52, 0xd8,
|
||||
0xa7, 0x50, 0xe8, 0x76, 0x8d, 0xef, 0xff, 0xed,
|
||||
0x91, 0x22, 0x81, 0x0a, 0xae, 0xb9, 0x9f, 0x91,
|
||||
0x72, 0xaf, 0x82, 0xb6, 0x04, 0xdc, 0x4b, 0x8e,
|
||||
0x51, 0xbc, 0xb0, 0x82, 0x35, 0xa6, 0xf4, 0x34,
|
||||
0x13, 0x32, 0xe4, 0xca, 0x60, 0x48, 0x2a, 0x4b,
|
||||
0xa1, 0xa0, 0x3b, 0x3e, 0x65, 0x00, 0x8f, 0xc5,
|
||||
0xda, 0x76, 0xb7, 0x0b, 0xf1, 0x69, 0x0d, 0xb4,
|
||||
0xea, 0xe2, 0x9c, 0x5f, 0x1b, 0xad, 0xd0, 0x3c,
|
||||
0x5c, 0xcf, 0x2a, 0x55, 0xd7, 0x05, 0xdd, 0xcd,
|
||||
0x86, 0xd4, 0x49, 0x51, 0x1c, 0xeb, 0x7e, 0xc3,
|
||||
0x0b, 0xf1, 0x2b, 0x1f, 0xa3, 0x5b, 0x91, 0x3f,
|
||||
0x9f, 0x74, 0x7a, 0x8a, 0xfd, 0x1b, 0x13, 0x0e,
|
||||
0x94, 0xbf, 0xf9, 0x4e, 0xff, 0xd0, 0x1a, 0x91,
|
||||
0x73, 0x5c, 0xa1, 0x72, 0x6a, 0xcd, 0x0b, 0x19,
|
||||
0x7c, 0x4e, 0x5b, 0x03, 0x39, 0x36, 0x97, 0xe1,
|
||||
0x26, 0x82, 0x6f, 0xb6, 0xbb, 0xde, 0x8e, 0xcc,
|
||||
0x1e, 0x08, 0x29, 0x85, 0x16, 0xe2, 0xc9, 0xed,
|
||||
0x03, 0xff, 0x3c, 0x1b, 0x78, 0x60, 0xf6, 0xde,
|
||||
0x76, 0xd4, 0xce, 0xcd, 0x94, 0xc8, 0x11, 0x98,
|
||||
0x55, 0xef, 0x52, 0x97, 0xca, 0x67, 0xe9, 0xf3,
|
||||
0xe7, 0xff, 0x72, 0xb1, 0xe9, 0x97, 0x85, 0xca,
|
||||
0x0a, 0x7e, 0x77, 0x20, 0xc5, 0xb3, 0x6d, 0xc6,
|
||||
0xd7, 0x2c, 0xac, 0x95, 0x74, 0xc8, 0xcb, 0xbc,
|
||||
0x2f, 0x80, 0x1e, 0x23, 0xe5, 0x6f, 0xd3, 0x44,
|
||||
0xb0, 0x7f, 0x22, 0x15, 0x4b, 0xeb, 0xa0, 0xf0,
|
||||
0x8c, 0xe8, 0x89, 0x1e, 0x64, 0x3e, 0xd9, 0x95,
|
||||
0xc9, 0x4d, 0x9a, 0x69, 0xc9, 0xf1, 0xb5, 0xf4,
|
||||
0x99, 0x02, 0x7a, 0x78, 0x57, 0x2a, 0xee, 0xbd,
|
||||
0x74, 0xd2, 0x0c, 0xc3, 0x98, 0x81, 0xc2, 0x13,
|
||||
0xee, 0x77, 0x0b, 0x10, 0x10, 0xe4, 0xbe, 0xa7,
|
||||
0x18, 0x84, 0x69, 0x77, 0xae, 0x11, 0x9f, 0x7a,
|
||||
0x02, 0x3a, 0xb5, 0x8c, 0xca, 0x0a, 0xd7, 0x52,
|
||||
0xaf, 0xe6, 0x56, 0xbb, 0x3c, 0x17, 0x25, 0x6a,
|
||||
0x9f, 0x6e, 0x9b, 0xf1, 0x9f, 0xdd, 0x5a, 0x38,
|
||||
0xfc, 0x82, 0xbb, 0xe8, 0x72, 0xc5, 0x53, 0x9e,
|
||||
0xdb, 0x60, 0x9e, 0xf4, 0xf7, 0x9c, 0x20, 0x3e,
|
||||
0xbb, 0x14, 0x0f, 0x2e, 0x58, 0x3c, 0xb2, 0xad,
|
||||
0x15, 0xb4, 0xaa, 0x5b, 0x65, 0x50, 0x16, 0xa8,
|
||||
0x44, 0x92, 0x77, 0xdb, 0xd4, 0x77, 0xef, 0x2c,
|
||||
0x8d, 0x6c, 0x01, 0x7d, 0xb7, 0x38, 0xb1, 0x8d,
|
||||
0xeb, 0x4a, 0x42, 0x7d, 0x19, 0x23, 0xce, 0x3f,
|
||||
0xf2, 0x62, 0x73, 0x57, 0x79, 0xa4, 0x18, 0xf2,
|
||||
0x0a, 0x28, 0x2d, 0xf9, 0x20, 0x14, 0x7b, 0xea,
|
||||
0xbe, 0x42, 0x1e, 0xe5, 0x31, 0x9d, 0x05, 0x68 },
|
||||
.rlen = 512,
|
||||
}
|
||||
};
|
||||
|
||||
static struct cipher_testvec aes_xts_dec_tv_template[] = {
|
||||
/* http://grouper.ieee.org/groups/1619/email/pdf00086.pdf */
|
||||
{ /* XTS-AES 1 */
|
||||
.key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.klen = 32,
|
||||
.iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.input = { 0x91, 0x7c, 0xf6, 0x9e, 0xbd, 0x68, 0xb2, 0xec,
|
||||
0x9b, 0x9f, 0xe9, 0xa3, 0xea, 0xdd, 0xa6, 0x92,
|
||||
0xcd, 0x43, 0xd2, 0xf5, 0x95, 0x98, 0xed, 0x85,
|
||||
0x8c, 0x02, 0xc2, 0x65, 0x2f, 0xbf, 0x92, 0x2e },
|
||||
.ilen = 32,
|
||||
.result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.rlen = 32,
|
||||
}, { /* XTS-AES 2 */
|
||||
.key = { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 },
|
||||
.klen = 32,
|
||||
.iv = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.input = { 0xc4, 0x54, 0x18, 0x5e, 0x6a, 0x16, 0x93, 0x6e,
|
||||
0x39, 0x33, 0x40, 0x38, 0xac, 0xef, 0x83, 0x8b,
|
||||
0xfb, 0x18, 0x6f, 0xff, 0x74, 0x80, 0xad, 0xc4,
|
||||
0x28, 0x93, 0x82, 0xec, 0xd6, 0xd3, 0x94, 0xf0 },
|
||||
.ilen = 32,
|
||||
.result = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 },
|
||||
.rlen = 32,
|
||||
}, { /* XTS-AES 3 */
|
||||
.key = { 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
|
||||
0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 },
|
||||
.klen = 32,
|
||||
.iv = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.input = { 0xaf, 0x85, 0x33, 0x6b, 0x59, 0x7a, 0xfc, 0x1a,
|
||||
0x90, 0x0b, 0x2e, 0xb2, 0x1e, 0xc9, 0x49, 0xd2,
|
||||
0x92, 0xdf, 0x4c, 0x04, 0x7e, 0x0b, 0x21, 0x53,
|
||||
0x21, 0x86, 0xa5, 0x97, 0x1a, 0x22, 0x7a, 0x89 },
|
||||
.ilen = 32,
|
||||
.result = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 },
|
||||
.rlen = 32,
|
||||
}, { /* XTS-AES 4 */
|
||||
.key = { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
|
||||
0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
|
||||
0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
|
||||
0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95 },
|
||||
.klen = 32,
|
||||
.iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
.input = { 0x27, 0xa7, 0x47, 0x9b, 0xef, 0xa1, 0xd4, 0x76,
|
||||
0x48, 0x9f, 0x30, 0x8c, 0xd4, 0xcf, 0xa6, 0xe2,
|
||||
0xa9, 0x6e, 0x4b, 0xbe, 0x32, 0x08, 0xff, 0x25,
|
||||
0x28, 0x7d, 0xd3, 0x81, 0x96, 0x16, 0xe8, 0x9c,
|
||||
0xc7, 0x8c, 0xf7, 0xf5, 0xe5, 0x43, 0x44, 0x5f,
|
||||
0x83, 0x33, 0xd8, 0xfa, 0x7f, 0x56, 0x00, 0x00,
|
||||
0x05, 0x27, 0x9f, 0xa5, 0xd8, 0xb5, 0xe4, 0xad,
|
||||
0x40, 0xe7, 0x36, 0xdd, 0xb4, 0xd3, 0x54, 0x12,
|
||||
0x32, 0x80, 0x63, 0xfd, 0x2a, 0xab, 0x53, 0xe5,
|
||||
0xea, 0x1e, 0x0a, 0x9f, 0x33, 0x25, 0x00, 0xa5,
|
||||
0xdf, 0x94, 0x87, 0xd0, 0x7a, 0x5c, 0x92, 0xcc,
|
||||
0x51, 0x2c, 0x88, 0x66, 0xc7, 0xe8, 0x60, 0xce,
|
||||
0x93, 0xfd, 0xf1, 0x66, 0xa2, 0x49, 0x12, 0xb4,
|
||||
0x22, 0x97, 0x61, 0x46, 0xae, 0x20, 0xce, 0x84,
|
||||
0x6b, 0xb7, 0xdc, 0x9b, 0xa9, 0x4a, 0x76, 0x7a,
|
||||
0xae, 0xf2, 0x0c, 0x0d, 0x61, 0xad, 0x02, 0x65,
|
||||
0x5e, 0xa9, 0x2d, 0xc4, 0xc4, 0xe4, 0x1a, 0x89,
|
||||
0x52, 0xc6, 0x51, 0xd3, 0x31, 0x74, 0xbe, 0x51,
|
||||
0xa1, 0x0c, 0x42, 0x11, 0x10, 0xe6, 0xd8, 0x15,
|
||||
0x88, 0xed, 0xe8, 0x21, 0x03, 0xa2, 0x52, 0xd8,
|
||||
0xa7, 0x50, 0xe8, 0x76, 0x8d, 0xef, 0xff, 0xed,
|
||||
0x91, 0x22, 0x81, 0x0a, 0xae, 0xb9, 0x9f, 0x91,
|
||||
0x72, 0xaf, 0x82, 0xb6, 0x04, 0xdc, 0x4b, 0x8e,
|
||||
0x51, 0xbc, 0xb0, 0x82, 0x35, 0xa6, 0xf4, 0x34,
|
||||
0x13, 0x32, 0xe4, 0xca, 0x60, 0x48, 0x2a, 0x4b,
|
||||
0xa1, 0xa0, 0x3b, 0x3e, 0x65, 0x00, 0x8f, 0xc5,
|
||||
0xda, 0x76, 0xb7, 0x0b, 0xf1, 0x69, 0x0d, 0xb4,
|
||||
0xea, 0xe2, 0x9c, 0x5f, 0x1b, 0xad, 0xd0, 0x3c,
|
||||
0x5c, 0xcf, 0x2a, 0x55, 0xd7, 0x05, 0xdd, 0xcd,
|
||||
0x86, 0xd4, 0x49, 0x51, 0x1c, 0xeb, 0x7e, 0xc3,
|
||||
0x0b, 0xf1, 0x2b, 0x1f, 0xa3, 0x5b, 0x91, 0x3f,
|
||||
0x9f, 0x74, 0x7a, 0x8a, 0xfd, 0x1b, 0x13, 0x0e,
|
||||
0x94, 0xbf, 0xf9, 0x4e, 0xff, 0xd0, 0x1a, 0x91,
|
||||
0x73, 0x5c, 0xa1, 0x72, 0x6a, 0xcd, 0x0b, 0x19,
|
||||
0x7c, 0x4e, 0x5b, 0x03, 0x39, 0x36, 0x97, 0xe1,
|
||||
0x26, 0x82, 0x6f, 0xb6, 0xbb, 0xde, 0x8e, 0xcc,
|
||||
0x1e, 0x08, 0x29, 0x85, 0x16, 0xe2, 0xc9, 0xed,
|
||||
0x03, 0xff, 0x3c, 0x1b, 0x78, 0x60, 0xf6, 0xde,
|
||||
0x76, 0xd4, 0xce, 0xcd, 0x94, 0xc8, 0x11, 0x98,
|
||||
0x55, 0xef, 0x52, 0x97, 0xca, 0x67, 0xe9, 0xf3,
|
||||
0xe7, 0xff, 0x72, 0xb1, 0xe9, 0x97, 0x85, 0xca,
|
||||
0x0a, 0x7e, 0x77, 0x20, 0xc5, 0xb3, 0x6d, 0xc6,
|
||||
0xd7, 0x2c, 0xac, 0x95, 0x74, 0xc8, 0xcb, 0xbc,
|
||||
0x2f, 0x80, 0x1e, 0x23, 0xe5, 0x6f, 0xd3, 0x44,
|
||||
0xb0, 0x7f, 0x22, 0x15, 0x4b, 0xeb, 0xa0, 0xf0,
|
||||
0x8c, 0xe8, 0x89, 0x1e, 0x64, 0x3e, 0xd9, 0x95,
|
||||
0xc9, 0x4d, 0x9a, 0x69, 0xc9, 0xf1, 0xb5, 0xf4,
|
||||
0x99, 0x02, 0x7a, 0x78, 0x57, 0x2a, 0xee, 0xbd,
|
||||
0x74, 0xd2, 0x0c, 0xc3, 0x98, 0x81, 0xc2, 0x13,
|
||||
0xee, 0x77, 0x0b, 0x10, 0x10, 0xe4, 0xbe, 0xa7,
|
||||
0x18, 0x84, 0x69, 0x77, 0xae, 0x11, 0x9f, 0x7a,
|
||||
0x02, 0x3a, 0xb5, 0x8c, 0xca, 0x0a, 0xd7, 0x52,
|
||||
0xaf, 0xe6, 0x56, 0xbb, 0x3c, 0x17, 0x25, 0x6a,
|
||||
0x9f, 0x6e, 0x9b, 0xf1, 0x9f, 0xdd, 0x5a, 0x38,
|
||||
0xfc, 0x82, 0xbb, 0xe8, 0x72, 0xc5, 0x53, 0x9e,
|
||||
0xdb, 0x60, 0x9e, 0xf4, 0xf7, 0x9c, 0x20, 0x3e,
|
||||
0xbb, 0x14, 0x0f, 0x2e, 0x58, 0x3c, 0xb2, 0xad,
|
||||
0x15, 0xb4, 0xaa, 0x5b, 0x65, 0x50, 0x16, 0xa8,
|
||||
0x44, 0x92, 0x77, 0xdb, 0xd4, 0x77, 0xef, 0x2c,
|
||||
0x8d, 0x6c, 0x01, 0x7d, 0xb7, 0x38, 0xb1, 0x8d,
|
||||
0xeb, 0x4a, 0x42, 0x7d, 0x19, 0x23, 0xce, 0x3f,
|
||||
0xf2, 0x62, 0x73, 0x57, 0x79, 0xa4, 0x18, 0xf2,
|
||||
0x0a, 0x28, 0x2d, 0xf9, 0x20, 0x14, 0x7b, 0xea,
|
||||
0xbe, 0x42, 0x1e, 0xe5, 0x31, 0x9d, 0x05, 0x68 },
|
||||
.ilen = 512,
|
||||
.result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
|
||||
.rlen = 512,
|
||||
}
|
||||
};
|
||||
|
||||
/* Cast5 test vectors from RFC 2144 */
|
||||
#define CAST5_ENC_TEST_VECTORS 3
|
||||
#define CAST5_DEC_TEST_VECTORS 3
|
||||
@ -3831,6 +4227,96 @@ static struct cipher_testvec camellia_cbc_dec_tv_template[] = {
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* SEED test vectors
|
||||
*/
|
||||
#define SEED_ENC_TEST_VECTORS 4
|
||||
#define SEED_DEC_TEST_VECTORS 4
|
||||
|
||||
static struct cipher_testvec seed_enc_tv_template[] = {
|
||||
{
|
||||
.key = { [0 ... 15] = 0x00 },
|
||||
.klen = 16,
|
||||
.input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
.ilen = 16,
|
||||
.result = { 0x5e, 0xba, 0xc6, 0xe0, 0x05, 0x4e, 0x16, 0x68,
|
||||
0x19, 0xaf, 0xf1, 0xcc, 0x6d, 0x34, 0x6c, 0xdb },
|
||||
.rlen = 16,
|
||||
}, {
|
||||
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
.klen = 16,
|
||||
.input = { [0 ... 15] = 0x00 },
|
||||
.ilen = 16,
|
||||
.result = { 0xc1, 0x1f, 0x22, 0xf2, 0x01, 0x40, 0x50, 0x50,
|
||||
0x84, 0x48, 0x35, 0x97, 0xe4, 0x37, 0x0f, 0x43 },
|
||||
.rlen = 16,
|
||||
}, {
|
||||
.key = { 0x47, 0x06, 0x48, 0x08, 0x51, 0xe6, 0x1b, 0xe8,
|
||||
0x5d, 0x74, 0xbf, 0xb3, 0xfd, 0x95, 0x61, 0x85 },
|
||||
.klen = 16,
|
||||
.input = { 0x83, 0xa2, 0xf8, 0xa2, 0x88, 0x64, 0x1f, 0xb9,
|
||||
0xa4, 0xe9, 0xa5, 0xcc, 0x2f, 0x13, 0x1c, 0x7d },
|
||||
.ilen = 16,
|
||||
.result = { 0xee, 0x54, 0xd1, 0x3e, 0xbc, 0xae, 0x70, 0x6d,
|
||||
0x22, 0x6b, 0xc3, 0x14, 0x2c, 0xd4, 0x0d, 0x4a },
|
||||
.rlen = 16,
|
||||
}, {
|
||||
.key = { 0x28, 0xdb, 0xc3, 0xbc, 0x49, 0xff, 0xd8, 0x7d,
|
||||
0xcf, 0xa5, 0x09, 0xb1, 0x1d, 0x42, 0x2b, 0xe7 },
|
||||
.klen = 16,
|
||||
.input = { 0xb4, 0x1e, 0x6b, 0xe2, 0xeb, 0xa8, 0x4a, 0x14,
|
||||
0x8e, 0x2e, 0xed, 0x84, 0x59, 0x3c, 0x5e, 0xc7 },
|
||||
.ilen = 16,
|
||||
.result = { 0x9b, 0x9b, 0x7b, 0xfc, 0xd1, 0x81, 0x3c, 0xb9,
|
||||
0x5d, 0x0b, 0x36, 0x18, 0xf4, 0x0f, 0x51, 0x22 },
|
||||
.rlen = 16,
|
||||
}
|
||||
};
|
||||
|
||||
static struct cipher_testvec seed_dec_tv_template[] = {
|
||||
{
|
||||
.key = { [0 ... 15] = 0x00 },
|
||||
.klen = 16,
|
||||
.input = { 0x5e, 0xba, 0xc6, 0xe0, 0x05, 0x4e, 0x16, 0x68,
|
||||
0x19, 0xaf, 0xf1, 0xcc, 0x6d, 0x34, 0x6c, 0xdb },
|
||||
.ilen = 16,
|
||||
.result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
.rlen = 16,
|
||||
}, {
|
||||
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
.klen = 16,
|
||||
.input = { 0xc1, 0x1f, 0x22, 0xf2, 0x01, 0x40, 0x50, 0x50,
|
||||
0x84, 0x48, 0x35, 0x97, 0xe4, 0x37, 0x0f, 0x43 },
|
||||
.ilen = 16,
|
||||
.result = { [0 ... 15] = 0x00 },
|
||||
.rlen = 16,
|
||||
}, {
|
||||
.key = { 0x47, 0x06, 0x48, 0x08, 0x51, 0xe6, 0x1b, 0xe8,
|
||||
0x5d, 0x74, 0xbf, 0xb3, 0xfd, 0x95, 0x61, 0x85 },
|
||||
.klen = 16,
|
||||
.input = { 0xee, 0x54, 0xd1, 0x3e, 0xbc, 0xae, 0x70, 0x6d,
|
||||
0x22, 0x6b, 0xc3, 0x14, 0x2c, 0xd4, 0x0d, 0x4a },
|
||||
.ilen = 16,
|
||||
.result = { 0x83, 0xa2, 0xf8, 0xa2, 0x88, 0x64, 0x1f, 0xb9,
|
||||
0xa4, 0xe9, 0xa5, 0xcc, 0x2f, 0x13, 0x1c, 0x7d },
|
||||
.rlen = 16,
|
||||
}, {
|
||||
.key = { 0x28, 0xdb, 0xc3, 0xbc, 0x49, 0xff, 0xd8, 0x7d,
|
||||
0xcf, 0xa5, 0x09, 0xb1, 0x1d, 0x42, 0x2b, 0xe7 },
|
||||
.klen = 16,
|
||||
.input = { 0x9b, 0x9b, 0x7b, 0xfc, 0xd1, 0x81, 0x3c, 0xb9,
|
||||
0x5d, 0x0b, 0x36, 0x18, 0xf4, 0x0f, 0x51, 0x22 },
|
||||
.ilen = 16,
|
||||
.result = { 0xb4, 0x1e, 0x6b, 0xe2, 0xeb, 0xa8, 0x4a, 0x14,
|
||||
0x8e, 0x2e, 0xed, 0x84, 0x59, 0x3c, 0x5e, 0xc7 },
|
||||
.rlen = 16,
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Compression stuff.
|
||||
*/
|
||||
@ -4193,6 +4679,27 @@ static struct cipher_speed aes_lrw_speed_template[] = {
|
||||
{ .klen = 0, .blen = 0, }
|
||||
};
|
||||
|
||||
static struct cipher_speed aes_xts_speed_template[] = {
|
||||
{ .klen = 32, .blen = 16, },
|
||||
{ .klen = 32, .blen = 64, },
|
||||
{ .klen = 32, .blen = 256, },
|
||||
{ .klen = 32, .blen = 1024, },
|
||||
{ .klen = 32, .blen = 8192, },
|
||||
{ .klen = 48, .blen = 16, },
|
||||
{ .klen = 48, .blen = 64, },
|
||||
{ .klen = 48, .blen = 256, },
|
||||
{ .klen = 48, .blen = 1024, },
|
||||
{ .klen = 48, .blen = 8192, },
|
||||
{ .klen = 64, .blen = 16, },
|
||||
{ .klen = 64, .blen = 64, },
|
||||
{ .klen = 64, .blen = 256, },
|
||||
{ .klen = 64, .blen = 1024, },
|
||||
{ .klen = 64, .blen = 8192, },
|
||||
|
||||
/* End marker */
|
||||
{ .klen = 0, .blen = 0, }
|
||||
};
|
||||
|
||||
static struct cipher_speed des3_ede_speed_template[] = {
|
||||
{ .klen = 24, .blen = 16, },
|
||||
{ .klen = 24, .blen = 64, },
|
||||
|
292
crypto/xts.c
Normal file
292
crypto/xts.c
Normal file
@ -0,0 +1,292 @@
|
||||
/* XTS: as defined in IEEE1619/D16
|
||||
* http://grouper.ieee.org/groups/1619/email/pdf00086.pdf
|
||||
* (sector sizes which are not a multiple of 16 bytes are,
|
||||
* however currently unsupported)
|
||||
*
|
||||
* Copyright (c) 2007 Rik Snel <rsnel@cube.dyndns.org>
|
||||
*
|
||||
* Based om ecb.c
|
||||
* Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*/
|
||||
#include <crypto/algapi.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <crypto/b128ops.h>
|
||||
#include <crypto/gf128mul.h>
|
||||
|
||||
struct priv {
|
||||
struct crypto_cipher *child;
|
||||
struct crypto_cipher *tweak;
|
||||
};
|
||||
|
||||
static int setkey(struct crypto_tfm *parent, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct priv *ctx = crypto_tfm_ctx(parent);
|
||||
struct crypto_cipher *child = ctx->tweak;
|
||||
u32 *flags = &parent->crt_flags;
|
||||
int err;
|
||||
|
||||
/* key consists of keys of equal size concatenated, therefore
|
||||
* the length must be even */
|
||||
if (keylen % 2) {
|
||||
/* tell the user why there was an error */
|
||||
*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* we need two cipher instances: one to compute the inital 'tweak'
|
||||
* by encrypting the IV (usually the 'plain' iv) and the other
|
||||
* one to encrypt and decrypt the data */
|
||||
|
||||
/* tweak cipher, uses Key2 i.e. the second half of *key */
|
||||
crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
|
||||
crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) &
|
||||
CRYPTO_TFM_REQ_MASK);
|
||||
err = crypto_cipher_setkey(child, key + keylen/2, keylen/2);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) &
|
||||
CRYPTO_TFM_RES_MASK);
|
||||
|
||||
child = ctx->child;
|
||||
|
||||
/* data cipher, uses Key1 i.e. the first half of *key */
|
||||
crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
|
||||
crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) &
|
||||
CRYPTO_TFM_REQ_MASK);
|
||||
err = crypto_cipher_setkey(child, key, keylen/2);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) &
|
||||
CRYPTO_TFM_RES_MASK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct sinfo {
|
||||
be128 t;
|
||||
struct crypto_tfm *tfm;
|
||||
void (*fn)(struct crypto_tfm *, u8 *, const u8 *);
|
||||
};
|
||||
|
||||
static inline void xts_round(struct sinfo *s, void *dst, const void *src)
|
||||
{
|
||||
be128_xor(dst, &s->t, src); /* PP <- T xor P */
|
||||
s->fn(s->tfm, dst, dst); /* CC <- E(Key1,PP) */
|
||||
be128_xor(dst, dst, &s->t); /* C <- T xor CC */
|
||||
}
|
||||
|
||||
static int crypt(struct blkcipher_desc *d,
|
||||
struct blkcipher_walk *w, struct priv *ctx,
|
||||
void (*tw)(struct crypto_tfm *, u8 *, const u8 *),
|
||||
void (*fn)(struct crypto_tfm *, u8 *, const u8 *))
|
||||
{
|
||||
int err;
|
||||
unsigned int avail;
|
||||
const int bs = crypto_cipher_blocksize(ctx->child);
|
||||
struct sinfo s = {
|
||||
.tfm = crypto_cipher_tfm(ctx->child),
|
||||
.fn = fn
|
||||
};
|
||||
be128 *iv;
|
||||
u8 *wsrc;
|
||||
u8 *wdst;
|
||||
|
||||
err = blkcipher_walk_virt(d, w);
|
||||
if (!w->nbytes)
|
||||
return err;
|
||||
|
||||
avail = w->nbytes;
|
||||
|
||||
wsrc = w->src.virt.addr;
|
||||
wdst = w->dst.virt.addr;
|
||||
|
||||
/* calculate first value of T */
|
||||
iv = (be128 *)w->iv;
|
||||
tw(crypto_cipher_tfm(ctx->tweak), (void *)&s.t, w->iv);
|
||||
|
||||
goto first;
|
||||
|
||||
for (;;) {
|
||||
do {
|
||||
gf128mul_x_ble(&s.t, &s.t);
|
||||
|
||||
first:
|
||||
xts_round(&s, wdst, wsrc);
|
||||
|
||||
wsrc += bs;
|
||||
wdst += bs;
|
||||
} while ((avail -= bs) >= bs);
|
||||
|
||||
err = blkcipher_walk_done(d, w, avail);
|
||||
if (!w->nbytes)
|
||||
break;
|
||||
|
||||
avail = w->nbytes;
|
||||
|
||||
wsrc = w->src.virt.addr;
|
||||
wdst = w->dst.virt.addr;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
|
||||
struct scatterlist *src, unsigned int nbytes)
|
||||
{
|
||||
struct priv *ctx = crypto_blkcipher_ctx(desc->tfm);
|
||||
struct blkcipher_walk w;
|
||||
|
||||
blkcipher_walk_init(&w, dst, src, nbytes);
|
||||
return crypt(desc, &w, ctx, crypto_cipher_alg(ctx->tweak)->cia_encrypt,
|
||||
crypto_cipher_alg(ctx->child)->cia_encrypt);
|
||||
}
|
||||
|
||||
static int decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
|
||||
struct scatterlist *src, unsigned int nbytes)
|
||||
{
|
||||
struct priv *ctx = crypto_blkcipher_ctx(desc->tfm);
|
||||
struct blkcipher_walk w;
|
||||
|
||||
blkcipher_walk_init(&w, dst, src, nbytes);
|
||||
return crypt(desc, &w, ctx, crypto_cipher_alg(ctx->tweak)->cia_encrypt,
|
||||
crypto_cipher_alg(ctx->child)->cia_decrypt);
|
||||
}
|
||||
|
||||
static int init_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct crypto_cipher *cipher;
|
||||
struct crypto_instance *inst = (void *)tfm->__crt_alg;
|
||||
struct crypto_spawn *spawn = crypto_instance_ctx(inst);
|
||||
struct priv *ctx = crypto_tfm_ctx(tfm);
|
||||
u32 *flags = &tfm->crt_flags;
|
||||
|
||||
cipher = crypto_spawn_cipher(spawn);
|
||||
if (IS_ERR(cipher))
|
||||
return PTR_ERR(cipher);
|
||||
|
||||
if (crypto_cipher_blocksize(cipher) != 16) {
|
||||
*flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
|
||||
crypto_free_cipher(cipher);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx->child = cipher;
|
||||
|
||||
cipher = crypto_spawn_cipher(spawn);
|
||||
if (IS_ERR(cipher)) {
|
||||
crypto_free_cipher(ctx->child);
|
||||
return PTR_ERR(cipher);
|
||||
}
|
||||
|
||||
/* this check isn't really needed, leave it here just in case */
|
||||
if (crypto_cipher_blocksize(cipher) != 16) {
|
||||
crypto_free_cipher(cipher);
|
||||
crypto_free_cipher(ctx->child);
|
||||
*flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx->tweak = cipher;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void exit_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct priv *ctx = crypto_tfm_ctx(tfm);
|
||||
crypto_free_cipher(ctx->child);
|
||||
crypto_free_cipher(ctx->tweak);
|
||||
}
|
||||
|
||||
static struct crypto_instance *alloc(struct rtattr **tb)
|
||||
{
|
||||
struct crypto_instance *inst;
|
||||
struct crypto_alg *alg;
|
||||
int err;
|
||||
|
||||
err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER);
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
|
||||
CRYPTO_ALG_TYPE_MASK);
|
||||
if (IS_ERR(alg))
|
||||
return ERR_PTR(PTR_ERR(alg));
|
||||
|
||||
inst = crypto_alloc_instance("xts", alg);
|
||||
if (IS_ERR(inst))
|
||||
goto out_put_alg;
|
||||
|
||||
inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER;
|
||||
inst->alg.cra_priority = alg->cra_priority;
|
||||
inst->alg.cra_blocksize = alg->cra_blocksize;
|
||||
|
||||
if (alg->cra_alignmask < 7)
|
||||
inst->alg.cra_alignmask = 7;
|
||||
else
|
||||
inst->alg.cra_alignmask = alg->cra_alignmask;
|
||||
|
||||
inst->alg.cra_type = &crypto_blkcipher_type;
|
||||
|
||||
inst->alg.cra_blkcipher.ivsize = alg->cra_blocksize;
|
||||
inst->alg.cra_blkcipher.min_keysize =
|
||||
2 * alg->cra_cipher.cia_min_keysize;
|
||||
inst->alg.cra_blkcipher.max_keysize =
|
||||
2 * alg->cra_cipher.cia_max_keysize;
|
||||
|
||||
inst->alg.cra_ctxsize = sizeof(struct priv);
|
||||
|
||||
inst->alg.cra_init = init_tfm;
|
||||
inst->alg.cra_exit = exit_tfm;
|
||||
|
||||
inst->alg.cra_blkcipher.setkey = setkey;
|
||||
inst->alg.cra_blkcipher.encrypt = encrypt;
|
||||
inst->alg.cra_blkcipher.decrypt = decrypt;
|
||||
|
||||
out_put_alg:
|
||||
crypto_mod_put(alg);
|
||||
return inst;
|
||||
}
|
||||
|
||||
static void free(struct crypto_instance *inst)
|
||||
{
|
||||
crypto_drop_spawn(crypto_instance_ctx(inst));
|
||||
kfree(inst);
|
||||
}
|
||||
|
||||
static struct crypto_template crypto_tmpl = {
|
||||
.name = "xts",
|
||||
.alloc = alloc,
|
||||
.free = free,
|
||||
.module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int __init crypto_module_init(void)
|
||||
{
|
||||
return crypto_register_template(&crypto_tmpl);
|
||||
}
|
||||
|
||||
static void __exit crypto_module_exit(void)
|
||||
{
|
||||
crypto_unregister_template(&crypto_tmpl);
|
||||
}
|
||||
|
||||
module_init(crypto_module_init);
|
||||
module_exit(crypto_module_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("XTS block cipher mode");
|
@ -58,6 +58,8 @@ source "drivers/power/Kconfig"
|
||||
|
||||
source "drivers/hwmon/Kconfig"
|
||||
|
||||
source "drivers/ssb/Kconfig"
|
||||
|
||||
source "drivers/mfd/Kconfig"
|
||||
|
||||
source "drivers/media/Kconfig"
|
||||
|
@ -88,3 +88,4 @@ obj-$(CONFIG_DMA_ENGINE) += dma/
|
||||
obj-$(CONFIG_HID) += hid/
|
||||
obj-$(CONFIG_PPC_PS3) += ps3/
|
||||
obj-$(CONFIG_OF) += of/
|
||||
obj-$(CONFIG_SSB) += ssb/
|
||||
|
@ -3576,7 +3576,7 @@ init_card(struct atm_dev *dev)
|
||||
* XXX: <hack>
|
||||
*/
|
||||
sprintf(tname, "eth%d", card->index);
|
||||
tmp = dev_get_by_name(tname); /* jhs: was "tmp = dev_get(tname);" */
|
||||
tmp = dev_get_by_name(&init_net, tname); /* jhs: was "tmp = dev_get(tname);" */
|
||||
if (tmp) {
|
||||
memcpy(card->atmdev->esi, tmp->dev_addr, 6);
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/genhd.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include <asm/unaligned.h>
|
||||
#include "aoe.h"
|
||||
|
||||
@ -194,7 +195,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
|
||||
sl = sl_tail = NULL;
|
||||
|
||||
read_lock(&dev_base_lock);
|
||||
for_each_netdev(ifp) {
|
||||
for_each_netdev(&init_net, ifp) {
|
||||
dev_hold(ifp);
|
||||
if (!is_aoe_netif(ifp))
|
||||
goto cont;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include <asm/unaligned.h>
|
||||
#include "aoe.h"
|
||||
|
||||
@ -114,6 +115,9 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
|
||||
struct aoe_hdr *h;
|
||||
u32 n;
|
||||
|
||||
if (ifp->nd_net != &init_net)
|
||||
goto exit;
|
||||
|
||||
skb = skb_share_check(skb, GFP_ATOMIC);
|
||||
if (skb == NULL)
|
||||
return 0;
|
||||
|
@ -234,18 +234,6 @@ out:
|
||||
kfree_skb(__skb);
|
||||
}
|
||||
|
||||
/*
|
||||
* Netlink socket input callback - dequeues the skbs and calls the
|
||||
* main netlink receiving function.
|
||||
*/
|
||||
static void cn_input(struct sock *sk, int len)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
|
||||
while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL)
|
||||
cn_rx_skb(skb);
|
||||
}
|
||||
|
||||
/*
|
||||
* Notification routing.
|
||||
*
|
||||
@ -442,11 +430,11 @@ static int __devinit cn_init(void)
|
||||
struct cn_dev *dev = &cdev;
|
||||
int err;
|
||||
|
||||
dev->input = cn_input;
|
||||
dev->input = cn_rx_skb;
|
||||
dev->id.idx = cn_idx;
|
||||
dev->id.val = cn_val;
|
||||
|
||||
dev->nls = netlink_kernel_create(NETLINK_CONNECTOR,
|
||||
dev->nls = netlink_kernel_create(&init_net, NETLINK_CONNECTOR,
|
||||
CN_NETLINK_USERS + 0xf,
|
||||
dev->input, NULL, THIS_MODULE);
|
||||
if (!dev->nls)
|
||||
|
@ -14,7 +14,6 @@ config CRYPTO_DEV_PADLOCK
|
||||
tristate "Support for VIA PadLock ACE"
|
||||
depends on X86_32
|
||||
select CRYPTO_ALGAPI
|
||||
default m
|
||||
help
|
||||
Some VIA processors come with an integrated crypto engine
|
||||
(so called VIA PadLock ACE, Advanced Cryptography Engine)
|
||||
@ -28,7 +27,6 @@ config CRYPTO_DEV_PADLOCK_AES
|
||||
tristate "PadLock driver for AES algorithm"
|
||||
depends on CRYPTO_DEV_PADLOCK
|
||||
select CRYPTO_BLKCIPHER
|
||||
default m
|
||||
help
|
||||
Use VIA PadLock for AES algorithm.
|
||||
|
||||
@ -42,7 +40,6 @@ config CRYPTO_DEV_PADLOCK_SHA
|
||||
depends on CRYPTO_DEV_PADLOCK
|
||||
select CRYPTO_SHA1
|
||||
select CRYPTO_SHA256
|
||||
default m
|
||||
help
|
||||
Use VIA PadLock for SHA1/SHA256 algorithms.
|
||||
|
||||
@ -58,7 +55,6 @@ config CRYPTO_DEV_GEODE
|
||||
depends on X86_32 && PCI
|
||||
select CRYPTO_ALGAPI
|
||||
select CRYPTO_BLKCIPHER
|
||||
default m
|
||||
help
|
||||
Say 'Y' here to use the AMD Geode LX processor on-board AES
|
||||
engine for the CryptoAPI AES algorithm.
|
||||
@ -70,7 +66,6 @@ config ZCRYPT
|
||||
tristate "Support for PCI-attached cryptographic adapters"
|
||||
depends on S390
|
||||
select ZCRYPT_MONOLITHIC if ZCRYPT="y"
|
||||
default "m"
|
||||
help
|
||||
Select this option if you want to use a PCI-attached cryptographic
|
||||
adapter like:
|
||||
|
@ -473,6 +473,7 @@ geode_aes_exit(void)
|
||||
MODULE_AUTHOR("Advanced Micro Devices, Inc.");
|
||||
MODULE_DESCRIPTION("Geode LX Hardware AES driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("aes");
|
||||
|
||||
module_init(geode_aes_init);
|
||||
module_exit(geode_aes_exit);
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Copyright (c) 2004 Michal Ludvig <michal@logix.cz>
|
||||
*
|
||||
* Key expansion routine taken from crypto/aes.c
|
||||
* Key expansion routine taken from crypto/aes_generic.c
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -660,4 +660,4 @@ MODULE_DESCRIPTION("VIA PadLock AES algorithm support");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Michal Ludvig");
|
||||
|
||||
MODULE_ALIAS("aes-padlock");
|
||||
MODULE_ALIAS("aes");
|
||||
|
@ -13,6 +13,7 @@
|
||||
*/
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/sha.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
@ -24,12 +25,7 @@
|
||||
#include "padlock.h"
|
||||
|
||||
#define SHA1_DEFAULT_FALLBACK "sha1-generic"
|
||||
#define SHA1_DIGEST_SIZE 20
|
||||
#define SHA1_HMAC_BLOCK_SIZE 64
|
||||
|
||||
#define SHA256_DEFAULT_FALLBACK "sha256-generic"
|
||||
#define SHA256_DIGEST_SIZE 32
|
||||
#define SHA256_HMAC_BLOCK_SIZE 64
|
||||
|
||||
struct padlock_sha_ctx {
|
||||
char *data;
|
||||
@ -107,11 +103,11 @@ static void padlock_do_sha1(const char *in, char *out, int count)
|
||||
char buf[128+16];
|
||||
char *result = NEAREST_ALIGNED(buf);
|
||||
|
||||
((uint32_t *)result)[0] = 0x67452301;
|
||||
((uint32_t *)result)[1] = 0xEFCDAB89;
|
||||
((uint32_t *)result)[2] = 0x98BADCFE;
|
||||
((uint32_t *)result)[3] = 0x10325476;
|
||||
((uint32_t *)result)[4] = 0xC3D2E1F0;
|
||||
((uint32_t *)result)[0] = SHA1_H0;
|
||||
((uint32_t *)result)[1] = SHA1_H1;
|
||||
((uint32_t *)result)[2] = SHA1_H2;
|
||||
((uint32_t *)result)[3] = SHA1_H3;
|
||||
((uint32_t *)result)[4] = SHA1_H4;
|
||||
|
||||
asm volatile (".byte 0xf3,0x0f,0xa6,0xc8" /* rep xsha1 */
|
||||
: "+S"(in), "+D"(result)
|
||||
@ -128,14 +124,14 @@ static void padlock_do_sha256(const char *in, char *out, int count)
|
||||
char buf[128+16];
|
||||
char *result = NEAREST_ALIGNED(buf);
|
||||
|
||||
((uint32_t *)result)[0] = 0x6A09E667;
|
||||
((uint32_t *)result)[1] = 0xBB67AE85;
|
||||
((uint32_t *)result)[2] = 0x3C6EF372;
|
||||
((uint32_t *)result)[3] = 0xA54FF53A;
|
||||
((uint32_t *)result)[4] = 0x510E527F;
|
||||
((uint32_t *)result)[5] = 0x9B05688C;
|
||||
((uint32_t *)result)[6] = 0x1F83D9AB;
|
||||
((uint32_t *)result)[7] = 0x5BE0CD19;
|
||||
((uint32_t *)result)[0] = SHA256_H0;
|
||||
((uint32_t *)result)[1] = SHA256_H1;
|
||||
((uint32_t *)result)[2] = SHA256_H2;
|
||||
((uint32_t *)result)[3] = SHA256_H3;
|
||||
((uint32_t *)result)[4] = SHA256_H4;
|
||||
((uint32_t *)result)[5] = SHA256_H5;
|
||||
((uint32_t *)result)[6] = SHA256_H6;
|
||||
((uint32_t *)result)[7] = SHA256_H7;
|
||||
|
||||
asm volatile (".byte 0xf3,0x0f,0xa6,0xd0" /* rep xsha256 */
|
||||
: "+S"(in), "+D"(result)
|
||||
@ -215,7 +211,7 @@ static struct crypto_alg sha1_alg = {
|
||||
.cra_priority = PADLOCK_CRA_PRIORITY,
|
||||
.cra_flags = CRYPTO_ALG_TYPE_DIGEST |
|
||||
CRYPTO_ALG_NEED_FALLBACK,
|
||||
.cra_blocksize = SHA1_HMAC_BLOCK_SIZE,
|
||||
.cra_blocksize = SHA1_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct padlock_sha_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(sha1_alg.cra_list),
|
||||
@ -237,7 +233,7 @@ static struct crypto_alg sha256_alg = {
|
||||
.cra_priority = PADLOCK_CRA_PRIORITY,
|
||||
.cra_flags = CRYPTO_ALG_TYPE_DIGEST |
|
||||
CRYPTO_ALG_NEED_FALLBACK,
|
||||
.cra_blocksize = SHA256_HMAC_BLOCK_SIZE,
|
||||
.cra_blocksize = SHA256_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct padlock_sha_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(sha256_alg.cra_list),
|
||||
@ -253,19 +249,6 @@ static struct crypto_alg sha256_alg = {
|
||||
}
|
||||
};
|
||||
|
||||
static void __init padlock_sha_check_fallbacks(void)
|
||||
{
|
||||
if (!crypto_has_hash("sha1", 0, CRYPTO_ALG_ASYNC |
|
||||
CRYPTO_ALG_NEED_FALLBACK))
|
||||
printk(KERN_WARNING PFX
|
||||
"Couldn't load fallback module for sha1.\n");
|
||||
|
||||
if (!crypto_has_hash("sha256", 0, CRYPTO_ALG_ASYNC |
|
||||
CRYPTO_ALG_NEED_FALLBACK))
|
||||
printk(KERN_WARNING PFX
|
||||
"Couldn't load fallback module for sha256.\n");
|
||||
}
|
||||
|
||||
static int __init padlock_init(void)
|
||||
{
|
||||
int rc = -ENODEV;
|
||||
@ -280,8 +263,6 @@ static int __init padlock_init(void)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
padlock_sha_check_fallbacks();
|
||||
|
||||
rc = crypto_register_alg(&sha1_alg);
|
||||
if (rc)
|
||||
goto out;
|
||||
@ -314,5 +295,7 @@ MODULE_DESCRIPTION("VIA PadLock SHA1/SHA256 algorithms support.");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Michal Ludvig");
|
||||
|
||||
MODULE_ALIAS("sha1");
|
||||
MODULE_ALIAS("sha256");
|
||||
MODULE_ALIAS("sha1-padlock");
|
||||
MODULE_ALIAS("sha256-padlock");
|
||||
|
@ -159,14 +159,16 @@ MODULE_PARM_DESC(max_partial_datagrams,
|
||||
|
||||
|
||||
static int ether1394_header(struct sk_buff *skb, struct net_device *dev,
|
||||
unsigned short type, void *daddr, void *saddr,
|
||||
unsigned len);
|
||||
unsigned short type, const void *daddr,
|
||||
const void *saddr, unsigned len);
|
||||
static int ether1394_rebuild_header(struct sk_buff *skb);
|
||||
static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr);
|
||||
static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh);
|
||||
static int ether1394_header_parse(const struct sk_buff *skb,
|
||||
unsigned char *haddr);
|
||||
static int ether1394_header_cache(const struct neighbour *neigh,
|
||||
struct hh_cache *hh);
|
||||
static void ether1394_header_cache_update(struct hh_cache *hh,
|
||||
struct net_device *dev,
|
||||
unsigned char *haddr);
|
||||
const struct net_device *dev,
|
||||
const unsigned char *haddr);
|
||||
static int ether1394_tx(struct sk_buff *skb, struct net_device *dev);
|
||||
static void ether1394_iso(struct hpsb_iso *iso);
|
||||
|
||||
@ -506,6 +508,14 @@ static void ether1394_reset_priv(struct net_device *dev, int set_mtu)
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
}
|
||||
|
||||
static const struct header_ops ether1394_header_ops = {
|
||||
.create = ether1394_header,
|
||||
.rebuild = ether1394_rebuild_header,
|
||||
.cache = ether1394_header_cache,
|
||||
.cache_update = ether1394_header_cache_update,
|
||||
.parse = ether1394_header_parse,
|
||||
};
|
||||
|
||||
static void ether1394_init_dev(struct net_device *dev)
|
||||
{
|
||||
dev->open = ether1394_open;
|
||||
@ -515,11 +525,7 @@ static void ether1394_init_dev(struct net_device *dev)
|
||||
dev->tx_timeout = ether1394_tx_timeout;
|
||||
dev->change_mtu = ether1394_change_mtu;
|
||||
|
||||
dev->hard_header = ether1394_header;
|
||||
dev->rebuild_header = ether1394_rebuild_header;
|
||||
dev->hard_header_cache = ether1394_header_cache;
|
||||
dev->header_cache_update= ether1394_header_cache_update;
|
||||
dev->hard_header_parse = ether1394_header_parse;
|
||||
dev->header_ops = ðer1394_header_ops;
|
||||
|
||||
SET_ETHTOOL_OPS(dev, ðtool_ops);
|
||||
|
||||
@ -598,7 +604,6 @@ static void ether1394_add_host(struct hpsb_host *host)
|
||||
goto out;
|
||||
}
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
SET_NETDEV_DEV(dev, &host->device);
|
||||
|
||||
priv = netdev_priv(dev);
|
||||
@ -711,8 +716,8 @@ static void ether1394_host_reset(struct hpsb_host *host)
|
||||
* saddr=NULL means use device source address
|
||||
* daddr=NULL means leave destination address (eg unresolved arp). */
|
||||
static int ether1394_header(struct sk_buff *skb, struct net_device *dev,
|
||||
unsigned short type, void *daddr, void *saddr,
|
||||
unsigned len)
|
||||
unsigned short type, const void *daddr,
|
||||
const void *saddr, unsigned len)
|
||||
{
|
||||
struct eth1394hdr *eth =
|
||||
(struct eth1394hdr *)skb_push(skb, ETH1394_HLEN);
|
||||
@ -752,15 +757,15 @@ static int ether1394_rebuild_header(struct sk_buff *skb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr)
|
||||
static int ether1394_header_parse(const struct sk_buff *skb,
|
||||
unsigned char *haddr)
|
||||
{
|
||||
struct net_device *dev = skb->dev;
|
||||
|
||||
memcpy(haddr, dev->dev_addr, ETH1394_ALEN);
|
||||
memcpy(haddr, skb->dev->dev_addr, ETH1394_ALEN);
|
||||
return ETH1394_ALEN;
|
||||
}
|
||||
|
||||
static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh)
|
||||
static int ether1394_header_cache(const struct neighbour *neigh,
|
||||
struct hh_cache *hh)
|
||||
{
|
||||
unsigned short type = hh->hh_type;
|
||||
struct net_device *dev = neigh->dev;
|
||||
@ -779,8 +784,8 @@ static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh)
|
||||
|
||||
/* Called by Address Resolution module to notify changes in address. */
|
||||
static void ether1394_header_cache_update(struct hh_cache *hh,
|
||||
struct net_device *dev,
|
||||
unsigned char * haddr)
|
||||
const struct net_device *dev,
|
||||
const unsigned char * haddr)
|
||||
{
|
||||
memcpy((u8 *)hh->hh_data + 16 - ETH1394_HLEN, haddr, dev->addr_len);
|
||||
}
|
||||
@ -900,8 +905,8 @@ static u16 ether1394_parse_encap(struct sk_buff *skb, struct net_device *dev,
|
||||
}
|
||||
|
||||
/* Now add the ethernet header. */
|
||||
if (dev->hard_header(skb, dev, ntohs(ether_type), &dest_hw, NULL,
|
||||
skb->len) >= 0)
|
||||
if (dev_hard_header(skb, dev, ntohs(ether_type), &dest_hw, NULL,
|
||||
skb->len) >= 0)
|
||||
ret = ether1394_type_trans(skb, dev);
|
||||
|
||||
return ret;
|
||||
|
@ -1866,13 +1866,14 @@ err1:
|
||||
static int cma_alloc_any_port(struct idr *ps, struct rdma_id_private *id_priv)
|
||||
{
|
||||
struct rdma_bind_list *bind_list;
|
||||
int port, ret;
|
||||
int port, ret, low, high;
|
||||
|
||||
bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
|
||||
if (!bind_list)
|
||||
return -ENOMEM;
|
||||
|
||||
retry:
|
||||
/* FIXME: add proper port randomization per like inet_csk_get_port */
|
||||
do {
|
||||
ret = idr_get_new_above(ps, bind_list, next_port, &port);
|
||||
} while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL));
|
||||
@ -1880,18 +1881,19 @@ retry:
|
||||
if (ret)
|
||||
goto err1;
|
||||
|
||||
if (port > sysctl_local_port_range[1]) {
|
||||
if (next_port != sysctl_local_port_range[0]) {
|
||||
inet_get_local_port_range(&low, &high);
|
||||
if (port > high) {
|
||||
if (next_port != low) {
|
||||
idr_remove(ps, port);
|
||||
next_port = sysctl_local_port_range[0];
|
||||
next_port = low;
|
||||
goto retry;
|
||||
}
|
||||
ret = -EADDRNOTAVAIL;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
if (port == sysctl_local_port_range[1])
|
||||
next_port = sysctl_local_port_range[0];
|
||||
if (port == high)
|
||||
next_port = low;
|
||||
else
|
||||
next_port = port + 1;
|
||||
|
||||
@ -2769,12 +2771,12 @@ static void cma_remove_one(struct ib_device *device)
|
||||
|
||||
static int cma_init(void)
|
||||
{
|
||||
int ret;
|
||||
int ret, low, high;
|
||||
|
||||
get_random_bytes(&next_port, sizeof next_port);
|
||||
next_port = ((unsigned int) next_port %
|
||||
(sysctl_local_port_range[1] - sysctl_local_port_range[0])) +
|
||||
sysctl_local_port_range[0];
|
||||
inet_get_local_port_range(&low, &high);
|
||||
next_port = ((unsigned int) next_port % (high - low)) + low;
|
||||
|
||||
cma_wq = create_singlethread_workqueue("rdma_cm");
|
||||
if (!cma_wq)
|
||||
return -ENOMEM;
|
||||
|
@ -886,7 +886,6 @@ static struct net_device *c2_devinit(struct c2_dev *c2dev,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SET_MODULE_OWNER(netdev);
|
||||
SET_NETDEV_DEV(netdev, &c2dev->pcidev->dev);
|
||||
|
||||
netdev->open = c2_up;
|
||||
|
@ -715,7 +715,6 @@ static int c2_pseudo_change_mtu(struct net_device *netdev, int new_mtu)
|
||||
|
||||
static void setup(struct net_device *netdev)
|
||||
{
|
||||
SET_MODULE_OWNER(netdev);
|
||||
netdev->open = c2_pseudo_up;
|
||||
netdev->stop = c2_pseudo_down;
|
||||
netdev->hard_start_xmit = c2_pseudo_xmit_frame;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <net/net_namespace.h>
|
||||
|
||||
#include "cxio_resource.h"
|
||||
#include "cxio_hal.h"
|
||||
@ -894,7 +895,7 @@ int cxio_rdev_open(struct cxio_rdev *rdev_p)
|
||||
if (cxio_hal_find_rdev_by_name(rdev_p->dev_name)) {
|
||||
return -EBUSY;
|
||||
}
|
||||
netdev_p = dev_get_by_name(rdev_p->dev_name);
|
||||
netdev_p = dev_get_by_name(&init_net, rdev_p->dev_name);
|
||||
if (!netdev_p) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -228,6 +228,8 @@ struct ipoib_dev_priv {
|
||||
|
||||
struct net_device *dev;
|
||||
|
||||
struct napi_struct napi;
|
||||
|
||||
unsigned long flags;
|
||||
|
||||
struct mutex mcast_mutex;
|
||||
@ -278,8 +280,6 @@ struct ipoib_dev_priv {
|
||||
|
||||
struct ib_event_handler event_handler;
|
||||
|
||||
struct net_device_stats stats;
|
||||
|
||||
struct net_device *parent;
|
||||
struct list_head child_intfs;
|
||||
struct list_head list;
|
||||
@ -351,7 +351,7 @@ extern struct workqueue_struct *ipoib_workqueue;
|
||||
|
||||
/* functions */
|
||||
|
||||
int ipoib_poll(struct net_device *dev, int *budget);
|
||||
int ipoib_poll(struct napi_struct *napi, int budget);
|
||||
void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr);
|
||||
|
||||
struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
|
||||
|
@ -430,7 +430,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
|
||||
ipoib_dbg(priv, "cm recv error "
|
||||
"(status=%d, wrid=%d vend_err %x)\n",
|
||||
wc->status, wr_id, wc->vendor_err);
|
||||
++priv->stats.rx_dropped;
|
||||
++dev->stats.rx_dropped;
|
||||
goto repost;
|
||||
}
|
||||
|
||||
@ -457,7 +457,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
|
||||
* this packet and reuse the old buffer.
|
||||
*/
|
||||
ipoib_dbg(priv, "failed to allocate receive buffer %d\n", wr_id);
|
||||
++priv->stats.rx_dropped;
|
||||
++dev->stats.rx_dropped;
|
||||
goto repost;
|
||||
}
|
||||
|
||||
@ -474,8 +474,8 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
|
||||
skb_pull(skb, IPOIB_ENCAP_LEN);
|
||||
|
||||
dev->last_rx = jiffies;
|
||||
++priv->stats.rx_packets;
|
||||
priv->stats.rx_bytes += skb->len;
|
||||
++dev->stats.rx_packets;
|
||||
dev->stats.rx_bytes += skb->len;
|
||||
|
||||
skb->dev = dev;
|
||||
/* XXX get correct PACKET_ type here */
|
||||
@ -512,8 +512,8 @@ void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_
|
||||
if (unlikely(skb->len > tx->mtu)) {
|
||||
ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n",
|
||||
skb->len, tx->mtu);
|
||||
++priv->stats.tx_dropped;
|
||||
++priv->stats.tx_errors;
|
||||
++dev->stats.tx_dropped;
|
||||
++dev->stats.tx_errors;
|
||||
ipoib_cm_skb_too_long(dev, skb, tx->mtu - IPOIB_ENCAP_LEN);
|
||||
return;
|
||||
}
|
||||
@ -532,7 +532,7 @@ void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_
|
||||
tx_req->skb = skb;
|
||||
addr = ib_dma_map_single(priv->ca, skb->data, skb->len, DMA_TO_DEVICE);
|
||||
if (unlikely(ib_dma_mapping_error(priv->ca, addr))) {
|
||||
++priv->stats.tx_errors;
|
||||
++dev->stats.tx_errors;
|
||||
dev_kfree_skb_any(skb);
|
||||
return;
|
||||
}
|
||||
@ -542,7 +542,7 @@ void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_
|
||||
if (unlikely(post_send(priv, tx, tx->tx_head & (ipoib_sendq_size - 1),
|
||||
addr, skb->len))) {
|
||||
ipoib_warn(priv, "post_send failed\n");
|
||||
++priv->stats.tx_errors;
|
||||
++dev->stats.tx_errors;
|
||||
ib_dma_unmap_single(priv->ca, addr, skb->len, DMA_TO_DEVICE);
|
||||
dev_kfree_skb_any(skb);
|
||||
} else {
|
||||
@ -580,8 +580,8 @@ static void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ipoib_cm_tx *tx
|
||||
ib_dma_unmap_single(priv->ca, tx_req->mapping, tx_req->skb->len, DMA_TO_DEVICE);
|
||||
|
||||
/* FIXME: is this right? Shouldn't we only increment on success? */
|
||||
++priv->stats.tx_packets;
|
||||
priv->stats.tx_bytes += tx_req->skb->len;
|
||||
++dev->stats.tx_packets;
|
||||
dev->stats.tx_bytes += tx_req->skb->len;
|
||||
|
||||
dev_kfree_skb_any(tx_req->skb);
|
||||
|
||||
|
@ -208,7 +208,7 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
|
||||
* this packet and reuse the old buffer.
|
||||
*/
|
||||
if (unlikely(ipoib_alloc_rx_skb(dev, wr_id))) {
|
||||
++priv->stats.rx_dropped;
|
||||
++dev->stats.rx_dropped;
|
||||
goto repost;
|
||||
}
|
||||
|
||||
@ -225,8 +225,8 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
|
||||
skb_pull(skb, IPOIB_ENCAP_LEN);
|
||||
|
||||
dev->last_rx = jiffies;
|
||||
++priv->stats.rx_packets;
|
||||
priv->stats.rx_bytes += skb->len;
|
||||
++dev->stats.rx_packets;
|
||||
dev->stats.rx_bytes += skb->len;
|
||||
|
||||
skb->dev = dev;
|
||||
/* XXX get correct PACKET_ type here */
|
||||
@ -260,8 +260,8 @@ static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
|
||||
ib_dma_unmap_single(priv->ca, tx_req->mapping,
|
||||
tx_req->skb->len, DMA_TO_DEVICE);
|
||||
|
||||
++priv->stats.tx_packets;
|
||||
priv->stats.tx_bytes += tx_req->skb->len;
|
||||
++dev->stats.tx_packets;
|
||||
dev->stats.tx_bytes += tx_req->skb->len;
|
||||
|
||||
dev_kfree_skb_any(tx_req->skb);
|
||||
|
||||
@ -281,63 +281,58 @@ static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
|
||||
wc->status, wr_id, wc->vendor_err);
|
||||
}
|
||||
|
||||
int ipoib_poll(struct net_device *dev, int *budget)
|
||||
int ipoib_poll(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
||||
int max = min(*budget, dev->quota);
|
||||
struct ipoib_dev_priv *priv = container_of(napi, struct ipoib_dev_priv, napi);
|
||||
struct net_device *dev = priv->dev;
|
||||
int done;
|
||||
int t;
|
||||
int empty;
|
||||
int n, i;
|
||||
|
||||
done = 0;
|
||||
empty = 0;
|
||||
|
||||
while (max) {
|
||||
poll_more:
|
||||
while (done < budget) {
|
||||
int max = (budget - done);
|
||||
|
||||
t = min(IPOIB_NUM_WC, max);
|
||||
n = ib_poll_cq(priv->cq, t, priv->ibwc);
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
for (i = 0; i < n; i++) {
|
||||
struct ib_wc *wc = priv->ibwc + i;
|
||||
|
||||
if (wc->wr_id & IPOIB_CM_OP_SRQ) {
|
||||
++done;
|
||||
--max;
|
||||
ipoib_cm_handle_rx_wc(dev, wc);
|
||||
} else if (wc->wr_id & IPOIB_OP_RECV) {
|
||||
++done;
|
||||
--max;
|
||||
ipoib_ib_handle_rx_wc(dev, wc);
|
||||
} else
|
||||
ipoib_ib_handle_tx_wc(dev, wc);
|
||||
}
|
||||
|
||||
if (n != t) {
|
||||
empty = 1;
|
||||
if (n != t)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dev->quota -= done;
|
||||
*budget -= done;
|
||||
|
||||
if (empty) {
|
||||
netif_rx_complete(dev);
|
||||
if (done < budget) {
|
||||
netif_rx_complete(dev, napi);
|
||||
if (unlikely(ib_req_notify_cq(priv->cq,
|
||||
IB_CQ_NEXT_COMP |
|
||||
IB_CQ_REPORT_MISSED_EVENTS)) &&
|
||||
netif_rx_reschedule(dev, 0))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
netif_rx_reschedule(dev, napi))
|
||||
goto poll_more;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return done;
|
||||
}
|
||||
|
||||
void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr)
|
||||
{
|
||||
netif_rx_schedule(dev_ptr);
|
||||
struct net_device *dev = dev_ptr;
|
||||
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
||||
|
||||
netif_rx_schedule(dev, &priv->napi);
|
||||
}
|
||||
|
||||
static inline int post_send(struct ipoib_dev_priv *priv,
|
||||
@ -367,8 +362,8 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
|
||||
if (unlikely(skb->len > priv->mcast_mtu + IPOIB_ENCAP_LEN)) {
|
||||
ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n",
|
||||
skb->len, priv->mcast_mtu + IPOIB_ENCAP_LEN);
|
||||
++priv->stats.tx_dropped;
|
||||
++priv->stats.tx_errors;
|
||||
++dev->stats.tx_dropped;
|
||||
++dev->stats.tx_errors;
|
||||
ipoib_cm_skb_too_long(dev, skb, priv->mcast_mtu);
|
||||
return;
|
||||
}
|
||||
@ -388,7 +383,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
|
||||
addr = ib_dma_map_single(priv->ca, skb->data, skb->len,
|
||||
DMA_TO_DEVICE);
|
||||
if (unlikely(ib_dma_mapping_error(priv->ca, addr))) {
|
||||
++priv->stats.tx_errors;
|
||||
++dev->stats.tx_errors;
|
||||
dev_kfree_skb_any(skb);
|
||||
return;
|
||||
}
|
||||
@ -397,7 +392,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
|
||||
if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size - 1),
|
||||
address->ah, qpn, addr, skb->len))) {
|
||||
ipoib_warn(priv, "post_send failed\n");
|
||||
++priv->stats.tx_errors;
|
||||
++dev->stats.tx_errors;
|
||||
ib_dma_unmap_single(priv->ca, addr, skb->len, DMA_TO_DEVICE);
|
||||
dev_kfree_skb_any(skb);
|
||||
} else {
|
||||
@ -577,7 +572,6 @@ int ipoib_ib_dev_stop(struct net_device *dev, int flush)
|
||||
int i;
|
||||
|
||||
clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
|
||||
netif_poll_disable(dev);
|
||||
|
||||
ipoib_cm_dev_stop(dev);
|
||||
|
||||
@ -660,7 +654,6 @@ timeout:
|
||||
msleep(1);
|
||||
}
|
||||
|
||||
netif_poll_enable(dev);
|
||||
ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP);
|
||||
|
||||
return 0;
|
||||
|
@ -98,16 +98,20 @@ int ipoib_open(struct net_device *dev)
|
||||
|
||||
ipoib_dbg(priv, "bringing up interface\n");
|
||||
|
||||
napi_enable(&priv->napi);
|
||||
set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags);
|
||||
|
||||
if (ipoib_pkey_dev_delay_open(dev))
|
||||
return 0;
|
||||
|
||||
if (ipoib_ib_dev_open(dev))
|
||||
if (ipoib_ib_dev_open(dev)) {
|
||||
napi_disable(&priv->napi);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ipoib_ib_dev_up(dev)) {
|
||||
ipoib_ib_dev_stop(dev, 1);
|
||||
napi_disable(&priv->napi);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -140,6 +144,7 @@ static int ipoib_stop(struct net_device *dev)
|
||||
ipoib_dbg(priv, "stopping interface\n");
|
||||
|
||||
clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags);
|
||||
napi_disable(&priv->napi);
|
||||
|
||||
netif_stop_queue(dev);
|
||||
|
||||
@ -512,7 +517,7 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
|
||||
|
||||
neigh = ipoib_neigh_alloc(skb->dst->neighbour);
|
||||
if (!neigh) {
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb);
|
||||
return;
|
||||
}
|
||||
@ -577,7 +582,7 @@ err_list:
|
||||
err_path:
|
||||
ipoib_neigh_free(dev, neigh);
|
||||
err_drop:
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb);
|
||||
|
||||
spin_unlock(&priv->lock);
|
||||
@ -626,7 +631,7 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
|
||||
} else
|
||||
__path_add(dev, path);
|
||||
} else {
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb);
|
||||
}
|
||||
|
||||
@ -645,7 +650,7 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
|
||||
skb_push(skb, sizeof *phdr);
|
||||
__skb_queue_tail(&path->queue, skb);
|
||||
} else {
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb);
|
||||
}
|
||||
|
||||
@ -713,7 +718,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
__skb_queue_tail(&neigh->queue, skb);
|
||||
spin_unlock(&priv->lock);
|
||||
} else {
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb);
|
||||
}
|
||||
} else {
|
||||
@ -739,7 +744,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
IPOIB_QPN(phdr->hwaddr),
|
||||
IPOIB_GID_RAW_ARG(phdr->hwaddr + 4));
|
||||
dev_kfree_skb_any(skb);
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -753,13 +758,6 @@ out:
|
||||
return NETDEV_TX_OK;
|
||||
}
|
||||
|
||||
static struct net_device_stats *ipoib_get_stats(struct net_device *dev)
|
||||
{
|
||||
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
||||
|
||||
return &priv->stats;
|
||||
}
|
||||
|
||||
static void ipoib_timeout(struct net_device *dev)
|
||||
{
|
||||
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
||||
@ -775,7 +773,7 @@ static void ipoib_timeout(struct net_device *dev)
|
||||
static int ipoib_hard_header(struct sk_buff *skb,
|
||||
struct net_device *dev,
|
||||
unsigned short type,
|
||||
void *daddr, void *saddr, unsigned len)
|
||||
const void *daddr, const void *saddr, unsigned len)
|
||||
{
|
||||
struct ipoib_header *header;
|
||||
|
||||
@ -856,11 +854,10 @@ struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neighbour)
|
||||
|
||||
void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh)
|
||||
{
|
||||
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
||||
struct sk_buff *skb;
|
||||
*to_ipoib_neigh(neigh->neighbour) = NULL;
|
||||
while ((skb = __skb_dequeue(&neigh->queue))) {
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb);
|
||||
}
|
||||
if (ipoib_cm_get(neigh))
|
||||
@ -935,6 +932,10 @@ void ipoib_dev_cleanup(struct net_device *dev)
|
||||
priv->tx_ring = NULL;
|
||||
}
|
||||
|
||||
static const struct header_ops ipoib_header_ops = {
|
||||
.create = ipoib_hard_header,
|
||||
};
|
||||
|
||||
static void ipoib_setup(struct net_device *dev)
|
||||
{
|
||||
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
||||
@ -943,13 +944,12 @@ static void ipoib_setup(struct net_device *dev)
|
||||
dev->stop = ipoib_stop;
|
||||
dev->change_mtu = ipoib_change_mtu;
|
||||
dev->hard_start_xmit = ipoib_start_xmit;
|
||||
dev->get_stats = ipoib_get_stats;
|
||||
dev->tx_timeout = ipoib_timeout;
|
||||
dev->hard_header = ipoib_hard_header;
|
||||
dev->header_ops = &ipoib_header_ops;
|
||||
dev->set_multicast_list = ipoib_set_mcast_list;
|
||||
dev->neigh_setup = ipoib_neigh_setup_dev;
|
||||
dev->poll = ipoib_poll;
|
||||
dev->weight = 100;
|
||||
|
||||
netif_napi_add(dev, &priv->napi, ipoib_poll, 100);
|
||||
|
||||
dev->watchdog_timeo = HZ;
|
||||
|
||||
@ -973,8 +973,6 @@ static void ipoib_setup(struct net_device *dev)
|
||||
|
||||
netif_carrier_off(dev);
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
priv->dev = dev;
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
|
@ -125,7 +125,7 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&priv->tx_lock, flags);
|
||||
priv->stats.tx_dropped += tx_dropped;
|
||||
dev->stats.tx_dropped += tx_dropped;
|
||||
spin_unlock_irqrestore(&priv->tx_lock, flags);
|
||||
|
||||
kfree(mcast);
|
||||
@ -320,7 +320,7 @@ ipoib_mcast_sendonly_join_complete(int status,
|
||||
/* Flush out any queued packets */
|
||||
spin_lock_irq(&priv->tx_lock);
|
||||
while (!skb_queue_empty(&mcast->pkt_queue)) {
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb_dequeue(&mcast->pkt_queue));
|
||||
}
|
||||
spin_unlock_irq(&priv->tx_lock);
|
||||
@ -675,7 +675,7 @@ void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb)
|
||||
if (!test_bit(IPOIB_MCAST_STARTED, &priv->flags) ||
|
||||
!priv->broadcast ||
|
||||
!test_bit(IPOIB_MCAST_FLAG_ATTACHED, &priv->broadcast->flags)) {
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb);
|
||||
goto unlock;
|
||||
}
|
||||
@ -690,7 +690,7 @@ void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb)
|
||||
if (!mcast) {
|
||||
ipoib_warn(priv, "unable to allocate memory for "
|
||||
"multicast structure\n");
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb);
|
||||
goto out;
|
||||
}
|
||||
@ -705,7 +705,7 @@ void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb)
|
||||
if (skb_queue_len(&mcast->pkt_queue) < IPOIB_MAX_MCAST_QUEUE)
|
||||
skb_queue_tail(&mcast->pkt_queue, skb);
|
||||
else {
|
||||
++priv->stats.tx_dropped;
|
||||
++dev->stats.tx_dropped;
|
||||
dev_kfree_skb_any(skb);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <linux/fs.h>
|
||||
#endif
|
||||
#include <linux/isdnif.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include "isdn_divert.h"
|
||||
|
||||
|
||||
@ -284,12 +285,12 @@ divert_dev_init(void)
|
||||
init_waitqueue_head(&rd_queue);
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
isdn_proc_entry = proc_mkdir("net/isdn", NULL);
|
||||
isdn_proc_entry = proc_mkdir("isdn", init_net.proc_net);
|
||||
if (!isdn_proc_entry)
|
||||
return (-1);
|
||||
isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry);
|
||||
if (!isdn_divert_entry) {
|
||||
remove_proc_entry("net/isdn", NULL);
|
||||
remove_proc_entry("isdn", init_net.proc_net);
|
||||
return (-1);
|
||||
}
|
||||
isdn_divert_entry->proc_fops = &isdn_fops;
|
||||
@ -309,7 +310,7 @@ divert_dev_deinit(void)
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
remove_proc_entry("divert", isdn_proc_entry);
|
||||
remove_proc_entry("net/isdn", NULL);
|
||||
remove_proc_entry("isdn", init_net.proc_net);
|
||||
#endif /* CONFIG_PROC_FS */
|
||||
|
||||
return (0);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <net/net_namespace.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "di_defs.h"
|
||||
@ -86,7 +87,7 @@ proc_read(char *page, char **start, off_t off, int count, int *eof,
|
||||
|
||||
static int DIVA_INIT_FUNCTION create_proc(void)
|
||||
{
|
||||
proc_net_eicon = proc_mkdir("net/eicon", NULL);
|
||||
proc_net_eicon = proc_mkdir("eicon", init_net.proc_net);
|
||||
|
||||
if (proc_net_eicon) {
|
||||
if ((proc_didd =
|
||||
@ -102,7 +103,7 @@ static int DIVA_INIT_FUNCTION create_proc(void)
|
||||
static void remove_proc(void)
|
||||
{
|
||||
remove_proc_entry(DRIVERLNAME, proc_net_eicon);
|
||||
remove_proc_entry("net/eicon", NULL);
|
||||
remove_proc_entry("eicon", init_net.proc_net);
|
||||
}
|
||||
|
||||
static int DIVA_INIT_FUNCTION divadidd_init(void)
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/smp_lock.h>
|
||||
#include <net/net_namespace.h>
|
||||
|
||||
#include "hysdn_defs.h"
|
||||
|
||||
@ -392,7 +393,7 @@ hysdn_procconf_init(void)
|
||||
hysdn_card *card;
|
||||
unsigned char conf_name[20];
|
||||
|
||||
hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net);
|
||||
hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, init_net.proc_net);
|
||||
if (!hysdn_proc_entry) {
|
||||
printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n");
|
||||
return (-1);
|
||||
@ -437,5 +438,5 @@ hysdn_procconf_release(void)
|
||||
card = card->next; /* point to next card */
|
||||
}
|
||||
|
||||
remove_proc_entry(PROC_SUBDIR_NAME, proc_net);
|
||||
remove_proc_entry(PROC_SUBDIR_NAME, init_net.proc_net);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ static __inline__ int isdn_net_device_started(isdn_net_dev *n)
|
||||
if (lp->master)
|
||||
dev = lp->master;
|
||||
else
|
||||
dev = &n->dev;
|
||||
dev = n->dev;
|
||||
return netif_running(dev);
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ static __inline__ void isdn_net_device_wake_queue(isdn_net_local *lp)
|
||||
if (lp->master)
|
||||
netif_wake_queue(lp->master);
|
||||
else
|
||||
netif_wake_queue(&lp->netdev->dev);
|
||||
netif_wake_queue(lp->netdev->dev);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -102,7 +102,7 @@ static __inline__ void isdn_net_device_stop_queue(isdn_net_local *lp)
|
||||
if (lp->master)
|
||||
netif_stop_queue(lp->master);
|
||||
else
|
||||
netif_stop_queue(&lp->netdev->dev);
|
||||
netif_stop_queue(lp->netdev->dev);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -287,7 +287,7 @@ isdn_net_unbind_channel(isdn_net_local * lp)
|
||||
BEWARE! This chunk of code cannot be called from hardware
|
||||
interrupt handler. I hope it is true. --ANK
|
||||
*/
|
||||
qdisc_reset(lp->netdev->dev.qdisc);
|
||||
qdisc_reset(lp->netdev->dev->qdisc);
|
||||
}
|
||||
lp->dialstate = 0;
|
||||
dev->rx_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL;
|
||||
@ -345,27 +345,27 @@ isdn_net_autohup(void)
|
||||
l->chargetime += l->chargeint;
|
||||
if (time_after(jiffies, l->chargetime + l->chargeint - 2 * HZ))
|
||||
if (l->outgoing || l->hupflags & ISDN_INHUP)
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
} else if (l->outgoing) {
|
||||
if (l->hupflags & ISDN_CHARGEHUP) {
|
||||
if (l->hupflags & ISDN_WAITCHARGE) {
|
||||
printk(KERN_DEBUG "isdn_net: Hupflags of %s are %X\n",
|
||||
l->name, l->hupflags);
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
} else if (time_after(jiffies, l->chargetime + l->chargeint)) {
|
||||
printk(KERN_DEBUG
|
||||
"isdn_net: %s: chtime = %lu, chint = %d\n",
|
||||
l->name, l->chargetime, l->chargeint);
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
}
|
||||
} else
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
} else if (l->hupflags & ISDN_INHUP)
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
}
|
||||
|
||||
if(dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*l) == ISDN_NET_DM_OFF)) {
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -579,7 +579,7 @@ isdn_net_dial(void)
|
||||
if (!lp->dial) {
|
||||
printk(KERN_WARNING "%s: phone number deleted?\n",
|
||||
lp->name);
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
break;
|
||||
}
|
||||
anymore = 1;
|
||||
@ -616,8 +616,8 @@ isdn_net_dial(void)
|
||||
s = "dial suppressed: isdn system stopped";
|
||||
else
|
||||
s = "dial suppressed: dialmode `off'";
|
||||
isdn_net_unreachable(&p->dev, NULL, s);
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_unreachable(p->dev, NULL, s);
|
||||
isdn_net_hangup(p->dev);
|
||||
break;
|
||||
}
|
||||
cmd.driver = lp->isdn_device;
|
||||
@ -633,7 +633,7 @@ isdn_net_dial(void)
|
||||
if (!lp->dial) {
|
||||
printk(KERN_WARNING "%s: phone number deleted?\n",
|
||||
lp->name);
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
break;
|
||||
}
|
||||
if (!strncmp(lp->dial->num, "LEASED", strlen("LEASED"))) {
|
||||
@ -644,8 +644,8 @@ isdn_net_dial(void)
|
||||
if (time_after(jiffies, lp->dialstarted + lp->dialtimeout)) {
|
||||
lp->dialwait_timer = jiffies + lp->dialwait;
|
||||
lp->dialstarted = 0;
|
||||
isdn_net_unreachable(&p->dev, NULL, "dial: timed out");
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_unreachable(p->dev, NULL, "dial: timed out");
|
||||
isdn_net_hangup(p->dev);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -674,9 +674,9 @@ isdn_net_dial(void)
|
||||
if (lp->dialtimeout == 0) {
|
||||
lp->dialwait_timer = jiffies + lp->dialwait;
|
||||
lp->dialstarted = 0;
|
||||
isdn_net_unreachable(&p->dev, NULL, "dial: tried all numbers dialmax times");
|
||||
isdn_net_unreachable(p->dev, NULL, "dial: tried all numbers dialmax times");
|
||||
}
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -758,7 +758,7 @@ isdn_net_dial(void)
|
||||
cmd.arg = lp->isdn_channel + (lp->l3_proto << 8);
|
||||
isdn_command(&cmd);
|
||||
if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT15)
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
else {
|
||||
anymore = 1;
|
||||
lp->dialstate++;
|
||||
@ -781,7 +781,7 @@ isdn_net_dial(void)
|
||||
printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer);
|
||||
#endif
|
||||
if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10)
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
else
|
||||
anymore = 1;
|
||||
break;
|
||||
@ -1618,7 +1618,7 @@ isdn_net_ciscohdlck_slarp_send_reply(isdn_net_local *lp)
|
||||
__be32 addr = 0; /* local ipv4 address */
|
||||
__be32 mask = 0; /* local netmask */
|
||||
|
||||
if ((in_dev = lp->netdev->dev.ip_ptr) != NULL) {
|
||||
if ((in_dev = lp->netdev->dev->ip_ptr) != NULL) {
|
||||
/* take primary(first) address of interface */
|
||||
struct in_ifaddr *ifa = in_dev->ifa_list;
|
||||
if (ifa != NULL) {
|
||||
@ -1866,61 +1866,21 @@ isdn_net_rcv_skb(int idx, struct sk_buff *skb)
|
||||
isdn_net_local *lp = p->local;
|
||||
if ((lp->flags & ISDN_NET_CONNECTED) &&
|
||||
(!lp->dialstate)) {
|
||||
isdn_net_receive(&p->dev, skb);
|
||||
isdn_net_receive(p->dev, skb);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
my_eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
|
||||
void *daddr, void *saddr, unsigned len)
|
||||
{
|
||||
struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
|
||||
|
||||
/*
|
||||
* Set the protocol type. For a packet of type ETH_P_802_3 we
|
||||
* put the length here instead. It is up to the 802.2 layer to
|
||||
* carry protocol information.
|
||||
*/
|
||||
|
||||
if (type != ETH_P_802_3)
|
||||
eth->h_proto = htons(type);
|
||||
else
|
||||
eth->h_proto = htons(len);
|
||||
|
||||
/*
|
||||
* Set the source hardware address.
|
||||
*/
|
||||
if (saddr)
|
||||
memcpy(eth->h_source, saddr, dev->addr_len);
|
||||
else
|
||||
memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
|
||||
|
||||
/*
|
||||
* Anyway, the loopback-device should never use this function...
|
||||
*/
|
||||
|
||||
if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
|
||||
memset(eth->h_dest, 0, dev->addr_len);
|
||||
return ETH_HLEN /*(dev->hard_header_len)*/;
|
||||
}
|
||||
if (daddr) {
|
||||
memcpy(eth->h_dest, daddr, dev->addr_len);
|
||||
return ETH_HLEN /*dev->hard_header_len*/;
|
||||
}
|
||||
return -ETH_HLEN /*dev->hard_header_len*/;
|
||||
}
|
||||
|
||||
/*
|
||||
* build an header
|
||||
* depends on encaps that is being used.
|
||||
*/
|
||||
|
||||
static int
|
||||
isdn_net_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
|
||||
void *daddr, void *saddr, unsigned plen)
|
||||
static int isdn_net_header(struct sk_buff *skb, struct net_device *dev,
|
||||
unsigned short type,
|
||||
const void *daddr, const void *saddr, unsigned plen)
|
||||
{
|
||||
isdn_net_local *lp = dev->priv;
|
||||
unsigned char *p;
|
||||
@ -1928,7 +1888,7 @@ isdn_net_header(struct sk_buff *skb, struct net_device *dev, unsigned short type
|
||||
|
||||
switch (lp->p_encap) {
|
||||
case ISDN_NET_ENCAP_ETHER:
|
||||
len = my_eth_header(skb, dev, type, daddr, saddr, plen);
|
||||
len = eth_header(skb, dev, type, daddr, saddr, plen);
|
||||
break;
|
||||
#ifdef CONFIG_ISDN_PPP
|
||||
case ISDN_NET_ENCAP_SYNCPPP:
|
||||
@ -2005,6 +1965,32 @@ isdn_net_rebuild_header(struct sk_buff *skb)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int isdn_header_cache(const struct neighbour *neigh, struct hh_cache *hh)
|
||||
{
|
||||
const struct net_device *dev = neigh->dev;
|
||||
isdn_net_local *lp = dev->priv;
|
||||
|
||||
if (lp->p_encap == ISDN_NET_ENCAP_ETHER)
|
||||
return eth_header_cache(neigh, hh);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void isdn_header_cache_update(struct hh_cache *hh,
|
||||
const struct net_device *dev,
|
||||
const unsigned char *haddr)
|
||||
{
|
||||
isdn_net_local *lp = dev->priv;
|
||||
if (lp->p_encap == ISDN_NET_ENCAP_ETHER)
|
||||
return eth_header_cache_update(hh, dev, haddr);
|
||||
}
|
||||
|
||||
static const struct header_ops isdn_header_ops = {
|
||||
.create = isdn_net_header,
|
||||
.rebuild = isdn_net_rebuild_header,
|
||||
.cache = isdn_header_cache,
|
||||
.cache_update = isdn_header_cache_update,
|
||||
};
|
||||
|
||||
/*
|
||||
* Interface-setup. (just after registering a new interface)
|
||||
*/
|
||||
@ -2012,18 +1998,12 @@ static int
|
||||
isdn_net_init(struct net_device *ndev)
|
||||
{
|
||||
ushort max_hlhdr_len = 0;
|
||||
isdn_net_local *lp = (isdn_net_local *) ndev->priv;
|
||||
int drvidx, i;
|
||||
int drvidx;
|
||||
|
||||
ether_setup(ndev);
|
||||
lp->org_hhc = ndev->hard_header_cache;
|
||||
lp->org_hcu = ndev->header_cache_update;
|
||||
ndev->header_ops = NULL;
|
||||
|
||||
/* Setup the generic properties */
|
||||
|
||||
ndev->hard_header = NULL;
|
||||
ndev->hard_header_cache = NULL;
|
||||
ndev->header_cache_update = NULL;
|
||||
ndev->mtu = 1500;
|
||||
ndev->flags = IFF_NOARP|IFF_POINTOPOINT;
|
||||
ndev->type = ARPHRD_ETHER;
|
||||
@ -2032,9 +2012,6 @@ isdn_net_init(struct net_device *ndev)
|
||||
/* for clients with MPPP maybe higher values better */
|
||||
ndev->tx_queue_len = 30;
|
||||
|
||||
for (i = 0; i < ETH_ALEN; i++)
|
||||
ndev->broadcast[i] = 0xff;
|
||||
|
||||
/* The ISDN-specific entries in the device structure. */
|
||||
ndev->open = &isdn_net_open;
|
||||
ndev->hard_start_xmit = &isdn_net_start_xmit;
|
||||
@ -2052,7 +2029,6 @@ isdn_net_init(struct net_device *ndev)
|
||||
ndev->hard_header_len = ETH_HLEN + max_hlhdr_len;
|
||||
ndev->stop = &isdn_net_close;
|
||||
ndev->get_stats = &isdn_net_get_stats;
|
||||
ndev->rebuild_header = &isdn_net_rebuild_header;
|
||||
ndev->do_ioctl = NULL;
|
||||
return 0;
|
||||
}
|
||||
@ -2530,6 +2506,42 @@ isdn_net_force_dial(char *name)
|
||||
return (isdn_net_force_dial_lp(p->local));
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper for alloc_netdev()
|
||||
*/
|
||||
static void _isdn_setup(struct net_device *dev)
|
||||
{
|
||||
isdn_net_local *lp = dev->priv;
|
||||
|
||||
dev->flags = IFF_NOARP | IFF_POINTOPOINT;
|
||||
lp->p_encap = ISDN_NET_ENCAP_RAWIP;
|
||||
lp->magic = ISDN_NET_MAGIC;
|
||||
lp->last = lp;
|
||||
lp->next = lp;
|
||||
lp->isdn_device = -1;
|
||||
lp->isdn_channel = -1;
|
||||
lp->pre_device = -1;
|
||||
lp->pre_channel = -1;
|
||||
lp->exclusive = -1;
|
||||
lp->ppp_slot = -1;
|
||||
lp->pppbind = -1;
|
||||
skb_queue_head_init(&lp->super_tx_queue);
|
||||
lp->l2_proto = ISDN_PROTO_L2_X75I;
|
||||
lp->l3_proto = ISDN_PROTO_L3_TRANS;
|
||||
lp->triggercps = 6000;
|
||||
lp->slavedelay = 10 * HZ;
|
||||
lp->hupflags = ISDN_INHUP; /* Do hangup even on incoming calls */
|
||||
lp->onhtime = 10; /* Default hangup-time for saving costs */
|
||||
lp->dialmax = 1;
|
||||
/* Hangup before Callback, manual dial */
|
||||
lp->flags = ISDN_NET_CBHUP | ISDN_NET_DM_MANUAL;
|
||||
lp->cbdelay = 25; /* Wait 5 secs before Callback */
|
||||
lp->dialtimeout = -1; /* Infinite Dial-Timeout */
|
||||
lp->dialwait = 5 * HZ; /* Wait 5 sec. after failed dial */
|
||||
lp->dialstarted = 0; /* Jiffies of last dial-start */
|
||||
lp->dialwait_timer = 0; /* Jiffies of earliest next dial-start */
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new network-interface and initialize its data structures.
|
||||
*/
|
||||
@ -2543,23 +2555,21 @@ isdn_net_new(char *name, struct net_device *master)
|
||||
printk(KERN_WARNING "isdn_net: interface %s already exists\n", name);
|
||||
return NULL;
|
||||
}
|
||||
if (name == NULL)
|
||||
name = " ";
|
||||
if (!(netdev = kzalloc(sizeof(isdn_net_dev), GFP_KERNEL))) {
|
||||
printk(KERN_WARNING "isdn_net: Could not allocate net-device\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!(netdev->local = kzalloc(sizeof(isdn_net_local), GFP_KERNEL))) {
|
||||
printk(KERN_WARNING "isdn_net: Could not allocate device locals\n");
|
||||
netdev->dev = alloc_netdev(sizeof(isdn_net_local), name, _isdn_setup);
|
||||
if (!netdev->dev) {
|
||||
printk(KERN_WARNING "isdn_net: Could not allocate network device\n");
|
||||
kfree(netdev);
|
||||
return NULL;
|
||||
}
|
||||
if (name == NULL)
|
||||
strcpy(netdev->local->name, " ");
|
||||
else
|
||||
strcpy(netdev->local->name, name);
|
||||
strcpy(netdev->dev.name, netdev->local->name);
|
||||
netdev->dev.priv = netdev->local;
|
||||
netdev->dev.init = isdn_net_init;
|
||||
netdev->local->p_encap = ISDN_NET_ENCAP_RAWIP;
|
||||
netdev->local = netdev->dev->priv;
|
||||
strcpy(netdev->local->name, netdev->dev->name);
|
||||
netdev->dev->init = isdn_net_init;
|
||||
if (master) {
|
||||
/* Device shall be a slave */
|
||||
struct net_device *p = (((isdn_net_local *) master->priv)->slave);
|
||||
@ -2571,60 +2581,33 @@ isdn_net_new(char *name, struct net_device *master)
|
||||
q = p;
|
||||
p = (((isdn_net_local *) p->priv)->slave);
|
||||
}
|
||||
((isdn_net_local *) q->priv)->slave = &(netdev->dev);
|
||||
((isdn_net_local *) q->priv)->slave = netdev->dev;
|
||||
} else {
|
||||
/* Device shall be a master */
|
||||
/*
|
||||
* Watchdog timer (currently) for master only.
|
||||
*/
|
||||
netdev->dev.tx_timeout = isdn_net_tx_timeout;
|
||||
netdev->dev.watchdog_timeo = ISDN_NET_TX_TIMEOUT;
|
||||
if (register_netdev(&netdev->dev) != 0) {
|
||||
netdev->dev->tx_timeout = isdn_net_tx_timeout;
|
||||
netdev->dev->watchdog_timeo = ISDN_NET_TX_TIMEOUT;
|
||||
if (register_netdev(netdev->dev) != 0) {
|
||||
printk(KERN_WARNING "isdn_net: Could not register net-device\n");
|
||||
kfree(netdev->local);
|
||||
free_netdev(netdev->dev);
|
||||
kfree(netdev);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
netdev->local->magic = ISDN_NET_MAGIC;
|
||||
|
||||
netdev->queue = netdev->local;
|
||||
spin_lock_init(&netdev->queue_lock);
|
||||
|
||||
netdev->local->last = netdev->local;
|
||||
netdev->local->netdev = netdev;
|
||||
netdev->local->next = netdev->local;
|
||||
|
||||
INIT_WORK(&netdev->local->tqueue, isdn_net_softint);
|
||||
spin_lock_init(&netdev->local->xmit_lock);
|
||||
|
||||
netdev->local->isdn_device = -1;
|
||||
netdev->local->isdn_channel = -1;
|
||||
netdev->local->pre_device = -1;
|
||||
netdev->local->pre_channel = -1;
|
||||
netdev->local->exclusive = -1;
|
||||
netdev->local->ppp_slot = -1;
|
||||
netdev->local->pppbind = -1;
|
||||
skb_queue_head_init(&netdev->local->super_tx_queue);
|
||||
netdev->local->l2_proto = ISDN_PROTO_L2_X75I;
|
||||
netdev->local->l3_proto = ISDN_PROTO_L3_TRANS;
|
||||
netdev->local->triggercps = 6000;
|
||||
netdev->local->slavedelay = 10 * HZ;
|
||||
netdev->local->hupflags = ISDN_INHUP; /* Do hangup even on incoming calls */
|
||||
netdev->local->onhtime = 10; /* Default hangup-time for saving costs
|
||||
of those who forget configuring this */
|
||||
netdev->local->dialmax = 1;
|
||||
netdev->local->flags = ISDN_NET_CBHUP | ISDN_NET_DM_MANUAL; /* Hangup before Callback, manual dial */
|
||||
netdev->local->cbdelay = 25; /* Wait 5 secs before Callback */
|
||||
netdev->local->dialtimeout = -1; /* Infinite Dial-Timeout */
|
||||
netdev->local->dialwait = 5 * HZ; /* Wait 5 sec. after failed dial */
|
||||
netdev->local->dialstarted = 0; /* Jiffies of last dial-start */
|
||||
netdev->local->dialwait_timer = 0; /* Jiffies of earliest next dial-start */
|
||||
|
||||
/* Put into to netdev-chain */
|
||||
netdev->next = (void *) dev->netdev;
|
||||
dev->netdev = netdev;
|
||||
return netdev->dev.name;
|
||||
return netdev->dev->name;
|
||||
}
|
||||
|
||||
char *
|
||||
@ -2649,7 +2632,7 @@ isdn_net_newslave(char *parm)
|
||||
/* Master must not be started yet */
|
||||
if (isdn_net_device_started(n))
|
||||
return NULL;
|
||||
return (isdn_net_new(newname, &(n->dev)));
|
||||
return (isdn_net_new(newname, n->dev));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -2718,9 +2701,9 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
|
||||
lp->name);
|
||||
return -EINVAL;
|
||||
#else
|
||||
p->dev.type = ARPHRD_PPP; /* change ARP type */
|
||||
p->dev.addr_len = 0;
|
||||
p->dev.do_ioctl = isdn_ppp_dev_ioctl;
|
||||
p->dev->type = ARPHRD_PPP; /* change ARP type */
|
||||
p->dev->addr_len = 0;
|
||||
p->dev->do_ioctl = isdn_ppp_dev_ioctl;
|
||||
#endif
|
||||
break;
|
||||
case ISDN_NET_ENCAP_X25IFACE:
|
||||
@ -2729,12 +2712,12 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
|
||||
p->local->name);
|
||||
return -EINVAL;
|
||||
#else
|
||||
p->dev.type = ARPHRD_X25; /* change ARP type */
|
||||
p->dev.addr_len = 0;
|
||||
p->dev->type = ARPHRD_X25; /* change ARP type */
|
||||
p->dev->addr_len = 0;
|
||||
#endif
|
||||
break;
|
||||
case ISDN_NET_ENCAP_CISCOHDLCK:
|
||||
p->dev.do_ioctl = isdn_ciscohdlck_dev_ioctl;
|
||||
p->dev->do_ioctl = isdn_ciscohdlck_dev_ioctl;
|
||||
break;
|
||||
default:
|
||||
if( cfg->p_encap >= 0 &&
|
||||
@ -2861,21 +2844,14 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
|
||||
}
|
||||
if (cfg->p_encap != lp->p_encap) {
|
||||
if (cfg->p_encap == ISDN_NET_ENCAP_RAWIP) {
|
||||
p->dev.hard_header = NULL;
|
||||
p->dev.hard_header_cache = NULL;
|
||||
p->dev.header_cache_update = NULL;
|
||||
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
|
||||
p->dev->header_ops = NULL;
|
||||
p->dev->flags = IFF_NOARP|IFF_POINTOPOINT;
|
||||
} else {
|
||||
p->dev.hard_header = isdn_net_header;
|
||||
if (cfg->p_encap == ISDN_NET_ENCAP_ETHER) {
|
||||
p->dev.hard_header_cache = lp->org_hhc;
|
||||
p->dev.header_cache_update = lp->org_hcu;
|
||||
p->dev.flags = IFF_BROADCAST | IFF_MULTICAST;
|
||||
} else {
|
||||
p->dev.hard_header_cache = NULL;
|
||||
p->dev.header_cache_update = NULL;
|
||||
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
|
||||
}
|
||||
p->dev->header_ops = &isdn_header_ops;
|
||||
if (cfg->p_encap == ISDN_NET_ENCAP_ETHER)
|
||||
p->dev->flags = IFF_BROADCAST | IFF_MULTICAST;
|
||||
else
|
||||
p->dev->flags = IFF_NOARP|IFF_POINTOPOINT;
|
||||
}
|
||||
}
|
||||
lp->p_encap = cfg->p_encap;
|
||||
@ -3095,7 +3071,7 @@ isdn_net_force_hangup(char *name)
|
||||
isdn_net_hangup(q);
|
||||
q = (((isdn_net_local *) q->priv)->slave);
|
||||
}
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
return 0;
|
||||
}
|
||||
return -ENODEV;
|
||||
@ -3123,13 +3099,11 @@ isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q)
|
||||
isdn_unexclusive_channel(p->local->pre_device, p->local->pre_channel);
|
||||
if (p->local->master) {
|
||||
/* It's a slave-device, so update master's slave-pointer if necessary */
|
||||
if (((isdn_net_local *) (p->local->master->priv))->slave == &p->dev)
|
||||
if (((isdn_net_local *) (p->local->master->priv))->slave == p->dev)
|
||||
((isdn_net_local *) (p->local->master->priv))->slave = p->local->slave;
|
||||
} else {
|
||||
/* Unregister only if it's a master-device */
|
||||
p->dev.hard_header_cache = p->local->org_hhc;
|
||||
p->dev.header_cache_update = p->local->org_hcu;
|
||||
unregister_netdev(&p->dev);
|
||||
unregister_netdev(p->dev);
|
||||
}
|
||||
/* Unlink device from chain */
|
||||
spin_lock_irqsave(&dev->lock, flags);
|
||||
@ -3157,7 +3131,7 @@ isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q)
|
||||
/* If no more net-devices remain, disable auto-hangup timer */
|
||||
if (dev->netdev == NULL)
|
||||
isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 0);
|
||||
kfree(p->local);
|
||||
free_netdev(p->dev);
|
||||
kfree(p);
|
||||
|
||||
return 0;
|
||||
|
@ -360,7 +360,7 @@ isdn_ppp_release(int min, struct file *file)
|
||||
* isdn_ppp_free() sets is->lp to NULL and lp->ppp_slot to -1
|
||||
* removing the IPPP_CONNECT flag omits calling of isdn_ppp_wakeup_daemon()
|
||||
*/
|
||||
isdn_net_hangup(&p->dev);
|
||||
isdn_net_hangup(p->dev);
|
||||
}
|
||||
for (i = 0; i < NUM_RCV_BUFFS; i++) {
|
||||
kfree(is->rq[i].buf);
|
||||
@ -531,7 +531,7 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
|
||||
if (lp) {
|
||||
/* OK .. we are ready to send buffers */
|
||||
is->pppcfg = val; /* isdn_ppp_xmit test for SC_ENABLE_IP !!! */
|
||||
netif_wake_queue(&lp->netdev->dev);
|
||||
netif_wake_queue(lp->netdev->dev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1023,7 +1023,7 @@ void isdn_ppp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buf
|
||||
static void
|
||||
isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff *skb, int proto)
|
||||
{
|
||||
struct net_device *dev = &net_dev->dev;
|
||||
struct net_device *dev = net_dev->dev;
|
||||
struct ippp_struct *is, *mis;
|
||||
isdn_net_local *mlp = NULL;
|
||||
int slot;
|
||||
|
@ -1220,10 +1220,17 @@ static struct net_device_stats * dvb_net_get_stats(struct net_device *dev)
|
||||
return &((struct dvb_net_priv*) dev->priv)->stats;
|
||||
}
|
||||
|
||||
static const struct header_ops dvb_header_ops = {
|
||||
.create = eth_header,
|
||||
.parse = eth_header_parse,
|
||||
.rebuild = eth_rebuild_header,
|
||||
};
|
||||
|
||||
static void dvb_net_setup(struct net_device *dev)
|
||||
{
|
||||
ether_setup(dev);
|
||||
|
||||
dev->header_ops = &dvb_header_ops;
|
||||
dev->open = dvb_net_open;
|
||||
dev->stop = dvb_net_stop;
|
||||
dev->hard_start_xmit = dvb_net_tx;
|
||||
@ -1232,7 +1239,7 @@ static void dvb_net_setup(struct net_device *dev)
|
||||
dev->set_mac_address = dvb_net_set_mac;
|
||||
dev->mtu = 4096;
|
||||
dev->mc_count = 0;
|
||||
dev->hard_header_cache = NULL;
|
||||
|
||||
dev->flags |= IFF_NOARP;
|
||||
}
|
||||
|
||||
|
@ -1427,8 +1427,6 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
|
||||
dlprintk((KERN_INFO MYNAM ": Finished registering dev "
|
||||
"and setting initial values\n"));
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
if (register_netdev(dev) != 0) {
|
||||
free_netdev(dev);
|
||||
dev = NULL;
|
||||
|
@ -174,8 +174,6 @@ struct net_device * __init el1_probe(int unit)
|
||||
mem_start = dev->mem_start & 7;
|
||||
}
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
if (io > 0x1ff) { /* Check a single specified location. */
|
||||
err = el1_probe1(dev, io);
|
||||
} else if (io != 0) {
|
||||
@ -317,7 +315,6 @@ static int __init el1_probe1(struct net_device *dev, int ioaddr)
|
||||
dev->tx_timeout = &el_timeout;
|
||||
dev->watchdog_timeo = HZ;
|
||||
dev->stop = &el1_close;
|
||||
dev->get_stats = &el1_get_stats;
|
||||
dev->set_multicast_list = &set_multicast_list;
|
||||
dev->ethtool_ops = &netdev_ethtool_ops;
|
||||
return 0;
|
||||
@ -376,7 +373,7 @@ static void el_timeout(struct net_device *dev)
|
||||
if (el_debug)
|
||||
printk (KERN_DEBUG "%s: transmit timed out, txsr %#2x axsr=%02x rxsr=%02x.\n",
|
||||
dev->name, inb(TX_STATUS), inb(AX_STATUS), inb(RX_STATUS));
|
||||
lp->stats.tx_errors++;
|
||||
dev->stats.tx_errors++;
|
||||
outb(TX_NORM, TX_CMD);
|
||||
outb(RX_NORM, RX_CMD);
|
||||
outb(AX_OFF, AX_CMD); /* Just trigger a false interrupt. */
|
||||
@ -443,7 +440,7 @@ static int el_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
lp->tx_pkt_start = gp_start;
|
||||
lp->collisions = 0;
|
||||
|
||||
lp->stats.tx_bytes += skb->len;
|
||||
dev->stats.tx_bytes += skb->len;
|
||||
|
||||
/*
|
||||
* Command mode with status cleared should [in theory]
|
||||
@ -590,7 +587,7 @@ static irqreturn_t el_interrupt(int irq, void *dev_id)
|
||||
printk (KERN_DEBUG "%s: Transmit failed 16 times, Ethernet jammed?\n",dev->name);
|
||||
outb(AX_SYS, AX_CMD);
|
||||
lp->txing = 0;
|
||||
lp->stats.tx_aborted_errors++;
|
||||
dev->stats.tx_aborted_errors++;
|
||||
netif_wake_queue(dev);
|
||||
}
|
||||
else if (txsr & TX_COLLISION)
|
||||
@ -608,7 +605,7 @@ static irqreturn_t el_interrupt(int irq, void *dev_id)
|
||||
outb(AX_SYS, AX_CMD);
|
||||
outw(lp->tx_pkt_start, GP_LOW);
|
||||
outb(AX_XMIT, AX_CMD);
|
||||
lp->stats.collisions++;
|
||||
dev->stats.collisions++;
|
||||
spin_unlock(&lp->lock);
|
||||
goto out;
|
||||
}
|
||||
@ -617,7 +614,7 @@ static irqreturn_t el_interrupt(int irq, void *dev_id)
|
||||
/*
|
||||
* It worked.. we will now fall through and receive
|
||||
*/
|
||||
lp->stats.tx_packets++;
|
||||
dev->stats.tx_packets++;
|
||||
if (el_debug > 6)
|
||||
printk(KERN_DEBUG " Tx succeeded %s\n",
|
||||
(txsr & TX_RDY) ? "." : "but tx is busy!");
|
||||
@ -642,10 +639,10 @@ static irqreturn_t el_interrupt(int irq, void *dev_id)
|
||||
* Just reading rx_status fixes most errors.
|
||||
*/
|
||||
if (rxsr & RX_MISSED)
|
||||
lp->stats.rx_missed_errors++;
|
||||
dev->stats.rx_missed_errors++;
|
||||
else if (rxsr & RX_RUNT)
|
||||
{ /* Handled to avoid board lock-up. */
|
||||
lp->stats.rx_length_errors++;
|
||||
dev->stats.rx_length_errors++;
|
||||
if (el_debug > 5)
|
||||
printk(KERN_DEBUG " runt.\n");
|
||||
}
|
||||
@ -696,7 +693,6 @@ out:
|
||||
|
||||
static void el_receive(struct net_device *dev)
|
||||
{
|
||||
struct net_local *lp = netdev_priv(dev);
|
||||
int ioaddr = dev->base_addr;
|
||||
int pkt_len;
|
||||
struct sk_buff *skb;
|
||||
@ -710,7 +706,7 @@ static void el_receive(struct net_device *dev)
|
||||
{
|
||||
if (el_debug)
|
||||
printk(KERN_DEBUG "%s: bogus packet, length=%d\n", dev->name, pkt_len);
|
||||
lp->stats.rx_over_errors++;
|
||||
dev->stats.rx_over_errors++;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -729,7 +725,7 @@ static void el_receive(struct net_device *dev)
|
||||
if (skb == NULL)
|
||||
{
|
||||
printk(KERN_INFO "%s: Memory squeeze, dropping packet.\n", dev->name);
|
||||
lp->stats.rx_dropped++;
|
||||
dev->stats.rx_dropped++;
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -744,8 +740,8 @@ static void el_receive(struct net_device *dev)
|
||||
skb->protocol=eth_type_trans(skb,dev);
|
||||
netif_rx(skb);
|
||||
dev->last_rx = jiffies;
|
||||
lp->stats.rx_packets++;
|
||||
lp->stats.rx_bytes+=pkt_len;
|
||||
dev->stats.rx_packets++;
|
||||
dev->stats.rx_bytes+=pkt_len;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -812,23 +808,6 @@ static int el1_close(struct net_device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* el1_get_stats:
|
||||
* @dev: The card to get the statistics for
|
||||
*
|
||||
* In smarter devices this function is needed to pull statistics off the
|
||||
* board itself. The 3c501 has no hardware statistics. We maintain them all
|
||||
* so they are by definition always up to date.
|
||||
*
|
||||
* Returns the statistics for the card from the card private data
|
||||
*/
|
||||
|
||||
static struct net_device_stats *el1_get_stats(struct net_device *dev)
|
||||
{
|
||||
struct net_local *lp = netdev_priv(dev);
|
||||
return &lp->stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* set_multicast_list:
|
||||
* @dev: The device to adjust
|
||||
|
@ -11,7 +11,6 @@ static irqreturn_t el_interrupt(int irq, void *dev_id);
|
||||
static void el_receive(struct net_device *dev);
|
||||
static void el_reset(struct net_device *dev);
|
||||
static int el1_close(struct net_device *dev);
|
||||
static struct net_device_stats *el1_get_stats(struct net_device *dev);
|
||||
static void set_multicast_list(struct net_device *dev);
|
||||
static const struct ethtool_ops netdev_ethtool_ops;
|
||||
|
||||
@ -29,7 +28,6 @@ static int el_debug = EL_DEBUG;
|
||||
|
||||
struct net_local
|
||||
{
|
||||
struct net_device_stats stats;
|
||||
int tx_pkt_start; /* The length of the current Tx packet. */
|
||||
int collisions; /* Tx collisions this packet */
|
||||
int loading; /* Spot buffer load collisions */
|
||||
|
@ -95,8 +95,6 @@ static int __init do_el2_probe(struct net_device *dev)
|
||||
int base_addr = dev->base_addr;
|
||||
int irq = dev->irq;
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
if (base_addr > 0x1ff) /* Check a single specified location. */
|
||||
return el2_probe1(dev, base_addr);
|
||||
else if (base_addr != 0) /* Don't probe at all. */
|
||||
@ -179,6 +177,7 @@ el2_probe1(struct net_device *dev, int ioaddr)
|
||||
int i, iobase_reg, membase_reg, saved_406, wordlength, retval;
|
||||
static unsigned version_printed;
|
||||
unsigned long vendor_id;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
if (!request_region(ioaddr, EL2_IO_EXTENT, DRV_NAME))
|
||||
return -EBUSY;
|
||||
@ -228,7 +227,8 @@ el2_probe1(struct net_device *dev, int ioaddr)
|
||||
|
||||
/* Retrieve and print the ethernet address. */
|
||||
for (i = 0; i < 6; i++)
|
||||
printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
|
||||
dev->dev_addr[i] = inb(ioaddr + i);
|
||||
printk("%s", print_mac(mac, dev->dev_addr));
|
||||
|
||||
/* Map the 8390 back into the window. */
|
||||
outb(ECNTRL_THIN, ioaddr + 0x406);
|
||||
|
@ -167,21 +167,6 @@ static int elp_debug;
|
||||
* 3 = messages when interrupts received
|
||||
*/
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* useful macros
|
||||
*
|
||||
*****************************************************************/
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* List of I/O-addresses we try to auto-sense
|
||||
@ -270,7 +255,7 @@ static inline void set_hsf(struct net_device *dev, int hsf)
|
||||
spin_unlock_irqrestore(&adapter->lock, flags);
|
||||
}
|
||||
|
||||
static int start_receive(struct net_device *, pcb_struct *);
|
||||
static bool start_receive(struct net_device *, pcb_struct *);
|
||||
|
||||
static inline void adapter_reset(struct net_device *dev)
|
||||
{
|
||||
@ -328,28 +313,28 @@ static inline void check_3c505_dma(struct net_device *dev)
|
||||
}
|
||||
|
||||
/* Primitive functions used by send_pcb() */
|
||||
static inline unsigned int send_pcb_slow(unsigned int base_addr, unsigned char byte)
|
||||
static inline bool send_pcb_slow(unsigned int base_addr, unsigned char byte)
|
||||
{
|
||||
unsigned long timeout;
|
||||
outb_command(byte, base_addr);
|
||||
for (timeout = jiffies + 5*HZ/100; time_before(jiffies, timeout);) {
|
||||
if (inb_status(base_addr) & HCRE)
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
printk(KERN_WARNING "3c505: send_pcb_slow timed out\n");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline unsigned int send_pcb_fast(unsigned int base_addr, unsigned char byte)
|
||||
static inline bool send_pcb_fast(unsigned int base_addr, unsigned char byte)
|
||||
{
|
||||
unsigned int timeout;
|
||||
outb_command(byte, base_addr);
|
||||
for (timeout = 0; timeout < 40000; timeout++) {
|
||||
if (inb_status(base_addr) & HCRE)
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
printk(KERN_WARNING "3c505: send_pcb_fast timed out\n");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check to see if the receiver needs restarting, and kick it if so */
|
||||
@ -386,7 +371,7 @@ static inline void prime_rx(struct net_device *dev)
|
||||
* timeout is reduced to 500us).
|
||||
*/
|
||||
|
||||
static int send_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
static bool send_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
{
|
||||
int i;
|
||||
unsigned long timeout;
|
||||
@ -396,14 +381,14 @@ static int send_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
check_3c505_dma(dev);
|
||||
|
||||
if (adapter->dmaing && adapter->current_dma.direction == 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
/* Avoid contention */
|
||||
if (test_and_set_bit(1, &adapter->send_pcb_semaphore)) {
|
||||
if (elp_debug >= 3) {
|
||||
printk(KERN_DEBUG "%s: send_pcb entered while threaded\n", dev->name);
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* load each byte into the command register and
|
||||
@ -435,7 +420,7 @@ static int send_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
switch (GET_ASF(dev->base_addr)) {
|
||||
case ASF_PCB_ACK:
|
||||
adapter->send_pcb_semaphore = 0;
|
||||
return TRUE;
|
||||
return true;
|
||||
|
||||
case ASF_PCB_NAK:
|
||||
#ifdef ELP_DEBUG
|
||||
@ -453,7 +438,7 @@ static int send_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
spin_unlock_irqrestore(&adapter->lock, flags);
|
||||
abort:
|
||||
adapter->send_pcb_semaphore = 0;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -470,7 +455,7 @@ static int send_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
*
|
||||
*****************************************************************/
|
||||
|
||||
static int receive_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
{
|
||||
int i, j;
|
||||
int total_length;
|
||||
@ -487,7 +472,7 @@ static int receive_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && time_before(jiffies, timeout));
|
||||
if (time_after_eq(jiffies, timeout)) {
|
||||
TIMEOUT_MSG(__LINE__);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
pcb->command = inb_command(dev->base_addr);
|
||||
|
||||
@ -497,14 +482,14 @@ static int receive_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
if (time_after_eq(jiffies, timeout)) {
|
||||
TIMEOUT_MSG(__LINE__);
|
||||
printk(KERN_INFO "%s: status %02x\n", dev->name, stat);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
pcb->length = inb_command(dev->base_addr);
|
||||
|
||||
if (pcb->length > MAX_PCB_DATA) {
|
||||
INVALID_PCB_MSG(pcb->length);
|
||||
adapter_reset(dev);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
/* read the data */
|
||||
spin_lock_irqsave(&adapter->lock, flags);
|
||||
@ -519,7 +504,7 @@ static int receive_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
spin_unlock_irqrestore(&adapter->lock, flags);
|
||||
if (j >= 20000) {
|
||||
TIMEOUT_MSG(__LINE__);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
/* woops, the last "data" byte was really the length! */
|
||||
total_length = pcb->data.raw[--i];
|
||||
@ -529,7 +514,7 @@ static int receive_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
if (elp_debug >= 2)
|
||||
printk(KERN_WARNING "%s: mangled PCB received\n", dev->name);
|
||||
set_hsf(dev, HSF_PCB_NAK);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pcb->command == CMD_RECEIVE_PACKET_COMPLETE) {
|
||||
@ -538,14 +523,14 @@ static int receive_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
set_hsf(dev, HSF_PCB_NAK);
|
||||
printk(KERN_WARNING "%s: PCB rejected, transfer in progress and backlog full\n", dev->name);
|
||||
pcb->command = 0;
|
||||
return TRUE;
|
||||
return true;
|
||||
} else {
|
||||
pcb->command = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
set_hsf(dev, HSF_PCB_ACK);
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
@ -555,9 +540,9 @@ static int receive_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||
*
|
||||
******************************************************/
|
||||
|
||||
static int start_receive(struct net_device *dev, pcb_struct * tx_pcb)
|
||||
static bool start_receive(struct net_device *dev, pcb_struct * tx_pcb)
|
||||
{
|
||||
int status;
|
||||
bool status;
|
||||
elp_device *adapter = dev->priv;
|
||||
|
||||
if (elp_debug >= 3)
|
||||
@ -984,7 +969,7 @@ static int elp_open(struct net_device *dev)
|
||||
*
|
||||
******************************************************/
|
||||
|
||||
static int send_packet(struct net_device *dev, struct sk_buff *skb)
|
||||
static bool send_packet(struct net_device *dev, struct sk_buff *skb)
|
||||
{
|
||||
elp_device *adapter = dev->priv;
|
||||
unsigned long target;
|
||||
@ -998,7 +983,7 @@ static int send_packet(struct net_device *dev, struct sk_buff *skb)
|
||||
if (test_and_set_bit(0, (void *) &adapter->busy)) {
|
||||
if (elp_debug >= 2)
|
||||
printk(KERN_DEBUG "%s: transmit blocked\n", dev->name);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
adapter->stats.tx_bytes += nlen;
|
||||
@ -1015,7 +1000,7 @@ static int send_packet(struct net_device *dev, struct sk_buff *skb)
|
||||
|
||||
if (!send_pcb(dev, &adapter->tx_pcb)) {
|
||||
adapter->busy = 0;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
/* if this happens, we die */
|
||||
if (test_and_set_bit(0, (void *) &adapter->dmaing))
|
||||
@ -1047,7 +1032,7 @@ static int send_packet(struct net_device *dev, struct sk_buff *skb)
|
||||
if (elp_debug >= 3)
|
||||
printk(KERN_DEBUG "%s: DMA transfer started\n", dev->name);
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1401,8 +1386,7 @@ static int __init elplus_setup(struct net_device *dev)
|
||||
unsigned long timeout;
|
||||
unsigned long cookie = 0;
|
||||
int err = -ENODEV;
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
/*
|
||||
* setup adapter structure
|
||||
@ -1538,11 +1522,10 @@ static int __init elplus_setup(struct net_device *dev)
|
||||
/*
|
||||
* print remainder of startup message
|
||||
*/
|
||||
printk(KERN_INFO "%s: 3c505 at %#lx, irq %d, dma %d, ",
|
||||
dev->name, dev->base_addr, dev->irq, dev->dma);
|
||||
printk("addr %02x:%02x:%02x:%02x:%02x:%02x, ",
|
||||
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
|
||||
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
|
||||
printk(KERN_INFO "%s: 3c505 at %#lx, irq %d, dma %d, "
|
||||
"addr %s, ",
|
||||
dev->name, dev->base_addr, dev->irq, dev->dma,
|
||||
print_mac(mac, dev->dev_addr));
|
||||
|
||||
/*
|
||||
* read more information from the adapter
|
||||
|
@ -118,7 +118,6 @@ enum commands {
|
||||
|
||||
/* Information that need to be kept for each board. */
|
||||
struct net_local {
|
||||
struct net_device_stats stats;
|
||||
int last_restart;
|
||||
ushort rx_head;
|
||||
ushort rx_tail;
|
||||
@ -289,7 +288,6 @@ static int el16_send_packet(struct sk_buff *skb, struct net_device *dev);
|
||||
static irqreturn_t el16_interrupt(int irq, void *dev_id);
|
||||
static void el16_rx(struct net_device *dev);
|
||||
static int el16_close(struct net_device *dev);
|
||||
static struct net_device_stats *el16_get_stats(struct net_device *dev);
|
||||
static void el16_tx_timeout (struct net_device *dev);
|
||||
|
||||
static void hardware_send_packet(struct net_device *dev, void *buf, short length, short pad);
|
||||
@ -327,8 +325,6 @@ struct net_device * __init el16_probe(int unit)
|
||||
mem_start = dev->mem_start & 15;
|
||||
}
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
if (io > 0x1ff) /* Check a single specified location. */
|
||||
err = el16_probe1(dev, io);
|
||||
else if (io != 0)
|
||||
@ -361,6 +357,7 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
|
||||
static unsigned char init_ID_done, version_printed;
|
||||
int i, irq, irqval, retval;
|
||||
struct net_local *lp;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
if (init_ID_done == 0) {
|
||||
ushort lrs_state = 0xff;
|
||||
@ -406,10 +403,9 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
|
||||
dev->base_addr = ioaddr;
|
||||
|
||||
outb(0x01, ioaddr + MISC_CTRL);
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (i = 0; i < 6; i++)
|
||||
dev->dev_addr[i] = inb(ioaddr + i);
|
||||
printk(" %02x", dev->dev_addr[i]);
|
||||
}
|
||||
printk(" %s", print_mac(mac, dev->dev_addr));
|
||||
|
||||
if (mem_start)
|
||||
net_debug = mem_start & 7;
|
||||
@ -457,7 +453,6 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
|
||||
dev->open = el16_open;
|
||||
dev->stop = el16_close;
|
||||
dev->hard_start_xmit = el16_send_packet;
|
||||
dev->get_stats = el16_get_stats;
|
||||
dev->tx_timeout = el16_tx_timeout;
|
||||
dev->watchdog_timeo = TX_TIMEOUT;
|
||||
dev->ethtool_ops = &netdev_ethtool_ops;
|
||||
@ -491,7 +486,7 @@ static void el16_tx_timeout (struct net_device *dev)
|
||||
readw(shmem + iSCB_STATUS) & 0x8000 ? "IRQ conflict" :
|
||||
"network cable problem");
|
||||
/* Try to restart the adaptor. */
|
||||
if (lp->last_restart == lp->stats.tx_packets) {
|
||||
if (lp->last_restart == dev->stats.tx_packets) {
|
||||
if (net_debug > 1)
|
||||
printk ("Resetting board.\n");
|
||||
/* Completely reset the adaptor. */
|
||||
@ -503,7 +498,7 @@ static void el16_tx_timeout (struct net_device *dev)
|
||||
printk ("Kicking board.\n");
|
||||
writew(0xf000 | CUC_START | RX_START, shmem + iSCB_CMD);
|
||||
outb (0, ioaddr + SIGNAL_CA); /* Issue channel-attn. */
|
||||
lp->last_restart = lp->stats.tx_packets;
|
||||
lp->last_restart = dev->stats.tx_packets;
|
||||
}
|
||||
dev->trans_start = jiffies;
|
||||
netif_wake_queue (dev);
|
||||
@ -522,7 +517,7 @@ static int el16_send_packet (struct sk_buff *skb, struct net_device *dev)
|
||||
|
||||
spin_lock_irqsave (&lp->lock, flags);
|
||||
|
||||
lp->stats.tx_bytes += length;
|
||||
dev->stats.tx_bytes += length;
|
||||
/* Disable the 82586's input to the interrupt line. */
|
||||
outb (0x80, ioaddr + MISC_CTRL);
|
||||
|
||||
@ -581,14 +576,14 @@ static irqreturn_t el16_interrupt(int irq, void *dev_id)
|
||||
}
|
||||
/* Tx unsuccessful or some interesting status bit set. */
|
||||
if (!(tx_status & 0x2000) || (tx_status & 0x0f3f)) {
|
||||
lp->stats.tx_errors++;
|
||||
if (tx_status & 0x0600) lp->stats.tx_carrier_errors++;
|
||||
if (tx_status & 0x0100) lp->stats.tx_fifo_errors++;
|
||||
if (!(tx_status & 0x0040)) lp->stats.tx_heartbeat_errors++;
|
||||
if (tx_status & 0x0020) lp->stats.tx_aborted_errors++;
|
||||
lp->stats.collisions += tx_status & 0xf;
|
||||
dev->stats.tx_errors++;
|
||||
if (tx_status & 0x0600) dev->stats.tx_carrier_errors++;
|
||||
if (tx_status & 0x0100) dev->stats.tx_fifo_errors++;
|
||||
if (!(tx_status & 0x0040)) dev->stats.tx_heartbeat_errors++;
|
||||
if (tx_status & 0x0020) dev->stats.tx_aborted_errors++;
|
||||
dev->stats.collisions += tx_status & 0xf;
|
||||
}
|
||||
lp->stats.tx_packets++;
|
||||
dev->stats.tx_packets++;
|
||||
if (net_debug > 5)
|
||||
printk("Reaped %x, Tx status %04x.\n" , lp->tx_reap, tx_status);
|
||||
lp->tx_reap += TX_BUF_SIZE;
|
||||
@ -667,17 +662,6 @@ static int el16_close(struct net_device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get the current statistics. This may be called with the card open or
|
||||
closed. */
|
||||
static struct net_device_stats *el16_get_stats(struct net_device *dev)
|
||||
{
|
||||
struct net_local *lp = netdev_priv(dev);
|
||||
|
||||
/* ToDo: decide if there are any useful statistics from the SCB. */
|
||||
|
||||
return &lp->stats;
|
||||
}
|
||||
|
||||
/* Initialize the Rx-block list. */
|
||||
static void init_rx_bufs(struct net_device *dev)
|
||||
{
|
||||
@ -854,12 +838,12 @@ static void el16_rx(struct net_device *dev)
|
||||
pkt_len);
|
||||
} else if ((frame_status & 0x2000) == 0) {
|
||||
/* Frame Rxed, but with error. */
|
||||
lp->stats.rx_errors++;
|
||||
if (frame_status & 0x0800) lp->stats.rx_crc_errors++;
|
||||
if (frame_status & 0x0400) lp->stats.rx_frame_errors++;
|
||||
if (frame_status & 0x0200) lp->stats.rx_fifo_errors++;
|
||||
if (frame_status & 0x0100) lp->stats.rx_over_errors++;
|
||||
if (frame_status & 0x0080) lp->stats.rx_length_errors++;
|
||||
dev->stats.rx_errors++;
|
||||
if (frame_status & 0x0800) dev->stats.rx_crc_errors++;
|
||||
if (frame_status & 0x0400) dev->stats.rx_frame_errors++;
|
||||
if (frame_status & 0x0200) dev->stats.rx_fifo_errors++;
|
||||
if (frame_status & 0x0100) dev->stats.rx_over_errors++;
|
||||
if (frame_status & 0x0080) dev->stats.rx_length_errors++;
|
||||
} else {
|
||||
/* Malloc up new buffer. */
|
||||
struct sk_buff *skb;
|
||||
@ -868,7 +852,7 @@ static void el16_rx(struct net_device *dev)
|
||||
skb = dev_alloc_skb(pkt_len+2);
|
||||
if (skb == NULL) {
|
||||
printk("%s: Memory squeeze, dropping packet.\n", dev->name);
|
||||
lp->stats.rx_dropped++;
|
||||
dev->stats.rx_dropped++;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -880,8 +864,8 @@ static void el16_rx(struct net_device *dev)
|
||||
skb->protocol=eth_type_trans(skb,dev);
|
||||
netif_rx(skb);
|
||||
dev->last_rx = jiffies;
|
||||
lp->stats.rx_packets++;
|
||||
lp->stats.rx_bytes += pkt_len;
|
||||
dev->stats.rx_packets++;
|
||||
dev->stats.rx_bytes += pkt_len;
|
||||
}
|
||||
|
||||
/* Clear the status word and set End-of-List on the rx frame. */
|
||||
|
@ -299,7 +299,7 @@ static struct isapnp_device_id el3_isapnp_adapters[] __initdata = {
|
||||
{ } /* terminate list */
|
||||
};
|
||||
|
||||
static u16 el3_isapnp_phys_addr[8][3];
|
||||
static __be16 el3_isapnp_phys_addr[8][3];
|
||||
static int nopnp;
|
||||
#endif /* __ISAPNP__ */
|
||||
|
||||
@ -313,8 +313,9 @@ static int nopnp;
|
||||
static int __init el3_common_init(struct net_device *dev)
|
||||
{
|
||||
struct el3_private *lp = netdev_priv(dev);
|
||||
short i;
|
||||
int err;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};
|
||||
|
||||
spin_lock_init(&lp->lock);
|
||||
|
||||
@ -346,17 +347,10 @@ static int __init el3_common_init(struct net_device *dev)
|
||||
return err;
|
||||
}
|
||||
|
||||
{
|
||||
const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};
|
||||
printk("%s: 3c5x9 found at %#3.3lx, %s port, address ",
|
||||
dev->name, dev->base_addr,
|
||||
if_names[(dev->if_port & 0x03)]);
|
||||
}
|
||||
|
||||
/* Read in the station address. */
|
||||
for (i = 0; i < 6; i++)
|
||||
printk(" %2.2x", dev->dev_addr[i]);
|
||||
printk(", IRQ %d.\n", dev->irq);
|
||||
printk(KERN_INFO "%s: 3c5x9 found at %#3.3lx, %s port, "
|
||||
"address %s, IRQ %d.\n",
|
||||
dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)],
|
||||
print_mac(mac, dev->dev_addr), dev->irq);
|
||||
|
||||
if (el3_debug > 0)
|
||||
printk(KERN_INFO "%s", version);
|
||||
@ -385,7 +379,7 @@ static int __init el3_probe(int card_idx)
|
||||
struct el3_private *lp;
|
||||
short lrs_state = 0xff, i;
|
||||
int ioaddr, irq, if_port;
|
||||
u16 phys_addr[3];
|
||||
__be16 phys_addr[3];
|
||||
static int current_tag;
|
||||
int err = -ENODEV;
|
||||
#if defined(__ISAPNP__)
|
||||
@ -432,7 +426,6 @@ __again:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
SET_NETDEV_DEV(dev, &idev->dev);
|
||||
pnp_cards++;
|
||||
|
||||
@ -524,8 +517,6 @@ no_pnp:
|
||||
if (!dev)
|
||||
return -ENOMEM;
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
netdev_boot_setup_check(dev);
|
||||
|
||||
/* Set passed-in IRQ or I/O Addr. */
|
||||
@ -644,7 +635,6 @@ static int __init el3_mca_probe(struct device *device)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
netdev_boot_setup_check(dev);
|
||||
|
||||
memcpy(dev->dev_addr, phys_addr, sizeof(phys_addr));
|
||||
@ -704,8 +694,6 @@ static int __init el3_eisa_probe (struct device *device)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
netdev_boot_setup_check(dev);
|
||||
|
||||
memcpy(dev->dev_addr, phys_addr, sizeof(phys_addr));
|
||||
|
@ -501,8 +501,6 @@ static struct net_device *corkscrew_scan(int unit)
|
||||
netdev_boot_setup_check(dev);
|
||||
}
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
#ifdef __ISAPNP__
|
||||
if(nopnp == 1)
|
||||
goto no_pnp;
|
||||
@ -571,6 +569,7 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
|
||||
unsigned int eeprom[0x40], checksum = 0; /* EEPROM contents */
|
||||
int i;
|
||||
int irq;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
if (idev) {
|
||||
irq = pnp_irq(idev, 0);
|
||||
@ -632,8 +631,7 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
|
||||
checksum = (checksum ^ (checksum >> 8)) & 0xff;
|
||||
if (checksum != 0x00)
|
||||
printk(" ***INVALID CHECKSUM %4.4x*** ", checksum);
|
||||
for (i = 0; i < 6; i++)
|
||||
printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
|
||||
printk(" %s", print_mac(mac, dev->dev_addr));
|
||||
if (eeprom[16] == 0x11c7) { /* Corkscrew */
|
||||
if (request_dma(dev->dma, "3c515")) {
|
||||
printk(", DMA %d allocation failed", dev->dma);
|
||||
|
@ -383,8 +383,8 @@ void alloc586(struct net_device *dev)
|
||||
static int elmc_getinfo(char *buf, int slot, void *d)
|
||||
{
|
||||
int len = 0;
|
||||
struct net_device *dev = (struct net_device *) d;
|
||||
int i;
|
||||
struct net_device *dev = d;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
if (dev == NULL)
|
||||
return len;
|
||||
@ -399,12 +399,8 @@ static int elmc_getinfo(char *buf, int slot, void *d)
|
||||
len += sprintf(buf + len, "Transceiver: %s\n", dev->if_port ?
|
||||
"External" : "Internal");
|
||||
len += sprintf(buf + len, "Device: %s\n", dev->name);
|
||||
len += sprintf(buf + len, "Hardware Address:");
|
||||
for (i = 0; i < 6; i++) {
|
||||
len += sprintf(buf + len, " %02x", dev->dev_addr[i]);
|
||||
}
|
||||
buf[len++] = '\n';
|
||||
buf[len] = 0;
|
||||
len += sprintf(buf + len, "Hardware Address: %s\n",
|
||||
print_mac(mac, dev->dev_addr));
|
||||
|
||||
return len;
|
||||
} /* elmc_getinfo() */
|
||||
@ -422,8 +418,8 @@ static int __init do_elmc_probe(struct net_device *dev)
|
||||
unsigned int size = 0;
|
||||
int retval;
|
||||
struct priv *pr = dev->priv;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
if (MCA_bus == 0) {
|
||||
return -ENODEV;
|
||||
}
|
||||
@ -545,12 +541,11 @@ static int __init do_elmc_probe(struct net_device *dev)
|
||||
|
||||
/* The hardware address for the 3c523 is stored in the first six
|
||||
bytes of the IO address. */
|
||||
printk(KERN_INFO "%s: hardware address ", dev->name);
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (i = 0; i < 6; i++)
|
||||
dev->dev_addr[i] = inb(dev->base_addr + i);
|
||||
printk(" %02x", dev->dev_addr[i]);
|
||||
}
|
||||
printk("\n");
|
||||
|
||||
printk(KERN_INFO "%s: hardware address %s\n",
|
||||
dev->name, print_mac(mac, dev->dev_addr));
|
||||
|
||||
dev->open = &elmc_open;
|
||||
dev->stop = &elmc_close;
|
||||
|
@ -257,8 +257,6 @@ struct net_device *__init mc32_probe(int unit)
|
||||
if (unit >= 0)
|
||||
sprintf(dev->name, "eth%d", unit);
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
/* Do not check any supplied i/o locations.
|
||||
POS registers usually don't fail :) */
|
||||
|
||||
@ -338,6 +336,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
|
||||
"82586 initialisation failure",
|
||||
"Adapter list configuration error"
|
||||
};
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
/* Time to play MCA games */
|
||||
|
||||
@ -398,17 +397,17 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
|
||||
* Go PROM browsing
|
||||
*/
|
||||
|
||||
printk("%s: Address ", dev->name);
|
||||
|
||||
/* Retrieve and print the ethernet address. */
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
mca_write_pos(slot, 6, i+12);
|
||||
mca_write_pos(slot, 7, 0);
|
||||
|
||||
printk(" %2.2x", dev->dev_addr[i] = mca_read_pos(slot,3));
|
||||
dev->dev_addr[i] = mca_read_pos(slot,3);
|
||||
}
|
||||
|
||||
printk("%s: Address %s", dev->name, print_mac(mac, dev->dev_addr));
|
||||
|
||||
mca_write_pos(slot, 6, 0);
|
||||
mca_write_pos(slot, 7, 0);
|
||||
|
||||
|
@ -538,10 +538,10 @@ enum MasterCtrl {
|
||||
#define LAST_FRAG 0x80000000 /* Last Addr/Len pair in descriptor. */
|
||||
#define DN_COMPLETE 0x00010000 /* This packet has been downloaded */
|
||||
struct boom_rx_desc {
|
||||
u32 next; /* Last entry points to 0. */
|
||||
s32 status;
|
||||
u32 addr; /* Up to 63 addr/len pairs possible. */
|
||||
s32 length; /* Set LAST_FRAG to indicate last pair. */
|
||||
__le32 next; /* Last entry points to 0. */
|
||||
__le32 status;
|
||||
__le32 addr; /* Up to 63 addr/len pairs possible. */
|
||||
__le32 length; /* Set LAST_FRAG to indicate last pair. */
|
||||
};
|
||||
/* Values for the Rx status entry. */
|
||||
enum rx_desc_status {
|
||||
@ -558,16 +558,16 @@ enum rx_desc_status {
|
||||
#endif
|
||||
|
||||
struct boom_tx_desc {
|
||||
u32 next; /* Last entry points to 0. */
|
||||
s32 status; /* bits 0:12 length, others see below. */
|
||||
__le32 next; /* Last entry points to 0. */
|
||||
__le32 status; /* bits 0:12 length, others see below. */
|
||||
#if DO_ZEROCOPY
|
||||
struct {
|
||||
u32 addr;
|
||||
s32 length;
|
||||
__le32 addr;
|
||||
__le32 length;
|
||||
} frag[1+MAX_SKB_FRAGS];
|
||||
#else
|
||||
u32 addr;
|
||||
s32 length;
|
||||
__le32 addr;
|
||||
__le32 length;
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -705,7 +705,7 @@ static struct {
|
||||
|
||||
static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
|
||||
int chip_idx, int card_idx);
|
||||
static void vortex_up(struct net_device *dev);
|
||||
static int vortex_up(struct net_device *dev);
|
||||
static void vortex_down(struct net_device *dev, int final);
|
||||
static int vortex_open(struct net_device *dev);
|
||||
static void mdio_sync(void __iomem *ioaddr, int bits);
|
||||
@ -841,8 +841,11 @@ static int vortex_resume(struct pci_dev *pdev)
|
||||
return -EBUSY;
|
||||
}
|
||||
if (netif_running(dev)) {
|
||||
vortex_up(dev);
|
||||
netif_device_attach(dev);
|
||||
err = vortex_up(dev);
|
||||
if (err)
|
||||
return err;
|
||||
else
|
||||
netif_device_attach(dev);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -1011,6 +1014,7 @@ static int __devinit vortex_probe1(struct device *gendev,
|
||||
char *print_name = "3c59x";
|
||||
struct pci_dev *pdev = NULL;
|
||||
struct eisa_device *edev = NULL;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
if (!printed_version) {
|
||||
printk (version);
|
||||
@ -1033,7 +1037,6 @@ static int __devinit vortex_probe1(struct device *gendev,
|
||||
printk (KERN_ERR PFX "unable to allocate etherdev, aborting\n");
|
||||
goto out;
|
||||
}
|
||||
SET_MODULE_OWNER(dev);
|
||||
SET_NETDEV_DEV(dev, gendev);
|
||||
vp = netdev_priv(dev);
|
||||
|
||||
@ -1128,7 +1131,7 @@ static int __devinit vortex_probe1(struct device *gendev,
|
||||
+ sizeof(struct boom_tx_desc) * TX_RING_SIZE,
|
||||
&vp->rx_ring_dma);
|
||||
retval = -ENOMEM;
|
||||
if (vp->rx_ring == 0)
|
||||
if (!vp->rx_ring)
|
||||
goto free_region;
|
||||
|
||||
vp->tx_ring = (struct boom_tx_desc *)(vp->rx_ring + RX_RING_SIZE);
|
||||
@ -1201,12 +1204,10 @@ static int __devinit vortex_probe1(struct device *gendev,
|
||||
if ((checksum != 0x00) && !(vci->drv_flags & IS_TORNADO))
|
||||
printk(" ***INVALID CHECKSUM %4.4x*** ", checksum);
|
||||
for (i = 0; i < 3; i++)
|
||||
((u16 *)dev->dev_addr)[i] = htons(eeprom[i + 10]);
|
||||
((__be16 *)dev->dev_addr)[i] = htons(eeprom[i + 10]);
|
||||
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
|
||||
if (print_info) {
|
||||
for (i = 0; i < 6; i++)
|
||||
printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
|
||||
}
|
||||
if (print_info)
|
||||
printk(" %s", print_mac(mac, dev->dev_addr));
|
||||
/* Unfortunately an all zero eeprom passes the checksum and this
|
||||
gets found in the wild in failure cases. Crypto is hard 8) */
|
||||
if (!is_valid_ether_addr(dev->dev_addr)) {
|
||||
@ -1484,19 +1485,24 @@ static void vortex_check_media(struct net_device *dev, unsigned int init)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
vortex_up(struct net_device *dev)
|
||||
{
|
||||
struct vortex_private *vp = netdev_priv(dev);
|
||||
void __iomem *ioaddr = vp->ioaddr;
|
||||
unsigned int config;
|
||||
int i, mii_reg1, mii_reg5;
|
||||
int i, mii_reg1, mii_reg5, err;
|
||||
|
||||
if (VORTEX_PCI(vp)) {
|
||||
pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */
|
||||
if (vp->pm_state_valid)
|
||||
pci_restore_state(VORTEX_PCI(vp));
|
||||
pci_enable_device(VORTEX_PCI(vp));
|
||||
err = pci_enable_device(VORTEX_PCI(vp));
|
||||
if (err) {
|
||||
printk(KERN_WARNING "%s: Could not enable device \n",
|
||||
dev->name);
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
|
||||
/* Before initializing select the active media port. */
|
||||
@ -1661,6 +1667,8 @@ vortex_up(struct net_device *dev)
|
||||
if (vp->cb_fn_base) /* The PCMCIA people are idiots. */
|
||||
iowrite32(0x8000, vp->cb_fn_base + 4);
|
||||
netif_start_queue (dev);
|
||||
err_out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1674,7 +1682,7 @@ vortex_open(struct net_device *dev)
|
||||
if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ?
|
||||
&boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev))) {
|
||||
printk(KERN_ERR "%s: Could not reserve IRQ %d\n", dev->name, dev->irq);
|
||||
goto out;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (vp->full_bus_master_rx) { /* Boomerang bus master. */
|
||||
@ -1703,20 +1711,22 @@ vortex_open(struct net_device *dev)
|
||||
}
|
||||
}
|
||||
retval = -ENOMEM;
|
||||
goto out_free_irq;
|
||||
goto err_free_irq;
|
||||
}
|
||||
/* Wrap the ring. */
|
||||
vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma);
|
||||
}
|
||||
|
||||
vortex_up(dev);
|
||||
return 0;
|
||||
retval = vortex_up(dev);
|
||||
if (!retval)
|
||||
goto out;
|
||||
|
||||
out_free_irq:
|
||||
err_free_irq:
|
||||
free_irq(dev->irq, dev);
|
||||
out:
|
||||
err:
|
||||
if (vortex_debug > 1)
|
||||
printk(KERN_ERR "%s: vortex_open() fails: returning %d\n", dev->name, retval);
|
||||
out:
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2490,7 +2500,7 @@ boomerang_rx(struct net_device *dev)
|
||||
|
||||
/* Check if the packet is long enough to just accept without
|
||||
copying to a properly sized skbuff. */
|
||||
if (pkt_len < rx_copybreak && (skb = dev_alloc_skb(pkt_len + 2)) != 0) {
|
||||
if (pkt_len < rx_copybreak && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
|
||||
skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
|
||||
pci_dma_sync_single_for_cpu(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
|
||||
/* 'skb_put()' points to the start of sk_buff data area. */
|
||||
@ -2823,9 +2833,14 @@ static void vortex_set_msglevel(struct net_device *dev, u32 dbg)
|
||||
vortex_debug = dbg;
|
||||
}
|
||||
|
||||
static int vortex_get_stats_count(struct net_device *dev)
|
||||
static int vortex_get_sset_count(struct net_device *dev, int sset)
|
||||
{
|
||||
return VORTEX_NUM_STATS;
|
||||
switch (sset) {
|
||||
case ETH_SS_STATS:
|
||||
return VORTEX_NUM_STATS;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
|
||||
static void vortex_get_ethtool_stats(struct net_device *dev,
|
||||
@ -2882,7 +2897,7 @@ static const struct ethtool_ops vortex_ethtool_ops = {
|
||||
.get_msglevel = vortex_get_msglevel,
|
||||
.set_msglevel = vortex_set_msglevel,
|
||||
.get_ethtool_stats = vortex_get_ethtool_stats,
|
||||
.get_stats_count = vortex_get_stats_count,
|
||||
.get_sset_count = vortex_get_sset_count,
|
||||
.get_settings = vortex_get_settings,
|
||||
.set_settings = vortex_set_settings,
|
||||
.get_link = ethtool_op_get_link,
|
||||
@ -2899,7 +2914,7 @@ static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
||||
struct vortex_private *vp = netdev_priv(dev);
|
||||
void __iomem *ioaddr = vp->ioaddr;
|
||||
unsigned long flags;
|
||||
int state = 0;
|
||||
pci_power_t state = 0;
|
||||
|
||||
if(VORTEX_PCI(vp))
|
||||
state = VORTEX_PCI(vp)->current_state;
|
||||
|
@ -305,18 +305,18 @@ static int lance_rx (struct net_device *dev)
|
||||
|
||||
/* We got an incomplete frame? */
|
||||
if ((bits & LE_R1_POK) != LE_R1_POK) {
|
||||
lp->stats.rx_over_errors++;
|
||||
lp->stats.rx_errors++;
|
||||
dev->stats.rx_over_errors++;
|
||||
dev->stats.rx_errors++;
|
||||
continue;
|
||||
} else if (bits & LE_R1_ERR) {
|
||||
/* Count only the end frame as a rx error,
|
||||
* not the beginning
|
||||
*/
|
||||
if (bits & LE_R1_BUF) lp->stats.rx_fifo_errors++;
|
||||
if (bits & LE_R1_CRC) lp->stats.rx_crc_errors++;
|
||||
if (bits & LE_R1_OFL) lp->stats.rx_over_errors++;
|
||||
if (bits & LE_R1_FRA) lp->stats.rx_frame_errors++;
|
||||
if (bits & LE_R1_EOP) lp->stats.rx_errors++;
|
||||
if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++;
|
||||
if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++;
|
||||
if (bits & LE_R1_OFL) dev->stats.rx_over_errors++;
|
||||
if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++;
|
||||
if (bits & LE_R1_EOP) dev->stats.rx_errors++;
|
||||
} else {
|
||||
len = (rd->mblength & 0xfff) - 4;
|
||||
skb = dev_alloc_skb (len+2);
|
||||
@ -324,7 +324,7 @@ static int lance_rx (struct net_device *dev)
|
||||
if (skb == 0) {
|
||||
printk ("%s: Memory squeeze, deferring packet.\n",
|
||||
dev->name);
|
||||
lp->stats.rx_dropped++;
|
||||
dev->stats.rx_dropped++;
|
||||
rd->mblength = 0;
|
||||
rd->rmd1_bits = LE_R1_OWN;
|
||||
lp->rx_new = (lp->rx_new + 1) & lp->rx_ring_mod_mask;
|
||||
@ -339,8 +339,8 @@ static int lance_rx (struct net_device *dev)
|
||||
skb->protocol = eth_type_trans (skb, dev);
|
||||
netif_rx (skb);
|
||||
dev->last_rx = jiffies;
|
||||
lp->stats.rx_packets++;
|
||||
lp->stats.rx_bytes += len;
|
||||
dev->stats.rx_packets++;
|
||||
dev->stats.rx_bytes += len;
|
||||
}
|
||||
|
||||
/* Return the packet to the pool */
|
||||
@ -377,12 +377,12 @@ static int lance_tx (struct net_device *dev)
|
||||
if (td->tmd1_bits & LE_T1_ERR) {
|
||||
status = td->misc;
|
||||
|
||||
lp->stats.tx_errors++;
|
||||
if (status & LE_T3_RTY) lp->stats.tx_aborted_errors++;
|
||||
if (status & LE_T3_LCOL) lp->stats.tx_window_errors++;
|
||||
dev->stats.tx_errors++;
|
||||
if (status & LE_T3_RTY) dev->stats.tx_aborted_errors++;
|
||||
if (status & LE_T3_LCOL) dev->stats.tx_window_errors++;
|
||||
|
||||
if (status & LE_T3_CLOS) {
|
||||
lp->stats.tx_carrier_errors++;
|
||||
dev->stats.tx_carrier_errors++;
|
||||
if (lp->auto_select) {
|
||||
lp->tpe = 1 - lp->tpe;
|
||||
printk("%s: Carrier Lost, trying %s\n",
|
||||
@ -400,7 +400,7 @@ static int lance_tx (struct net_device *dev)
|
||||
/* buffer errors and underflows turn off the transmitter */
|
||||
/* Restart the adapter */
|
||||
if (status & (LE_T3_BUF|LE_T3_UFL)) {
|
||||
lp->stats.tx_fifo_errors++;
|
||||
dev->stats.tx_fifo_errors++;
|
||||
|
||||
printk ("%s: Tx: ERR_BUF|ERR_UFL, restarting\n",
|
||||
dev->name);
|
||||
@ -420,13 +420,13 @@ static int lance_tx (struct net_device *dev)
|
||||
|
||||
/* One collision before packet was sent. */
|
||||
if (td->tmd1_bits & LE_T1_EONE)
|
||||
lp->stats.collisions++;
|
||||
dev->stats.collisions++;
|
||||
|
||||
/* More than one collision, be optimistic. */
|
||||
if (td->tmd1_bits & LE_T1_EMORE)
|
||||
lp->stats.collisions += 2;
|
||||
dev->stats.collisions += 2;
|
||||
|
||||
lp->stats.tx_packets++;
|
||||
dev->stats.tx_packets++;
|
||||
}
|
||||
|
||||
j = (j + 1) & lp->tx_ring_mod_mask;
|
||||
@ -471,9 +471,9 @@ lance_interrupt (int irq, void *dev_id)
|
||||
|
||||
/* Log misc errors. */
|
||||
if (csr0 & LE_C0_BABL)
|
||||
lp->stats.tx_errors++; /* Tx babble. */
|
||||
dev->stats.tx_errors++; /* Tx babble. */
|
||||
if (csr0 & LE_C0_MISS)
|
||||
lp->stats.rx_errors++; /* Missed a Rx frame. */
|
||||
dev->stats.rx_errors++; /* Missed a Rx frame. */
|
||||
if (csr0 & LE_C0_MERR) {
|
||||
printk("%s: Bus master arbitration failure, status %4.4x.\n",
|
||||
dev->name, csr0);
|
||||
@ -589,13 +589,6 @@ int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct net_device_stats *lance_get_stats (struct net_device *dev)
|
||||
{
|
||||
struct lance_private *lp = netdev_priv(dev);
|
||||
|
||||
return &lp->stats;
|
||||
}
|
||||
|
||||
/* taken from the depca driver via a2065.c */
|
||||
static void lance_load_multicast (struct net_device *dev)
|
||||
{
|
||||
|
@ -111,7 +111,6 @@ struct lance_private
|
||||
int lance_log_rx_bufs, lance_log_tx_bufs;
|
||||
int rx_ring_mod_mask, tx_ring_mod_mask;
|
||||
|
||||
struct net_device_stats stats;
|
||||
int tpe; /* TPE is selected */
|
||||
int auto_select; /* cable-selection is by carrier */
|
||||
unsigned short busmaster_regval;
|
||||
@ -246,7 +245,6 @@ struct lance_private
|
||||
extern int lance_open(struct net_device *dev);
|
||||
extern int lance_close (struct net_device *dev);
|
||||
extern int lance_start_xmit (struct sk_buff *skb, struct net_device *dev);
|
||||
extern struct net_device_stats *lance_get_stats (struct net_device *dev);
|
||||
extern void lance_set_multicast (struct net_device *dev);
|
||||
extern void lance_tx_timeout(struct net_device *dev);
|
||||
#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||
|
@ -78,7 +78,7 @@
|
||||
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
|
||||
#define CP_VLAN_TAG_USED 1
|
||||
#define CP_VLAN_TX_TAG(tx_desc,vlan_tag_value) \
|
||||
do { (tx_desc)->opts2 = (vlan_tag_value); } while (0)
|
||||
do { (tx_desc)->opts2 = cpu_to_le32(vlan_tag_value); } while (0)
|
||||
#else
|
||||
#define CP_VLAN_TAG_USED 0
|
||||
#define CP_VLAN_TX_TAG(tx_desc,vlan_tag_value) \
|
||||
@ -303,25 +303,25 @@ static const unsigned int cp_rx_config =
|
||||
(RX_DMA_BURST << RxCfgDMAShift);
|
||||
|
||||
struct cp_desc {
|
||||
u32 opts1;
|
||||
u32 opts2;
|
||||
u64 addr;
|
||||
__le32 opts1;
|
||||
__le32 opts2;
|
||||
__le64 addr;
|
||||
};
|
||||
|
||||
struct cp_dma_stats {
|
||||
u64 tx_ok;
|
||||
u64 rx_ok;
|
||||
u64 tx_err;
|
||||
u32 rx_err;
|
||||
u16 rx_fifo;
|
||||
u16 frame_align;
|
||||
u32 tx_ok_1col;
|
||||
u32 tx_ok_mcol;
|
||||
u64 rx_ok_phys;
|
||||
u64 rx_ok_bcast;
|
||||
u32 rx_ok_mcast;
|
||||
u16 tx_abort;
|
||||
u16 tx_underrun;
|
||||
__le64 tx_ok;
|
||||
__le64 rx_ok;
|
||||
__le64 tx_err;
|
||||
__le32 rx_err;
|
||||
__le16 rx_fifo;
|
||||
__le16 frame_align;
|
||||
__le32 tx_ok_1col;
|
||||
__le32 tx_ok_mcol;
|
||||
__le64 rx_ok_phys;
|
||||
__le64 rx_ok_bcast;
|
||||
__le32 rx_ok_mcast;
|
||||
__le16 tx_abort;
|
||||
__le16 tx_underrun;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct cp_extra_stats {
|
||||
@ -334,6 +334,8 @@ struct cp_private {
|
||||
spinlock_t lock;
|
||||
u32 msg_enable;
|
||||
|
||||
struct napi_struct napi;
|
||||
|
||||
struct pci_dev *pdev;
|
||||
u32 rx_config;
|
||||
u16 cpcmd;
|
||||
@ -460,9 +462,9 @@ static inline void cp_rx_skb (struct cp_private *cp, struct sk_buff *skb,
|
||||
cp->dev->last_rx = jiffies;
|
||||
|
||||
#if CP_VLAN_TAG_USED
|
||||
if (cp->vlgrp && (desc->opts2 & RxVlanTagged)) {
|
||||
if (cp->vlgrp && (desc->opts2 & cpu_to_le32(RxVlanTagged))) {
|
||||
vlan_hwaccel_receive_skb(skb, cp->vlgrp,
|
||||
be16_to_cpu(desc->opts2 & 0xffff));
|
||||
swab16(le32_to_cpu(desc->opts2) & 0xffff));
|
||||
} else
|
||||
#endif
|
||||
netif_receive_skb(skb);
|
||||
@ -501,12 +503,12 @@ static inline unsigned int cp_rx_csum_ok (u32 status)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cp_rx_poll (struct net_device *dev, int *budget)
|
||||
static int cp_rx_poll(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct cp_private *cp = netdev_priv(dev);
|
||||
unsigned rx_tail = cp->rx_tail;
|
||||
unsigned rx_work = dev->quota;
|
||||
unsigned rx;
|
||||
struct cp_private *cp = container_of(napi, struct cp_private, napi);
|
||||
struct net_device *dev = cp->dev;
|
||||
unsigned int rx_tail = cp->rx_tail;
|
||||
int rx;
|
||||
|
||||
rx_status_loop:
|
||||
rx = 0;
|
||||
@ -560,7 +562,7 @@ rx_status_loop:
|
||||
|
||||
skb_reserve(new_skb, RX_OFFSET);
|
||||
|
||||
pci_unmap_single(cp->pdev, mapping,
|
||||
dma_unmap_single(&cp->pdev->dev, mapping,
|
||||
buflen, PCI_DMA_FROMDEVICE);
|
||||
|
||||
/* Handle checksum offloading for incoming packets. */
|
||||
@ -571,7 +573,7 @@ rx_status_loop:
|
||||
|
||||
skb_put(skb, len);
|
||||
|
||||
mapping = pci_map_single(cp->pdev, new_skb->data, buflen,
|
||||
mapping = dma_map_single(&cp->pdev->dev, new_skb->data, buflen,
|
||||
PCI_DMA_FROMDEVICE);
|
||||
cp->rx_skb[rx_tail] = new_skb;
|
||||
|
||||
@ -588,33 +590,28 @@ rx_next:
|
||||
desc->opts1 = cpu_to_le32(DescOwn | cp->rx_buf_sz);
|
||||
rx_tail = NEXT_RX(rx_tail);
|
||||
|
||||
if (!rx_work--)
|
||||
if (rx >= budget)
|
||||
break;
|
||||
}
|
||||
|
||||
cp->rx_tail = rx_tail;
|
||||
|
||||
dev->quota -= rx;
|
||||
*budget -= rx;
|
||||
|
||||
/* if we did not reach work limit, then we're done with
|
||||
* this round of polling
|
||||
*/
|
||||
if (rx_work) {
|
||||
if (rx < budget) {
|
||||
unsigned long flags;
|
||||
|
||||
if (cpr16(IntrStatus) & cp_rx_intr_mask)
|
||||
goto rx_status_loop;
|
||||
|
||||
local_irq_save(flags);
|
||||
spin_lock_irqsave(&cp->lock, flags);
|
||||
cpw16_f(IntrMask, cp_intr_mask);
|
||||
__netif_rx_complete(dev);
|
||||
local_irq_restore(flags);
|
||||
|
||||
return 0; /* done */
|
||||
__netif_rx_complete(dev, napi);
|
||||
spin_unlock_irqrestore(&cp->lock, flags);
|
||||
}
|
||||
|
||||
return 1; /* not done */
|
||||
return rx;
|
||||
}
|
||||
|
||||
static irqreturn_t cp_interrupt (int irq, void *dev_instance)
|
||||
@ -647,9 +644,9 @@ static irqreturn_t cp_interrupt (int irq, void *dev_instance)
|
||||
}
|
||||
|
||||
if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr))
|
||||
if (netif_rx_schedule_prep(dev)) {
|
||||
if (netif_rx_schedule_prep(dev, &cp->napi)) {
|
||||
cpw16_f(IntrMask, cp_norx_intr_mask);
|
||||
__netif_rx_schedule(dev);
|
||||
__netif_rx_schedule(dev, &cp->napi);
|
||||
}
|
||||
|
||||
if (status & (TxOK | TxErr | TxEmpty | SWInt))
|
||||
@ -704,7 +701,7 @@ static void cp_tx (struct cp_private *cp)
|
||||
skb = cp->tx_skb[tx_tail];
|
||||
BUG_ON(!skb);
|
||||
|
||||
pci_unmap_single(cp->pdev, le64_to_cpu(txd->addr),
|
||||
dma_unmap_single(&cp->pdev->dev, le64_to_cpu(txd->addr),
|
||||
le32_to_cpu(txd->opts1) & 0xffff,
|
||||
PCI_DMA_TODEVICE);
|
||||
|
||||
@ -768,7 +765,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
|
||||
|
||||
#if CP_VLAN_TAG_USED
|
||||
if (cp->vlgrp && vlan_tx_tag_present(skb))
|
||||
vlan_tag = TxVlanTag | cpu_to_be16(vlan_tx_tag_get(skb));
|
||||
vlan_tag = TxVlanTag | swab16(vlan_tx_tag_get(skb));
|
||||
#endif
|
||||
|
||||
entry = cp->tx_head;
|
||||
@ -782,7 +779,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
|
||||
dma_addr_t mapping;
|
||||
|
||||
len = skb->len;
|
||||
mapping = pci_map_single(cp->pdev, skb->data, len, PCI_DMA_TODEVICE);
|
||||
mapping = dma_map_single(&cp->pdev->dev, skb->data, len, PCI_DMA_TODEVICE);
|
||||
CP_VLAN_TX_TAG(txd, vlan_tag);
|
||||
txd->addr = cpu_to_le64(mapping);
|
||||
wmb();
|
||||
@ -818,7 +815,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
|
||||
*/
|
||||
first_eor = eor;
|
||||
first_len = skb_headlen(skb);
|
||||
first_mapping = pci_map_single(cp->pdev, skb->data,
|
||||
first_mapping = dma_map_single(&cp->pdev->dev, skb->data,
|
||||
first_len, PCI_DMA_TODEVICE);
|
||||
cp->tx_skb[entry] = skb;
|
||||
entry = NEXT_TX(entry);
|
||||
@ -830,7 +827,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
|
||||
dma_addr_t mapping;
|
||||
|
||||
len = this_frag->size;
|
||||
mapping = pci_map_single(cp->pdev,
|
||||
mapping = dma_map_single(&cp->pdev->dev,
|
||||
((void *) page_address(this_frag->page) +
|
||||
this_frag->page_offset),
|
||||
len, PCI_DMA_TODEVICE);
|
||||
@ -1021,8 +1018,8 @@ static void cp_init_hw (struct cp_private *cp)
|
||||
cpw8_f (Cfg9346, Cfg9346_Unlock);
|
||||
|
||||
/* Restore our idea of the MAC address. */
|
||||
cpw32_f (MAC0 + 0, cpu_to_le32 (*(u32 *) (dev->dev_addr + 0)));
|
||||
cpw32_f (MAC0 + 4, cpu_to_le32 (*(u32 *) (dev->dev_addr + 4)));
|
||||
cpw32_f (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0)));
|
||||
cpw32_f (MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4)));
|
||||
|
||||
cp_start_hw(cp);
|
||||
cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */
|
||||
@ -1069,8 +1066,8 @@ static int cp_refill_rx (struct cp_private *cp)
|
||||
|
||||
skb_reserve(skb, RX_OFFSET);
|
||||
|
||||
mapping = pci_map_single(cp->pdev, skb->data, cp->rx_buf_sz,
|
||||
PCI_DMA_FROMDEVICE);
|
||||
mapping = dma_map_single(&cp->pdev->dev, skb->data,
|
||||
cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
|
||||
cp->rx_skb[i] = skb;
|
||||
|
||||
cp->rx_ring[i].opts2 = 0;
|
||||
@ -1110,7 +1107,8 @@ static int cp_alloc_rings (struct cp_private *cp)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
mem = pci_alloc_consistent(cp->pdev, CP_RING_BYTES, &cp->ring_dma);
|
||||
mem = dma_alloc_coherent(&cp->pdev->dev, CP_RING_BYTES,
|
||||
&cp->ring_dma, GFP_KERNEL);
|
||||
if (!mem)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -1128,7 +1126,7 @@ static void cp_clean_rings (struct cp_private *cp)
|
||||
for (i = 0; i < CP_RX_RING_SIZE; i++) {
|
||||
if (cp->rx_skb[i]) {
|
||||
desc = cp->rx_ring + i;
|
||||
pci_unmap_single(cp->pdev, le64_to_cpu(desc->addr),
|
||||
dma_unmap_single(&cp->pdev->dev,le64_to_cpu(desc->addr),
|
||||
cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
|
||||
dev_kfree_skb(cp->rx_skb[i]);
|
||||
}
|
||||
@ -1139,7 +1137,7 @@ static void cp_clean_rings (struct cp_private *cp)
|
||||
struct sk_buff *skb = cp->tx_skb[i];
|
||||
|
||||
desc = cp->tx_ring + i;
|
||||
pci_unmap_single(cp->pdev, le64_to_cpu(desc->addr),
|
||||
dma_unmap_single(&cp->pdev->dev,le64_to_cpu(desc->addr),
|
||||
le32_to_cpu(desc->opts1) & 0xffff,
|
||||
PCI_DMA_TODEVICE);
|
||||
if (le32_to_cpu(desc->opts1) & LastFrag)
|
||||
@ -1158,7 +1156,8 @@ static void cp_clean_rings (struct cp_private *cp)
|
||||
static void cp_free_rings (struct cp_private *cp)
|
||||
{
|
||||
cp_clean_rings(cp);
|
||||
pci_free_consistent(cp->pdev, CP_RING_BYTES, cp->rx_ring, cp->ring_dma);
|
||||
dma_free_coherent(&cp->pdev->dev, CP_RING_BYTES, cp->rx_ring,
|
||||
cp->ring_dma);
|
||||
cp->rx_ring = NULL;
|
||||
cp->tx_ring = NULL;
|
||||
}
|
||||
@ -1175,6 +1174,8 @@ static int cp_open (struct net_device *dev)
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
napi_enable(&cp->napi);
|
||||
|
||||
cp_init_hw(cp);
|
||||
|
||||
rc = request_irq(dev->irq, cp_interrupt, IRQF_SHARED, dev->name, dev);
|
||||
@ -1188,6 +1189,7 @@ static int cp_open (struct net_device *dev)
|
||||
return 0;
|
||||
|
||||
err_out_hw:
|
||||
napi_disable(&cp->napi);
|
||||
cp_stop_hw(cp);
|
||||
cp_free_rings(cp);
|
||||
return rc;
|
||||
@ -1198,6 +1200,8 @@ static int cp_close (struct net_device *dev)
|
||||
struct cp_private *cp = netdev_priv(dev);
|
||||
unsigned long flags;
|
||||
|
||||
napi_disable(&cp->napi);
|
||||
|
||||
if (netif_msg_ifdown(cp))
|
||||
printk(KERN_DEBUG "%s: disabling interface\n", dev->name);
|
||||
|
||||
@ -1379,9 +1383,14 @@ static int cp_get_regs_len(struct net_device *dev)
|
||||
return CP_REGS_SIZE;
|
||||
}
|
||||
|
||||
static int cp_get_stats_count (struct net_device *dev)
|
||||
static int cp_get_sset_count (struct net_device *dev, int sset)
|
||||
{
|
||||
return CP_NUM_STATS;
|
||||
switch (sset) {
|
||||
case ETH_SS_STATS:
|
||||
return CP_NUM_STATS;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
|
||||
static int cp_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
|
||||
@ -1517,7 +1526,8 @@ static void cp_get_ethtool_stats (struct net_device *dev,
|
||||
dma_addr_t dma;
|
||||
int i;
|
||||
|
||||
nic_stats = pci_alloc_consistent(cp->pdev, sizeof(*nic_stats), &dma);
|
||||
nic_stats = dma_alloc_coherent(&cp->pdev->dev, sizeof(*nic_stats),
|
||||
&dma, GFP_KERNEL);
|
||||
if (!nic_stats)
|
||||
return;
|
||||
|
||||
@ -1552,13 +1562,13 @@ static void cp_get_ethtool_stats (struct net_device *dev,
|
||||
tmp_stats[i++] = cp->cp_stats.rx_frags;
|
||||
BUG_ON(i != CP_NUM_STATS);
|
||||
|
||||
pci_free_consistent(cp->pdev, sizeof(*nic_stats), nic_stats, dma);
|
||||
dma_free_coherent(&cp->pdev->dev, sizeof(*nic_stats), nic_stats, dma);
|
||||
}
|
||||
|
||||
static const struct ethtool_ops cp_ethtool_ops = {
|
||||
.get_drvinfo = cp_get_drvinfo,
|
||||
.get_regs_len = cp_get_regs_len,
|
||||
.get_stats_count = cp_get_stats_count,
|
||||
.get_sset_count = cp_get_sset_count,
|
||||
.get_settings = cp_get_settings,
|
||||
.set_settings = cp_set_settings,
|
||||
.nway_reset = cp_nway_reset,
|
||||
@ -1567,11 +1577,8 @@ static const struct ethtool_ops cp_ethtool_ops = {
|
||||
.set_msglevel = cp_set_msglevel,
|
||||
.get_rx_csum = cp_get_rx_csum,
|
||||
.set_rx_csum = cp_set_rx_csum,
|
||||
.get_tx_csum = ethtool_op_get_tx_csum,
|
||||
.set_tx_csum = ethtool_op_set_tx_csum, /* local! */
|
||||
.get_sg = ethtool_op_get_sg,
|
||||
.set_sg = ethtool_op_set_sg,
|
||||
.get_tso = ethtool_op_get_tso,
|
||||
.set_tso = ethtool_op_set_tso,
|
||||
.get_regs = cp_get_regs,
|
||||
.get_wol = cp_get_wol,
|
||||
@ -1821,6 +1828,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
void __iomem *regs;
|
||||
resource_size_t pciaddr;
|
||||
unsigned int addr_len, i, pci_using_dac;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
#ifndef MODULE
|
||||
static int version_printed;
|
||||
@ -1840,7 +1848,6 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
dev = alloc_etherdev(sizeof(struct cp_private));
|
||||
if (!dev)
|
||||
return -ENOMEM;
|
||||
SET_MODULE_OWNER(dev);
|
||||
SET_NETDEV_DEV(dev, &pdev->dev);
|
||||
|
||||
cp = netdev_priv(dev);
|
||||
@ -1923,8 +1930,8 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
/* read MAC address from EEPROM */
|
||||
addr_len = read_eeprom (regs, 0, 8) == 0x8129 ? 8 : 6;
|
||||
for (i = 0; i < 3; i++)
|
||||
((u16 *) (dev->dev_addr))[i] =
|
||||
le16_to_cpu (read_eeprom (regs, i + 7, addr_len));
|
||||
((__le16 *) (dev->dev_addr))[i] =
|
||||
cpu_to_le16(read_eeprom (regs, i + 7, addr_len));
|
||||
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
|
||||
|
||||
dev->open = cp_open;
|
||||
@ -1933,11 +1940,10 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
dev->hard_start_xmit = cp_start_xmit;
|
||||
dev->get_stats = cp_get_stats;
|
||||
dev->do_ioctl = cp_ioctl;
|
||||
dev->poll = cp_rx_poll;
|
||||
#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||
dev->poll_controller = cp_poll_controller;
|
||||
#endif
|
||||
dev->weight = 16; /* arbitrary? from NAPI_HOWTO.txt. */
|
||||
netif_napi_add(dev, &cp->napi, cp_rx_poll, 16);
|
||||
#ifdef BROKEN
|
||||
dev->change_mtu = cp_change_mtu;
|
||||
#endif
|
||||
@ -1964,13 +1970,10 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
goto err_out_iomap;
|
||||
|
||||
printk (KERN_INFO "%s: RTL-8139C+ at 0x%lx, "
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x, "
|
||||
"IRQ %d\n",
|
||||
"%s, IRQ %d\n",
|
||||
dev->name,
|
||||
dev->base_addr,
|
||||
dev->dev_addr[0], dev->dev_addr[1],
|
||||
dev->dev_addr[2], dev->dev_addr[3],
|
||||
dev->dev_addr[4], dev->dev_addr[5],
|
||||
print_mac(mac, dev->dev_addr),
|
||||
dev->irq);
|
||||
|
||||
pci_set_drvdata(pdev, dev);
|
||||
|
@ -291,198 +291,197 @@ static struct {
|
||||
|
||||
/* Symbolic offsets to registers. */
|
||||
enum RTL8139_registers {
|
||||
MAC0 = 0, /* Ethernet hardware address. */
|
||||
MAR0 = 8, /* Multicast filter. */
|
||||
TxStatus0 = 0x10, /* Transmit status (Four 32bit registers). */
|
||||
TxAddr0 = 0x20, /* Tx descriptors (also four 32bit). */
|
||||
RxBuf = 0x30,
|
||||
ChipCmd = 0x37,
|
||||
RxBufPtr = 0x38,
|
||||
RxBufAddr = 0x3A,
|
||||
IntrMask = 0x3C,
|
||||
IntrStatus = 0x3E,
|
||||
TxConfig = 0x40,
|
||||
RxConfig = 0x44,
|
||||
Timer = 0x48, /* A general-purpose counter. */
|
||||
RxMissed = 0x4C, /* 24 bits valid, write clears. */
|
||||
Cfg9346 = 0x50,
|
||||
Config0 = 0x51,
|
||||
Config1 = 0x52,
|
||||
FlashReg = 0x54,
|
||||
MediaStatus = 0x58,
|
||||
Config3 = 0x59,
|
||||
Config4 = 0x5A, /* absent on RTL-8139A */
|
||||
HltClk = 0x5B,
|
||||
MultiIntr = 0x5C,
|
||||
TxSummary = 0x60,
|
||||
BasicModeCtrl = 0x62,
|
||||
BasicModeStatus = 0x64,
|
||||
NWayAdvert = 0x66,
|
||||
NWayLPAR = 0x68,
|
||||
NWayExpansion = 0x6A,
|
||||
MAC0 = 0, /* Ethernet hardware address. */
|
||||
MAR0 = 8, /* Multicast filter. */
|
||||
TxStatus0 = 0x10, /* Transmit status (Four 32bit registers). */
|
||||
TxAddr0 = 0x20, /* Tx descriptors (also four 32bit). */
|
||||
RxBuf = 0x30,
|
||||
ChipCmd = 0x37,
|
||||
RxBufPtr = 0x38,
|
||||
RxBufAddr = 0x3A,
|
||||
IntrMask = 0x3C,
|
||||
IntrStatus = 0x3E,
|
||||
TxConfig = 0x40,
|
||||
RxConfig = 0x44,
|
||||
Timer = 0x48, /* A general-purpose counter. */
|
||||
RxMissed = 0x4C, /* 24 bits valid, write clears. */
|
||||
Cfg9346 = 0x50,
|
||||
Config0 = 0x51,
|
||||
Config1 = 0x52,
|
||||
FlashReg = 0x54,
|
||||
MediaStatus = 0x58,
|
||||
Config3 = 0x59,
|
||||
Config4 = 0x5A, /* absent on RTL-8139A */
|
||||
HltClk = 0x5B,
|
||||
MultiIntr = 0x5C,
|
||||
TxSummary = 0x60,
|
||||
BasicModeCtrl = 0x62,
|
||||
BasicModeStatus = 0x64,
|
||||
NWayAdvert = 0x66,
|
||||
NWayLPAR = 0x68,
|
||||
NWayExpansion = 0x6A,
|
||||
/* Undocumented registers, but required for proper operation. */
|
||||
FIFOTMS = 0x70, /* FIFO Control and test. */
|
||||
CSCR = 0x74, /* Chip Status and Configuration Register. */
|
||||
PARA78 = 0x78,
|
||||
PARA7c = 0x7c, /* Magic transceiver parameter register. */
|
||||
Config5 = 0xD8, /* absent on RTL-8139A */
|
||||
FIFOTMS = 0x70, /* FIFO Control and test. */
|
||||
CSCR = 0x74, /* Chip Status and Configuration Register. */
|
||||
PARA78 = 0x78,
|
||||
PARA7c = 0x7c, /* Magic transceiver parameter register. */
|
||||
Config5 = 0xD8, /* absent on RTL-8139A */
|
||||
};
|
||||
|
||||
enum ClearBitMasks {
|
||||
MultiIntrClear = 0xF000,
|
||||
ChipCmdClear = 0xE2,
|
||||
Config1Clear = (1<<7)|(1<<6)|(1<<3)|(1<<2)|(1<<1),
|
||||
MultiIntrClear = 0xF000,
|
||||
ChipCmdClear = 0xE2,
|
||||
Config1Clear = (1<<7)|(1<<6)|(1<<3)|(1<<2)|(1<<1),
|
||||
};
|
||||
|
||||
enum ChipCmdBits {
|
||||
CmdReset = 0x10,
|
||||
CmdRxEnb = 0x08,
|
||||
CmdTxEnb = 0x04,
|
||||
RxBufEmpty = 0x01,
|
||||
CmdReset = 0x10,
|
||||
CmdRxEnb = 0x08,
|
||||
CmdTxEnb = 0x04,
|
||||
RxBufEmpty = 0x01,
|
||||
};
|
||||
|
||||
/* Interrupt register bits, using my own meaningful names. */
|
||||
enum IntrStatusBits {
|
||||
PCIErr = 0x8000,
|
||||
PCSTimeout = 0x4000,
|
||||
RxFIFOOver = 0x40,
|
||||
RxUnderrun = 0x20,
|
||||
RxOverflow = 0x10,
|
||||
TxErr = 0x08,
|
||||
TxOK = 0x04,
|
||||
RxErr = 0x02,
|
||||
RxOK = 0x01,
|
||||
PCIErr = 0x8000,
|
||||
PCSTimeout = 0x4000,
|
||||
RxFIFOOver = 0x40,
|
||||
RxUnderrun = 0x20,
|
||||
RxOverflow = 0x10,
|
||||
TxErr = 0x08,
|
||||
TxOK = 0x04,
|
||||
RxErr = 0x02,
|
||||
RxOK = 0x01,
|
||||
|
||||
RxAckBits = RxFIFOOver | RxOverflow | RxOK,
|
||||
RxAckBits = RxFIFOOver | RxOverflow | RxOK,
|
||||
};
|
||||
|
||||
enum TxStatusBits {
|
||||
TxHostOwns = 0x2000,
|
||||
TxUnderrun = 0x4000,
|
||||
TxStatOK = 0x8000,
|
||||
TxOutOfWindow = 0x20000000,
|
||||
TxAborted = 0x40000000,
|
||||
TxCarrierLost = 0x80000000,
|
||||
TxHostOwns = 0x2000,
|
||||
TxUnderrun = 0x4000,
|
||||
TxStatOK = 0x8000,
|
||||
TxOutOfWindow = 0x20000000,
|
||||
TxAborted = 0x40000000,
|
||||
TxCarrierLost = 0x80000000,
|
||||
};
|
||||
enum RxStatusBits {
|
||||
RxMulticast = 0x8000,
|
||||
RxPhysical = 0x4000,
|
||||
RxBroadcast = 0x2000,
|
||||
RxBadSymbol = 0x0020,
|
||||
RxRunt = 0x0010,
|
||||
RxTooLong = 0x0008,
|
||||
RxCRCErr = 0x0004,
|
||||
RxBadAlign = 0x0002,
|
||||
RxStatusOK = 0x0001,
|
||||
RxMulticast = 0x8000,
|
||||
RxPhysical = 0x4000,
|
||||
RxBroadcast = 0x2000,
|
||||
RxBadSymbol = 0x0020,
|
||||
RxRunt = 0x0010,
|
||||
RxTooLong = 0x0008,
|
||||
RxCRCErr = 0x0004,
|
||||
RxBadAlign = 0x0002,
|
||||
RxStatusOK = 0x0001,
|
||||
};
|
||||
|
||||
/* Bits in RxConfig. */
|
||||
enum rx_mode_bits {
|
||||
AcceptErr = 0x20,
|
||||
AcceptRunt = 0x10,
|
||||
AcceptBroadcast = 0x08,
|
||||
AcceptMulticast = 0x04,
|
||||
AcceptMyPhys = 0x02,
|
||||
AcceptAllPhys = 0x01,
|
||||
AcceptErr = 0x20,
|
||||
AcceptRunt = 0x10,
|
||||
AcceptBroadcast = 0x08,
|
||||
AcceptMulticast = 0x04,
|
||||
AcceptMyPhys = 0x02,
|
||||
AcceptAllPhys = 0x01,
|
||||
};
|
||||
|
||||
/* Bits in TxConfig. */
|
||||
enum tx_config_bits {
|
||||
|
||||
/* Interframe Gap Time. Only TxIFG96 doesn't violate IEEE 802.3 */
|
||||
TxIFGShift = 24,
|
||||
TxIFG84 = (0 << TxIFGShift), /* 8.4us / 840ns (10 / 100Mbps) */
|
||||
TxIFG88 = (1 << TxIFGShift), /* 8.8us / 880ns (10 / 100Mbps) */
|
||||
TxIFG92 = (2 << TxIFGShift), /* 9.2us / 920ns (10 / 100Mbps) */
|
||||
TxIFG96 = (3 << TxIFGShift), /* 9.6us / 960ns (10 / 100Mbps) */
|
||||
TxIFGShift = 24,
|
||||
TxIFG84 = (0 << TxIFGShift), /* 8.4us / 840ns (10 / 100Mbps) */
|
||||
TxIFG88 = (1 << TxIFGShift), /* 8.8us / 880ns (10 / 100Mbps) */
|
||||
TxIFG92 = (2 << TxIFGShift), /* 9.2us / 920ns (10 / 100Mbps) */
|
||||
TxIFG96 = (3 << TxIFGShift), /* 9.6us / 960ns (10 / 100Mbps) */
|
||||
|
||||
TxLoopBack = (1 << 18) | (1 << 17), /* enable loopback test mode */
|
||||
TxCRC = (1 << 16), /* DISABLE appending CRC to end of Tx packets */
|
||||
TxClearAbt = (1 << 0), /* Clear abort (WO) */
|
||||
TxDMAShift = 8, /* DMA burst value (0-7) is shifted this many bits */
|
||||
TxRetryShift = 4, /* TXRR value (0-15) is shifted this many bits */
|
||||
TxLoopBack = (1 << 18) | (1 << 17), /* enable loopback test mode */
|
||||
TxCRC = (1 << 16), /* DISABLE Tx pkt CRC append */
|
||||
TxClearAbt = (1 << 0), /* Clear abort (WO) */
|
||||
TxDMAShift = 8, /* DMA burst value (0-7) is shifted X many bits */
|
||||
TxRetryShift = 4, /* TXRR value (0-15) is shifted X many bits */
|
||||
|
||||
TxVersionMask = 0x7C800000, /* mask out version bits 30-26, 23 */
|
||||
TxVersionMask = 0x7C800000, /* mask out version bits 30-26, 23 */
|
||||
};
|
||||
|
||||
/* Bits in Config1 */
|
||||
enum Config1Bits {
|
||||
Cfg1_PM_Enable = 0x01,
|
||||
Cfg1_VPD_Enable = 0x02,
|
||||
Cfg1_PIO = 0x04,
|
||||
Cfg1_MMIO = 0x08,
|
||||
LWAKE = 0x10, /* not on 8139, 8139A */
|
||||
Cfg1_PM_Enable = 0x01,
|
||||
Cfg1_VPD_Enable = 0x02,
|
||||
Cfg1_PIO = 0x04,
|
||||
Cfg1_MMIO = 0x08,
|
||||
LWAKE = 0x10, /* not on 8139, 8139A */
|
||||
Cfg1_Driver_Load = 0x20,
|
||||
Cfg1_LED0 = 0x40,
|
||||
Cfg1_LED1 = 0x80,
|
||||
SLEEP = (1 << 1), /* only on 8139, 8139A */
|
||||
PWRDN = (1 << 0), /* only on 8139, 8139A */
|
||||
Cfg1_LED0 = 0x40,
|
||||
Cfg1_LED1 = 0x80,
|
||||
SLEEP = (1 << 1), /* only on 8139, 8139A */
|
||||
PWRDN = (1 << 0), /* only on 8139, 8139A */
|
||||
};
|
||||
|
||||
/* Bits in Config3 */
|
||||
enum Config3Bits {
|
||||
Cfg3_FBtBEn = (1 << 0), /* 1 = Fast Back to Back */
|
||||
Cfg3_FuncRegEn = (1 << 1), /* 1 = enable CardBus Function registers */
|
||||
Cfg3_CLKRUN_En = (1 << 2), /* 1 = enable CLKRUN */
|
||||
Cfg3_CardB_En = (1 << 3), /* 1 = enable CardBus registers */
|
||||
Cfg3_LinkUp = (1 << 4), /* 1 = wake up on link up */
|
||||
Cfg3_Magic = (1 << 5), /* 1 = wake up on Magic Packet (tm) */
|
||||
Cfg3_PARM_En = (1 << 6), /* 0 = software can set twister parameters */
|
||||
Cfg3_GNTSel = (1 << 7), /* 1 = delay 1 clock from PCI GNT signal */
|
||||
Cfg3_FBtBEn = (1 << 0), /* 1 = Fast Back to Back */
|
||||
Cfg3_FuncRegEn = (1 << 1), /* 1 = enable CardBus Function registers */
|
||||
Cfg3_CLKRUN_En = (1 << 2), /* 1 = enable CLKRUN */
|
||||
Cfg3_CardB_En = (1 << 3), /* 1 = enable CardBus registers */
|
||||
Cfg3_LinkUp = (1 << 4), /* 1 = wake up on link up */
|
||||
Cfg3_Magic = (1 << 5), /* 1 = wake up on Magic Packet (tm) */
|
||||
Cfg3_PARM_En = (1 << 6), /* 0 = software can set twister parameters */
|
||||
Cfg3_GNTSel = (1 << 7), /* 1 = delay 1 clock from PCI GNT signal */
|
||||
};
|
||||
|
||||
/* Bits in Config4 */
|
||||
enum Config4Bits {
|
||||
LWPTN = (1 << 2), /* not on 8139, 8139A */
|
||||
LWPTN = (1 << 2), /* not on 8139, 8139A */
|
||||
};
|
||||
|
||||
/* Bits in Config5 */
|
||||
enum Config5Bits {
|
||||
Cfg5_PME_STS = (1 << 0), /* 1 = PCI reset resets PME_Status */
|
||||
Cfg5_LANWake = (1 << 1), /* 1 = enable LANWake signal */
|
||||
Cfg5_LDPS = (1 << 2), /* 0 = save power when link is down */
|
||||
Cfg5_FIFOAddrPtr = (1 << 3), /* Realtek internal SRAM testing */
|
||||
Cfg5_UWF = (1 << 4), /* 1 = accept unicast wakeup frame */
|
||||
Cfg5_MWF = (1 << 5), /* 1 = accept multicast wakeup frame */
|
||||
Cfg5_BWF = (1 << 6), /* 1 = accept broadcast wakeup frame */
|
||||
Cfg5_PME_STS = (1 << 0), /* 1 = PCI reset resets PME_Status */
|
||||
Cfg5_LANWake = (1 << 1), /* 1 = enable LANWake signal */
|
||||
Cfg5_LDPS = (1 << 2), /* 0 = save power when link is down */
|
||||
Cfg5_FIFOAddrPtr= (1 << 3), /* Realtek internal SRAM testing */
|
||||
Cfg5_UWF = (1 << 4), /* 1 = accept unicast wakeup frame */
|
||||
Cfg5_MWF = (1 << 5), /* 1 = accept multicast wakeup frame */
|
||||
Cfg5_BWF = (1 << 6), /* 1 = accept broadcast wakeup frame */
|
||||
};
|
||||
|
||||
enum RxConfigBits {
|
||||
/* rx fifo threshold */
|
||||
RxCfgFIFOShift = 13,
|
||||
RxCfgFIFONone = (7 << RxCfgFIFOShift),
|
||||
RxCfgFIFOShift = 13,
|
||||
RxCfgFIFONone = (7 << RxCfgFIFOShift),
|
||||
|
||||
/* Max DMA burst */
|
||||
RxCfgDMAShift = 8,
|
||||
RxCfgDMAShift = 8,
|
||||
RxCfgDMAUnlimited = (7 << RxCfgDMAShift),
|
||||
|
||||
/* rx ring buffer length */
|
||||
RxCfgRcv8K = 0,
|
||||
RxCfgRcv16K = (1 << 11),
|
||||
RxCfgRcv32K = (1 << 12),
|
||||
RxCfgRcv64K = (1 << 11) | (1 << 12),
|
||||
RxCfgRcv8K = 0,
|
||||
RxCfgRcv16K = (1 << 11),
|
||||
RxCfgRcv32K = (1 << 12),
|
||||
RxCfgRcv64K = (1 << 11) | (1 << 12),
|
||||
|
||||
/* Disable packet wrap at end of Rx buffer. (not possible with 64k) */
|
||||
RxNoWrap = (1 << 7),
|
||||
RxNoWrap = (1 << 7),
|
||||
};
|
||||
|
||||
/* Twister tuning parameters from RealTek.
|
||||
Completely undocumented, but required to tune bad links on some boards. */
|
||||
enum CSCRBits {
|
||||
CSCR_LinkOKBit = 0x0400,
|
||||
CSCR_LinkChangeBit = 0x0800,
|
||||
CSCR_LinkStatusBits = 0x0f000,
|
||||
CSCR_LinkDownOffCmd = 0x003c0,
|
||||
CSCR_LinkDownCmd = 0x0f3c0,
|
||||
CSCR_LinkOKBit = 0x0400,
|
||||
CSCR_LinkChangeBit = 0x0800,
|
||||
CSCR_LinkStatusBits = 0x0f000,
|
||||
CSCR_LinkDownOffCmd = 0x003c0,
|
||||
CSCR_LinkDownCmd = 0x0f3c0,
|
||||
};
|
||||
|
||||
enum Cfg9346Bits {
|
||||
Cfg9346_Lock = 0x00,
|
||||
Cfg9346_Unlock = 0xC0,
|
||||
Cfg9346_Lock = 0x00,
|
||||
Cfg9346_Unlock = 0xC0,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
CH_8139 = 0,
|
||||
CH_8139 = 0,
|
||||
CH_8139_K,
|
||||
CH_8139A,
|
||||
CH_8139A_G,
|
||||
@ -495,8 +494,8 @@ typedef enum {
|
||||
} chip_t;
|
||||
|
||||
enum chip_flags {
|
||||
HasHltClk = (1 << 0),
|
||||
HasLWake = (1 << 1),
|
||||
HasHltClk = (1 << 0),
|
||||
HasLWake = (1 << 1),
|
||||
};
|
||||
|
||||
#define HW_REVID(b30, b29, b28, b27, b26, b23, b22) \
|
||||
@ -569,36 +568,46 @@ struct rtl_extra_stats {
|
||||
};
|
||||
|
||||
struct rtl8139_private {
|
||||
void __iomem *mmio_addr;
|
||||
int drv_flags;
|
||||
struct pci_dev *pci_dev;
|
||||
u32 msg_enable;
|
||||
struct net_device_stats stats;
|
||||
unsigned char *rx_ring;
|
||||
unsigned int cur_rx; /* Index into the Rx buffer of next Rx pkt. */
|
||||
unsigned int tx_flag;
|
||||
unsigned long cur_tx;
|
||||
unsigned long dirty_tx;
|
||||
unsigned char *tx_buf[NUM_TX_DESC]; /* Tx bounce buffers */
|
||||
unsigned char *tx_bufs; /* Tx bounce buffer region. */
|
||||
dma_addr_t rx_ring_dma;
|
||||
dma_addr_t tx_bufs_dma;
|
||||
signed char phys[4]; /* MII device addresses. */
|
||||
char twistie, twist_row, twist_col; /* Twister tune state. */
|
||||
unsigned int watchdog_fired : 1;
|
||||
unsigned int default_port : 4; /* Last dev->if_port value. */
|
||||
unsigned int have_thread : 1;
|
||||
spinlock_t lock;
|
||||
spinlock_t rx_lock;
|
||||
chip_t chipset;
|
||||
u32 rx_config;
|
||||
struct rtl_extra_stats xstats;
|
||||
void __iomem *mmio_addr;
|
||||
int drv_flags;
|
||||
struct pci_dev *pci_dev;
|
||||
u32 msg_enable;
|
||||
struct napi_struct napi;
|
||||
struct net_device *dev;
|
||||
struct net_device_stats stats;
|
||||
|
||||
struct delayed_work thread;
|
||||
unsigned char *rx_ring;
|
||||
unsigned int cur_rx; /* RX buf index of next pkt */
|
||||
dma_addr_t rx_ring_dma;
|
||||
|
||||
struct mii_if_info mii;
|
||||
unsigned int regs_len;
|
||||
unsigned long fifo_copy_timeout;
|
||||
unsigned int tx_flag;
|
||||
unsigned long cur_tx;
|
||||
unsigned long dirty_tx;
|
||||
unsigned char *tx_buf[NUM_TX_DESC]; /* Tx bounce buffers */
|
||||
unsigned char *tx_bufs; /* Tx bounce buffer region. */
|
||||
dma_addr_t tx_bufs_dma;
|
||||
|
||||
signed char phys[4]; /* MII device addresses. */
|
||||
|
||||
/* Twister tune state. */
|
||||
char twistie, twist_row, twist_col;
|
||||
|
||||
unsigned int watchdog_fired : 1;
|
||||
unsigned int default_port : 4; /* Last dev->if_port value. */
|
||||
unsigned int have_thread : 1;
|
||||
|
||||
spinlock_t lock;
|
||||
spinlock_t rx_lock;
|
||||
|
||||
chip_t chipset;
|
||||
u32 rx_config;
|
||||
struct rtl_extra_stats xstats;
|
||||
|
||||
struct delayed_work thread;
|
||||
|
||||
struct mii_if_info mii;
|
||||
unsigned int regs_len;
|
||||
unsigned long fifo_copy_timeout;
|
||||
};
|
||||
|
||||
MODULE_AUTHOR ("Jeff Garzik <jgarzik@pobox.com>");
|
||||
@ -625,10 +634,10 @@ static void rtl8139_tx_timeout (struct net_device *dev);
|
||||
static void rtl8139_init_ring (struct net_device *dev);
|
||||
static int rtl8139_start_xmit (struct sk_buff *skb,
|
||||
struct net_device *dev);
|
||||
static int rtl8139_poll(struct net_device *dev, int *budget);
|
||||
#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||
static void rtl8139_poll_controller(struct net_device *dev);
|
||||
#endif
|
||||
static int rtl8139_poll(struct napi_struct *napi, int budget);
|
||||
static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance);
|
||||
static int rtl8139_close (struct net_device *dev);
|
||||
static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
|
||||
@ -646,24 +655,11 @@ static const struct ethtool_ops rtl8139_ethtool_ops;
|
||||
#define RTL_W16_F(reg, val16) do { iowrite16 ((val16), ioaddr + (reg)); ioread16 (ioaddr + (reg)); } while (0)
|
||||
#define RTL_W32_F(reg, val32) do { iowrite32 ((val32), ioaddr + (reg)); ioread32 (ioaddr + (reg)); } while (0)
|
||||
|
||||
|
||||
#define MMIO_FLUSH_AUDIT_COMPLETE 1
|
||||
#if MMIO_FLUSH_AUDIT_COMPLETE
|
||||
|
||||
/* write MMIO register */
|
||||
#define RTL_W8(reg, val8) iowrite8 ((val8), ioaddr + (reg))
|
||||
#define RTL_W16(reg, val16) iowrite16 ((val16), ioaddr + (reg))
|
||||
#define RTL_W32(reg, val32) iowrite32 ((val32), ioaddr + (reg))
|
||||
|
||||
#else
|
||||
|
||||
/* write MMIO register, then flush */
|
||||
#define RTL_W8 RTL_W8_F
|
||||
#define RTL_W16 RTL_W16_F
|
||||
#define RTL_W32 RTL_W32_F
|
||||
|
||||
#endif /* MMIO_FLUSH_AUDIT_COMPLETE */
|
||||
|
||||
/* read MMIO register */
|
||||
#define RTL_R8(reg) ioread8 (ioaddr + (reg))
|
||||
#define RTL_R16(reg) ioread16 (ioaddr + (reg))
|
||||
@ -770,7 +766,6 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
|
||||
dev_err(&pdev->dev, "Unable to alloc new net device\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
SET_MODULE_OWNER(dev);
|
||||
SET_NETDEV_DEV(dev, &pdev->dev);
|
||||
|
||||
tp = netdev_priv(dev);
|
||||
@ -931,6 +926,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
|
||||
int i, addr_len, option;
|
||||
void __iomem *ioaddr;
|
||||
static int board_idx = -1;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
assert (pdev != NULL);
|
||||
assert (ent != NULL);
|
||||
@ -963,6 +959,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
|
||||
|
||||
assert (dev != NULL);
|
||||
tp = netdev_priv(dev);
|
||||
tp->dev = dev;
|
||||
|
||||
ioaddr = tp->mmio_addr;
|
||||
assert (ioaddr != NULL);
|
||||
@ -976,8 +973,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
|
||||
/* The Rtl8139-specific entries in the device structure. */
|
||||
dev->open = rtl8139_open;
|
||||
dev->hard_start_xmit = rtl8139_start_xmit;
|
||||
dev->poll = rtl8139_poll;
|
||||
dev->weight = 64;
|
||||
netif_napi_add(dev, &tp->napi, rtl8139_poll, 64);
|
||||
dev->stop = rtl8139_close;
|
||||
dev->get_stats = rtl8139_get_stats;
|
||||
dev->set_multicast_list = rtl8139_set_rx_mode;
|
||||
@ -1022,14 +1018,11 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
|
||||
pci_set_drvdata (pdev, dev);
|
||||
|
||||
printk (KERN_INFO "%s: %s at 0x%lx, "
|
||||
"%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, "
|
||||
"IRQ %d\n",
|
||||
"%s, IRQ %d\n",
|
||||
dev->name,
|
||||
board_info[ent->driver_data].name,
|
||||
dev->base_addr,
|
||||
dev->dev_addr[0], dev->dev_addr[1],
|
||||
dev->dev_addr[2], dev->dev_addr[3],
|
||||
dev->dev_addr[4], dev->dev_addr[5],
|
||||
print_mac(mac, dev->dev_addr),
|
||||
dev->irq);
|
||||
|
||||
printk (KERN_DEBUG "%s: Identified 8139 chip type '%s'\n",
|
||||
@ -1314,24 +1307,26 @@ static int rtl8139_open (struct net_device *dev)
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
tp->tx_bufs = pci_alloc_consistent(tp->pci_dev, TX_BUF_TOT_LEN,
|
||||
&tp->tx_bufs_dma);
|
||||
tp->rx_ring = pci_alloc_consistent(tp->pci_dev, RX_BUF_TOT_LEN,
|
||||
&tp->rx_ring_dma);
|
||||
tp->tx_bufs = dma_alloc_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
|
||||
&tp->tx_bufs_dma, GFP_KERNEL);
|
||||
tp->rx_ring = dma_alloc_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN,
|
||||
&tp->rx_ring_dma, GFP_KERNEL);
|
||||
if (tp->tx_bufs == NULL || tp->rx_ring == NULL) {
|
||||
free_irq(dev->irq, dev);
|
||||
|
||||
if (tp->tx_bufs)
|
||||
pci_free_consistent(tp->pci_dev, TX_BUF_TOT_LEN,
|
||||
dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
|
||||
tp->tx_bufs, tp->tx_bufs_dma);
|
||||
if (tp->rx_ring)
|
||||
pci_free_consistent(tp->pci_dev, RX_BUF_TOT_LEN,
|
||||
dma_free_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN,
|
||||
tp->rx_ring, tp->rx_ring_dma);
|
||||
|
||||
return -ENOMEM;
|
||||
|
||||
}
|
||||
|
||||
napi_enable(&tp->napi);
|
||||
|
||||
tp->mii.full_duplex = tp->mii.force_media;
|
||||
tp->tx_flag = (TX_FIFO_THRESH << 11) & 0x003f0000;
|
||||
|
||||
@ -2103,39 +2098,32 @@ static void rtl8139_weird_interrupt (struct net_device *dev,
|
||||
}
|
||||
}
|
||||
|
||||
static int rtl8139_poll(struct net_device *dev, int *budget)
|
||||
static int rtl8139_poll(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct rtl8139_private *tp = netdev_priv(dev);
|
||||
struct rtl8139_private *tp = container_of(napi, struct rtl8139_private, napi);
|
||||
struct net_device *dev = tp->dev;
|
||||
void __iomem *ioaddr = tp->mmio_addr;
|
||||
int orig_budget = min(*budget, dev->quota);
|
||||
int done = 1;
|
||||
int work_done;
|
||||
|
||||
spin_lock(&tp->rx_lock);
|
||||
if (likely(RTL_R16(IntrStatus) & RxAckBits)) {
|
||||
int work_done;
|
||||
work_done = 0;
|
||||
if (likely(RTL_R16(IntrStatus) & RxAckBits))
|
||||
work_done += rtl8139_rx(dev, tp, budget);
|
||||
|
||||
work_done = rtl8139_rx(dev, tp, orig_budget);
|
||||
if (likely(work_done > 0)) {
|
||||
*budget -= work_done;
|
||||
dev->quota -= work_done;
|
||||
done = (work_done < orig_budget);
|
||||
}
|
||||
}
|
||||
|
||||
if (done) {
|
||||
if (work_done < budget) {
|
||||
unsigned long flags;
|
||||
/*
|
||||
* Order is important since data can get interrupted
|
||||
* again when we think we are done.
|
||||
*/
|
||||
local_irq_save(flags);
|
||||
spin_lock_irqsave(&tp->lock, flags);
|
||||
RTL_W16_F(IntrMask, rtl8139_intr_mask);
|
||||
__netif_rx_complete(dev);
|
||||
local_irq_restore(flags);
|
||||
__netif_rx_complete(dev, napi);
|
||||
spin_unlock_irqrestore(&tp->lock, flags);
|
||||
}
|
||||
spin_unlock(&tp->rx_lock);
|
||||
|
||||
return !done;
|
||||
return work_done;
|
||||
}
|
||||
|
||||
/* The interrupt handler does all of the Rx thread work and cleans up
|
||||
@ -2180,9 +2168,9 @@ static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance)
|
||||
/* Receive packets are processed by poll routine.
|
||||
If not running start it now. */
|
||||
if (status & RxAckBits){
|
||||
if (netif_rx_schedule_prep(dev)) {
|
||||
if (netif_rx_schedule_prep(dev, &tp->napi)) {
|
||||
RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
|
||||
__netif_rx_schedule (dev);
|
||||
__netif_rx_schedule(dev, &tp->napi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2223,7 +2211,8 @@ static int rtl8139_close (struct net_device *dev)
|
||||
void __iomem *ioaddr = tp->mmio_addr;
|
||||
unsigned long flags;
|
||||
|
||||
netif_stop_queue (dev);
|
||||
netif_stop_queue(dev);
|
||||
napi_disable(&tp->napi);
|
||||
|
||||
if (netif_msg_ifdown(tp))
|
||||
printk(KERN_DEBUG "%s: Shutting down ethercard, status was 0x%4.4x.\n",
|
||||
@ -2248,10 +2237,10 @@ static int rtl8139_close (struct net_device *dev)
|
||||
|
||||
rtl8139_tx_clear (tp);
|
||||
|
||||
pci_free_consistent(tp->pci_dev, RX_BUF_TOT_LEN,
|
||||
tp->rx_ring, tp->rx_ring_dma);
|
||||
pci_free_consistent(tp->pci_dev, TX_BUF_TOT_LEN,
|
||||
tp->tx_bufs, tp->tx_bufs_dma);
|
||||
dma_free_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN,
|
||||
tp->rx_ring, tp->rx_ring_dma);
|
||||
dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
|
||||
tp->tx_bufs, tp->tx_bufs_dma);
|
||||
tp->rx_ring = NULL;
|
||||
tp->tx_bufs = NULL;
|
||||
|
||||
@ -2417,9 +2406,14 @@ static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs,
|
||||
}
|
||||
#endif /* CONFIG_8139TOO_MMIO */
|
||||
|
||||
static int rtl8139_get_stats_count(struct net_device *dev)
|
||||
static int rtl8139_get_sset_count(struct net_device *dev, int sset)
|
||||
{
|
||||
return RTL_NUM_STATS;
|
||||
switch (sset) {
|
||||
case ETH_SS_STATS:
|
||||
return RTL_NUM_STATS;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
|
||||
static void rtl8139_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
|
||||
@ -2450,7 +2444,7 @@ static const struct ethtool_ops rtl8139_ethtool_ops = {
|
||||
.get_wol = rtl8139_get_wol,
|
||||
.set_wol = rtl8139_set_wol,
|
||||
.get_strings = rtl8139_get_strings,
|
||||
.get_stats_count = rtl8139_get_stats_count,
|
||||
.get_sset_count = rtl8139_get_sset_count,
|
||||
.get_ethtool_stats = rtl8139_get_ethtool_stats,
|
||||
};
|
||||
|
||||
|
@ -326,7 +326,6 @@ struct i596_private {
|
||||
struct i596_cmd *cmd_head;
|
||||
int cmd_backlog;
|
||||
unsigned long last_cmd;
|
||||
struct net_device_stats stats;
|
||||
struct i596_rfd rfds[RX_RING_SIZE];
|
||||
struct i596_rbd rbds[RX_RING_SIZE];
|
||||
struct tx_cmd tx_cmds[TX_RING_SIZE];
|
||||
@ -360,7 +359,6 @@ static int i596_open(struct net_device *dev);
|
||||
static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev);
|
||||
static irqreturn_t i596_interrupt(int irq, void *dev_id);
|
||||
static int i596_close(struct net_device *dev);
|
||||
static struct net_device_stats *i596_get_stats(struct net_device *dev);
|
||||
static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd);
|
||||
static void i596_tx_timeout (struct net_device *dev);
|
||||
static void print_eth(unsigned char *buf, char *str);
|
||||
@ -828,7 +826,7 @@ memory_squeeze:
|
||||
if (skb == NULL) {
|
||||
/* XXX tulip.c can defer packets here!! */
|
||||
printk(KERN_WARNING "%s: i596_rx Memory squeeze, dropping packet.\n", dev->name);
|
||||
lp->stats.rx_dropped++;
|
||||
dev->stats.rx_dropped++;
|
||||
}
|
||||
else {
|
||||
if (!rx_in_place) {
|
||||
@ -844,28 +842,28 @@ memory_squeeze:
|
||||
#endif
|
||||
netif_rx(skb);
|
||||
dev->last_rx = jiffies;
|
||||
lp->stats.rx_packets++;
|
||||
lp->stats.rx_bytes+=pkt_len;
|
||||
dev->stats.rx_packets++;
|
||||
dev->stats.rx_bytes+=pkt_len;
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEB(DEB_ERRORS, printk(KERN_DEBUG "%s: Error, rfd.stat = 0x%04x\n",
|
||||
dev->name, rfd->stat));
|
||||
lp->stats.rx_errors++;
|
||||
dev->stats.rx_errors++;
|
||||
if ((rfd->stat) & 0x0001)
|
||||
lp->stats.collisions++;
|
||||
dev->stats.collisions++;
|
||||
if ((rfd->stat) & 0x0080)
|
||||
lp->stats.rx_length_errors++;
|
||||
dev->stats.rx_length_errors++;
|
||||
if ((rfd->stat) & 0x0100)
|
||||
lp->stats.rx_over_errors++;
|
||||
dev->stats.rx_over_errors++;
|
||||
if ((rfd->stat) & 0x0200)
|
||||
lp->stats.rx_fifo_errors++;
|
||||
dev->stats.rx_fifo_errors++;
|
||||
if ((rfd->stat) & 0x0400)
|
||||
lp->stats.rx_frame_errors++;
|
||||
dev->stats.rx_frame_errors++;
|
||||
if ((rfd->stat) & 0x0800)
|
||||
lp->stats.rx_crc_errors++;
|
||||
dev->stats.rx_crc_errors++;
|
||||
if ((rfd->stat) & 0x1000)
|
||||
lp->stats.rx_length_errors++;
|
||||
dev->stats.rx_length_errors++;
|
||||
}
|
||||
|
||||
/* Clear the buffer descriptor count and EOF + F flags */
|
||||
@ -916,8 +914,8 @@ static void i596_cleanup_cmd(struct net_device *dev, struct i596_private *lp)
|
||||
|
||||
dev_kfree_skb(skb);
|
||||
|
||||
lp->stats.tx_errors++;
|
||||
lp->stats.tx_aborted_errors++;
|
||||
dev->stats.tx_errors++;
|
||||
dev->stats.tx_aborted_errors++;
|
||||
|
||||
ptr->v_next = ptr->b_next = I596_NULL;
|
||||
tx_cmd->cmd.command = 0; /* Mark as free */
|
||||
@ -1038,10 +1036,10 @@ static void i596_tx_timeout (struct net_device *dev)
|
||||
DEB(DEB_ERRORS,printk(KERN_ERR "%s: transmit timed out, status resetting.\n",
|
||||
dev->name));
|
||||
|
||||
lp->stats.tx_errors++;
|
||||
dev->stats.tx_errors++;
|
||||
|
||||
/* Try to restart the adaptor */
|
||||
if (lp->last_restart == lp->stats.tx_packets) {
|
||||
if (lp->last_restart == dev->stats.tx_packets) {
|
||||
DEB(DEB_ERRORS,printk(KERN_ERR "Resetting board.\n"));
|
||||
/* Shutdown and restart */
|
||||
i596_reset (dev, lp, ioaddr);
|
||||
@ -1050,7 +1048,7 @@ static void i596_tx_timeout (struct net_device *dev)
|
||||
DEB(DEB_ERRORS,printk(KERN_ERR "Kicking board.\n"));
|
||||
lp->scb.command = CUC_START | RX_START;
|
||||
CA (dev);
|
||||
lp->last_restart = lp->stats.tx_packets;
|
||||
lp->last_restart = dev->stats.tx_packets;
|
||||
}
|
||||
|
||||
dev->trans_start = jiffies;
|
||||
@ -1082,7 +1080,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
if (tx_cmd->cmd.command) {
|
||||
printk(KERN_NOTICE "%s: xmit ring full, dropping packet.\n",
|
||||
dev->name);
|
||||
lp->stats.tx_dropped++;
|
||||
dev->stats.tx_dropped++;
|
||||
|
||||
dev_kfree_skb(skb);
|
||||
} else {
|
||||
@ -1107,8 +1105,8 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
DEB(DEB_TXADDR,print_eth(skb->data, "tx-queued"));
|
||||
i596_add_cmd(dev, &tx_cmd->cmd);
|
||||
|
||||
lp->stats.tx_packets++;
|
||||
lp->stats.tx_bytes += length;
|
||||
dev->stats.tx_packets++;
|
||||
dev->stats.tx_bytes += length;
|
||||
}
|
||||
|
||||
netif_start_queue(dev);
|
||||
@ -1118,15 +1116,12 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
|
||||
static void print_eth(unsigned char *add, char *str)
|
||||
{
|
||||
int i;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
DECLARE_MAC_BUF(mac2);
|
||||
|
||||
printk(KERN_DEBUG "i596 0x%p, ", add);
|
||||
for (i = 0; i < 6; i++)
|
||||
printk(" %02X", add[i + 6]);
|
||||
printk(" -->");
|
||||
for (i = 0; i < 6; i++)
|
||||
printk(" %02X", add[i]);
|
||||
printk(" %02X%02X, %s\n", add[12], add[13], str);
|
||||
printk(KERN_DEBUG "i596 0x%p, %s --> %s %02X%02X, %s\n",
|
||||
add, print_mac(mac, add + 6), print_mac(mac2, add),
|
||||
add[12], add[13], str);
|
||||
}
|
||||
|
||||
static int io = 0x300;
|
||||
@ -1234,11 +1229,9 @@ struct net_device * __init i82596_probe(int unit)
|
||||
DEB(DEB_PROBE,printk(KERN_INFO "%s", version));
|
||||
|
||||
/* The 82596-specific entries in the device structure. */
|
||||
SET_MODULE_OWNER(dev);
|
||||
dev->open = i596_open;
|
||||
dev->stop = i596_close;
|
||||
dev->hard_start_xmit = i596_start_xmit;
|
||||
dev->get_stats = i596_get_stats;
|
||||
dev->set_multicast_list = set_multicast_list;
|
||||
dev->tx_timeout = i596_tx_timeout;
|
||||
dev->watchdog_timeo = TX_TIMEOUT;
|
||||
@ -1344,17 +1337,17 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
|
||||
if ((ptr->status) & STAT_OK) {
|
||||
DEB(DEB_TXADDR,print_eth(skb->data, "tx-done"));
|
||||
} else {
|
||||
lp->stats.tx_errors++;
|
||||
dev->stats.tx_errors++;
|
||||
if ((ptr->status) & 0x0020)
|
||||
lp->stats.collisions++;
|
||||
dev->stats.collisions++;
|
||||
if (!((ptr->status) & 0x0040))
|
||||
lp->stats.tx_heartbeat_errors++;
|
||||
dev->stats.tx_heartbeat_errors++;
|
||||
if ((ptr->status) & 0x0400)
|
||||
lp->stats.tx_carrier_errors++;
|
||||
dev->stats.tx_carrier_errors++;
|
||||
if ((ptr->status) & 0x0800)
|
||||
lp->stats.collisions++;
|
||||
dev->stats.collisions++;
|
||||
if ((ptr->status) & 0x1000)
|
||||
lp->stats.tx_aborted_errors++;
|
||||
dev->stats.tx_aborted_errors++;
|
||||
}
|
||||
|
||||
dev_kfree_skb_irq(skb);
|
||||
@ -1409,8 +1402,8 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
|
||||
if (netif_running(dev)) {
|
||||
DEB(DEB_ERRORS,printk(KERN_ERR "%s: i596 interrupt receive unit inactive, status 0x%x\n", dev->name, status));
|
||||
ack_cmd |= RX_START;
|
||||
lp->stats.rx_errors++;
|
||||
lp->stats.rx_fifo_errors++;
|
||||
dev->stats.rx_errors++;
|
||||
dev->stats.rx_fifo_errors++;
|
||||
rebuild_rx_bufs(dev);
|
||||
}
|
||||
}
|
||||
@ -1493,14 +1486,6 @@ static int i596_close(struct net_device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct net_device_stats *
|
||||
i596_get_stats(struct net_device *dev)
|
||||
{
|
||||
struct i596_private *lp = dev->priv;
|
||||
|
||||
return &lp->stats;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set or clear the multicast filter for this adaptor.
|
||||
*/
|
||||
@ -1551,6 +1536,7 @@ static void set_multicast_list(struct net_device *dev)
|
||||
struct dev_mc_list *dmi;
|
||||
unsigned char *cp;
|
||||
struct mc_cmd *cmd;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
if (wait_cfg(dev, &lp->mc_cmd.cmd, 1000, "multicast list change request timed out"))
|
||||
return;
|
||||
@ -1561,8 +1547,8 @@ static void set_multicast_list(struct net_device *dev)
|
||||
for (dmi = dev->mc_list; cnt && dmi != NULL; dmi = dmi->next, cnt--, cp += 6) {
|
||||
memcpy(cp, dmi->dmi_addr, 6);
|
||||
if (i596_debug > 1)
|
||||
DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5]));
|
||||
DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %s\n",
|
||||
dev->name, print_mac(mac, cp)));
|
||||
}
|
||||
i596_add_cmd(dev, &cmd->cmd);
|
||||
}
|
||||
|
@ -135,6 +135,12 @@ config TUN
|
||||
|
||||
If you don't know what to use this for, you don't need it.
|
||||
|
||||
config VETH
|
||||
tristate "Virtual ethernet device"
|
||||
---help---
|
||||
The device is an ethernet tunnel. Devices are created in pairs. When
|
||||
one end receives the packet it appears on its pair and vice versa.
|
||||
|
||||
config NET_SB1000
|
||||
tristate "General Instruments Surfboard 1000"
|
||||
depends on PNP
|
||||
@ -159,6 +165,15 @@ config NET_SB1000
|
||||
|
||||
If you don't have this card, of course say N.
|
||||
|
||||
config IP1000
|
||||
tristate "IP1000 Gigabit Ethernet support"
|
||||
depends on PCI && EXPERIMENTAL
|
||||
---help---
|
||||
This driver supports IP1000 gigabit Ethernet cards.
|
||||
|
||||
To compile this driver as a module, choose M here: the module
|
||||
will be called ipg. This is recommended.
|
||||
|
||||
source "drivers/net/arcnet/Kconfig"
|
||||
|
||||
source "drivers/net/phy/Kconfig"
|
||||
@ -225,6 +240,13 @@ config AX88796
|
||||
AX88796 driver, using platform bus to provide
|
||||
chip detection and resources
|
||||
|
||||
config AX88796_93CX6
|
||||
bool "ASIX AX88796 external 93CX6 eeprom support"
|
||||
depends on AX88796
|
||||
select EEPROM_93CX6
|
||||
help
|
||||
Select this if your platform comes with an external 93CX6 eeprom.
|
||||
|
||||
config MACE
|
||||
tristate "MACE (Power Mac ethernet) support"
|
||||
depends on PPC_PMAC && PPC32
|
||||
@ -466,10 +488,6 @@ config MIPS_AU1X00_ENET
|
||||
If you have an Alchemy Semi AU1X00 based system
|
||||
say Y. Otherwise, say N.
|
||||
|
||||
config NET_SB1250_MAC
|
||||
tristate "SB1250 Ethernet support"
|
||||
depends on SIBYTE_SB1xxx_SOC
|
||||
|
||||
config SGI_IOC3_ETH
|
||||
bool "SGI IOC3 Ethernet"
|
||||
depends on PCI && SGI_IP27
|
||||
@ -480,26 +498,6 @@ config SGI_IOC3_ETH
|
||||
the Ethernet-HOWTO, available from
|
||||
<http://www.tldp.org/docs.html#howto>.
|
||||
|
||||
config SGI_IOC3_ETH_HW_RX_CSUM
|
||||
bool "Receive hardware checksums"
|
||||
depends on SGI_IOC3_ETH && INET
|
||||
default y
|
||||
help
|
||||
The SGI IOC3 network adapter supports TCP and UDP checksums in
|
||||
hardware to offload processing of these checksums from the CPU. At
|
||||
the moment only acceleration of IPv4 is supported. This option
|
||||
enables offloading for checksums on receive. If unsure, say Y.
|
||||
|
||||
config SGI_IOC3_ETH_HW_TX_CSUM
|
||||
bool "Transmit hardware checksums"
|
||||
depends on SGI_IOC3_ETH && INET
|
||||
default y
|
||||
help
|
||||
The SGI IOC3 network adapter supports TCP and UDP checksums in
|
||||
hardware to offload processing of these checksums from the CPU. At
|
||||
the moment only acceleration of IPv4 is supported. This option
|
||||
enables offloading for checksums on transmit. If unsure, say Y.
|
||||
|
||||
config MIPS_SIM_NET
|
||||
tristate "MIPS simulator Network device"
|
||||
depends on MIPS_SIM
|
||||
@ -843,6 +841,8 @@ config BFIN_MAC
|
||||
tristate "Blackfin 536/537 on-chip mac support"
|
||||
depends on NET_ETHERNET && (BF537 || BF536) && (!BF537_PORT_H)
|
||||
select CRC32
|
||||
select MII
|
||||
select PHYLIB
|
||||
select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE
|
||||
help
|
||||
This is the driver for blackfin on-chip mac device. Say Y if you want it
|
||||
@ -944,7 +944,7 @@ config SMC911X
|
||||
tristate "SMSC LAN911[5678] support"
|
||||
select CRC32
|
||||
select MII
|
||||
depends on ARCH_PXA
|
||||
depends on ARCH_PXA || SUPERH
|
||||
help
|
||||
This is a driver for SMSC's LAN911x series of Ethernet chipsets
|
||||
including the new LAN9115, LAN9116, LAN9117, and LAN9118.
|
||||
@ -1250,75 +1250,8 @@ config IBMVETH
|
||||
<file:Documentation/networking/net-modules.txt>. The module will
|
||||
be called ibmveth.
|
||||
|
||||
config IBM_EMAC
|
||||
tristate "PowerPC 4xx on-chip Ethernet support"
|
||||
depends on 4xx && !PPC_MERGE
|
||||
help
|
||||
This driver supports the PowerPC 4xx EMAC family of on-chip
|
||||
Ethernet controllers.
|
||||
|
||||
config IBM_EMAC_RXB
|
||||
int "Number of receive buffers"
|
||||
depends on IBM_EMAC
|
||||
default "128"
|
||||
|
||||
config IBM_EMAC_TXB
|
||||
int "Number of transmit buffers"
|
||||
depends on IBM_EMAC
|
||||
default "64"
|
||||
|
||||
config IBM_EMAC_POLL_WEIGHT
|
||||
int "MAL NAPI polling weight"
|
||||
depends on IBM_EMAC
|
||||
default "32"
|
||||
|
||||
config IBM_EMAC_RX_COPY_THRESHOLD
|
||||
int "RX skb copy threshold (bytes)"
|
||||
depends on IBM_EMAC
|
||||
default "256"
|
||||
|
||||
config IBM_EMAC_RX_SKB_HEADROOM
|
||||
int "Additional RX skb headroom (bytes)"
|
||||
depends on IBM_EMAC
|
||||
default "0"
|
||||
help
|
||||
Additional receive skb headroom. Note, that driver
|
||||
will always reserve at least 2 bytes to make IP header
|
||||
aligned, so usually there is no need to add any additional
|
||||
headroom.
|
||||
|
||||
If unsure, set to 0.
|
||||
|
||||
config IBM_EMAC_PHY_RX_CLK_FIX
|
||||
bool "PHY Rx clock workaround"
|
||||
depends on IBM_EMAC && (405EP || 440GX || 440EP || 440GR)
|
||||
help
|
||||
Enable this if EMAC attached to a PHY which doesn't generate
|
||||
RX clock if there is no link, if this is the case, you will
|
||||
see "TX disable timeout" or "RX disable timeout" in the system
|
||||
log.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config IBM_EMAC_DEBUG
|
||||
bool "Debugging"
|
||||
depends on IBM_EMAC
|
||||
default n
|
||||
|
||||
config IBM_EMAC_ZMII
|
||||
bool
|
||||
depends on IBM_EMAC && (NP405H || NP405L || 44x)
|
||||
default y
|
||||
|
||||
config IBM_EMAC_RGMII
|
||||
bool
|
||||
depends on IBM_EMAC && 440GX
|
||||
default y
|
||||
|
||||
config IBM_EMAC_TAH
|
||||
bool
|
||||
depends on IBM_EMAC && 440GX
|
||||
default y
|
||||
source "drivers/net/ibm_emac/Kconfig"
|
||||
source "drivers/net/ibm_newemac/Kconfig"
|
||||
|
||||
config NET_PCI
|
||||
bool "EISA, VLB, PCI and on board controllers"
|
||||
@ -1453,18 +1386,38 @@ config APRICOT
|
||||
called apricot.
|
||||
|
||||
config B44
|
||||
tristate "Broadcom 4400 ethernet support"
|
||||
depends on NET_PCI && PCI
|
||||
tristate "Broadcom 440x/47xx ethernet support"
|
||||
depends on SSB_POSSIBLE
|
||||
select SSB
|
||||
select MII
|
||||
help
|
||||
If you have a network (Ethernet) controller of this type, say Y and
|
||||
read the Ethernet-HOWTO, available from
|
||||
If you have a network (Ethernet) controller of this type, say Y
|
||||
or M and read the Ethernet-HOWTO, available from
|
||||
<http://www.tldp.org/docs.html#howto>.
|
||||
|
||||
To compile this driver as a module, choose M here and read
|
||||
<file:Documentation/networking/net-modules.txt>. The module will be
|
||||
called b44.
|
||||
|
||||
# Auto-select SSB PCI-HOST support, if possible
|
||||
config B44_PCI_AUTOSELECT
|
||||
bool
|
||||
depends on B44 && SSB_PCIHOST_POSSIBLE
|
||||
select SSB_PCIHOST
|
||||
default y
|
||||
|
||||
# Auto-select SSB PCICORE driver, if possible
|
||||
config B44_PCICORE_AUTOSELECT
|
||||
bool
|
||||
depends on B44 && SSB_DRIVER_PCICORE_POSSIBLE
|
||||
select SSB_DRIVER_PCICORE
|
||||
default y
|
||||
|
||||
config B44_PCI
|
||||
bool
|
||||
depends on B44_PCI_AUTOSELECT && B44_PCICORE_AUTOSELECT
|
||||
default y
|
||||
|
||||
config FORCEDETH
|
||||
tristate "nForce Ethernet support"
|
||||
depends on NET_PCI && PCI
|
||||
@ -1513,21 +1466,6 @@ config TC35815
|
||||
depends on NET_PCI && PCI && MIPS
|
||||
select MII
|
||||
|
||||
config DGRS
|
||||
tristate "Digi Intl. RightSwitch SE-X support"
|
||||
depends on NET_PCI && (PCI || EISA)
|
||||
---help---
|
||||
This is support for the Digi International RightSwitch series of
|
||||
PCI/EISA Ethernet switch cards. These include the SE-4 and the SE-6
|
||||
models. If you have a network card of this type, say Y and read the
|
||||
Ethernet-HOWTO, available from
|
||||
<http://www.tldp.org/docs.html#howto>. More specific
|
||||
information is contained in <file:Documentation/networking/dgrs.txt>.
|
||||
|
||||
To compile this driver as a module, choose M here and read
|
||||
<file:Documentation/networking/net-modules.txt>. The module
|
||||
will be called dgrs.
|
||||
|
||||
config EEPRO100
|
||||
tristate "EtherExpressPro/100 support (eepro100, original Becker driver)"
|
||||
depends on NET_PCI && PCI
|
||||
@ -2009,14 +1947,15 @@ config ACENIC_OMIT_TIGON_I
|
||||
The safe and default value for this is N.
|
||||
|
||||
config DL2K
|
||||
tristate "D-Link DL2000-based Gigabit Ethernet support"
|
||||
tristate "DL2000/TC902x-based Gigabit Ethernet support"
|
||||
depends on PCI
|
||||
select CRC32
|
||||
help
|
||||
This driver supports D-Link 2000-based gigabit ethernet cards, which
|
||||
includes
|
||||
This driver supports DL2000/TC902x-based Gigabit ethernet cards,
|
||||
which includes
|
||||
D-Link DGE-550T Gigabit Ethernet Adapter.
|
||||
D-Link DL2000-based Gigabit Ethernet Adapter.
|
||||
Sundance/Tamarack TC902x Gigabit Ethernet Adapter.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called dl2k.
|
||||
@ -2069,6 +2008,29 @@ config E1000_DISABLE_PACKET_SPLIT
|
||||
|
||||
If in doubt, say N.
|
||||
|
||||
config E1000E
|
||||
tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support"
|
||||
depends on PCI
|
||||
---help---
|
||||
This driver supports the PCI-Express Intel(R) PRO/1000 gigabit
|
||||
ethernet family of adapters. For PCI or PCI-X e1000 adapters,
|
||||
use the regular e1000 driver For more information on how to
|
||||
identify your adapter, go to the Adapter & Driver ID Guide at:
|
||||
|
||||
<http://support.intel.com/support/network/adapter/pro100/21397.htm>
|
||||
|
||||
For general information and support, go to the Intel support
|
||||
website at:
|
||||
|
||||
<http://support.intel.com>
|
||||
|
||||
More specific information on configuring the driver is in
|
||||
<file:Documentation/networking/e1000e.txt>.
|
||||
|
||||
To compile this driver as a module, choose M here and read
|
||||
<file:Documentation/networking/net-modules.txt>. The module
|
||||
will be called e1000e.
|
||||
|
||||
source "drivers/net/ixp2000/Kconfig"
|
||||
|
||||
config MYRI_SBUS
|
||||
@ -2153,6 +2115,19 @@ config R8169_VLAN
|
||||
|
||||
If in doubt, say Y.
|
||||
|
||||
config SB1250_MAC
|
||||
tristate "SB1250 Gigabit Ethernet support"
|
||||
depends on SIBYTE_SB1xxx_SOC
|
||||
select PHYLIB
|
||||
---help---
|
||||
This driver supports Gigabit Ethernet interfaces based on the
|
||||
Broadcom SiByte family of System-On-a-Chip parts. They include
|
||||
the BCM1120, BCM1125, BCM1125H, BCM1250, BCM1255, BCM1280, BCM1455
|
||||
and BCM1480 chips.
|
||||
|
||||
To compile this driver as a module, choose M here: the module
|
||||
will be called sb1250-mac.
|
||||
|
||||
config SIS190
|
||||
tristate "SiS190/SiS191 gigabit ethernet support"
|
||||
depends on PCI
|
||||
@ -2501,18 +2476,42 @@ config CHELSIO_T3
|
||||
config EHEA
|
||||
tristate "eHEA Ethernet support"
|
||||
depends on IBMEBUS
|
||||
select INET_LRO
|
||||
---help---
|
||||
This driver supports the IBM pSeries eHEA ethernet adapter.
|
||||
|
||||
To compile the driver as a module, choose M here. The module
|
||||
will be called ehea.
|
||||
|
||||
config IXGBE
|
||||
tristate "Intel(R) 10GbE PCI Express adapters support"
|
||||
depends on PCI
|
||||
---help---
|
||||
This driver supports Intel(R) 10GbE PCI Express family of
|
||||
adapters. For more information on how to identify your adapter, go
|
||||
to the Adapter & Driver ID Guide at:
|
||||
|
||||
<http://support.intel.com/support/network/adapter/pro100/21397.htm>
|
||||
|
||||
For general information and support, go to the Intel support
|
||||
website at:
|
||||
|
||||
<http://support.intel.com>
|
||||
|
||||
More specific information on configuring the driver is in
|
||||
<file:Documentation/networking/ixgbe.txt>.
|
||||
|
||||
To compile this driver as a module, choose M here and read
|
||||
<file:Documentation/networking/net-modules.txt>. The module
|
||||
will be called ixgbe.
|
||||
|
||||
config IXGB
|
||||
tristate "Intel(R) PRO/10GbE support"
|
||||
depends on PCI
|
||||
---help---
|
||||
This driver supports Intel(R) PRO/10GbE family of
|
||||
adapters. For more information on how to identify your adapter, go
|
||||
This driver supports Intel(R) PRO/10GbE family of adapters for
|
||||
PCI-X type cards. For PCI-E type cards, use the "ixgbe" driver
|
||||
instead. For more information on how to identify your adapter, go
|
||||
to the Adapter & Driver ID Guide at:
|
||||
|
||||
<http://support.intel.com/support/network/adapter/pro100/21397.htm>
|
||||
@ -2576,6 +2575,7 @@ config MYRI10GE
|
||||
depends on PCI
|
||||
select FW_LOADER
|
||||
select CRC32
|
||||
select INET_LRO
|
||||
---help---
|
||||
This driver supports Myricom Myri-10G Dual Protocol interface in
|
||||
Ethernet mode. If the eeprom on your board is not recent enough,
|
||||
@ -2594,6 +2594,13 @@ config NETXEN_NIC
|
||||
help
|
||||
This enables the support for NetXen's Gigabit Ethernet card.
|
||||
|
||||
config NIU
|
||||
tristate "Sun Neptune 10Gbit Ethernet support"
|
||||
depends on PCI
|
||||
help
|
||||
This enables support for cards based upon Sun's
|
||||
Neptune chipset.
|
||||
|
||||
config PASEMI_MAC
|
||||
tristate "PA Semi 1/10Gbit MAC"
|
||||
depends on PPC64 && PCI
|
||||
@ -2617,6 +2624,12 @@ config MLX4_DEBUG
|
||||
debug_level module parameter (which can also be set after
|
||||
the driver is loaded through sysfs).
|
||||
|
||||
config TEHUTI
|
||||
tristate "Tehuti Networks 10G Ethernet"
|
||||
depends on PCI
|
||||
help
|
||||
Tehuti Networks 10G Ethernet NIC
|
||||
|
||||
endif # NETDEV_10000
|
||||
|
||||
source "drivers/net/tokenring/Kconfig"
|
||||
@ -3074,6 +3087,16 @@ config NETCONSOLE
|
||||
If you want to log kernel messages over the network, enable this.
|
||||
See <file:Documentation/networking/netconsole.txt> for details.
|
||||
|
||||
config NETCONSOLE_DYNAMIC
|
||||
bool "Dynamic reconfiguration of logging targets (EXPERIMENTAL)"
|
||||
depends on NETCONSOLE && SYSFS && EXPERIMENTAL
|
||||
select CONFIGFS_FS
|
||||
help
|
||||
This option enables the ability to dynamically reconfigure target
|
||||
parameters (interface, IP addresses, port numbers, MAC addresses)
|
||||
at runtime through a userspace interface exported using configfs.
|
||||
See <file:Documentation/networking/netconsole.txt> for details.
|
||||
|
||||
config NETPOLL
|
||||
def_bool NETCONSOLE
|
||||
|
||||
|
@ -3,14 +3,19 @@
|
||||
#
|
||||
|
||||
obj-$(CONFIG_E1000) += e1000/
|
||||
obj-$(CONFIG_E1000E) += e1000e/
|
||||
obj-$(CONFIG_IBM_EMAC) += ibm_emac/
|
||||
obj-$(CONFIG_IBM_NEW_EMAC) += ibm_newemac/
|
||||
obj-$(CONFIG_IXGBE) += ixgbe/
|
||||
obj-$(CONFIG_IXGB) += ixgb/
|
||||
obj-$(CONFIG_IP1000) += ipg.o
|
||||
obj-$(CONFIG_CHELSIO_T1) += chelsio/
|
||||
obj-$(CONFIG_CHELSIO_T3) += cxgb3/
|
||||
obj-$(CONFIG_EHEA) += ehea/
|
||||
obj-$(CONFIG_BONDING) += bonding/
|
||||
obj-$(CONFIG_ATL1) += atl1/
|
||||
obj-$(CONFIG_GIANFAR) += gianfar_driver.o
|
||||
obj-$(CONFIG_TEHUTI) += tehuti.o
|
||||
|
||||
gianfar_driver-objs := gianfar.o \
|
||||
gianfar_ethtool.o \
|
||||
@ -39,7 +44,6 @@ obj-$(CONFIG_SUNVNET) += sunvnet.o
|
||||
obj-$(CONFIG_MACE) += mace.o
|
||||
obj-$(CONFIG_BMAC) += bmac.o
|
||||
|
||||
obj-$(CONFIG_DGRS) += dgrs.o
|
||||
obj-$(CONFIG_VORTEX) += 3c59x.o
|
||||
obj-$(CONFIG_TYPHOON) += typhoon.o
|
||||
obj-$(CONFIG_NE2K_PCI) += ne2k-pci.o 8390.o
|
||||
@ -106,7 +110,7 @@ obj-$(CONFIG_E2100) += e2100.o 8390.o
|
||||
obj-$(CONFIG_ES3210) += es3210.o 8390.o
|
||||
obj-$(CONFIG_LNE390) += lne390.o 8390.o
|
||||
obj-$(CONFIG_NE3210) += ne3210.o 8390.o
|
||||
obj-$(CONFIG_NET_SB1250_MAC) += sb1250-mac.o
|
||||
obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o
|
||||
obj-$(CONFIG_B44) += b44.o
|
||||
obj-$(CONFIG_FORCEDETH) += forcedeth.o
|
||||
obj-$(CONFIG_NE_H8300) += ne-h8300.o
|
||||
@ -193,6 +197,7 @@ obj-$(CONFIG_MACSONIC) += macsonic.o
|
||||
obj-$(CONFIG_MACMACE) += macmace.o
|
||||
obj-$(CONFIG_MAC89x0) += mac89x0.o
|
||||
obj-$(CONFIG_TUN) += tun.o
|
||||
obj-$(CONFIG_VETH) += veth.o
|
||||
obj-$(CONFIG_NET_NETX) += netx-eth.o
|
||||
obj-$(CONFIG_DL2K) += dl2k.o
|
||||
obj-$(CONFIG_R8169) += r8169.o
|
||||
@ -236,3 +241,4 @@ obj-$(CONFIG_NETCONSOLE) += netconsole.o
|
||||
obj-$(CONFIG_FS_ENET) += fs_enet/
|
||||
|
||||
obj-$(CONFIG_NETXEN_NIC) += netxen/
|
||||
obj-$(CONFIG_NIU) += niu.o
|
||||
|
@ -119,7 +119,6 @@ struct lance_private {
|
||||
int lance_log_rx_bufs, lance_log_tx_bufs;
|
||||
int rx_ring_mod_mask, tx_ring_mod_mask;
|
||||
|
||||
struct net_device_stats stats;
|
||||
int tpe; /* cable-selection is TPE */
|
||||
int auto_select; /* cable-selection by carrier */
|
||||
unsigned short busmaster_regval;
|
||||
@ -294,18 +293,18 @@ static int lance_rx (struct net_device *dev)
|
||||
|
||||
/* We got an incomplete frame? */
|
||||
if ((bits & LE_R1_POK) != LE_R1_POK) {
|
||||
lp->stats.rx_over_errors++;
|
||||
lp->stats.rx_errors++;
|
||||
dev->stats.rx_over_errors++;
|
||||
dev->stats.rx_errors++;
|
||||
continue;
|
||||
} else if (bits & LE_R1_ERR) {
|
||||
/* Count only the end frame as a rx error,
|
||||
* not the beginning
|
||||
*/
|
||||
if (bits & LE_R1_BUF) lp->stats.rx_fifo_errors++;
|
||||
if (bits & LE_R1_CRC) lp->stats.rx_crc_errors++;
|
||||
if (bits & LE_R1_OFL) lp->stats.rx_over_errors++;
|
||||
if (bits & LE_R1_FRA) lp->stats.rx_frame_errors++;
|
||||
if (bits & LE_R1_EOP) lp->stats.rx_errors++;
|
||||
if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++;
|
||||
if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++;
|
||||
if (bits & LE_R1_OFL) dev->stats.rx_over_errors++;
|
||||
if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++;
|
||||
if (bits & LE_R1_EOP) dev->stats.rx_errors++;
|
||||
} else {
|
||||
len = (rd->mblength & 0xfff) - 4;
|
||||
skb = dev_alloc_skb (len+2);
|
||||
@ -313,7 +312,7 @@ static int lance_rx (struct net_device *dev)
|
||||
if (skb == 0) {
|
||||
printk(KERN_WARNING "%s: Memory squeeze, "
|
||||
"deferring packet.\n", dev->name);
|
||||
lp->stats.rx_dropped++;
|
||||
dev->stats.rx_dropped++;
|
||||
rd->mblength = 0;
|
||||
rd->rmd1_bits = LE_R1_OWN;
|
||||
lp->rx_new = (lp->rx_new + 1) & lp->rx_ring_mod_mask;
|
||||
@ -328,8 +327,8 @@ static int lance_rx (struct net_device *dev)
|
||||
skb->protocol = eth_type_trans (skb, dev);
|
||||
netif_rx (skb);
|
||||
dev->last_rx = jiffies;
|
||||
lp->stats.rx_packets++;
|
||||
lp->stats.rx_bytes += len;
|
||||
dev->stats.rx_packets++;
|
||||
dev->stats.rx_bytes += len;
|
||||
}
|
||||
|
||||
/* Return the packet to the pool */
|
||||
@ -364,12 +363,12 @@ static int lance_tx (struct net_device *dev)
|
||||
if (td->tmd1_bits & LE_T1_ERR) {
|
||||
status = td->misc;
|
||||
|
||||
lp->stats.tx_errors++;
|
||||
if (status & LE_T3_RTY) lp->stats.tx_aborted_errors++;
|
||||
if (status & LE_T3_LCOL) lp->stats.tx_window_errors++;
|
||||
dev->stats.tx_errors++;
|
||||
if (status & LE_T3_RTY) dev->stats.tx_aborted_errors++;
|
||||
if (status & LE_T3_LCOL) dev->stats.tx_window_errors++;
|
||||
|
||||
if (status & LE_T3_CLOS) {
|
||||
lp->stats.tx_carrier_errors++;
|
||||
dev->stats.tx_carrier_errors++;
|
||||
if (lp->auto_select) {
|
||||
lp->tpe = 1 - lp->tpe;
|
||||
printk(KERN_ERR "%s: Carrier Lost, "
|
||||
@ -388,7 +387,7 @@ static int lance_tx (struct net_device *dev)
|
||||
/* buffer errors and underflows turn off the transmitter */
|
||||
/* Restart the adapter */
|
||||
if (status & (LE_T3_BUF|LE_T3_UFL)) {
|
||||
lp->stats.tx_fifo_errors++;
|
||||
dev->stats.tx_fifo_errors++;
|
||||
|
||||
printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, "
|
||||
"restarting\n", dev->name);
|
||||
@ -408,13 +407,13 @@ static int lance_tx (struct net_device *dev)
|
||||
|
||||
/* One collision before packet was sent. */
|
||||
if (td->tmd1_bits & LE_T1_EONE)
|
||||
lp->stats.collisions++;
|
||||
dev->stats.collisions++;
|
||||
|
||||
/* More than one collision, be optimistic. */
|
||||
if (td->tmd1_bits & LE_T1_EMORE)
|
||||
lp->stats.collisions += 2;
|
||||
dev->stats.collisions += 2;
|
||||
|
||||
lp->stats.tx_packets++;
|
||||
dev->stats.tx_packets++;
|
||||
}
|
||||
|
||||
j = (j + 1) & lp->tx_ring_mod_mask;
|
||||
@ -459,9 +458,9 @@ static irqreturn_t lance_interrupt (int irq, void *dev_id)
|
||||
|
||||
/* Log misc errors. */
|
||||
if (csr0 & LE_C0_BABL)
|
||||
lp->stats.tx_errors++; /* Tx babble. */
|
||||
dev->stats.tx_errors++; /* Tx babble. */
|
||||
if (csr0 & LE_C0_MISS)
|
||||
lp->stats.rx_errors++; /* Missed a Rx frame. */
|
||||
dev->stats.rx_errors++; /* Missed a Rx frame. */
|
||||
if (csr0 & LE_C0_MERR) {
|
||||
printk(KERN_ERR "%s: Bus master arbitration failure, status "
|
||||
"%4.4x.\n", dev->name, csr0);
|
||||
@ -606,7 +605,7 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
|
||||
/* Now, give the packet to the lance */
|
||||
ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN);
|
||||
lp->tx_new = (lp->tx_new+1) & lp->tx_ring_mod_mask;
|
||||
lp->stats.tx_bytes += skblen;
|
||||
dev->stats.tx_bytes += skblen;
|
||||
|
||||
if (TX_BUFFS_AVAIL <= 0)
|
||||
netif_stop_queue(dev);
|
||||
@ -621,13 +620,6 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
|
||||
return status;
|
||||
}
|
||||
|
||||
static struct net_device_stats *lance_get_stats (struct net_device *dev)
|
||||
{
|
||||
struct lance_private *lp = netdev_priv(dev);
|
||||
|
||||
return &lp->stats;
|
||||
}
|
||||
|
||||
/* taken from the depca driver */
|
||||
static void lance_load_multicast (struct net_device *dev)
|
||||
{
|
||||
@ -724,6 +716,7 @@ static int __devinit a2065_init_one(struct zorro_dev *z,
|
||||
unsigned long board, base_addr, mem_start;
|
||||
struct resource *r1, *r2;
|
||||
int err;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
board = z->resource.start;
|
||||
base_addr = board+A2065_LANCE;
|
||||
@ -746,7 +739,6 @@ static int __devinit a2065_init_one(struct zorro_dev *z,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
priv = netdev_priv(dev);
|
||||
|
||||
r1->name = dev->name;
|
||||
@ -783,7 +775,6 @@ static int __devinit a2065_init_one(struct zorro_dev *z,
|
||||
dev->hard_start_xmit = &lance_start_xmit;
|
||||
dev->tx_timeout = &lance_tx_timeout;
|
||||
dev->watchdog_timeo = 5*HZ;
|
||||
dev->get_stats = &lance_get_stats;
|
||||
dev->set_multicast_list = &lance_set_multicast;
|
||||
dev->dma = 0;
|
||||
|
||||
@ -802,9 +793,8 @@ static int __devinit a2065_init_one(struct zorro_dev *z,
|
||||
zorro_set_drvdata(z, dev);
|
||||
|
||||
printk(KERN_INFO "%s: A2065 at 0x%08lx, Ethernet Address "
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, board,
|
||||
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
|
||||
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
|
||||
"%s\n", dev->name, board,
|
||||
print_mac(mac, dev->dev_addr));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -103,8 +103,6 @@ static int __init do_ac3200_probe(struct net_device *dev)
|
||||
int irq = dev->irq;
|
||||
int mem_start = dev->mem_start;
|
||||
|
||||
SET_MODULE_OWNER(dev);
|
||||
|
||||
if (ioaddr > 0x1ff) /* Check a single specified location. */
|
||||
return ac_probe1(ioaddr, dev);
|
||||
else if (ioaddr > 0) /* Don't probe at all. */
|
||||
@ -148,6 +146,7 @@ out:
|
||||
static int __init ac_probe1(int ioaddr, struct net_device *dev)
|
||||
{
|
||||
int i, retval;
|
||||
DECLARE_MAC_BUF(mac);
|
||||
|
||||
if (!request_region(ioaddr, AC_IO_EXTENT, DRV_NAME))
|
||||
return -EBUSY;
|
||||
@ -169,10 +168,11 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
|
||||
inb(ioaddr + AC_ID_PORT + 2), inb(ioaddr + AC_ID_PORT + 3));
|
||||
#endif
|
||||
|
||||
printk("AC3200 in EISA slot %d, node", ioaddr/0x1000);
|
||||
for(i = 0; i < 6; i++)
|
||||
printk(" %02x", dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i));
|
||||
for (i = 0; i < 6; i++)
|
||||
dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i);
|
||||
|
||||
printk(KERN_DEBUG "AC3200 in EISA slot %d, node %s",
|
||||
ioaddr/0x1000, print_mac(mac, dev->dev_addr));
|
||||
#if 0
|
||||
/* Check the vendor ID/prefix. Redundant after checking the EISA ID */
|
||||
if (inb(ioaddr + AC_SA_PROM + 0) != AC_ADDR0
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user