* [NET-2.6.24][VETH][patch 1/1] fix bad netif_carrier_off place
From: dlezcano @ 2007-09-19 13:38 UTC (permalink / raw)
To: davem; +Cc: xemul, netdev
In-Reply-To: <20070919133821.495385952@mai.toulouse-stg.fr.ibm.com>
[-- Attachment #1: fix-veth-netcarrier-off.patch --]
[-- Type: text/plain, Size: 1145 bytes --]
From: Daniel Lezcano <dlezcano@fr.ibm.com>
If the netif_carrier_off is called before register_netdev
that will use and generate an event for a non initialized network
device and that leads to a Oops.
I moved the netif_carrier_off from the setup function after each
register_netdev call.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
drivers/net/veth.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: net-2.6.24/drivers/net/veth.c
===================================================================
--- net-2.6.24.orig/drivers/net/veth.c
+++ net-2.6.24/drivers/net/veth.c
@@ -286,7 +286,6 @@ static void veth_setup(struct net_device
dev->features |= NETIF_F_LLTX;
dev->init = veth_dev_init;
dev->destructor = veth_dev_free;
- netif_carrier_off(dev);
}
/*
@@ -357,6 +356,8 @@ static int veth_newlink(struct net_devic
if (err < 0)
goto err_register_peer;
+ netif_carrier_off(peer);
+
/*
* register dev last
*
@@ -382,6 +383,8 @@ static int veth_newlink(struct net_devic
if (err < 0)
goto err_register_dev;
+ netif_carrier_off(dev);
+
/*
* tie the deviced together
*/
--
^ permalink raw reply
* [PATCH] PHYLIB: IRQ event workqueue handling fixes
From: Maciej W. Rozycki @ 2007-09-19 14:38 UTC (permalink / raw)
To: Andy Fleming, Andrew Morton, Jeff Garzik; +Cc: netdev, linux-kernel
Keep track of disable_irq_nosync() invocations and call enable_irq() the
right number of times if work has been cancelled that would include them.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
Now that the call to flush_work_keventd() (problematic because of
rtnl_mutex being held) has been replaced by cancel_work_sync() another
issue has arisen and been left unresolved. As the MDIO bus cannot be
accessed from the interrupt context the PHY interrupt handler uses
disable_irq_nosync() to prevent from looping and schedules some work to be
done as a softirq, which, apart from handling the state change of the
originating PHY, is responsible for reenabling the interrupt. Now if the
interrupt line is shared by another device and a call to the softirq
handler has been cancelled, that call to enable_irq() never happens and
the other device cannot use its interrupt anymore as its stuck disabled.
I decided to use a counter rather than a flag because there may be more
than one call to phy_change() cancelled in the queue -- a real one and a
fake one triggered by free_irq() if DEBUG_SHIRQ is used, if nothing else.
Therefore because of its nesting property enable_irq() has to be called
the right number of times to match the number disable_irq_nosync() was
called and restore the original state. This DEBUG_SHIRQ feature is also
the reason why free_irq() has to be called before cancel_work_sync().
While at it I updated the comment about phy_stop_interrupts() being
called from `keventd' -- this is no longer relevant as the use of
cancel_work_sync() makes such an approach unnecessary. OTOH a similar
comment referring to flush_scheduled_work() in phy_stop() still applies as
using cancel_work_sync() there would be dangerous.
Checked with checkpatch.pl and at the run time (with and without
DEBUG_SHIRQ).
Please apply.
Maciej
patch-mips-2.6.23-rc5-20070904-phy-irq-fix-9
diff -up --recursive --new-file linux-mips-2.6.23-rc5-20070904.macro/drivers/net/phy/phy.c linux-mips-2.6.23-rc5-20070904/drivers/net/phy/phy.c
--- linux-mips-2.6.23-rc5-20070904.macro/drivers/net/phy/phy.c 2007-09-16 17:17:20.000000000 +0000
+++ linux-mips-2.6.23-rc5-20070904/drivers/net/phy/phy.c 2007-09-18 14:28:07.000000000 +0000
@@ -7,7 +7,7 @@
* Author: Andy Fleming
*
* Copyright (c) 2004 Freescale Semiconductor, Inc.
- * Copyright (c) 2006 Maciej W. Rozycki
+ * Copyright (c) 2006, 2007 Maciej W. Rozycki
*
* 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
@@ -35,6 +35,7 @@
#include <linux/timer.h>
#include <linux/workqueue.h>
+#include <asm/atomic.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>
@@ -561,6 +562,7 @@ static irqreturn_t phy_interrupt(int irq
* queue will write the PHY to disable and clear the
* interrupt, and then reenable the irq line. */
disable_irq_nosync(irq);
+ atomic_inc(&phydev->irq_disable);
schedule_work(&phydev->phy_queue);
@@ -631,6 +633,7 @@ int phy_start_interrupts(struct phy_devi
INIT_WORK(&phydev->phy_queue, phy_change);
+ atomic_set(&phydev->irq_disable, 0);
if (request_irq(phydev->irq, phy_interrupt,
IRQF_SHARED,
"phy_interrupt",
@@ -661,13 +664,22 @@ int phy_stop_interrupts(struct phy_devic
if (err)
phy_error(phydev);
+ free_irq(phydev->irq, phydev);
+
/*
- * Finish any pending work; we might have been scheduled to be called
- * from keventd ourselves, but cancel_work_sync() handles that.
+ * Cannot call flush_scheduled_work() here as desired because
+ * of rtnl_lock(), but we do not really care about what would
+ * be done, except from enable_irq(), so cancel any work
+ * possibly pending and take care of the matter below.
*/
cancel_work_sync(&phydev->phy_queue);
-
- free_irq(phydev->irq, phydev);
+ /*
+ * If work indeed has been cancelled, disable_irq() will have
+ * been left unbalanced from phy_interrupt() and enable_irq()
+ * has to be called so that other devices on the line work.
+ */
+ while (atomic_dec_return(&phydev->irq_disable) >= 0)
+ enable_irq(phydev->irq);
return err;
}
@@ -694,6 +706,7 @@ static void phy_change(struct work_struc
phydev->state = PHY_CHANGELINK;
spin_unlock(&phydev->lock);
+ atomic_dec(&phydev->irq_disable);
enable_irq(phydev->irq);
/* Reenable interrupts */
@@ -707,6 +720,7 @@ static void phy_change(struct work_struc
irq_enable_err:
disable_irq(phydev->irq);
+ atomic_inc(&phydev->irq_disable);
phy_err:
phy_error(phydev);
}
diff -up --recursive --new-file linux-mips-2.6.23-rc5-20070904.macro/include/linux/phy.h linux-mips-2.6.23-rc5-20070904/include/linux/phy.h
--- linux-mips-2.6.23-rc5-20070904.macro/include/linux/phy.h 2007-07-10 04:56:57.000000000 +0000
+++ linux-mips-2.6.23-rc5-20070904/include/linux/phy.h 2007-09-11 23:05:41.000000000 +0000
@@ -25,6 +25,8 @@
#include <linux/timer.h>
#include <linux/workqueue.h>
+#include <asm/atomic.h>
+
#define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \
SUPPORTED_10baseT_Full | \
SUPPORTED_100baseT_Half | \
@@ -281,6 +283,7 @@ struct phy_device {
/* Interrupt and Polling infrastructure */
struct work_struct phy_queue;
struct timer_list phy_timer;
+ atomic_t irq_disable;
spinlock_t lock;
^ permalink raw reply
* Re: e1000 driver and samba
From: L F @ 2007-09-19 14:53 UTC (permalink / raw)
To: Tantilov, Emil S
Cc: Florian Weimer, Urs Thuermann, Bill Fink, Brandeburg, Jesse,
Kok, Auke-jan H, James Chapman, netdev
In-Reply-To: <08FE5CC30C9A3F41BF819A502CF7BF6E02045257@fmsmsx411.amr.corp.intel.com>
Well,
the issue seems to have gone away as of this morning, but I am
somewhat unsure as to why.
Placement of some things were modified so as to allow shorter cables.
Now there are 3' CAT6 cables everywhere except for the 15' cable
between the two switches. All the cables are new, high quality
'tested' cables from a company nearby.
The server is now running 2.6.22.6 with the 7.6.5 e1000 driver from
intel.com and samba 3.0.26-1 ... and it seems to work. Samba will not
disconnect, even with all 8 clients running unreasonable read/write
loads and CRC and MD5 checksums of the transferred files all match.
The issue therefore seems to have gone away, but the reason why still
escapes me. I cannot believe that CAT5 cables under 10' in length were
causing it, because if that were the case
1) it would've shown itself, I presume, from the beginning
2) I could name dozens of different locations which would be having
the same problems
Samba 3.0.25 was definitely part of the problem and I sent a nice
nastygram to the debian maintainers, because -testing is not
-unstable, last I checked.
As to samba having any sort of data integrity capability, to the best
of my knowledge that has never been the case.
To answer further questions: I checked for file integrity with
CRC/CRC32/MD5 checksum utilities. They used to fail fairly
consistently, they have been fine all this morning.
Here is my samba config, for reference, comments etc. stripped.
[global]
workgroup = WORKGROUP
server string = %h server
wins support = yes
dns proxy = yes
name resolve order = host wins bcast
log level = 1
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
encrypt passwords = true
passdb backend = tdbsam
obey pam restrictions = yes
invalid users = root
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\sUNIX\spassword:* %n\n
*Retype\snew\sUNIX\spassword:* %n\n .
socket options = TCP_NODELAY IPTOS_LOWDELAY
domain master = yes
[backups]
comment = Backup Share
path = /var/archive/backups
browseable = yes
writeable = no
guest ok = no
write list = samba
force user = samba
[downloads]
comment = Downloads Share
path = /var/archive/downloads
browseable = yes
writeable = no
guest ok = no
read list = samba
write list = samba
force user = samba
There is nothing there that I would deem unusual. Since the transition
to 2.6 kernels I have been omitting the buffer statements in the
socket options.
I have one further question: what should I be doing with the TSO and
flow control? As of now, TSO is on but flow control is off.
I'd like to thank everyone who helped and I'll be trying to see if the
realtek integrated NIC works next.
Luigi Fabio
^ permalink raw reply
* Re: Please pull 'iwlwifi' branch of wireless-2.6
From: John W. Linville @ 2007-09-19 14:57 UTC (permalink / raw)
To: Jeff Garzik
Cc: David Miller, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <46F12414.8000900-o2qLIJkoznsdnm+yROfE0A@public.gmane.org>
On Wed, Sep 19, 2007 at 09:28:52AM -0400, Jeff Garzik wrote:
> David Miller wrote:
> >Jeff, if you have no objections I'll pull this into net-2.6.24
> Given that there is now a large backlog of new drivers to review, I
> think the preferred course of action would be to queue them into -mm
> (via net-2.6.24) for wider review and testing, and then make sure they
> all get a thorough review+ACK before pushing upstream.
FWIW, all of the wireless drivers posted recently have been in -mm
for some time thanks to Andrew's pulls of wireless-dev.
> So far, its sounding like each review has turned up stuff that wants
> fixing before the drivers commented upon go upstream.
I'm sure there are things worth fixing. Feel free to comment and
I/we will scramble to make the appropriate changes.
John
--
John W. Linville
linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org
^ permalink raw reply
* Re: [RFC PATCH] 2.6.22.6 netfilter: sk_setup_caps in ip_make_route_harder
From: Patrick McHardy @ 2007-09-19 15:00 UTC (permalink / raw)
To: lepton; +Cc: lkm, Netfilter Development Mailinglist, Linux Netdev List
In-Reply-To: <20070919093648.GA7491@router.lepton.home>
lepton wrote:
> Hi,
> For local src packets, it is better to update sk_route_caps in
> ip_route_me_harder.
This seems like a good idea to me. But why only for local src
(address) packets? This function can also be used for locally
generated packet that have been (f.i.) NATed to a foreign
address ...
> Signed-off-by: Lepton Wu <ytht.net@gmail.com>
>
> diff -pru -X linux-2.6.22.6/Documentation/dontdiff linux-2.6.22.6/net/ipv4/netfilter.c linux-2.6.22.6-lepton/net/ipv4/netfilter.c
> --- linux-2.6.22.6/net/ipv4/netfilter.c 2007-09-19 13:19:13.000000000 +0800
> +++ linux-2.6.22.6-lepton/net/ipv4/netfilter.c 2007-09-19 17:10:36.000000000 +0800
> @@ -37,6 +37,10 @@ int ip_route_me_harder(struct sk_buff **
> /* Drop old route. */
> dst_release((*pskb)->dst);
> (*pskb)->dst = &rt->u.dst;
> + if((*pskb)->sk){
> + dst_hold((*pskb)->dst);
> + sk_setup_caps((*pskb)->sk, (*pskb)->dst);
> + }
> } else {
> /* non-local src, find valid iif to satisfy
> * rp-filter when calling ip_route_input. */
>
^ permalink raw reply
* Re: drop association of connection-less socket
From: Ulrich Drepper @ 2007-09-19 15:04 UTC (permalink / raw)
To: netdev
In-Reply-To: <46F0CFB9.30808@redhat.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I guess the request is not that useful. The family of the socket is
determined earlier so to undo this it takes more of an effort. I
managed to get by for most cases without this change so no action needed.
- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQFG8TqZ2ijCOnn/RHQRAkXeAJ0RGW9zuP8xnLNVdnsHCLFR6IVJ8QCgwmBf
0ncI+FkqHE3vaYieIcHqOXo=
=UxXC
-----END PGP SIGNATURE-----
^ permalink raw reply
* Re: [PATCH 2.6.23-rc6] NETWORKING : Edge Triggered EPOLLOUT events get missed for TCP sockets
From: Davide Libenzi @ 2007-09-19 15:07 UTC (permalink / raw)
To: Nagendra Tomar; +Cc: netdev, Linux Kernel Mailing List, David Miller
In-Reply-To: <84176.52377.qm@web53710.mail.re2.yahoo.com>
On Wed, 19 Sep 2007, Nagendra Tomar wrote:
[ ... ]
Seems like epoll ate your message too :)
Can you repost your bug report and the patch?
- Davide
^ permalink raw reply
* [PATCH] PHYLIB: Fix an interrupt loop potential when halting
From: Maciej W. Rozycki @ 2007-09-19 15:09 UTC (permalink / raw)
To: Andy Fleming, Andrew Morton, Jeff Garzik; +Cc: netdev, linux-kernel
Ensure the PHY_HALTED state is not entered with the IRQ asserted as it
could lead to an interrupt loop.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
There is a small window in phy_stop(), where the state of the PHY machine
indicates it has been halted, but its interrupt output might still be
unmasked. If an interrupt goes active right at this moment it will loop
as the phy_interrupt() handler exits immediately with IRQ_NONE if the
halted state is seen. It is unsafe to extend the phydev spinlock to cover
phy_interrupt(). It is safe to swap the order of the actions though as
all the competing places to unmask the interrupt output of the PHY, which
are phy_change() and phy_timer() are already covered with the lock as is
the sequence in question.
Checked with checkpatch.pl and at the run time.
Please apply.
Maciej
patch-mips-2.6.23-rc5-20070904-phy-halt-0
diff -up --recursive --new-file linux-mips-2.6.23-rc5-20070904.macro/drivers/net/phy/phy.c linux-mips-2.6.23-rc5-20070904/drivers/net/phy/phy.c
--- linux-mips-2.6.23-rc5-20070904.macro/drivers/net/phy/phy.c 2007-09-04 04:55:42.000000000 +0000
+++ linux-mips-2.6.23-rc5-20070904/drivers/net/phy/phy.c 2007-09-16 17:17:20.000000000 +0000
@@ -722,8 +722,6 @@ void phy_stop(struct phy_device *phydev)
if (PHY_HALTED == phydev->state)
goto out_unlock;
- phydev->state = PHY_HALTED;
-
if (phydev->irq != PHY_POLL) {
/* Disable PHY Interrupts */
phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
@@ -732,6 +730,8 @@ void phy_stop(struct phy_device *phydev)
phy_clear_interrupt(phydev);
}
+ phydev->state = PHY_HALTED;
+
out_unlock:
spin_unlock(&phydev->lock);
^ permalink raw reply
* follow-up: discrepancy with POSIX
From: Ulrich Drepper @ 2007-09-19 15:21 UTC (permalink / raw)
To: netdev, Linux Kernel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
As a follow up to my question from yesterday on the netdev list what I
think is a real problem. Either in the kernel or in the POSIX spec.
The POSIX spec currently says this about SOCK_DGRAM sockets:
If address is a null address for the protocol, the socket’s peer
address shall be reset.
The term "null address" is not further specified but it will usually be
read to allow the following scenario to work out:
fd = socket(AT_INET6, ...)
connect(fd, ...some IPv6 address...)
struct sockaddr_in6 sin6 = { .sin6_family = AF_INET6 };
connect(fd, &sin6, sizeof (sin6));
connect(fd, ...some new IPv6 address...)
This does not work on Linux in the moment. The socket remains connected
to the old IPv6 address but the second connect() call does succeed (this
does not sound OK). What does work is if the connect call to
disassociate the address uses AF_UNSPEC instead of AF_INET6.
The question is: do people here think this is a problem in the POSIX
spec? Binding to :: and 0.0.0.0 isn't possible, so maybe the Linux
implementation should allow this?
If you think the POSIX spec is wrong (and can point to other
implementations doing the same as Linux) let me know and I'll work on
getting the spec changed.
- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQFG8T6L2ijCOnn/RHQRAnSRAJ9sXDGG9OepEQWQInaPgwxCWlaH6wCghqim
ULttg5/lU8c1rSpBnoRCjB8=
=nGVv
-----END PGP SIGNATURE-----
^ permalink raw reply
* Re: S2io: Support for add/delete/store/restore ethernet addresses
From: Jeff Garzik @ 2007-09-19 15:23 UTC (permalink / raw)
To: Sivakumar Subramani; +Cc: netdev
> S2io: Support for add/delete/store/restore ethernet addresses
>
> - Support to add/delete/store/restore 64 and 128 Ethernet addresses
> for Xframe I and Xframe II respectively.
>
> Signed-off-by: Sreenivasa Honnur <sreenivasa.honnur@neterion.com>
Please resend this against the latest netdev-2.6.git#upstream, since it
needs to be re-merged with the latest net-2.6.24 changes.
^ permalink raw reply
* Re: [RFC PATCH] 2.6.22.6 netfilter: sk_setup_caps in ip_make_route_harder
From: Patrick McHardy @ 2007-09-19 15:17 UTC (permalink / raw)
To: lepton; +Cc: Netfilter Development Mailinglist, Linux Netdev List
In-Reply-To: <46F13999.30700@trash.net>
Patrick McHardy wrote:
> lepton wrote:
>
>>Hi,
>> For local src packets, it is better to update sk_route_caps in
>> ip_route_me_harder.
>
>
>
> This seems like a good idea to me. But why only for local src
> (address) packets? This function can also be used for locally
> generated packet that have been (f.i.) NATed to a foreign
> address ...
Actually, I'm afraid it might break some setups. Rerouting is
done per packet, but if we cache the dst_entry for the socket,
all packets from that socket will be routed similar.
^ permalink raw reply
* Re: [RESEND][PATCH 2/4 Rev-3] Add new timeval_to_sec function
From: Stephen Hemminger @ 2007-09-19 15:29 UTC (permalink / raw)
To: Varun Chandramohan
Cc: davem, netdev, kaber, socketcan, krkumar2, tgraf, varuncha
In-Reply-To: <20070919092407.ecd87071.varunc@linux.vnet.ibm.com>
On Wed, 19 Sep 2007 09:24:07 +0530
Varun Chandramohan <varunc@linux.vnet.ibm.com> wrote:
> A new function for converting timeval to time_t is added in netlink.h. Its a common function used in differentplaces. The reason for adding this function in netlink.h is that its used by netlink for stats purpose.
>
> Signed-off-by: Varun Chandramohan <varunc@linux.vnet.ibm.com>
> ---
> include/net/netlink.h | 13 +++++++++++++
> 1 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/include/net/netlink.h b/include/net/netlink.h
> index d7b824b..f86cc59 100644
> --- a/include/net/netlink.h
> +++ b/include/net/netlink.h
> @@ -1100,4 +1100,17 @@ static inline int nla_validate_nested(st
> #define nla_for_each_nested(pos, nla, rem) \
> nla_for_each_attr(pos, nla_data(nla), nla_len(nla), rem)
>
> +/**
> + * timeval_to_sec - Convert timeval to seconds
> + * @tv: pointer to the timeval variable to be converted
> + *
> + * Returns the seconds representation of timeval parameter.
> + * Note : Here we round up the value. We dont need accuracy.
> + * This is mainly used in netlink for stats purpose.
> + */
> +static inline time_t timeval_to_sec(const struct timeval *tv)
> +{
> + return (tv->tv_sec + (tv->tv_usec ? 1 : 0));
> +}
> +
> #endif
1. If needed it belongs in include/linux/time.h
2. You never adequately explained why the function rounds up? No other
statistical or time interface does rounding, why should this API round
and others do not?
--
Stephen Hemminger <shemminger@linux-foundation.org>
^ permalink raw reply
* [PATCH] ucc_geth: remove unnecessary asm/ocp.h include from ucc_geth_mii.c
From: Timur Tabi @ 2007-09-19 15:30 UTC (permalink / raw)
To: netdev; +Cc: Timur Tabi
ucc_geth_mii.c includes <asm/ocp.h>, but it never needed it. With commit
2f6c9d961081dc7b109eb19166244bcb2a5dfc28, the asm-powerpc => asm-ppc link
is removed, and so ucc_geth_mii.c can no longer include include/asm-ppc/ocp.h,
so the compile fails. This patch removes the #include line.
Signed-off-by: Timur Tabi <timur@freescale.com>
---
This patch is for the net-2.6.24 branch of the netdev-2.6.git repository.
drivers/net/ucc_geth_mii.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c
index 6c257b8..df884f0 100644
--- a/drivers/net/ucc_geth_mii.c
+++ b/drivers/net/ucc_geth_mii.c
@@ -32,7 +32,6 @@
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/platform_device.h>
-#include <asm/ocp.h>
#include <linux/crc32.h>
#include <linux/mii.h>
#include <linux/phy.h>
--
1.5.2.4
^ permalink raw reply related
* Re: new NAPI interface broken
From: Roland Dreier @ 2007-09-19 15:33 UTC (permalink / raw)
To: Jan-Bernd Themann; +Cc: David Miller, shemminger, netdev, themann, raisch
In-Reply-To: <200709181815.45954.ossthema@de.ibm.com>
> One other thing I observed is that I can not unload the module as the
> ref counter of the eth device is too low. I haven't tracked down the
> source of this problem yet.
I suspect that this is because netif_rx_reschedule() was missing a
dev_hold() to match the dev_put() in netif_rx_complete(). Dave merged
a fix for that problem yesterday, so current net-2.6.24 should be OK.
Let us know if it's not OK, because then there's another bug...
- R.
^ permalink raw reply
* [PATCH 2/4] Blackfin EMAC driver: add power management interface and change the bf537mac_reset to bf537mac_disable
From: Bryan Wu @ 2007-09-19 15:37 UTC (permalink / raw)
To: Jeff Garzik, linux-kernel, netdev, uclinux-dist-devel
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jeff Garzik <jeff@garzik.org>
---
drivers/net/bfin_mac.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index ead7be9..5cb4433 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -672,7 +672,7 @@ static void bf537mac_poll(struct net_device *dev)
}
#endif /* CONFIG_NET_POLL_CONTROLLER */
-static void bf537mac_reset(void)
+static void bf537mac_disable(void)
{
unsigned int opmode;
@@ -730,7 +730,7 @@ static void bf537mac_timeout(struct net_device *dev)
{
pr_debug("%s: %s\n", dev->name, __FUNCTION__);
- bf537mac_reset();
+ bf537mac_disable();
/* reset tx queue */
tx_list_tail = tx_list_head->next;
@@ -810,7 +810,7 @@ static int bf537mac_open(struct net_device *dev)
bf537mac_setphy(dev);
setup_system_regs(dev);
- bf537mac_reset();
+ bf537mac_disable();
bf537mac_enable(dev);
pr_debug("hardware init finished\n");
@@ -968,15 +968,30 @@ static int bfin_mac_remove(struct platform_device *pdev)
return 0;
}
-static int bfin_mac_suspend(struct platform_device *pdev, pm_message_t state)
+#ifdef CONFIG_PM
+static int bfin_mac_suspend(struct platform_device *pdev, pm_message_t mesg)
{
+ struct net_device *net_dev = platform_get_drvdata(pdev);
+
+ if (netif_running(net_dev))
+ bf537mac_close(net_dev);
+
return 0;
}
static int bfin_mac_resume(struct platform_device *pdev)
{
+ struct net_device *net_dev = platform_get_drvdata(pdev);
+
+ if (netif_running(net_dev))
+ bf537mac_open(net_dev);
+
return 0;
}
+#else
+#define bfin_mac_suspend NULL
+#define bfin_mac_resume NULL
+#endif /* CONFIG_PM */
static struct platform_driver bfin_mac_driver = {
.probe = bfin_mac_probe,
--
1.5.2
^ permalink raw reply related
* [PATCH 1/4] Blackfin EMAC driver: add function to change the MAC address
From: Bryan Wu @ 2007-09-19 15:37 UTC (permalink / raw)
To: Jeff Garzik, linux-kernel, netdev, uclinux-dist-devel,
Alex Landau
From: Alex Landau <lirsb@yahoo.com>
Date: Wed, 19 Sep 2007 23:14:18 +0800
Subject: [PATCH] Blackfin EMAC driver: add function to change the MAC address
Alex Landau writes in the forums:
Previously, changing the MAC address (e.g. via ifconfig) resulted
in a generic function to be called that only changed a variable in
memory. This patch also updated the Blackfin MAC address registers
to filter the correct new MAC.
Signed-off-by: Alex Landau <lirsb@yahoo.com>
Signed-off-by: Mike Frysinger <michael.frysinger@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jeff Garzik <jeff@garzik.org>
---
drivers/net/bfin_mac.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index cebe554..ead7be9 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -463,7 +463,7 @@ void setup_system_regs(struct net_device *dev)
bfin_write_DMA1_Y_MODIFY(0);
}
-void setup_mac_addr(u8 * mac_addr)
+static void setup_mac_addr(u8 *mac_addr)
{
u32 addr_low = le32_to_cpu(*(__le32 *) & mac_addr[0]);
u16 addr_hi = le16_to_cpu(*(__le16 *) & mac_addr[4]);
@@ -473,6 +473,16 @@ void setup_mac_addr(u8 * mac_addr)
bfin_write_EMAC_ADDRHI(addr_hi);
}
+static int bf537mac_set_mac_address(struct net_device *dev, void *p)
+{
+ struct sockaddr *addr = p;
+ if (netif_running(dev))
+ return -EBUSY;
+ memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+ setup_mac_addr(dev->dev_addr);
+ return 0;
+}
+
static void adjust_tx_list(void)
{
int timeout_cnt = MAX_TIMEOUT_CNT;
@@ -876,6 +886,7 @@ static int __init bf537mac_probe(struct net_device *dev)
dev->open = bf537mac_open;
dev->stop = bf537mac_close;
dev->hard_start_xmit = bf537mac_hard_start_xmit;
+ dev->set_mac_address = bf537mac_set_mac_address;
dev->tx_timeout = bf537mac_timeout;
dev->set_multicast_list = bf537mac_set_multicast_list;
#ifdef CONFIG_NET_POLL_CONTROLLER
--
1.5.2
^ permalink raw reply related
* [PATCH 4/4] Blackfin EMAC driver: add a select for the PHYLIB of this driver
From: Bryan Wu @ 2007-09-19 15:37 UTC (permalink / raw)
To: Jeff Garzik, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA,
uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b, Robin Getz
Since we are adding requirement for the PHYLIB for this driver, there should be a select for that
Cc: Robin Getz <robin.getz-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Bryan Wu <bryan.wu-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
---
drivers/net/Kconfig | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index fd284a9..ebba92d 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -838,6 +838,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
--
1.5.2
^ permalink raw reply related
* [PATCH net-2.6.24] eHEA: poll function update for new NAPI scheme
From: Jan-Bernd Themann @ 2007-09-19 15:40 UTC (permalink / raw)
To: David Miller
Cc: netdev, Christoph Raisch, Jan-Bernd Themann, linux-kernel,
linux-ppc, Marcus Eder, Thomas Klein
Update of ehea_poll function to work with new NAPI scheme.
Signed-off-by: Jan-Bernd Themann <themann@de.ibm.com>
---
Hi David,
this patch is built upon the patches provided by Mel Gorman
(2.6.23-rc6-mm1: Build failure on ppc64 drivers/net/ehea/ehea_main.c)
and Roland Dreier
([PATCH net-2.6.24] Fix refcounting problem with netif_rx_reschedule())
drivers/net/ehea/ehea_main.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index c5fc0b1..1bb39a7 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -609,6 +609,7 @@ static struct ehea_cqe *ehea_proc_cqes(struct ehea_port_res *pr, int my_quota)
}
#define EHEA_NAPI_POLL_NUM_BEFORE_IRQ 16
+#define EHEA_POLL_MAX_CQES 65535
static int ehea_poll(struct napi_struct *napi, int budget)
{
@@ -616,15 +617,18 @@ static int ehea_poll(struct napi_struct *napi, int budget)
struct net_device *dev = pr->port->netdev;
struct ehea_cqe *cqe;
struct ehea_cqe *cqe_skb = NULL;
- int force_irq, wqe_index, rx;
-
- cqe = ehea_poll_rq1(pr->qp, &wqe_index);
- cqe_skb = ehea_poll_cq(pr->send_cq);
+ int force_irq, wqe_index;
+ int rx = 0;
force_irq = (pr->poll_counter > EHEA_NAPI_POLL_NUM_BEFORE_IRQ);
+ cqe_skb = ehea_proc_cqes(pr, EHEA_POLL_MAX_CQES);
+
+ if (!force_irq)
+ rx += ehea_proc_rwqes(dev, pr, budget - rx);
- if ((!cqe && !cqe_skb) || force_irq) {
+ while ((rx != budget) || force_irq) {
pr->poll_counter = 0;
+ force_irq = 0;
netif_rx_complete(dev, napi);
ehea_reset_cq_ep(pr->recv_cq);
ehea_reset_cq_ep(pr->send_cq);
@@ -634,19 +638,16 @@ static int ehea_poll(struct napi_struct *napi, int budget)
cqe_skb = ehea_poll_cq(pr->send_cq);
if (!cqe && !cqe_skb)
- return 0;
+ return rx;
if (!netif_rx_reschedule(dev, napi))
- return 0;
- }
+ return rx;
- rx = ehea_proc_rwqes(dev, pr, budget);
- cqe = ehea_poll_rq1(pr->qp, &wqe_index);
- cqe_skb = ehea_proc_cqes(pr, 300);
-
- if (cqe || cqe_skb)
- pr->poll_counter++;
+ cqe_skb = ehea_proc_cqes(pr, EHEA_POLL_MAX_CQES);
+ rx += ehea_proc_rwqes(dev, pr, budget - rx);
+ }
+ pr->poll_counter++;
return rx;
}
--
1.5.2
^ permalink raw reply related
* [PATCH 3/4] Blackfin EMAC driver: Add phy abstraction layer supporting in bfin_emac driver
From: Bryan Wu @ 2007-09-19 15:37 UTC (permalink / raw)
To: Jeff Garzik, linux-kernel, netdev, uclinux-dist-devel
- add MDIO functions and register mdio bus
- add phy abstraction layer (PAL) functions and use PAL API
- test on STAMP537 board
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jeff Garzik <jeff@garzik.org>
---
drivers/net/bfin_mac.c | 311 +++++++++++++++++++++++++++++-------------------
drivers/net/bfin_mac.h | 53 ++-------
2 files changed, 196 insertions(+), 168 deletions(-)
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 5cb4433..53fe7de 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -47,6 +47,7 @@
#include <linux/spinlock.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
+#include <linux/phy.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
@@ -94,6 +95,9 @@ static struct net_dma_desc_tx *current_tx_ptr;
static struct net_dma_desc_tx *tx_desc;
static struct net_dma_desc_rx *rx_desc;
+static void bf537mac_disable(void);
+static void bf537mac_enable(void);
+
static void desc_list_free(void)
{
struct net_dma_desc_rx *r;
@@ -282,8 +286,11 @@ static int setup_pin_mux(int action)
return 0;
}
+/*
+ * MII operations
+ */
/* Wait until the previous MDC/MDIO transaction has completed */
-static void poll_mdc_done(void)
+static void mdio_poll(void)
{
int timeout_cnt = MAX_TIMEOUT_CNT;
@@ -299,154 +306,201 @@ static void poll_mdc_done(void)
}
/* Read an off-chip register in a PHY through the MDC/MDIO port */
-static u16 read_phy_reg(u16 PHYAddr, u16 RegAddr)
+static int mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
{
- poll_mdc_done();
+ mdio_poll();
+
/* read mode */
- bfin_write_EMAC_STAADD(SET_PHYAD(PHYAddr) |
- SET_REGAD(RegAddr) |
+ bfin_write_EMAC_STAADD(SET_PHYAD((u16) phy_addr) |
+ SET_REGAD((u16) regnum) |
STABUSY);
- poll_mdc_done();
- return (u16) bfin_read_EMAC_STADAT();
+ mdio_poll();
+
+ return (int) bfin_read_EMAC_STADAT();
}
/* Write an off-chip register in a PHY through the MDC/MDIO port */
-static void raw_write_phy_reg(u16 PHYAddr, u16 RegAddr, u32 Data)
+static int mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
+ u16 value)
{
- bfin_write_EMAC_STADAT(Data);
+ mdio_poll();
+
+ bfin_write_EMAC_STADAT((u32) value);
/* write mode */
- bfin_write_EMAC_STAADD(SET_PHYAD(PHYAddr) |
- SET_REGAD(RegAddr) |
+ bfin_write_EMAC_STAADD(SET_PHYAD((u16) phy_addr) |
+ SET_REGAD((u16) regnum) |
STAOP |
STABUSY);
- poll_mdc_done();
+ mdio_poll();
+
+ return 0;
}
-static void write_phy_reg(u16 PHYAddr, u16 RegAddr, u32 Data)
+static int mdiobus_reset(struct mii_bus *bus)
{
- poll_mdc_done();
- raw_write_phy_reg(PHYAddr, RegAddr, Data);
+ return 0;
}
-/* set up the phy */
-static void bf537mac_setphy(struct net_device *dev)
+static void bf537_adjust_link(struct net_device *dev)
{
- u16 phydat;
struct bf537mac_local *lp = netdev_priv(dev);
+ struct phy_device *phydev = lp->phydev;
+ unsigned long flags;
+ int new_state = 0;
+
+ spin_lock_irqsave(&lp->lock, flags);
+ if (phydev->link) {
+ /* Now we make sure that we can be in full duplex mode.
+ * If not, we operate in half-duplex mode. */
+ if (phydev->duplex != lp->old_duplex) {
+ u32 opmode = bfin_read_EMAC_OPMODE();
+ new_state = 1;
+
+ if (phydev->duplex)
+ opmode |= FDMODE;
+ else
+ opmode &= ~(FDMODE);
+
+ bfin_write_EMAC_OPMODE(opmode);
+ lp->old_duplex = phydev->duplex;
+ }
- /* Program PHY registers */
- pr_debug("start setting up phy\n");
-
- /* issue a reset */
- raw_write_phy_reg(lp->PhyAddr, PHYREG_MODECTL, 0x8000);
-
- /* wait half a second */
- msleep(500);
-
- phydat = read_phy_reg(lp->PhyAddr, PHYREG_MODECTL);
-
- /* advertise flow control supported */
- phydat = read_phy_reg(lp->PhyAddr, PHYREG_ANAR);
- phydat |= (1 << 10);
- write_phy_reg(lp->PhyAddr, PHYREG_ANAR, phydat);
+ if (phydev->speed != lp->old_speed) {
+#if defined(CONFIG_BFIN_MAC_RMII)
+ u32 opmode = bfin_read_EMAC_OPMODE();
+ bf537mac_disable();
+ switch (phydev->speed) {
+ case 10:
+ opmode |= RMII_10;
+ break;
+ case 100:
+ opmode &= ~(RMII_10);
+ break;
+ default:
+ printk(KERN_WARNING
+ "%s: Ack! Speed (%d) is not 10/100!\n",
+ DRV_NAME, phydev->speed);
+ break;
+ }
+ bfin_write_EMAC_OPMODE(opmode);
+ bf537mac_enable();
+#endif
- phydat = 0;
- if (lp->Negotiate)
- phydat |= 0x1000; /* enable auto negotiation */
- else {
- if (lp->FullDuplex)
- phydat |= (1 << 8); /* full duplex */
- else
- phydat &= (~(1 << 8)); /* half duplex */
+ new_state = 1;
+ lp->old_speed = phydev->speed;
+ }
- if (!lp->Port10)
- phydat |= (1 << 13); /* 100 Mbps */
- else
- phydat &= (~(1 << 13)); /* 10 Mbps */
+ if (!lp->old_link) {
+ new_state = 1;
+ lp->old_link = 1;
+ netif_schedule(dev);
+ }
+ } else if (lp->old_link) {
+ new_state = 1;
+ lp->old_link = 0;
+ lp->old_speed = 0;
+ lp->old_duplex = -1;
}
- if (lp->Loopback)
- phydat |= (1 << 14); /* enable TX->RX loopback */
-
- write_phy_reg(lp->PhyAddr, PHYREG_MODECTL, phydat);
- msleep(500);
-
- phydat = read_phy_reg(lp->PhyAddr, PHYREG_MODECTL);
- /* check for SMSC PHY */
- if ((read_phy_reg(lp->PhyAddr, PHYREG_PHYID1) == 0x7) &&
- ((read_phy_reg(lp->PhyAddr, PHYREG_PHYID2) & 0xfff0) == 0xC0A0)) {
- /*
- * we have SMSC PHY so reqest interrupt
- * on link down condition
- */
-
- /* enable interrupts */
- write_phy_reg(lp->PhyAddr, 30, 0x0ff);
+ if (new_state) {
+ u32 opmode = bfin_read_EMAC_OPMODE();
+ phy_print_status(phydev);
+ pr_debug("EMAC_OPMODE = 0x%08x\n", opmode);
}
+
+ spin_unlock_irqrestore(&lp->lock, flags);
}
-/**************************************************************************/
-void setup_system_regs(struct net_device *dev)
+static int mii_probe(struct net_device *dev)
{
- int phyaddr;
- unsigned short sysctl, phydat;
- u32 opmode;
struct bf537mac_local *lp = netdev_priv(dev);
- int count = 0;
-
- phyaddr = lp->PhyAddr;
+ struct phy_device *phydev = NULL;
+ unsigned short sysctl;
+ int i;
- /* Enable PHY output */
+ /* Enable PHY output early */
if (!(bfin_read_VR_CTL() & PHYCLKOE))
bfin_write_VR_CTL(bfin_read_VR_CTL() | PHYCLKOE);
/* MDC = 2.5 MHz */
- sysctl = SET_MDCDIV(24);
- /* Odd word alignment for Receive Frame DMA word */
- /* Configure checksum support and rcve frame word alignment */
-#if defined(BFIN_MAC_CSUM_OFFLOAD)
- sysctl |= RXDWA | RXCKS;
-#else
- sysctl |= RXDWA;
-#endif
+ sysctl = bfin_read_EMAC_SYSCTL();
+ sysctl |= SET_MDCDIV(24);
bfin_write_EMAC_SYSCTL(sysctl);
- /* auto negotiation on */
- /* full duplex */
- /* 100 Mbps */
- phydat = PHY_ANEG_EN | PHY_DUPLEX | PHY_SPD_SET;
- write_phy_reg(phyaddr, PHYREG_MODECTL, phydat);
- /* test if full duplex supported */
- do {
- msleep(100);
- phydat = read_phy_reg(phyaddr, PHYREG_MODESTAT);
- if (count > 30) {
- printk(KERN_NOTICE DRV_NAME ": Link is down\n");
- printk(KERN_NOTICE DRV_NAME
- "please check your network connection\n");
- break;
- }
- count++;
- } while (!(phydat & 0x0004));
+ /* search for connect PHY device */
+ for (i = 0; i < PHY_MAX_ADDR; i++) {
+ struct phy_device *const tmp_phydev = lp->mii_bus.phy_map[i];
- phydat = read_phy_reg(phyaddr, PHYREG_ANLPAR);
+ if (!tmp_phydev)
+ continue; /* no PHY here... */
- if ((phydat & 0x0100) || (phydat & 0x0040)) {
- opmode = FDMODE;
- } else {
- opmode = 0;
- printk(KERN_INFO DRV_NAME
- ": Network is set to half duplex\n");
+ phydev = tmp_phydev;
+ break; /* found it */
+ }
+
+ /* now we are supposed to have a proper phydev, to attach to... */
+ if (!phydev) {
+ printk(KERN_INFO "%s: Don't found any phy device at all\n",
+ dev->name);
+ return -ENODEV;
}
#if defined(CONFIG_BFIN_MAC_RMII)
- opmode |= RMII; /* For Now only 100MBit are supported */
+ phydev = phy_connect(dev, phydev->dev.bus_id, &bf537_adjust_link, 0,
+ PHY_INTERFACE_MODE_RMII);
+#else
+ phydev = phy_connect(dev, phydev->dev.bus_id, &bf537_adjust_link, 0,
+ PHY_INTERFACE_MODE_MII);
#endif
- bfin_write_EMAC_OPMODE(opmode);
+ if (IS_ERR(phydev)) {
+ printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
+ return PTR_ERR(phydev);
+ }
+
+ /* mask with MAC supported features */
+ phydev->supported &= (SUPPORTED_10baseT_Half
+ | SUPPORTED_10baseT_Full
+ | SUPPORTED_100baseT_Half
+ | SUPPORTED_100baseT_Full
+ | SUPPORTED_Autoneg
+ | SUPPORTED_Pause | SUPPORTED_Asym_Pause
+ | SUPPORTED_MII
+ | SUPPORTED_TP);
+
+ phydev->advertising = phydev->supported;
+
+ lp->old_link = 0;
+ lp->old_speed = 0;
+ lp->old_duplex = -1;
+ lp->phydev = phydev;
+
+ printk(KERN_INFO "%s: attached PHY driver [%s] "
+ "(mii_bus:phy_addr=%s, irq=%d)\n",
+ DRV_NAME, phydev->drv->name, phydev->dev.bus_id, phydev->irq);
+
+ return 0;
+}
+
+/**************************************************************************/
+void setup_system_regs(struct net_device *dev)
+{
+ unsigned short sysctl;
+
+ /*
+ * Odd word alignment for Receive Frame DMA word
+ * Configure checksum support and rcve frame word alignment
+ */
+ sysctl = bfin_read_EMAC_SYSCTL();
+#if defined(BFIN_MAC_CSUM_OFFLOAD)
+ sysctl |= RXDWA | RXCKS;
+#else
+ sysctl |= RXDWA;
+#endif
+ bfin_write_EMAC_SYSCTL(sysctl);
bfin_write_EMAC_MMC_CTL(RSTC | CROLL);
@@ -686,18 +740,18 @@ static void bf537mac_disable(void)
/*
* Enable Interrupts, Receive, and Transmit
*/
-static int bf537mac_enable(struct net_device *dev)
+static void bf537mac_enable(void)
{
u32 opmode;
- pr_debug("%s: %s\n", dev->name, __FUNCTION__);
+ pr_debug("%s: %s\n", DRV_NAME, __FUNCTION__);
/* Set RX DMA */
bfin_write_DMA1_NEXT_DESC_PTR(&(rx_list_head->desc_a));
bfin_write_DMA1_CONFIG(rx_list_head->desc_a.config);
/* Wait MII done */
- poll_mdc_done();
+ mdio_poll();
/* We enable only RX here */
/* ASTP : Enable Automatic Pad Stripping
@@ -721,8 +775,6 @@ static int bf537mac_enable(struct net_device *dev)
#endif
/* Turn on the EMAC rx */
bfin_write_EMAC_OPMODE(opmode);
-
- return 0;
}
/* Our watchdog timed out. Called by the networking layer */
@@ -735,7 +787,7 @@ static void bf537mac_timeout(struct net_device *dev)
/* reset tx queue */
tx_list_tail = tx_list_head->next;
- bf537mac_enable(dev);
+ bf537mac_enable();
/* We can accept TX packets again */
dev->trans_start = jiffies;
@@ -789,6 +841,7 @@ static void bf537mac_shutdown(struct net_device *dev)
*/
static int bf537mac_open(struct net_device *dev)
{
+ struct bf537mac_local *lp = netdev_priv(dev);
int retval;
pr_debug("%s: %s\n", dev->name, __FUNCTION__);
@@ -808,10 +861,10 @@ static int bf537mac_open(struct net_device *dev)
if (retval)
return retval;
- bf537mac_setphy(dev);
+ phy_start(lp->phydev);
setup_system_regs(dev);
bf537mac_disable();
- bf537mac_enable(dev);
+ bf537mac_enable();
pr_debug("hardware init finished\n");
netif_start_queue(dev);
@@ -828,11 +881,14 @@ static int bf537mac_open(struct net_device *dev)
*/
static int bf537mac_close(struct net_device *dev)
{
+ struct bf537mac_local *lp = netdev_priv(dev);
pr_debug("%s: %s\n", dev->name, __FUNCTION__);
netif_stop_queue(dev);
netif_carrier_off(dev);
+ phy_stop(lp->phydev);
+
/* clear everything */
bf537mac_shutdown(dev);
@@ -846,6 +902,7 @@ static int __init bf537mac_probe(struct net_device *dev)
{
struct bf537mac_local *lp = netdev_priv(dev);
int retval;
+ int i;
/* Grab the MAC address in the MAC */
*(__le32 *) (&(dev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO());
@@ -862,7 +919,6 @@ static int __init bf537mac_probe(struct net_device *dev)
/* set the GPIO pins to Ethernet mode */
retval = setup_pin_mux(1);
-
if (retval)
return retval;
@@ -880,6 +936,23 @@ static int __init bf537mac_probe(struct net_device *dev)
setup_mac_addr(dev->dev_addr);
+ /* MDIO bus initial */
+ lp->mii_bus.priv = dev;
+ lp->mii_bus.read = mdiobus_read;
+ lp->mii_bus.write = mdiobus_write;
+ lp->mii_bus.reset = mdiobus_reset;
+ lp->mii_bus.name = "bfin_mac_mdio";
+ lp->mii_bus.id = 0;
+ lp->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
+ for (i = 0; i < PHY_MAX_ADDR; ++i)
+ lp->mii_bus.irq[i] = PHY_POLL;
+
+ mdiobus_register(&lp->mii_bus);
+
+ retval = mii_probe(dev);
+ if (retval)
+ return retval;
+
/* Fill in the fields of the device structure with ethernet values. */
ether_setup(dev);
@@ -893,13 +966,6 @@ static int __init bf537mac_probe(struct net_device *dev)
dev->poll_controller = bf537mac_poll;
#endif
- /* fill in some of the fields */
- lp->version = 1;
- lp->PhyAddr = 0x01;
- lp->CLKIN = 25;
- lp->FullDuplex = 0;
- lp->Negotiate = 1;
- lp->FlowControl = 0;
spin_lock_init(&lp->lock);
/* now, enable interrupts */
@@ -912,9 +978,6 @@ static int __init bf537mac_probe(struct net_device *dev)
return -EBUSY;
}
- /* Enable PHY output early */
- if (!(bfin_read_VR_CTL() & PHYCLKOE))
- bfin_write_VR_CTL(bfin_read_VR_CTL() | PHYCLKOE);
retval = register_netdev(dev);
if (retval == 0) {
diff --git a/drivers/net/bfin_mac.h b/drivers/net/bfin_mac.h
index b827246..3a107ad 100644
--- a/drivers/net/bfin_mac.h
+++ b/drivers/net/bfin_mac.h
@@ -31,32 +31,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*
- * PHY REGISTER NAMES
- */
-#define PHYREG_MODECTL 0x0000
-#define PHYREG_MODESTAT 0x0001
-#define PHYREG_PHYID1 0x0002
-#define PHYREG_PHYID2 0x0003
-#define PHYREG_ANAR 0x0004
-#define PHYREG_ANLPAR 0x0005
-#define PHYREG_ANER 0x0006
-#define PHYREG_NSR 0x0010
-#define PHYREG_LBREMR 0x0011
-#define PHYREG_REC 0x0012
-#define PHYREG_10CFG 0x0013
-#define PHYREG_PHY1_1 0x0014
-#define PHYREG_PHY1_2 0x0015
-#define PHYREG_PHY2 0x0016
-#define PHYREG_TW_1 0x0017
-#define PHYREG_TW_2 0x0018
-#define PHYREG_TEST 0x0019
-
-#define PHY_RESET 0x8000
-#define PHY_ANEG_EN 0x1000
-#define PHY_DUPLEX 0x0100
-#define PHY_SPD_SET 0x2000
-
#define BFIN_MAC_CSUM_OFFLOAD
struct dma_descriptor {
@@ -104,27 +78,18 @@ struct bf537mac_local {
* can find out semi-useless statistics of how well the card is
* performing
*/
- int version;
+ struct net_device_stats stats;
- int FlowEnabled; /* record if data flow is active */
- int EtherIntIVG; /* IVG for the ethernet interrupt */
- int RXIVG; /* IVG for the RX completion */
- int TXIVG; /* IVG for the TX completion */
- int PhyAddr; /* PHY address */
- int OpMode; /* set these bits n the OPMODE regs */
- int Port10; /* set port speed to 10 Mbit/s */
- int GenChksums; /* IP checksums to be calculated */
- int NoRcveLnth; /* dont insert recv length at start of buffer */
- int StripPads; /* remove trailing pad bytes */
- int FullDuplex; /* set full duplex mode */
- int Negotiate; /* enable auto negotiation */
- int Loopback; /* loopback at the PHY */
- int Cache; /* Buffers may be cached */
- int FlowControl; /* flow control active */
- int CLKIN; /* clock in value in MHZ */
- unsigned short IntMask; /* interrupt mask */
unsigned char Mac[6]; /* MAC address of the board */
spinlock_t lock;
+
+ /* MII and PHY stuffs */
+ int old_link; /* used by bf537_adjust_link */
+ int old_speed;
+ int old_duplex;
+
+ struct phy_device *phydev;
+ struct mii_bus mii_bus;
};
extern void get_bf537_ether_addr(char *addr);
--
1.5.2
^ permalink raw reply related
* Re: [ofa-general] [PATCH] RDMA/CMA: Implement rdma_resolve_ip retry enhancement.
From: Roland Dreier @ 2007-09-19 15:43 UTC (permalink / raw)
To: ggrundstrom; +Cc: netdev, general
In-Reply-To: <200709190022.l8J0MbWt024754@neteffect.com>
Thanks for the patch...
> If an application is calling rdma_resolve_ip() and a status of -ENODATA is returned from addr_resolve_local/remote(), the timeout mechanism waits until the application's timeout occurs before rechecking the address resolution status; the application will wait until it's full timeout occurs. This case is seen when the work thread call to process_req() is made before the arp packet is processed.
I'm having a hard time understanding this changelog. Could you please
resend with a description that lets me understand:
- What the current behavior is and what is wrong with that;
- What the behavior should be;
- And how your patch changes the behavior to be correct.
> This patch is in addition to Steve Wise's neigh_event_send patch to initiate neighbour discovery sent on 9/12/2007.
Does this mean it depends on Steve's patch being applied first?
Also please try to keep lines in the changelog to 72 characters or so...
> @@ -136,6 +137,7 @@ static void set_timeout(unsigned long ti
> static void queue_req(struct addr_req *req)
> {
> struct addr_req *temp_req;
> + unsigned long req_timeout = msecs_to_jiffies(MIN_ADDR_TIMEOUT_MS) + jiffies;
>
> mutex_lock(&lock);
> list_for_each_entry_reverse(temp_req, &req_list, list) {
> @@ -145,8 +147,10 @@ static void queue_req(struct addr_req *r
>
> list_add(&req->list, &temp_req->list);
>
> - if (req_list.next == &req->list)
> + if (req_list.next == &req->list) {
> + req_timeout = min(req_timeout, req->timeout);
> set_timeout(req->timeout);
> + }
> mutex_unlock(&lock);
> }
I don't understand this code. It seems you keep track of the minimum
timeout, and then ignore the value you computed. What am I missing?
Thanks,
Roland
^ permalink raw reply
* Re: new NAPI interface broken
From: Jan-Bernd Themann @ 2007-09-19 15:43 UTC (permalink / raw)
To: Roland Dreier; +Cc: David Miller, shemminger, netdev, themann, raisch
In-Reply-To: <adafy1ak6u8.fsf@cisco.com>
On Wednesday 19 September 2007 17:33, Roland Dreier wrote:
> > One other thing I observed is that I can not unload the module as the
> > ref counter of the eth device is too low. I haven't tracked down the
> > source of this problem yet.
>
> I suspect that this is because netif_rx_reschedule() was missing a
> dev_hold() to match the dev_put() in netif_rx_complete(). Dave merged
> a fix for that problem yesterday, so current net-2.6.24 should be OK.
> Let us know if it's not OK, because then there's another bug...
>
> - R.
>
When I applied this netif_rx_reschedule fix this problem did not occur
anymore (module could be unloaded). So I guess I hit the problem you
described.
Thanks,
Jan-Bernd
^ permalink raw reply
* Re: follow-up: discrepancy with POSIX
From: Andi Kleen @ 2007-09-19 15:47 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: netdev, Linux Kernel
In-Reply-To: <46F13E8B.4050309@redhat.com>
Ulrich Drepper <drepper@redhat.com> writes:
>
> fd = socket(AT_INET6, ...)
>
> connect(fd, ...some IPv6 address...)
>
> struct sockaddr_in6 sin6 = { .sin6_family = AF_INET6 };
> connect(fd, &sin6, sizeof (sin6));
The standard way to undo connect is to use AF_UNSPEC. Code to handle
that for dgram sockets is there. It's the same code for v4 and v6.
-Andi
^ permalink raw reply
* Re: [PATCH] tehuti: driver for Tehuti 10GbE network adapters
From: 'Christoph Hellwig' @ 2007-09-19 15:52 UTC (permalink / raw)
To: Alexander Indenbaum
Cc: 'Christoph Hellwig', jeff, davem, akpm, netdev,
'Nadav Shemer', 'Andy Gospodarek'
In-Reply-To: <20070919104438.B1FF775CAD@mail.tehutinetworks.co.il>
On Wed, Sep 19, 2007 at 12:44:33PM +0200, Alexander Indenbaum wrote:
> > - please don't redefine the dma mask constants
> > - please use the firmware loader instead of mebedding a firmware
> > image
>
> Could you give us some pointers to docs and examples of "firmware loader"?
> I'm not sure I'm familiar with such mechanism in Linux kernel.
Documentation/firmware_class/ in the kernel tree has the documentation
for it. Grep the kernel tree for request_firmware to find various users.
> Putting dual-port issue aside, could you elaborate what is the problem in
> your opinion in bdx_remove() implementation? What is wrong with calling
> free_netdev() right after unregister_netdev()? Could you provide pointers
> for docs and examples to correct PCI network device remove interface
> implementation?
free_netdev can only be called if you're sure you don't reference your
netdevice anymore. Most notably that means you need to call free_irq
first.
^ permalink raw reply
* Re: [RFC PATCH] 2.6.22.6 netfilter: sk_setup_caps in ip_make_route_harder
From: lepton @ 2007-09-19 15:55 UTC (permalink / raw)
To: Patrick McHardy
Cc: lepton, Netfilter Development Mailinglist, Linux Netdev List
In-Reply-To: <46F13D7D.6010603@trash.net>
Yes, you are right.
What do you think about this:
For all packets can be sent out, we just disable
all things in sk_route_caps in ip_route_me_harder
diff -X linux-2.6.22.6/Documentation/dontdiff -pru linux-2.6.22.6/net/ipv4/netfilter.c linux-2.6.22.6-lepton/net/ipv4/netfilter.c
--- linux-2.6.22.6/net/ipv4/netfilter.c 2007-09-14 17:41:18.000000000 +0800
+++ linux-2.6.22.6-lepton/net/ipv4/netfilter.c 2007-09-19 23:52:11.000000000 +0800
@@ -57,6 +57,10 @@ int ip_route_me_harder(struct sk_buff **
if ((*pskb)->dst->error)
return -1;
+ if((*pskb)->sk&&sk->sk_route_caps)
+ /* This is overkill, but it is safe and simple */
+ sk->sk_route_caps=0;
+
#ifdef CONFIG_XFRM
if (!(IPCB(*pskb)->flags & IPSKB_XFRM_TRANSFORMED) &&
xfrm_decode_session(*pskb, &fl, AF_INET) == 0)
On Wed, Sep 19, 2007 at 05:17:17PM +0200, Patrick McHardy wrote:
> Patrick McHardy wrote:
> > lepton wrote:
> >
> >>Hi,
> >> For local src packets, it is better to update sk_route_caps in
> >> ip_route_me_harder.
> >
> >
> >
> > This seems like a good idea to me. But why only for local src
> > (address) packets? This function can also be used for locally
> > generated packet that have been (f.i.) NATed to a foreign
> > address ...
>
>
> Actually, I'm afraid it might break some setups. Rerouting is
> done per packet, but if we cache the dst_entry for the socket,
> all packets from that socket will be routed similar.
>
^ permalink raw reply
* Re: [PATCH 2.6.23-rc6] NETWORKING : Edge Triggered EPOLLOUT events get missed for TCP sockets
From: David Miller @ 2007-09-19 16:02 UTC (permalink / raw)
To: tomer_iisc; +Cc: netdev, linux-kernel
In-Reply-To: <106538.13069.qm@web53707.mail.re2.yahoo.com>
From: Nagendra Tomar <tomer_iisc@yahoo.com>
Date: Wed, 19 Sep 2007 04:13:24 -0700 (PDT)
> With the SOCK_NOSPACE check in tcp_check_space(), this epoll_wait call will
> not return, even when the incoming acks free the buffers.
> Note that this patch assumes that the SOCK_NOSPACE check in
> tcp_check_space is a trivial optimization which can be safely removed.
I think the more correct fix is to fix whoever isn't
setting the SOCK_NOSPACE bit, that check really is
crucial.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox