Netdev List
 help / color / mirror / Atom feed
* Re: IPv6 autoconf/accept_ra default values - revisited
From: Brian Haley @ 2010-02-17 16:54 UTC (permalink / raw)
  To: Kolbjørn Barmen; +Cc: Vlad Yasevich, davem, yoshfuji, netdev
In-Reply-To: <alpine.LNX.2.01.1002162206090.2396@halbrend.uninett.no>

Hi Kolla,

Kolbjørn Barmen wrote:
>> For a test, can you turno-off accept_ra/accept_ra_defrtr/accept_ra_pinfo
> 
> What are they, documented anywhere?

Documentation/networking/ip-sysctl.txt

>> and see if you can get the behavior you want?
> 
> I must admit that I havent tried using those yet, but still
> I somehow managed to get what I want like this:
> 
> ~ # cat /etc/modprobe.d/ipv6.conf
> options ipv6 disable_ipv6=1 autoconf=0
> ~ # cat /etc/sysctl.d/ipv6.conf
> net.ipv6.conf.default.autoconf=0
> net.ipv6.conf.default.accept_ra=0
> net.ipv6.conf.default.disable_ipv6 = 0
> net.ipv6.conf.all.autoconf=0
> net.ipv6.conf.all.accept_ra=0
> net.ipv6.conf.lo.disable_ipv6=0
> 
> I'm still not convinced it really works, but it looks good so far.

Ok, so when the IPv6 module is loaded, it won't configure any addresses.
Then you enable IPv6 on future interfaces that are added, and enable it
on lo.  So after this you just have an address on lo and your bridges,
right?

>>> So, could "autoconf" also please turn off accept_ra?
>>> Or, if you like, add another parameter for it :P
>> There are other things in the RA that are useful, like MTU, turning-off
>> accept_ra would miss that
> 
> So what is one supposed to do when one wants fully statically configured
> IPv6 addresses and routes? Or is that not supposed to be possible?

This sequence worked for me on a single interface:

# sysctl net.ipv6.conf.eth0.disable_ipv6=1
# sysctl net.ipv6.conf.eth0.accept_ra_defrtr=0
# sysctl net.ipv6.conf.eth0.accept_ra_pinfo=0
# sysctl net.ipv6.conf.eth0.disable_ipv6=0

Interface now has just link-local and you can add addresses and routes
as necessary.

So it looks possible to modify your conf file like this:

net.ipv6.conf.all.accept_ra_defrtr=0
net.ipv6.conf.all.accept_ra_pinfo=0

>> I think maybe ignoring the prefix info options when autoconf=0 might be
>> what you want.  I guess we could do another module parameter if we had
>> to.
> 
> Yes - all I want is ignore prefix and router announcements, they are not
> to be trusted.

By router announcements do you mean you don't want to make the sender the
default router?

>>> And the entire "all" vs. "default" still confuses me.
>>>
>>> * "default" is supposed to cover _all future_ interfaces?
>>> * "all" is supposed to cover _all existing_ interfaces, and change them?
>>>   If not, then what is its function?
>> Yes, "default" covers future interfaces, but "all" behavior depends on
>> the option - "all->forwarding" and "all->disable_ipv6" will reset
>> interfaces and "all->proxy_ndp" affects all interfaces.  Other than
>> that, the "all" variables seem not to be used.  Making it more like the
>> IPv4 code sooner than later might be a good thing, maybe others have
>> thoughts on that?
> 
> I'd say yes, and the sooner the better.
> (I've noticed the Debian has "Full IPv6 support" in their feature list for
> next release this summer, it would be nice to have something ready for that.)

Well, I'll see what I can do...

>>> And lastly - all this would be a non-issue if the defaults values were so
>>> that all autoconf/accept_ra were 0 - it's _so_ easy to turn on, but
>>> incredibly complicated to turn off. The harder it is to make sense out of
>>> things like this, the harder it is to have people start with IPv6.
>> I don't think that default is going to change since it would effectively
>> disable IPv6 for 99.9% of users, my grandmother would wonder why nothing works
>> any more and not know how to fix it :)  In other words, people not doing
>> autoconfiguration are in the minority, and might need to change all these
>> default settings, but we should make it easier to use.
> 
> Right, here it comes, the "most users" argument.
> Sorry, but I just want to rant a little over this ;)
> 
> Your grandmother will be pretty fed up anyways since some random wifi
> stumbler with 6to4 accidently turned on, jumps on her weakly configured
> access point, announcing routes so that her computer now routes all
> traffic through the stumblers laptop, which works fine till the stumbler
> vanishes, leaving your grandmother's computer with lots of stalled TCP
> sessions and a broken default gateway. Not to mention all the timeouts she
> will have to wait for as her computer attempts to contact all the ipv6
> addresses it resolves before finally, maybe, trying ipv4 instead.

Yes, I've seen this too when someone configures their laptop to be an
IPv6 router at home, and then comes into the office.  We then track them
down and "educate" them :)  The only solution to this is SeND I believe,
and that's not widely deployed at all.

> I have worked with ipv6 in "production" long enough to know that the
> overly optimistic view on how things are supposed to work is one of the
> big obstacles for deployment of IPv6, it's just too fragile...
> 
> 6to4 accidently activated on a machine on the LAN? Boom!
> Loop between LANs as resault of accident plugging on switch? Boom!
> Multihomed machine accidently forwards between interfaces? Boom!
> 
> And what do you do when suddenly you have heaploads of machiens with
> nonworking IPv6 configurations? DHCPv6 to the rescue? Or not? :)

DHCPv6 is going to be widely used from what I know, as enterprises
typically use DHCPv4 today, they don't want the end-user to be
administering this stuff at all.

-Brian

^ permalink raw reply

* [net-next PATCH 1/3] qlge: Fix dropping of large non-TCP/UDP frames.
From: Ron Mercer @ 2010-02-17 16:41 UTC (permalink / raw)
  To: davem; +Cc: netdev, ron.mercer
In-Reply-To: <1266424883-25927-1-git-send-email-ron.mercer@qlogic.com>

This was found with pings that were large enough to span multiple rx
buffers.  The split frame logic handles this case nicely.

Signed-off-by: Ron Mercer <ron.mercer@qlogic.com>
---
 drivers/net/qlge/qlge_main.c |   20 +++++---------------
 1 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 2c052ca..0541e77 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -2066,21 +2066,11 @@ static unsigned long ql_process_mac_rx_intr(struct ql_adapter *qdev,
 		ql_process_mac_rx_page(qdev, rx_ring, ib_mac_rsp,
 						length, vlan_id);
 	} else {
-		struct bq_desc *lbq_desc;
-
-		/* Free small buffer that holds the IAL */
-		lbq_desc = ql_get_curr_sbuf(rx_ring);
-		netif_err(qdev, rx_err, qdev->ndev,
-			  "Dropping frame, len %d > mtu %d\n",
-			  length, qdev->ndev->mtu);
-
-		/* Unwind the large buffers for this frame. */
-		while (length > 0) {
-			lbq_desc = ql_get_curr_lchunk(qdev, rx_ring);
-			length -= (length < rx_ring->lbq_buf_size) ?
-				length : rx_ring->lbq_buf_size;
-			put_page(lbq_desc->p.pg_chunk.page);
-		}
+		/* Non-TCP/UDP large frames that span multiple buffers
+		 * can be processed corrrectly by the split frame logic.
+		 */
+		ql_process_mac_split_rx_intr(qdev, rx_ring, ib_mac_rsp,
+						vlan_id);
 	}
 
 	return (unsigned long)length;
-- 
1.6.0.2


^ permalink raw reply related

* [net-next PATCH 3/3] qlge: Fix occasional loopback test failure.
From: Ron Mercer @ 2010-02-17 16:41 UTC (permalink / raw)
  To: davem; +Cc: netdev, ron.mercer
In-Reply-To: <1266424883-25927-1-git-send-email-ron.mercer@qlogic.com>

On some servers we see the cleaning of the RX queue finish before all
the loopback packets are sent out.  This delay allows the queues to
settle before checking for successful completion.
Also, delay completion so link has time to come back up.

Signed-off-by: Ron Mercer <ron.mercer@qlogic.com>
---
 drivers/net/qlge/qlge_ethtool.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/net/qlge/qlge_ethtool.c b/drivers/net/qlge/qlge_ethtool.c
index 4f26afe..05b8bde 100644
--- a/drivers/net/qlge/qlge_ethtool.c
+++ b/drivers/net/qlge/qlge_ethtool.c
@@ -503,7 +503,8 @@ static int ql_run_loopback_test(struct ql_adapter *qdev)
 			return -EPIPE;
 		atomic_inc(&qdev->lb_count);
 	}
-
+	/* Give queue time to settle before testing results. */
+	msleep(2);
 	ql_clean_lb_rx_ring(&qdev->rx_ring[0], 128);
 	return atomic_read(&qdev->lb_count) ? -EIO : 0;
 }
@@ -536,6 +537,10 @@ static void ql_self_test(struct net_device *ndev,
 			data[0] = 0;
 		}
 		clear_bit(QL_SELFTEST, &qdev->flags);
+		/* Give link time to come up after
+		 * port configuration changes.
+		 */
+		msleep_interruptible(4 * 1000);
 	} else {
 		netif_err(qdev, drv, qdev->ndev,
 			  "is down, Loopback test will fail.\n");
-- 
1.6.0.2


^ permalink raw reply related

* [net-next PATCH 0/3] qlge: minor fixes.
From: Ron Mercer @ 2010-02-17 16:41 UTC (permalink / raw)
  To: davem; +Cc: netdev, ron.mercer


 Miscellaneous fixes for qlge:

1) Fix large ping (non-TCP/UDP) frame dropping when data spans
multiple  rx  buffers.
2) Fix mac address filter issue for bonding.
3) Fix ethtool loopback test.



^ permalink raw reply

* [net-next PATCH 2/3] qlge: Fix bonding mac address bug.
From: Ron Mercer @ 2010-02-17 16:41 UTC (permalink / raw)
  To: davem; +Cc: netdev, ron.mercer
In-Reply-To: <1266424883-25927-1-git-send-email-ron.mercer@qlogic.com>

Use local copy of current mac address when initializing.  In bonding
testing we saw cases where dev_addr was out of data causing failover
errors.

