* Re: [RFC Patch] net: reserve ports for applications using fixed port numbers
From: David Miller @ 2010-02-04 21:56 UTC (permalink / raw)
To: penguin-kernel-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp
Cc: opurdila-+zzKsuq53OdBDgjK7y7TUQ, amwang-H+wXaHxf7aLQT0dZR+AlfA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
nhorman-2XuSBdqkA4R54TAoqtyWWQ, linux-sctp-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <201002050645.CEC95380.MLOtOVFFHSFOQJ-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>
From: Tetsuo Handa <penguin-kernel-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>
Date: Fri, 5 Feb 2010 06:45:28 +0900
> Octavian Purdila wrote:
>>
>> int inet_is_reserved_local_port(int port)
>> {
>> if (test_bit(port, reserved_ports))
>> return 1;
>> return 0;
>> }
>>
> Above check is exactly what I'm doing in the LSM hook.
But his version can be done inline in 2 or 3 instructions.
An LSM hook will result in an indirect function call,
all live registers spilled to the stack, then all of
those reloaded when the function returns.
It will be much more expensive.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH] Net / pktgen: Fix freezing problem
From: Rafael J. Wysocki @ 2010-02-04 21:50 UTC (permalink / raw)
To: LKML; +Cc: NetDev, pm list, Andrew Morton, David Miller,
Ciprian Dorin Craciun
From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: Net / pktgen: Fix freezing problem
Add missing try_to_freeze() to one of the pktgen_thread_worker() code
paths so that it doesn't block suspend/hibernation.
Fixes http://bugzilla.kernel.org/show_bug.cgi?id=15006
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Reported-and-tested-by: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
---
net/core/pktgen.c | 1 +
1 file changed, 1 insertion(+)
Index: linux-2.6/net/core/pktgen.c
===================================================================
--- linux-2.6.orig/net/core/pktgen.c
+++ linux-2.6/net/core/pktgen.c
@@ -3524,6 +3524,7 @@ static int pktgen_thread_worker(void *ar
wait_event_interruptible_timeout(t->queue,
t->control != 0,
HZ/10);
+ try_to_freeze();
continue;
}
^ permalink raw reply
* Re: [RFC Patch] net: reserve ports for applications using fixed port numbers
From: Tetsuo Handa @ 2010-02-04 21:45 UTC (permalink / raw)
To: opurdila-+zzKsuq53OdBDgjK7y7TUQ, davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: amwang-H+wXaHxf7aLQT0dZR+AlfA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
nhorman-2XuSBdqkA4R54TAoqtyWWQ, linux-sctp-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <201002042015.51092.opurdila-+zzKsuq53OdBDgjK7y7TUQ@public.gmane.org>
Octavian Purdila wrote:
>
> int inet_is_reserved_local_port(int port)
> {
> if (test_bit(port, reserved_ports))
> return 1;
> return 0;
> }
>
Above check is exactly what I'm doing in the LSM hook.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] doc: document IPv6 parameters
From: David Miller @ 2010-02-04 21:37 UTC (permalink / raw)
To: brian.haley; +Cc: netdev, greg
In-Reply-To: <4B6B32E8.6070408@hp.com>
From: Brian Haley <brian.haley@hp.com>
Date: Thu, 04 Feb 2010 15:49:44 -0500
> Can you take these in net-next-2.6? I haven't heard boo from anyone
> on linux-doc or lkml.
Sure, applied, thanks Brian.
^ permalink raw reply
* Re: [net-next PATCH 3/3] qlge: Add watchdog timer.
From: David Miller @ 2010-02-04 21:32 UTC (permalink / raw)
To: ron.mercer; +Cc: netdev
In-Reply-To: <20100204211929.GC9938@linux-ox1b.qlogic.org>
From: Ron Mercer <ron.mercer@qlogic.com>
Date: Thu, 4 Feb 2010 13:19:29 -0800
>> Did the timer every fire more than once in your testing?
>>
>> Don't you need to re-setup the expiration period before
>> adding it again?
>
> It does fire repeatedly but I should have put in the new expiration
> period. I added some prints to the timer and without resetting the
> expiration the timer would pop faster, but still less than 5 seconds.
> I've added the expiration here and see very even pops on 5 second
> intervals.
Of course it pops faster, if you don't reset the expiration
period it is "right now". :-)
I'll apply this new version, thanks.
^ permalink raw reply
* Re: [net-next PATCH 3/3] qlge: Add watchdog timer.
From: Ron Mercer @ 2010-02-04 21:19 UTC (permalink / raw)
To: David Miller; +Cc: netdev@vger.kernel.org
In-Reply-To: <20100204.122931.189315763.davem@davemloft.net>
> Did the timer every fire more than once in your testing?
>
> Don't you need to re-setup the expiration period before
> adding it again?
It does fire repeatedly but I should have put in the new expiration
period. I added some prints to the timer and without resetting the
expiration the timer would pop faster, but still less than 5 seconds.
I've added the expiration here and see very even pops on 5 second
intervals.
>From 4637fe181eda8440282b6a3acc0bc2c5aefbd7ea Mon Sep 17 00:00:00 2001
From: Ron Mercer <ron.mercer@qlogic.com>
Date: Thu, 4 Feb 2010 13:11:43 -0800
Subject: [net-next PATCH 1/1] qlge: Add watchdog timer.
Add periodic heartbeat register read to trigger the eeh
recovery process.
We see cases where an eeh error was injected and the slot was
suspended. An asic access attempt is required to flush the recovery process,
but without interrupts the process can stall.
Adding this periodic register read causes the recovery process to begin.
Signed-off-by: Ron Mercer <ron.mercer@qlogic.com>
---
drivers/net/qlge/qlge.h | 1 +
drivers/net/qlge/qlge_main.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index 780a387..ebfd177 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -2145,6 +2145,7 @@ struct ql_adapter {
struct completion ide_completion;
struct nic_operations *nic_ops;
u16 device_id;
+ struct timer_list timer;
atomic_t lb_count;
};
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 7e00029..87a40d1 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -4574,6 +4574,21 @@ static const struct net_device_ops qlge_netdev_ops = {
.ndo_vlan_rx_kill_vid = qlge_vlan_rx_kill_vid,
};
+static void ql_timer(unsigned long data)
+{
+ struct ql_adapter *qdev = (struct ql_adapter *)data;
+ u32 var = 0;
+
+ var = ql_read32(qdev, STS);
+ if (pci_channel_offline(qdev->pdev)) {
+ QPRINTK(qdev, IFUP, ERR, "EEH STS = 0x%.08x.\n", var);
+ return;
+ }
+
+ qdev->timer.expires = jiffies + (5*HZ);
+ add_timer(&qdev->timer);
+}
+
static int __devinit qlge_probe(struct pci_dev *pdev,
const struct pci_device_id *pci_entry)
{
@@ -4625,6 +4640,14 @@ static int __devinit qlge_probe(struct pci_dev *pdev,
pci_disable_device(pdev);
return err;
}
+ /* Start up the timer to trigger EEH if
+ * the bus goes dead
+ */
+ init_timer_deferrable(&qdev->timer);
+ qdev->timer.data = (unsigned long)qdev;
+ qdev->timer.function = ql_timer;
+ qdev->timer.expires = jiffies + (5*HZ);
+ add_timer(&qdev->timer);
ql_link_off(qdev);
ql_display_dev_info(ndev);
atomic_set(&qdev->lb_count, 0);
@@ -4645,6 +4668,8 @@ int ql_clean_lb_rx_ring(struct rx_ring *rx_ring, int budget)
static void __devexit qlge_remove(struct pci_dev *pdev)
{
struct net_device *ndev = pci_get_drvdata(pdev);
+ struct ql_adapter *qdev = netdev_priv(ndev);
+ del_timer_sync(&qdev->timer);
unregister_netdev(ndev);
ql_release_all(pdev);
pci_disable_device(pdev);
@@ -4757,6 +4782,8 @@ static void qlge_io_resume(struct pci_dev *pdev)
QPRINTK(qdev, IFUP, ERR,
"Device was not running prior to EEH.\n");
}
+ qdev->timer.expires = jiffies + (5*HZ);
+ add_timer(&qdev->timer);
netif_device_attach(ndev);
}
@@ -4773,6 +4800,7 @@ static int qlge_suspend(struct pci_dev *pdev, pm_message_t state)
int err;
netif_device_detach(ndev);
+ del_timer_sync(&qdev->timer);
if (netif_running(ndev)) {
err = ql_adapter_down(qdev);
@@ -4817,6 +4845,8 @@ static int qlge_resume(struct pci_dev *pdev)
return err;
}
+ qdev->timer.expires = jiffies + (5*HZ);
+ add_timer(&qdev->timer);
netif_device_attach(ndev);
return 0;
--
1.6.0.2
^ permalink raw reply related
* Re: [net-next-2.6 PATCH v2 1/3] ethtool: Introduce n-tuple filter programming support
From: Waskiewicz Jr, Peter P @ 2010-02-04 21:26 UTC (permalink / raw)
To: David Miller
Cc: Kirsher, Jeffrey T, netdev@vger.kernel.org, gospo@redhat.com,
Waskiewicz Jr, Peter P
In-Reply-To: <20100204.091854.24215476.davem@davemloft.net>
On Thu, 4 Feb 2010, David Miller wrote:
> From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> Date: Wed, 03 Feb 2010 23:48:13 -0800
>
> > +#define ETHTOOL_RXNTUPLE_ACTION_DROP -1
> > + struct list_head list;
> > +};
>
> You can't do this.
>
> You put the list_head here in the kernel header, which BTW can
> be used by userspace too, and then you elide it in the
> ethtool utility copy of the header.
>
> Use an encapsulator if you must inside of the kernel, but keep the
> userspace visible data structure clean of RCU and list_head
> kernel datastructures.
Ok. I'll respin this asap. Thanks for the quick review Dave.
-PJ
^ permalink raw reply
* [PATCH] doc: document IPv6 parameters
From: Brian Haley @ 2010-02-04 20:49 UTC (permalink / raw)
To: David Miller; +Cc: netdev@vger.kernel.org, greg
Dave,
Can you take these in net-next-2.6? I haven't heard boo from anyone on linux-doc or lkml.
-Brian
Update documentation to describe IPv6 parameters.
Reported by <greg@enjellic.com>.
Signed-off-by: Brian Haley <brian.haley@hp.com>
---
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 736d456..3ca7f8f 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -54,6 +54,7 @@ parameter is applicable:
IMA Integrity measurement architecture is enabled.
IOSCHED More than one I/O scheduler is enabled.
IP_PNP IP DHCP, BOOTP, or RARP is enabled.
+ IPV6 IPv6 support is enabled.
ISAPNP ISA PnP code is enabled.
ISDN Appropriate ISDN support is enabled.
JOY Appropriate joystick support is enabled.
@@ -347,6 +348,9 @@ and is between 256 and 4096 characters. It is defined in the file
Change the amount of debugging information output
when initialising the APIC and IO-APIC components.
+ autoconf= [IPV6]
+ See Documentation/networking/ipv6.txt.
+
show_lapic= [APIC,X86] Advanced Programmable Interrupt Controller
Limit apic dumping. The parameter defines the maximal
number of local apics being dumped. Also it is possible
@@ -629,6 +633,12 @@ and is between 256 and 4096 characters. It is defined in the file
See drivers/char/README.epca and
Documentation/serial/digiepca.txt.
+ disable= [IPV6]
+ See Documentation/networking/ipv6.txt.
+
+ disable_ipv6= [IPV6]
+ See Documentation/networking/ipv6.txt.
+
disable_mtrr_cleanup [X86]
The kernel tries to adjust MTRR layout from continuous
to discrete, to make X server driver able to add WB
^ permalink raw reply related
* Re: [net-next PATCH 3/3] qlge: Add watchdog timer.
From: David Miller @ 2010-02-04 20:29 UTC (permalink / raw)
To: ron.mercer; +Cc: netdev
In-Reply-To: <20100204200603.GB9938@linux-ox1b.qlogic.org>
From: Ron Mercer <ron.mercer@qlogic.com>
Date: Thu, 4 Feb 2010 12:06:03 -0800
> +static void ql_timer(unsigned long data)
> +{
> + struct ql_adapter *qdev = (struct ql_adapter *)data;
> + u32 var = 0;
> +
> + var = ql_read32(qdev, STS);
> + if (pci_channel_offline(qdev->pdev)) {
> + QPRINTK(qdev, IFUP, ERR, "EEH STS = 0x%.08x.\n", var);
> + return;
> + }
> +
> + add_timer(&qdev->timer);
> +}
> +
Did the timer every fire more than once in your testing?
Don't you need to re-setup the expiration period before
adding it again?
Same goes for all of those sequences where you go:
del_timer_sync(&qdev->timer);
...
add_timer(&qdev->timer);
in the patch.
^ permalink raw reply
* Re: [PATCH for 2.6.33] conntrack: restrict runtime hashsize modifications
From: Jon Masters @ 2010-02-04 20:23 UTC (permalink / raw)
To: Alexey Dobriyan
Cc: Patrick McHardy, davem, eric.dumazet, netdev, netfilter-devel
In-Reply-To: <20100204194744.GA4185@x200>
On Thu, 2010-02-04 at 21:47 +0200, Alexey Dobriyan wrote:
> On Thu, Feb 04, 2010 at 06:04:34PM +0100, Patrick McHardy wrote:
> > Patrick McHardy wrote:
> > > Alexey Dobriyan wrote:
> > Additionally I removed reinitializing the hash random value when
> > changing the hash size since that also requires to rehash in all
> > namespaces.
>
> I'm not fond of this, because we're not even closely going to allow changing
> hashtable size per-netns. As such having actual per-netns hashtable size
> just slows down everything.
Are you sure, as compared with a shared global size that this is really
going to slow things down all that much? We already need to poke in that
struct to pull out various things just hash. I haven't profiled to see.
Jon.
^ permalink raw reply
* Re: [PATCH for 2.6.33] conntrack: restrict runtime hashsize modifications
From: Jon Masters @ 2010-02-04 20:20 UTC (permalink / raw)
To: Patrick McHardy
Cc: Alexey Dobriyan, davem, eric.dumazet, netdev, netfilter-devel
In-Reply-To: <4B6AFE22.20304@trash.net>
On Thu, 2010-02-04 at 18:04 +0100, Patrick McHardy wrote:
> Patrick McHardy wrote:
> > Alexey Dobriyan wrote:
> >> Jon Masters correctly points out that conntrack hash sizes
> >> (nf_conntrack_htable_size) are global (not per-netns) and
> >> modifiable at runtime via /sys/module/nf_conntrack/hashsize .
> >>
> >> Steps to reproduce:
> >> clone(CLONE_NEWNET)
> >> [grow /sys/module/nf_conntrack/hashsize]
> >> exit()
> >>
> >> At netns exit we are going to scan random memory for conntracks to be killed.
> >>
> >> Apparently there is a code which deals with hashtable resize for
> >> init_net (and it was there befode netns conntrack code), so prohibit
> >> hashsize modification if there is more than one netns exists.
> >>
> >> To change hashtable sizes, you need to reload module.
> >>
> >> Expectation hashtable size was simply glued to a variable with no code
> >> to rehash expectations, so it was a bug to allow writing to it.
> >> Make "expect_hashsize" readonly.
> >>
> >> This is temporarily until we figure out what to do.
> >
> > How about alternatively moving nf_conntrack_hsize into the
> > per-namespace struct? It doesn't look more complicated or
> > intrusive and would allow to still change the init_net
> > hashsize. Also seems less hackish :)
>
> How about this (so far untested) patch? The htable_size is moved into
> the per-namespace struct and initialized from the current (global)
> value of nf_conntrack_htable_size. Changes through sysfs are still
> permitted, but only affect the init namespace and newly created ones.
I moved the random seed into the per-ns context aswell. I think that's
better than having a global one, and you don't need to rehash all.
Jon.
^ permalink raw reply
* Re: [PATCH for 2.6.33] conntrack: restrict runtime hashsize modifications
From: Jon Masters @ 2010-02-04 20:18 UTC (permalink / raw)
To: Patrick McHardy
Cc: Alexey Dobriyan, davem, eric.dumazet, netdev, netfilter-devel
In-Reply-To: <4B6AF58A.202@trash.net>
On Thu, 2010-02-04 at 17:27 +0100, Patrick McHardy wrote:
> Patrick McHardy wrote:
> > Alexey Dobriyan wrote:
> >> Jon Masters correctly points out that conntrack hash sizes
> >> (nf_conntrack_htable_size) are global (not per-netns) and
> >> modifiable at runtime via /sys/module/nf_conntrack/hashsize .
> >>
> >> Steps to reproduce:
> >> clone(CLONE_NEWNET)
> >> [grow /sys/module/nf_conntrack/hashsize]
> >> exit()
> >>
> >> At netns exit we are going to scan random memory for conntracks to be killed.
> >>
> >> Apparently there is a code which deals with hashtable resize for
> >> init_net (and it was there befode netns conntrack code), so prohibit
> >> hashsize modification if there is more than one netns exists.
> >>
> >> To change hashtable sizes, you need to reload module.
> >>
> >> Expectation hashtable size was simply glued to a variable with no code
> >> to rehash expectations, so it was a bug to allow writing to it.
> >> Make "expect_hashsize" readonly.
> >>
> >> This is temporarily until we figure out what to do.
> >
> > How about alternatively moving nf_conntrack_hsize into the
> > per-namespace struct? It doesn't look more complicated or
> > intrusive and would allow to still change the init_net
> > hashsize. Also seems less hackish :)
>
> Just to avoid duplicate work, I'm currently trying that.
Bah. I already worked a set of patches to do that as I mentioned, but
you've probably done it by now - can clean up and post if not :)
Jon.
^ permalink raw reply
* [PATCH 2/2] qlge: Code clean up
From: leitao @ 2010-02-04 20:11 UTC (permalink / raw)
To: ron.mercer; +Cc: netdev, Breno Leitao
In-Reply-To: <48284d15bf68cb154cf3948f3fd0b8ea11981ff3.1265314112.git.root@sanx1002.austin.ibm.com>
Just reordering this assignment that doesn't depend on any
condition.
Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
---
drivers/net/qlge/qlge_main.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index c583fb5..0d6e6f8 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -4129,12 +4129,12 @@ static int qlge_change_mtu(struct net_device *ndev, int new_mtu)
queue_delayed_work(qdev->workqueue,
&qdev->mpi_port_cfg_work, 3*HZ);
+ ndev->mtu = new_mtu;
+
if (!netif_running(qdev->ndev)) {
- ndev->mtu = new_mtu;
return 0;
}
- ndev->mtu = new_mtu;
status = ql_change_rx_buffers(qdev);
if (status) {
QPRINTK(qdev, IFUP, ERR,
--
1.6.0.2
^ permalink raw reply related
* [PATCH 1/2] qlge: removing unreachable block of code
From: leitao @ 2010-02-04 20:11 UTC (permalink / raw)
To: ron.mercer; +Cc: netdev, Breno Leitao
Currently the qlge_change_mtu() is never called if the new_mtu is
equal current MTU, due this condition on dev_set_mtu():
if (new_mtu == dev->mtu)
return 0;
So, this block of code is never reached and is being removed.
Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
---
drivers/net/qlge/qlge_main.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 7e00029..c583fb5 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -4123,9 +4123,6 @@ static int qlge_change_mtu(struct net_device *ndev, int new_mtu)
QPRINTK(qdev, IFUP, ERR, "Changing to jumbo MTU.\n");
} else if (ndev->mtu == 9000 && new_mtu == 1500) {
QPRINTK(qdev, IFUP, ERR, "Changing to normal MTU.\n");
- } else if ((ndev->mtu == 1500 && new_mtu == 1500) ||
- (ndev->mtu == 9000 && new_mtu == 9000)) {
- return 0;
} else
return -EINVAL;
--
1.6.0.2
^ permalink raw reply related
* Re: [net-next PATCH 3/3] qlge: Add watchdog timer.
From: Ron Mercer @ 2010-02-04 20:06 UTC (permalink / raw)
To: David Miller; +Cc: netdev@vger.kernel.org
In-Reply-To: <20100203.193222.64773800.davem@davemloft.net>
>From 81cc7ea1ce2b906a29ad250daeb120101b70f4f1 Mon Sep 17 00:00:00 2001
From: Ron Mercer <ron.mercer@qlogic.com>
Date: Thu, 4 Feb 2010 11:54:37 -0800
Subject: [net-next PATCH 1/1] qlge: Add watchdog timer.
Add deferred timer for 5-second periodic heartbeat register read to
trigger the eeh recovery process.
We see cases where an eeh error was injected and the slot was
suspended. An asic access attempt is required to flush the recovery process,
but without interrupts the process can stall.
Adding this periodic register read causes the recovery process to begin.
Signed-off-by: Ron Mercer <ron.mercer@qlogic.com>
---
drivers/net/qlge/qlge.h | 1 +
drivers/net/qlge/qlge_main.c | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index 780a387..ebfd177 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -2145,6 +2145,7 @@ struct ql_adapter {
struct completion ide_completion;
struct nic_operations *nic_ops;
u16 device_id;
+ struct timer_list timer;
atomic_t lb_count;
};
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 7e00029..f1fc3a8 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -4574,6 +4574,20 @@ static const struct net_device_ops qlge_netdev_ops = {
.ndo_vlan_rx_kill_vid = qlge_vlan_rx_kill_vid,
};
+static void ql_timer(unsigned long data)
+{
+ struct ql_adapter *qdev = (struct ql_adapter *)data;
+ u32 var = 0;
+
+ var = ql_read32(qdev, STS);
+ if (pci_channel_offline(qdev->pdev)) {
+ QPRINTK(qdev, IFUP, ERR, "EEH STS = 0x%.08x.\n", var);
+ return;
+ }
+
+ add_timer(&qdev->timer);
+}
+
static int __devinit qlge_probe(struct pci_dev *pdev,
const struct pci_device_id *pci_entry)
{
@@ -4625,6 +4639,14 @@ static int __devinit qlge_probe(struct pci_dev *pdev,
pci_disable_device(pdev);
return err;
}
+ /* Start up the timer to trigger EEH if
+ * the bus goes dead
+ */
+ init_timer_deferrable(&qdev->timer);
+ qdev->timer.data = (unsigned long)qdev;
+ qdev->timer.function = ql_timer;
+ qdev->timer.expires = jiffies + (5*HZ);
+ add_timer(&qdev->timer);
ql_link_off(qdev);
ql_display_dev_info(ndev);
atomic_set(&qdev->lb_count, 0);
@@ -4645,6 +4667,8 @@ int ql_clean_lb_rx_ring(struct rx_ring *rx_ring, int budget)
static void __devexit qlge_remove(struct pci_dev *pdev)
{
struct net_device *ndev = pci_get_drvdata(pdev);
+ struct ql_adapter *qdev = netdev_priv(ndev);
+ del_timer_sync(&qdev->timer);
unregister_netdev(ndev);
ql_release_all(pdev);
pci_disable_device(pdev);
@@ -4757,6 +4781,7 @@ static void qlge_io_resume(struct pci_dev *pdev)
QPRINTK(qdev, IFUP, ERR,
"Device was not running prior to EEH.\n");
}
+ add_timer(&qdev->timer);
netif_device_attach(ndev);
}
@@ -4773,6 +4798,7 @@ static int qlge_suspend(struct pci_dev *pdev, pm_message_t state)
int err;
netif_device_detach(ndev);
+ del_timer_sync(&qdev->timer);
if (netif_running(ndev)) {
err = ql_adapter_down(qdev);
@@ -4817,6 +4843,7 @@ static int qlge_resume(struct pci_dev *pdev)
return err;
}
+ add_timer(&qdev->timer);
netif_device_attach(ndev);
return 0;
--
1.6.0.2
^ permalink raw reply related
* Re: [PATCH 9/9] net: move am79c961's probe function to .devinit.text
From: Uwe Kleine-König @ 2010-02-04 20:06 UTC (permalink / raw)
To: David Miller; +Cc: gregkh, linux-kernel, 12o3l, rmk+kernel, netdev, akpm
In-Reply-To: <20100204.120501.110961896.davem@davemloft.net>
On Thu, Feb 04, 2010 at 12:05:01PM -0800, David Miller wrote:
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Date: Thu, 4 Feb 2010 20:56:57 +0100
>
> > @David Miller: this patch is in patchwork with State: Not Applicable.
> > Does that mean that netdev isn't the right tree for this patch?
>
> I was under the impression that someone would pick up the
> whole set as a unit.
Ah, OK. I hope Greg does exactly that now.
Thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply
* Re: [PATCH 9/9] net: move am79c961's probe function to .devinit.text
From: David Miller @ 2010-02-04 20:05 UTC (permalink / raw)
To: u.kleine-koenig; +Cc: gregkh, linux-kernel, 12o3l, rmk+kernel, netdev, akpm
In-Reply-To: <1265313417-5568-9-git-send-email-u.kleine-koenig@pengutronix.de>
From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date: Thu, 4 Feb 2010 20:56:57 +0100
> @David Miller: this patch is in patchwork with State: Not Applicable.
> Does that mean that netdev isn't the right tree for this patch?
I was under the impression that someone would pick up the
whole set as a unit.
If you want me to take it into net-next-2.6 I can.
^ permalink raw reply
* [PATCH 9/9] net: move am79c961's probe function to .devinit.text
From: Uwe Kleine-König @ 2010-02-04 19:56 UTC (permalink / raw)
To: Greg KH, linux-kernel; +Cc: Roel Kluin, Russell King, netdev, Andrew Morton
In-Reply-To: <20100203150850.GA28815@kroah.com>
A pointer to am79c961_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.
An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Roel Kluin <12o3l@tiscali.nl>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: netdev@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
---
Hello,
@David Miller: this patch is in patchwork with State: Not Applicable.
Does that mean that netdev isn't the right tree for this patch?
Best regards
Uwe
drivers/net/arm/am79c961a.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index 164b37e..1c3c1f9 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -680,7 +680,7 @@ static const struct net_device_ops am79c961_netdev_ops = {
#endif
};
-static int __init am79c961_probe(struct platform_device *pdev)
+static int __devinit am79c961_probe(struct platform_device *pdev)
{
struct resource *res;
struct net_device *dev;
--
1.6.6
^ permalink raw reply related
* Re: [PATCH for 2.6.33] conntrack: restrict runtime hashsize modifications
From: Alexey Dobriyan @ 2010-02-04 19:47 UTC (permalink / raw)
To: Patrick McHardy; +Cc: davem, jonathan, eric.dumazet, netdev, netfilter-devel
In-Reply-To: <4B6AFE22.20304@trash.net>
On Thu, Feb 04, 2010 at 06:04:34PM +0100, Patrick McHardy wrote:
> Patrick McHardy wrote:
> > Alexey Dobriyan wrote:
> >> Jon Masters correctly points out that conntrack hash sizes
> >> (nf_conntrack_htable_size) are global (not per-netns) and
> >> modifiable at runtime via /sys/module/nf_conntrack/hashsize .
> >>
> >> Steps to reproduce:
> >> clone(CLONE_NEWNET)
> >> [grow /sys/module/nf_conntrack/hashsize]
> >> exit()
> >>
> >> At netns exit we are going to scan random memory for conntracks to be killed.
> >>
> >> Apparently there is a code which deals with hashtable resize for
> >> init_net (and it was there befode netns conntrack code), so prohibit
> >> hashsize modification if there is more than one netns exists.
> >>
> >> To change hashtable sizes, you need to reload module.
> >>
> >> Expectation hashtable size was simply glued to a variable with no code
> >> to rehash expectations, so it was a bug to allow writing to it.
> >> Make "expect_hashsize" readonly.
> >>
> >> This is temporarily until we figure out what to do.
> >
> > How about alternatively moving nf_conntrack_hsize into the
> > per-namespace struct? It doesn't look more complicated or
> > intrusive and would allow to still change the init_net
> > hashsize. Also seems less hackish :)
>
> How about this (so far untested) patch? The htable_size is moved into
> the per-namespace struct and initialized from the current (global)
> value of nf_conntrack_htable_size. Changes through sysfs are still
> permitted, but only affect the init namespace and newly created ones.
No matter what we do, it's a hack!
> Additionally I removed reinitializing the hash random value when
> changing the hash size since that also requires to rehash in all
> namespaces.
I'm not fond of this, because we're not even closely going to allow changing
hashtable size per-netns. As such having actual per-netns hashtable size
just slows down everything.
^ permalink raw reply
* Re: netfilter/iptables and network interface names
From: Jan Engelhardt @ 2010-02-04 18:44 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Thomas Woerner, netdev, Netfilter Developer Mailing List
In-Reply-To: <4B6AFAA1.5080703@trash.net>
On Thursday 2010-02-04 17:49, Patrick McHardy wrote:
>Jan Engelhardt wrote:
>>> The kernel also forbids ".".
>>
>> My first thought was the same, but:
>>
>> a) Interestingly, it does not prohibit '.'
>>
>> ip tunnel add foo0.3 mode sit local 1.2.3.4 remote 5.6.7.8
>>
>> b) The '.' is to be seen as valid as far as xtables.c goes, so
>> as to match VLAN interfaces.
>
>Ah of course, its only invalid at the beginning of the name.
>
Nope:
19:44 borg:/home/jengelh # ip tunnel add .3 mode sit local 1.2.3.6 remote
5.6.7.7
19:44 borg:/home/jengelh # ip a
17: .3: <POINTOPOINT,NOARP> mtu 1480 qdisc noop state DOWN
link/sit 1.2.3.6 peer 5.6.7.7
^ permalink raw reply
* Re: [PATCH net-next-2.6] libphy: add phy_find_first function
From: David Miller @ 2010-02-04 18:23 UTC (permalink / raw)
To: jpirko; +Cc: netdev
In-Reply-To: <20100203153430.GB9266@psychotron.lab.eng.brq.redhat.com>
From: Jiri Pirko <jpirko@redhat.com>
Date: Wed, 3 Feb 2010 16:34:31 +0100
> Many drivers do this in them manually. Now they can use this function.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH net-next-2.6] net: use helpers to access mc list V2
From: David Miller @ 2010-02-04 18:22 UTC (permalink / raw)
To: jpirko; +Cc: netdev
In-Reply-To: <20100203125942.GA9266@psychotron.lab.eng.brq.redhat.com>
From: Jiri Pirko <jpirko@redhat.com>
Date: Wed, 3 Feb 2010 13:59:43 +0100
> This patch introduces the similar helpers as those already done for uc list.
> However multicast lists are no list_head lists but "mademanually". The three
> macros added by this patch will make the transition of mc_list to list_head
> smooth in two steps:
>
> 1) convert all drivers to use these macros (with the original iterator of type
> "struct dev_mc_list")
> 2) once all drivers are converted, convert list type and iterators to "struct
> netdev_hw_addr" in one patch.
>
>>From now on, drivers can (and should) use "netdev_for_each_mc_addr" to iterate
> over the addresses with iterator of type "struct netdev_hw_addr". Also macros
> "netdev_mc_count" and "netdev_mc_empty" to read list's length. This is the state
> which should be reached in all drivers.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Applied, thanks Jiri.
^ permalink raw reply
* Re: [RFC Patch] net: reserve ports for applications using fixed port numbers
From: David Miller @ 2010-02-04 18:21 UTC (permalink / raw)
To: opurdila-+zzKsuq53OdBDgjK7y7TUQ
Cc: amwang-H+wXaHxf7aLQT0dZR+AlfA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
nhorman-2XuSBdqkA4R54TAoqtyWWQ, linux-sctp-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <201002042015.51092.opurdila-+zzKsuq53OdBDgjK7y7TUQ@public.gmane.org>
From: Octavian Purdila <opurdila-+zzKsuq53OdBDgjK7y7TUQ@public.gmane.org>
Date: Thu, 4 Feb 2010 20:15:51 +0200
> int inet_is_reserved_local_port(int port)
> {
> if (test_bit(port, reserved_ports))
> return 1;
> return 0;
> }
>
> In theory it might be slower because of the reserved_ports bitmap will have a
> larger memory footprint than just a min/max, especially with random port
> allocation. But is this an issue in practice?
No need to speculate, some simple benchmarks would confirm or deny
this.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [RFC Patch] net: reserve ports for applications using fixed port numbers
From: Octavian Purdila @ 2010-02-04 18:15 UTC (permalink / raw)
To: David Miller
Cc: amwang-H+wXaHxf7aLQT0dZR+AlfA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
nhorman-2XuSBdqkA4R54TAoqtyWWQ, linux-sctp-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20100204.094110.64247447.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
On Thursday 04 February 2010 19:41:10 you wrote:
> From: Octavian Purdila <opurdila-+zzKsuq53OdBDgjK7y7TUQ@public.gmane.org>
> Date: Thu, 4 Feb 2010 14:44:01 +0200
>
> > My concern is that we can have multiple applications that require a
> > fixed port and if those ports are significantly apart we will
> > decrease the port range available for connect. And that will hurt
> > the rate of which new connections can be opened.
>
> I'm already uneasy about adding the simple check every time
> we loop around in the bind port allocator.
>
> Adding an LSM hook to this spot? I absolutely refuse to allow
> that, it will completely kill bind performance.
>
I think Tetsuo was proposing the LSM hook, so I'll leave him the daunting task
of convincing you of the benefit of that :) - I have no opinion on this due to
massive lack of knowledge.
I was just proposing to use a discrete set of ports instead of a range. The
check in the current patch:
int inet_is_reserved_local_port(int port)
{
int min, max;
inet_get_local_reserved_ports(&min, &max);
if (min && max)
return (port >= min && port <= max);
return 0;
}
would become:
int inet_is_reserved_local_port(int port)
{
if (test_bit(port, reserved_ports))
return 1;
return 0;
}
In theory it might be slower because of the reserved_ports bitmap will have a
larger memory footprint than just a min/max, especially with random port
allocation. But is this an issue in practice?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] net: emaclite: adding MDIO and phy lib support
From: Grant Likely @ 2010-02-04 18:12 UTC (permalink / raw)
To: John Linn
Cc: netdev, linuxppc-dev, jgarzik, jwboyer, john.williams,
Sadanand Mutyala
In-Reply-To: <00044664-e9db-419f-88bd-4de21af118b6@VA3EHSMHS001.ehs.local>
Hi John and Sadanand. Looks like a good patch, but a few issues to
resolve. Comments below.
g.
On Wed, Feb 3, 2010 at 5:49 PM, John Linn <john.linn@xilinx.com> wrote:
> These changes add MDIO and phy lib support to the driver as the
> IP core now supports the MDIO bus.
>
> The MDIO bus and phy are added as a child to the emaclite in the device
> tree as illustrated below.
>
> mdio {
> #address-cells = <1>;
> #size-cells = <0>;
> phy0: phy@7 {
> reg = <7>;
For completeness, phy node need a "compatible" property.
> } ;
> }
>
> Signed-off-by: Sadanand Mutyala <Sadanand.Mutyala@xilinx.com>
> Signed-off-by: John Linn <john.linn@xilinx.com>
> ---
> drivers/net/Kconfig | 1 +
> drivers/net/xilinx_emaclite.c | 362 ++++++++++++++++++++++++++++++++++++-----
> 2 files changed, 319 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index 396fd38..2056cd2 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -1947,6 +1947,7 @@ config ATL2
> config XILINX_EMACLITE
> tristate "Xilinx 10/100 Ethernet Lite support"
> depends on PPC32 || MICROBLAZE
> + select PHYLIB
> help
> This driver supports the 10/100 Ethernet Lite from Xilinx.
>
Patch appears to be whitespace damaged. All tabs have been converted to spaces.
> diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
> index 83a044d..8c7d7ae 100644
> --- a/drivers/net/xilinx_emaclite.c
> +++ b/drivers/net/xilinx_emaclite.c
> @@ -22,11 +22,17 @@
>
> #include <linux/of_device.h>
> #include <linux/of_platform.h>
> +#include <linux/of_mdio.h>
> +#include <linux/phy.h>
>
> #define DRIVER_NAME "xilinx_emaclite"
>
> /* Register offsets for the EmacLite Core */
> #define XEL_TXBUFF_OFFSET 0x0 /* Transmit Buffer */
> +#define XEL_MDIOADDR_OFFSET 0x07E4 /* MDIO Address Register */
> +#define XEL_MDIOWR_OFFSET 0x07E8 /* MDIO Write Data Register */
> +#define XEL_MDIORD_OFFSET 0x07EC /* MDIO Read Data Register */
> +#define XEL_MDIOCTRL_OFFSET 0x07F0 /* MDIO Control Register */
> #define XEL_GIER_OFFSET 0x07F8 /* GIE Register */
> #define XEL_TSR_OFFSET 0x07FC /* Tx status */
> #define XEL_TPLR_OFFSET 0x07F4 /* Tx packet length */
> @@ -37,6 +43,22 @@
>
> #define XEL_BUFFER_OFFSET 0x0800 /* Next Tx/Rx buffer's offset */
>
> +/* MDIO Address Register Bit Masks */
> +#define XEL_MDIOADDR_REGADR_MASK 0x0000001F /* Register Address */
> +#define XEL_MDIOADDR_PHYADR_MASK 0x000003E0 /* PHY Address */
> +#define XEL_MDIOADDR_PHYADR_SHIFT 5
> +#define XEL_MDIOADDR_OP_MASK 0x00000400 /* RD/WR Operation */
> +
> +/* MDIO Write Data Register Bit Masks */
> +#define XEL_MDIOWR_WRDATA_MASK 0x0000FFFF /* Data to be Written */
> +
> +/* MDIO Read Data Register Bit Masks */
> +#define XEL_MDIORD_RDDATA_MASK 0x0000FFFF /* Data to be Read */
> +
> +/* MDIO Control Register Bit Masks */
> +#define XEL_MDIOCTRL_MDIOSTS_MASK 0x00000001 /* MDIO Status Mask */
> +#define XEL_MDIOCTRL_MDIOEN_MASK 0x00000008 /* MDIO Enable */
> +
> /* Global Interrupt Enable Register (GIER) Bit Masks */
> #define XEL_GIER_GIE_MASK 0x80000000 /* Global Enable */
>
> @@ -87,6 +109,12 @@
> * @reset_lock: lock used for synchronization
> * @deferred_skb: holds an skb (for transmission at a later time) when the
> * Tx buffer is not free
> + * @phy_dev: pointer to the PHY device
> + * @phy_node: pointer to the PHY device node
> + * @mii_bus: pointer to the MII bus
> + * @mdio_irqs: IRQs table for MDIO bus
> + * @last_link: last link status
> + * @has_mdio: indicates whether MDIO is included in the HW
> */
> struct net_local {
>
> @@ -100,6 +128,15 @@ struct net_local {
>
> spinlock_t reset_lock;
> struct sk_buff *deferred_skb;
> +
> + struct phy_device *phy_dev;
> + struct device_node *phy_node;
> +
> + struct mii_bus *mii_bus;
> + int mdio_irqs[PHY_MAX_ADDR];
> +
> + int last_link;
> + bool has_mdio;
> };
>
>
> @@ -431,7 +468,7 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
> }
>
> /**
> - * xemaclite_set_mac_address - Set the MAC address for this device
> + * xemaclite_update_address - Update the MAC address in the device
> * @drvdata: Pointer to the Emaclite device private data
> * @address_ptr:Pointer to the MAC address (MAC address is a 48-bit value)
> *
> @@ -441,8 +478,8 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
> * The MAC address can be programmed using any of the two transmit
> * buffers (if configured).
> */
> -static void xemaclite_set_mac_address(struct net_local *drvdata,
> - u8 *address_ptr)
> +static void xemaclite_update_address(struct net_local *drvdata,
> + u8 *address_ptr)
> {
> void __iomem *addr;
> u32 reg_data;
> @@ -465,6 +502,30 @@ static void xemaclite_set_mac_address(struct net_local *drvdata,
> }
>
> /**
> + * xemaclite_set_mac_address - Set the MAC address for this device
> + * @dev: Pointer to the network device instance
> + * @addr: Void pointer to the sockaddr structure
> + *
> + * This function copies the HW address from the sockaddr strucutre to the
> + * net_device structure and updates the address in HW.
> + *
> + * Return: Error if the net device is busy or 0 if the addr is set
> + * successfully
> + */
> +static int xemaclite_set_mac_address(struct net_device *dev, void *address)
> +{
> + struct net_local *lp = (struct net_local *) netdev_priv(dev);
> + struct sockaddr *addr = address;
> +
> + if (netif_running(dev))
> + return -EBUSY;
> +
> + memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
> + xemaclite_update_address(lp, dev->dev_addr);
> + return 0;
> +}
> +
> +/**
> * xemaclite_tx_timeout - Callback for Tx Timeout
> * @dev: Pointer to the network device
> *
> @@ -641,12 +702,195 @@ static irqreturn_t xemaclite_interrupt(int irq, void *dev_id)
> return IRQ_HANDLED;
> }
>
> +/**********************/
> +/* MDIO Bus functions */
> +/**********************/
> +/**
> + * xemaclite_mdio_read - Read from a given MII management register
> + * @bus: the mii_bus struct
> + * @phy_id: the phy address
> + * @reg: register number to read from
> + *
> + * This function waits till the device is ready to accept a new MDIO
> + * request and then writes the phy address to the MDIO Address register
> + * and reads data from MDIO Read Data register, when its available.
> + *
> + * Return: Value read from the MII management register
> + */
> +static int xemaclite_mdio_read(struct mii_bus *bus, int phy_id, int reg)
> +{
> + struct net_local *lp = bus->priv;
> + u32 ctrl_reg;
> + u32 rc;
> +
> + /* Wait till the device is ready */
> + do {
> + ctrl_reg = in_be32(lp->base_addr + XEL_MDIOCTRL_OFFSET);
> + } while (ctrl_reg & XEL_MDIOCTRL_MDIOSTS_MASK);
This is a busywait loop that just burns cycles while waiting for the
MDIO bus to become non-busy, and further down...
> +
> + /* Write the PHY address, register number and set the OP bit in the
> + * MDIO Address register. Set the Status bit in the MDIO Control
> + * register to start a MDIO read transaction.
> + */
> + out_be32(lp->base_addr + XEL_MDIOADDR_OFFSET,
> + XEL_MDIOADDR_OP_MASK |
> + ((phy_id << XEL_MDIOADDR_PHYADR_SHIFT) | reg));
> + out_be32(lp->base_addr + XEL_MDIOCTRL_OFFSET,
> + ctrl_reg | XEL_MDIOCTRL_MDIOSTS_MASK);
> +
> + /* Wait for the device to complete the transaction and read the value
> + * from MDIO Read Data register.
> + */
> + do {
> + ctrl_reg = in_be32(lp->base_addr + XEL_MDIOCTRL_OFFSET);
> + } while (ctrl_reg & XEL_MDIOCTRL_MDIOSTS_MASK);
... I see the same thing waiting for the issued transaction to
complete. Busywaiting on slow events, like MDIO transfers, wastes a
lot of cycles that could be used for running other threads.
At the very least, the wait loop should msleep() so that other threads
get scheduled. Even better is if a completion is used and the MDIO
irq can be used to wake up the thread.
Another problem with this busywait is that is has no failure path if
the MDIO bus hangs up. The thread could get stuck spinning on this
loop forever with no way to kill it.
> + rc = in_be32(lp->base_addr + XEL_MDIORD_OFFSET);
> +
> + dev_dbg(&lp->ndev->dev,
> + "xemaclite_mdio_read(phy_id=%i, reg=%x) == %x\n",
> + phy_id, reg, rc);
> +
> + return rc;
> +}
> +
> +/**
> + * xemaclite_mdio_write - Write to a given MII management register
> + * @bus: the mii_bus struct
> + * @phy_id: the phy address
> + * @reg: register number to write to
> + * @val: value to write to the register number specified by reg
> + *
> + * This fucntion waits till the device is ready to accept a new MDIO
> + * request and then writes the val to the MDIO Write Data register.
> + */
> +static int xemaclite_mdio_write(struct mii_bus *bus, int phy_id, int reg,
> + u16 val)
> +{
> + struct net_local *lp = bus->priv;
> + u32 ctrl_reg;
> +
> + dev_dbg(&lp->ndev->dev,
> + "xemaclite_mdio_write(phy_id=%i, reg=%x, val=%x)\n",
> + phy_id, reg, val);
> +
> + /* Wait till the device is ready */
> + do {
> + ctrl_reg = in_be32(lp->base_addr + XEL_MDIOCTRL_OFFSET);
> + } while (ctrl_reg & XEL_MDIOCTRL_MDIOSTS_MASK);
Ditto here. In fact, this is a common pattern used 4 times in this
patch. Probably a candidate to break out into a subroutine.
> +
> + /* Write the PHY address, register number and clear the OP bit in the
> + * MDIO Address register and then write the value into the MDIO Write
> + * Data register. Finally, set the Status bit in the MDIO Control
> + * register to start a MDIO write transaction.
> + */
> + out_be32(lp->base_addr + XEL_MDIOADDR_OFFSET,
> + ~XEL_MDIOADDR_OP_MASK &
> + ((phy_id << XEL_MDIOADDR_PHYADR_SHIFT) | reg));
> + out_be32(lp->base_addr + XEL_MDIOWR_OFFSET, val);
> + out_be32(lp->base_addr + XEL_MDIOCTRL_OFFSET,
> + ctrl_reg | XEL_MDIOCTRL_MDIOSTS_MASK);
> +
> + return 0;
> +}
> +
> +/**
> + * xemaclite_mdio_reset - Reset the mdio bus.
> + * @bus: Pointer to the MII bus
> + *
> + * This function is required(?) as per Documentation/networking/phy.txt.
> + * There is no reset in this device; this function always returns 0.
> + */
> +static int xemaclite_mdio_reset(struct mii_bus *bus)
> +{
> + return 0;
> +}
> +
> +/**
> + * xemaclite_mdio_setup - Register mii_bus for the Emaclite device
> + * @lp: Pointer to the Emaclite device private data
> + * @ofdev: Pointer to OF device structure
> + *
> + * This function enables MDIO bus in the Emaclite device and registers a
> + * mii_bus.
> + *
> + * Return: 0 upon success or a negative error upon failure
> + */
> +static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
> +{
> + struct mii_bus *bus;
> + int rc;
> + struct resource res;
> + struct device_node *np = of_get_parent(lp->phy_node);
> +
> + /* Don't register the MDIO bus if the phy_node or its parent node
> + * can't be found.
> + */
> + if (!np)
> + return -ENODEV;
> +
> + /* Enable the MDIO bus by asserting the enable bit in MDIO Control
> + * register.
> + */
> + out_be32(lp->base_addr + XEL_MDIOCTRL_OFFSET,
> + XEL_MDIOCTRL_MDIOEN_MASK);
> +
> + bus = mdiobus_alloc();
> + if (!bus)
> + return -ENOMEM;
> +
> + of_address_to_resource(np, 0, &res);
> + snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
> + (unsigned long long)res.start);
> + bus->priv = lp;
> + bus->name = "Xilinx Emaclite MDIO";
> + bus->read = xemaclite_mdio_read;
> + bus->write = xemaclite_mdio_write;
> + bus->reset = xemaclite_mdio_reset;
> + bus->parent = dev;
> + bus->irq = lp->mdio_irqs; /* preallocated IRQ table */
> +
> + lp->mii_bus = bus;
> +
> + rc = of_mdiobus_register(bus, np);
> + if (rc)
> + goto err_register;
> +
> + return 0;
> +
> +err_register:
> + mdiobus_free(bus);
> + return rc;
> +}
> +
> +/**
> + * xemaclite_adjust_link - Link state callback for the Emaclite device
> + * @ndev: pointer to net_device struct
> + *
> + * There's nothing in the Emaclite device to be configured when the link
> + * state changes. We just print the status.
> + */
> +void xemaclite_adjust_link(struct net_device *ndev)
> +{
> + struct net_local *lp = netdev_priv(ndev);
> + struct phy_device *phy = lp->phy_dev;
> + int link_state;
> +
> + /* hash together the state values to decide if something has changed */
> + link_state = phy->speed | (phy->duplex << 1) | phy->link;
> +
> + if (lp->last_link != link_state) {
> + lp->last_link = link_state;
> + phy_print_status(phy);
> + }
> +}
> +
> /**
> * xemaclite_open - Open the network device
> * @dev: Pointer to the network device
> *
> * This function sets the MAC address, requests an IRQ and enables interrupts
> * for the Emaclite device and starts the Tx queue.
> + * It also connects to the phy device, if MDIO is included in Emaclite device.
> */
> static int xemaclite_open(struct net_device *dev)
> {
> @@ -656,14 +900,50 @@ static int xemaclite_open(struct net_device *dev)
> /* Just to be safe, stop the device first */
> xemaclite_disable_interrupts(lp);
>
> + if (lp->phy_node) {
> + u32 bmcr;
> +
> + lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node,
> + xemaclite_adjust_link, 0,
> + PHY_INTERFACE_MODE_MII);
> + if (!lp->phy_dev) {
> + dev_err(&lp->ndev->dev, "of_phy_connect() failed\n");
> + return -ENODEV;
> + }
> +
> + /* EmacLite doesn't support giga-bit speeds */
> + lp->phy_dev->supported &= (PHY_BASIC_FEATURES);
> + lp->phy_dev->advertising = lp->phy_dev->supported;
> +
> + /* Don't advertise 1000BASE-T Full/Half duplex speeds */
> + xemaclite_mdio_write(lp->mii_bus, lp->phy_dev->addr,
> + MII_CTRL1000, 0x00);
> + /* Advertise only 10 and 100mbps full/half duplex speeds */
> + xemaclite_mdio_write(lp->mii_bus, lp->phy_dev->addr,
> + MII_ADVERTISE, ADVERTISE_ALL);
> +
> + /* Restart auto negotiation */
> + bmcr = xemaclite_mdio_read(lp->mii_bus,
> + lp->phy_dev->addr, MII_BMCR);
> + bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
> + xemaclite_mdio_write(lp->mii_bus, lp->phy_dev->addr,
> + MII_BMCR, bmcr);
> +
> + phy_start(lp->phy_dev);
> + }
> +
> /* Set the MAC address each time opened */
> - xemaclite_set_mac_address(lp, dev->dev_addr);
> + xemaclite_update_address(lp, dev->dev_addr);
>
> /* Grab the IRQ */
> retval = request_irq(dev->irq, xemaclite_interrupt, 0, dev->name, dev);
> if (retval) {
> dev_err(&lp->ndev->dev, "Could not allocate interrupt %d\n",
> dev->irq);
> + if (lp->phy_dev)
> + phy_disconnect(lp->phy_dev);
> + lp->phy_dev = NULL;
> +
> return retval;
> }
>
> @@ -682,6 +962,7 @@ static int xemaclite_open(struct net_device *dev)
> *
> * This function stops the Tx queue, disables interrupts and frees the IRQ for
> * the Emaclite device.
> + * It also disconnects the phy device associated with the Emaclite device.
> */
> static int xemaclite_close(struct net_device *dev)
> {
> @@ -691,6 +972,10 @@ static int xemaclite_close(struct net_device *dev)
> xemaclite_disable_interrupts(lp);
> free_irq(dev->irq, dev);
>
> + if (lp->phy_dev)
> + phy_disconnect(lp->phy_dev);
> + lp->phy_dev = NULL;
> +
> return 0;
> }
>
> @@ -754,42 +1039,6 @@ static int xemaclite_send(struct sk_buff *orig_skb, struct net_device *dev)
> }
>
> /**
> - * xemaclite_ioctl - Perform IO Control operations on the network device
> - * @dev: Pointer to the network device
> - * @rq: Pointer to the interface request structure
> - * @cmd: IOCTL command
> - *
> - * The only IOCTL operation supported by this function is setting the MAC
> - * address. An error is reported if any other operations are requested.
> - *
> - * Return: 0 to indicate success, or a negative error for failure.
> - */
> -static int xemaclite_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
> -{
> - struct net_local *lp = (struct net_local *) netdev_priv(dev);
> - struct hw_addr_data *hw_addr = (struct hw_addr_data *) &rq->ifr_hwaddr;
> -
> - switch (cmd) {
> - case SIOCETHTOOL:
> - return -EIO;
> -
> - case SIOCSIFHWADDR:
> - dev_err(&lp->ndev->dev, "SIOCSIFHWADDR\n");
> -
> - /* Copy MAC address in from user space */
> - copy_from_user((void __force *) dev->dev_addr,
> - (void __user __force *) hw_addr,
> - IFHWADDRLEN);
> - xemaclite_set_mac_address(lp, dev->dev_addr);
> - break;
> - default:
> - return -EOPNOTSUPP;
> - }
> -
> - return 0;
> -}
> -
> -/**
> * xemaclite_remove_ndev - Free the network device
> * @ndev: Pointer to the network device to be freed
> *
> @@ -840,6 +1089,8 @@ static struct net_device_ops xemaclite_netdev_ops;
> * This function probes for the Emaclite device in the device tree.
> * It initializes the driver data structure and the hardware, sets the MAC
> * address and registers the network device.
> + * It also registers a mii_bus for the Emaclite device, if MDIO is included
> + * in the device.
> *
> * Return: 0, if the driver is bound to the Emaclite device, or
> * a negative error if there is failure.
> @@ -853,7 +1104,6 @@ static int __devinit xemaclite_of_probe(struct of_device *ofdev,
> struct net_local *lp = NULL;
> struct device *dev = &ofdev->dev;
> const void *mac_address;
> -
Unrelated whitespace change.
> int rc = 0;
>
> dev_info(dev, "Device Tree Probing\n");
> @@ -880,6 +1130,7 @@ static int __devinit xemaclite_of_probe(struct of_device *ofdev,
> }
>
> dev_set_drvdata(dev, ndev);
> + SET_NETDEV_DEV(ndev, &ofdev->dev);
>
> ndev->irq = r_irq.start;
> ndev->mem_start = r_mem.start;
> @@ -923,7 +1174,16 @@ static int __devinit xemaclite_of_probe(struct of_device *ofdev,
> out_be32(lp->base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET, 0);
>
> /* Set the MAC address in the EmacLite device */
> - xemaclite_set_mac_address(lp, ndev->dev_addr);
> + xemaclite_update_address(lp, ndev->dev_addr);
> +
> + /* Check if MDIO is included in the HW */
> + lp->has_mdio = get_bool(ofdev, "xlnx,include-mdio");
> + if (lp->has_mdio) {
> + lp->phy_node = of_parse_phandle(ofdev->node, "phy-handle", 0);
> + rc = xemaclite_mdio_setup(lp, &ofdev->dev);
> + if (rc)
> + dev_warn(&ofdev->dev, "error registering MDIO bus\n");
> + }
What if the phy is attached to a different MDIO bus (which is
completely possible)? The fetching of phy_node should be performed
regardless of whether or not xlnx,include-mdio is set.
>
> dev_info(dev,
> "MAC address is now %2x:%2x:%2x:%2x:%2x:%2x\n",
> @@ -972,12 +1232,25 @@ static int __devexit xemaclite_of_remove(struct of_device *of_dev)
> struct device *dev = &of_dev->dev;
> struct net_device *ndev = dev_get_drvdata(dev);
>
> + struct net_local *lp = (struct net_local *) netdev_priv(ndev);
> +
> + /* Un-register the mii_bus, if configured */
> + if (lp->has_mdio) {
> + mdiobus_unregister(lp->mii_bus);
> + kfree(lp->mii_bus->irq);
> + mdiobus_free(lp->mii_bus);
> + lp->mii_bus = NULL;
> + }
> +
> unregister_netdev(ndev);
>
> + if (lp->phy_node)
> + of_node_put(lp->phy_node);
> + lp->phy_node = NULL;
> +
> release_mem_region(ndev->mem_start, ndev->mem_end-ndev->mem_start + 1);
>
> xemaclite_remove_ndev(ndev);
> -
> dev_set_drvdata(dev, NULL);
>
> return 0;
> @@ -987,7 +1260,7 @@ static struct net_device_ops xemaclite_netdev_ops = {
> .ndo_open = xemaclite_open,
> .ndo_stop = xemaclite_close,
> .ndo_start_xmit = xemaclite_send,
> - .ndo_do_ioctl = xemaclite_ioctl,
> + .ndo_set_mac_address = xemaclite_set_mac_address,
> .ndo_tx_timeout = xemaclite_tx_timeout,
> .ndo_get_stats = xemaclite_get_stats,
> };
> @@ -999,6 +1272,7 @@ static struct of_device_id xemaclite_of_match[] __devinitdata = {
> { .compatible = "xlnx,xps-ethernetlite-1.00.a", },
> { .compatible = "xlnx,xps-ethernetlite-2.00.a", },
> { .compatible = "xlnx,xps-ethernetlite-2.01.a", },
> + { .compatible = "xlnx,xps-ethernetlite-3.00.a", },
> { /* end of list */ },
> };
> MODULE_DEVICE_TABLE(of, xemaclite_of_match);
> --
> 1.6.2.1
>
>
>
> This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
>
>
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ 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