Signed-off-by: Ron Mercer <ron.mercer@qlogic.com>
---
 drivers/net/qlge/qlge.h      |    2 ++
 drivers/net/qlge/qlge_main.c |    6 +++++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index 57d135e..8b742b6 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -2139,6 +2139,8 @@ struct ql_adapter {
 	u16 device_id;
 	struct timer_list timer;
 	atomic_t lb_count;
+	/* Keep local copy of current mac address. */
+	char current_mac_addr[6];
 };
 
 /*
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 0541e77..c170349 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -463,7 +463,7 @@ static int ql_set_mac_addr(struct ql_adapter *qdev, int set)
 	char *addr;
 
 	if (set) {
-		addr = &qdev->ndev->dev_addr[0];
+		addr = &qdev->current_mac_addr[0];
 		netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
 			     "Set Mac addr %pM\n", addr);
 	} else {
@@ -4301,6 +4301,8 @@ static int qlge_set_mac_address(struct net_device *ndev, void *p)
 	if (!is_valid_ether_addr(addr->sa_data))
 		return -EADDRNOTAVAIL;
 	memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len);
+	/* Update local copy of current mac address. */
+	memcpy(qdev->current_mac_addr, ndev->dev_addr, ndev->addr_len);
 
 	status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK);
 	if (status)
@@ -4542,6 +4544,8 @@ static int __devinit ql_init_device(struct pci_dev *pdev,
 	}
 
 	memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
+	/* Keep local copy of current mac address. */
+	memcpy(qdev->current_mac_addr, ndev->dev_addr, ndev->addr_len);
 
 	/* Set up the default ring sizes. */
 	qdev->tx_ring_size = NUM_TX_RING_ENTRIES;
-- 
1.6.0.2


^ permalink raw reply related

* [PATCH net-next-2.6] xt_hashlimit: fix locking
From: Eric Dumazet @ 2010-02-17 16:43 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: davem, netdev, netfilter-devel
In-Reply-To: <20100216145550.2796.32.sendpatchset@x2.localnet>

Le mardi 16 février 2010 à 15:55 +0100, Patrick McHardy a écrit :
> commit 2eff25c18c3d332d3c4dd98f2ac9b7114e9771b0
> Author: Patrick McHardy <kaber@trash.net>
> Date:   Wed Feb 3 13:24:54 2010 +0100
> 
>     netfilter: xt_hashlimit: fix race condition and simplify locking
>     
>     As noticed by Shin Hong <hongshin@gmail.com>, there is a race between
>     htable_find_get() and htable_put():
>     
>     htable_put():				htable_find_get():
>     
>     					spin_lock_bh(&hashlimit_lock);
>     					<search entry>
>     atomic_dec_and_test(&hinfo->use)
>     					atomic_inc(&hinfo->use)
>     					spin_unlock_bh(&hashlimit_lock)
>     					return hinfo;
>     spin_lock_bh(&hashlimit_lock);
>     hlist_del(&hinfo->node);
>     spin_unlock_bh(&hashlimit_lock);
>     htable_destroy(hinfo);
>     
>     The entire locking concept is overly complicated, tables are only
>     created/referenced and released in process context, so a single
>     mutex works just fine. Remove the hashinfo_spinlock and atomic
>     reference count and use the mutex to protect table lookups/creation
>     and reference count changes.
>     
>     Signed-off-by: Patrick McHardy <kaber@trash.net>
> 

Patrick, David

I believe this patch has a problem, since latest net-next-2.6 triggers :

[  240.682047] INFO: task iptables:4512 blocked for more than 120
seconds.
[  240.682125] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
disables this message.
[  240.682198] iptables      D f7a69c48     0  4512   4436 0x00000000
[  240.682201]  f7a69c5c 00000086 00000002 f7a69c48 c3603304 00000000
c0379b0d 0000000e
[  240.682540]  00000138 f8c06504 fffbef49 d15abc2a 00000007 c0785000
c0788304 00000000
[  240.682861]  f81af0c0 c078d080 d157e120 00000007 f81aee40 c037a608
00000202 f9e38478
[  240.683191] Call Trace:
[  240.683247]  [<c0379b0d>] ? get_from_free_list+0x3d/0x50
[  240.683303]  [<c037a608>] ? ida_pre_get+0x18/0xe0
[  240.683359]  [<c05503ed>] __mutex_lock_slowpath+0xed/0x230
[  240.683426]  [<c0550540>] mutex_lock+0x10/0x20
[  240.683488]  [<c04dee7e>] hashlimit_mt_check+0x29e/0x380
[  240.683544]  [<c04de02c>] xt_check_match+0x9c/0x1b0
[  240.683599]  [<c05509a7>] ? __mutex_lock_interruptible_slowpath
+0x1a7/0x260
[  240.683657]  [<c05509a7>] ? __mutex_lock_interruptible_slowpath
+0x1a7/0x260
[  240.683716]  [<c05502fd>] ? mutex_unlock+0xd/0x10
[  240.683770]  [<c04ddb1f>] ? xt_find_match+0xdf/0x150
[  240.683831]  [<c0521994>] translate_table+0x384/0x760
[  240.683886]  [<c04dde02>] ? xt_alloc_table_info+0x52/0xc0
[  240.683942]  [<c0522bef>] do_ipt_set_ctl+0x16f/0x440
[  240.683998]  [<c04da2cb>] nf_sockopt+0x15b/0x1a0
[  240.684062]  [<c0551ca0>] ? _raw_spin_lock_bh+0x10/0x30
[  240.684118]  [<c04da369>] nf_setsockopt+0x29/0x30
[  240.684177]  [<c04eb96e>] ip_setsockopt+0x8e/0xa0
[  240.684233]  [<c02bd6ec>] ? page_add_new_anon_rmap+0x7c/0x90
[  240.684289]  [<c0504df4>] raw_setsockopt+0x44/0x80
[  240.684345]  [<c04aaf87>] sock_common_setsockopt+0x27/0x30
[  240.684411]  [<c04a9569>] sys_setsockopt+0x59/0xb0
[  240.684472]  [<c04aa90a>] sys_socketcall+0x12a/0x280
[  240.684528]  [<c0202c50>] sysenter_do_call+0x12/0x26


htable_create() is called with hashlimit_mutex already hold

Maybe original race could be solved using atomic_inc_not_zero() instead
of atomic_inc() ?

Or following quick & dirty patch just cures the problem.

Thanks

[PATCH net-next-2.6] xt_hashlimit: fix locking

Commit 2eff25c18c3d332d3c4dd98f2ac9b7114e9771b0
(netfilter: xt_hashlimit: fix race condition and simplify locking)
added a mutex deadlock :
htable_create() is called with hashlimit_mutex already locked

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index e47fb80..d952806 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -262,9 +262,7 @@ static int htable_create_v0(struct net *net, struct xt_hashlimit_info *minfo, u_
 	hinfo->timer.expires = jiffies + msecs_to_jiffies(hinfo->cfg.gc_interval);
 	add_timer(&hinfo->timer);
 
-	mutex_lock(&hashlimit_mutex);
 	hlist_add_head(&hinfo->node, &hashlimit_net->htables);
-	mutex_unlock(&hashlimit_mutex);
 
 	return 0;
 }
@@ -327,9 +325,7 @@ static int htable_create(struct net *net, struct xt_hashlimit_mtinfo1 *minfo,
 	hinfo->timer.expires = jiffies + msecs_to_jiffies(hinfo->cfg.gc_interval);
 	add_timer(&hinfo->timer);
 
-	mutex_lock(&hashlimit_mutex);
 	hlist_add_head(&hinfo->node, &hashlimit_net->htables);
-	mutex_unlock(&hashlimit_mutex);
 
 	return 0;
 }


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* Re: [net-next PATCH v4 3/3] net: reserve ports for applications using fixed port numbers
From: Eric Dumazet @ 2010-02-17 16:39 UTC (permalink / raw)
  To: Cong Wang
  Cc: Octavian Purdila, David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers, Neil Horman
In-Reply-To: <4B7C159A.3060603@redhat.com>

Le jeudi 18 février 2010 à 00:13 +0800, Cong Wang a écrit :

> I don't think so, if you want to avoid race condition, you just need to
> write the reserved ports before any networking application starts, IOW,
> as early as possible during boot.
> 

Sure, but I was thinking retrieving the list of reserved port by a
database query, using network :)

Anyway, I just feel your argument is not applicable.

Our kernel is capable of doing an intersection for us, we dont need
to forbid user to mark a port as 'reserved' if this port is already
blacklisted by another mechanism (for example, if this port is already
in use)

^ permalink raw reply

* Re: [net-next PATCH v4 1/3] sysctl: refactor integer handling proc code
From: Eric W. Biederman @ 2010-02-17 16:33 UTC (permalink / raw)
  To: Cong Wang
  Cc: Octavian Purdila, David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers
In-Reply-To: <4B7C178A.8010708@redhat.com>

Cong Wang <amwang@redhat.com> writes:

> Octavian Purdila wrote:
>> On Tuesday 16 February 2010 15:09:51 you wrote:
>>> Octavian Purdila wrote:
>>>> On Tuesday 16 February 2010 10:41:07 you wrote:
>>>>>> +static int proc_skip_wspace(char __user **buf, size_t *size)
>>>>>> +{
>>>>>> +     char c;
>>>>>> +
>>>>>> +     while (*size) {
>>>>>> +             if (get_user(c, *buf))
>>>>>> +                     return -EFAULT;
>>>>>> +             if (!isspace(c))
>>>>>> +                     break;
>>>>>> +             (*size)--; (*buf)++;
>>>>>> +     }
>>>>>> +
>>>>>> +     return 0;
>>>>>> +}
>>>>> In lib/string.c we have skip_spaces(), I think we can use it
>>>>> here instead of inventing another one.
>>>> I'm afraid we can't, skip_spaces does not accept userspace buffers.
>>> Well, you need to use copy_from_user() before call it.
>>>
>>
>> And how much would you copy? You need to either use a stack buffer and do a
>> loop copy or you would need to copy the whole userspace buffer which means we
>> need to allocate a kernel buffer. I think its much cleaner the way is
>> currently done.
>
> Yeah, maybe just a personal preference. :-/

There can be valid security reasons for copying all of the data before
processing it.

Semantically if we an guarantee that we either have processed the
entire buffer or failed the entire buffer and no changes have occurred
in the kernel that seems like a much easier semantic to work with in
user space.

Eric

^ permalink raw reply

* Re: [net-next PATCH v4 1/3] sysctl: refactor integer handling proc code
From: Cong Wang @ 2010-02-17 16:31 UTC (permalink / raw)
  To: Octavian Purdila
  Cc: David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers, Eric W. Biederman
In-Reply-To: <201002161600.54975.opurdila@ixiacom.com>

Octavian Purdila wrote:
> On Tuesday 16 February 2010 15:08:23 you wrote:
>> Octavian Purdila wrote:
>>> On Tuesday 16 February 2010 10:41:07 you wrote:
>>>>> +
>>>>> +     if (!write && !first && left && !err)
>>>>> +             err = proc_put_newline(&buffer, &left);
>>>>> +     if (write && !err)
>>>>> +             err = proc_skip_wspace(&buffer, &left);
>>>>> +     if (err == -EFAULT /* do we really need to check for -EFAULT? */
>>>>> || +         (write && first))
>>>>> +             return err ? : -EINVAL;
>>>> The logic here seems messy, adding one or two goto's may help?
>>> OK, I'll give it a try.
>>>
>>> What about the EFAULT check, is that really required?
>> I think so, it means to keep the errno to user-space when it is EFAULT,
>> right? This seems reasonable.
>>
> 
> The problem I see is that this way we don't actually acknowledge some of the 
> set values, e.g. say that we have buffer="1 2 3" and length = 100. Although we 
> do accept values 1, 2 and 3 we don't acknowledge that to the user (as we would 
> do for, say "1 2 3 4a"), but return -EFAULT.
> 
> I think it would be better to skip this check. That means that the user will 
> get the ack for the 1, 2 and 3 values and next time it continues the write it 
> will get -EFAULT.
> 
> This will of course change the userspace ABI, albeit in a minor way, and it is 
> not clear to me if doing this is allowed (even if this new approach would be 
> the correct one).
> 

I think the right behavior is accept "1 2 3" and return the number of
bytes that we accept.

^ permalink raw reply

* Re: [net-next PATCH v4 0/3] net: reserve ports for applications using fixed port
From: Eric W. Biederman @ 2010-02-17 16:26 UTC (permalink / raw)
  To: Cong Wang
  Cc: Octavian Purdila, David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers, Eric Dumazet
In-Reply-To: <4B7C1722.7040304@redhat.com>

Cong Wang <amwang@redhat.com> writes:

> Eric W. Biederman wrote:
>> Cong Wang <amwang@redhat.com> writes:
>>
>>> Octavian Purdila wrote:
>>>> On Tuesday 16 February 2010 22:08:13 you wrote:
>>>>>> Something like bellow?
>>>>>>
>>>>>> # set bits 8080 and 1666
>>>>>> $echo 8080 1666-1666 > /proc
>>>>>>
>>>>>> #reset bit 1666
>>>>>> $echo 8080 > /proc
>>>>>>
>>>>>> #reset whole bitmap
>>>>>> $echo > /proc
>>>>> Yes. So something like that.
>>>>>
>>>>> I think I would use commas instead of spaces as that is more traditional.
>>>
>>> Why this is better than the current version?
>>>
>>> For the single port case, currently we use:
>>>
>>> echo +8080 > /xxxx #set
>>> echo -8080 > /xxxx #clear
>>>
>>> Now we will use:
>>>
>>> echo 8080 > /xxxx #set
>>> echo 8080 > /xxxx #clear
>>
>> No.
>>
>>> I don't think the latter is better...
>>>
>>> For the multi-port case, yes, we should accept 'echo 8080,10000 >/xxxx'.
>>
>> What I was envisioning was:
>>
>> echo 8080 > /xxx # set the bitmap to 8080
>> echo 8080,10000 > /xxx # add 10000 to the bitmap
>> echo 8080 > /xxxx # remove 10000 from the bitmap.
>>
>> That is when you set it you enter the entire set every time, treating
>> the entire set as a single value.
>>
>
> Oh, I see, this is ok.
>
> But if we could support multi-port, that will be better, something like:
>
> echo '8080,10000-11000' > /xxx #add port 8080 and port range 10000-11000
>
> so that I don't have to construct a long string for all ports within
> 10000 and 11000.

Yes, multi-port ranges are what I suggested.  You simply had not
gotten confused about that aspect, so I was not repeating it.
Except for pathological cases a ranges should keep the string
that represents the bitmap small.

Eric

^ permalink raw reply

* Re: [net-next PATCH v4 0/3] net: reserve ports for applications using fixed port
From: Cong Wang @ 2010-02-17 16:19 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Octavian Purdila, David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers, Eric Dumazet
In-Reply-To: <m1ljer3ksy.fsf@fess.ebiederm.org>

Eric W. Biederman wrote:
> Cong Wang <amwang@redhat.com> writes:
> 
>> Octavian Purdila wrote:
>>> On Tuesday 16 February 2010 22:08:13 you wrote:
>>>>> Something like bellow?
>>>>>
>>>>> # set bits 8080 and 1666
>>>>> $echo 8080 1666-1666 > /proc
>>>>>
>>>>> #reset bit 1666
>>>>> $echo 8080 > /proc
>>>>>
>>>>> #reset whole bitmap
>>>>> $echo > /proc
>>>> Yes. So something like that.
>>>>
>>>> I think I would use commas instead of spaces as that is more traditional.
>>
>> Why this is better than the current version?
>>
>> For the single port case, currently we use:
>>
>> echo +8080 > /xxxx #set
>> echo -8080 > /xxxx #clear
>>
>> Now we will use:
>>
>> echo 8080 > /xxxx #set
>> echo 8080 > /xxxx #clear
> 
> No.
> 
>> I don't think the latter is better...
>>
>> For the multi-port case, yes, we should accept 'echo 8080,10000 >/xxxx'.
> 
> What I was envisioning was:
> 
> echo 8080 > /xxx # set the bitmap to 8080
> echo 8080,10000 > /xxx # add 10000 to the bitmap
> echo 8080 > /xxxx # remove 10000 from the bitmap.
> 
> That is when you set it you enter the entire set every time, treating
> the entire set as a single value.
> 

Oh, I see, this is ok.

But if we could support multi-port, that will be better, something like:

echo '8080,10000-11000' > /xxx #add port 8080 and port range 10000-11000

so that I don't have to construct a long string for all ports within
10000 and 11000.

Thanks.

^ permalink raw reply

* Re: [net-next PATCH v4 1/3] sysctl: refactor integer handling proc code
From: Cong Wang @ 2010-02-17 16:21 UTC (permalink / raw)
  To: Octavian Purdila
  Cc: David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers, Eric W. Biederman
In-Reply-To: <201002161544.33086.opurdila@ixiacom.com>

Octavian Purdila wrote:
> On Tuesday 16 February 2010 15:09:51 you wrote:
>> Octavian Purdila wrote:
>>> On Tuesday 16 February 2010 10:41:07 you wrote:
>>>>> +static int proc_skip_wspace(char __user **buf, size_t *size)
>>>>> +{
>>>>> +     char c;
>>>>> +
>>>>> +     while (*size) {
>>>>> +             if (get_user(c, *buf))
>>>>> +                     return -EFAULT;
>>>>> +             if (!isspace(c))
>>>>> +                     break;
>>>>> +             (*size)--; (*buf)++;
>>>>> +     }
>>>>> +
>>>>> +     return 0;
>>>>> +}
>>>> In lib/string.c we have skip_spaces(), I think we can use it
>>>> here instead of inventing another one.
>>> I'm afraid we can't, skip_spaces does not accept userspace buffers.
>> Well, you need to use copy_from_user() before call it.
>>
> 
> And how much would you copy? You need to either use a stack buffer and do a 
> loop copy or you would need to copy the whole userspace buffer which means we 
> need to allocate a kernel buffer. I think its much cleaner the way is currently 
> done.

Yeah, maybe just a personal preference. :-/


^ permalink raw reply

* Re: [net-next PATCH v4 3/3] net: reserve ports for applications using fixed port numbers
From: Cong Wang @ 2010-02-17 16:13 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Octavian Purdila, David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers, Neil Horman
In-Reply-To: <1266326425.3045.53.camel@edumazet-laptop>

Eric Dumazet wrote:
> Le mardi 16 février 2010 à 21:06 +0800, Cong Wang a écrit :
>> Octavian Purdila wrote:
>>> On Tuesday 16 February 2010 11:37:04 you wrote:
>>>>>  	BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
>>>>>
>>>>> +	sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
>>>>> +	if (!sysctl_local_reserved_ports)
>>>>> +		goto out;
>>>>> +
>>>> I think we should also consider the ports in ip_local_port_range,
>>>> since we can only reserve the ports in that range.
>>>>
>>> That is subject to changes at runtime, which means we will have to readjust 
>>> the bitmap at runtime which introduces the need for additional synchronization 
>>> operations which I would rather avoid. 
>> Why? As long as the bitmap is global, this will not be hard.
>>
>> Consider that if one user writes a port number which is beyond
>> the ip_local_port_range into ip_local_reserved_ports, we should
>> not accept this, because it doesn't make any sense. But with your
>> patch, we do.
> 
> I disagree with you. This is perfectly OK.
> 
> A port not being flagged in ip_local_reserved_ports doesnt mean it can
> be used for allocation.
> 
> If you want to really block ports from being used at boot, you could for
> example :
> 
> # temporarly reduce the ip_local_port_range
> echo "61000 61001" >/proc/sys/net/ipv4/ip_local_port_range
> # Build our bitmap (could be slow, if a remote database is read)
> for port in $LIST_RESERVED_PORT
> do
>   echo $port >/proc/sys/net/ipv4/ip_local_reserved_ports
> done
> echo "10000 61000" >/proc/sys/net/ipv4/ip_local_port_range
> 
> 

I don't think so, if you want to avoid race condition, you just need to
write the reserved ports before any networking application starts, IOW,
as early as possible during boot.

Thanks.

^ permalink raw reply

* Re: [net-next PATCH v4 0/3] net: reserve ports for applications using fixed port
From: Eric W. Biederman @ 2010-02-17 16:10 UTC (permalink / raw)
  To: Cong Wang
  Cc: Octavian Purdila, David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers, Eric Dumazet
In-Reply-To: <4B7C11D4.1080309@redhat.com>

Cong Wang <amwang@redhat.com> writes:

> Octavian Purdila wrote:
>> On Tuesday 16 February 2010 22:08:13 you wrote:
>>>> Something like bellow?
>>>>
>>>> # set bits 8080 and 1666
>>>> $echo 8080 1666-1666 > /proc
>>>>
>>>> #reset bit 1666
>>>> $echo 8080 > /proc
>>>>
>>>> #reset whole bitmap
>>>> $echo > /proc
>>> Yes. So something like that.
>>>
>>> I think I would use commas instead of spaces as that is more traditional.
>
>
> Why this is better than the current version?
>
> For the single port case, currently we use:
>
> echo +8080 > /xxxx #set
> echo -8080 > /xxxx #clear
>
> Now we will use:
>
> echo 8080 > /xxxx #set
> echo 8080 > /xxxx #clear

No.

> I don't think the latter is better...
>
> For the multi-port case, yes, we should accept 'echo 8080,10000 >/xxxx'.

What I was envisioning was:

echo 8080 > /xxx # set the bitmap to 8080
echo 8080,10000 > /xxx # add 10000 to the bitmap
echo 8080 > /xxxx # remove 10000 from the bitmap.

That is when you set it you enter the entire set every time, treating
the entire set as a single value.

Eric

^ permalink raw reply

* Re: [net-next PATCH v4 3/3] net: reserve ports for applications using fixed port numbers
From: Cong Wang @ 2010-02-17 16:07 UTC (permalink / raw)
  To: Octavian Purdila
  Cc: David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers, Neil Horman, Eric Dumazet
In-Reply-To: <201002161625.22495.opurdila@ixiacom.com>

Octavian Purdila wrote:
> On Tuesday 16 February 2010 15:06:26 you wrote:
>> Octavian Purdila wrote:
>>> On Tuesday 16 February 2010 11:37:04 you wrote:
>>>>>  	BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
>>>>>
>>>>> +	sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
>>>>> +	if (!sysctl_local_reserved_ports)
>>>>> +		goto out;
>>>>> +
>>>> I think we should also consider the ports in ip_local_port_range,
>>>> since we can only reserve the ports in that range.
>>> That is subject to changes at runtime, which means we will have to
>>> readjust the bitmap at runtime which introduces the need for additional
>>> synchronization operations which I would rather avoid.
>> Why? As long as the bitmap is global, this will not be hard.
>>
> 
> For the more important point see bellow, but with regard to reallocation, this 
> means we need to at least use rcu_read_lock() in the fast path to avoid races 
> between freeing the old bitmap and doing a read in progress. 
> 
> Granted, that is a light operation, but would it makes things so much more 
> complicated just so that we save one memory page (assuming the range is the 
> default [32000 64000] one).


Why not just allocate the bitmap for all ports? 65535/8 bytes are
needed.

> 
>> Consider that if one user writes a port number which is beyond
>> the ip_local_port_range into ip_local_reserved_ports, we should
>> not accept this, because it doesn't make any sense. But with your
>> patch, we do.
>>
> 
> I think it should be allowed. I see ip_local_reserved_ports and ip_local_range 
> as independent settings that can be change at any time.


According to the original purpose, they are not.

> 
> That way I can flag port 8080 even if the current range is [32000, 64000] and 
> then later I can expand the range to [1024, 64000] without loosing the 8080 
> reservation.

Then its meaning is changed, bind(0) will never have chance to get 8080,
thus reserving 8080 for this purpose fails.

I want to always keep its original meaning, if the local_port_range goes
out, then local_reserved_port should be empty at the same time, you have
to reset it after changing local_port_range.

^ permalink raw reply

* Re: [net-next PATCH v4 0/3] net: reserve ports for applications using fixed port
From: Cong Wang @ 2010-02-17 15:57 UTC (permalink / raw)
  To: Octavian Purdila
  Cc: Eric W. Biederman, David Miller, Linux Kernel Network Developers,
	Linux Kernel Developers, Eric Dumazet
In-Reply-To: <201002162322.13101.opurdila@ixiacom.com>

Octavian Purdila wrote:
> On Tuesday 16 February 2010 22:08:13 you wrote:
>>> Something like bellow?
>>>
>>> # set bits 8080 and 1666
>>> $echo 8080 1666-1666 > /proc
>>>
>>> #reset bit 1666
>>> $echo 8080 > /proc
>>>
>>> #reset whole bitmap
>>> $echo > /proc
>> Yes. So something like that.
>>
>> I think I would use commas instead of spaces as that is more traditional.


Why this is better than the current version?

For the single port case, currently we use:

echo +8080 > /xxxx #set
echo -8080 > /xxxx #clear

Now we will use:

echo 8080 > /xxxx #set
echo 8080 > /xxxx #clear

I don't think the latter is better...

For the multi-port case, yes, we should accept 'echo 8080,10000 >/xxxx'.


>>
> 
> OK, I was trying to reuse the existing skip whitespace code :) but if you 
> think its cleaner with commas I can do that.
> 
>>> Note that this new proc entry will work in conjunction with the existing
>>> ip_local_port_range option, so the default bitmap can (and should be)
>>> empty.

Yes, we don't know which ports the user wants to reserve.


>> Do we want userspace to see this implementation detail? Two data structures
>>  doing the almost the same thing could get confusing in a hurry.  It feels
>>  like a recipe for changing one and not the other and then running around
>>  trying to figure out why the change did not work.
>>
> 
> Yes, I believe we want to have reserved_ports contain just those special ports 
> that the user wants to reserve. After all we add this entry for this specific 
> purpose. 
> 

This is why I insist we should make sure all ports accepted by
ip_local_reserved_ports must be in ip_local_port_range.

^ permalink raw reply

* Re: [net-next-2.6 PATCH v2 3/3] fs_enet: add FEC TX buffer alignment workaround for MPC5121
From: Eric Dumazet @ 2010-02-17 15:17 UTC (permalink / raw)
  To: Anatolij Gustschin
  Cc: netdev, linuxppc-dev, David S. Miller, Grant Likely,
	Detlev Zundel, Wolfgang Denk, John Rigby, Piotr Ziecik
In-Reply-To: <1266418530-2727-4-git-send-email-agust@denx.de>

Le mercredi 17 février 2010 à 15:55 +0100, Anatolij Gustschin a écrit :
> MPC5121 FEC requeries 4-byte alignmnent for TX data buffers.
> This patch is a work around that copies misaligned tx packets
> to an aligned skb before sending.
> 
> Signed-off-by: John Rigby <jcrigby@gmail.com>
> Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
>  drivers/net/fs_enet/fs_enet-main.c |   44 ++++++++++++++++++++++++++++++++++++
>  1 files changed, 44 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
> index 4297021..166a89d 100644
> --- a/drivers/net/fs_enet/fs_enet-main.c
> +++ b/drivers/net/fs_enet/fs_enet-main.c
> @@ -580,6 +580,37 @@ void fs_cleanup_bds(struct net_device *dev)
>  
>  /**********************************************************************************/
>  
> +#ifdef CONFIG_FS_ENET_MPC5121_FEC
> +/*
> + * MPC5121 FEC requeries 4-byte alignment for TX data buffer!
> + */
> +static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
> +					       struct sk_buff *skb)
> +{
> +	struct sk_buff *new_skb;
> +	struct fs_enet_private *fep = netdev_priv(dev);
> +
> +	/* Alloc new skb */
> +	new_skb = dev_alloc_skb(ENET_RX_FRSIZE + 4);


ENET_RX_FRSIZE looks strange in TX path

Why not using skb->len + 4 instead of ENET_RX_FRSIZE + 4 ?


> +	if (!new_skb) {
> +		dev_warn(fep->dev, "Memory squeeze, dropping tx packet.\n");

I am just wondering if this is ratelimited ?

> +		return NULL;
> +	}
> +
> +	/* Make sure new skb is properly aligned */
> +	skb_align(new_skb, 4);

> +
> +	/* Copy data to new skb ... */
> +	skb_copy_from_linear_data(skb, new_skb->data, skb->len);
> +	skb_put(new_skb, skb->len);
> +
> +	/* ... and free an old one */
> +	dev_kfree_skb_any(skb);
> +
> +	return new_skb;
> +}
> +#endif
> +
>  static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  {
>  	struct fs_enet_private *fep = netdev_priv(dev);
> @@ -588,6 +619,19 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  	u16 sc;
>  	unsigned long flags;
>  
> +#ifdef CONFIG_FS_ENET_MPC5121_FEC
> +	if (((unsigned long)skb->data) & 0x3) {
> +		skb = tx_skb_align_workaround(dev, skb);
> +		if (!skb) {
> +			/*
> +			 * We have lost packet due to memory allocation error
> +			 * in tx_skb_align_workaround(). Hopefully original
> +			 * skb is still valid, so try transmit it later.
> +			 */

Could you define 'try to transmit later' ?
Who is responsible to trigger this event ?


> +			return NETDEV_TX_BUSY;
> +		}
> +	}
> +#endif
>  	spin_lock_irqsave(&fep->tx_lock, flags);
>  
>  	/*



^ permalink raw reply

* Re: [net-next-2.6 PATCH v2 3/3] fs_enet: add FEC TX buffer alignment workaround for MPC5121
From: Grant Likely @ 2010-02-17 15:13 UTC (permalink / raw)
  To: Anatolij Gustschin
  Cc: netdev, linuxppc-dev, David S. Miller, Detlev Zundel,
	Wolfgang Denk, John Rigby, Piotr Ziecik
In-Reply-To: <1266418530-2727-4-git-send-email-agust@denx.de>

On Wed, Feb 17, 2010 at 7:55 AM, Anatolij Gustschin <agust@denx.de> wrote:
> MPC5121 FEC requeries 4-byte alignmnent for TX data buffers.
> This patch is a work around that copies misaligned tx packets
> to an aligned skb before sending.
>
> Signed-off-by: John Rigby <jcrigby@gmail.com>
> Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
>  drivers/net/fs_enet/fs_enet-main.c |   44 ++++++++++++++++++++++++++++++++++++
>  1 files changed, 44 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
> index 4297021..166a89d 100644
> --- a/drivers/net/fs_enet/fs_enet-main.c
> +++ b/drivers/net/fs_enet/fs_enet-main.c
> @@ -580,6 +580,37 @@ void fs_cleanup_bds(struct net_device *dev)
>
>  /**********************************************************************************/
>
> +#ifdef CONFIG_FS_ENET_MPC5121_FEC
> +/*
> + * MPC5121 FEC requeries 4-byte alignment for TX data buffer!
> + */
> +static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
> +                                              struct sk_buff *skb)
> +{
> +       struct sk_buff *new_skb;
> +       struct fs_enet_private *fep = netdev_priv(dev);
> +
> +       /* Alloc new skb */
> +       new_skb = dev_alloc_skb(ENET_RX_FRSIZE + 4);
> +       if (!new_skb) {
> +               dev_warn(fep->dev, "Memory squeeze, dropping tx packet.\n");
> +               return NULL;
> +       }
> +
> +       /* Make sure new skb is properly aligned */
> +       skb_align(new_skb, 4);
> +
> +       /* Copy data to new skb ... */
> +       skb_copy_from_linear_data(skb, new_skb->data, skb->len);
> +       skb_put(new_skb, skb->len);
> +
> +       /* ... and free an old one */
> +       dev_kfree_skb_any(skb);
> +
> +       return new_skb;
> +}
> +#endif
> +
>  static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> @@ -588,6 +619,19 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
>        u16 sc;
>        unsigned long flags;
>
> +#ifdef CONFIG_FS_ENET_MPC5121_FEC
> +       if (((unsigned long)skb->data) & 0x3) {
> +               skb = tx_skb_align_workaround(dev, skb);
> +               if (!skb) {
> +                       /*
> +                        * We have lost packet due to memory allocation error
> +                        * in tx_skb_align_workaround(). Hopefully original
> +                        * skb is still valid, so try transmit it later.
> +                        */
> +                       return NETDEV_TX_BUSY;
> +               }
> +       }
> +#endif

Instead of
>        spin_lock_irqsave(&fep->tx_lock, flags);
>
>        /*
> --
> 1.6.3.3
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply

* Re: [net-next-2.6 PATCH v2 2/3] fs_enet: Add support for MPC512x to fs_enet driver
From: Grant Likely @ 2010-02-17 15:11 UTC (permalink / raw)
  To: Anatolij Gustschin
  Cc: Wolfgang Denk, Detlev Zundel, netdev, linuxppc-dev,
	David S. Miller, Piotr Ziecik
In-Reply-To: <1266418530-2727-3-git-send-email-agust@denx.de>

On Wed, Feb 17, 2010 at 7:55 AM, Anatolij Gustschin <agust@denx.de> wrote:
> Extend the fs_enet driver to support MPC512x FEC.
> Enable it with CONFIG_FS_ENET_MPC5121_FEC option.
>
> Signed-off-by: John Rigby <jcrigby@gmail.com>
> Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>

Looks sane to me.

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
>  drivers/net/fs_enet/Kconfig        |   10 +++++--
>  drivers/net/fs_enet/fs_enet-main.c |    7 +++++
>  drivers/net/fs_enet/fs_enet.h      |   49 +++++++++++++++++++++++++++++++++++-
>  drivers/net/fs_enet/mac-fec.c      |   46 ++++++++++++++++++++++-----------
>  drivers/net/fs_enet/mii-fec.c      |    4 +-
>  5 files changed, 95 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/fs_enet/Kconfig b/drivers/net/fs_enet/Kconfig
> index 562ea68..fc073b5 100644
> --- a/drivers/net/fs_enet/Kconfig
> +++ b/drivers/net/fs_enet/Kconfig
> @@ -1,9 +1,13 @@
>  config FS_ENET
>        tristate "Freescale Ethernet Driver"
> -       depends on CPM1 || CPM2
> +       depends on CPM1 || CPM2 || PPC_MPC512x
>        select MII
>        select PHYLIB
>
> +config FS_ENET_MPC5121_FEC
> +       def_bool y if (FS_ENET && PPC_MPC512x)
> +       select FS_ENET_HAS_FEC
> +
>  config FS_ENET_HAS_SCC
>        bool "Chip has an SCC usable for ethernet"
>        depends on FS_ENET && (CPM1 || CPM2)
> @@ -16,13 +20,13 @@ config FS_ENET_HAS_FCC
>
>  config FS_ENET_HAS_FEC
>        bool "Chip has an FEC usable for ethernet"
> -       depends on FS_ENET && CPM1
> +       depends on FS_ENET && (CPM1 || FS_ENET_MPC5121_FEC)
>        select FS_ENET_MDIO_FEC
>        default y
>
>  config FS_ENET_MDIO_FEC
>        tristate "MDIO driver for FEC"
> -       depends on FS_ENET && CPM1
> +       depends on FS_ENET && (CPM1 || FS_ENET_MPC5121_FEC)
>
>  config FS_ENET_MDIO_FCC
>        tristate "MDIO driver for FCC"
> diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
> index c34a7e0..4297021 100644
> --- a/drivers/net/fs_enet/fs_enet-main.c
> +++ b/drivers/net/fs_enet/fs_enet-main.c
> @@ -1094,11 +1094,18 @@ static struct of_device_id fs_enet_match[] = {
>        },
>  #endif
>  #ifdef CONFIG_FS_ENET_HAS_FEC
> +#ifdef CONFIG_FS_ENET_MPC5121_FEC
> +       {
> +               .compatible = "fsl,mpc5121-fec",
> +               .data = (void *)&fs_fec_ops,
> +       },
> +#else
>        {
>                .compatible = "fsl,pq1-fec-enet",
>                .data = (void *)&fs_fec_ops,
>        },
>  #endif
> +#endif
>        {}
>  };
>  MODULE_DEVICE_TABLE(of, fs_enet_match);
> diff --git a/drivers/net/fs_enet/fs_enet.h b/drivers/net/fs_enet/fs_enet.h
> index ef01e09..1ece4b1 100644
> --- a/drivers/net/fs_enet/fs_enet.h
> +++ b/drivers/net/fs_enet/fs_enet.h
> @@ -13,9 +13,56 @@
>
>  #ifdef CONFIG_CPM1
>  #include <asm/cpm1.h>
> +#endif
> +
> +#if defined(CONFIG_FS_ENET_HAS_FEC)
> +#include <asm/cpm.h>
> +
> +#if defined(CONFIG_FS_ENET_MPC5121_FEC)
> +/* MPC5121 FEC has different register layout */
> +struct fec {
> +       u32 fec_reserved0;
> +       u32 fec_ievent;                 /* Interrupt event reg */
> +       u32 fec_imask;                  /* Interrupt mask reg */
> +       u32 fec_reserved1;
> +       u32 fec_r_des_active;           /* Receive descriptor reg */
> +       u32 fec_x_des_active;           /* Transmit descriptor reg */
> +       u32 fec_reserved2[3];
> +       u32 fec_ecntrl;                 /* Ethernet control reg */
> +       u32 fec_reserved3[6];
> +       u32 fec_mii_data;               /* MII manage frame reg */
> +       u32 fec_mii_speed;              /* MII speed control reg */
> +       u32 fec_reserved4[7];
> +       u32 fec_mib_ctrlstat;           /* MIB control/status reg */
> +       u32 fec_reserved5[7];
> +       u32 fec_r_cntrl;                /* Receive control reg */
> +       u32 fec_reserved6[15];
> +       u32 fec_x_cntrl;                /* Transmit Control reg */
> +       u32 fec_reserved7[7];
> +       u32 fec_addr_low;               /* Low 32bits MAC address */
> +       u32 fec_addr_high;              /* High 16bits MAC address */
> +       u32 fec_opd;                    /* Opcode + Pause duration */
> +       u32 fec_reserved8[10];
> +       u32 fec_hash_table_high;        /* High 32bits hash table */
> +       u32 fec_hash_table_low;         /* Low 32bits hash table */
> +       u32 fec_grp_hash_table_high;    /* High 32bits hash table */
> +       u32 fec_grp_hash_table_low;     /* Low 32bits hash table */
> +       u32 fec_reserved9[7];
> +       u32 fec_x_wmrk;                 /* FIFO transmit water mark */
> +       u32 fec_reserved10;
> +       u32 fec_r_bound;                /* FIFO receive bound reg */
> +       u32 fec_r_fstart;               /* FIFO receive start reg */
> +       u32 fec_reserved11[11];
> +       u32 fec_r_des_start;            /* Receive descriptor ring */
> +       u32 fec_x_des_start;            /* Transmit descriptor ring */
> +       u32 fec_r_buff_size;            /* Maximum receive buff size */
> +       u32 fec_reserved12[26];
> +       u32 fec_dma_control;            /* DMA Endian and other ctrl */
> +};
> +#endif
>
>  struct fec_info {
> -       fec_t __iomem *fecp;
> +       struct fec __iomem *fecp;
>        u32 mii_speed;
>  };
>  #endif
> diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
> index 7047813..c9657da 100644
> --- a/drivers/net/fs_enet/mac-fec.c
> +++ b/drivers/net/fs_enet/mac-fec.c
> @@ -80,7 +80,7 @@
>  */
>  #define FEC_RESET_DELAY                50
>
> -static int whack_reset(fec_t __iomem *fecp)
> +static int whack_reset(struct fec __iomem *fecp)
>  {
>        int i;
>
> @@ -168,7 +168,7 @@ static void cleanup_data(struct net_device *dev)
>  static void set_promiscuous_mode(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        FS(fecp, r_cntrl, FEC_RCNTRL_PROM);
>  }
> @@ -216,7 +216,7 @@ static void set_multicast_one(struct net_device *dev, const u8 *mac)
>  static void set_multicast_finish(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        /* if all multi or too many multicasts; just enable all */
>        if ((dev->flags & IFF_ALLMULTI) != 0 ||
> @@ -246,7 +246,7 @@ static void set_multicast_list(struct net_device *dev)
>  static void restart(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>        const struct fs_platform_info *fpi = fep->fpi;
>        dma_addr_t rx_bd_base_phys, tx_bd_base_phys;
>        int r;
> @@ -280,7 +280,11 @@ static void restart(struct net_device *dev)
>         * Set maximum receive buffer size.
>         */
>        FW(fecp, r_buff_size, PKT_MAXBLR_SIZE);
> +#ifdef CONFIG_FS_ENET_MPC5121_FEC
> +       FW(fecp, r_cntrl, PKT_MAXBUF_SIZE << 16);
> +#else
>        FW(fecp, r_hash, PKT_MAXBUF_SIZE);
> +#endif
>
>        /* get physical address */
>        rx_bd_base_phys = fep->ring_mem_addr;
> @@ -297,7 +301,11 @@ static void restart(struct net_device *dev)
>        /*
>         * Enable big endian and don't care about SDMA FC.
>         */
> +#ifdef CONFIG_FS_ENET_MPC5121_FEC
> +       FS(fecp, dma_control, 0xC0000000);
> +#else
>        FW(fecp, fun_code, 0x78000000);
> +#endif
>
>        /*
>         * Set MII speed.
> @@ -308,9 +316,17 @@ static void restart(struct net_device *dev)
>         * Clear any outstanding interrupt.
>         */
>        FW(fecp, ievent, 0xffc0);
> +#ifndef CONFIG_FS_ENET_MPC5121_FEC
>        FW(fecp, ivec, (virq_to_hw(fep->interrupt) / 2) << 29);
>
>        FW(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */
> +#else
> +       /*
> +        * Only set MII mode - do not touch maximum frame length
> +        * configured before.
> +        */
> +       FS(fecp, r_cntrl, FEC_RCNTRL_MII_MODE);
> +#endif
>        /*
>         * adjust to duplex mode
>         */
> @@ -339,7 +355,7 @@ static void stop(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
>        const struct fs_platform_info *fpi = fep->fpi;
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        struct fec_info* feci= fep->phydev->bus->priv;
>
> @@ -375,7 +391,7 @@ static void stop(struct net_device *dev)
>  static void napi_clear_rx_event(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        FW(fecp, ievent, FEC_NAPI_RX_EVENT_MSK);
>  }
> @@ -383,7 +399,7 @@ static void napi_clear_rx_event(struct net_device *dev)
>  static void napi_enable_rx(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        FS(fecp, imask, FEC_NAPI_RX_EVENT_MSK);
>  }
> @@ -391,7 +407,7 @@ static void napi_enable_rx(struct net_device *dev)
>  static void napi_disable_rx(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        FC(fecp, imask, FEC_NAPI_RX_EVENT_MSK);
>  }
> @@ -399,7 +415,7 @@ static void napi_disable_rx(struct net_device *dev)
>  static void rx_bd_done(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        FW(fecp, r_des_active, 0x01000000);
>  }
> @@ -407,7 +423,7 @@ static void rx_bd_done(struct net_device *dev)
>  static void tx_kickstart(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        FW(fecp, x_des_active, 0x01000000);
>  }
> @@ -415,7 +431,7 @@ static void tx_kickstart(struct net_device *dev)
>  static u32 get_int_events(struct net_device *dev)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        return FR(fecp, ievent) & FR(fecp, imask);
>  }
> @@ -423,7 +439,7 @@ static u32 get_int_events(struct net_device *dev)
>  static void clear_int_events(struct net_device *dev, u32 int_events)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
> -       fec_t __iomem *fecp = fep->fec.fecp;
> +       struct fec __iomem *fecp = fep->fec.fecp;
>
>        FW(fecp, ievent, int_events);
>  }
> @@ -439,17 +455,17 @@ static int get_regs(struct net_device *dev, void *p, int *sizep)
>  {
>        struct fs_enet_private *fep = netdev_priv(dev);
>
> -       if (*sizep < sizeof(fec_t))
> +       if (*sizep < sizeof(struct fec))
>                return -EINVAL;
>
> -       memcpy_fromio(p, fep->fec.fecp, sizeof(fec_t));
> +       memcpy_fromio(p, fep->fec.fecp, sizeof(struct fec));
>
>        return 0;
>  }
>
>  static int get_regs_len(struct net_device *dev)
>  {
> -       return sizeof(fec_t);
> +       return sizeof(struct fec);
>  }
>
>  static void tx_restart(struct net_device *dev)
> diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c
> index 96eba42..5944b65 100644
> --- a/drivers/net/fs_enet/mii-fec.c
> +++ b/drivers/net/fs_enet/mii-fec.c
> @@ -52,7 +52,7 @@
>  static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)
>  {
>        struct fec_info* fec = bus->priv;
> -       fec_t __iomem *fecp = fec->fecp;
> +       struct fec __iomem *fecp = fec->fecp;
>        int i, ret = -1;
>
>        BUG_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
> @@ -75,7 +75,7 @@ static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)
>  static int fs_enet_fec_mii_write(struct mii_bus *bus, int phy_id, int location, u16 val)
>  {
>        struct fec_info* fec = bus->priv;
> -       fec_t __iomem *fecp = fec->fecp;
> +       struct fec __iomem *fecp = fec->fecp;
>        int i;
>
>        /* this must never happen */
> --
> 1.6.3.3
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply

* [net-next-2.6 PATCH v2 3/3] fs_enet: add FEC TX buffer alignment workaround for MPC5121
From: Anatolij Gustschin @ 2010-02-17 14:55 UTC (permalink / raw)
  To: netdev
  Cc: linuxppc-dev, David S. Miller, Grant Likely, Detlev Zundel,
	Wolfgang Denk, John Rigby, Anatolij Gustschin, Piotr Ziecik
In-Reply-To: <1266418530-2727-3-git-send-email-agust@denx.de>

MPC5121 FEC requeries 4-byte alignmnent for TX data buffers.
This patch is a work around that copies misaligned tx packets
to an aligned skb before sending.

Signed-off-by: John Rigby <jcrigby@gmail.com>
Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
Signed-off-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 drivers/net/fs_enet/fs_enet-main.c |   44 ++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 4297021..166a89d 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -580,6 +580,37 @@ void fs_cleanup_bds(struct net_device *dev)
 
 /**********************************************************************************/
 
+#ifdef CONFIG_FS_ENET_MPC5121_FEC
+/*
+ * MPC5121 FEC requeries 4-byte alignment for TX data buffer!
+ */
+static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
+					       struct sk_buff *skb)
+{
+	struct sk_buff *new_skb;
+	struct fs_enet_private *fep = netdev_priv(dev);
+
+	/* Alloc new skb */
+	new_skb = dev_alloc_skb(ENET_RX_FRSIZE + 4);
+	if (!new_skb) {
+		dev_warn(fep->dev, "Memory squeeze, dropping tx packet.\n");
+		return NULL;
+	}
+
+	/* Make sure new skb is properly aligned */
+	skb_align(new_skb, 4);
+
+	/* Copy data to new skb ... */
+	skb_copy_from_linear_data(skb, new_skb->data, skb->len);
+	skb_put(new_skb, skb->len);
+
+	/* ... and free an old one */
+	dev_kfree_skb_any(skb);
+
+	return new_skb;
+}
+#endif
+
 static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
@@ -588,6 +619,19 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	u16 sc;
 	unsigned long flags;
 
+#ifdef CONFIG_FS_ENET_MPC5121_FEC
+	if (((unsigned long)skb->data) & 0x3) {
+		skb = tx_skb_align_workaround(dev, skb);
+		if (!skb) {
+			/*
+			 * We have lost packet due to memory allocation error
+			 * in tx_skb_align_workaround(). Hopefully original
+			 * skb is still valid, so try transmit it later.
+			 */
+			return NETDEV_TX_BUSY;
+		}
+	}
+#endif
 	spin_lock_irqsave(&fep->tx_lock, flags);
 
 	/*
-- 
1.6.3.3


^ permalink raw reply related

* [net-next-2.6 PATCH v2 2/3] fs_enet: Add support for MPC512x to fs_enet driver
From: Anatolij Gustschin @ 2010-02-17 14:55 UTC (permalink / raw)
  To: netdev
  Cc: linuxppc-dev, David S. Miller, Grant Likely, Detlev Zundel,
	Wolfgang Denk, John Rigby, Anatolij Gustschin, Piotr Ziecik
In-Reply-To: <1266418530-2727-2-git-send-email-agust@denx.de>

Extend the fs_enet driver to support MPC512x FEC.
Enable it with CONFIG_FS_ENET_MPC5121_FEC option.

Signed-off-by: John Rigby <jcrigby@gmail.com>
Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
Signed-off-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 drivers/net/fs_enet/Kconfig        |   10 +++++--
 drivers/net/fs_enet/fs_enet-main.c |    7 +++++
 drivers/net/fs_enet/fs_enet.h      |   49 +++++++++++++++++++++++++++++++++++-
 drivers/net/fs_enet/mac-fec.c      |   46 ++++++++++++++++++++++-----------
 drivers/net/fs_enet/mii-fec.c      |    4 +-
 5 files changed, 95 insertions(+), 21 deletions(-)

diff --git a/drivers/net/fs_enet/Kconfig b/drivers/net/fs_enet/Kconfig
index 562ea68..fc073b5 100644
--- a/drivers/net/fs_enet/Kconfig
+++ b/drivers/net/fs_enet/Kconfig
@@ -1,9 +1,13 @@
 config FS_ENET
        tristate "Freescale Ethernet Driver"
-       depends on CPM1 || CPM2
+       depends on CPM1 || CPM2 || PPC_MPC512x
        select MII
        select PHYLIB
 
+config FS_ENET_MPC5121_FEC
+	def_bool y if (FS_ENET && PPC_MPC512x)
+	select FS_ENET_HAS_FEC
+
 config FS_ENET_HAS_SCC
 	bool "Chip has an SCC usable for ethernet"
 	depends on FS_ENET && (CPM1 || CPM2)
@@ -16,13 +20,13 @@ config FS_ENET_HAS_FCC
 
 config FS_ENET_HAS_FEC
 	bool "Chip has an FEC usable for ethernet"
-	depends on FS_ENET && CPM1
+	depends on FS_ENET && (CPM1 || FS_ENET_MPC5121_FEC)
 	select FS_ENET_MDIO_FEC
 	default y
 
 config FS_ENET_MDIO_FEC
 	tristate "MDIO driver for FEC"
-	depends on FS_ENET && CPM1
+	depends on FS_ENET && (CPM1 || FS_ENET_MPC5121_FEC)
 
 config FS_ENET_MDIO_FCC
 	tristate "MDIO driver for FCC"
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index c34a7e0..4297021 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -1094,11 +1094,18 @@ static struct of_device_id fs_enet_match[] = {
 	},
 #endif
 #ifdef CONFIG_FS_ENET_HAS_FEC
+#ifdef CONFIG_FS_ENET_MPC5121_FEC
+	{
+		.compatible = "fsl,mpc5121-fec",
+		.data = (void *)&fs_fec_ops,
+	},
+#else
 	{
 		.compatible = "fsl,pq1-fec-enet",
 		.data = (void *)&fs_fec_ops,
 	},
 #endif
+#endif
 	{}
 };
 MODULE_DEVICE_TABLE(of, fs_enet_match);
diff --git a/drivers/net/fs_enet/fs_enet.h b/drivers/net/fs_enet/fs_enet.h
index ef01e09..1ece4b1 100644
--- a/drivers/net/fs_enet/fs_enet.h
+++ b/drivers/net/fs_enet/fs_enet.h
@@ -13,9 +13,56 @@
 
 #ifdef CONFIG_CPM1
 #include <asm/cpm1.h>
+#endif
+
+#if defined(CONFIG_FS_ENET_HAS_FEC)
+#include <asm/cpm.h>
+
+#if defined(CONFIG_FS_ENET_MPC5121_FEC)
+/* MPC5121 FEC has different register layout */
+struct fec {
+	u32 fec_reserved0;
+	u32 fec_ievent;			/* Interrupt event reg */
+	u32 fec_imask;			/* Interrupt mask reg */
+	u32 fec_reserved1;
+	u32 fec_r_des_active;		/* Receive descriptor reg */
+	u32 fec_x_des_active;		/* Transmit descriptor reg */
+	u32 fec_reserved2[3];
+	u32 fec_ecntrl;			/* Ethernet control reg */
+	u32 fec_reserved3[6];
+	u32 fec_mii_data;		/* MII manage frame reg */
+	u32 fec_mii_speed;		/* MII speed control reg */
+	u32 fec_reserved4[7];
+	u32 fec_mib_ctrlstat;		/* MIB control/status reg */
+	u32 fec_reserved5[7];
+	u32 fec_r_cntrl;		/* Receive control reg */
+	u32 fec_reserved6[15];
+	u32 fec_x_cntrl;		/* Transmit Control reg */
+	u32 fec_reserved7[7];
+	u32 fec_addr_low;		/* Low 32bits MAC address */
+	u32 fec_addr_high;		/* High 16bits MAC address */
+	u32 fec_opd;			/* Opcode + Pause duration */
+	u32 fec_reserved8[10];
+	u32 fec_hash_table_high;	/* High 32bits hash table */
+	u32 fec_hash_table_low;		/* Low 32bits hash table */
+	u32 fec_grp_hash_table_high;	/* High 32bits hash table */
+	u32 fec_grp_hash_table_low;	/* Low 32bits hash table */
+	u32 fec_reserved9[7];
+	u32 fec_x_wmrk;			/* FIFO transmit water mark */
+	u32 fec_reserved10;
+	u32 fec_r_bound;		/* FIFO receive bound reg */
+	u32 fec_r_fstart;		/* FIFO receive start reg */
+	u32 fec_reserved11[11];
+	u32 fec_r_des_start;		/* Receive descriptor ring */
+	u32 fec_x_des_start;		/* Transmit descriptor ring */
+	u32 fec_r_buff_size;		/* Maximum receive buff size */
+	u32 fec_reserved12[26];
+	u32 fec_dma_control;		/* DMA Endian and other ctrl */
+};
+#endif
 
 struct fec_info {
-	fec_t __iomem *fecp;
+	struct fec __iomem *fecp;
 	u32 mii_speed;
 };
 #endif
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index 7047813..c9657da 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -80,7 +80,7 @@
  */
 #define FEC_RESET_DELAY		50
 
-static int whack_reset(fec_t __iomem *fecp)
+static int whack_reset(struct fec __iomem *fecp)
 {
 	int i;
 
@@ -168,7 +168,7 @@ static void cleanup_data(struct net_device *dev)
 static void set_promiscuous_mode(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	FS(fecp, r_cntrl, FEC_RCNTRL_PROM);
 }
@@ -216,7 +216,7 @@ static void set_multicast_one(struct net_device *dev, const u8 *mac)
 static void set_multicast_finish(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	/* if all multi or too many multicasts; just enable all */
 	if ((dev->flags & IFF_ALLMULTI) != 0 ||
@@ -246,7 +246,7 @@ static void set_multicast_list(struct net_device *dev)
 static void restart(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 	const struct fs_platform_info *fpi = fep->fpi;
 	dma_addr_t rx_bd_base_phys, tx_bd_base_phys;
 	int r;
@@ -280,7 +280,11 @@ static void restart(struct net_device *dev)
 	 * Set maximum receive buffer size.
 	 */
 	FW(fecp, r_buff_size, PKT_MAXBLR_SIZE);
+#ifdef CONFIG_FS_ENET_MPC5121_FEC
+	FW(fecp, r_cntrl, PKT_MAXBUF_SIZE << 16);
+#else
 	FW(fecp, r_hash, PKT_MAXBUF_SIZE);
+#endif
 
 	/* get physical address */
 	rx_bd_base_phys = fep->ring_mem_addr;
@@ -297,7 +301,11 @@ static void restart(struct net_device *dev)
 	/*
 	 * Enable big endian and don't care about SDMA FC.
 	 */
+#ifdef CONFIG_FS_ENET_MPC5121_FEC
+	FS(fecp, dma_control, 0xC0000000);
+#else
 	FW(fecp, fun_code, 0x78000000);
+#endif
 
 	/*
 	 * Set MII speed.
@@ -308,9 +316,17 @@ static void restart(struct net_device *dev)
 	 * Clear any outstanding interrupt.
 	 */
 	FW(fecp, ievent, 0xffc0);
+#ifndef CONFIG_FS_ENET_MPC5121_FEC
 	FW(fecp, ivec, (virq_to_hw(fep->interrupt) / 2) << 29);
 
 	FW(fecp, r_cntrl, FEC_RCNTRL_MII_MODE);	/* MII enable */
+#else
+	/*
+	 * Only set MII mode - do not touch maximum frame length
+	 * configured before.
+	 */
+	FS(fecp, r_cntrl, FEC_RCNTRL_MII_MODE);
+#endif
 	/*
 	 * adjust to duplex mode
 	 */
@@ -339,7 +355,7 @@ static void stop(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
 	const struct fs_platform_info *fpi = fep->fpi;
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	struct fec_info* feci= fep->phydev->bus->priv;
 
@@ -375,7 +391,7 @@ static void stop(struct net_device *dev)
 static void napi_clear_rx_event(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	FW(fecp, ievent, FEC_NAPI_RX_EVENT_MSK);
 }
@@ -383,7 +399,7 @@ static void napi_clear_rx_event(struct net_device *dev)
 static void napi_enable_rx(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	FS(fecp, imask, FEC_NAPI_RX_EVENT_MSK);
 }
@@ -391,7 +407,7 @@ static void napi_enable_rx(struct net_device *dev)
 static void napi_disable_rx(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	FC(fecp, imask, FEC_NAPI_RX_EVENT_MSK);
 }
@@ -399,7 +415,7 @@ static void napi_disable_rx(struct net_device *dev)
 static void rx_bd_done(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	FW(fecp, r_des_active, 0x01000000);
 }
@@ -407,7 +423,7 @@ static void rx_bd_done(struct net_device *dev)
 static void tx_kickstart(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	FW(fecp, x_des_active, 0x01000000);
 }
@@ -415,7 +431,7 @@ static void tx_kickstart(struct net_device *dev)
 static u32 get_int_events(struct net_device *dev)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	return FR(fecp, ievent) & FR(fecp, imask);
 }
@@ -423,7 +439,7 @@ static u32 get_int_events(struct net_device *dev)
 static void clear_int_events(struct net_device *dev, u32 int_events)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
-	fec_t __iomem *fecp = fep->fec.fecp;
+	struct fec __iomem *fecp = fep->fec.fecp;
 
 	FW(fecp, ievent, int_events);
 }
@@ -439,17 +455,17 @@ static int get_regs(struct net_device *dev, void *p, int *sizep)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
 
-	if (*sizep < sizeof(fec_t))
+	if (*sizep < sizeof(struct fec))
 		return -EINVAL;
 
-	memcpy_fromio(p, fep->fec.fecp, sizeof(fec_t));
+	memcpy_fromio(p, fep->fec.fecp, sizeof(struct fec));
 
 	return 0;
 }
 
 static int get_regs_len(struct net_device *dev)
 {
-	return sizeof(fec_t);
+	return sizeof(struct fec);
 }
 
 static void tx_restart(struct net_device *dev)
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c
index 96eba42..5944b65 100644
--- a/drivers/net/fs_enet/mii-fec.c
+++ b/drivers/net/fs_enet/mii-fec.c
@@ -52,7 +52,7 @@
 static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)
 {
 	struct fec_info* fec = bus->priv;
-	fec_t __iomem *fecp = fec->fecp;
+	struct fec __iomem *fecp = fec->fecp;
 	int i, ret = -1;
 
 	BUG_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
@@ -75,7 +75,7 @@ static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)
 static int fs_enet_fec_mii_write(struct mii_bus *bus, int phy_id, int location, u16 val)
 {
 	struct fec_info* fec = bus->priv;
-	fec_t __iomem *fecp = fec->fecp;
+	struct fec __iomem *fecp = fec->fecp;
 	int i;
 
 	/* this must never happen */
-- 
1.6.3.3


^ permalink raw reply related

* [net-next-2.6 PATCH v2 1/3] fs_enet: use dev_xxx instead of printk
From: Anatolij Gustschin @ 2010-02-17 14:55 UTC (permalink / raw)
  To: netdev
  Cc: linuxppc-dev, David S. Miller, Grant Likely, Detlev Zundel,
	Wolfgang Denk, John Rigby, Anatolij Gustschin
In-Reply-To: <1266418530-2727-1-git-send-email-agust@denx.de>

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/net/fs_enet/fs_enet-main.c |   39 +++++++++++++----------------------
 drivers/net/fs_enet/mac-fcc.c      |    5 ++-
 drivers/net/fs_enet/mac-fec.c      |   12 ++++------
 drivers/net/fs_enet/mac-scc.c      |    9 +++----
 4 files changed, 27 insertions(+), 38 deletions(-)

diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index ec2f503..c34a7e0 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -108,9 +108,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
 		 * the last indicator should be set.
 		 */
 		if ((sc & BD_ENET_RX_LAST) == 0)
-			printk(KERN_WARNING DRV_MODULE_NAME
-			       ": %s rcv is not +last\n",
-			       dev->name);
+			dev_warn(fep->dev, "rcv is not +last\n");
 
 		/*
 		 * Check for errors.
@@ -178,9 +176,8 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
 				received++;
 				netif_receive_skb(skb);
 			} else {
-				printk(KERN_WARNING DRV_MODULE_NAME
-				       ": %s Memory squeeze, dropping packet.\n",
-				       dev->name);
+				dev_warn(fep->dev,
+					 "Memory squeeze, dropping packet.\n");
 				fep->stats.rx_dropped++;
 				skbn = skb;
 			}
@@ -242,9 +239,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
 		 * the last indicator should be set.
 		 */
 		if ((sc & BD_ENET_RX_LAST) == 0)
-			printk(KERN_WARNING DRV_MODULE_NAME
-			       ": %s rcv is not +last\n",
-			       dev->name);
+			dev_warn(fep->dev, "rcv is not +last\n");
 
 		/*
 		 * Check for errors.
@@ -313,9 +308,8 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
 				received++;
 				netif_rx(skb);
 			} else {
-				printk(KERN_WARNING DRV_MODULE_NAME
-				       ": %s Memory squeeze, dropping packet.\n",
-				       dev->name);
+				dev_warn(fep->dev,
+					 "Memory squeeze, dropping packet.\n");
 				fep->stats.rx_dropped++;
 				skbn = skb;
 			}
@@ -388,10 +382,10 @@ static void fs_enet_tx(struct net_device *dev)
 		} else
 			fep->stats.tx_packets++;
 
-		if (sc & BD_ENET_TX_READY)
-			printk(KERN_WARNING DRV_MODULE_NAME
-			       ": %s HEY! Enet xmit interrupt and TX_READY.\n",
-			       dev->name);
+		if (sc & BD_ENET_TX_READY) {
+			dev_warn(fep->dev,
+				 "HEY! Enet xmit interrupt and TX_READY.\n");
+		}
 
 		/*
 		 * Deferred means some collisions occurred during transmit,
@@ -511,9 +505,8 @@ void fs_init_bds(struct net_device *dev)
 	for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) {
 		skb = dev_alloc_skb(ENET_RX_FRSIZE);
 		if (skb == NULL) {
-			printk(KERN_WARNING DRV_MODULE_NAME
-			       ": %s Memory squeeze, unable to allocate skb\n",
-			       dev->name);
+			dev_warn(fep->dev,
+				 "Memory squeeze, unable to allocate skb\n");
 			break;
 		}
 		skb_align(skb, ENET_RX_ALIGN);
@@ -610,8 +603,7 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 		 * Ooops.  All transmit buffers are full.  Bail out.
 		 * This should not happen, since the tx queue should be stopped.
 		 */
-		printk(KERN_WARNING DRV_MODULE_NAME
-		       ": %s tx queue full!.\n", dev->name);
+		dev_warn(fep->dev, "tx queue full!.\n");
 		return NETDEV_TX_BUSY;
 	}
 
@@ -788,8 +780,7 @@ static int fs_enet_open(struct net_device *dev)
 	r = request_irq(fep->interrupt, fs_enet_interrupt, IRQF_SHARED,
 			"fs_enet-mac", dev);
 	if (r != 0) {
-		printk(KERN_ERR DRV_MODULE_NAME
-		       ": %s Could not allocate FS_ENET IRQ!", dev->name);
+		dev_err(fep->dev, "Could not allocate FS_ENET IRQ!");
 		if (fep->fpi->use_napi)
 			napi_disable(&fep->napi);
 		return -EINVAL;
@@ -1053,7 +1044,7 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
 	if (ret)
 		goto out_free_bd;
 
-	printk(KERN_INFO "%s: fs_enet: %pM\n", ndev->name, ndev->dev_addr);
+	pr_info("%s: fs_enet: %pM\n", ndev->name, ndev->dev_addr);
 
 	return 0;
 
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index 482f27d..504add3 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -476,8 +476,9 @@ static void clear_int_events(struct net_device *dev, u32 int_events)
 
 static void ev_error(struct net_device *dev, u32 int_events)
 {
-	printk(KERN_WARNING DRV_MODULE_NAME
-	       ": %s FS_ENET ERROR(s) 0x%x\n", dev->name, int_events);
+	struct fs_enet_private *fep = netdev_priv(dev);
+
+	dev_warn(fep->dev, "FS_ENET ERROR(s) 0x%x\n", int_events);
 }
 
 static int get_regs(struct net_device *dev, void *p, int *sizep)
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index ddf13ef..7047813 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -257,8 +257,7 @@ static void restart(struct net_device *dev)
 
 	r = whack_reset(fep->fec.fecp);
 	if (r != 0)
-		printk(KERN_ERR DRV_MODULE_NAME
-				": %s FEC Reset FAILED!\n", dev->name);
+		dev_err(fep->dev, "FEC Reset FAILED!\n");
 	/*
 	 * Set station address.
 	 */
@@ -355,9 +354,7 @@ static void stop(struct net_device *dev)
 		udelay(1);
 
 	if (i == FEC_RESET_DELAY)
-		printk(KERN_WARNING DRV_MODULE_NAME
-		       ": %s FEC timeout on graceful transmit stop\n",
-		       dev->name);
+		dev_warn(fep->dev, "FEC timeout on graceful transmit stop\n");
 	/*
 	 * Disable FEC. Let only MII interrupts.
 	 */
@@ -433,8 +430,9 @@ static void clear_int_events(struct net_device *dev, u32 int_events)
 
 static void ev_error(struct net_device *dev, u32 int_events)
 {
-	printk(KERN_WARNING DRV_MODULE_NAME
-	       ": %s FEC ERROR(s) 0x%x\n", dev->name, int_events);
+	struct fs_enet_private *fep = netdev_priv(dev);
+
+	dev_warn(fep->dev, "FEC ERROR(s) 0x%x\n", int_events);
 }
 
 static int get_regs(struct net_device *dev, void *p, int *sizep)
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index 141dbc9..ff467e4 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -367,9 +367,7 @@ static void stop(struct net_device *dev)
 		udelay(1);
 
 	if (i == SCC_RESET_DELAY)
-		printk(KERN_WARNING DRV_MODULE_NAME
-		       ": %s SCC timeout on graceful transmit stop\n",
-		       dev->name);
+		dev_warn(fep->dev, "SCC timeout on graceful transmit stop\n");
 
 	W16(sccp, scc_sccm, 0);
 	C32(sccp, scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT);
@@ -429,8 +427,9 @@ static void clear_int_events(struct net_device *dev, u32 int_events)
 
 static void ev_error(struct net_device *dev, u32 int_events)
 {
-	printk(KERN_WARNING DRV_MODULE_NAME
-	       ": %s SCC ERROR(s) 0x%x\n", dev->name, int_events);
+	struct fs_enet_private *fep = netdev_priv(dev);
+
+	dev_warn(fep->dev, "SCC ERROR(s) 0x%x\n", int_events);
 }
 
 static int get_regs(struct net_device *dev, void *p, int *sizep)
-- 
1.6.3.3


^ permalink raw reply related

* [net-next-2.6 PATCH v2 0/3] Support for MPC512x FEC
From: Anatolij Gustschin @ 2010-02-17 14:55 UTC (permalink / raw)
  To: netdev
  Cc: linuxppc-dev, David S. Miller, Grant Likely, Detlev Zundel,
	Wolfgang Denk, John Rigby, Anatolij Gustschin

These patches attempt to provide support for the Freescale MPC512x
FEC in the fs_enet driver. The first cleanup patch replaces printk
by dev_xxx. The second and third attemt to support MPC5121 FEC
in the FEC driver.

Changes since previous version:

 - don't attempt to provide runtime selection of
   MPC5121 FEC support in the driver since it doesn't
   make sence. Select MPC5121 FEC support at compile time.
 - fix tx buffer alignment workaround patch to align
   only misaligned buffers.

The patches are based on net-next-2.6 and has been
tested on the:
   - Freescale/STX "MPC5121ADS" board (board rev. 4) with
     a MPC5121e Rev. 2.
   - TQM860L and TQM855 boards.

Anatolij Gustschin (3):
  fs_enet: use dev_xxx instead of printk
  fs_enet: Add support for MPC512x to fs_enet driver
  fs_enet: add FEC TX buffer alignment workaround for MPC5121

 drivers/net/fs_enet/Kconfig        |   10 +++-
 drivers/net/fs_enet/fs_enet-main.c |   90 ++++++++++++++++++++++++++----------
 drivers/net/fs_enet/fs_enet.h      |   49 +++++++++++++++++++-
 drivers/net/fs_enet/mac-fcc.c      |    5 +-
 drivers/net/fs_enet/mac-fec.c      |   58 ++++++++++++++---------
 drivers/net/fs_enet/mac-scc.c      |    9 ++--
 drivers/net/fs_enet/mii-fec.c      |    4 +-
 7 files changed, 166 insertions(+), 59 deletions(-)


^ permalink raw reply

* Re: Recent change to net-next broke KVM bridging
From: Arnd Bergmann @ 2010-02-17 14:26 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David Miller, netdev
In-Reply-To: <20100216173658.519b6245@nehalam>

On Wednesday 17 February 2010, Stephen Hemminger wrote:
> Something in net-next tree broke bridging of virtual nets.
> My local VM's can no longer access external networks.

Is that using tun/tap devices to access the bridge or something else?
Do you know if an older net-next version on top of 2.6.33-rc was still
working?

The only patch I've seen in that area is 05c2828c7 "tun: export
underlying socket", but that seems harmless.

	Arnd

^ permalink raw reply

* Re: [PATCH 2/2] Staging: Octeon: Remove /proc/octeon_ethernet_stats
From: Ralf Baechle @ 2010-02-17 14:25 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, netdev, gregkh
In-Reply-To: <1266369933-1282-2-git-send-email-ddaney@caviumnetworks.com>

Thanks folks, queued for 2.6.23.

  Ralf

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox