[PATCH 3.10.y 1/2] ipv6: prevent fib6_run_gc() contention

2015-06-10 Thread Konstantin Khlebnikov
From: Michal Kubeček mkube...@suse.cz

commit 2ac3ac8f86f2fe065d746d9a9abaca867adec577 upstream

On a high-traffic router with many processors and many IPv6 dst
entries, soft lockup in fib6_run_gc() can occur when number of
entries reaches gc_thresh.

This happens because fib6_run_gc() uses fib6_gc_lock to allow
only one thread to run the garbage collector but ip6_dst_gc()
doesn't update net-ipv6.ip6_rt_last_gc until fib6_run_gc()
returns. On a system with many entries, this can take some time
so that in the meantime, other threads pass the tests in
ip6_dst_gc() (ip6_rt_last_gc is still not updated) and wait for
the lock. They then have to run the garbage collector one after
another which blocks them for quite long.

Resolve this by replacing special value ~0UL of expire parameter
to fib6_run_gc() by explicit force parameter to choose between
spin_lock_bh() and spin_trylock_bh() and call fib6_run_gc() with
force=false if gc_thresh is reached but not max_size.

Signed-off-by: Michal Kubecek mkube...@suse.cz
Signed-off-by: David S. Miller da...@davemloft.net
---
 include/net/ip6_fib.h |2 +-
 net/ipv6/ip6_fib.c|   19 ---
 net/ipv6/ndisc.c  |4 ++--
 net/ipv6/route.c  |4 ++--
 4 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 665e0cee59bd..5e661a979694 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -301,7 +301,7 @@ extern void inet6_rt_notify(int event, 
struct rt6_info *rt,
struct nl_info *info);
 
 extern voidfib6_run_gc(unsigned long expires,
-   struct net *net);
+   struct net *net, bool force);
 
 extern voidfib6_gc_cleanup(void);
 
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index ceeb9458bb60..0b5e9086322d 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1648,19 +1648,16 @@ static int fib6_age(struct rt6_info *rt, void *arg)
 
 static DEFINE_SPINLOCK(fib6_gc_lock);
 
-void fib6_run_gc(unsigned long expires, struct net *net)
+void fib6_run_gc(unsigned long expires, struct net *net, bool force)
 {
-   if (expires != ~0UL) {
+   if (force) {
spin_lock_bh(fib6_gc_lock);
-   gc_args.timeout = expires ? (int)expires :
-   net-ipv6.sysctl.ip6_rt_gc_interval;
-   } else {
-   if (!spin_trylock_bh(fib6_gc_lock)) {
-   mod_timer(net-ipv6.ip6_fib_timer, jiffies + HZ);
-   return;
-   }
-   gc_args.timeout = net-ipv6.sysctl.ip6_rt_gc_interval;
+   } else if (!spin_trylock_bh(fib6_gc_lock)) {
+   mod_timer(net-ipv6.ip6_fib_timer, jiffies + HZ);
+   return;
}
+   gc_args.timeout = expires ? (int)expires :
+ net-ipv6.sysctl.ip6_rt_gc_interval;
 
gc_args.more = icmp6_dst_gc();
 
@@ -1677,7 +1674,7 @@ void fib6_run_gc(unsigned long expires, struct net *net)
 
 static void fib6_gc_timer_cb(unsigned long arg)
 {
-   fib6_run_gc(0, (struct net *)arg);
+   fib6_run_gc(0, (struct net *)arg, true);
 }
 
 static int __net_init fib6_net_init(struct net *net)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 05f361338c2e..deedf7ddbc6e 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1584,7 +1584,7 @@ static int ndisc_netdev_event(struct notifier_block 
*this, unsigned long event,
switch (event) {
case NETDEV_CHANGEADDR:
neigh_changeaddr(nd_tbl, dev);
-   fib6_run_gc(~0UL, net);
+   fib6_run_gc(0, net, false);
idev = in6_dev_get(dev);
if (!idev)
break;
@@ -1594,7 +1594,7 @@ static int ndisc_netdev_event(struct notifier_block 
*this, unsigned long event,
break;
case NETDEV_DOWN:
neigh_ifdown(nd_tbl, dev);
-   fib6_run_gc(~0UL, net);
+   fib6_run_gc(0, net, false);
break;
case NETDEV_NOTIFY_PEERS:
ndisc_send_unsol_na(dev);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d94d224f7e68..bd83c90f970c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1349,7 +1349,7 @@ static int ip6_dst_gc(struct dst_ops *ops)
goto out;
 
net-ipv6.ip6_rt_gc_expire++;
-   fib6_run_gc(net-ipv6.ip6_rt_gc_expire, net);
+   fib6_run_gc(net-ipv6.ip6_rt_gc_expire, net, entries  rt_max_size);
net-ipv6.ip6_rt_last_gc = now;
entries = dst_entries_get_slow(ops);
if (entries  ops-gc_thresh)
@@ -2849,7 +2849,7 @@ int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write,
net = (struct net *)ctl-extra1;
delay = net-ipv6.sysctl.flush_delay;
proc_dointvec(ctl, write, buffer, lenp, ppos);
-   fib6_run_gc(delay = 0 

[PATCH 3.10.y 2/2] ipv6: update ip6_rt_last_gc every time GC is run

2015-06-10 Thread Konstantin Khlebnikov
From: Michal Kubeček mkube...@suse.cz

commit 49a18d86f66d33a20144ecb5a34bba0d1856b260 upstream

As pointed out by Eric Dumazet, net-ipv6.ip6_rt_last_gc should
hold the last time garbage collector was run so that we should
update it whenever fib6_run_gc() calls fib6_clean_all(), not only
if we got there from ip6_dst_gc().

Signed-off-by: Michal Kubecek mkube...@suse.cz
Signed-off-by: David S. Miller da...@davemloft.net
---
 net/ipv6/ip6_fib.c |6 +-
 net/ipv6/route.c   |4 +---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 0b5e9086322d..46458ee31939 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1650,6 +1650,8 @@ static DEFINE_SPINLOCK(fib6_gc_lock);
 
 void fib6_run_gc(unsigned long expires, struct net *net, bool force)
 {
+   unsigned long now;
+
if (force) {
spin_lock_bh(fib6_gc_lock);
} else if (!spin_trylock_bh(fib6_gc_lock)) {
@@ -1662,10 +1664,12 @@ void fib6_run_gc(unsigned long expires, struct net 
*net, bool force)
gc_args.more = icmp6_dst_gc();
 
fib6_clean_all(net, fib6_age, 0, NULL);
+   now = jiffies;
+   net-ipv6.ip6_rt_last_gc = now;
 
if (gc_args.more)
mod_timer(net-ipv6.ip6_fib_timer,
- round_jiffies(jiffies
+ round_jiffies(now
+ net-ipv6.sysctl.ip6_rt_gc_interval));
else
del_timer(net-ipv6.ip6_fib_timer);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index bd83c90f970c..6ebefd46f718 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1334,7 +1334,6 @@ static void icmp6_clean_all(int (*func)(struct rt6_info 
*rt, void *arg),
 
 static int ip6_dst_gc(struct dst_ops *ops)
 {
-   unsigned long now = jiffies;
struct net *net = container_of(ops, struct net, ipv6.ip6_dst_ops);
int rt_min_interval = net-ipv6.sysctl.ip6_rt_gc_min_interval;
int rt_max_size = net-ipv6.sysctl.ip6_rt_max_size;
@@ -1344,13 +1343,12 @@ static int ip6_dst_gc(struct dst_ops *ops)
int entries;
 
entries = dst_entries_get_fast(ops);
-   if (time_after(rt_last_gc + rt_min_interval, now) 
+   if (time_after(rt_last_gc + rt_min_interval, jiffies) 
entries = rt_max_size)
goto out;
 
net-ipv6.ip6_rt_gc_expire++;
fib6_run_gc(net-ipv6.ip6_rt_gc_expire, net, entries  rt_max_size);
-   net-ipv6.ip6_rt_last_gc = now;
entries = dst_entries_get_slow(ops);
if (entries  ops-gc_thresh)
net-ipv6.ip6_rt_gc_expire = rt_gc_timeout1;

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


[PATCH 3.10.y 0/2] ipv6: avoid soft lockups in fib6_run_gc()

2015-06-10 Thread Konstantin Khlebnikov
Two patches from 3.11 which are missing in 3.10.y

I've just seen livelock in 3.10.69+ where all cpus are stuck in fib6_run_gc()

4[2919865.977745] Call Trace:
4[2919865.977748]  IRQ 
4[2919865.977754]  [8163b87e] _raw_spin_lock_bh+0x1e/0x30
4[2919865.977759]  [815e4018] fib6_run_gc+0x28/0x100
4[2919865.977762]  [815dc64b] ip6_dst_gc+0xcb/0x110
4[2919865.977767]  [8153ead3] dst_alloc+0x163/0x180
4[2919865.90]  [815ddce4] ip6_rt_copy+0x44/0x350
4[2919865.93]  [815debc7] ip6_pol_route.isra.46+0x347/0x460
4[2919865.96]  [815ded3a] ip6_pol_route_output+0x2a/0x30
4[2919865.977781]  [81605061] fib6_rule_action+0xd1/0x200
4[2919865.977783]  [815ded10] ? ip6_pol_route_input+0x30/0x30
4[2919865.977788]  [81556b9d] ? pfifo_fast_enqueue+0x8d/0xa0
4[2919865.977791]  [815513e5] fib_rules_lookup+0xd5/0x150
4[2919865.977795]  [81605344] fib6_rule_lookup+0x44/0x80
4[2919865.977797]  [815ded10] ? ip6_pol_route_input+0x30/0x30
4[2919865.977800]  [815dce93] ip6_route_output+0x73/0xb0
4[2919865.977804]  [815cf4fb] ip6_dst_lookup_tail+0xdb/0xf0
4[2919865.977807]  [815cf6ed] ip6_dst_lookup_flow+0x3d/0xa0
4[2919865.977811]  [815fe4b0] inet6_csk_route_socket+0x160/0x200
4[2919865.977814]  [815fe622] inet6_csk_xmit+0x42/0xd0
4[2919865.977819]  [81588e6b] tcp_transmit_skb+0x42b/0x8a0
4[2919865.977823]  [81589376] tcp_xmit_probe_skb+0x96/0xb0
4[2919865.977826]  [8158bce9] tcp_write_wakeup+0x59/0x180
4[2919865.977830]  [8158c298] tcp_keepalive_timer+0x178/0x260
4[2919865.977833]  [8158cee6] ? tcp_write_timer+0x46/0x80
4[2919865.977836]  [8158c120] ? tcp_out_of_resources+0xc0/0xc0
4[2919865.977840]  [81064576] call_timer_fn+0x46/0x160
4[2919865.977842]  [8106517c] ? cascade+0x7c/0xa0
4[2919865.977845]  [81065e0d] run_timer_softirq+0x25d/0x290
4[2919865.977849]  [813104a4] ? timerqueue_add+0x64/0xb0
4[2919865.977852]  [8158c120] ? tcp_out_of_resources+0xc0/0xc0
4[2919865.977858]  [8109ba74] ? ktime_get+0x54/0xe0
4[2919865.977861]  [8105df58] __do_softirq+0xd8/0x270
4[2919865.977865]  [810a3b04] ? tick_program_event+0x24/0x30
4[2919865.977870]  [8107f385] ? hrtimer_interrupt+0x185/0x270
4[2919865.977874]  [8164581c] call_softirq+0x1c/0x30
4[2919865.977878]  [810154d5] do_softirq+0x65/0xa0
4[2919865.977881]  [8105e24e] irq_exit+0x8e/0xb0
4[2919865.977884]  [8164619e] smp_apic_timer_interrupt+0x6e/0x99
4[2919865.977887]  [8164505d] apic_timer_interrupt+0x6d/0x80

---

Michal Kubeček (2):
  ipv6: prevent fib6_run_gc() contention
  ipv6: update ip6_rt_last_gc every time GC is run


 include/net/ip6_fib.h |2 +-
 net/ipv6/ip6_fib.c|   25 +
 net/ipv6/ndisc.c  |4 ++--
 net/ipv6/route.c  |8 +++-
 4 files changed, 19 insertions(+), 20 deletions(-)

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


pull-request: mac80211-next 2015-06-10

2015-06-10 Thread Johannes Berg
Hi Dave,

For -next, I have another set of changes, mostly small fixes for there
and a few cleanups. Kalle and I also decided to put in a big API change
that I'd been planning for a while and that required modifying all the
drivers, for that I pulled in your net-next tree before (re-)applying
that patch. Therefore, you shouldn't run into any conflicts now; without
that at least the new mediatek driver wouldn't have built.

Let me know if there are any issues.

Thanks,
johannes

The following changes since commit c3eee1fb1d308564ada5f7ea57bc51efc6130b37:

  Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge 
(2015-06-09 20:23:52 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 
tags/mac80211-next-for-davem-2015-06-10

for you to fetch changes up to 5df03344c5639fdd848cb87553956df7276a8645:

  mac80211: convert HW flags to unsigned long bitmap (2015-06-10 13:48:42 +0200)


For this round we mostly have fixes:
 * mesh fixes from Alexis Green and Chun-Yeow Yeoh,
 * a documentation fix from Jakub Kicinski,
 * a missing channel release (from Michal Kazior),
 * a fix for a signal strength reporting bug (from Sara Sharon),
 * handle deauth while associating (myself),
 * don't report mangled TX SKB back to userspace for status (myself),
 * handle aggregation session timeouts properly in fast-xmit (myself)

However, there are also a few cleanups and one big change that
affects all drivers (and that required me to pull in your tree)
to change the mac80211 HW flags to use an unsigned long bitmap
so that we can extend them more easily - we're running out of
flags even with a cleanup to remove the two unused ones.


Alexis Green (3):
  mac80211: Fix incorrectly named last_hop_metric variable in 
mesh_rx_path_sel_frame
  mac80211: Always check rates and capabilities in mesh mode
  mac80211: Fix a case of incorrect metric used when forwarding a PREQ

Chun-Yeow Yeoh (1):
  mac80211: fix the beacon csa counter for mesh and ibss

Jakub Kicinski (1):
  mac80211: remove obsolete sentence from documentation

Johannes Berg (9):
  mac80211: act upon and report deauth while associating
  mac80211: move TX PN to public part of key struct
  mac80211: copy nl80211 mgmt TX SKB for status
  mac80211: stop using pointers as userspace cookies
  mac80211: remove short slot/short preamble incapable flags
  mac80211: rename single hw-scan flag to follow naming convention
  mac80211: handle aggregation session timeout on fast-xmit path
  Merge remote-tracking branch 'net-next/master' into mac80211-next
  mac80211: convert HW flags to unsigned long bitmap

Michal Kazior (1):
  mac80211: release channel on auth failure

Sara Sharon (1):
  mac80211: ignore invalid scan RSSI values

 drivers/net/wireless/adm8211.c |   8 +-
 drivers/net/wireless/at76c50x-usb.c|   4 +-
 drivers/net/wireless/ath/ar5523/ar5523.c   |   6 +-
 drivers/net/wireless/ath/ath10k/mac.c  |  34 ++--
 drivers/net/wireless/ath/ath5k/base.c  |  12 +-
 drivers/net/wireless/ath/ath9k/htc_drv_init.c  |  20 +--
 drivers/net/wireless/ath/ath9k/init.c  |  24 +--
 drivers/net/wireless/ath/carl9170/fw.c |   2 +-
 drivers/net/wireless/ath/carl9170/main.c   |  20 +--
 drivers/net/wireless/ath/wcn36xx/main.c|  12 +-
 drivers/net/wireless/ath/wcn36xx/smd.c |   4 +-
 drivers/net/wireless/b43/main.c|   4 +-
 drivers/net/wireless/b43legacy/main.c  |   5 +-
 .../net/wireless/brcm80211/brcmsmac/mac80211_if.c  |   7 +-
 drivers/net/wireless/cw1200/main.c |  16 +-
 drivers/net/wireless/iwlegacy/3945-mac.c   |   6 +-
 drivers/net/wireless/iwlegacy/4965-mac.c   |  12 +-
 drivers/net/wireless/iwlwifi/dvm/mac80211.c|  26 +--
 drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c|   4 +-
 drivers/net/wireless/iwlwifi/mvm/mac80211.c|  32 ++--
 drivers/net/wireless/libertas_tf/main.c|   2 +-
 drivers/net/wireless/mac80211_hwsim.c  |  26 +--
 drivers/net/wireless/mediatek/mt7601u/init.c   |  10 +-
 drivers/net/wireless/mwl8k.c   |   9 +-
 drivers/net/wireless/p54/main.c|  12 +-
 drivers/net/wireless/rsi/rsi_91x_mac80211.c|   7 +-
 drivers/net/wireless/rt2x00/rt2400pci.c|   8 +-
 drivers/net/wireless/rt2x00/rt2500pci.c|   8 +-
 drivers/net/wireless/rt2x00/rt2500usb.c|   9 +-
 drivers/net/wireless/rt2x00/rt2800lib.c|  16 +-
 drivers/net/wireless/rt2x00/rt61pci.c  |   9 +-
 drivers/net/wireless/rt2x00/rt73usb.c  |   9 +-
 drivers/net/wireless/rtl818x/rtl8180/dev.c |   9 +-

Re: [PATCH v3] ipv6: Fix protocol resubmission

2015-06-10 Thread Josh Hunt

On 06/09/2015 11:24 PM, Hajime Tazaki wrote:


Hello Josh, Dave,

my mobile ipv6 test on libos failed with this commit.

This commit makes a destination option header handling (i.e.,
ipprot-handler == ipv6_destopt_rcv) failed since
ipv6_destopt_rcv() seems to return a positive value to
indicate to goto resubmission label.

I will look for more detail.

-- Hajime


Hajime

Thanks for the report. I mentioned in an earlier post this might be a 
problem.


Dave, what if we restore the old behavior, but add a new label to handle 
the case where the decapsulating protocol returns the nexthdr value? 
Allowing for migration over to this method over time. I've pasted in a 
patch doing so below.


The other solution I guess is to change how the udp handler works, but I 
was hoping to keep it behaving the same as v4.


Josh

diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 41a73da..a4fab24 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -212,13 +212,13 @@ static int ip6_input_finish(struct sock *sk, 
struct sk_buff *skb)

 */

rcu_read_lock();
+resubmit:
idev = ip6_dst_idev(skb_dst(skb));
if (!pskb_pull(skb, skb_transport_offset(skb)))
goto discard;
nhoff = IP6CB(skb)-nhoff;
nexthdr = skb_network_header(skb)[nhoff];
-
-resubmit:
+resubmit_nexthdr:
raw = raw6_local_deliver(skb, nexthdr);
ipprot = rcu_dereference(inet6_protos[nexthdr]);
if (ipprot) {
@@ -246,9 +246,11 @@ resubmit:
goto discard;

ret = ipprot-handler(skb);
-   if (ret  0) {
-   nexthdr = -ret;
+   if (ret  0) {
goto resubmit;
+   } else if (ret  0) {
+   nexthdr = -ret;
+   goto resubmit_nexthdr;
} else if (ret == 0) {
IP6_INC_STATS_BH(net, idev, 
IPSTATS_MIB_INDELIVERS);

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


[PATCH net-next] net/unix: support SCM_SECURITY for stream sockets

2015-06-10 Thread Stephen Smalley
SCM_SECURITY was originally only implemented for datagram sockets,
not for stream sockets.  However, SCM_CREDENTIALS is supported on
Unix stream sockets.  For consistency, implement Unix stream support
for SCM_SECURITY as well.  Also clean up the existing code and get
rid of the superfluous UNIXSID macro.

Motivated by https://bugzilla.redhat.com/show_bug.cgi?id=1224211,
where systemd was using SCM_CREDENTIALS and assumed wrongly that
SCM_SECURITY was also supported on Unix stream sockets.

Signed-off-by: Stephen Smalley s...@tycho.nsa.gov
Acked-by: Paul Moore p...@paul-moore.com
---
 include/net/af_unix.h |  1 -
 net/unix/af_unix.c| 20 
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index a175ba4..4a167b3 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -39,7 +39,6 @@ struct unix_skb_parms {
 };
 
 #define UNIXCB(skb)(*(struct unix_skb_parms *)((skb)-cb))
-#define UNIXSID(skb)   (UNIXCB((skb)).secid)
 
 #define unix_state_lock(s) spin_lock(unix_sk(s)-lock)
 #define unix_state_unlock(s)   spin_unlock(unix_sk(s)-lock)
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index f25e167..03ee4d3 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -140,12 +140,17 @@ static struct hlist_head *unix_sockets_unbound(void *addr)
 #ifdef CONFIG_SECURITY_NETWORK
 static void unix_get_secdata(struct scm_cookie *scm, struct sk_buff *skb)
 {
-   memcpy(UNIXSID(skb), scm-secid, sizeof(u32));
+   UNIXCB(skb).secid = scm-secid;
 }
 
 static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff 
*skb)
 {
-   scm-secid = *UNIXSID(skb);
+   scm-secid = UNIXCB(skb).secid;
+}
+
+static inline bool unix_secdata_eq(struct scm_cookie *scm, struct sk_buff *skb)
+{
+   return (scm-secid == UNIXCB(skb).secid);
 }
 #else
 static inline void unix_get_secdata(struct scm_cookie *scm, struct sk_buff 
*skb)
@@ -153,6 +158,11 @@ static inline void unix_get_secdata(struct scm_cookie 
*scm, struct sk_buff *skb)
 
 static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff 
*skb)
 { }
+
+static inline bool unix_secdata_eq(struct scm_cookie *scm, struct sk_buff *skb)
+{
+   return true;
+}
 #endif /* CONFIG_SECURITY_NETWORK */
 
 /*
@@ -1414,6 +1424,7 @@ static int unix_scm_to_skb(struct scm_cookie *scm, struct 
sk_buff *skb, bool sen
UNIXCB(skb).uid = scm-creds.uid;
UNIXCB(skb).gid = scm-creds.gid;
UNIXCB(skb).fp = NULL;
+   unix_get_secdata(scm, skb);
if (scm-fp  send_fds)
err = unix_attach_fds(scm, skb);
 
@@ -1509,7 +1520,6 @@ static int unix_dgram_sendmsg(struct socket *sock, struct 
msghdr *msg,
if (err  0)
goto out_free;
max_level = err + 1;
-   unix_get_secdata(scm, skb);
 
skb_put(skb, len - data_len);
skb-data_len = data_len;
@@ -2118,11 +2128,13 @@ unlock:
/* Never glue messages from different writers */
if ((UNIXCB(skb).pid  != scm.pid) ||
!uid_eq(UNIXCB(skb).uid, scm.creds.uid) ||
-   !gid_eq(UNIXCB(skb).gid, scm.creds.gid))
+   !gid_eq(UNIXCB(skb).gid, scm.creds.gid) ||
+   !unix_secdata_eq(scm, skb))
break;
} else if (test_bit(SOCK_PASSCRED, sock-flags)) {
/* Copy credentials */
scm_set_cred(scm, UNIXCB(skb).pid, UNIXCB(skb).uid, 
UNIXCB(skb).gid);
+   unix_set_secdata(scm, skb);
check_creds = true;
}
 
-- 
2.1.0

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


Re: [PATCH] net, swap: Remove a warning and clarify why sk_mem_reclaim is required when deactivating swap

2015-06-10 Thread Leon Romanovsky
On Tue, Jun 9, 2015 at 9:40 PM, Jeff Layton jlay...@poochiereds.net wrote:
 From: Mel Gorman mgor...@suse.de

 Jeff Layton reported the following;

  [   74.232485] [ cut here ]
  [   74.233354] WARNING: CPU: 2 PID: 754 at net/core/sock.c:364 
 sk_clear_memalloc+0x51/0x80()
  [   74.234790] Modules linked in: cts rpcsec_gss_krb5 nfsv4 dns_resolver nfs 
 fscache xfs libcrc32c snd_hda_codec_generic snd_hda_intel snd_hda_controller 
 snd_hda_codec snd_hda_core snd_hwdep snd_seq snd_seq_device nfsd snd_pcm 
 snd_timer snd e1000 ppdev parport_pc joydev parport pvpanic soundcore floppy 
 serio_raw i2c_piix4 pcspkr nfs_acl lockd virtio_balloon acpi_cpufreq 
 auth_rpcgss grace sunrpc qxl drm_kms_helper ttm drm virtio_console virtio_blk 
 virtio_pci ata_generic virtio_ring pata_acpi virtio
  [   74.243599] CPU: 2 PID: 754 Comm: swapoff Not tainted 4.1.0-rc6+ #5
  [   74.244635] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
  [   74.245546]   79e69e31 8800d066bde8 
 8179263d
  [   74.246786]    8800d066be28 
 8109e6fa
  [   74.248175]   880118d48000 8800d58f5c08 
 880036e380a8
  [   74.249483] Call Trace:
  [   74.249872]  [8179263d] dump_stack+0x45/0x57
  [   74.250703]  [8109e6fa] warn_slowpath_common+0x8a/0xc0
  [   74.251655]  [8109e82a] warn_slowpath_null+0x1a/0x20
  [   74.252585]  [81661241] sk_clear_memalloc+0x51/0x80
  [   74.253519]  [a0116c72] xs_disable_swap+0x42/0x80 [sunrpc]
  [   74.254537]  [a01109de] rpc_clnt_swap_deactivate+0x7e/0xc0 
 [sunrpc]
  [   74.255610]  [a03e4fd7] nfs_swap_deactivate+0x27/0x30 [nfs]
  [   74.256582]  [811e99d4] destroy_swap_extents+0x74/0x80
  [   74.257496]  [811ecb52] SyS_swapoff+0x222/0x5c0
  [   74.258318]  [81023f27] ? syscall_trace_leave+0xc7/0x140
  [   74.259253]  [81798dae] system_call_fastpath+0x12/0x71
  [   74.260158] ---[ end trace 2530722966429f10 ]---

 The warning in question was unnecessary but with Jeff's series the rules
 are also clearer.  This patch removes the warning and updates the comment
 to explain why sk_mem_reclaim() may still be called.

 Signed-off-by: Mel Gorman mgor...@suse.de
 Acked-by: Jeff Layton jeff.lay...@primarydata.com
 ---
  net/core/sock.c | 12 +---
  1 file changed, 5 insertions(+), 7 deletions(-)

 diff --git a/net/core/sock.c b/net/core/sock.c
 index 292f42228bfb..2bb4c56370e5 100644
 --- a/net/core/sock.c
 +++ b/net/core/sock.c
 @@ -354,14 +354,12 @@ void sk_clear_memalloc(struct sock *sk)

 /*
  * SOCK_MEMALLOC is allowed to ignore rmem limits to ensure forward
 -* progress of swapping. However, if SOCK_MEMALLOC is cleared while
 -* it has rmem allocations there is a risk that the user of the
 -* socket cannot make forward progress due to exceeding the rmem
 -* limits. By rights, sk_clear_memalloc() should only be called
 -* on sockets being torn down but warn and reset the accounting if
 -* that assumption breaks.
 +* progress of swapping. SOCK_MEMALLOC may be cleared while
 +* it has rmem allocations due to the last swapfile being deactivated
 +* but there is a risk that the socket is unusable due to exceeding
 +* the rmem limits. Reclaim the reserves and obey rmem limits again.
  */
 -   if (WARN_ON(sk-sk_forward_alloc))
 +   if (sk-sk_forward_alloc)
You don't really need this IF. if sk-sk_forward_alloc is equal to
zero, it will be less than SK_MEM_QUANTUM.
http://lxr.free-electrons.com/source/include/net/sock.h#L1405

1405 static inline void sk_mem_reclaim(struct sock *sk)
1406 {
1407 if (!sk_has_account(sk))
1408 return;
1409 if (sk-sk_forward_alloc = SK_MEM_QUANTUM)
1410 __sk_mem_reclaim(sk);
1411 }


 sk_mem_reclaim(sk);
  }
  EXPORT_SYMBOL_GPL(sk_clear_memalloc);
 --
 2.4.2

 --
 To unsubscribe, send a message with 'unsubscribe linux-mm' in
 the body to majord...@kvack.org.  For more info on Linux MM,
 see: http://www.linux-mm.org/ .
 Don't email: a href=mailto:d...@kvack.org; em...@kvack.org /a



-- 
Leon Romanovsky | Independent Linux Consultant
www.leon.nu | l...@leon.nu
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] NET: Add ezchip ethernet driver

2015-06-10 Thread Paul Bolle
Just a nit and a question.

On Tue, 2015-06-09 at 15:44 +0300, Noam Camus wrote:
 --- /dev/null
 +++ b/drivers/net/ethernet/ezchip/Kconfig

 +config NET_VENDOR_EZCHIP
 + bool EZchip devices
 + default y
 + ---help---
 +   If you have a network (Ethernet) device belonging to this class, say Y
 +   and read the Ethernet-HOWTO, available from
 +   http://www.tldp.org/docs.html#howto.
 +
 +   Note that the answer to this question doesn't directly affect the
 +   kernel: saying N will just cause the configurator to skip all
 +   the questions about EZchip devices. If you say Y, you will be asked 
 for
 +   your specific device in the following questions.
 +
 +if NET_VENDOR_EZCHIP
 +
 +config EZCHIP_NPS_LAN
 + tristate EZchip NPS LAN support
 + default y

It's not common for drivers to default to 'y'. Any specific reason to do
so here?

 + ---help---
 +   Simple LAN device without multicast support.
 +   Device performance is not high and may be used for
 +   debug or management purposes.
 +   Device supports interrupts for RX and TX(end).
 +   Device does not support NAPI and also does not support DMA.
 +
 +endif

 --- /dev/null
 +++ b/drivers/net/ethernet/ezchip/nps_enet.c

 + * This program is free software; you can redistribute it and/or modify it
 + * under the terms and conditions of the GNU General Public License,
 + * version 2, as published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope it will be useful, but WITHOUT
 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 + * more details.
 + *
 + * The full GNU General Public License is included in this distribution in
 + * the file called COPYING.

This states the license is GPL v2.

 +MODULE_LICENSE(GPL);

And, according to include/linux/module.h, this states the license is GPL
v2 or later. So I think that either the comment at the top of this file
or the ident used in the MODULE_LICENSE() macro needs to change.


Paul Bolle

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


jewelry and watches

2015-06-10 Thread Tonny
Dear Sir/Madam:

Attached pls kindly find our new design .

Best regards!
 

Tonny

Re: [PATCH WIP RFC 0/3] mpls: support for ler

2015-06-10 Thread roopa

On 6/8/15, 3:58 PM, Thomas Graf wrote:

I'll immediately ACK any series that supports both models and rebase
my patches on top of it. I think we are on the right track overall.


I am trying to get my code on github to collaborate better. Stay tuned
(hopefully end of day today).



Robert/Thomas, All my changes are in the below repo under the 'mpls' branch.
https://github.com/CumulusNetworks/net-next
https://github.com/CumulusNetworks/iproute2

The last iproute2 commit has a sample usage.

The commits pushed to this tree do not contain support for the following 
yet (but working on it):

a) tunnel routes to work with tunnel RTA_OIF and a non-tunnel RTA_OIF:
The current commits in the tree assume a non-tunnel RTA_OIF.
If the tunnel driver has registered a dst_output func,  dst_output
is set to the tunnel dst output handler in the receive route lookup path 
which in turn does the encap
and xmits. Thomas had last suggested using a flag to skip the dst output 
handler re-direction
for cases where RTA_OIF is a special tunnel netdev and the tunnel driver 
xmit function
can do the encap. My current thinking is to pass the oif to the encap 
parse handler and the handler can set the flag on the tunnel state. And 
this flag can then be used to skip the dst_output re-direction.

This change should be trivial will fix it soon.

b) make RTA_OIF optional and do a fib lookup.

keep your suggestions/feedback coming...

thanks,
Roopa








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


Re: [PATCH RFC] net: phy: Introduced the PHY_AN_PENDING state

2015-06-10 Thread Keng Soon Cheah
Resending as I didn't reply all.

On Tue, Jun 09, 2015 at 10:17:59PM -0700, Florian Fainelli wrote:
 
 The typical way to work around these problems are to fix them at the PHY
 driver level, see below.
 

My first attempt of work around is to target on the PHY driver but I
couldn't figure out a good way in doing that because

1. We use RT kernel. The jitter performance is very sensitive to the time
we spend in the kernel. Hence polling for auto-negotiation to complete
before starting a new one could hurt the system performance. Moreover,
I've seen the PHY takes up to 11s to complete auto-negotiation.

2. Ruling out status polling mean I have to switch to use some work
scheduling mechanism to let the PHY driver come back and check the
auto-negotiation status (which is what the state machine is doing now)
but this seem to even complicate the solution because the PHY state machine
has moved to PHY_AN state at the same time, but the auto-negotiation has
not really been fired yet. There are more conditions that need to be
consider to sync the PHY driver and the PHY state machine after the
previous auto-negotiation finish.

It looks like a dead end to me for continuing down the path of modifying
PHY driver. Do let me know if you have better idea to achieve the same
objective.

 
 That sounds like a bug in the PHY state machine and/or the PHY driver if
 you are allowed to restart auto-negotiation while one is pending. Now
 that the PHY state machine has debug prints built-in, could you capture
 a trace of this failing case?
 
 Is this observed with the generic PHY driver or a custom PHY driver?
 

It's not really a problem in the state machine or PHY driver. A very common
scenario for an auto-negotiation to start before previous complete is at
system boot up where the previous auto-negotiation, either triggered by
hardware (because PHY come out from reset and auto-negotiate by itself)
or software (U-Boot triggering PHY software reset).

The other scenario that I'm able to induce the same effect is by doing
mii-tool -r in Linux.

 As usual with state machines, introducing a new state needs to be
 carefully done in order to make sure that all transitions are correct,
 so far I would rather work on finding the root cause/extending the
 timeout and/or making it configurable on a PHY-driver basis rather than
 having this additional state which is more error prone.
 

I agree that introducing changes to the state machine will need careful
review and it's my last option within the constraint I have. I tried to
serialize the PHY_AN_PENDING and PHY_AN state to minimize the disruption
introduced to the state machine. There is only one entry to the
PHY_AN_PENDING state (via phy_start_aneg) and there is only one exit point
to continue with PHY_AN. The state machine would otherwise identical with
the original state machine.
Should the PHY drop to any state other than PHY_AN_PENDING, they will
always transition their state as usual.
Should the PHY state machine requires an auto-negotiation, it will always
enter PHY_AN_PENDING and always continue with PHY_AN as usual.

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


RE: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-10 Thread Madalin-Cristian Bucur
Hi Eric,

Can you please tell us if this change would be for the better?

I was about to say yes to this request but checked and no other Ethernet driver 
seems to use the queue trans_start.
I was able to find your patch net: tx scalability works : trans_start [ 
http://patchwork.ozlabs.org/patch/27104/ ] but did not find more about this 
topic.
 
Thank you,
Madalin

 -Original Message-
 From: Xie Jianhua-B29408
 Sent: Wednesday, June 10, 2015 9:00 AM
 To: Bucur Madalin-Cristian-B32716; netdev@vger.kernel.org; linuxppc-
 d...@lists.ozlabs.org
 Cc: linux-ker...@vger.kernel.org
 Subject: RE: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet
 
 
 
  -Original Message-
  From: Linuxppc-dev [mailto:linuxppc-dev-
  bounces+jianhua.xie=freescale@lists.ozlabs.org] On Behalf Of
 Madalin
  Bucur
  Sent: Wednesday, April 29, 2015 10:57 PM
  To: netdev@vger.kernel.org; linuxppc-...@lists.ozlabs.org
  Cc: linux-ker...@vger.kernel.org; Bucur Madalin-Cristian-B32716
  Subject: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet
 
  This introduces the Freescale Data Path Acceleration Architecture
  (DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
  BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
  the Freescale DPAA QorIQ platforms.
 
 Snip..
 
  +
  +   if (unlikely(dpa_xmit(priv, percpu_stats, queue_mapping, fd)  0))
  +   goto xmit_failed;
  +
  +   net_dev-trans_start = jiffies;
 
 It is probably better to use netdev_queue-trans_start to instead of
 net_dev-trans_start on SMP.
 
 Best Regards,
 Jianhua
 
  +   return NETDEV_TX_OK;
  +
  +xmit_failed:
  +   if (fd.cmd  FM_FD_CMD_FCO) {
  +   (*countptr)--;
  +   dpa_fd_release(net_dev, fd);
  +   percpu_stats-tx_errors++;
  +   return NETDEV_TX_OK;
  +   }
  +   _dpa_cleanup_tx_fd(priv, fd);
  +   percpu_stats-tx_errors++;
  +   dev_kfree_skb(skb);
  +   return NETDEV_TX_OK;
  +}
  --
  1.7.11.7
 
  ___
  Linuxppc-dev mailing list
  linuxppc-...@lists.ozlabs.org
  https://lists.ozlabs.org/listinfo/linuxppc-dev
N�r��yb�X��ǧv�^�)޺{.n�+���z�^�)w*jg����ݢj/���z�ޖ��2�ޙ�)ߡ�a�����G���h��j:+v���w��٥

Re: [PATCH v3 1/2] sctp: rcu-ify addr_waitq

2015-06-10 Thread Marcelo Ricardo Leitner
On Tue, Jun 09, 2015 at 04:32:59PM -0300, Marcelo Ricardo Leitner wrote:
 On Tue, Jun 09, 2015 at 07:36:38AM -0400, Neil Horman wrote:
  On Mon, Jun 08, 2015 at 05:37:05PM +0200, Hannes Frederic Sowa wrote:
   On Mo, 2015-06-08 at 11:19 -0400, Neil Horman wrote:
On Mon, Jun 08, 2015 at 04:59:18PM +0200, Hannes Frederic Sowa wrote:
 On Mon, Jun 8, 2015, at 16:46, Hannes Frederic Sowa wrote:
  Hi Marcelo,
  
  a few hints on rcuification, sorry I reviewed the code so late:
  
  On Fri, Jun 5, 2015, at 19:08, mleit...@redhat.com wrote:
   From: Marcelo Ricardo Leitner marcelo.leit...@gmail.com
   
   That's needed for the next patch, so we break the lock 
   inversion between
   netns_sctp-addr_wq_lock and socket lock on
   sctp_addr_wq_timeout_handler(). With this, we can traverse 
   addr_waitq
   without taking addr_wq_lock, taking it just for the write 
   operations.
   
   Signed-off-by: Marcelo Ricardo Leitner 
   marcelo.leit...@gmail.com
   ---
   
   Notes:
   v2-v3:
 placed break statement on sctp_free_addr_wq_entry()
 removed unnecessary spin_lock noticed by Neil
   
include/net/netns/sctp.h |  2 +-
net/sctp/protocol.c  | 80
+---
2 files changed, 49 insertions(+), 33 deletions(-)
   
   diff --git a/include/net/netns/sctp.h 
   b/include/net/netns/sctp.h
   index
   3573a81815ad9e0efb6ceb721eb066d3726419f0..9e53412c4ed829e8e4577
   7a6d95406d490dbaa75
   100644
   --- a/include/net/netns/sctp.h
   +++ b/include/net/netns/sctp.h
   @@ -28,7 +28,7 @@ struct netns_sctp {
* It is a list of sctp_sockaddr_entry.
*/
   struct list_head local_addr_list;
   -   struct list_head addr_waitq;
   +   struct list_head __rcu addr_waitq;
   struct timer_list addr_wq_timer;
   struct list_head auto_asconf_splist;
   spinlock_t addr_wq_lock;
   diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
   index
   53b7acde9aa37bf3d4029c459421564d5270f4c0..9954fb8c9a9455d5ad7a6
   27e2d7f9a1fef861fc2
   100644
   --- a/net/sctp/protocol.c
   +++ b/net/sctp/protocol.c
   @@ -593,15 +593,47 @@ static void sctp_v4_ecn_capable(struct 
   sock *sk)
   INET_ECN_xmit(sk);
}

   +static void sctp_free_addr_wq(struct net *net)
   +{
   +   struct sctp_sockaddr_entry *addrw;
   +
   +   spin_lock_bh(net-sctp.addr_wq_lock);
  
  Instead of holding spin_lock_bh you need to hold 
  rcu_read_lock_bh, so
  kfree_rcu does not call free function at once (in theory ;) ).
  
   +   del_timer(net-sctp.addr_wq_timer);
   +   list_for_each_entry_rcu(addrw, net-sctp.addr_waitq, 
   list) {
   +   list_del_rcu(addrw-list);
   +   kfree_rcu(addrw, rcu);
   +   }
   +   spin_unlock_bh(net-sctp.addr_wq_lock);
   +}
   +
   +/* As there is no refcnt on sctp_sockaddr_entry, we must check 
   inside
   + * the lock if it wasn't removed from addr_waitq already, 
   otherwise we
   + * could double-free it.
   + */
   +static void sctp_free_addr_wq_entry(struct net *net,
   +   struct sctp_sockaddr_entry 
   *addrw)
   +{
   +   struct sctp_sockaddr_entry *temp;
   +
   +   spin_lock_bh(net-sctp.addr_wq_lock);
  
  I don't think this spin_lock operation is needed. The del_timer
  functions do synchronize themselves.
  
 
 Sorry, those above two locks are needed, they are not implied by 
 other
 locks.
 
What makes you say that? Multiple contexts can issue mod_timer calls 
on the
same timer safely no, because of the internal locking?
   
   That's true for timer handling but not to protect net-sctp.addr_waitq
   list (Marcelo just explained it to me off-list). Looking at the patch
   only in patchworks lost quite a lot of context you were already
   discussing. ;)
   
  I can imagine :)
  
   We are currently checking if the double iteration can be avoided by
   splicing addr_waitq on the local stack while holding the spin_lock and
   later on notifying the sockets.
   
  As we discussed, this I think would make a good alternate approach.
 
 I was experimenting on this but this would introduce another complex
 logic instead, as not all elements are pruned from net-sctp.addr_waitq
 at sctp_addr_wq_timeout_handler(), mainly ipv6 addresses in DAD state
 (which I believe that break statement is misplaced and should be a
 continue instead, I'll check on this later)
 
 That means we would have to do the splice, process the loop, merge the
 remaining elements with the new net-sctp.addr_waitq that was 

Re: pull-request: mac80211-next 2015-06-10

2015-06-10 Thread Johannes Berg
On Wed, 2015-06-10 at 15:09 +0200, Johannes Berg wrote:

 The following changes since commit c3eee1fb1d308564ada5f7ea57bc51efc6130b37:
 
   Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge 
 (2015-06-09 20:23:52 -0700)
 
 are available in the git repository at:
 
   git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 
 tags/mac80211-next-for-davem-2015-06-10
 
 for you to fetch changes up to 5df03344c5639fdd848cb87553956df7276a8645:
 
   mac80211: convert HW flags to unsigned long bitmap (2015-06-10 13:48:42 
 +0200)

Oops, fixed a stupid bug in there so that's now commit
30686bf7f5b3c30831761e188a6e3cb33580fa48. Sorry about that.

johannes

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


[PATCH net-next 07/13] net/mlx4_core: Allocate default counter per port

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

Default counter per port will be allocated at the mlx4 core driver load.

Every QP opened by the Ethernet driver will be attached to the port's default
counter.  This is an infrastructure step to collect VF statistics from the PF.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c|5 ++
 drivers/net/ethernet/mellanox/mlx4/en_resources.c |2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c |   71 -
 drivers/net/ethernet/mellanox/mlx4/mlx4.h |1 +
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h  |1 +
 include/linux/mlx4/device.h   |1 +
 6 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c 
b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 98efb58..048fca0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -1597,6 +1597,9 @@ int mlx4_en_start_port(struct net_device *dev)
}
mdev-mac_removed[priv-port] = 0;
 
+   priv-counter_index =
+   mlx4_get_default_counter_index(mdev-dev, priv-port);
+
err = mlx4_en_config_rss_steer(priv);
if (err) {
en_err(priv, Failed configuring rss steering\n);
@@ -1755,6 +1758,7 @@ void mlx4_en_stop_port(struct net_device *dev, int detach)
 
/* Set port as not active */
priv-port_up = false;
+   priv-counter_index = MLX4_SINK_COUNTER_INDEX(mdev-dev);
 
/* Promsicuous mode */
if (mdev-dev-caps.steering_mode ==
@@ -2778,6 +2782,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int 
port,
 
priv = netdev_priv(dev);
memset(priv, 0, sizeof(struct mlx4_en_priv));
+   priv-counter_index = MLX4_SINK_COUNTER_INDEX(mdev-dev);
spin_lock_init(priv-stats_lock);
INIT_WORK(priv-rx_mode_task, mlx4_en_do_set_rx_mode);
INIT_WORK(priv-watchdog_task, mlx4_en_restart);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_resources.c 
b/drivers/net/ethernet/mellanox/mlx4/en_resources.c
index 97bcb91..e482fa1 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_resources.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_resources.c
@@ -66,7 +66,7 @@ void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int 
size, int stride,
context-pri_path.sched_queue |= user_prio  3;
context-pri_path.feup = MLX4_FEUP_FORCE_ETH_UP;
}
-   context-pri_path.counter_index = MLX4_SINK_COUNTER_INDEX(mdev-dev);
+   context-pri_path.counter_index = priv-counter_index;
context-cqn_send = cpu_to_be32(cqn);
context-cqn_recv = cpu_to_be32(cqn);
context-db_rec_addr = cpu_to_be64(priv-res.db.dma  2);
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index c3fe49e..3d0de27 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2219,6 +2219,47 @@ static void mlx4_cleanup_counters_table(struct mlx4_dev 
*dev)
mlx4_bitmap_cleanup(mlx4_priv(dev)-counters_bitmap);
 }
 
+static void mlx4_cleanup_default_counters(struct mlx4_dev *dev)
+{
+   struct mlx4_priv *priv = mlx4_priv(dev);
+   int port;
+
+   for (port = 0; port  dev-caps.num_ports; port++)
+   if (priv-def_counter[port] != -1)
+   mlx4_counter_free(dev,  priv-def_counter[port]);
+}
+
+static int mlx4_allocate_default_counters(struct mlx4_dev *dev)
+{
+   struct mlx4_priv *priv = mlx4_priv(dev);
+   int port, err = 0;
+   u32 idx;
+
+   for (port = 0; port  dev-caps.num_ports; port++)
+   priv-def_counter[port] = -1;
+
+   for (port = 0; port  dev-caps.num_ports; port++) {
+   err = mlx4_counter_alloc(dev, idx);
+
+   if (!err || err == -ENOSPC) {
+   priv-def_counter[port] = idx;
+   } else if (err == -ENOENT) {
+   err = 0;
+   continue;
+   } else {
+   mlx4_err(dev, %s: failed to allocate default counter 
port %d err %d\n,
+__func__, port + 1, err);
+   mlx4_cleanup_default_counters(dev);
+   return err;
+   }
+
+   mlx4_dbg(dev, %s: default counter index %d for port %d\n,
+__func__, priv-def_counter[port], port + 1);
+   }
+
+   return err;
+}
+
 int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx)
 {
struct mlx4_priv *priv = mlx4_priv(dev);
@@ -2227,8 +2268,10 @@ int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx)
return -ENOENT;
 
*idx = mlx4_bitmap_alloc(priv-counters_bitmap);
-   if 

[PATCH net-next 09/13] IB/mlx4: Set VF to read from QP counters

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

As IB VFs are not capable to read the port counters through MADs,
move there to read their own QP counters to gather statistics.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/infiniband/hw/mlx4/mad.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 74ca13f..bc698b1 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -869,10 +869,12 @@ int mlx4_ib_process_mad(struct ib_device *ibdev, int 
mad_flags, u8 port_num,
struct ib_wc *in_wc, struct ib_grh *in_grh,
struct ib_mad *in_mad, struct ib_mad *out_mad)
 {
+   struct mlx4_ib_dev *dev = to_mdev(ibdev);
switch (rdma_port_get_link_layer(ibdev, port_num)) {
case IB_LINK_LAYER_INFINIBAND:
-   return ib_process_mad(ibdev, mad_flags, port_num, in_wc,
- in_grh, in_mad, out_mad);
+   if (!mlx4_is_slave(dev-dev))
+   return ib_process_mad(ibdev, mad_flags, port_num, in_wc,
+ in_grh, in_mad, out_mad);
case IB_LINK_LAYER_ETHERNET:
return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
  in_grh, in_mad, out_mad);
-- 
1.7.1

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


[PATCH net-next 11/13] net/mlx4_en: Show PF own statistics via ethtool

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

Allow the user to observe the PF own statistics using ethtool with pf_
prefixed counter names.

Those counters are the PF statistics out of the overall port statistics.
Every PF QP is attached to a counter and the summary of those counters
is the PF statistics.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c |   17 
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c  |8 ++-
 drivers/net/ethernet/mellanox/mlx4/en_port.c|   24 ++-
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h|1 +
 drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h |   11 +-
 5 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c 
b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index a2ddf3d..99ba1c5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -119,6 +119,12 @@ static const char main_strings[][ETH_GSTRING_LEN] = {
queue_stopped, wake_queue, tx_timeout, rx_alloc_failed,
rx_csum_good, rx_csum_none, rx_csum_complete, tx_chksum_offload,
 
+   /* pf statistics */
+   pf_rx_packets,
+   pf_rx_bytes,
+   pf_tx_packets,
+   pf_tx_bytes,
+
/* priority flow control statistics rx */
rx_pause_prio_0, rx_pause_duration_prio_0,
rx_pause_transition_prio_0,
@@ -368,6 +374,11 @@ static void mlx4_en_get_ethtool_stats(struct net_device 
*dev,
if (bitmap_iterator_test(it))
data[index++] = ((unsigned long *)priv-port_stats)[i];
 
+   for (i = 0; i  NUM_PF_STATS; i++, bitmap_iterator_inc(it))
+   if (bitmap_iterator_test(it))
+   data[index++] =
+   ((unsigned long *)priv-pf_stats)[i];
+
for (i = 0; i  NUM_FLOW_PRIORITY_STATS_RX;
 i++, bitmap_iterator_inc(it))
if (bitmap_iterator_test(it))
@@ -448,6 +459,12 @@ static void mlx4_en_get_strings(struct net_device *dev,
strcpy(data + (index++) * ETH_GSTRING_LEN,
   main_strings[strings]);
 
+   for (i = 0; i  NUM_PF_STATS; i++, strings++,
+bitmap_iterator_inc(it))
+   if (bitmap_iterator_test(it))
+   strcpy(data + (index++) * ETH_GSTRING_LEN,
+  main_strings[strings]);
+
for (i = 0; i  NUM_FLOW_STATS; i++, strings++,
 bitmap_iterator_inc(it))
if (bitmap_iterator_test(it))
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c 
b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 048fca0..f9142f2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -1895,6 +1895,7 @@ static void mlx4_en_clear_stats(struct net_device *dev)
   sizeof(priv-rx_priority_flowstats));
memset(priv-tx_priority_flowstats, 0,
   sizeof(priv-tx_priority_flowstats));
+   memset(priv-pf_stats, 0, sizeof(priv-pf_stats));
 
for (i = 0; i  priv-tx_ring_num; i++) {
priv-tx_ring[i]-bytes = 0;
@@ -2685,7 +2686,7 @@ void mlx4_en_update_pfc_stats_bitmap(struct mlx4_dev *dev,
 u8 rx_ppp, u8 rx_pause,
 u8 tx_ppp, u8 tx_pause)
 {
-   int last_i = NUM_MAIN_STATS + NUM_PORT_STATS;
+   int last_i = NUM_MAIN_STATS + NUM_PORT_STATS + NUM_PF_STATS;
 
if (!mlx4_is_slave(dev) 
(dev-caps.flags2  MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN)) {
@@ -2747,6 +2748,11 @@ void mlx4_en_set_stats_bitmap(struct mlx4_dev *dev,
bitmap_set(stats_bitmap-bitmap, last_i, NUM_PORT_STATS);
last_i += NUM_PORT_STATS;
 
+   if (mlx4_is_master(dev))
+   bitmap_set(stats_bitmap-bitmap, last_i,
+  NUM_PF_STATS);
+   last_i += NUM_PF_STATS;
+
mlx4_en_update_pfc_stats_bitmap(dev, stats_bitmap,
rx_ppp, rx_pause,
tx_ppp, tx_pause);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c 
b/drivers/net/ethernet/mellanox/mlx4/en_port.c
index 0a56f01..df1236c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c
@@ -149,14 +149,16 @@ static unsigned long en_stats_adder(__be64 *start, __be64 
*next, int num)
 
 int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 {
+   struct mlx4_counter tmp_counter_stats;
struct mlx4_en_stat_out_mbox *mlx4_en_stats;
struct mlx4_en_stat_out_flow_control_mbox *flowstats;
struct 

[PATCH net-next 08/13] IB/mlx4: Add RoCE/IB dedicated counters

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

This is an infrastructure step to attach all the QPs opened from the
IB driver to a counter in order to collect VF stats from the PF using
those counters.

If the port's type is Ethernet, the counter policy demands two counters
per port (one for RoCE and one for Ethernet). The port default counter
(allocated in mlx4_core) is used for the Ethernet netdev QPs and we
allocate another counter for RoCE.

If the port's traffic is Infiniband, the counter policy demands
one counter per port, so it can use the port's default counter.

Also, Add 'allocated' flag for each counter in order to clean it at
unload.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/infiniband/hw/mlx4/mad.c |2 +-
 drivers/infiniband/hw/mlx4/main.c|   43 +++--
 drivers/infiniband/hw/mlx4/mlx4_ib.h |7 -
 drivers/infiniband/hw/mlx4/qp.c  |4 +-
 4 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index ad6a881..74ca13f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -831,7 +831,7 @@ static int iboe_process_mad(struct ib_device *ibdev, int 
mad_flags, u8 port_num,
struct mlx4_cmd_mailbox *mailbox;
struct mlx4_ib_dev *dev = to_mdev(ibdev);
int err;
-   u32 inmod = dev-counters[port_num - 1]  0x;
+   u32 inmod = dev-counters[port_num - 1].index  0x;
u8 mode;
 
if (in_mad-mad_hdr.mgmt_class != IB_MGMT_CLASS_PERF_MGMT)
diff --git a/drivers/infiniband/hw/mlx4/main.c 
b/drivers/infiniband/hw/mlx4/main.c
index 024b0f7..b6bd217 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2098,6 +2098,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
struct mlx4_ib_iboe *iboe;
int ib_num_ports = 0;
int num_req_counters;
+   int allocated;
+   u32 counter_index;
 
pr_info_once(%s, mlx4_ib_version);
 
@@ -2263,19 +2265,31 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
num_req_counters = mlx4_is_bonded(dev) ? 1 : ibdev-num_ports;
for (i = 0; i  num_req_counters; ++i) {
mutex_init(ibdev-qp1_proxy_lock[i]);
+   allocated = 0;
if (mlx4_ib_port_link_layer(ibdev-ib_dev, i + 1) ==
IB_LINK_LAYER_ETHERNET) {
-   err = mlx4_counter_alloc(ibdev-dev, 
ibdev-counters[i]);
+   err = mlx4_counter_alloc(ibdev-dev, counter_index);
+   /* if failed to allocate a new counter, use default */
if (err)
-   ibdev-counters[i] = -1;
-   } else {
-   ibdev-counters[i] = -1;
+   counter_index =
+   mlx4_get_default_counter_index(dev,
+  i + 1);
+   else
+   allocated = 1;
+   } else { /* IB_LINK_LAYER_INFINIBAND use the default counter */
+   counter_index = mlx4_get_default_counter_index(dev,
+  i + 1);
}
+   ibdev-counters[i].index = counter_index;
+   ibdev-counters[i].allocated = allocated;
+   pr_info(counter index %d for port %d allocated %d\n,
+   counter_index, i + 1, allocated);
}
if (mlx4_is_bonded(dev))
-   for (i = 1; i  ibdev-num_ports ; ++i)
-   ibdev-counters[i] = ibdev-counters[0];
-
+   for (i = 1; i  ibdev-num_ports ; ++i) {
+   ibdev-counters[i].index = ibdev-counters[0].index;
+   ibdev-counters[i].allocated = 0;
+   }
 
mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
ib_num_ports++;
@@ -2415,10 +2429,12 @@ err_steer_qp_release:
mlx4_qp_release_range(dev, ibdev-steer_qpn_base,
  ibdev-steer_qpn_count);
 err_counter:
-   for (; i; --i)
-   if (ibdev-counters[i - 1] != -1)
-   mlx4_counter_free(ibdev-dev, ibdev-counters[i - 1]);
-
+   for (i = 0; i  ibdev-num_ports; ++i) {
+   if (ibdev-counters[i].index != -1 
+   ibdev-counters[i].allocated)
+   mlx4_counter_free(ibdev-dev,
+ ibdev-counters[i].index);
+   }
 err_map:
iounmap(ibdev-uar_map);
 
@@ -2535,8 +2551,9 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void 
*ibdev_ptr)
 
iounmap(ibdev-uar_map);
for (p = 0; p  

[PATCH net-next 10/13] net/mlx4_core: Add helper to query counters

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

This is an infrastructure step for querying VF and PF counters.

This code was in the IB driver, move it to the mlx4 core driver
so it will be accessible for more use cases.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/infiniband/hw/mlx4/mad.c |   32 
 drivers/net/ethernet/mellanox/mlx4/cmd.c |   57 ++
 include/linux/mlx4/cmd.h |3 ++
 include/linux/mlx4/device.h  |8 
 4 files changed, 76 insertions(+), 24 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index bc698b1..bc09b4e 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -64,14 +64,6 @@ enum {
 #define GUID_TBL_BLK_NUM_ENTRIES 8
 #define GUID_TBL_BLK_SIZE (GUID_TBL_ENTRY_SIZE * GUID_TBL_BLK_NUM_ENTRIES)
 
-/* Counters should be saturate once they reach their maximum value */
-#define ASSIGN_32BIT_COUNTER(counter, value) do {\
-   if ((value)  U32_MAX)   \
-   counter = cpu_to_be32(U32_MAX); \
-   else \
-   counter = cpu_to_be32(value);\
-} while (0)
-
 struct mlx4_mad_rcv_buf {
struct ib_grh grh;
u8 payload[256];
@@ -828,31 +820,25 @@ static int iboe_process_mad(struct ib_device *ibdev, int 
mad_flags, u8 port_num,
struct ib_wc *in_wc, struct ib_grh *in_grh,
struct ib_mad *in_mad, struct ib_mad *out_mad)
 {
-   struct mlx4_cmd_mailbox *mailbox;
+   struct mlx4_counter counter_stats;
struct mlx4_ib_dev *dev = to_mdev(ibdev);
int err;
-   u32 inmod = dev-counters[port_num - 1].index  0x;
-   u8 mode;
 
if (in_mad-mad_hdr.mgmt_class != IB_MGMT_CLASS_PERF_MGMT)
return -EINVAL;
 
-   mailbox = mlx4_alloc_cmd_mailbox(dev-dev);
-   if (IS_ERR(mailbox))
-   return IB_MAD_RESULT_FAILURE;
-
-   err = mlx4_cmd_box(dev-dev, 0, mailbox-dma, inmod, 0,
-  MLX4_CMD_QUERY_IF_STAT, MLX4_CMD_TIME_CLASS_C,
-  MLX4_CMD_WRAPPED);
+   memset(counter_stats, 0, sizeof(counter_stats));
+   err = mlx4_get_counter_stats(dev-dev,
+dev-counters[port_num - 1].index,
+counter_stats, 0);
if (err)
err = IB_MAD_RESULT_FAILURE;
else {
memset(out_mad-data, 0, sizeof out_mad-data);
-   mode = ((struct mlx4_counter *)mailbox-buf)-counter_mode;
-   switch (mode  0xf) {
+   switch (counter_stats.counter_mode  0xf) {
case 0:
-   edit_counter(mailbox-buf,
-   (void *)(out_mad-data + 40));
+   edit_counter(counter_stats,
+(void *)(out_mad-data + 40));
err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
break;
default:
@@ -860,8 +846,6 @@ static int iboe_process_mad(struct ib_device *ibdev, int 
mad_flags, u8 port_num,
}
}
 
-   mlx4_free_cmd_mailbox(dev-dev, mailbox);
-
return err;
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c 
b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 91d8344..4495bbd 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -49,6 +49,7 @@
 #include mlx4.h
 #include fw.h
 #include fw_qos.h
+#include mlx4_stats.h
 
 #define CMD_POLL_TOKEN 0x
 #define INBOX_MASK 0xff00ULL
@@ -3166,6 +3167,62 @@ int mlx4_set_vf_link_state(struct mlx4_dev *dev, int 
port, int vf, int link_stat
 }
 EXPORT_SYMBOL_GPL(mlx4_set_vf_link_state);
 
+int mlx4_get_counter_stats(struct mlx4_dev *dev, int counter_index,
+  struct mlx4_counter *counter_stats, int reset)
+{
+   struct mlx4_cmd_mailbox *mailbox = NULL;
+   struct mlx4_counter *tmp_counter;
+   int err;
+   u32 if_stat_in_mod;
+
+   if (!counter_stats)
+   return -EINVAL;
+
+   if (counter_index == MLX4_SINK_COUNTER_INDEX(dev))
+   return 0;
+
+   mailbox = mlx4_alloc_cmd_mailbox(dev);
+   if (IS_ERR(mailbox))
+   return PTR_ERR(mailbox);
+
+   memset(mailbox-buf, 0, sizeof(struct mlx4_counter));
+   if_stat_in_mod = counter_index;
+   if (reset)
+   if_stat_in_mod |= MLX4_QUERY_IF_STAT_RESET;
+   err = mlx4_cmd_box(dev, 0, mailbox-dma,
+  if_stat_in_mod, 0,
+  MLX4_CMD_QUERY_IF_STAT,
+  MLX4_CMD_TIME_CLASS_C,
+  MLX4_CMD_NATIVE);
+   if (err) 

[PATCH net-next 12/13] net/core: Add reading VF statistics through the PF netdevice

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

Add ndo_get_vf_stats where the PF retrieves and fills the VFs traffic
statistics. Add rtnl_link_vf_stats64 for passing the VF statistics from
the PF to user-space.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 include/linux/netdevice.h|4 
 include/uapi/linux/if_link.h |   11 +++
 net/core/rtnetlink.c |   12 ++--
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6f5f71f..b1d3b88 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1100,6 +1100,10 @@ struct net_device_ops {
 struct ifla_vf_info *ivf);
int (*ndo_set_vf_link_state)(struct net_device *dev,
 int vf, int 
link_state);
+   int (*ndo_get_vf_stats)(struct net_device *dev,
+   int vf,
+   struct rtnl_link_vf_stats64
+   *vf_stats);
int (*ndo_set_vf_port)(struct net_device *dev,
   int vf,
   struct nlattr *port[]);
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 1737b7a..9c25aeb 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -70,6 +70,16 @@ struct rtnl_link_stats64 {
__u64   tx_compressed;
 };
 
+/* VF statistics structure */
+struct rtnl_link_vf_stats64 {
+   __u64   rx_packets; /* total packets received   */
+   __u64   tx_packets; /* total packets transmitted*/
+   __u64   rx_bytes;   /* total bytes received */
+   __u64   tx_bytes;   /* total bytes transmitted  */
+   __u64   broadcast;  /* broadcast packets received   */
+   __u64   multicast;  /* multicast packets received   */
+};
+
 /* The struct should be in sync with struct ifmap */
 struct rtnl_link_ifmap {
__u64   mem_start;
@@ -482,6 +492,7 @@ enum {
IFLA_VF_RSS_QUERY_EN,   /* RSS Redirection Table and Hash Key query
 * on/off switch
 */
+   IFLA_VF_STATS,  /* network device statistics */
__IFLA_VF_MAX,
 };
 
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 077b6d2..6d7c939 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -819,7 +819,8 @@ static inline int rtnl_vfinfo_size(const struct net_device 
*dev,
 nla_total_size(sizeof(struct ifla_vf_spoofchk)) +
 nla_total_size(sizeof(struct ifla_vf_rate)) +
 nla_total_size(sizeof(struct ifla_vf_link_state)) +
-nla_total_size(sizeof(struct ifla_vf_rss_query_en)));
+nla_total_size(sizeof(struct ifla_vf_rss_query_en)) +
+nla_total_size(sizeof(struct rtnl_link_vf_stats64)));
return size;
} else
return 0;
@@ -1138,6 +1139,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct 
net_device *dev,
struct ifla_vf_spoofchk vf_spoofchk;
struct ifla_vf_link_state vf_linkstate;
struct ifla_vf_rss_query_en vf_rss_query_en;
+   struct rtnl_link_vf_stats64 vf_stats;
 
/*
 * Not all SR-IOV capable drivers support the
@@ -1176,6 +1178,10 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct 
net_device *dev,
nla_nest_cancel(skb, vfinfo);
goto nla_put_failure;
}
+   memset(vf_stats, 0, sizeof(vf_stats));
+   if (dev-netdev_ops-ndo_get_vf_stats)
+   dev-netdev_ops-ndo_get_vf_stats(dev, i,
+ vf_stats);
if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), vf_mac) 
||
nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), 
vf_vlan) ||
nla_put(skb, IFLA_VF_RATE, sizeof(vf_rate),
@@ -1188,7 +1194,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct 
net_device *dev,
vf_linkstate) ||
nla_put(skb, IFLA_VF_RSS_QUERY_EN,
sizeof(vf_rss_query_en),
-   vf_rss_query_en))
+   vf_rss_query_en) ||

Re: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-10 Thread Eric Dumazet
On Wed, 2015-06-10 at 07:38 +, Madalin-Cristian Bucur wrote:
 Hi Eric,
 
 Can you please tell us if this change would be for the better?
 
 I was about to say yes to this request but checked and no other Ethernet 
 driver seems to use the queue trans_start.
 I was able to find your patch net: tx scalability works : trans_start [ 
 http://patchwork.ozlabs.org/patch/27104/ ] but did not find more about this 
 topic.
  

Drivers no longer have to worry about updating trans_start themselves.
Core networking stack handles this.

Check txq_trans_update() done from netdev_start_xmit()


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


[PATCH net-next 04/13] net/mlx4_core: Remove counters table allocation from VF flow

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

Since virtual functions get their counters indices allocation from the PF,
allocate counters indices bitmap only in case the function isn't virtual.

Also, check that the device has counters to allocate before creating the
indices bitmap table.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/net/ethernet/mellanox/mlx4/main.c |   25 ++---
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 9c1b8b0..c3fe49e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2198,6 +2198,9 @@ static int mlx4_init_counters_table(struct mlx4_dev *dev)
if (!(dev-caps.flags  MLX4_DEV_CAP_FLAG_COUNTERS))
return -ENOENT;
 
+   if (!dev-caps.max_counters)
+   return -ENOSPC;
+
nent_pow2 = roundup_pow_of_two(dev-caps.max_counters);
/* reserve last counter index for sink counter */
return mlx4_bitmap_init(priv-counters_bitmap, nent_pow2,
@@ -2210,6 +2213,9 @@ static void mlx4_cleanup_counters_table(struct mlx4_dev 
*dev)
if (!(dev-caps.flags  MLX4_DEV_CAP_FLAG_COUNTERS))
return;
 
+   if (!dev-caps.max_counters)
+   return;
+
mlx4_bitmap_cleanup(mlx4_priv(dev)-counters_bitmap);
 }
 
@@ -2425,10 +2431,12 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
goto err_srq_table_free;
}
 
-   err = mlx4_init_counters_table(dev);
-   if (err  err != -ENOENT) {
-   mlx4_err(dev, Failed to initialize counters table, 
aborting\n);
-   goto err_qp_table_free;
+   if (!mlx4_is_slave(dev)) {
+   err = mlx4_init_counters_table(dev);
+   if (err  err != -ENOENT) {
+   mlx4_err(dev, Failed to initialize counters table, 
aborting\n);
+   goto err_qp_table_free;
+   }
}
 
if (!mlx4_is_slave(dev)) {
@@ -2470,7 +2478,8 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
return 0;
 
 err_counters_table_free:
-   mlx4_cleanup_counters_table(dev);
+   if (!mlx4_is_slave(dev))
+   mlx4_cleanup_counters_table(dev);
 
 err_qp_table_free:
mlx4_cleanup_qp_table(dev);
@@ -3201,7 +3210,8 @@ err_port:
for (--port; port = 1; --port)
mlx4_cleanup_port_info(priv-port[port]);
 
-   mlx4_cleanup_counters_table(dev);
+   if (!mlx4_is_slave(dev))
+   mlx4_cleanup_counters_table(dev);
mlx4_cleanup_qp_table(dev);
mlx4_cleanup_srq_table(dev);
mlx4_cleanup_cq_table(dev);
@@ -3499,7 +3509,8 @@ static void mlx4_unload_one(struct pci_dev *pdev)
mlx4_free_resource_tracker(dev,
   RES_TR_FREE_SLAVES_ONLY);
 
-   mlx4_cleanup_counters_table(dev);
+   if (!mlx4_is_slave(dev))
+   mlx4_cleanup_counters_table(dev);
mlx4_cleanup_qp_table(dev);
mlx4_cleanup_srq_table(dev);
mlx4_cleanup_cq_table(dev);
-- 
1.7.1

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


[PATCH net-next 01/13] net/mlx4_core: Check before cleaning counters bitmap

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

If counters are not supported by the device. The indices bitmap table is not
allocated during initialization. Add the symmetrical check before cleaning
the counters bitmap table or freeing a counter.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/net/ethernet/mellanox/mlx4/main.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 0dbd704..f95466f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2204,6 +2204,9 @@ static int mlx4_init_counters_table(struct mlx4_dev *dev)
 
 static void mlx4_cleanup_counters_table(struct mlx4_dev *dev)
 {
+   if (!(dev-caps.flags  MLX4_DEV_CAP_FLAG_COUNTERS))
+   return;
+
mlx4_bitmap_cleanup(mlx4_priv(dev)-counters_bitmap);
 }
 
@@ -2241,6 +2244,9 @@ EXPORT_SYMBOL_GPL(mlx4_counter_alloc);
 
 void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
 {
+   if (!(dev-caps.flags  MLX4_DEV_CAP_FLAG_COUNTERS))
+   return;
+
mlx4_bitmap_free(mlx4_priv(dev)-counters_bitmap, idx, MLX4_USE_RR);
return;
 }
-- 
1.7.1

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


[PATCH net-next 06/13] net/mlx4_core: Add port attribute when tracking counters

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

Counter will get its port attribute within the resource tracker when
the first QP attached to it is modified to RTR. If a QP is counter-less,
an attempt to create a new counter with assigned port will be made.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 .../net/ethernet/mellanox/mlx4/resource_tracker.c  |   90 +++-
 1 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c 
b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 802eb2a..73db584 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -723,6 +723,9 @@ static void update_gid(struct mlx4_dev *dev, struct 
mlx4_cmd_mailbox *inbox,
}
 }
 
+static int handle_counter(struct mlx4_dev *dev, struct mlx4_qp_context *qpc,
+ u8 slave, int port);
+
 static int update_vport_qp_param(struct mlx4_dev *dev,
 struct mlx4_cmd_mailbox *inbox,
 u8 slave, u32 qpn)
@@ -738,6 +741,10 @@ static int update_vport_qp_param(struct mlx4_dev *dev,
vp_oper = priv-mfunc.master.vf_oper[slave].vport[port];
qp_type = (be32_to_cpu(qpc-flags)  16)  0xff;
 
+   err = handle_counter(dev, qpc, slave, port);
+   if (err)
+   goto out;
+
if (MLX4_VGT != vp_oper-state.default_vlan) {
/* the reserved QPs (special, proxy, tunnel)
 * do not operate over vlans
@@ -882,6 +889,83 @@ static void put_res(struct mlx4_dev *dev, int slave, u64 
res_id,
spin_unlock_irq(mlx4_tlock(dev));
 }
 
+static int counter_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd,
+u64 in_param, u64 *out_param, int port);
+
+static int handle_existing_counter(struct mlx4_dev *dev, u8 slave, int port,
+  int counter_index)
+{
+   struct res_common *r;
+   struct res_counter *counter;
+   int ret = 0;
+
+   if (counter_index == MLX4_SINK_COUNTER_INDEX(dev))
+   return ret;
+
+   spin_lock_irq(mlx4_tlock(dev));
+   r = find_res(dev, counter_index, RES_COUNTER);
+   if (!r || r-owner != slave)
+   ret = -EINVAL;
+   counter = container_of(r, struct res_counter, com);
+   if (!counter-port)
+   counter-port = port;
+
+   spin_unlock_irq(mlx4_tlock(dev));
+   return ret;
+}
+
+static int handle_unexisting_counter(struct mlx4_dev *dev,
+struct mlx4_qp_context *qpc, u8 slave,
+int port)
+{
+   struct mlx4_priv *priv = mlx4_priv(dev);
+   struct mlx4_resource_tracker *tracker = priv-mfunc.master.res_tracker;
+   struct res_common *tmp;
+   struct res_counter *counter;
+   u64 counter_idx = MLX4_SINK_COUNTER_INDEX(dev);
+   int err = 0;
+
+   spin_lock_irq(mlx4_tlock(dev));
+   list_for_each_entry(tmp,
+   tracker-slave_list[slave].res_list[RES_COUNTER],
+   list) {
+   counter = container_of(tmp, struct res_counter, com);
+   if (port == counter-port) {
+   qpc-pri_path.counter_index  = counter-com.res_id;
+   spin_unlock_irq(mlx4_tlock(dev));
+   return 0;
+   }
+   }
+   spin_unlock_irq(mlx4_tlock(dev));
+
+   /* No existing counter, need to allocate a new counter */
+   err = counter_alloc_res(dev, slave, RES_OP_RESERVE, 0, 0, counter_idx,
+   port);
+   if (err == -ENOENT) {
+   err = 0;
+   } else if (err  err != -ENOSPC) {
+   mlx4_err(dev, %s: failed to create new counter for slave %d 
err %d\n,
+__func__, slave, err);
+   } else {
+   qpc-pri_path.counter_index = counter_idx;
+   mlx4_dbg(dev, %s: alloc new counter for slave %d index %d\n,
+__func__, slave, qpc-pri_path.counter_index);
+   err = 0;
+   }
+
+   return err;
+}
+
+static int handle_counter(struct mlx4_dev *dev, struct mlx4_qp_context *qpc,
+ u8 slave, int port)
+{
+   if (qpc-pri_path.counter_index != MLX4_SINK_COUNTER_INDEX(dev))
+   return handle_existing_counter(dev, slave, port,
+  qpc-pri_path.counter_index);
+
+   return handle_unexisting_counter(dev, qpc, slave, port);
+}
+
 static struct res_common *alloc_qp_tr(int id)
 {
struct res_qp *ret;
@@ -2025,7 +2109,7 @@ static int vlan_alloc_res(struct mlx4_dev *dev, int 
slave, int op, int cmd,
 }
 
 static int counter_alloc_res(struct mlx4_dev *dev, int slave, int 

[PATCH net-next 00/13] mlx4 driver update (+ new VF ndo)

2015-06-10 Thread Or Gerlitz
Hi Dave,

This series from Eran and Hadar is further dealing with traffic 
counters in the mlx4 driver, this time mostly around SRIOV.

We added a new ndo to read the VF counters through the PF netdev 
netlink infrastructure plus mlx4 implementation for that ndo.

Or.

Eran Ben Elisha (13):
  net/mlx4_core: Check before cleaning counters bitmap
  net/mlx4_core: Reset counters data when freed
  net/mlx4_core: Add sink counter
  net/mlx4_core: Remove counters table allocation from VF flow
  net/mlx4_core: Adjust counter grant policy in the resource tracker
  net/mlx4_core: Add port attribute when tracking counters
  net/mlx4_core: Allocate default counter per port
  IB/mlx4: Add RoCE/IB dedicated counters
  IB/mlx4: Set VF to read from QP counters
  net/mlx4_core: Add helper to query counters
  net/mlx4_en: Show PF own statistics via ethtool
  net/core: Add reading VF statistics through the PF netdevice
  net/mlx4_en: Support ndo_get_vf_stats

 drivers/infiniband/hw/mlx4/mad.c   |   38 ++---
 drivers/infiniband/hw/mlx4/main.c  |   43 --
 drivers/infiniband/hw/mlx4/mlx4_ib.h   |7 +-
 drivers/infiniband/hw/mlx4/qp.c|7 +-
 drivers/net/ethernet/mellanox/mlx4/cmd.c   |   86 ++
 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c|   17 ++
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |   23 +++-
 drivers/net/ethernet/mellanox/mlx4/en_port.c   |   24 +++-
 drivers/net/ethernet/mellanox/mlx4/en_resources.c  |2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c  |  134 ++--
 drivers/net/ethernet/mellanox/mlx4/mlx4.h  |5 +
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   |2 +
 drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h|   11 +-
 .../net/ethernet/mellanox/mlx4/resource_tracker.c  |  173 +++-
 include/linux/mlx4/cmd.h   |6 +
 include/linux/mlx4/device.h|   10 +
 include/linux/netdevice.h  |4 +
 include/uapi/linux/if_link.h   |   11 ++
 net/core/rtnetlink.c   |   12 +-
 19 files changed, 545 insertions(+), 70 deletions(-)

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


[PATCH net-next 05/13] net/mlx4_core: Adjust counter grant policy in the resource tracker

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

Each physical function has a guarantee of two counters per port, one
for a default counter and one for the IB driver.

Each virtual function has a guarantee of one counter per port.
All other counters are free and can be obtained on demand.

This is a preparation step for supporting a get_vf_stats ndo call,
so we can promise a counter for every VF in order to collect their
statistics from the PF context.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 .../net/ethernet/mellanox/mlx4/resource_tracker.c  |   35 +--
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c 
b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index ab48386..802eb2a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -48,6 +48,8 @@
 #include fw.h
 
 #define MLX4_MAC_VALID (1ull  63)
+#define MLX4_PF_COUNTERS_PER_PORT  2
+#define MLX4_VF_COUNTERS_PER_PORT  1
 
 struct mac_res {
struct list_head list;
@@ -459,11 +461,21 @@ void mlx4_init_quotas(struct mlx4_dev *dev)
dev-quotas.mpt =
priv-mfunc.master.res_tracker.res_alloc[RES_MPT].quota[pf];
 }
+
+static int get_max_gauranteed_vfs_counter(struct mlx4_dev *dev)
+{
+   /* reduce the sink counter */
+   return (dev-caps.max_counters - 1 -
+   (MLX4_PF_COUNTERS_PER_PORT * MLX4_MAX_PORTS))
+   / MLX4_MAX_PORTS;
+}
+
 int mlx4_init_resource_tracker(struct mlx4_dev *dev)
 {
struct mlx4_priv *priv = mlx4_priv(dev);
int i, j;
int t;
+   int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev);
 
priv-mfunc.master.res_tracker.slave_list =
kzalloc(dev-num_slaves * sizeof(struct slave_list),
@@ -499,6 +511,9 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
res_alloc-allocated = kzalloc((dev-persist-
num_vfs + 1) *
   sizeof(int), GFP_KERNEL);
+   /* Reduce the sink counter */
+   if (i == RES_COUNTER)
+   res_alloc-res_free = dev-caps.max_counters - 1;
 
if (!res_alloc-quota || !res_alloc-guaranteed ||
!res_alloc-allocated)
@@ -577,9 +592,17 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
break;
case RES_COUNTER:
res_alloc-quota[t] = dev-caps.max_counters;
-   res_alloc-guaranteed[t] = 0;
if (t == mlx4_master_func_num(dev))
-   res_alloc-res_free = 
res_alloc-quota[t];
+   res_alloc-guaranteed[t] =
+   MLX4_PF_COUNTERS_PER_PORT *
+   MLX4_MAX_PORTS;
+   else if (t = max_vfs_guarantee_counter)
+   res_alloc-guaranteed[t] =
+   MLX4_VF_COUNTERS_PER_PORT *
+   MLX4_MAX_PORTS;
+   else
+   res_alloc-guaranteed[t] = 0;
+   res_alloc-res_free -= res_alloc-guaranteed[t];
break;
default:
break;
@@ -952,7 +975,7 @@ static struct res_common *alloc_srq_tr(int id)
return ret-com;
 }
 
-static struct res_common *alloc_counter_tr(int id)
+static struct res_common *alloc_counter_tr(int id, int port)
 {
struct res_counter *ret;
 
@@ -962,6 +985,7 @@ static struct res_common *alloc_counter_tr(int id)
 
ret-com.res_id = id;
ret-com.state = RES_COUNTER_ALLOCATED;
+   ret-port = port;
 
return ret-com;
 }
@@ -1022,7 +1046,7 @@ static struct res_common *alloc_tr(u64 id, enum 
mlx4_resource type, int slave,
pr_err(implementation missing\n);
return NULL;
case RES_COUNTER:
-   ret = alloc_counter_tr(id);
+   ret = alloc_counter_tr(id, extra);
break;
case RES_XRCD:
ret = alloc_xrcdn_tr(id);
@@ -2335,6 +2359,9 @@ static int counter_free_res(struct mlx4_dev *dev, int 
slave, int op, int cmd,
return -EINVAL;
 
index = get_param_l(in_param);
+   if (index == MLX4_SINK_COUNTER_INDEX(dev))
+   return 0;
+
err = rem_res_range(dev, slave, index, 1, RES_COUNTER, 0);
if (err)
return err;
-- 
1.7.1

--
To unsubscribe 

[PATCH net-next 02/13] net/mlx4_core: Reset counters data when freed

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

Add resetting the counter data to the free counter flow, so the counter's
data won't be accessible anymore if querying the counter. Also, on next
counter allocation (to another VM for example), it will be fresh and clear.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/net/ethernet/mellanox/mlx4/main.c |   21 +
 drivers/net/ethernet/mellanox/mlx4/mlx4.h |2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index f95466f..11f5568 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2242,11 +2242,32 @@ int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx)
 }
 EXPORT_SYMBOL_GPL(mlx4_counter_alloc);
 
+static int __mlx4_clear_if_stat(struct mlx4_dev *dev,
+   u8 counter_index)
+{
+   struct mlx4_cmd_mailbox *if_stat_mailbox;
+   int err;
+   u32 if_stat_in_mod = (counter_index  0xff) | MLX4_QUERY_IF_STAT_RESET;
+
+   if_stat_mailbox = mlx4_alloc_cmd_mailbox(dev);
+   if (IS_ERR(if_stat_mailbox))
+   return PTR_ERR(if_stat_mailbox);
+
+   err = mlx4_cmd_box(dev, 0, if_stat_mailbox-dma, if_stat_in_mod, 0,
+  MLX4_CMD_QUERY_IF_STAT, MLX4_CMD_TIME_CLASS_C,
+  MLX4_CMD_NATIVE);
+
+   mlx4_free_cmd_mailbox(dev, if_stat_mailbox);
+   return err;
+}
+
 void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
 {
if (!(dev-caps.flags  MLX4_DEV_CAP_FLAG_COUNTERS))
return;
 
+   __mlx4_clear_if_stat(dev, idx);
+
mlx4_bitmap_free(mlx4_priv(dev)-counters_bitmap, idx, MLX4_USE_RR);
return;
 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h 
b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index f424900..8d2d359 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -65,6 +65,8 @@
 
 #define INIT_HCA_TPT_MW_ENABLE  (1  7)
 
+#define MLX4_QUERY_IF_STAT_RESET   BIT(31)
+
 enum {
MLX4_HCR_BASE   = 0x80680,
MLX4_HCR_SIZE   = 0x0001c,
-- 
1.7.1

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


[PATCH net-next 13/13] net/mlx4_en: Support ndo_get_vf_stats

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

Implement function to gather vf statistics through the PF. The function
is provided in the master net device ops.

All VFs counters are stored in list per slave, run over the slave's list
and collect all statistics.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/net/ethernet/mellanox/mlx4/cmd.c   |   29 
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |   10 
 drivers/net/ethernet/mellanox/mlx4/mlx4.h  |2 +
 .../net/ethernet/mellanox/mlx4/resource_tracker.c  |   48 
 include/linux/mlx4/cmd.h   |3 +
 5 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c 
b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 4495bbd..c438e56 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -3223,6 +3223,35 @@ if_stat_out:
 }
 EXPORT_SYMBOL_GPL(mlx4_get_counter_stats);
 
+int mlx4_get_vf_stats(struct mlx4_dev *dev, int port, int vf_idx,
+ struct rtnl_link_vf_stats64 *vf_stats)
+{
+   struct mlx4_counter tmp_vf_stats;
+   int slave;
+   int err = 0;
+
+   if (!vf_stats)
+   return -EINVAL;
+
+   if (!mlx4_is_master(dev))
+   return -EPROTONOSUPPORT;
+
+   slave = mlx4_get_slave_indx(dev, vf_idx);
+   if (slave  0)
+   return -EINVAL;
+
+   err = mlx4_calc_vf_counters(dev, slave, port, tmp_vf_stats);
+   if (!err  tmp_vf_stats.counter_mode == 0) {
+   vf_stats-rx_packets = be64_to_cpu(tmp_vf_stats.rx_frames);
+   vf_stats-tx_packets = be64_to_cpu(tmp_vf_stats.tx_frames);
+   vf_stats-rx_bytes = be64_to_cpu(tmp_vf_stats.rx_bytes);
+   vf_stats-tx_bytes = be64_to_cpu(tmp_vf_stats.tx_bytes);
+   }
+
+   return err;
+}
+EXPORT_SYMBOL_GPL(mlx4_get_vf_stats);
+
 int mlx4_vf_smi_enabled(struct mlx4_dev *dev, int slave, int port)
 {
struct mlx4_priv *priv = mlx4_priv(dev);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c 
b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index f9142f2..6b816aa 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2292,6 +2292,15 @@ static int mlx4_en_set_vf_link_state(struct net_device 
*dev, int vf, int link_st
return mlx4_set_vf_link_state(mdev-dev, en_priv-port, vf, link_state);
 }
 
+static int mlx4_en_get_vf_stats(struct net_device *dev, int vf,
+   struct rtnl_link_vf_stats64 *vf_stats)
+{
+   struct mlx4_en_priv *en_priv = netdev_priv(dev);
+   struct mlx4_en_dev *mdev = en_priv-mdev;
+
+   return mlx4_get_vf_stats(mdev-dev, en_priv-port, vf, vf_stats);
+}
+
 #define PORT_ID_BYTE_LEN 8
 static int mlx4_en_get_phys_port_id(struct net_device *dev,
struct netdev_phys_item_id *ppid)
@@ -2489,6 +2498,7 @@ static const struct net_device_ops mlx4_netdev_ops_master 
= {
.ndo_set_vf_rate= mlx4_en_set_vf_rate,
.ndo_set_vf_spoofchk= mlx4_en_set_vf_spoofchk,
.ndo_set_vf_link_state  = mlx4_en_set_vf_link_state,
+   .ndo_get_vf_stats   = mlx4_en_get_vf_stats,
.ndo_get_vf_config  = mlx4_en_get_vf_config,
 #ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller= mlx4_en_netpoll,
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h 
b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index e9e94bc..a092c5c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -1010,6 +1010,8 @@ int __mlx4_write_mtt(struct mlx4_dev *dev, struct 
mlx4_mtt *mtt,
 int start_index, int npages, u64 *page_list);
 int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx);
 void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx);
+int mlx4_calc_vf_counters(struct mlx4_dev *dev, int slave, int port,
+ struct mlx4_counter *data);
 int __mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn);
 void __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn);
 
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c 
b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 73db584..731423c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -46,6 +46,7 @@
 
 #include mlx4.h
 #include fw.h
+#include mlx4_stats.h
 
 #define MLX4_MAC_VALID (1ull  63)
 #define MLX4_PF_COUNTERS_PER_PORT  2
@@ -1147,6 +1148,53 @@ static struct res_common *alloc_tr(u64 id, enum 
mlx4_resource type, int slave,
return ret;
 }
 
+int mlx4_calc_vf_counters(struct mlx4_dev *dev, int slave, int port,
+ struct mlx4_counter *data)
+{
+   struct 

[PATCH net-next 03/13] net/mlx4_core: Add sink counter

2015-06-10 Thread Or Gerlitz
From: Eran Ben Elisha era...@mellanox.com

Reserve the last valid counter index for sink counter, when a
new counter cannot be allocated, the driver will use this counter.

In order to avoid allocating this counter on any other flow, fix the
indices bitmap allocation range, and reserve the sink counter index.

Add macro for the sink counter index and replace all appearences of the
index with the macro.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/infiniband/hw/mlx4/qp.c   |3 ++-
 drivers/net/ethernet/mellanox/mlx4/en_resources.c |2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c |   11 +++
 include/linux/mlx4/device.h   |1 +
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 02fc91c..c7d916f 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1544,7 +1544,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
dev-counters[qp-port - 1];
optpar |= MLX4_QP_OPTPAR_COUNTER_INDEX;
} else
-   context-pri_path.counter_index = 0xff;
+   context-pri_path.counter_index =
+   MLX4_SINK_COUNTER_INDEX(dev-dev);
 
if (qp-flags  MLX4_IB_QP_NETIF) {
mlx4_ib_steer_qp_reg(dev, qp, 1);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_resources.c 
b/drivers/net/ethernet/mellanox/mlx4/en_resources.c
index 34f2fdf..97bcb91 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_resources.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_resources.c
@@ -66,7 +66,7 @@ void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int 
size, int stride,
context-pri_path.sched_queue |= user_prio  3;
context-pri_path.feup = MLX4_FEUP_FORCE_ETH_UP;
}
-   context-pri_path.counter_index = 0xff;
+   context-pri_path.counter_index = MLX4_SINK_COUNTER_INDEX(mdev-dev);
context-cqn_send = cpu_to_be32(cqn);
context-cqn_recv = cpu_to_be32(cqn);
context-db_rec_addr = cpu_to_be64(priv-res.db.dma  2);
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 11f5568..9c1b8b0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -479,7 +479,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct 
mlx4_dev_cap *dev_cap)
}
}
 
-   dev-caps.max_counters = 1  ilog2(dev_cap-max_counters);
+   dev-caps.max_counters = dev_cap-max_counters;
 
dev-caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap-reserved_qps;
dev-caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] =
@@ -2193,13 +2193,16 @@ err_free_icm:
 static int mlx4_init_counters_table(struct mlx4_dev *dev)
 {
struct mlx4_priv *priv = mlx4_priv(dev);
-   int nent;
+   int nent_pow2;
 
if (!(dev-caps.flags  MLX4_DEV_CAP_FLAG_COUNTERS))
return -ENOENT;
 
-   nent = dev-caps.max_counters;
-   return mlx4_bitmap_init(priv-counters_bitmap, nent, nent - 1, 0, 0);
+   nent_pow2 = roundup_pow_of_two(dev-caps.max_counters);
+   /* reserve last counter index for sink counter */
+   return mlx4_bitmap_init(priv-counters_bitmap, nent_pow2,
+   nent_pow2 - 1, 0,
+   nent_pow2 - dev-caps.max_counters + 1);
 }
 
 static void mlx4_cleanup_counters_table(struct mlx4_dev *dev)
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index ad31e47..312c504 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -957,6 +957,7 @@ struct mlx4_mad_ifc {
((dev)-caps.flags  MLX4_DEV_CAP_FLAG_IBOE))
 
 #define MLX4_INVALID_SLAVE_ID  0xFF
+#define MLX4_SINK_COUNTER_INDEX(dev)   (dev-caps.max_counters - 1)
 
 void handle_port_mgmt_change_event(struct work_struct *work);
 
-- 
1.7.1

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


RE: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-10 Thread Jianhua Xie


 -Original Message-
 From: Linuxppc-dev [mailto:linuxppc-dev-
 bounces+jianhua.xie=freescale@lists.ozlabs.org] On Behalf Of Madalin
 Bucur
 Sent: Wednesday, April 29, 2015 10:57 PM
 To: netdev@vger.kernel.org; linuxppc-...@lists.ozlabs.org
 Cc: linux-ker...@vger.kernel.org; Bucur Madalin-Cristian-B32716
 Subject: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet
 
 This introduces the Freescale Data Path Acceleration Architecture
 (DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
 BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
 the Freescale DPAA QorIQ platforms.
 
Snip..

 +
 + if (unlikely(dpa_xmit(priv, percpu_stats, queue_mapping, fd)  0))
 + goto xmit_failed;
 +
 + net_dev-trans_start = jiffies;

It is probably better to use netdev_queue-trans_start to instead of 
net_dev-trans_start on SMP.

Best Regards,
Jianhua

 + return NETDEV_TX_OK;
 +
 +xmit_failed:
 + if (fd.cmd  FM_FD_CMD_FCO) {
 + (*countptr)--;
 + dpa_fd_release(net_dev, fd);
 + percpu_stats-tx_errors++;
 + return NETDEV_TX_OK;
 + }
 + _dpa_cleanup_tx_fd(priv, fd);
 + percpu_stats-tx_errors++;
 + dev_kfree_skb(skb);
 + return NETDEV_TX_OK;
 +}
 --
 1.7.11.7
 
 ___
 Linuxppc-dev mailing list
 linuxppc-...@lists.ozlabs.org
 https://lists.ozlabs.org/listinfo/linuxppc-dev
N�r��yb�X��ǧv�^�)޺{.n�+���z�^�)w*jg����ݢj/���z�ޖ��2�ޙ�)ߡ�a�����G���h��j:+v���w��٥

[PATCH net-next 2/3 v2] net: ipv4 sysctl option to ignore routes when nexthop link is down

2015-06-10 Thread Andy Gospodarek
This feature is only enabled with the new per-interface or ipv4 global
sysctls called 'ignore_routes_with_linkdown'.

net.ipv4.conf.all.ignore_routes_with_linkdown = 0
net.ipv4.conf.default.ignore_routes_with_linkdown = 0
net.ipv4.conf.lo.ignore_routes_with_linkdown = 0
...

When the above sysctls are set, will report to userspace that a route is
dead and will no longer resolve to this nexthop when performing a fib
lookup.  This will signal to userspace that the route will not be
selected.  The signalling of a RTNH_F_DEAD is only passed to userspace
if the sysctl is enabled and link is down.  This was done as without it the
netlink listeners would have no idea whether or not a nexthop would be
selected.   The kernel only sets RTNH_F_DEAD internally if the inteface has
IFF_UP cleared.

With the new sysctl set, the following behavior can be observed
(interface p8p1 is link-down):

# ip route show 
default via 10.0.5.2 dev p9p1 
10.0.5.0/24 dev p9p1  proto kernel  scope link  src 10.0.5.15 
70.0.0.0/24 dev p7p1  proto kernel  scope link  src 70.0.0.1 
80.0.0.0/24 dev p8p1  proto kernel  scope link  src 80.0.0.1 dead linkdown
90.0.0.0/24 via 80.0.0.2 dev p8p1  metric 1 dead linkdown
90.0.0.0/24 via 70.0.0.2 dev p7p1  metric 2 
# ip route get 90.0.0.1 
90.0.0.1 via 70.0.0.2 dev p7p1  src 70.0.0.1 
cache 
# ip route get 80.0.0.1 
local 80.0.0.1 dev lo  src 80.0.0.1 
cache local 
# ip route get 80.0.0.2
80.0.0.2 via 10.0.5.2 dev p9p1  src 10.0.5.15 
cache 

While the route does remain in the table (so it can be modified if
needed rather than being wiped away as it would be if IFF_UP was
cleared), the proper next-hop is chosen automatically when the link is
down.  Now interface p8p1 is linked-up:

# ip route show 
default via 10.0.5.2 dev p9p1 
10.0.5.0/24 dev p9p1  proto kernel  scope link  src 10.0.5.15 
70.0.0.0/24 dev p7p1  proto kernel  scope link  src 70.0.0.1 
80.0.0.0/24 dev p8p1  proto kernel  scope link  src 80.0.0.1 
90.0.0.0/24 via 80.0.0.2 dev p8p1  metric 1 
90.0.0.0/24 via 70.0.0.2 dev p7p1  metric 2 
192.168.56.0/24 dev p2p1  proto kernel  scope link  src 192.168.56.2 
# ip route get 90.0.0.1 
90.0.0.1 via 80.0.0.2 dev p8p1  src 80.0.0.1 
cache 
# ip route get 80.0.0.1 
local 80.0.0.1 dev lo  src 80.0.0.1 
cache local 
# ip route get 80.0.0.2
80.0.0.2 dev p8p1  src 80.0.0.1 
cache 

and the output changes to what one would expect.

If the sysctl is not set, the following output would be expected when
p8p1 is down:

# ip route show 
default via 10.0.5.2 dev p9p1 
10.0.5.0/24 dev p9p1  proto kernel  scope link  src 10.0.5.15 
70.0.0.0/24 dev p7p1  proto kernel  scope link  src 70.0.0.1 
80.0.0.0/24 dev p8p1  proto kernel  scope link  src 80.0.0.1 linkdown
90.0.0.0/24 via 80.0.0.2 dev p8p1  metric 1 linkdown
90.0.0.0/24 via 70.0.0.2 dev p7p1  metric 2 

Since the dead flag does not appear, there should be no expectation that
the kernel would skip using this route due to link being down.

v2: Split kernel changes into 2 patches, this actually makes a
behavioral change if the sysctl is set.  Also took suggestion from Alex
to simplify code by only checking sysctl during fib lookup and
suggestion from Scott to add a per-interface sysctl.

Signed-off-by: Andy Gospodarek go...@cumulusnetworks.com
Signed-off-by: Dinesh Dutt dd...@cumulusnetworks.com
---
 include/linux/inetdevice.h|  3 +++
 include/net/fib_rules.h   |  3 ++-
 include/net/ip_fib.h  | 17 ++---
 include/uapi/linux/ip.h   |  1 +
 include/uapi/linux/sysctl.h   |  1 +
 kernel/sysctl_binary.c|  1 +
 net/ipv4/devinet.c|  2 ++
 net/ipv4/fib_frontend.c   |  6 +++---
 net/ipv4/fib_rules.c  |  5 +++--
 net/ipv4/fib_semantics.c  | 28 ++--
 net/ipv4/fib_trie.c   |  7 +++
 net/ipv4/netfilter/ipt_rpfilter.c |  2 +-
 net/ipv4/route.c  | 10 +-
 13 files changed, 61 insertions(+), 25 deletions(-)

diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index 0a21fbe..a4328ce 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -120,6 +120,9 @@ static inline void ipv4_devconf_setall(struct in_device 
*in_dev)
 || (!IN_DEV_FORWARD(in_dev)  \
  IN_DEV_ORCONF((in_dev), ACCEPT_REDIRECTS)))
 
+#define IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) \
+   IN_DEV_CONF_GET((in_dev), IGNORE_ROUTES_WITH_LINKDOWN)
+
 #define IN_DEV_ARPFILTER(in_dev)   IN_DEV_ORCONF((in_dev), ARPFILTER)
 #define IN_DEV_ARP_ACCEPT(in_dev)  IN_DEV_ORCONF((in_dev), ARP_ACCEPT)
 #define IN_DEV_ARP_ANNOUNCE(in_dev)IN_DEV_MAXCONF((in_dev), ARP_ANNOUNCE)
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 6d67383..903a55e 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -36,7 +36,8 @@ struct fib_lookup_arg {
void*result;
struct fib_rule *rule;
int

[PATCH net-next 0/3 v2] changes to make ipv4 routing table aware of next-hop link status

2015-06-10 Thread Andy Gospodarek
This series adds the ability to have the Linux kernel track whether or
not a particular route should be used based on the link-status of the
interface associated with the next-hop.

Before this patch any link-failure on an interface that was serving as a
gateway for some systems could result in those systems being isolated
from the rest of the network as the stack would continue to attempt to
send frames out of an interface that is actually linked-down.  When the
kernel is responsible for all forwarding, it should also be responsible
for taking action when the traffic can no longer be forwarded -- there
is no real need to outsource link-monitoring to userspace anymore.

This feature is only enabled with the new per-interface or ipv4 global
sysctls called 'ignore_routes_with_linkdown'.

net.ipv4.conf.all.ignore_routes_with_linkdown = 0
net.ipv4.conf.default.ignore_routes_with_linkdown = 0
net.ipv4.conf.lo.ignore_routes_with_linkdown = 0
...

When the above sysctls are set, the kernel will not only report to
userspace that the link is down, but it will also report to userspace
that a route is dead.  This will signal to userspace that the route will
not be selected.

With the new sysctls set, the following behavior can be observed
(interface p8p1 is link-down):

# ip route show 
default via 10.0.5.2 dev p9p1 
10.0.5.0/24 dev p9p1  proto kernel  scope link  src 10.0.5.15 
70.0.0.0/24 dev p7p1  proto kernel  scope link  src 70.0.0.1 
80.0.0.0/24 dev p8p1  proto kernel  scope link  src 80.0.0.1 dead linkdown
90.0.0.0/24 via 80.0.0.2 dev p8p1  metric 1 dead linkdown
90.0.0.0/24 via 70.0.0.2 dev p7p1  metric 2 
# ip route get 90.0.0.1 
90.0.0.1 via 70.0.0.2 dev p7p1  src 70.0.0.1 
cache 
# ip route get 80.0.0.1 
local 80.0.0.1 dev lo  src 80.0.0.1 
cache local 
# ip route get 80.0.0.2
80.0.0.2 via 10.0.5.2 dev p9p1  src 10.0.5.15 
cache 

While the route does remain in the table (so it can be modified if
needed rather than being wiped away as it would be if IFF_UP was
cleared), the proper next-hop is chosen automatically when the link is
down.  Now interface p8p1 is linked-up:

# ip route show 
default via 10.0.5.2 dev p9p1 
10.0.5.0/24 dev p9p1  proto kernel  scope link  src 10.0.5.15 
70.0.0.0/24 dev p7p1  proto kernel  scope link  src 70.0.0.1 
80.0.0.0/24 dev p8p1  proto kernel  scope link  src 80.0.0.1 
90.0.0.0/24 via 80.0.0.2 dev p8p1  metric 1 
90.0.0.0/24 via 70.0.0.2 dev p7p1  metric 2 
192.168.56.0/24 dev p2p1  proto kernel  scope link  src 192.168.56.2 
# ip route get 90.0.0.1 
90.0.0.1 via 80.0.0.2 dev p8p1  src 80.0.0.1 
cache 
# ip route get 80.0.0.1 
local 80.0.0.1 dev lo  src 80.0.0.1 
cache local 
# ip route get 80.0.0.2
80.0.0.2 dev p8p1  src 80.0.0.1 
cache 

and the output changes to what one would expect.

If the global or interface sysctl is not set, the following output would be
expected when p8p1 is down:

# ip route show 
default via 10.0.5.2 dev p9p1 
10.0.5.0/24 dev p9p1  proto kernel  scope link  src 10.0.5.15 
70.0.0.0/24 dev p7p1  proto kernel  scope link  src 70.0.0.1 
80.0.0.0/24 dev p8p1  proto kernel  scope link  src 80.0.0.1 linkdown
90.0.0.0/24 via 80.0.0.2 dev p8p1  metric 1 linkdown
90.0.0.0/24 via 70.0.0.2 dev p7p1  metric 2 

If the dead flag does not appear there should be no expectation that the
kernel would skip using this route due to link being down.

v2: Split kernel changes into 2 patches: first to add linkdown flag and
second to add new sysctl settings.  Also took suggestion from Alex to
simplify code by only checking sysctl during fib lookup and suggestion
from Scott to add a per-interface sysctl.  Added iproute2 patch to
recognize and print linkdown flag.

Though there were some that preferred not to have a configuration option
and to make this behavior the default when it was discussed in Ottawa
earlier this year since it was time to do this.  I wanted to propose
the config option to preserve the current behavior for those that desire
it.  I'll happily remove it if Dave and Linus approve.

An IPv6 implementation is also needed (DECnet too!), but I wanted to start with
the IPv4 implementation to get people comfortable with the idea before moving
forward.  If this is accepted the IPv6 implementation can be posted shortly.

There was also a request for switchdev support for this, but that will be
posted as a followup as switchdev does not currently handle dead
next-hops in a multi-path case and I felt that infra needed to be added
first.

FWIW, we have been running the original version of this series with a
global sysctl and our customers have been happily using a backported
version for IPv4 and IPv6 for 6 months.

Andy Gospodarek (3):
  net: track link-status of ipv4 nexthops
  net: ipv4 sysctl option to ignore routes when nexthop link is down
  iproute2: add support to print 'linkdown' nexthop flag

 include/linux/inetdevice.h|  3 ++
 include/net/fib_rules.h   |  3 +-
 include/net/ip_fib.h  | 21 +-
 

[PATCH iproute2 3/3 v2] add support to print 'linkdown' nexthop flag

2015-06-10 Thread Andy Gospodarek
Signed-off-by: Andy Gospodaerk go...@cumulusnetworks.com
Signed-off-by: Dinesh Dutt dd...@cumulusnetworks.com

---
 ip/iproute.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/ip/iproute.c b/ip/iproute.c
index 3795baf..3369c49 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -451,6 +451,8 @@ int print_route(const struct sockaddr_nl *who, struct 
nlmsghdr *n, void *arg)
fprintf(fp, offload );
if (r-rtm_flags  RTM_F_NOTIFY)
fprintf(fp, notify );
+   if (r-rtm_flags  RTNH_F_LINKDOWN)
+   fprintf(fp, linkdown );
if (tb[RTA_MARK]) {
unsigned int mark = *(unsigned int*)RTA_DATA(tb[RTA_MARK]);
if (mark) {
@@ -670,6 +672,8 @@ int print_route(const struct sockaddr_nl *who, struct 
nlmsghdr *n, void *arg)
fprintf(fp,  onlink);
if (nh-rtnh_flags  RTNH_F_PERVASIVE)
fprintf(fp,  pervasive);
+   if (nh-rtnh_flags  RTNH_F_LINKDOWN)
+   fprintf(fp,  linkdown);
len -= NLMSG_ALIGN(nh-rtnh_len);
nh = RTNH_NEXT(nh);
}
-- 
1.9.3

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


[PATCH net-next 1/3 v2] net: track link-status of ipv4 nexthops

2015-06-10 Thread Andy Gospodarek
Add a fib flag called RTNH_F_LINKDOWN to any ipv4 nexthops that are
reachable via an interface where carrier is off.  No action is taken,
but additional flags are passed to userspace to indicate carrier status.

This also includes a cleanup to fib_disable_ip to more clearly indicate
what event made the function call to replace the more cryptic force
option previously used.

v2: Split out kernel functionality into 2 patches, this patch simply sets and
clears new nexthop flag RTNH_F_LINKDOWN.

Signed-off-by: Andy Gospodarek go...@cumulusnetworks.com
Signed-off-by: Dinesh Dutt dd...@cumulusnetworks.com

---
 include/net/ip_fib.h   |  4 +--
 include/uapi/linux/rtnetlink.h |  1 +
 net/ipv4/fib_frontend.c| 26 +++-
 net/ipv4/fib_semantics.c   | 56 --
 4 files changed, 60 insertions(+), 27 deletions(-)

diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 54271ed..d1de1b7 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -305,9 +305,9 @@ void fib_flush_external(struct net *net);
 
 /* Exported by fib_semantics.c */
 int ip_fib_check_default(__be32 gw, struct net_device *dev);
-int fib_sync_down_dev(struct net_device *dev, int force);
+int fib_sync_down_dev(struct net_device *dev, int event);
 int fib_sync_down_addr(struct net *net, __be32 local);
-int fib_sync_up(struct net_device *dev);
+int fib_sync_up(struct net_device *dev, unsigned int nh_flags);
 void fib_select_multipath(struct fib_result *res);
 
 /* Exported by fib_trie.c */
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index 17fb02f..8dde432 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -338,6 +338,7 @@ struct rtnexthop {
 #define RTNH_F_PERVASIVE   2   /* Do recursive gateway lookup  */
 #define RTNH_F_ONLINK  4   /* Gateway is forced on link*/
 #define RTNH_F_OFFLOAD 8   /* offloaded route */
+#define RTNH_F_LINKDOWN16  /* carrier-down on nexthop */
 
 /* Macros to handle hexthops */
 
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 872494e..1e4c646 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1063,9 +1063,9 @@ static void nl_fib_lookup_exit(struct net *net)
net-ipv4.fibnl = NULL;
 }
 
-static void fib_disable_ip(struct net_device *dev, int force)
+static void fib_disable_ip(struct net_device *dev, int event)
 {
-   if (fib_sync_down_dev(dev, force))
+   if (fib_sync_down_dev(dev, event))
fib_flush(dev_net(dev));
rt_cache_flush(dev_net(dev));
arp_ifdown(dev);
@@ -1080,9 +1080,7 @@ static int fib_inetaddr_event(struct notifier_block 
*this, unsigned long event,
switch (event) {
case NETDEV_UP:
fib_add_ifaddr(ifa);
-#ifdef CONFIG_IP_ROUTE_MULTIPATH
-   fib_sync_up(dev);
-#endif
+   fib_sync_up(dev, RTNH_F_DEAD);
atomic_inc(net-ipv4.dev_addr_genid);
rt_cache_flush(dev_net(dev));
break;
@@ -1093,7 +1091,7 @@ static int fib_inetaddr_event(struct notifier_block 
*this, unsigned long event,
/* Last address was deleted from this interface.
 * Disable IP.
 */
-   fib_disable_ip(dev, 1);
+   fib_disable_ip(dev, event);
} else {
rt_cache_flush(dev_net(dev));
}
@@ -1107,9 +1105,10 @@ static int fib_netdev_event(struct notifier_block *this, 
unsigned long event, vo
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct in_device *in_dev;
struct net *net = dev_net(dev);
+   unsigned flags;
 
if (event == NETDEV_UNREGISTER) {
-   fib_disable_ip(dev, 2);
+   fib_disable_ip(dev, event);
rt_flush_dev(dev);
return NOTIFY_DONE;
}
@@ -1123,17 +1122,20 @@ static int fib_netdev_event(struct notifier_block 
*this, unsigned long event, vo
for_ifa(in_dev) {
fib_add_ifaddr(ifa);
} endfor_ifa(in_dev);
-#ifdef CONFIG_IP_ROUTE_MULTIPATH
-   fib_sync_up(dev);
-#endif
+   fib_sync_up(dev, RTNH_F_DEAD);
atomic_inc(net-ipv4.dev_addr_genid);
rt_cache_flush(net);
break;
case NETDEV_DOWN:
-   fib_disable_ip(dev, 0);
+   fib_disable_ip(dev, event);
break;
-   case NETDEV_CHANGEMTU:
case NETDEV_CHANGE:
+   flags = dev_get_flags(dev);
+   if (flags  (IFF_RUNNING|IFF_LOWER_UP))
+   fib_sync_up(dev, RTNH_F_LINKDOWN);
+   else
+   fib_sync_down_dev(dev, event);
+   case NETDEV_CHANGEMTU:
rt_cache_flush(net);

[PATCH 07/12] fsl/fman: Add FMan MURAM support

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

Add Frame Manager Multi-User RAM support.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/net/ethernet/freescale/fman/Kconfig|   1 +
 drivers/net/ethernet/freescale/fman/Makefile   |   6 +-
 drivers/net/ethernet/freescale/fman/fm_muram.c | 127 +
 .../net/ethernet/freescale/fman/inc/fm_muram_ext.h | 103 +
 4 files changed, 235 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/fm_muram.c
 create mode 100644 drivers/net/ethernet/freescale/fman/inc/fm_muram_ext.h

diff --git a/drivers/net/ethernet/freescale/fman/Kconfig 
b/drivers/net/ethernet/freescale/fman/Kconfig
index af42c3a..825a0d5 100644
--- a/drivers/net/ethernet/freescale/fman/Kconfig
+++ b/drivers/net/ethernet/freescale/fman/Kconfig
@@ -1,6 +1,7 @@
 config FSL_FMAN
bool FMan support
depends on FSL_SOC || COMPILE_TEST
+   select GENERIC_ALLOCATOR
default n
help
Freescale Data-Path Acceleration Architecture Frame Manager
diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 1841b03..55c91bd 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -1,8 +1,10 @@
-subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman/flib
+subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman/flib \
+
-I$(srctree)/drivers/net/ethernet/freescale/fman/inc \
+
-I$(srctree)/drivers/net/ethernet/freescale/fman
 
 obj-y  += fsl_fman.o
 
-fsl_fman-objs  := fman.o
+fsl_fman-objs  := fman.o fm_muram.o
 
 obj-y  += port/
 obj-y  += mac/
diff --git a/drivers/net/ethernet/freescale/fman/fm_muram.c 
b/drivers/net/ethernet/freescale/fman/fm_muram.c
new file mode 100644
index 000..f62042a
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fm_muram.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* FM MURAM ... */
+#include fm_muram_ext.h
+
+#include linux/io.h
+#include linux/string.h
+#include linux/slab.h
+#include linux/genalloc.h
+
+struct muram_info {
+   struct gen_pool *pool;
+   void __iomem *vbase;
+   uint64_t size;
+   phys_addr_t pbase;
+};
+
+struct muram_info *fm_muram_init(phys_addr_t base, uint64_t size)
+{
+   struct muram_info *p_muram;
+   void __iomem *vaddr;
+   int ret;
+
+   p_muram = kzalloc(sizeof(*p_muram), GFP_KERNEL);
+   if (!p_muram)
+   return NULL;
+
+   p_muram-pool = gen_pool_create(ilog2(64), -1);
+   if (!p_muram-pool) {
+   pr_err(%s(): MURAM pool create failed\n, __func__);
+   return NULL;
+   }
+
+   vaddr = ioremap(base, size);
+   if (!vaddr) {
+   pr_err(%s(): MURAM ioremap failed\n, __func__);
+   return NULL;
+   }
+
+   ret = gen_pool_add_virt(p_muram-pool, (unsigned long)vaddr,
+   base, size, -1);
+   if (ret  0) {
+   pr_err(%s(): MURAM pool add failed\n, 

[PATCH 02/12] fsl/fman: Add the FMan FLIB

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

The FMan FLib provides the basic API used by the FMan drivers to
configure and control the FMan hardware.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/net/ethernet/freescale/Kconfig   |   1 +
 drivers/net/ethernet/freescale/Makefile  |   2 +
 drivers/net/ethernet/freescale/fman/Kconfig  |   7 +
 drivers/net/ethernet/freescale/fman/Makefile |   5 +
 drivers/net/ethernet/freescale/fman/fman.c   | 973 +++
 5 files changed, 988 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/Kconfig
 create mode 100644 drivers/net/ethernet/freescale/fman/Makefile
 create mode 100644 drivers/net/ethernet/freescale/fman/fman.c

diff --git a/drivers/net/ethernet/freescale/Kconfig 
b/drivers/net/ethernet/freescale/Kconfig
index 25e3425..24e938d 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -55,6 +55,7 @@ config FEC_MPC52xx_MDIO
  If compiled as module, it will be called fec_mpc52xx_phy.
 
 source drivers/net/ethernet/freescale/fs_enet/Kconfig
+source drivers/net/ethernet/freescale/fman/Kconfig
 
 config FSL_PQ_MDIO
tristate Freescale PQ MDIO
diff --git a/drivers/net/ethernet/freescale/Makefile 
b/drivers/net/ethernet/freescale/Makefile
index 71debd1..4097c58 100644
--- a/drivers/net/ethernet/freescale/Makefile
+++ b/drivers/net/ethernet/freescale/Makefile
@@ -17,3 +17,5 @@ gianfar_driver-objs := gianfar.o \
gianfar_ethtool.o
 obj-$(CONFIG_UCC_GETH) += ucc_geth_driver.o
 ucc_geth_driver-objs := ucc_geth.o ucc_geth_ethtool.o
+
+obj-$(CONFIG_FSL_FMAN) += fman/
diff --git a/drivers/net/ethernet/freescale/fman/Kconfig 
b/drivers/net/ethernet/freescale/fman/Kconfig
new file mode 100644
index 000..8aeae29
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/Kconfig
@@ -0,0 +1,7 @@
+config FSL_FMAN
+   bool FMan support
+   depends on FSL_SOC || COMPILE_TEST
+   default n
+   help
+   Freescale Data-Path Acceleration Architecture Frame Manager
+   (FMan) support
diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
new file mode 100644
index 000..2799c6f
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -0,0 +1,5 @@
+subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman/flib
+
+obj-y  += fsl_fman.o
+
+fsl_fman-objs  := fman.o
diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
new file mode 100644
index 000..410c498
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -0,0 +1,973 @@
+/*
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include fsl_fman.h
+
+uint32_t fman_get_bmi_err_event(struct fman_bmi_regs __iomem *bmi_rg)
+{
+   uint32_t event, mask, force;
+
+   event = ioread32be(bmi_rg-fmbm_ievr);
+   mask = ioread32be(bmi_rg-fmbm_ier);
+   event = mask;
+   /* clear the forced events */
+   force = ioread32be(bmi_rg-fmbm_ifr);
+   if (force  event)
+   iowrite32be(force  ~event, bmi_rg-fmbm_ifr);
+   /* clear the 

Re: [PATCH v3] ipv6: Fix protocol resubmission

2015-06-10 Thread YOSHIFUJI Hideaki
Hi,

Josh Hunt wrote:
 On 06/09/2015 11:24 PM, Hajime Tazaki wrote:

 Hello Josh, Dave,

 my mobile ipv6 test on libos failed with this commit.

 This commit makes a destination option header handling (i.e.,
 ipprot-handler == ipv6_destopt_rcv) failed since
 ipv6_destopt_rcv() seems to return a positive value to
 indicate to goto resubmission label.

 I will look for more detail.

 -- Hajime
 
 Hajime
 
 Thanks for the report. I mentioned in an earlier post this might be a problem.
 
 Dave, what if we restore the old behavior, but add a new label to handle the 
 case where the decapsulating protocol returns the nexthdr value? Allowing for 
 migration over to this method over time. I've pasted in a patch doing so 
 below.

I think it is insufficient because IPv6 stack already uses
positive value, 0 and negative values.

 
 The other solution I guess is to change how the udp handler works, but I was 
 hoping to keep it behaving the same as v4.

xfrm returns different value for IPv4 and IPv6, for example,
so udp can do in the same way.  And we can use the fact that
the size of next header field is 8-bit.


 
 Josh
 
 diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
 index 41a73da..a4fab24 100644
 --- a/net/ipv6/ip6_input.c
 +++ b/net/ipv6/ip6_input.c
 @@ -212,13 +212,13 @@ static int ip6_input_finish(struct sock *sk, struct 
 sk_buff *skb)
  */
 
 rcu_read_lock();
 +resubmit:
 idev = ip6_dst_idev(skb_dst(skb));
 if (!pskb_pull(skb, skb_transport_offset(skb)))
 goto discard;
 nhoff = IP6CB(skb)-nhoff;
 nexthdr = skb_network_header(skb)[nhoff];
 -
 -resubmit:
 +resubmit_nexthdr:
 raw = raw6_local_deliver(skb, nexthdr);
 ipprot = rcu_dereference(inet6_protos[nexthdr]);
 if (ipprot) {
 @@ -246,9 +246,11 @@ resubmit:
 goto discard;
 
 ret = ipprot-handler(skb);
 -   if (ret  0) {
 -   nexthdr = -ret;
 +   if (ret  0) {
 goto resubmit;
 +   } else if (ret  0) {
 +   nexthdr = -ret;
 +   goto resubmit_nexthdr;
 } else if (ret == 0) {
 IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INDELIVERS);
 }

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


[PATCH 06/12] fsl/fman: Add the FMan MAC FLIB

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

The FMan MAC FLib provides basic API used by the drivers to
configure and control the FMan MAC hardware.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/net/ethernet/freescale/fman/Makefile   |   1 +
 drivers/net/ethernet/freescale/fman/mac/Makefile   |   5 +
 .../net/ethernet/freescale/fman/mac/fman_dtsec.c   | 571 +
 .../freescale/fman/mac/fman_dtsec_mii_acc.c| 168 ++
 .../net/ethernet/freescale/fman/mac/fman_memac.c   | 365 +
 .../freescale/fman/mac/fman_memac_mii_acc.c| 217 
 .../net/ethernet/freescale/fman/mac/fman_tgec.c| 217 
 7 files changed, 1544 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/Makefile
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_dtsec_mii_acc.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_memac.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_memac_mii_acc.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_tgec.c

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 50a4de2..1841b03 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -5,3 +5,4 @@ obj-y   += fsl_fman.o
 fsl_fman-objs  := fman.o
 
 obj-y  += port/
+obj-y  += mac/
diff --git a/drivers/net/ethernet/freescale/fman/mac/Makefile 
b/drivers/net/ethernet/freescale/fman/mac/Makefile
new file mode 100644
index 000..ce03e25
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/mac/Makefile
@@ -0,0 +1,5 @@
+obj-y  += fsl_fman_mac.o
+
+fsl_fman_mac-objs  := fman_dtsec.o fman_dtsec_mii_acc.o\
+  fman_memac.o fman_memac_mii_acc.o\
+  fman_tgec.o
diff --git a/drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c
new file mode 100644
index 000..290a037
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c
@@ -0,0 +1,571 @@
+/*
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include fsl_fman_dtsec.h
+
+void fman_dtsec_stop_rx(struct dtsec_regs __iomem *regs)
+{
+   /* Assert the graceful stop bit */
+   iowrite32be(ioread32be(regs-rctrl) | RCTRL_GRS, regs-rctrl);
+}
+
+void fman_dtsec_stop_tx(struct dtsec_regs __iomem *regs)
+{
+   /* Assert the graceful stop bit */
+   iowrite32be(ioread32be(regs-tctrl) | DTSEC_TCTRL_GTS, regs-tctrl);
+}
+
+void fman_dtsec_start_tx(struct dtsec_regs __iomem *regs)
+{
+   /* clear the graceful stop bit */
+   iowrite32be(ioread32be(regs-tctrl)  ~DTSEC_TCTRL_GTS, regs-tctrl);
+}
+
+void fman_dtsec_start_rx(struct dtsec_regs __iomem *regs)
+{
+   /* clear the graceful stop bit */
+   iowrite32be(ioread32be(regs-rctrl)  ~RCTRL_GRS, regs-rctrl);
+}
+
+void fman_dtsec_defconfig(struct dtsec_cfg *cfg)
+{
+   cfg-halfdup_on = DEFAULT_HALFDUP_ON;
+   cfg-halfdup_retransmit = DEFAULT_HALFDUP_RETRANSMIT;
+   

[PATCH 01/12] fsl/fman: Add the FMan FLIB headers

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

This patch presents the FMan Foundation Libraries (FLIB) headers.
The FMan FLib provides the basic API used by the FMan drivers to
configure and control the FMan hardware.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 .../ethernet/freescale/fman/flib/common/general.h  |  41 ++
 .../net/ethernet/freescale/fman/flib/fsl_fman.h| 609 +
 2 files changed, 650 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/flib/common/general.h
 create mode 100644 drivers/net/ethernet/freescale/fman/flib/fsl_fman.h

diff --git a/drivers/net/ethernet/freescale/fman/flib/common/general.h 
b/drivers/net/ethernet/freescale/fman/flib/common/general.h
new file mode 100644
index 000..0501f01
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/flib/common/general.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __GENERAL_H
+#define __GENERAL_H
+
+#include linux/types.h
+#include linux/io.h
+
+#define iowrite32be(val, addr) out_be32((*addr), val)
+#define ioread32be(addr)   in_be32((*addr))
+
+#endif /* __GENERAL_H */
diff --git a/drivers/net/ethernet/freescale/fman/flib/fsl_fman.h 
b/drivers/net/ethernet/freescale/fman/flib/fsl_fman.h
new file mode 100644
index 000..95eef30
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/flib/fsl_fman.h
@@ -0,0 +1,609 @@
+/*
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED 

[V6 PATCH 2/7] arm64 : Introduce support for ACPI _CCA object

2015-06-10 Thread Suravee Suthikulpanit
From http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf,
section 6.2.17 _CCA states that ARM platforms require ACPI _CCA
object to be specified for DMA-cabpable devices. Therefore, this patch
specifies ACPI_CCA_REQUIRED in arm64 Kconfig.

In addition, to handle the case when _CCA is missing, arm64 would assign
dummy_dma_ops to disable DMA capability of the device.

Acked-by: Catalin Marinas catalin.mari...@arm.com
Signed-off-by: Mark Salter msal...@redhat.com
Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
---
 arch/arm64/Kconfig   |  1 +
 arch/arm64/include/asm/dma-mapping.h | 18 ++-
 arch/arm64/mm/dma-mapping.c  | 92 
 3 files changed, 109 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 4269dba..95307b4 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,5 +1,6 @@
 config ARM64
def_bool y
+   select ACPI_CCA_REQUIRED if ACPI
select ACPI_GENERIC_GSI if ACPI
select ACPI_REDUCED_HARDWARE_ONLY if ACPI
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
diff --git a/arch/arm64/include/asm/dma-mapping.h 
b/arch/arm64/include/asm/dma-mapping.h
index 9437e3d..f0d6d0b 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -18,6 +18,7 @@
 
 #ifdef __KERNEL__
 
+#include linux/acpi.h
 #include linux/types.h
 #include linux/vmalloc.h
 
@@ -28,13 +29,23 @@
 
 #define DMA_ERROR_CODE (~(dma_addr_t)0)
 extern struct dma_map_ops *dma_ops;
+extern struct dma_map_ops dummy_dma_ops;
 
 static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
 {
-   if (unlikely(!dev) || !dev-archdata.dma_ops)
+   if (unlikely(!dev))
return dma_ops;
-   else
+   else if (dev-archdata.dma_ops)
return dev-archdata.dma_ops;
+   else if (acpi_disabled)
+   return dma_ops;
+
+   /*
+* When ACPI is enabled, if arch_set_dma_ops is not called,
+* we will disable device DMA capability by setting it
+* to dummy_dma_ops.
+*/
+   return dummy_dma_ops;
 }
 
 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
@@ -48,6 +59,9 @@ static inline struct dma_map_ops *get_dma_ops(struct device 
*dev)
 static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 
size,
  struct iommu_ops *iommu, bool coherent)
 {
+   if (!acpi_disabled  !dev-archdata.dma_ops)
+   dev-archdata.dma_ops = dma_ops;
+
dev-archdata.dma_coherent = coherent;
 }
 #define arch_setup_dma_ops arch_setup_dma_ops
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index ef7d112..6e6d6ad 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -415,6 +415,98 @@ out:
return -ENOMEM;
 }
 
+/
+ * The following APIs are for dummy DMA ops *
+ /
+
+static void *__dummy_alloc(struct device *dev, size_t size,
+  dma_addr_t *dma_handle, gfp_t flags,
+  struct dma_attrs *attrs)
+{
+   return NULL;
+}
+
+static void __dummy_free(struct device *dev, size_t size,
+void *vaddr, dma_addr_t dma_handle,
+struct dma_attrs *attrs)
+{
+}
+
+static int __dummy_mmap(struct device *dev,
+   struct vm_area_struct *vma,
+   void *cpu_addr, dma_addr_t dma_addr, size_t size,
+   struct dma_attrs *attrs)
+{
+   return -ENXIO;
+}
+
+static dma_addr_t __dummy_map_page(struct device *dev, struct page *page,
+  unsigned long offset, size_t size,
+  enum dma_data_direction dir,
+  struct dma_attrs *attrs)
+{
+   return DMA_ERROR_CODE;
+}
+
+static void __dummy_unmap_page(struct device *dev, dma_addr_t dev_addr,
+  size_t size, enum dma_data_direction dir,
+  struct dma_attrs *attrs)
+{
+}
+
+static int __dummy_map_sg(struct device *dev, struct scatterlist *sgl,
+ int nelems, enum dma_data_direction dir,
+ struct dma_attrs *attrs)
+{
+   return 0;
+}
+
+static void __dummy_unmap_sg(struct device *dev,
+struct scatterlist *sgl, int nelems,
+enum dma_data_direction dir,
+struct dma_attrs *attrs)
+{
+}
+
+static void __dummy_sync_single(struct device *dev,
+   dma_addr_t dev_addr, size_t size,
+   enum dma_data_direction dir)
+{
+}
+
+static void __dummy_sync_sg(struct device *dev,
+   struct scatterlist *sgl, int nelems,
+   

[V6 PATCH 3/7] device property: Introduces device_dma_is_coherent()

2015-06-10 Thread Suravee Suthikulpanit
Currently, device drivers, which support both OF and ACPI,
need to call two separate APIs, of_dma_is_coherent() and
acpi_dma_is_coherent()) to determine device coherency attribute.

This patch simplifies this process by introducing a new device
property API, device_dma_is_coherent(), which calls the appropriate
interface based on the booting architecture.

Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
---
 drivers/base/property.c  | 14 ++
 include/linux/property.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 1d0b116..e645852 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -14,6 +14,7 @@
 #include linux/export.h
 #include linux/kernel.h
 #include linux/of.h
+#include linux/of_address.h
 #include linux/property.h
 
 /**
@@ -519,3 +520,16 @@ unsigned int device_get_child_node_count(struct device 
*dev)
return count;
 }
 EXPORT_SYMBOL_GPL(device_get_child_node_count);
+
+bool device_dma_is_coherent(struct device *dev)
+{
+   bool coherent = false;
+
+   if (IS_ENABLED(CONFIG_OF)  dev-of_node)
+   coherent = of_dma_is_coherent(dev-of_node);
+   else
+   acpi_check_dma(ACPI_COMPANION(dev), coherent);
+
+   return coherent;
+}
+EXPORT_SYMBOL_GPL(device_dma_is_coherent);
diff --git a/include/linux/property.h b/include/linux/property.h
index de8bdf4..76ebde9 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -164,4 +164,6 @@ struct property_set {
 
 void device_add_property_set(struct device *dev, struct property_set *pset);
 
+bool device_dma_is_coherent(struct device *dev);
+
 #endif /* _LINUX_PROPERTY_H_ */
-- 
2.1.0

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


[PATCH 1/1 linux-next] ath5k: use swap() in ath5k_hw_get_median_noise_floor()

2015-06-10 Thread Fabian Frederick
Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/net/wireless/ath/ath5k/phy.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/phy.c 
b/drivers/net/wireless/ath/ath5k/phy.c
index 0fce1c7..ef108a3 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -1566,17 +1566,13 @@ static s16
 ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah)
 {
s16 sort[ATH5K_NF_CAL_HIST_MAX];
-   s16 tmp;
int i, j;
 
memcpy(sort, ah-ah_nfcal_hist.nfval, sizeof(sort));
for (i = 0; i  ATH5K_NF_CAL_HIST_MAX - 1; i++) {
for (j = 1; j  ATH5K_NF_CAL_HIST_MAX - i; j++) {
-   if (sort[j]  sort[j - 1]) {
-   tmp = sort[j];
-   sort[j] = sort[j - 1];
-   sort[j - 1] = tmp;
-   }
+   if (sort[j]  sort[j - 1])
+   swap(sort[j], sort[j]);
}
}
for (i = 0; i  ATH5K_NF_CAL_HIST_MAX; i++) {
-- 
2.4.2

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


[PATCH 1/1 linux-next] vxge: use swap() in vxge_hw_channel_dtr_alloc()

2015-06-10 Thread Fabian Frederick
Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/net/ethernet/neterion/vxge/vxge-traffic.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/neterion/vxge/vxge-traffic.c 
b/drivers/net/ethernet/neterion/vxge/vxge-traffic.c
index 9e1aaa7..5f630a2 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-traffic.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-traffic.c
@@ -1004,8 +1004,6 @@ void vxge_hw_device_clear_tx_rx(struct __vxge_hw_device 
*hldev)
 static enum vxge_hw_status
 vxge_hw_channel_dtr_alloc(struct __vxge_hw_channel *channel, void **dtrh)
 {
-   void **tmp_arr;
-
if (channel-reserve_ptr - channel-reserve_top  0) {
 _alloc_after_swap:
*dtrh = channel-reserve_arr[--channel-reserve_ptr];
@@ -1020,10 +1018,7 @@ _alloc_after_swap:
 * i.e. no additional lock need to be done when we free a resource */
 
if (channel-length - channel-free_ptr  0) {
-
-   tmp_arr = channel-reserve_arr;
-   channel-reserve_arr = channel-free_arr;
-   channel-free_arr = tmp_arr;
+   swap(channel-reserve_arr, channel-free_arr);
channel-reserve_ptr = channel-length;
channel-reserve_top = channel-free_ptr;
channel-free_ptr = channel-length;
-- 
2.4.2

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


[PATCH 1/1 linux-next] net/mlx4: use swap() in mlx4_init_qp_table()

2015-06-10 Thread Fabian Frederick
Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/net/ethernet/mellanox/mlx4/qp.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c 
b/drivers/net/ethernet/mellanox/mlx4/qp.c
index b75214a..2026863 100644
--- a/drivers/net/ethernet/mellanox/mlx4/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
@@ -749,7 +749,7 @@ int mlx4_init_qp_table(struct mlx4_dev *dev)
 
{
int sort[MLX4_NUM_QP_REGION];
-   int i, j, tmp;
+   int i, j;
int last_base = dev-caps.num_qps;
 
for (i = 1; i  MLX4_NUM_QP_REGION; ++i)
@@ -758,11 +758,8 @@ int mlx4_init_qp_table(struct mlx4_dev *dev)
for (i = MLX4_NUM_QP_REGION; i  MLX4_QP_REGION_BOTTOM; --i) {
for (j = MLX4_QP_REGION_BOTTOM + 2; j  i; ++j) {
if (dev-caps.reserved_qps_cnt[sort[j]] 
-   dev-caps.reserved_qps_cnt[sort[j - 1]]) {
-   tmp = sort[j];
-   sort[j] = sort[j - 1];
-   sort[j - 1] = tmp;
-   }
+   dev-caps.reserved_qps_cnt[sort[j - 1]])
+   swap(sort[j], sort[j - 1]);
}
}
 
-- 
2.4.2

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


[PATCH net-next 16/19] bna: get rid of private macros for manipulation with lists

2015-06-10 Thread Ivan Vecera
Remove macros for manipulation with struct list_head and replace them
with standard ones.

Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bfa_cee.c   |   1 -
 drivers/net/ethernet/brocade/bna/bfa_ioc.c   |  10 +-
 drivers/net/ethernet/brocade/bna/bfa_msgq.c  |  10 +-
 drivers/net/ethernet/brocade/bna/bna.h   |   1 -
 drivers/net/ethernet/brocade/bna/bna_enet.c  |  50 ++---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 310 +--
 drivers/net/ethernet/brocade/bna/cna.h   |  56 -
 7 files changed, 130 insertions(+), 308 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_cee.c 
b/drivers/net/ethernet/brocade/bna/bfa_cee.c
index cf9f395..95bc8b6 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_cee.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_cee.c
@@ -282,7 +282,6 @@ bfa_nw_cee_attach(struct bfa_cee *cee, struct bfa_ioc *ioc,
cee-ioc = ioc;
 
bfa_nw_ioc_mbox_regisr(cee-ioc, BFI_MC_CEE, bfa_cee_isr, cee);
-   bfa_q_qe_init(cee-ioc_notify);
bfa_ioc_notify_init(cee-ioc_notify, bfa_cee_notify, cee);
bfa_nw_ioc_notify_register(cee-ioc, cee-ioc_notify);
 }
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index 52fc439..dabbb30 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -2163,7 +2163,8 @@ bfa_ioc_mbox_poll(struct bfa_ioc *ioc)
/**
 * Enqueue command to firmware.
 */
-   bfa_q_deq(mod-cmd_q, cmd);
+   cmd = list_first_entry(mod-cmd_q, struct bfa_mbox_cmd, qe);
+   list_del(cmd-qe);
bfa_ioc_mbox_send(ioc, cmd-msg, sizeof(cmd-msg));
 
/**
@@ -2184,8 +2185,10 @@ bfa_ioc_mbox_flush(struct bfa_ioc *ioc)
struct bfa_ioc_mbox_mod *mod = ioc-mbox_mod;
struct bfa_mbox_cmd *cmd;
 
-   while (!list_empty(mod-cmd_q))
-   bfa_q_deq(mod-cmd_q, cmd);
+   while (!list_empty(mod-cmd_q)) {
+   cmd = list_first_entry(mod-cmd_q, struct bfa_mbox_cmd, qe);
+   list_del(cmd-qe);
+   }
 }
 
 /**
@@ -3231,7 +3234,6 @@ bfa_nw_flash_attach(struct bfa_flash *flash, struct 
bfa_ioc *ioc, void *dev)
flash-op_busy = 0;
 
bfa_nw_ioc_mbox_regisr(flash-ioc, BFI_MC_FLASH, bfa_flash_intr, flash);
-   bfa_q_qe_init(flash-ioc_notify);
bfa_ioc_notify_init(flash-ioc_notify, bfa_flash_notify, flash);
list_add_tail(flash-ioc_notify.qe, flash-ioc-notify_q);
 }
diff --git a/drivers/net/ethernet/brocade/bna/bfa_msgq.c 
b/drivers/net/ethernet/brocade/bna/bfa_msgq.c
index c07d5b9..9c5bb24 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_msgq.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_msgq.c
@@ -66,8 +66,9 @@ cmdq_sm_stopped_entry(struct bfa_msgq_cmdq *cmdq)
cmdq-offset = 0;
cmdq-bytes_to_copy = 0;
while (!list_empty(cmdq-pending_q)) {
-   bfa_q_deq(cmdq-pending_q, cmdq_ent);
-   bfa_q_qe_init(cmdq_ent-qe);
+   cmdq_ent = list_first_entry(cmdq-pending_q,
+   struct bfa_msgq_cmd_entry, qe);
+   list_del(cmdq_ent-qe);
call_cmdq_ent_cbfn(cmdq_ent, BFA_STATUS_FAILED);
}
 }
@@ -242,8 +243,8 @@ bfa_msgq_cmdq_ci_update(struct bfa_msgq_cmdq *cmdq, struct 
bfi_mbmsg *mb)
 
/* Walk through pending list to see if the command can be posted */
while (!list_empty(cmdq-pending_q)) {
-   cmd =
-   (struct bfa_msgq_cmd_entry *)bfa_q_first(cmdq-pending_q);
+   cmd = list_first_entry(cmdq-pending_q,
+  struct bfa_msgq_cmd_entry, qe);
if (ntohs(cmd-msg_hdr-num_entries) =
BFA_MSGQ_FREE_CNT(cmdq)) {
list_del(cmd-qe);
@@ -615,7 +616,6 @@ bfa_msgq_attach(struct bfa_msgq *msgq, struct bfa_ioc *ioc)
bfa_msgq_rspq_attach(msgq-rspq, msgq);
 
bfa_nw_ioc_mbox_regisr(msgq-ioc, BFI_MC_MSGQ, bfa_msgq_isr, msgq);
-   bfa_q_qe_init(msgq-ioc_notify);
bfa_ioc_notify_init(msgq-ioc_notify, bfa_msgq_notify, msgq);
bfa_nw_ioc_notify_register(msgq-ioc, msgq-ioc_notify);
 }
diff --git a/drivers/net/ethernet/brocade/bna/bna.h 
b/drivers/net/ethernet/brocade/bna/bna.h
index 4f16ee2..66e6e09 100644
--- a/drivers/net/ethernet/brocade/bna/bna.h
+++ b/drivers/net/ethernet/brocade/bna/bna.h
@@ -283,7 +283,6 @@ void bna_hw_stats_get(struct bna *bna);
 
 /* APIs for RxF */
 struct bna_mac *bna_cam_mod_mac_get(struct list_head *head);
-void bna_cam_mod_mac_put(struct list_head *tail, struct bna_mac *mac);
 struct bna_mcam_handle *bna_mcam_mod_handle_get(struct bna_mcam_mod *mod);
 void bna_mcam_mod_handle_put(struct bna_mcam_mod *mcam_mod,
  struct bna_mcam_handle *handle);
diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c 
b/drivers/net/ethernet/brocade/bna/bna_enet.c
index 

[PATCH net-next 17/19] bna: use list_for_each_entry where appropriate

2015-06-10 Thread Ivan Vecera
Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bfa_ioc.c   |   5 +-
 drivers/net/ethernet/brocade/bna/bna.h   |  41 --
 drivers/net/ethernet/brocade/bna/bna_enet.c  |  23 --
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 117 +--
 4 files changed, 37 insertions(+), 149 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index dabbb30..2c74beb 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -1091,12 +1091,9 @@ static void
 bfa_ioc_event_notify(struct bfa_ioc *ioc, enum bfa_ioc_event event)
 {
struct bfa_ioc_notify *notify;
-   struct list_head*qe;
 
-   list_for_each(qe, ioc-notify_q) {
-   notify = (struct bfa_ioc_notify *)qe;
+   list_for_each_entry(notify, ioc-notify_q, qe)
notify-cbfn(notify-cbarg, event);
-   }
 }
 
 static void
diff --git a/drivers/net/ethernet/brocade/bna/bna.h 
b/drivers/net/ethernet/brocade/bna/bna.h
index 66e6e09..dc845b2 100644
--- a/drivers/net/ethernet/brocade/bna/bna.h
+++ b/drivers/net/ethernet/brocade/bna/bna.h
@@ -208,28 +208,24 @@ do {  
\
 #define bna_rx_rid_mask(_bna) ((_bna)-rx_mod.rid_mask)
 
 #define bna_tx_from_rid(_bna, _rid, _tx)   \
-do {   \
-   struct bna_tx_mod *__tx_mod = (_bna)-tx_mod;\
-   struct bna_tx *__tx;\
-   struct list_head *qe;  \
-   _tx = NULL;  \
-   list_for_each(qe, __tx_mod-tx_active_q) {  \
-   __tx = (struct bna_tx *)qe;  \
-   if (__tx-rid == (_rid)) {\
-   (_tx) = __tx;  \
-   break;\
-   }  \
-   }  \
+do {   \
+   struct bna_tx_mod *__tx_mod = (_bna)-tx_mod;  \
+   struct bna_tx *__tx;\
+   _tx = NULL; \
+   list_for_each_entry(__tx, __tx_mod-tx_active_q, qe) { \
+   if (__tx-rid == (_rid)) {  \
+   (_tx) = __tx;   \
+   break;  \
+   }   \
+   }   \
 } while (0)
 
 #define bna_rx_from_rid(_bna, _rid, _rx)   \
 do {   \
struct bna_rx_mod *__rx_mod = (_bna)-rx_mod;  \
struct bna_rx *__rx;\
-   struct list_head *qe;   \
_rx = NULL; \
-   list_for_each(qe, __rx_mod-rx_active_q) { \
-   __rx = (struct bna_rx *)qe; \
+   list_for_each_entry(__rx, __rx_mod-rx_active_q, qe) { \
if (__rx-rid == (_rid)) {  \
(_rx) = __rx;   \
break;  \
@@ -249,15 +245,12 @@ do {  
\
 
 static inline struct bna_mac *bna_mac_find(struct list_head *q, u8 *addr)
 {
-   struct bna_mac *mac = NULL;
-   struct list_head *qe;
-   list_for_each(qe, q) {
-   if (ether_addr_equal(((struct bna_mac *)qe)-addr, addr)) {
-   mac = (struct bna_mac *)qe;
-   break;
-   }
-   }
-   return mac;
+   struct bna_mac *mac;
+
+   list_for_each_entry(mac, q, qe)
+   if (ether_addr_equal(mac-addr, addr))
+   return mac;
+   return NULL;
 }
 
 #define bna_attr(_bna) ((_bna)-ioceth.attr)
diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c 
b/drivers/net/ethernet/brocade/bna/bna_enet.c
index bd8f2c2..05680e0 100644
--- a/drivers/net/ethernet/brocade/bna/bna_enet.c
+++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
@@ -1806,17 +1806,6 @@ bna_ucam_mod_init(struct bna_ucam_mod *ucam_mod, struct 
bna *bna,
 static void
 

Re: [PATCH net-next 1/3 v2] net: track link-status of ipv4 nexthops

2015-06-10 Thread Alexander Duyck

On 06/09/2015 11:47 PM, Andy Gospodarek wrote:

Add a fib flag called RTNH_F_LINKDOWN to any ipv4 nexthops that are
reachable via an interface where carrier is off.  No action is taken,
but additional flags are passed to userspace to indicate carrier status.

This also includes a cleanup to fib_disable_ip to more clearly indicate
what event made the function call to replace the more cryptic force
option previously used.

v2: Split out kernel functionality into 2 patches, this patch simply sets and
clears new nexthop flag RTNH_F_LINKDOWN.

Signed-off-by: Andy Gospodarek go...@cumulusnetworks.com
Signed-off-by: Dinesh Dutt dd...@cumulusnetworks.com

---
  include/net/ip_fib.h   |  4 +--
  include/uapi/linux/rtnetlink.h |  1 +
  net/ipv4/fib_frontend.c| 26 +++-
  net/ipv4/fib_semantics.c   | 56 --
  4 files changed, 60 insertions(+), 27 deletions(-)

diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 54271ed..d1de1b7 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -305,9 +305,9 @@ void fib_flush_external(struct net *net);

  /* Exported by fib_semantics.c */
  int ip_fib_check_default(__be32 gw, struct net_device *dev);
-int fib_sync_down_dev(struct net_device *dev, int force);
+int fib_sync_down_dev(struct net_device *dev, int event);
  int fib_sync_down_addr(struct net *net, __be32 local);
-int fib_sync_up(struct net_device *dev);
+int fib_sync_up(struct net_device *dev, unsigned int nh_flags);
  void fib_select_multipath(struct fib_result *res);

  /* Exported by fib_trie.c */
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index 17fb02f..8dde432 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -338,6 +338,7 @@ struct rtnexthop {
  #define RTNH_F_PERVASIVE  2   /* Do recursive gateway lookup  */
  #define RTNH_F_ONLINK 4   /* Gateway is forced on link*/
  #define RTNH_F_OFFLOAD8   /* offloaded route */
+#define RTNH_F_LINKDOWN16  /* carrier-down on nexthop */


So you could probably use some sort of define here to identify which 
flags are event based and which are configuration based.  Then it makes 
it easier to take care of code below such as the nh_comp call.




  /* Macros to handle hexthops */

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 872494e..1e4c646 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1063,9 +1063,9 @@ static void nl_fib_lookup_exit(struct net *net)
net-ipv4.fibnl = NULL;
  }

-static void fib_disable_ip(struct net_device *dev, int force)
+static void fib_disable_ip(struct net_device *dev, int event)


Event should be an unsigned long to match fib_inetaddr_event and avoid 
any unnecessary casts or warnings.



  {
-   if (fib_sync_down_dev(dev, force))
+   if (fib_sync_down_dev(dev, event))
fib_flush(dev_net(dev));
rt_cache_flush(dev_net(dev));
arp_ifdown(dev);
@@ -1080,9 +1080,7 @@ static int fib_inetaddr_event(struct notifier_block 
*this, unsigned long event,
switch (event) {
case NETDEV_UP:
fib_add_ifaddr(ifa);
-#ifdef CONFIG_IP_ROUTE_MULTIPATH
-   fib_sync_up(dev);
-#endif
+   fib_sync_up(dev, RTNH_F_DEAD);
atomic_inc(net-ipv4.dev_addr_genid);
rt_cache_flush(dev_net(dev));
break;


Shouldn't this bit be left wrapped in CONFIG_IP_ROUTE_MULTIPATH?  I 
thought RTNH_F_DEAD was only used in that case.



@@ -1093,7 +1091,7 @@ static int fib_inetaddr_event(struct notifier_block 
*this, unsigned long event,
/* Last address was deleted from this interface.
 * Disable IP.
 */
-   fib_disable_ip(dev, 1);
+   fib_disable_ip(dev, event);
} else {
rt_cache_flush(dev_net(dev));
}


Aren't you losing information here?  The line above this change is a 
call to see if ifa_list is NULL.  I don't see how that data is being 
communicated down to fib_disable_ip.  It seems like you could end up 
with the wrong scope.



@@ -1107,9 +1105,10 @@ static int fib_netdev_event(struct notifier_block *this, 
unsigned long event, vo
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct in_device *in_dev;
struct net *net = dev_net(dev);
+   unsigned flags;

if (event == NETDEV_UNREGISTER) {
-   fib_disable_ip(dev, 2);
+   fib_disable_ip(dev, event);
rt_flush_dev(dev);
return NOTIFY_DONE;
}
@@ -1123,17 +1122,20 @@ static int fib_netdev_event(struct notifier_block 
*this, unsigned long event, vo
for_ifa(in_dev) {
fib_add_ifaddr(ifa);
} endfor_ifa(in_dev);

[V6 PATCH 0/7] ACPI: Introduce support for _CCA object

2015-06-10 Thread Suravee Suthikulpanit
This patch series introduce support for _CCA object, which is currently
used mainly by ARM64 platform to specify DMA coherency attribute for
devices when booting with ACPI.

A copy of ACPIv6 can be found here:
http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf

This patch also introduces a new APIS:
1. acpi_check_dma() as part of ACPI API.
2. device_dma_is_coherent() as part of unified device property API.

This simplifies the logic in device drivers to determine device coherency
attribute regardless of booting with DT vs ACPI.

This has been tested on AMD-Seattle platform, which implements _CCA 
object as described in the AMD Opteron A1100 Series Processor ACPI Porting 
Guide:

http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Seattle_ACPI_Guide.pdf

Changes from V5 (https://lkml.org/lkml/2015/5/20/1033):
* Fix build error in the megaraid and ufs driver
  (reported by Mark Salter)

Changes from V4 (https://lkml.org/lkml/2015/5/15/669):
* Patch1:
  - Move the arch_setup_dma_ops() call from acpi_create_platform_device()
to acpi_bind_one() to support other bus types (per Rafael).
  - Rename acpi_device_flags.is_coherent to acpi_device_flags.coherent_dma.
(per Rafael)
  - Refactor acpi_dma_is_supported() and acpi_dma_is_coherent() to
acpi_check_dma() to simplify the new interface.
  - Only support _CCA=1 for now. See acpi_check_dma() (per Arnd and Catalin)
* Patch2:
  - Add acked-by Catalin.
* Patch3:
  - Use ACPI_COMPANION() instead of acpi_node().
  - Remove has_acpi_companion() check since already done by acpi_node().
(per Will)
* Remove the patch Generic function for setting up PCI device DMA 
coherency
  introduced in V4. (per Bjorn)

Changes from V3 (https://lkml.org/lkml/2015/5/7/1004):
* Remove ARCH64_SUPPORT_ACPI_CCA_ZERO and just use CONFIG_ARM64.
  (per Catalin and Rafael)
* Do not need to call arch_setup_dma_ops() for acpi_device-dev.
  (per Rafael)
* [3/6] (New) We also need to call arch_setup_dma_ops() for pci
  devices and check the CCA of the host bridge. Similar logic
  exists for OF. So, I refactor of_pci_dma_configure() to
  the more generic version pci_dma_configure(), and add support
  for ACPI.

Changes from V2 (https://lkml.org/lkml/2015/5/5/510):
* Reword ACPI_MUST_HAVE_CCA to ACPI_CCA_REQUIRED (per Rafael)
* Reword ACPI_SUPPORT_CCA_ZERO to ARCH64_SUPPORT_ACPI_CCA_ZERO
  (per Rafael and Arnd)
* Misc code styling clean up (per Rafael)
* Only print missing _CCA warning message in debug mode.
* Refactor logic in acpi_setup_device_dma() into
  if acpi_dma_is_supported() then call arch_setup_dma_ops().
* Do not allocate device dma_mask if !acpi_dma_is_supported()
  (per Arnd).
* Re-use the dummy functions with the same signature.

Changes from V1 (https://lkml.org/lkml/2015/4/29/290):
* Remove supports for 32-bit ARM since doesn't currently
  supporting ACPI (Per Catalin suggestions.)
* Do not call arch_setup_dma_ops() and when _CCA is missing.
  (per Arnd suggestion)
* Add CONFIG_ACPI_SUPPORT_CCA_ZERO kernel config flag to
  allow architectures to specify the behavior when _CCA=0.
* Add dummy_dma_ops for ARM64 (per Catalin suggestions).
* Fixed build error when ACPI is not configured by defining
  acpi_dma_is_coherent() for when CONFIG_ACPI is not set.
* Introduce device_dma_is_coherent().
* Use device_dma_is_coherent in crypto/ccp and amd-xgbe driver.

Changes from RFC: (https://lkml.org/lkml/2015/4/1/389)
* New logic for deriving and propagating coherent attribute from
  parent devices. (by Mark)
* Introducing acpi_dma_is_coherent() API (Per Tom suggestion)
* Introducing CONFIG_ACPI_MUST_HAVE_CCA kernel configuration.
* Rebased to linux-4.1-rc1

Suravee Suthikulpanit (7):
  ACPI / scan: Parse _CCA and setup device coherency
  arm64 : Introduce support for ACPI _CCA object
  device property: Introduces device_dma_is_coherent()
  crypto: ccp - Unify coherency checking logic with
device_dma_is_coherent()
  amd-xgbe: Unify coherency checking logic with device_dma_is_coherent()
  megaraid_sas: fix TRUE and FALSE re-define build error
  ufs: fix TRUE and FALSE re-define build error

 arch/arm64/Kconfig|  1 +
 arch/arm64/include/asm/dma-mapping.h  | 18 +-
 arch/arm64/mm/dma-mapping.c   | 92 +++
 drivers/acpi/Kconfig  |  3 +
 drivers/acpi/acpi_platform.c  |  2 +-
 drivers/acpi/glue.c   |  5 ++
 drivers/acpi/scan.c   | 35 
 drivers/base/property.c   | 14 +
 drivers/crypto/ccp/ccp-platform.c | 60 +---
 drivers/net/ethernet/amd/xgbe/xgbe-main.c | 27 +
 drivers/scsi/megaraid/megaraid_sas_fp.c   |  8 +++
 drivers/scsi/ufs/unipro.h  

Re: [RFC net-next 1/3] Symbol preparation for VRF driver

2015-06-10 Thread Alexander Duyck

On 06/08/2015 11:35 AM, Shrijeet Mukherjee wrote:

From: Shrijeet Mukherjee s...@cumulusnetworks.com

This change is needed for the following VRF driver which creates
a routing domain and allows applications to bind to the domain.

No active code path changes.

Signed-off-by: Shrijeet Mukherjee s...@cumulusnetworks.com
---
  net/ipv4/fib_frontend.c |1 +
  net/ipv4/fib_trie.c |2 ++
  2 files changed, 3 insertions(+)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 872494e..9d4cef4 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -108,6 +108,7 @@ struct fib_table *fib_new_table(struct net *net, u32 id)
hlist_add_head_rcu(tb-tb_hlist, net-ipv4.fib_table_hash[h]);
return tb;
  }
+EXPORT_SYMBOL_GPL(fib_new_table);

  /* caller must hold either rtnl or rcu read lock */
  struct fib_table *fib_get_table(struct net *net, u32 id)


So this block of code is wrapped in a #ifdef for 
CONFIG_IP_MULTIPLE_TABLES so anything that references it will need to 
make sure that it is defined.



diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 01bce15..97fa62d 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1247,6 +1247,7 @@ out:
  err:
return err;
  }
+EXPORT_SYMBOL_GPL(fib_table_insert);

  static inline t_key prefix_mismatch(t_key key, struct key_vector *n)
  {
@@ -1535,6 +1536,7 @@ int fib_table_delete(struct fib_table *tb, struct 
fib_config *cfg)
alias_free_mem_rcu(fa_to_delete);
return 0;
  }
+EXPORT_SYMBOL_GPL(fib_table_delete);

  /* Scan for the next leaf starting at the provided key value */
  static struct key_vector *leaf_walk_rcu(struct key_vector **tn, t_key key)



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


Re: [PATCH net-next 12/13] net/core: Add reading VF statistics through the PF netdevice

2015-06-10 Thread John Fastabend

On 06/10/2015 07:59 AM, Or Gerlitz wrote:

From: Eran Ben Elisha era...@mellanox.com

Add ndo_get_vf_stats where the PF retrieves and fills the VFs traffic
statistics. Add rtnl_link_vf_stats64 for passing the VF statistics from
the PF to user-space.

Signed-off-by: Eran Ben Elisha era...@mellanox.com
Signed-off-by: Hadar Hen Zion had...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
  include/linux/netdevice.h|4 
  include/uapi/linux/if_link.h |   11 +++
  net/core/rtnetlink.c |   12 ++--
  3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6f5f71f..b1d3b88 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1100,6 +1100,10 @@ struct net_device_ops {
 struct ifla_vf_info *ivf);
int (*ndo_set_vf_link_state)(struct net_device *dev,
 int vf, int 
link_state);
+   int (*ndo_get_vf_stats)(struct net_device *dev,
+   int vf,
+   struct rtnl_link_vf_stats64
+   *vf_stats);
int (*ndo_set_vf_port)(struct net_device *dev,
   int vf,
   struct nlattr *port[]);
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 1737b7a..9c25aeb 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -70,6 +70,16 @@ struct rtnl_link_stats64 {
__u64   tx_compressed;
  };

+/* VF statistics structure */
+struct rtnl_link_vf_stats64 {
+   __u64   rx_packets; /* total packets received   */
+   __u64   tx_packets; /* total packets transmitted*/
+   __u64   rx_bytes;   /* total bytes received */
+   __u64   tx_bytes;   /* total bytes transmitted  */
+   __u64   broadcast;  /* broadcast packets received   */
+   __u64   multicast;  /* multicast packets received   */
+};


Can we encode this in a nested netlink structure when its passed
up to userspace? I have more stats I would like to export in the
future such as dropped packets and if we put the structure in the UAPI
we wont be able to easily extend this.

The structure could be moved into ./include/linux/if_link.h though.


+
  /* The struct should be in sync with struct ifmap */
  struct rtnl_link_ifmap {
__u64   mem_start;
@@ -482,6 +492,7 @@ enum {
IFLA_VF_RSS_QUERY_EN,   /* RSS Redirection Table and Hash Key query
 * on/off switch
 */
+   IFLA_VF_STATS,  /* network device statistics */
__IFLA_VF_MAX,
  };

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 077b6d2..6d7c939 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -819,7 +819,8 @@ static inline int rtnl_vfinfo_size(const struct net_device 
*dev,
 nla_total_size(sizeof(struct ifla_vf_spoofchk)) +
 nla_total_size(sizeof(struct ifla_vf_rate)) +
 nla_total_size(sizeof(struct ifla_vf_link_state)) +
-nla_total_size(sizeof(struct ifla_vf_rss_query_en)));
+nla_total_size(sizeof(struct ifla_vf_rss_query_en)) +
+nla_total_size(sizeof(struct rtnl_link_vf_stats64)));
return size;
} else
return 0;
@@ -1138,6 +1139,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct 
net_device *dev,
struct ifla_vf_spoofchk vf_spoofchk;
struct ifla_vf_link_state vf_linkstate;
struct ifla_vf_rss_query_en vf_rss_query_en;
+   struct rtnl_link_vf_stats64 vf_stats;

/*
 * Not all SR-IOV capable drivers support the
@@ -1176,6 +1178,10 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct 
net_device *dev,
nla_nest_cancel(skb, vfinfo);
goto nla_put_failure;
}
+   memset(vf_stats, 0, sizeof(vf_stats));
+   if (dev-netdev_ops-ndo_get_vf_stats)
+   dev-netdev_ops-ndo_get_vf_stats(dev, i,
+ vf_stats);
if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), vf_mac) 
||
nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), 
vf_vlan) ||
nla_put(skb, IFLA_VF_RATE, sizeof(vf_rate),
@@ -1188,7 +1194,9 

[PATCH 05/12] fsl/fman: Add the FMan MAC FLIB headers

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

The FMan MAC FLib provides basic API used by the drivers to
configure and control the FMan MAC hardware.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 .../net/ethernet/freescale/fman/flib/fsl_enet.h| 275 +++
 .../ethernet/freescale/fman/flib/fsl_fman_dtsec.h  | 791 +
 .../freescale/fman/flib/fsl_fman_dtsec_mii_acc.h   | 103 +++
 .../ethernet/freescale/fman/flib/fsl_fman_memac.h  | 453 
 .../freescale/fman/flib/fsl_fman_memac_mii_acc.h   |  76 ++
 .../ethernet/freescale/fman/flib/fsl_fman_tgec.h   | 409 +++
 6 files changed, 2107 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/flib/fsl_enet.h
 create mode 100644 drivers/net/ethernet/freescale/fman/flib/fsl_fman_dtsec.h
 create mode 100644 
drivers/net/ethernet/freescale/fman/flib/fsl_fman_dtsec_mii_acc.h
 create mode 100644 drivers/net/ethernet/freescale/fman/flib/fsl_fman_memac.h
 create mode 100644 
drivers/net/ethernet/freescale/fman/flib/fsl_fman_memac_mii_acc.h
 create mode 100644 drivers/net/ethernet/freescale/fman/flib/fsl_fman_tgec.h

diff --git a/drivers/net/ethernet/freescale/fman/flib/fsl_enet.h 
b/drivers/net/ethernet/freescale/fman/flib/fsl_enet.h
new file mode 100644
index 000..78e7d04
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/flib/fsl_enet.h
@@ -0,0 +1,275 @@
+/*
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_ENET_H
+#define __FSL_ENET_H
+
+/*Ethernet MAC-PHY Interface */
+
+enum enet_interface {
+   E_ENET_IF_MII = 0x0001,   /* MII interface */
+   E_ENET_IF_RMII = 0x0002,  /* RMII interface */
+   E_ENET_IF_SMII = 0x0003,  /* SMII interface */
+   E_ENET_IF_GMII = 0x0004,  /* GMII interface */
+   E_ENET_IF_RGMII = 0x0005, /* RGMII interface */
+   E_ENET_IF_TBI = 0x0006,   /* TBI interface */
+   E_ENET_IF_RTBI = 0x0007,  /* RTBI interface */
+   E_ENET_IF_SGMII = 0x0008, /* SGMII interface */
+   E_ENET_IF_XGMII = 0x0009, /* XGMII interface */
+   E_ENET_IF_QSGMII = 0x000a,/* QSGMII interface */
+   E_ENET_IF_XFI = 0x000b/* XFI interface */
+};
+
+/* Ethernet Speed (nominal data rate) */
+enum enet_speed {
+   E_ENET_SPEED_10 = 10,   /* 10 Mbps */
+   E_ENET_SPEED_100 = 100, /* 100 Mbps */
+   E_ENET_SPEED_1000 = 1000,   /* 1000 Mbps = 1 Gbps */
+   E_ENET_SPEED_1 = 1  /* 1 Mbps = 10 Gbps */
+};
+
+enum mac_type {
+   E_MAC_DTSEC,
+   E_MAC_TGEC,
+   E_MAC_MEMAC
+};
+
+/* Enum for inter-module interrupts registration */
+enum fman_event_modules {
+   E_FMAN_MOD_PRS,   /* Parser event */
+   E_FMAN_MOD_KG,/* Keygen event */
+   E_FMAN_MOD_PLCR,  /* Policer event */
+   E_FMAN_MOD_10G_MAC,   /* 10G MAC event */
+   E_FMAN_MOD_1G_MAC,/* 1G MAC event */
+   E_FMAN_MOD_TMR,   /* Timer event */
+   E_FMAN_MOD_FMAN_CTRL, /* FMAN Controller  Timer event */
+

[PATCH 11/12] fsl/fman: Add FMan Port Support

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

This patch adds The FMan Port configuration, initialization and
runtime control routines.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/net/ethernet/freescale/fman/Makefile   |2 +-
 drivers/net/ethernet/freescale/fman/fm.c   |  487 ++-
 drivers/net/ethernet/freescale/fman/fm_common.h|  168 +++
 drivers/net/ethernet/freescale/fman/fm_drv.c   |  108 +-
 drivers/net/ethernet/freescale/fman/fm_drv.h   |2 +
 drivers/net/ethernet/freescale/fman/fm_port_drv.c  |  496 +++
 .../net/ethernet/freescale/fman/inc/fm_port_ext.h  |  376 +
 .../net/ethernet/freescale/fman/inc/fsl_fman_drv.h |  101 ++
 drivers/net/ethernet/freescale/fman/port/Makefile  |2 +-
 drivers/net/ethernet/freescale/fman/port/fm_port.c | 1435 
 drivers/net/ethernet/freescale/fman/port/fm_port.h |  527 +++
 11 files changed, 3700 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/fm_port_drv.c
 create mode 100644 drivers/net/ethernet/freescale/fman/inc/fm_port_ext.h
 create mode 100644 drivers/net/ethernet/freescale/fman/port/fm_port.c
 create mode 100644 drivers/net/ethernet/freescale/fman/port/fm_port.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index c6c3e24..8d637e2 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -4,7 +4,7 @@ subdir-ccflags-y += 
-I$(srctree)/drivers/net/ethernet/freescale/fman/flib \
 
 obj-y  += fsl_fman.o
 
-fsl_fman-objs  := fman.o fm_muram.o fm.o fm_drv.o
+fsl_fman-objs  := fman.o fm_muram.o fm.o fm_drv.o fm_port_drv.o
 
 obj-y  += port/
 obj-y  += mac/
diff --git a/drivers/net/ethernet/freescale/fman/fm.c 
b/drivers/net/ethernet/freescale/fman/fm.c
index fd6de5a..8bafab2 100644
--- a/drivers/net/ethernet/freescale/fman/fm.c
+++ b/drivers/net/ethernet/freescale/fman/fm.c
@@ -459,11 +459,36 @@ static void qmi_err_event(struct fm_t *p_fm)
 
 static void dma_err_event(struct fm_t *p_fm)
 {
-   uint32_t status;
+   uint32_t status, com_id;
+   uint8_t tnum;
+   uint8_t port_id;
+   uint8_t relative_port_id;
+   uint16_t liodn;
struct fman_dma_regs __iomem *dma_rg = p_fm-p_fm_dma_regs;
 
status = fman_get_dma_err_event(dma_rg);
 
+   if (status  DMA_STATUS_BUS_ERR) {
+   com_id = fman_get_dma_com_id(dma_rg);
+   port_id = (uint8_t)(((com_id  DMA_TRANSFER_PORTID_MASK) 
+   DMA_TRANSFER_PORTID_SHIFT));
+   HW_PORT_ID_TO_SW_PORT_ID(p_fm-p_fm_state_struct-rev_info.
+major_rev,
+relative_port_id,
+port_id);
+   tnum =
+   (uint8_t)((com_id  DMA_TRANSFER_TNUM_MASK) 
+  DMA_TRANSFER_TNUM_SHIFT);
+   liodn = (uint16_t)(com_id  DMA_TRANSFER_LIODN_MASK);
+   ASSERT(p_fm-p_fm_state_struct-
+   ports_types[port_id] !=
+   FM_PORT_TYPE_DUMMY);
+   p_fm-f_bus_error(p_fm-h_app,
+p_fm-p_fm_state_struct-
+ports_types[port_id],
+relative_port_id,
+fman_get_dma_addr(dma_rg), tnum, liodn);
+   }
if (status  DMA_STATUS_FM_SPDAT_ECC)
p_fm-f_exception(p_fm-h_app, FM_EX_DMA_SINGLE_PORT_ECC);
if (status  DMA_STATUS_READ_ECC)
@@ -764,6 +789,462 @@ uint8_t fm_get_id(struct fm_t *p_fm)
return p_fm-p_fm_state_struct-fm_id;
 }
 
+int fm_get_set_port_params(struct fm_t *p_fm,
+  struct fm_inter_module_port_init_params_t
+  *p_port_params)
+{
+   int err;
+   unsigned long int_flags;
+   uint8_t port_id = p_port_params-port_id, mac_id;
+   struct fman_rg fman_rg;
+
+   fman_rg.bmi_rg = p_fm-p_fm_bmi_regs;
+   fman_rg.qmi_rg = p_fm-p_fm_qmi_regs;
+   fman_rg.fpm_rg = p_fm-p_fm_fpm_regs;
+   fman_rg.dma_rg = p_fm-p_fm_dma_regs;
+
+   ASSERT(IN_RANGE(1, port_id, 63));
+
+   spin_lock_irqsave(p_fm-spinlock, int_flags);
+
+   p_fm-p_fm_state_struct-ports_types[port_id] =
+   p_port_params-port_type;
+
+   err =
+   fm_set_num_of_tasks(p_fm, p_port_params-port_id,
+   p_port_params-num_of_tasks,
+   p_port_params-num_of_extra_tasks, true);
+   if (err) {
+   spin_unlock_irqrestore(p_fm-spinlock, int_flags);
+   return err;
+   }
+#ifdef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
+   if (p_fm-p_fm_state_struct-rev_info.major_rev != 4)
+#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
+   /* for transmitO/H ports */
+  

Re: [PATCH v3] ipv6: Fix protocol resubmission

2015-06-10 Thread Josh Hunt


On 06/10/2015 10:23 AM, Josh Hunt wrote:

On 06/10/2015 10:16 AM, YOSHIFUJI Hideaki wrote:

Hi,

Josh Hunt wrote:


Hajime

Thanks for the report. I mentioned in an earlier post this might be a
problem.

Dave, what if we restore the old behavior, but add a new label to
handle the case where the decapsulating protocol returns the nexthdr
value? Allowing for migration over to this method over time. I've
pasted in a patch doing so below.


I think it is insufficient because IPv6 stack already uses
positive value, 0 and negative values.



Where does it use a negative value?

ret is only checked to be  or == to 0. I don't see any checks or code
handling a return value of  0 prior to my patch.

If something does return a negative value should it since nothing
happens with it?


Looking at the code again, I guess we don't increment
IPSTATS_MIB_INDELIVERS if we get a negative return value prior to my patch.

If so, then I guess we have to fix this in the udp path like you were 
suggesting. I will look at this and propose a patch to revert my 
original change and update the v6 udp code.


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


Re: [PATCH net-next 2/3 v2] net: ipv4 sysctl option to ignore routes when nexthop link is down

2015-06-10 Thread Alexander Duyck



On 06/09/2015 11:47 PM, Andy Gospodarek wrote:

This feature is only enabled with the new per-interface or ipv4 global
sysctls called 'ignore_routes_with_linkdown'.

net.ipv4.conf.all.ignore_routes_with_linkdown = 0
net.ipv4.conf.default.ignore_routes_with_linkdown = 0
net.ipv4.conf.lo.ignore_routes_with_linkdown = 0
...

When the above sysctls are set, will report to userspace that a route is
dead and will no longer resolve to this nexthop when performing a fib
lookup.  This will signal to userspace that the route will not be
selected.  The signalling of a RTNH_F_DEAD is only passed to userspace
if the sysctl is enabled and link is down.  This was done as without it the
netlink listeners would have no idea whether or not a nexthop would be
selected.   The kernel only sets RTNH_F_DEAD internally if the inteface has
IFF_UP cleared.

With the new sysctl set, the following behavior can be observed
(interface p8p1 is link-down):

# ip route show
default via 10.0.5.2 dev p9p1
10.0.5.0/24 dev p9p1  proto kernel  scope link  src 10.0.5.15
70.0.0.0/24 dev p7p1  proto kernel  scope link  src 70.0.0.1
80.0.0.0/24 dev p8p1  proto kernel  scope link  src 80.0.0.1 dead linkdown
90.0.0.0/24 via 80.0.0.2 dev p8p1  metric 1 dead linkdown
90.0.0.0/24 via 70.0.0.2 dev p7p1  metric 2
# ip route get 90.0.0.1
90.0.0.1 via 70.0.0.2 dev p7p1  src 70.0.0.1
 cache
# ip route get 80.0.0.1
local 80.0.0.1 dev lo  src 80.0.0.1
 cache local
# ip route get 80.0.0.2
80.0.0.2 via 10.0.5.2 dev p9p1  src 10.0.5.15
 cache

While the route does remain in the table (so it can be modified if
needed rather than being wiped away as it would be if IFF_UP was
cleared), the proper next-hop is chosen automatically when the link is
down.  Now interface p8p1 is linked-up:

# ip route show
default via 10.0.5.2 dev p9p1
10.0.5.0/24 dev p9p1  proto kernel  scope link  src 10.0.5.15
70.0.0.0/24 dev p7p1  proto kernel  scope link  src 70.0.0.1
80.0.0.0/24 dev p8p1  proto kernel  scope link  src 80.0.0.1
90.0.0.0/24 via 80.0.0.2 dev p8p1  metric 1
90.0.0.0/24 via 70.0.0.2 dev p7p1  metric 2
192.168.56.0/24 dev p2p1  proto kernel  scope link  src 192.168.56.2
# ip route get 90.0.0.1
90.0.0.1 via 80.0.0.2 dev p8p1  src 80.0.0.1
 cache
# ip route get 80.0.0.1
local 80.0.0.1 dev lo  src 80.0.0.1
 cache local
# ip route get 80.0.0.2
80.0.0.2 dev p8p1  src 80.0.0.1
 cache

and the output changes to what one would expect.

If the sysctl is not set, the following output would be expected when
p8p1 is down:

# ip route show
default via 10.0.5.2 dev p9p1
10.0.5.0/24 dev p9p1  proto kernel  scope link  src 10.0.5.15
70.0.0.0/24 dev p7p1  proto kernel  scope link  src 70.0.0.1
80.0.0.0/24 dev p8p1  proto kernel  scope link  src 80.0.0.1 linkdown
90.0.0.0/24 via 80.0.0.2 dev p8p1  metric 1 linkdown
90.0.0.0/24 via 70.0.0.2 dev p7p1  metric 2

Since the dead flag does not appear, there should be no expectation that
the kernel would skip using this route due to link being down.

v2: Split kernel changes into 2 patches, this actually makes a
behavioral change if the sysctl is set.  Also took suggestion from Alex
to simplify code by only checking sysctl during fib lookup and
suggestion from Scott to add a per-interface sysctl.

Signed-off-by: Andy Gospodarek go...@cumulusnetworks.com
Signed-off-by: Dinesh Dutt dd...@cumulusnetworks.com
---
  include/linux/inetdevice.h|  3 +++
  include/net/fib_rules.h   |  3 ++-
  include/net/ip_fib.h  | 17 ++---
  include/uapi/linux/ip.h   |  1 +
  include/uapi/linux/sysctl.h   |  1 +
  kernel/sysctl_binary.c|  1 +
  net/ipv4/devinet.c|  2 ++
  net/ipv4/fib_frontend.c   |  6 +++---
  net/ipv4/fib_rules.c  |  5 +++--
  net/ipv4/fib_semantics.c  | 28 ++--
  net/ipv4/fib_trie.c   |  7 +++
  net/ipv4/netfilter/ipt_rpfilter.c |  2 +-
  net/ipv4/route.c  | 10 +-
  13 files changed, 61 insertions(+), 25 deletions(-)

diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index 0a21fbe..a4328ce 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -120,6 +120,9 @@ static inline void ipv4_devconf_setall(struct in_device 
*in_dev)
 || (!IN_DEV_FORWARD(in_dev)  \
  IN_DEV_ORCONF((in_dev), ACCEPT_REDIRECTS)))

+#define IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) \
+   IN_DEV_CONF_GET((in_dev), IGNORE_ROUTES_WITH_LINKDOWN)
+
  #define IN_DEV_ARPFILTER(in_dev)  IN_DEV_ORCONF((in_dev), ARPFILTER)
  #define IN_DEV_ARP_ACCEPT(in_dev) IN_DEV_ORCONF((in_dev), ARP_ACCEPT)
  #define IN_DEV_ARP_ANNOUNCE(in_dev)   IN_DEV_MAXCONF((in_dev), ARP_ANNOUNCE)
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 6d67383..903a55e 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -36,7 +36,8 @@ struct fib_lookup_arg {
void*result;
struct 

[PATCH 1/1 linux-next] net/mlx4_core: use swap() in mlx4_make_profile()

2015-06-10 Thread Fabian Frederick
Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/net/ethernet/mellanox/mlx4/profile.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/profile.c 
b/drivers/net/ethernet/mellanox/mlx4/profile.c
index 2bf437a..bae8b22 100644
--- a/drivers/net/ethernet/mellanox/mlx4/profile.c
+++ b/drivers/net/ethernet/mellanox/mlx4/profile.c
@@ -82,7 +82,6 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
 
u64 total_size = 0;
struct mlx4_resource *profile;
-   struct mlx4_resource tmp;
struct sysinfo si;
int i, j;
 
@@ -149,11 +148,8 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
 */
for (i = MLX4_RES_NUM; i  0; --i)
for (j = 1; j  i; ++j) {
-   if (profile[j].size  profile[j - 1].size) {
-   tmp= profile[j];
-   profile[j] = profile[j - 1];
-   profile[j - 1] = tmp;
-   }
+   if (profile[j].size  profile[j - 1].size)
+   swap(profile[j], profile[j - 1]);
}
 
for (i = 0; i  MLX4_RES_NUM; ++i) {
-- 
2.4.2

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


[PATCH 1/1 linux-next] net/ibm/emac: use swap() in emac_make_bootlist()

2015-06-10 Thread Fabian Frederick
Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/net/ethernet/ibm/emac/core.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/ibm/emac/core.c 
b/drivers/net/ethernet/ibm/emac/core.c
index b9df0cb..b60a34d 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2999,7 +2999,7 @@ static struct platform_driver emac_driver = {
 static void __init emac_make_bootlist(void)
 {
struct device_node *np = NULL;
-   int j, max, i = 0, k;
+   int j, max, i = 0;
int cell_indices[EMAC_BOOT_LIST_SIZE];
 
/* Collect EMACs */
@@ -3026,12 +3026,8 @@ static void __init emac_make_bootlist(void)
for (i = 0; max  1  (i  (max - 1)); i++)
for (j = i; j  max; j++) {
if (cell_indices[i]  cell_indices[j]) {
-   np = emac_boot_list[i];
-   emac_boot_list[i] = emac_boot_list[j];
-   emac_boot_list[j] = np;
-   k = cell_indices[i];
-   cell_indices[i] = cell_indices[j];
-   cell_indices[j] = k;
+   swap(emac_boot_list[i], emac_boot_list[j]);
+   swap(cell_indices[i], cell_indices[j]);
}
}
 }
-- 
2.4.2

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


[PATCH net-next] net: phy: davicom: add IDs for DM9161B and C variants

2015-06-10 Thread Gustavo Zacarias
Add PHY IDs for Davicom DM9161B and DM9161C variants.
Tested with a DM9161C on a custom Atmel-based SAM9X25 board in RMII
mode.

The DM9161B uses the same model id with just the LSB bit of the version
id changing (which is masked out).

For all intents and purposes they're the same as the DM9161A with an
added GPSI mode and better fabrication process.

Signed-off-by: Gustavo Zacarias gust...@zacarias.com.ar
---
 drivers/net/phy/davicom.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
index 0d16c7d..2a32870 100644
--- a/drivers/net/phy/davicom.c
+++ b/drivers/net/phy/davicom.c
@@ -158,6 +158,18 @@ static struct phy_driver dm91xx_driver[] = {
.config_intr= dm9161_config_intr,
.driver = { .owner = THIS_MODULE,},
 }, {
+   .phy_id = 0x0181b8b0,
+   .name   = Davicom DM9161B/C,
+   .phy_id_mask= 0x0ff0,
+   .features   = PHY_BASIC_FEATURES,
+   .flags  = PHY_HAS_INTERRUPT,
+   .config_init= dm9161_config_init,
+   .config_aneg= dm9161_config_aneg,
+   .read_status= genphy_read_status,
+   .ack_interrupt  = dm9161_ack_interrupt,
+   .config_intr= dm9161_config_intr,
+   .driver = { .owner = THIS_MODULE,},
+}, {
.phy_id = 0x0181b8a0,
.name   = Davicom DM9161A,
.phy_id_mask= 0x0ff0,
@@ -186,6 +198,7 @@ module_phy_driver(dm91xx_driver);
 
 static struct mdio_device_id __maybe_unused davicom_tbl[] = {
{ 0x0181b880, 0x0ff0 },
+   { 0x0181b8b0, 0x0ff0 },
{ 0x0181b8a0, 0x0ff0 },
{ 0x00181b80, 0x0ff0 },
{ }
-- 
2.3.6

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


[PATCH net-next 12/19] bna: remove TX_E_PRIO_CHANGE event and BNA_TX_F_PRIO_CHANGED flag

2015-06-10 Thread Ivan Vecera
TX_E_PRIO_CHANGE event is never sent for bna_tx so it doesn't need to be
handled. After this change bna_tx-flags cannot contain
BNA_TX_F_PRIO_CHANGED flag and it can be also eliminated.

Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 22 --
 drivers/net/ethernet/brocade/bna/bna_types.h |  1 -
 2 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c 
b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
index 896aa82..54ad169 100644
--- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
+++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
@@ -2901,7 +2901,6 @@ enum bna_tx_event {
TX_E_FAIL   = 3,
TX_E_STARTED= 4,
TX_E_STOPPED= 5,
-   TX_E_PRIO_CHANGE= 6,
TX_E_CLEANUP_DONE   = 7,
TX_E_BW_UPDATE  = 8,
 };
@@ -2942,9 +2941,6 @@ bna_tx_sm_stopped(struct bna_tx *tx, enum bna_tx_event 
event)
/* No-op */
break;
 
-   case TX_E_PRIO_CHANGE:
-   break;
-
case TX_E_BW_UPDATE:
/* No-op */
break;
@@ -2965,28 +2961,23 @@ bna_tx_sm_start_wait(struct bna_tx *tx, enum 
bna_tx_event event)
 {
switch (event) {
case TX_E_STOP:
-   tx-flags = ~(BNA_TX_F_PRIO_CHANGED | BNA_TX_F_BW_UPDATED);
+   tx-flags = ~BNA_TX_F_BW_UPDATED;
bfa_fsm_set_state(tx, bna_tx_sm_stop_wait);
break;
 
case TX_E_FAIL:
-   tx-flags = ~(BNA_TX_F_PRIO_CHANGED | BNA_TX_F_BW_UPDATED);
+   tx-flags = ~BNA_TX_F_BW_UPDATED;
bfa_fsm_set_state(tx, bna_tx_sm_stopped);
break;
 
case TX_E_STARTED:
-   if (tx-flags  (BNA_TX_F_PRIO_CHANGED | BNA_TX_F_BW_UPDATED)) {
-   tx-flags = ~(BNA_TX_F_PRIO_CHANGED |
-   BNA_TX_F_BW_UPDATED);
+   if (tx-flags  BNA_TX_F_BW_UPDATED) {
+   tx-flags = ~BNA_TX_F_BW_UPDATED;
bfa_fsm_set_state(tx, bna_tx_sm_prio_stop_wait);
} else
bfa_fsm_set_state(tx, bna_tx_sm_started);
break;
 
-   case TX_E_PRIO_CHANGE:
-   tx-flags |=  BNA_TX_F_PRIO_CHANGED;
-   break;
-
case TX_E_BW_UPDATE:
tx-flags |= BNA_TX_F_BW_UPDATED;
break;
@@ -3028,7 +3019,6 @@ bna_tx_sm_started(struct bna_tx *tx, enum bna_tx_event 
event)
tx-tx_cleanup_cbfn(tx-bna-bnad, tx);
break;
 
-   case TX_E_PRIO_CHANGE:
case TX_E_BW_UPDATE:
bfa_fsm_set_state(tx, bna_tx_sm_prio_stop_wait);
break;
@@ -3061,7 +3051,6 @@ bna_tx_sm_stop_wait(struct bna_tx *tx, enum bna_tx_event 
event)
bna_tx_enet_stop(tx);
break;
 
-   case TX_E_PRIO_CHANGE:
case TX_E_BW_UPDATE:
/* No-op */
break;
@@ -3081,7 +3070,6 @@ bna_tx_sm_cleanup_wait(struct bna_tx *tx, enum 
bna_tx_event event)
 {
switch (event) {
case TX_E_FAIL:
-   case TX_E_PRIO_CHANGE:
case TX_E_BW_UPDATE:
/* No-op */
break;
@@ -3119,7 +3107,6 @@ bna_tx_sm_prio_stop_wait(struct bna_tx *tx, enum 
bna_tx_event event)
bfa_fsm_set_state(tx, bna_tx_sm_prio_cleanup_wait);
break;
 
-   case TX_E_PRIO_CHANGE:
case TX_E_BW_UPDATE:
/* No-op */
break;
@@ -3147,7 +3134,6 @@ bna_tx_sm_prio_cleanup_wait(struct bna_tx *tx, enum 
bna_tx_event event)
bfa_fsm_set_state(tx, bna_tx_sm_failed);
break;
 
-   case TX_E_PRIO_CHANGE:
case TX_E_BW_UPDATE:
/* No-op */
break;
diff --git a/drivers/net/ethernet/brocade/bna/bna_types.h 
b/drivers/net/ethernet/brocade/bna/bna_types.h
index 134abf7..e0e797f 100644
--- a/drivers/net/ethernet/brocade/bna/bna_types.h
+++ b/drivers/net/ethernet/brocade/bna/bna_types.h
@@ -135,7 +135,6 @@ enum bna_tx_type {
 enum bna_tx_flags {
BNA_TX_F_ENET_STARTED   = 1,
BNA_TX_F_ENABLED= 2,
-   BNA_TX_F_PRIO_CHANGED   = 4,
BNA_TX_F_BW_UPDATED = 8,
 };
 
-- 
2.3.6

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


[PATCH net-next 04/19] bna: get rid of duplicate and unused macros

2015-06-10 Thread Ivan Vecera
replaced macros:
BNA_MAC_IS_EQUAL - ether_addr_equal
BNA_POWER_OF_2 - is_power_of_2
BNA_TO_POWER_OF_2_HIGH - roundup_pow_of_two

removed unused macros:
bfa_fsm_get_state
bfa_ioc_clr_stats
bfa_ioc_fetch_stats
bfa_ioc_get_alt_ioc_fwstate
bfa_ioc_isr_mode_set
bfa_ioc_maxfrsize
bfa_ioc_mbox_cmd_pending
bfa_ioc_ownership_reset
bfa_ioc_rx_bbcredit
bfa_ioc_state_disabled
bfa_sm_cmp_state
bfa_sm_get_state
bfa_sm_send_event
bfa_sm_set_state
bfa_sm_state_decl
BFA_STRING_32
BFI_ADAPTER_IS_{PROTO,TTV,UNSUPP)
BFI_IOC_ENDIAN_SIG
BNA_{C,RX,TX}Q_PAGE_INDEX_MAX
BNA_{C,RX,TX}Q_PAGE_INDEX_MAX_SHIFT
BNA_{C,RX,TX}Q_QPGE_PTR_GET
BNA_IOC_TIMER_FREQ
BNA_MESSAGE_SIZE
BNA_QE_INDX_2_PTR
BNA_QE_INDX_RANGE
BNA_Q_GET_{C,P}I
BNA_Q_{C,P}I_ADD
BNA_Q_FREE_COUNT
BNA_Q_IN_USE_COUNT
BNA_TO_POWER_OF_2
containing_rec

Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bfa_cs.h   |  14 
 drivers/net/ethernet/brocade/bna/bfa_defs.h |   1 -
 drivers/net/ethernet/brocade/bna/bfa_ioc.c  |  14 
 drivers/net/ethernet/brocade/bna/bfa_ioc.h  |  13 ---
 drivers/net/ethernet/brocade/bna/bfi.h  |   8 --
 drivers/net/ethernet/brocade/bna/bna.h  | 105 +---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c|  13 ++-
 drivers/net/ethernet/brocade/bna/bnad_ethtool.c |   4 +-
 8 files changed, 9 insertions(+), 163 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_cs.h 
b/drivers/net/ethernet/brocade/bna/bfa_cs.h
index af25d8e..1d11d66 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_cs.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_cs.h
@@ -28,19 +28,6 @@
 
 typedef void (*bfa_sm_t)(void *sm, int event);
 
-/* oc - object class eg. bfa_ioc
- * st - state, eg. reset
- * otype - object type, eg. struct bfa_ioc
- * etype - object type, eg. enum ioc_event
- */
-#define bfa_sm_state_decl(oc, st, otype, etype)\
-   static void oc ## _sm_ ## st(otype * fsm, etype event)
-
-#define bfa_sm_set_state(_sm, _state)  ((_sm)-sm = (bfa_sm_t)(_state))
-#define bfa_sm_send_event(_sm, _event) ((_sm)-sm((_sm), (_event)))
-#define bfa_sm_get_state(_sm)  ((_sm)-sm)
-#define bfa_sm_cmp_state(_sm, _state)  ((_sm)-sm == (bfa_sm_t)(_state))
-
 /* For converting from state machine function to state encoding. */
 struct bfa_sm_table {
bfa_sm_tsm; /*! state machine function */
@@ -67,7 +54,6 @@ typedef void (*bfa_fsm_t)(void *fsm, int event);
 } while (0)
 
 #define bfa_fsm_send_event(_fsm, _event)   ((_fsm)-fsm((_fsm), (_event)))
-#define bfa_fsm_get_state(_fsm)((_fsm)-fsm)
 #define bfa_fsm_cmp_state(_fsm, _state)
\
((_fsm)-fsm == (bfa_fsm_t)(_state))
 
diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs.h 
b/drivers/net/ethernet/brocade/bna/bfa_defs.h
index 6827d91..d152b3f 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs.h
@@ -24,7 +24,6 @@
 #include bfa_defs_status.h
 #include bfa_defs_mfg_comm.h
 
-#define BFA_STRING_32  32
 #define BFA_VERSION_LEN 64
 
 /* -- adapter definitions  */
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index 82c95f8..29e0428 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -23,14 +23,6 @@
 
 /* IOC local definitions */
 
-#define bfa_ioc_state_disabled(__sm)   \
-   (((__sm) == BFI_IOC_UNINIT) ||  \
-((__sm) == BFI_IOC_INITING) || \
-((__sm) == BFI_IOC_HWINIT) ||  \
-((__sm) == BFI_IOC_DISABLED) ||\
-((__sm) == BFI_IOC_FAIL) ||\
-((__sm) == BFI_IOC_CFG_DISABLED))
-
 /* Asic specific macros : see bfa_hw_cb.c and bfa_hw_ct.c for details. */
 
 #define bfa_ioc_firmware_lock(__ioc)   \
@@ -57,12 +49,6 @@
((__ioc)-ioc_hwif-ioc_get_fwstate(__ioc))
 #define bfa_ioc_set_alt_ioc_fwstate(__ioc, __fwstate)  \
((__ioc)-ioc_hwif-ioc_set_alt_fwstate(__ioc, __fwstate))
-#define bfa_ioc_get_alt_ioc_fwstate(__ioc) \
-   ((__ioc)-ioc_hwif-ioc_get_alt_fwstate(__ioc))
-
-#define bfa_ioc_mbox_cmd_pending(__ioc)\
-   (!list_empty(((__ioc)-mbox_mod.cmd_q)) || \
-   readl((__ioc)-ioc_regs.hfn_mbox_cmd))
 
 static bool bfa_nw_auto_recover = true;
 
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.h 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.h
index b37bc16..b6ad2c5 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.h
@@ -232,12 +232,6 @@ struct bfa_ioc_hwif {
 #define bfa_ioc_asic_gen(__ioc)((__ioc)-asic_gen)
 #define bfa_ioc_is_default(__ioc)  \
(bfa_ioc_pcifn(__ioc) 

[PATCH net-next 05/19] bna: use BIT(x) instead of (1 x)

2015-06-10 Thread Ivan Vecera
Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 .../net/ethernet/brocade/bna/bfa_defs_mfg_comm.h   |  2 +-
 drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c  |  2 +-
 drivers/net/ethernet/brocade/bna/bfi_enet.h| 66 ++--
 drivers/net/ethernet/brocade/bna/bna_enet.c|  4 +-
 drivers/net/ethernet/brocade/bna/bna_hw_defs.h | 70 +++---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c   | 22 +++
 6 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs_mfg_comm.h 
b/drivers/net/ethernet/brocade/bna/bfa_defs_mfg_comm.h
index 679a503..16090fd 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs_mfg_comm.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs_mfg_comm.h
@@ -75,7 +75,7 @@ enum {
CB_GPIO_FC4P2   = (4),  /*! 4G 2port FC card   */
CB_GPIO_FC4P1   = (5),  /*! 4G 1port FC card   */
CB_GPIO_DFLY= (6),  /*! 8G 2port FC mezzanine card */
-   CB_GPIO_PROTO   = (1  7)  /*! 8G 2port FC prototypes */
+   CB_GPIO_PROTO   = BIT(7)/*! 8G 2port FC prototypes */
 };
 
 #define bfa_mfg_adapter_prop_init_gpio(gpio, card_type, prop)  \
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c 
b/drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c
index 2e72445..4247d8a 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c
@@ -24,7 +24,7 @@
 #include bfa_defs.h
 
 #define bfa_ioc_ct_sync_pos(__ioc) \
-   ((u32) (1  bfa_ioc_pcifn(__ioc)))
+   ((u32)BIT(bfa_ioc_pcifn(__ioc)))
 #define BFA_IOC_SYNC_REQD_SH   16
 #define bfa_ioc_ct_get_sync_ackd(__val) (__val  0x)
 #define bfa_ioc_ct_clear_sync_ackd(__val) (__val  0x)
diff --git a/drivers/net/ethernet/brocade/bna/bfi_enet.h 
b/drivers/net/ethernet/brocade/bna/bfi_enet.h
index fad3a12..d7be7ea8 100644
--- a/drivers/net/ethernet/brocade/bna/bfi_enet.h
+++ b/drivers/net/ethernet/brocade/bna/bfi_enet.h
@@ -68,13 +68,13 @@ union bfi_addr_be_u {
 #define BFI_ENET_TXQ_WI_EXTENSION  (0x104) /* Extension WI */
 
 /* TxQ Entry Control Flags */
-#define BFI_ENET_TXQ_WI_CF_FCOE_CRC(1  8)
-#define BFI_ENET_TXQ_WI_CF_IPID_MODE   (1  5)
-#define BFI_ENET_TXQ_WI_CF_INS_PRIO(1  4)
-#define BFI_ENET_TXQ_WI_CF_INS_VLAN(1  3)
-#define BFI_ENET_TXQ_WI_CF_UDP_CKSUM   (1  2)
-#define BFI_ENET_TXQ_WI_CF_TCP_CKSUM   (1  1)
-#define BFI_ENET_TXQ_WI_CF_IP_CKSUM(1  0)
+#define BFI_ENET_TXQ_WI_CF_FCOE_CRCBIT(8)
+#define BFI_ENET_TXQ_WI_CF_IPID_MODE   BIT(5)
+#define BFI_ENET_TXQ_WI_CF_INS_PRIOBIT(4)
+#define BFI_ENET_TXQ_WI_CF_INS_VLANBIT(3)
+#define BFI_ENET_TXQ_WI_CF_UDP_CKSUM   BIT(2)
+#define BFI_ENET_TXQ_WI_CF_TCP_CKSUM   BIT(1)
+#define BFI_ENET_TXQ_WI_CF_IP_CKSUMBIT(0)
 
 struct bfi_enet_txq_wi_base {
u8  reserved;
@@ -122,32 +122,32 @@ struct bfi_enet_rxq_entry {
 
 /*   R X   C O M P L E T I O N   Q U E U E   D E F I N E S   */
 /* CQ Entry Flags */
-#defineBFI_ENET_CQ_EF_MAC_ERROR(1   0)
-#defineBFI_ENET_CQ_EF_FCS_ERROR(1   1)
-#defineBFI_ENET_CQ_EF_TOO_LONG (1   2)
-#defineBFI_ENET_CQ_EF_FC_CRC_OK(1   3)
+#define BFI_ENET_CQ_EF_MAC_ERROR   BIT(0)
+#define BFI_ENET_CQ_EF_FCS_ERROR   BIT(1)
+#define BFI_ENET_CQ_EF_TOO_LONGBIT(2)
+#define BFI_ENET_CQ_EF_FC_CRC_OK   BIT(3)
 
-#defineBFI_ENET_CQ_EF_RSVD1(1   4)
-#defineBFI_ENET_CQ_EF_L4_CKSUM_OK  (1   5)
-#defineBFI_ENET_CQ_EF_L3_CKSUM_OK  (1   6)
-#defineBFI_ENET_CQ_EF_HDS_HEADER   (1   7)
+#define BFI_ENET_CQ_EF_RSVD1   BIT(4)
+#define BFI_ENET_CQ_EF_L4_CKSUM_OK BIT(5)
+#define BFI_ENET_CQ_EF_L3_CKSUM_OK BIT(6)
+#define BFI_ENET_CQ_EF_HDS_HEADER  BIT(7)
 
-#defineBFI_ENET_CQ_EF_UDP  (1   8)
-#defineBFI_ENET_CQ_EF_TCP  (1   9)
-#defineBFI_ENET_CQ_EF_IP_OPTIONS   (1  10)
-#defineBFI_ENET_CQ_EF_IPV6 (1  11)
+#define BFI_ENET_CQ_EF_UDP BIT(8)
+#define BFI_ENET_CQ_EF_TCP BIT(9)
+#define BFI_ENET_CQ_EF_IP_OPTIONS  BIT(10)
+#define BFI_ENET_CQ_EF_IPV6BIT(11)
 
-#defineBFI_ENET_CQ_EF_IPV4 (1  12)
-#defineBFI_ENET_CQ_EF_VLAN (1  13)
-#defineBFI_ENET_CQ_EF_RSS  (1  14)
-#defineBFI_ENET_CQ_EF_RSVD2(1  15)
+#define BFI_ENET_CQ_EF_IPV4BIT(12)
+#define BFI_ENET_CQ_EF_VLANBIT(13)
+#define BFI_ENET_CQ_EF_RSS BIT(14)
+#define BFI_ENET_CQ_EF_RSVD2   BIT(15)
 
-#defineBFI_ENET_CQ_EF_MCAST_MATCH  (1  16)
-#defineBFI_ENET_CQ_EF_MCAST(1  17)
-#define BFI_ENET_CQ_EF_BCAST   (1  18)
-#defineBFI_ENET_CQ_EF_REMOTE   (1  19)
+#define 

[PATCH net-next 06/19] bna: remove unused cbfn parameter

2015-06-10 Thread Ivan Vecera
removed:
bna_rx_ucast_add
bna_rx_ucast_del

simplified:
bna_enet_pause_config
bna_rx_mcast_delall
bna_rx_mcast_listset
bna_rx_mode_set
bna_rx_ucast_listset
bna_rx_ucast_set

Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bna.h  | 24 +
 drivers/net/ethernet/brocade/bna/bna_enet.c |  5 +---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c| 35 +++--
 drivers/net/ethernet/brocade/bna/bnad.c | 18 ++---
 drivers/net/ethernet/brocade/bna/bnad_ethtool.c |  2 +-
 5 files changed, 25 insertions(+), 59 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bna.h 
b/drivers/net/ethernet/brocade/bna/bna.h
index 130010d..0962e54 100644
--- a/drivers/net/ethernet/brocade/bna/bna.h
+++ b/drivers/net/ethernet/brocade/bna/bna.h
@@ -386,30 +386,19 @@ void bna_rx_coalescing_timeo_set(struct bna_rx *rx, int 
coalescing_timeo);
 void bna_rx_dim_reconfig(struct bna *bna, const u32 vector[][BNA_BIAS_T_MAX]);
 void bna_rx_dim_update(struct bna_ccb *ccb);
 enum bna_cb_status
-bna_rx_ucast_set(struct bna_rx *rx, u8 *ucmac,
-void (*cbfn)(struct bnad *, struct bna_rx *));
-enum bna_cb_status
-bna_rx_ucast_add(struct bna_rx *rx, u8* ucmac,
-void (*cbfn)(struct bnad *, struct bna_rx *));
-enum bna_cb_status
-bna_rx_ucast_del(struct bna_rx *rx, u8 *ucmac,
-void (*cbfn)(struct bnad *, struct bna_rx *));
+bna_rx_ucast_set(struct bna_rx *rx, u8 *ucmac);
 enum bna_cb_status
-bna_rx_ucast_listset(struct bna_rx *rx, int count, u8 *uclist,
-void (*cbfn)(struct bnad *, struct bna_rx *));
+bna_rx_ucast_listset(struct bna_rx *rx, int count, u8 *uclist);
 enum bna_cb_status
 bna_rx_mcast_add(struct bna_rx *rx, u8 *mcmac,
 void (*cbfn)(struct bnad *, struct bna_rx *));
 enum bna_cb_status
-bna_rx_mcast_listset(struct bna_rx *rx, int count, u8 *mcmac,
-void (*cbfn)(struct bnad *, struct bna_rx *));
+bna_rx_mcast_listset(struct bna_rx *rx, int count, u8 *mcmac);
 void
-bna_rx_mcast_delall(struct bna_rx *rx,
-   void (*cbfn)(struct bnad *, struct bna_rx *));
+bna_rx_mcast_delall(struct bna_rx *rx);
 enum bna_cb_status
 bna_rx_mode_set(struct bna_rx *rx, enum bna_rxmode rxmode,
-   enum bna_rxmode bitmask,
-   void (*cbfn)(struct bnad *, struct bna_rx *));
+   enum bna_rxmode bitmask);
 void bna_rx_vlan_add(struct bna_rx *rx, int vlan_id);
 void bna_rx_vlan_del(struct bna_rx *rx, int vlan_id);
 void bna_rx_vlanfilter_enable(struct bna_rx *rx);
@@ -429,8 +418,7 @@ void bna_enet_enable(struct bna_enet *enet);
 void bna_enet_disable(struct bna_enet *enet, enum bna_cleanup_type type,
  void (*cbfn)(void *));
 void bna_enet_pause_config(struct bna_enet *enet,
-  struct bna_pause_config *pause_config,
-  void (*cbfn)(struct bnad *));
+  struct bna_pause_config *pause_config);
 void bna_enet_mtu_set(struct bna_enet *enet, int mtu,
  void (*cbfn)(struct bnad *));
 void bna_enet_perm_mac_get(struct bna_enet *enet, u8 *mac);
diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c 
b/drivers/net/ethernet/brocade/bna/bna_enet.c
index 54902ce..b8de17b 100644
--- a/drivers/net/ethernet/brocade/bna/bna_enet.c
+++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
@@ -1308,13 +1308,10 @@ bna_enet_disable(struct bna_enet *enet, enum 
bna_cleanup_type type,
 
 void
 bna_enet_pause_config(struct bna_enet *enet,
- struct bna_pause_config *pause_config,
- void (*cbfn)(struct bnad *))
+ struct bna_pause_config *pause_config)
 {
enet-pause_config = *pause_config;
 
-   enet-pause_cbfn = cbfn;
-
bfa_fsm_send_event(enet, ENET_E_PAUSE_CFG);
 }
 
diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c 
b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
index 2c85f72..16d36df 100644
--- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
+++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
@@ -863,8 +863,7 @@ bna_rxf_fail(struct bna_rxf *rxf)
 }
 
 enum bna_cb_status
-bna_rx_ucast_set(struct bna_rx *rx, u8 *ucmac,
-void (*cbfn)(struct bnad *, struct bna_rx *))
+bna_rx_ucast_set(struct bna_rx *rx, u8 *ucmac)
 {
struct bna_rxf *rxf = rx-rxf;
 
@@ -878,7 +877,7 @@ bna_rx_ucast_set(struct bna_rx *rx, u8 *ucmac,
 
ether_addr_copy(rxf-ucast_pending_mac-addr, ucmac);
rxf-ucast_pending_set = 1;
-   rxf-cam_fltr_cbfn = cbfn;
+   rxf-cam_fltr_cbfn = NULL;
rxf-cam_fltr_cbarg = rx-bna-bnad;
 
bfa_fsm_send_event(rxf, RXF_E_CONFIG);
@@ -917,8 +916,7 @@ bna_rx_mcast_add(struct bna_rx *rx, u8 *addr,
 }
 
 enum bna_cb_status
-bna_rx_ucast_listset(struct bna_rx *rx, int count, u8 *uclist,
-void (*cbfn)(struct bnad *, struct bna_rx *))
+bna_rx_ucast_listset(struct bna_rx *rx, int 

[PATCH net-next 11/19] bna: remove paused from bna_rx_config and flags from bna_rxf

2015-06-10 Thread Ivan Vecera
The bna_rx_config struct member paused can be removed as it is never
written and as it cannot have non-zero value the bna_rxf struct member
flags also cannot have BNA_RXF_F_PAUSED value and is always zero.
So the flags member can be removed as well as bna_rxf_flags enum and
the code-paths that needs to have non-zero bna_rxf-flags.
This clean-up makes bna_rxf_sm_paused state unsed and can be also removed.
---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 36 +---
 drivers/net/ethernet/brocade/bna/bna_types.h |  6 -
 2 files changed, 1 insertion(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c 
b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
index ccf48a1..896aa82 100644
--- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
+++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
@@ -59,8 +59,6 @@ static int bna_rxf_allmulti_cfg_reset(struct bna_rxf *rxf,
 
 bfa_fsm_state_decl(bna_rxf, stopped, struct bna_rxf,
enum bna_rxf_event);
-bfa_fsm_state_decl(bna_rxf, paused, struct bna_rxf,
-   enum bna_rxf_event);
 bfa_fsm_state_decl(bna_rxf, cfg_wait, struct bna_rxf,
enum bna_rxf_event);
 bfa_fsm_state_decl(bna_rxf, started, struct bna_rxf,
@@ -79,11 +77,7 @@ bna_rxf_sm_stopped(struct bna_rxf *rxf, enum bna_rxf_event 
event)
 {
switch (event) {
case RXF_E_START:
-   if (rxf-flags  BNA_RXF_F_PAUSED) {
-   bfa_fsm_set_state(rxf, bna_rxf_sm_paused);
-   call_rxf_start_cbfn(rxf);
-   } else
-   bfa_fsm_set_state(rxf, bna_rxf_sm_cfg_wait);
+   bfa_fsm_set_state(rxf, bna_rxf_sm_cfg_wait);
break;
 
case RXF_E_STOP:
@@ -104,29 +98,6 @@ bna_rxf_sm_stopped(struct bna_rxf *rxf, enum bna_rxf_event 
event)
 }
 
 static void
-bna_rxf_sm_paused_entry(struct bna_rxf *rxf)
-{
-}
-
-static void
-bna_rxf_sm_paused(struct bna_rxf *rxf, enum bna_rxf_event event)
-{
-   switch (event) {
-   case RXF_E_STOP:
-   case RXF_E_FAIL:
-   bfa_fsm_set_state(rxf, bna_rxf_sm_stopped);
-   break;
-
-   case RXF_E_CONFIG:
-   call_rxf_cam_fltr_cbfn(rxf);
-   break;
-
-   default:
-   bfa_sm_fault(event);
-   }
-}
-
-static void
 bna_rxf_sm_cfg_wait_entry(struct bna_rxf *rxf)
 {
if (!bna_rxf_cfg_apply(rxf)) {
@@ -679,9 +650,6 @@ bna_rxf_init(struct bna_rxf *rxf,
INIT_LIST_HEAD(rxf-mcast_active_q);
INIT_LIST_HEAD(rxf-mcast_handle_q);
 
-   if (q_config-paused)
-   rxf-flags |= BNA_RXF_F_PAUSED;
-
rxf-rit = (u8 *)
res_info[BNA_RX_RES_MEM_T_RIT].res_u.mem_info.mdl[0].kva;
bna_rit_init(rxf, q_config-num_paths);
@@ -742,8 +710,6 @@ bna_rxf_uninit(struct bna_rxf *rxf)
rxf-rss_pending = 0;
rxf-vlan_strip_pending = false;
 
-   rxf-flags = 0;
-
rxf-rx = NULL;
 }
 
diff --git a/drivers/net/ethernet/brocade/bna/bna_types.h 
b/drivers/net/ethernet/brocade/bna/bna_types.h
index e56f650..134abf7 100644
--- a/drivers/net/ethernet/brocade/bna/bna_types.h
+++ b/drivers/net/ethernet/brocade/bna/bna_types.h
@@ -182,10 +182,6 @@ enum bna_rx_mod_flags {
BNA_RX_MOD_F_ENET_LOOPBACK  = 2,
 };
 
-enum bna_rxf_flags {
-   BNA_RXF_F_PAUSED= 1,
-};
-
 enum bna_rxf_event {
RXF_E_START = 1,
RXF_E_STOP  = 2,
@@ -668,7 +664,6 @@ struct bna_rx_config {
enum bna_rx_type rx_type;
int num_paths;
enum bna_rxp_type rxp_type;
-   int paused;
int coalescing_timeo;
/*
 * Small/Large (or Header/Data) buffer size to be configured
@@ -713,7 +708,6 @@ struct bna_rxp {
 /* RxF structure (hardware Rx Function) */
 struct bna_rxf {
bfa_fsm_t   fsm;
-   enum bna_rxf_flags flags;
 
struct bfa_msgq_cmd_entry msgq_cmd;
union {
-- 
2.3.6

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


[PATCH net-next 09/19] bna: remove prio_change_cbfn oper_state_cbfn from struct bna_tx

2015-06-10 Thread Ivan Vecera
Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 13 -
 drivers/net/ethernet/brocade/bna/bna_types.h |  3 ---
 2 files changed, 16 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c 
b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
index 27f75d7..471e74d 100644
--- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
+++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
@@ -3000,16 +3000,6 @@ do { 
\
}   \
 } while (0)
 
-#define call_tx_prio_change_cbfn(tx)   \
-do {   \
-   if ((tx)-prio_change_cbfn) {   \
-   void (*cbfn)(struct bnad *, struct bna_tx *);   \
-   cbfn = (tx)-prio_change_cbfn;  \
-   (tx)-prio_change_cbfn = NULL;  \
-   cbfn((tx)-bna-bnad, (tx));\
-   }   \
-} while (0)
-
 static void bna_tx_mod_cb_tx_stopped(void *tx_mod, struct bna_tx *tx);
 static void bna_bfi_tx_enet_start(struct bna_tx *tx);
 static void bna_tx_enet_stop(struct bna_tx *tx);
@@ -3062,7 +3052,6 @@ bna_tx_sm_stopped(struct bna_tx *tx, enum bna_tx_event 
event)
break;
 
case TX_E_PRIO_CHANGE:
-   call_tx_prio_change_cbfn(tx);
break;
 
case TX_E_BW_UPDATE:
@@ -3232,7 +3221,6 @@ bna_tx_sm_prio_stop_wait(struct bna_tx *tx, enum 
bna_tx_event event)
 
case TX_E_FAIL:
bfa_fsm_set_state(tx, bna_tx_sm_failed);
-   call_tx_prio_change_cbfn(tx);
tx-tx_cleanup_cbfn(tx-bna-bnad, tx);
break;
 
@@ -3253,7 +3241,6 @@ bna_tx_sm_prio_stop_wait(struct bna_tx *tx, enum 
bna_tx_event event)
 static void
 bna_tx_sm_prio_cleanup_wait_entry(struct bna_tx *tx)
 {
-   call_tx_prio_change_cbfn(tx);
tx-tx_cleanup_cbfn(tx-bna-bnad, tx);
 }
 
diff --git a/drivers/net/ethernet/brocade/bna/bna_types.h 
b/drivers/net/ethernet/brocade/bna/bna_types.h
index 96a02f2..095bd63 100644
--- a/drivers/net/ethernet/brocade/bna/bna_types.h
+++ b/drivers/net/ethernet/brocade/bna/bna_types.h
@@ -495,9 +495,6 @@ struct bna_tx {
void (*stop_cbfn)(void *arg, struct bna_tx *tx);
void*stop_cbarg;
 
-   /* callback for bna_tx_prio_set() */
-   void (*prio_change_cbfn)(struct bnad *bnad, struct bna_tx *tx);
-
struct bfa_msgq_cmd_entry msgq_cmd;
union {
struct bfi_enet_tx_cfg_req  cfg_req;
-- 
2.3.6

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


[PATCH net-next 01/19] bna: use ether_addr_copy instead of memcpy

2015-06-10 Thread Ivan Vecera
Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 12 ++--
 drivers/net/ethernet/brocade/bna/bnad.c  | 14 ++
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c 
b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
index 8ab3a5f..30d5e7f 100644
--- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
+++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
@@ -876,7 +876,7 @@ bna_rx_ucast_set(struct bna_rx *rx, u8 *ucmac,
bfa_q_qe_init(rxf-ucast_pending_mac-qe);
}
 
-   memcpy(rxf-ucast_pending_mac-addr, ucmac, ETH_ALEN);
+   ether_addr_copy(rxf-ucast_pending_mac-addr, ucmac);
rxf-ucast_pending_set = 1;
rxf-cam_fltr_cbfn = cbfn;
rxf-cam_fltr_cbarg = rx-bna-bnad;
@@ -905,7 +905,7 @@ bna_rx_mcast_add(struct bna_rx *rx, u8 *addr,
if (mac == NULL)
return BNA_CB_MCAST_LIST_FULL;
bfa_q_qe_init(mac-qe);
-   memcpy(mac-addr, addr, ETH_ALEN);
+   ether_addr_copy(mac-addr, addr);
list_add_tail(mac-qe, rxf-mcast_pending_add_q);
 
rxf-cam_fltr_cbfn = cbfn;
@@ -955,7 +955,7 @@ bna_rx_ucast_listset(struct bna_rx *rx, int count, u8 
*uclist,
if (mac == NULL)
goto err_return;
bfa_q_qe_init(mac-qe);
-   memcpy(mac-addr, mcaddr, ETH_ALEN);
+   ether_addr_copy(mac-addr, mcaddr);
list_add_tail(mac-qe, list_head);
mcaddr += ETH_ALEN;
}
@@ -1026,7 +1026,7 @@ bna_rx_mcast_listset(struct bna_rx *rx, int count, u8 
*mclist,
if (mac == NULL)
goto err_return;
bfa_q_qe_init(mac-qe);
-   memcpy(mac-addr, mcaddr, ETH_ALEN);
+   ether_addr_copy(mac-addr, mcaddr);
list_add_tail(mac-qe, list_head);
 
mcaddr += ETH_ALEN;
@@ -1149,8 +1149,8 @@ bna_rxf_ucast_cfg_apply(struct bna_rxf *rxf)
/* Set default unicast MAC */
if (rxf-ucast_pending_set) {
rxf-ucast_pending_set = 0;
-   memcpy(rxf-ucast_active_mac.addr,
-   rxf-ucast_pending_mac-addr, ETH_ALEN);
+   ether_addr_copy(rxf-ucast_active_mac.addr,
+   rxf-ucast_pending_mac-addr);
rxf-ucast_active_set = 1;
bna_bfi_ucast_req(rxf, rxf-ucast_active_mac,
BFI_ENET_H2I_MAC_UCAST_SET_REQ);
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c 
b/drivers/net/ethernet/brocade/bna/bnad.c
index caae6cb..bb87c11 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -875,9 +875,9 @@ bnad_set_netdev_perm_addr(struct bnad *bnad)
 {
struct net_device *netdev = bnad-netdev;
 
-   memcpy(netdev-perm_addr, bnad-perm_addr, netdev-addr_len);
+   ether_addr_copy(netdev-perm_addr, bnad-perm_addr.mac);
if (is_zero_ether_addr(netdev-dev_addr))
-   memcpy(netdev-dev_addr, bnad-perm_addr, netdev-addr_len);
+   ether_addr_copy(netdev-dev_addr, bnad-perm_addr.mac);
 }
 
 /* Control Path Handlers */
@@ -1862,8 +1862,7 @@ bnad_netdev_mc_list_get(struct net_device *netdev, u8 
*mc_list)
struct netdev_hw_addr *mc_addr;
 
netdev_for_each_mc_addr(mc_addr, netdev) {
-   memcpy(mc_list[i * ETH_ALEN], mc_addr-addr[0],
-   ETH_ALEN);
+   ether_addr_copy(mc_list[i * ETH_ALEN], mc_addr-addr[0]);
i++;
}
 }
@@ -3141,8 +3140,7 @@ bnad_set_rx_ucast_fltr(struct bnad *bnad)
 
entry = 0;
netdev_for_each_uc_addr(ha, netdev) {
-   memcpy(mac_list[entry * ETH_ALEN],
-  ha-addr[0], ETH_ALEN);
+   ether_addr_copy(mac_list[entry * ETH_ALEN], ha-addr[0]);
entry++;
}
 
@@ -3183,7 +3181,7 @@ bnad_set_rx_mcast_fltr(struct bnad *bnad)
if (mac_list == NULL)
goto mode_allmulti;
 
-   memcpy(mac_list[0], bnad_bcast_addr[0], ETH_ALEN);
+   ether_addr_copy(mac_list[0], bnad_bcast_addr[0]);
 
/* copy rest of the MCAST addresses */
bnad_netdev_mc_list_get(netdev, mac_list);
@@ -3260,7 +3258,7 @@ bnad_set_mac_address(struct net_device *netdev, void 
*mac_addr)
err = bnad_mac_addr_set_locked(bnad, sa-sa_data);
 
if (!err)
-   memcpy(netdev-dev_addr, sa-sa_data, netdev-addr_len);
+   ether_addr_copy(netdev-dev_addr, sa-sa_data);
 
spin_unlock_irqrestore(bnad-bna_lock, flags);
 
-- 
2.3.6

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


[PATCH net-next 10/19] bna: remove RXF_E_PAUSE and RXF_E_RESUME events

2015-06-10 Thread Ivan Vecera
RXF_E_PAUSE  RXF_E_RESUME events are never sent for bna_rxf object so
they needn't to be handled. The bna_rxf's state bna_rxf_sm_fltr_clr_wait
and function bna_rxf_fltr_clear are unused after this so remove them also.

Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 75 
 drivers/net/ethernet/brocade/bna/bna_types.h |  2 -
 2 files changed, 77 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c 
b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
index 471e74d..ccf48a1 100644
--- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
+++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
@@ -46,7 +46,6 @@ do {  
\
 
 static int bna_rxf_cfg_apply(struct bna_rxf *rxf);
 static void bna_rxf_cfg_reset(struct bna_rxf *rxf);
-static int bna_rxf_fltr_clear(struct bna_rxf *rxf);
 static int bna_rxf_ucast_cfg_apply(struct bna_rxf *rxf);
 static int bna_rxf_promisc_cfg_apply(struct bna_rxf *rxf);
 static int bna_rxf_allmulti_cfg_apply(struct bna_rxf *rxf);
@@ -66,8 +65,6 @@ bfa_fsm_state_decl(bna_rxf, cfg_wait, struct bna_rxf,
enum bna_rxf_event);
 bfa_fsm_state_decl(bna_rxf, started, struct bna_rxf,
enum bna_rxf_event);
-bfa_fsm_state_decl(bna_rxf, fltr_clr_wait, struct bna_rxf,
-   enum bna_rxf_event);
 bfa_fsm_state_decl(bna_rxf, last_resp_wait, struct bna_rxf,
enum bna_rxf_event);
 
@@ -101,14 +98,6 @@ bna_rxf_sm_stopped(struct bna_rxf *rxf, enum bna_rxf_event 
event)
call_rxf_cam_fltr_cbfn(rxf);
break;
 
-   case RXF_E_PAUSE:
-   rxf-flags |= BNA_RXF_F_PAUSED;
-   break;
-
-   case RXF_E_RESUME:
-   rxf-flags = ~BNA_RXF_F_PAUSED;
-   break;
-
default:
bfa_sm_fault(event);
}
@@ -132,11 +121,6 @@ bna_rxf_sm_paused(struct bna_rxf *rxf, enum bna_rxf_event 
event)
call_rxf_cam_fltr_cbfn(rxf);
break;
 
-   case RXF_E_RESUME:
-   rxf-flags = ~BNA_RXF_F_PAUSED;
-   bfa_fsm_set_state(rxf, bna_rxf_sm_cfg_wait);
-   break;
-
default:
bfa_sm_fault(event);
}
@@ -170,12 +154,6 @@ bna_rxf_sm_cfg_wait(struct bna_rxf *rxf, enum 
bna_rxf_event event)
/* No-op */
break;
 
-   case RXF_E_PAUSE:
-   rxf-flags |= BNA_RXF_F_PAUSED;
-   call_rxf_start_cbfn(rxf);
-   bfa_fsm_set_state(rxf, bna_rxf_sm_fltr_clr_wait);
-   break;
-
case RXF_E_FW_RESP:
if (!bna_rxf_cfg_apply(rxf)) {
/* No more pending config updates */
@@ -209,40 +187,6 @@ bna_rxf_sm_started(struct bna_rxf *rxf, enum bna_rxf_event 
event)
bfa_fsm_set_state(rxf, bna_rxf_sm_cfg_wait);
break;
 
-   case RXF_E_PAUSE:
-   rxf-flags |= BNA_RXF_F_PAUSED;
-   if (!bna_rxf_fltr_clear(rxf))
-   bfa_fsm_set_state(rxf, bna_rxf_sm_paused);
-   else
-   bfa_fsm_set_state(rxf, bna_rxf_sm_fltr_clr_wait);
-   break;
-
-   default:
-   bfa_sm_fault(event);
-   }
-}
-
-static void
-bna_rxf_sm_fltr_clr_wait_entry(struct bna_rxf *rxf)
-{
-}
-
-static void
-bna_rxf_sm_fltr_clr_wait(struct bna_rxf *rxf, enum bna_rxf_event event)
-{
-   switch (event) {
-   case RXF_E_FAIL:
-   bna_rxf_cfg_reset(rxf);
-   bfa_fsm_set_state(rxf, bna_rxf_sm_stopped);
-   break;
-
-   case RXF_E_FW_RESP:
-   if (!bna_rxf_fltr_clear(rxf)) {
-   /* No more pending CAM entries to clear */
-   bfa_fsm_set_state(rxf, bna_rxf_sm_paused);
-   }
-   break;
-
default:
bfa_sm_fault(event);
}
@@ -652,25 +596,6 @@ bna_rxf_cfg_apply(struct bna_rxf *rxf)
return 0;
 }
 
-/* Only software reset */
-static int
-bna_rxf_fltr_clear(struct bna_rxf *rxf)
-{
-   if (bna_rxf_ucast_cfg_reset(rxf, BNA_HARD_CLEANUP))
-   return 1;
-
-   if (bna_rxf_mcast_cfg_reset(rxf, BNA_HARD_CLEANUP))
-   return 1;
-
-   if (bna_rxf_promisc_cfg_reset(rxf, BNA_HARD_CLEANUP))
-   return 1;
-
-   if (bna_rxf_allmulti_cfg_reset(rxf, BNA_HARD_CLEANUP))
-   return 1;
-
-   return 0;
-}
-
 static void
 bna_rxf_cfg_reset(struct bna_rxf *rxf)
 {
diff --git a/drivers/net/ethernet/brocade/bna/bna_types.h 
b/drivers/net/ethernet/brocade/bna/bna_types.h
index 095bd63..e56f650 100644
--- a/drivers/net/ethernet/brocade/bna/bna_types.h
+++ b/drivers/net/ethernet/brocade/bna/bna_types.h
@@ -191,8 +191,6 @@ enum bna_rxf_event {
RXF_E_STOP  = 2,
RXF_E_FAIL  = 3,
   

[PATCH 04/12] fsl/fman: Add the FMan port FLIB

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

The FMan Port FLib provides basic API used by the drivers to
configure and control the FMan Port hardware.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/net/ethernet/freescale/fman/Kconfig|   1 +
 drivers/net/ethernet/freescale/fman/Makefile   |   2 +
 drivers/net/ethernet/freescale/fman/port/Makefile  |   3 +
 .../net/ethernet/freescale/fman/port/fman_port.c   | 619 +
 4 files changed, 625 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/port/Makefile
 create mode 100644 drivers/net/ethernet/freescale/fman/port/fman_port.c

diff --git a/drivers/net/ethernet/freescale/fman/Kconfig 
b/drivers/net/ethernet/freescale/fman/Kconfig
index 8aeae29..af42c3a 100644
--- a/drivers/net/ethernet/freescale/fman/Kconfig
+++ b/drivers/net/ethernet/freescale/fman/Kconfig
@@ -5,3 +5,4 @@ config FSL_FMAN
help
Freescale Data-Path Acceleration Architecture Frame Manager
(FMan) support
+
diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 2799c6f..50a4de2 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -3,3 +3,5 @@ subdir-ccflags-y += 
-I$(srctree)/drivers/net/ethernet/freescale/fman/flib
 obj-y  += fsl_fman.o
 
 fsl_fman-objs  := fman.o
+
+obj-y  += port/
diff --git a/drivers/net/ethernet/freescale/fman/port/Makefile 
b/drivers/net/ethernet/freescale/fman/port/Makefile
new file mode 100644
index 000..54b1fa4
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/port/Makefile
@@ -0,0 +1,3 @@
+obj-y  += fsl_fman_port.o
+
+fsl_fman_port-objs := fman_port.o
diff --git a/drivers/net/ethernet/freescale/fman/port/fman_port.c 
b/drivers/net/ethernet/freescale/fman/port/fman_port.c
new file mode 100644
index 000..6754c35
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/port/fman_port.c
@@ -0,0 +1,619 @@
+/*
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include common/general.h
+
+#include fman_common.h
+#include fsl_fman_port.h
+
+/* problem Eyal: the following should not be here*/
+#define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME   0x0028
+
+static uint32_t get_no_pcd_nia_bmi_ac_enc_frame(struct fman_port_cfg *cfg)
+{
+   if (cfg-errata_A006675)
+   return NIA_ENG_FM_CTL |
+   NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME;
+   else
+   return NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME;
+}
+
+static int init_bmi_rx(struct fman_port *port,
+  struct fman_port_cfg *cfg,
+  struct fman_port_params *params)
+{
+   struct fman_port_rx_bmi_regs __iomem *regs = port-bmi_regs-rx;
+   uint32_t tmp;
+
+   /* Rx Configuration register */
+   tmp = 0;
+   if (cfg-discard_override)
+   tmp |= BMI_PORT_CFG_FDOVR;
+   iowrite32be(tmp, regs-fmbm_rcfg);
+
+   /* DMA attributes */
+   tmp = (uint32_t)cfg-dma_swap_data  BMI_DMA_ATTR_SWP_SHIFT;
+   if (cfg-dma_ic_stash_on)
+   tmp |= BMI_DMA_ATTR_IC_STASH_ON;
+   if 

[PATCH net-next 08/19] bna: remove oper_state_cbfn from struct bna_rxf

2015-06-10 Thread Ivan Vecera
Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bna.h   | 15 ---
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c |  6 --
 drivers/net/ethernet/brocade/bna/bna_types.h |  4 
 3 files changed, 25 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bna.h 
b/drivers/net/ethernet/brocade/bna/bna.h
index 0962e54..4f16ee2 100644
--- a/drivers/net/ethernet/brocade/bna/bna.h
+++ b/drivers/net/ethernet/brocade/bna/bna.h
@@ -119,21 +119,6 @@ do {   
\
}   \
 } while (0)
 
-#definecall_rxf_pause_cbfn(rxf)
\
-do {   \
-   if ((rxf)-oper_state_cbfn) {   \
-   void (*cbfn)(struct bnad *, struct bna_rx *);   \
-   struct bnad *cbarg; \
-   cbfn = (rxf)-oper_state_cbfn;  \
-   cbarg = (rxf)-oper_state_cbarg;\
-   (rxf)-oper_state_cbfn = NULL;  \
-   (rxf)-oper_state_cbarg = NULL; \
-   cbfn(cbarg, rxf-rx);   \
-   }   \
-} while (0)
-
-#definecall_rxf_resume_cbfn(rxf) call_rxf_pause_cbfn(rxf)
-
 #define is_xxx_enable(mode, bitmask, xxx) ((bitmask  xxx)  (mode  xxx))
 
 #define is_xxx_disable(mode, bitmask, xxx) ((bitmask  xxx)  !(mode  xxx))
diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c 
b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
index 16d36df..27f75d7 100644
--- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
+++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
@@ -103,12 +103,10 @@ bna_rxf_sm_stopped(struct bna_rxf *rxf, enum 
bna_rxf_event event)
 
case RXF_E_PAUSE:
rxf-flags |= BNA_RXF_F_PAUSED;
-   call_rxf_pause_cbfn(rxf);
break;
 
case RXF_E_RESUME:
rxf-flags = ~BNA_RXF_F_PAUSED;
-   call_rxf_resume_cbfn(rxf);
break;
 
default:
@@ -119,7 +117,6 @@ bna_rxf_sm_stopped(struct bna_rxf *rxf, enum bna_rxf_event 
event)
 static void
 bna_rxf_sm_paused_entry(struct bna_rxf *rxf)
 {
-   call_rxf_pause_cbfn(rxf);
 }
 
 static void
@@ -166,7 +163,6 @@ bna_rxf_sm_cfg_wait(struct bna_rxf *rxf, enum bna_rxf_event 
event)
bna_rxf_cfg_reset(rxf);
call_rxf_start_cbfn(rxf);
call_rxf_cam_fltr_cbfn(rxf);
-   call_rxf_resume_cbfn(rxf);
bfa_fsm_set_state(rxf, bna_rxf_sm_stopped);
break;
 
@@ -197,7 +193,6 @@ bna_rxf_sm_started_entry(struct bna_rxf *rxf)
 {
call_rxf_start_cbfn(rxf);
call_rxf_cam_fltr_cbfn(rxf);
-   call_rxf_resume_cbfn(rxf);
 }
 
 static void
@@ -238,7 +233,6 @@ bna_rxf_sm_fltr_clr_wait(struct bna_rxf *rxf, enum 
bna_rxf_event event)
switch (event) {
case RXF_E_FAIL:
bna_rxf_cfg_reset(rxf);
-   call_rxf_pause_cbfn(rxf);
bfa_fsm_set_state(rxf, bna_rxf_sm_stopped);
break;
 
diff --git a/drivers/net/ethernet/brocade/bna/bna_types.h 
b/drivers/net/ethernet/brocade/bna/bna_types.h
index a50ee99..96a02f2 100644
--- a/drivers/net/ethernet/brocade/bna/bna_types.h
+++ b/drivers/net/ethernet/brocade/bna/bna_types.h
@@ -739,10 +739,6 @@ struct bna_rxf {
void (*stop_cbfn) (struct bna_rx *rx);
struct bna_rx *stop_cbarg;
 
-   /* callback for bna_rx_receive_pause() / bna_rx_receive_resume() */
-   void (*oper_state_cbfn) (struct bnad *bnad, struct bna_rx *rx);
-   struct bnad *oper_state_cbarg;
-
/**
 * callback for:
 *  bna_rxf_ucast_set()
-- 
2.3.6

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


[PATCH net-next 02/19] bna: get rid of mac_t

2015-06-10 Thread Ivan Vecera
The patch converts mac_t type to widely used 'u8 [ETH_ALEN]'.

Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bfa_defs.h |  4 ++--
 drivers/net/ethernet/brocade/bna/bfa_defs_cna.h |  2 +-
 drivers/net/ethernet/brocade/bna/bfa_ioc.c  |  8 
 drivers/net/ethernet/brocade/bna/bfa_ioc.h  |  2 +-
 drivers/net/ethernet/brocade/bna/bfi.h  |  6 +++---
 drivers/net/ethernet/brocade/bna/bfi_enet.h |  6 +++---
 drivers/net/ethernet/brocade/bna/bna.h  |  4 ++--
 drivers/net/ethernet/brocade/bna/bna_enet.c |  4 ++--
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c|  4 ++--
 drivers/net/ethernet/brocade/bna/bnad.c | 10 +-
 drivers/net/ethernet/brocade/bna/bnad.h |  2 +-
 drivers/net/ethernet/brocade/bna/cna.h  |  6 --
 12 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs.h 
b/drivers/net/ethernet/brocade/bna/bfa_defs.h
index 3bfd9da..f55887b 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs.h
@@ -55,7 +55,7 @@ struct bfa_adapter_attr {
charoptrom_ver[BFA_VERSION_LEN];
charos_type[BFA_ADAPTER_OS_TYPE_LEN];
struct bfa_mfg_vpd vpd;
-   struct mac mac;
+   u8  mac[ETH_ALEN];
 
u8  nports;
u8  max_speed;
@@ -211,7 +211,7 @@ struct bfa_mfg_block {
charsupplier_partnum[STRSZ(BFA_MFG_SUPPLIER_PARTNUM_SIZE)];
charsupplier_serialnum[STRSZ(BFA_MFG_SUPPLIER_SERIALNUM_SIZE)];
charsupplier_revision[STRSZ(BFA_MFG_SUPPLIER_REVISION_SIZE)];
-   mac_t   mfg_mac;/* base mac address */
+   u8  mfg_mac[ETH_ALEN]; /* base mac address */
u8  num_mac;/* number of mac addresses */
u8  rsv2;
u32 card_type;  /* card type  */
diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs_cna.h 
b/drivers/net/ethernet/brocade/bna/bfa_defs_cna.h
index a37326d..ce0b228 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs_cna.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs_cna.h
@@ -188,7 +188,7 @@ struct bfa_cee_attr {
u8 error_reason;
struct bfa_cee_lldp_cfg lldp_remote;
struct bfa_cee_dcbx_cfg dcbx_remote;
-   mac_t src_mac;
+   u8 src_mac[ETH_ALEN];
u8 link_speed;
u8 nw_priority;
u8 filler[2];
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index 68f3c13..82c95f8 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -2796,7 +2796,7 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc *ioc,
ad_attr-prototype = 0;
 
ad_attr-pwwn = bfa_ioc_get_pwwn(ioc);
-   ad_attr-mac  = bfa_nw_ioc_get_mac(ioc);
+   bfa_nw_ioc_get_mac(ioc, ad_attr-mac);
 
ad_attr-pcie_gen = ioc_attr-pcie_gen;
ad_attr-pcie_lanes = ioc_attr-pcie_lanes;
@@ -2942,10 +2942,10 @@ bfa_ioc_get_pwwn(struct bfa_ioc *ioc)
return ioc-attr-pwwn;
 }
 
-mac_t
-bfa_nw_ioc_get_mac(struct bfa_ioc *ioc)
+void
+bfa_nw_ioc_get_mac(struct bfa_ioc *ioc, u8 *mac)
 {
-   return ioc-attr-mac;
+   ether_addr_copy(mac, ioc-attr-mac);
 }
 
 /* Firmware failure detected. Start recovery actions. */
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.h 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.h
index effb715..b37bc16 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.h
@@ -309,7 +309,7 @@ void bfa_nw_ioc_fwver_get(struct bfa_ioc *ioc,
struct bfi_ioc_image_hdr *fwhdr);
 bool bfa_nw_ioc_fwver_cmp(struct bfa_ioc *ioc,
struct bfi_ioc_image_hdr *fwhdr);
-mac_t bfa_nw_ioc_get_mac(struct bfa_ioc *ioc);
+void bfa_nw_ioc_get_mac(struct bfa_ioc *ioc, u8 *mac);
 void bfa_nw_ioc_debug_memclaim(struct bfa_ioc *ioc, void *dbg_fwsave);
 int bfa_nw_ioc_debug_fwtrc(struct bfa_ioc *ioc, void *trcdata, int *trclen);
 int bfa_nw_ioc_debug_fwsave(struct bfa_ioc *ioc, void *trcdata, int *trclen);
diff --git a/drivers/net/ethernet/brocade/bna/bfi.h 
b/drivers/net/ethernet/brocade/bna/bfi.h
index 2bcde40..63645ac 100644
--- a/drivers/net/ethernet/brocade/bna/bfi.h
+++ b/drivers/net/ethernet/brocade/bna/bfi.h
@@ -189,14 +189,14 @@ struct bfi_ioc_getattr_req {
 struct bfi_ioc_attr {
u64 mfg_pwwn;   /*! Mfg port wwn  */
u64 mfg_nwwn;   /*! Mfg node wwn  */
-   mac_t   mfg_mac;/*! Mfg mac   */
+   u8  mfg_mac[ETH_ALEN]; /*! Mfg mac*/
u8  port_mode;  /* enum bfi_port_mode  */
u8  rsvd_a;
u64 pwwn;
u64 nwwn;
-   mac_t   mac;/*! PBC or Mfg mac*/
+  

[PATCH net-next 13/19] bna: correct comparisons/assignments to bool

2015-06-10 Thread Ivan Vecera
Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bfa_ioc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index 29e0428..52fc439 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -1373,7 +1373,7 @@ static enum bfi_ioc_img_ver_cmp
 bfa_ioc_fw_ver_patch_cmp(struct bfi_ioc_image_hdr *base_fwhdr,
 struct bfi_ioc_image_hdr *fwhdr_to_cmp)
 {
-   if (bfa_ioc_fw_ver_compatible(base_fwhdr, fwhdr_to_cmp) == false)
+   if (!bfa_ioc_fw_ver_compatible(base_fwhdr, fwhdr_to_cmp))
return BFI_IOC_IMG_VER_INCOMP;
 
if (fwhdr_to_cmp-fwver.patch  base_fwhdr-fwver.patch)
@@ -1384,7 +1384,7 @@ bfa_ioc_fw_ver_patch_cmp(struct bfi_ioc_image_hdr 
*base_fwhdr,
/* GA takes priority over internal builds of the same patch stream.
 * At this point major minor maint and patch numbers are same.
 */
-   if (fwhdr_is_ga(base_fwhdr) == true)
+   if (fwhdr_is_ga(base_fwhdr))
if (fwhdr_is_ga(fwhdr_to_cmp))
return BFI_IOC_IMG_VER_SAME;
else
@@ -2209,7 +2209,7 @@ bfa_nw_ioc_smem_read(struct bfa_ioc *ioc, void *tbuf, u32 
soff, u32 sz)
/*
 *  Hold semaphore to serialize pll init and fwtrc.
*/
-   if (bfa_nw_ioc_sem_get(ioc-ioc_regs.ioc_init_sem_reg) == 0)
+   if (!bfa_nw_ioc_sem_get(ioc-ioc_regs.ioc_init_sem_reg))
return 1;
 
writel(pgnum, ioc-ioc_regs.host_page_num_fn);
@@ -2264,7 +2264,7 @@ bfa_nw_ioc_debug_save_ftrc(struct bfa_ioc *ioc)
int tlen;
 
if (ioc-dbg_fwsave_once) {
-   ioc-dbg_fwsave_once = 0;
+   ioc-dbg_fwsave_once = false;
if (ioc-dbg_fwsave_len) {
tlen = ioc-dbg_fwsave_len;
bfa_nw_ioc_debug_fwtrc(ioc, ioc-dbg_fwsave, tlen);
-- 
2.3.6

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


[PATCH net-next 00/19] bna: clean-up

2015-06-10 Thread Ivan Vecera
The patches clean the bna driver.

Ivan Vecera (19):
  bna: use ether_addr_copy instead of memcpy
  bna: get rid of mac_t
  bna: replace pragma(pack) with attribute __packed
  bna: get rid of duplicate and unused macros
  bna: use BIT(x) instead of (1  x)
  bna: remove unused cbfn parameter
  bna: remove pause_cbfn from struct bna_enet
  bna: remove oper_state_cbfn from struct bna_rxf
  bna: remove prio_change_cbfn oper_state_cbfn from struct bna_tx
  bna: remove RXF_E_PAUSE and RXF_E_RESUME events
  bna: remove paused from bna_rx_config and flags from bna_rxf
  bna: remove TX_E_PRIO_CHANGE event and BNA_TX_F_PRIO_CHANGED flag
  bna: correct comparisons/assignments to bool
  bna: use memdup_user to copy userspace buffers
  bna: remove useless pointer assignment
  bna: get rid of private macros for manipulation with lists
  bna: use list_for_each_entry where appropriate
  bna: fix timeout API argument type
  bna: use netdev_* and dev_* instead of printk and pr_*

 drivers/net/ethernet/brocade/bna/bfa_cee.c |   1 -
 drivers/net/ethernet/brocade/bna/bfa_cs.h  |  14 -
 drivers/net/ethernet/brocade/bna/bfa_defs.h|  11 +-
 drivers/net/ethernet/brocade/bna/bfa_defs_cna.h|  16 +-
 .../net/ethernet/brocade/bna/bfa_defs_mfg_comm.h   |   8 +-
 drivers/net/ethernet/brocade/bna/bfa_ioc.c |  61 +-
 drivers/net/ethernet/brocade/bna/bfa_ioc.h |  23 +-
 drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c  |   2 +-
 drivers/net/ethernet/brocade/bna/bfa_msgq.c|  10 +-
 drivers/net/ethernet/brocade/bna/bfi.h |  84 ++-
 drivers/net/ethernet/brocade/bna/bfi_cna.h |  30 +-
 drivers/net/ethernet/brocade/bna/bfi_enet.h| 176 +++---
 drivers/net/ethernet/brocade/bna/bna.h | 186 +-
 drivers/net/ethernet/brocade/bna/bna_enet.c| 101 +---
 drivers/net/ethernet/brocade/bna/bna_hw_defs.h |  70 +--
 drivers/net/ethernet/brocade/bna/bna_tx_rx.c   | 665 +
 drivers/net/ethernet/brocade/bna/bna_types.h   |  19 -
 drivers/net/ethernet/brocade/bna/bnad.c|  93 ++-
 drivers/net/ethernet/brocade/bna/bnad.h|   2 +-
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c|  61 +-
 drivers/net/ethernet/brocade/bna/bnad_ethtool.c|  15 +-
 drivers/net/ethernet/brocade/bna/cna.h |  62 --
 drivers/net/ethernet/brocade/bna/cna_fwimg.c   |   2 +-
 23 files changed, 487 insertions(+), 1225 deletions(-)

-- 
2.3.6

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


[PATCH net-next 03/19] bna: replace pragma(pack) with attribute __packed

2015-06-10 Thread Ivan Vecera
Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bfa_defs.h|   6 +-
 drivers/net/ethernet/brocade/bna/bfa_defs_cna.h|  14 +--
 .../net/ethernet/brocade/bna/bfa_defs_mfg_comm.h   |   6 +-
 drivers/net/ethernet/brocade/bna/bfi.h |  70 +++---
 drivers/net/ethernet/brocade/bna/bfi_cna.h |  30 +++---
 drivers/net/ethernet/brocade/bna/bfi_enet.h| 104 ++---
 6 files changed, 103 insertions(+), 127 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs.h 
b/drivers/net/ethernet/brocade/bna/bfa_defs.h
index f55887b..6827d91 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs.h
@@ -187,8 +187,6 @@ enum {
 #define BFA_MFG_SUPPLIER_SERIALNUM_SIZE20
 #define BFA_MFG_SUPPLIER_REVISION_SIZE 4
 
-#pragma pack(1)
-
 /* BFA adapter manufacturing block definition.
  *
  * All numerical fields are in big-endian format.
@@ -227,9 +225,7 @@ struct bfa_mfg_block {
charinitial_mode[8]; /* initial mode: hba/cna/nic */
u8  rsv4[84];
u8  md5_chksum[BFA_MFG_CHKSUM_SIZE]; /* md5 checksum */
-};
-
-#pragma pack()
+} __packed;
 
 /* -- pci definitions  */
 
diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs_cna.h 
b/drivers/net/ethernet/brocade/bna/bfa_defs_cna.h
index ce0b228..f048887 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs_cna.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs_cna.h
@@ -109,8 +109,6 @@ union bfa_port_stats_u {
struct bfa_port_eth_stats eth;
 };
 
-#pragma pack(1)
-
 #define BFA_CEE_LLDP_MAX_STRING_LEN (128)
 #define BFA_CEE_DCBX_MAX_PRIORITY  (8)
 #define BFA_CEE_DCBX_MAX_PGID  (8)
@@ -133,7 +131,7 @@ struct bfa_cee_lldp_str {
u8 len;
u8 rsvd[2];
u8 value[BFA_CEE_LLDP_MAX_STRING_LEN];
-};
+} __packed;
 
 /* LLDP parameters */
 struct bfa_cee_lldp_cfg {
@@ -145,7 +143,7 @@ struct bfa_cee_lldp_cfg {
struct bfa_cee_lldp_str mgmt_addr;
u16 time_to_live;
u16 enabled_system_cap;
-};
+} __packed;
 
 enum bfa_cee_dcbx_version {
DCBX_PROTOCOL_PRECEE= 1,
@@ -171,7 +169,7 @@ struct bfa_cee_dcbx_cfg {
u8 lls_fcoe; /* FCoE Logical Link Status */
u8 lls_lan; /* LAN Logical Link Status */
u8 rsvd[2];
-};
+} __packed;
 
 /* CEE status */
 /* Making this to tri-state for the benefit of port list command */
@@ -192,7 +190,7 @@ struct bfa_cee_attr {
u8 link_speed;
u8 nw_priority;
u8 filler[2];
-};
+} __packed;
 
 /* LLDP/DCBX/CEE Statistics */
 struct bfa_cee_stats {
@@ -214,8 +212,6 @@ struct bfa_cee_stats {
u32 cee_status_up;  /*! CEE status up */
u32 cee_hw_cfg_changed; /*! CEE hw cfg changed */
u32 cee_rx_invalid_cfg; /*! CEE invalid cfg */
-};
-
-#pragma pack()
+} __packed;
 
 #endif /* __BFA_DEFS_CNA_H__ */
diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs_mfg_comm.h 
b/drivers/net/ethernet/brocade/bna/bfa_defs_mfg_comm.h
index 7a45cd0..679a503 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs_mfg_comm.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs_mfg_comm.h
@@ -59,8 +59,6 @@ enum {
BFA_MFG_TYPE_INVALID = 0,/*! Invalid card type */
 };
 
-#pragma pack(1)
-
 /* Check if Mezz card */
 #define bfa_mfg_is_mezz(type) (( \
(type) == BFA_MFG_TYPE_JAYHAWK || \
@@ -148,8 +146,6 @@ struct bfa_mfg_vpd {
u8  len;/*! vpd data length excluding header */
u8  rsv;
u8  data[BFA_MFG_VPD_LEN];  /*! vpd data */
-};
-
-#pragma pack()
+} __packed;
 
 #endif /* __BFA_DEFS_MFG_H__ */
diff --git a/drivers/net/ethernet/brocade/bna/bfi.h 
b/drivers/net/ethernet/brocade/bna/bfi.h
index 63645ac..3e97077 100644
--- a/drivers/net/ethernet/brocade/bna/bfi.h
+++ b/drivers/net/ethernet/brocade/bna/bfi.h
@@ -21,8 +21,6 @@
 
 #include bfa_defs.h
 
-#pragma pack(1)
-
 /* BFI FW image type */
 #defineBFI_FLASH_CHUNK_SZ  256 /*! Flash 
chunk size */
 #defineBFI_FLASH_CHUNK_SZ_WORDS(BFI_FLASH_CHUNK_SZ/sizeof(u32))
@@ -36,10 +34,10 @@ struct bfi_mhdr {
struct {
u8  qid;
u8  fn_lpu; /*! msg destination*/
-   } h2i;
+   } __packed h2i;
u16 i2htok; /*! token in msgs to host  */
-   } mtag;
-};
+   } __packed mtag;
+} __packed;
 
 #define bfi_fn_lpu(__fn, __lpu)((__fn)  1 | (__lpu))
 #define bfi_mhdr_2_fn(_mh) ((_mh)-mtag.h2i.fn_lpu  1)
@@ -75,14 +73,14 @@ union bfi_addr_u {
struct {
u32 addr_lo;
u32 addr_hi;
-   } a32;
-};
+   } __packed a32;
+} __packed;
 
 /* Generic DMA addr-len pair. */
 struct bfi_alen {
union bfi_addr_ual_addr;/* DMA 

[PATCH net-next 07/19] bna: remove pause_cbfn from struct bna_enet

2015-06-10 Thread Ivan Vecera
Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bna_enet.c  | 15 ---
 drivers/net/ethernet/brocade/bna/bna_types.h |  3 ---
 2 files changed, 18 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c 
b/drivers/net/ethernet/brocade/bna/bna_enet.c
index b8de17b..dc9f73b 100644
--- a/drivers/net/ethernet/brocade/bna/bna_enet.c
+++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
@@ -884,16 +884,6 @@ do {   
\
}   \
 } while (0)
 
-#define call_enet_pause_cbfn(enet) \
-do {   \
-   if ((enet)-pause_cbfn) {   \
-   void (*cbfn)(struct bnad *);\
-   cbfn = (enet)-pause_cbfn;  \
-   (enet)-pause_cbfn = NULL;  \
-   cbfn((enet)-bna-bnad);\
-   }   \
-} while (0)
-
 #define call_enet_mtu_cbfn(enet)   \
 do {   \
if ((enet)-mtu_cbfn) { \
@@ -925,7 +915,6 @@ bfa_fsm_state_decl(bna_enet, chld_stop_wait, struct 
bna_enet,
 static void
 bna_enet_sm_stopped_entry(struct bna_enet *enet)
 {
-   call_enet_pause_cbfn(enet);
call_enet_mtu_cbfn(enet);
call_enet_stop_cbfn(enet);
 }
@@ -947,7 +936,6 @@ bna_enet_sm_stopped(struct bna_enet *enet, enum 
bna_enet_event event)
break;
 
case ENET_E_PAUSE_CFG:
-   call_enet_pause_cbfn(enet);
break;
 
case ENET_E_MTU_CFG:
@@ -1039,7 +1027,6 @@ bna_enet_sm_started_entry(struct bna_enet *enet)
 * NOTE: Do not call bna_enet_chld_start() here, since it will be
 * inadvertently called during cfg_wait-started transition as well
 */
-   call_enet_pause_cbfn(enet);
call_enet_mtu_cbfn(enet);
 }
 
@@ -1211,8 +1198,6 @@ bna_enet_init(struct bna_enet *enet, struct bna *bna)
enet-stop_cbfn = NULL;
enet-stop_cbarg = NULL;
 
-   enet-pause_cbfn = NULL;
-
enet-mtu_cbfn = NULL;
 
bfa_fsm_set_state(enet, bna_enet_sm_stopped);
diff --git a/drivers/net/ethernet/brocade/bna/bna_types.h 
b/drivers/net/ethernet/brocade/bna/bna_types.h
index d0a7a56..a50ee99 100644
--- a/drivers/net/ethernet/brocade/bna/bna_types.h
+++ b/drivers/net/ethernet/brocade/bna/bna_types.h
@@ -362,9 +362,6 @@ struct bna_enet {
void (*stop_cbfn)(void *);
void*stop_cbarg;
 
-   /* Callback for bna_enet_pause_config() */
-   void (*pause_cbfn)(struct bnad *);
-
/* Callback for bna_enet_mtu_set() */
void (*mtu_cbfn)(struct bnad *);
 
-- 
2.3.6

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


[PATCH 12/12] fsl/fman: Add FMan MAC driver

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

This patch adds the Ethernet MAC driver support.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
Signed-off-by: Madalin Bucur madalin.bu...@freescale.com
---
 drivers/net/ethernet/freescale/fman/inc/mac.h | 136 
 drivers/net/ethernet/freescale/fman/mac/Makefile  |   3 +-
 drivers/net/ethernet/freescale/fman/mac/mac-api.c | 765 ++
 drivers/net/ethernet/freescale/fman/mac/mac.c | 526 +++
 4 files changed, 1429 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/inc/mac.h
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/mac-api.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/mac.c

diff --git a/drivers/net/ethernet/freescale/fman/inc/mac.h 
b/drivers/net/ethernet/freescale/fman/inc/mac.h
new file mode 100644
index 000..0111f4c
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/inc/mac.h
@@ -0,0 +1,136 @@
+/* Copyright 2008-2015 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __MAC_H
+#define __MAC_H
+
+#include linux/device.h  /* struct device, BUS_ID_SIZE */
+#include linux/if_ether.h/* ETH_ALEN */
+#include linux/phy.h /* phy_interface_t, struct phy_device */
+#include linux/list.h
+
+#include enet_ext.h
+
+#include fsl_fman_drv.h  /* struct port_device */
+#include fm_port_ext.h
+
+struct fm_mac_dev;
+enum fm_mac_exceptions;
+
+enum {DTSEC, XGMAC, MEMAC};
+
+struct mac_device {
+   struct device   *dev;
+   void*priv;
+   u8   cell_index;
+   struct resource *res;
+   void __iomem*vaddr;
+   u8   addr[ETH_ALEN];
+   bool promisc;
+
+   struct fm   *fm_dev;
+   struct fm_port_drv_t*port_dev[2];
+
+   phy_interface_t  phy_if;
+   u32  if_support;
+   bool link;
+   u16  speed;
+   u16  max_speed;
+   struct device_node  *phy_node;
+   char fixed_bus_id[MII_BUS_ID_SIZE + 3];
+   struct device_node  *tbi_node;
+   struct phy_device   *phy_dev;
+   void*fm;
+   /* List of multicast addresses */
+   struct list_head mc_addr_list;
+   struct platform_device  *eth_dev;
+
+   bool autoneg_pause;
+   bool rx_pause_req;
+   bool tx_pause_req;
+   bool rx_pause_active;
+   bool tx_pause_active;
+
+   int (*init_phy)(struct net_device *net_dev, struct mac_device *mac_dev);
+   int (*init)(struct mac_device *mac_dev);
+   int (*start)(struct mac_device *mac_dev);
+   int (*stop)(struct mac_device *mac_dev);
+   int (*set_promisc)(struct fm_mac_dev *fm_mac_dev, bool enable);
+   int (*change_addr)(struct fm_mac_dev *fm_mac_dev,
+  enet_addr_t *p_enet_addr);
+   int (*set_multi)(struct net_device *net_dev,
+struct mac_device *mac_dev);
+   int (*uninit)(struct fm_mac_dev *fm_mac_dev);
+   int (*set_rx_pause)(struct fm_mac_dev *fm_mac_dev, bool en);
+   int 

[V6 PATCH 1/7] ACPI / scan: Parse _CCA and setup device coherency

2015-06-10 Thread Suravee Suthikulpanit
This patch implements support for ACPI _CCA object, which is introduced in
ACPIv5.1, can be used for specifying device DMA coherency attribute.

The parsing logic traverses device namespace to parse coherency
information, and stores it in acpi_device_flags. Then uses it to call
arch_setup_dma_ops() when creating each device enumerated in DSDT
during ACPI scan.

This patch also introduces acpi_dma_is_coherent(), which provides
an interface for device drivers to check the coherency information
similarly to the of_dma_is_coherent().

Signed-off-by: Mark Salter msal...@redhat.com
Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
---
 drivers/acpi/Kconfig |  3 +++
 drivers/acpi/acpi_platform.c |  2 +-
 drivers/acpi/glue.c  |  5 +
 drivers/acpi/scan.c  | 35 +++
 include/acpi/acpi_bus.h  | 37 -
 include/linux/acpi.h |  5 +
 6 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index ab2cbb5..212735f 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -54,6 +54,9 @@ config ACPI_GENERIC_GSI
 config ACPI_SYSTEM_POWER_STATES_SUPPORT
bool
 
+config ACPI_CCA_REQUIRED
+   bool
+
 config ACPI_SLEEP
bool
depends on SUSPEND || HIBERNATION
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 4bf7559..06a67d5 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -103,7 +103,7 @@ struct platform_device *acpi_create_platform_device(struct 
acpi_device *adev)
pdevinfo.res = resources;
pdevinfo.num_res = count;
pdevinfo.fwnode = acpi_fwnode_handle(adev);
-   pdevinfo.dma_mask = DMA_BIT_MASK(32);
+   pdevinfo.dma_mask = acpi_check_dma(adev, NULL) ? DMA_BIT_MASK(32) : 0;
pdev = platform_device_register_full(pdevinfo);
if (IS_ERR(pdev))
dev_err(adev-dev, platform device creation failed: %ld\n,
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 39c485b..b9657af 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -13,6 +13,7 @@
 #include linux/slab.h
 #include linux/rwsem.h
 #include linux/acpi.h
+#include linux/dma-mapping.h
 
 #include internal.h
 
@@ -167,6 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device 
*acpi_dev)
struct list_head *physnode_list;
unsigned int node_id;
int retval = -EINVAL;
+   bool coherent;
 
if (has_acpi_companion(dev)) {
if (acpi_dev) {
@@ -223,6 +225,9 @@ int acpi_bind_one(struct device *dev, struct acpi_device 
*acpi_dev)
if (!has_acpi_companion(dev))
ACPI_COMPANION_SET(dev, acpi_dev);
 
+   if (acpi_check_dma(acpi_dev, coherent))
+   arch_setup_dma_ops(dev, 0, 0, NULL, coherent);
+
acpi_physnode_link_name(physical_node_name, node_id);
retval = sysfs_create_link(acpi_dev-dev.kobj, dev-kobj,
   physical_node_name);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 849b699..fdedb63 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -11,6 +11,7 @@
 #include linux/kthread.h
 #include linux/dmi.h
 #include linux/nls.h
+#include linux/dma-mapping.h
 
 #include asm/pgtable.h
 
@@ -2137,6 +2138,39 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp)
kfree(pnp-unique_id);
 }
 
+static void acpi_init_coherency(struct acpi_device *adev)
+{
+   unsigned long long cca = 0;
+   acpi_status status;
+   struct acpi_device *parent = adev-parent;
+
+   if (parent  parent-flags.cca_seen) {
+   /*
+* From ACPI spec, OSPM will ignore _CCA if an ancestor
+* already saw one.
+*/
+   adev-flags.cca_seen = 1;
+   cca = parent-flags.coherent_dma;
+   } else {
+   status = acpi_evaluate_integer(adev-handle, _CCA,
+  NULL, cca);
+   if (ACPI_SUCCESS(status))
+   adev-flags.cca_seen = 1;
+   else if (!IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED))
+   /*
+* If architecture does not specify that _CCA is
+* required for DMA-able devices (e.g. x86),
+* we default to _CCA=1.
+*/
+   cca = 1;
+   else
+   acpi_handle_debug(adev-handle,
+ ACPI device is missing _CCA.\n);
+   }
+
+   adev-flags.coherent_dma = cca;
+}
+
 void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 int type, unsigned long long sta)
 {
@@ -2155,6 +2189,7 @@ void acpi_init_device_object(struct acpi_device *device, 
acpi_handle handle,
device-flags.visited = false;

[V6 PATCH 5/7] amd-xgbe: Unify coherency checking logic with device_dma_is_coherent()

2015-06-10 Thread Suravee Suthikulpanit
Currently, amd-xgbe driver has separate logic to determine device
coherency for DT vs. ACPI. This patch simplifies the code with
a call to device_dma_is_coherent().

Signed-off-by: Tom Lendacky thomas.lenda...@amd.com
Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
---
 drivers/net/ethernet/amd/xgbe/xgbe-main.c | 27 +--
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index 7149053..6d2c702 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -168,13 +168,8 @@ static void xgbe_init_all_fptrs(struct xgbe_prv_data 
*pdata)
 #ifdef CONFIG_ACPI
 static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
 {
-   struct acpi_device *adev = pdata-adev;
struct device *dev = pdata-dev;
u32 property;
-   acpi_handle handle;
-   acpi_status status;
-   unsigned long long data;
-   int cca;
int ret;
 
/* Obtain the system clock setting */
@@ -195,24 +190,6 @@ static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
}
pdata-ptpclk_rate = property;
 
-   /* Retrieve the device cache coherency value */
-   handle = adev-handle;
-   do {
-   status = acpi_evaluate_integer(handle, _CCA, NULL, data);
-   if (!ACPI_FAILURE(status)) {
-   cca = data;
-   break;
-   }
-
-   status = acpi_get_parent(handle, handle);
-   } while (!ACPI_FAILURE(status));
-
-   if (ACPI_FAILURE(status)) {
-   dev_err(dev, error obtaining acpi coherency value\n);
-   return -EINVAL;
-   }
-   pdata-coherent = !!cca;
-
return 0;
 }
 #else   /* CONFIG_ACPI */
@@ -243,9 +220,6 @@ static int xgbe_of_support(struct xgbe_prv_data *pdata)
}
pdata-ptpclk_rate = clk_get_rate(pdata-ptpclk);
 
-   /* Retrieve the device cache coherency value */
-   pdata-coherent = of_dma_is_coherent(dev-of_node);
-
return 0;
 }
 #else   /* CONFIG_OF */
@@ -364,6 +338,7 @@ static int xgbe_probe(struct platform_device *pdev)
goto err_io;
 
/* Set the DMA coherency values */
+   pdata-coherent = device_dma_is_coherent(pdata-dev);
if (pdata-coherent) {
pdata-axdomain = XGBE_DMA_OS_AXDOMAIN;
pdata-arcache = XGBE_DMA_OS_ARCACHE;
-- 
2.1.0

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


[V6 PATCH 6/7] megaraid_sas: fix TRUE and FALSE re-define build error

2015-06-10 Thread Suravee Suthikulpanit
Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
Cc: Kashyap Desai kashyap.de...@avagotech.com
Cc: Sumit Saxena sumit.sax...@avagotech.com
Cc: Uday Lingala uday.ling...@avagotech.com
---
 drivers/scsi/megaraid/megaraid_sas_fp.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 4f72287..e8b7a69 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -66,7 +66,15 @@ MODULE_PARM_DESC(lb_pending_cmds, Change raid-1 load 
balancing outstanding 
 
 #define ABS_DIFF(a, b)   (((a)  (b)) ? ((a) - (b)) : ((b) - (a)))
 #define MR_LD_STATE_OPTIMAL 3
+
+#ifdef FALSE
+#undef FALSE
+#endif
 #define FALSE 0
+
+#ifdef TRUE
+#undef TRUE
+#endif
 #define TRUE 1
 
 #define SPAN_DEBUG 0
-- 
2.1.0

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


[V6 PATCH 7/7] ufs: fix TRUE and FALSE re-define build error

2015-06-10 Thread Suravee Suthikulpanit
Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
Cc: Vinayak Holikatti vinholika...@gmail.com
---
 drivers/scsi/ufs/unipro.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
index 3fc3e21..816a8a4 100644
--- a/drivers/scsi/ufs/unipro.h
+++ b/drivers/scsi/ufs/unipro.h
@@ -198,6 +198,14 @@ enum ufs_hs_gear_tag {
 #define T_TC0TXMAXSDUSIZE  0x4060
 #define T_TC1TXMAXSDUSIZE  0x4061
 
+#ifdef FALSE
+#undef FALSE
+#endif
+
+#ifdef TRUE
+#undef TRUE
+#endif
+
 /* Boolean attribute values */
 enum {
FALSE = 0,
-- 
2.1.0

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


[V6 PATCH 4/7] crypto: ccp - Unify coherency checking logic with device_dma_is_coherent()

2015-06-10 Thread Suravee Suthikulpanit
Currently, the driver has separate logic to determine device coherency
for DT vs ACPI.  This patch simplifies the code with a call to
device_dma_is_coherent().

Signed-off-by: Tom Lendacky thomas.lenda...@amd.com
Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
---
 drivers/crypto/ccp/ccp-platform.c | 60 +--
 1 file changed, 1 insertion(+), 59 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-platform.c 
b/drivers/crypto/ccp/ccp-platform.c
index b1c20b2..e446781 100644
--- a/drivers/crypto/ccp/ccp-platform.c
+++ b/drivers/crypto/ccp/ccp-platform.c
@@ -90,58 +90,6 @@ static struct resource *ccp_find_mmio_area(struct ccp_device 
*ccp)
return NULL;
 }
 
-#ifdef CONFIG_ACPI
-static int ccp_acpi_support(struct ccp_device *ccp)
-{
-   struct ccp_platform *ccp_platform = ccp-dev_specific;
-   struct acpi_device *adev = ACPI_COMPANION(ccp-dev);
-   acpi_handle handle;
-   acpi_status status;
-   unsigned long long data;
-   int cca;
-
-   /* Retrieve the device cache coherency value */
-   handle = adev-handle;
-   do {
-   status = acpi_evaluate_integer(handle, _CCA, NULL, data);
-   if (!ACPI_FAILURE(status)) {
-   cca = data;
-   break;
-   }
-   } while (!ACPI_FAILURE(status));
-
-   if (ACPI_FAILURE(status)) {
-   dev_err(ccp-dev, error obtaining acpi coherency value\n);
-   return -EINVAL;
-   }
-
-   ccp_platform-coherent = !!cca;
-
-   return 0;
-}
-#else  /* CONFIG_ACPI */
-static int ccp_acpi_support(struct ccp_device *ccp)
-{
-   return -EINVAL;
-}
-#endif
-
-#ifdef CONFIG_OF
-static int ccp_of_support(struct ccp_device *ccp)
-{
-   struct ccp_platform *ccp_platform = ccp-dev_specific;
-
-   ccp_platform-coherent = of_dma_is_coherent(ccp-dev-of_node);
-
-   return 0;
-}
-#else
-static int ccp_of_support(struct ccp_device *ccp)
-{
-   return -EINVAL;
-}
-#endif
-
 static int ccp_platform_probe(struct platform_device *pdev)
 {
struct ccp_device *ccp;
@@ -182,13 +130,7 @@ static int ccp_platform_probe(struct platform_device *pdev)
goto e_err;
}
 
-   if (ccp_platform-use_acpi)
-   ret = ccp_acpi_support(ccp);
-   else
-   ret = ccp_of_support(ccp);
-   if (ret)
-   goto e_err;
-
+   ccp_platform-coherent = device_dma_is_coherent(ccp-dev);
if (ccp_platform-coherent)
ccp-axcache = CACHE_WB_NO_ALLOC;
else
-- 
2.1.0

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


[PATCH 1/1 linux-next] net: fs_enet: use swap() in fs_enet_rx_napi()

2015-06-10 Thread Fabian Frederick
Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick f...@skynet.be
---
 drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c 
b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index 9b3639e..c5f299d 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -86,7 +86,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int 
budget)
struct net_device *dev = fep-ndev;
const struct fs_platform_info *fpi = fep-fpi;
cbd_t __iomem *bdp;
-   struct sk_buff *skb, *skbn, *skbt;
+   struct sk_buff *skb, *skbn;
int received = 0;
u16 pkt_len, sc;
int curidx;
@@ -161,10 +161,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int 
budget)
skb_reserve(skbn, 2);   /* align IP 
header */
skb_copy_from_linear_data(skb,
  skbn-data, pkt_len);
-   /* swap */
-   skbt = skb;
-   skb = skbn;
-   skbn = skbt;
+   swap(skb, skbn);
}
} else {
skbn = netdev_alloc_skb(dev, ENET_RX_FRSIZE);
-- 
2.4.2

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


Re: [PATCH] iwlwifi:dvm:Return false if resume command data is not same size as received packet for the function iwl_resume_status_fn

2015-06-10 Thread Grumbach, Emmanuel
On Wed, 2015-06-10 at 12:33 -0400, Nicholas Krause wrote:
 This makes the function iwl_resume_status_fn return false now if
 the received packet of type iwl_rx_packet is not the same size
 as the structure pointer, iwl_resume_data's cmd element in order
 to signal callers about this error and allow them to handle it
 occurrently.
 

Hm... Did you actually hit this if?
I am not sure I really want to wait here (which is what will happen if
you return false) when we get an unexpected length? I do not expect
anything besides the response I am waiting for since the firmware is
handling the GET_STATUS *only* - it just came back from WoWLAN. Bottom
line, this is really an error path and I prefer to exit and not wait for
the timeout in that case.
But I might be missing something?

 Signed-off-by: Nicholas Krause xerofo...@gmail.com
 ---
  drivers/net/wireless/iwlwifi/dvm/mac80211.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c 
 b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
 index 5abd62e..21e808c 100644
 --- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
 +++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
 @@ -409,7 +409,7 @@ static bool iwl_resume_status_fn(struct 
 iwl_notif_wait_data *notif_wait,
  
   if (iwl_rx_packet_payload_len(pkt) != sizeof(*resume_data-cmd)) {
   IWL_ERR(priv, rx wrong size data\n);
 - return true;
 + return false;
   }
   memcpy(resume_data-cmd, pkt-data, sizeof(*resume_data-cmd));
   resume_data-valid = true;



[PATCH 09/12] fsl/fman: Add FMan MAC support

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

Add Frame Manger MAC Driver support.
This patch adds The FMan MAC configuration, initialization and
runtime control routines.
This patch contains support for these types of MACs:
tGEC, dTSEC and mEMAC

Signed-off-by: Igal Liberman igal.liber...@freescale.com
Signed-off-by: Madalin Bucur madalin.bu...@freescale.com
---
 drivers/net/ethernet/freescale/fman/fm.c   |   73 ++
 drivers/net/ethernet/freescale/fman/fm.h   |3 +
 drivers/net/ethernet/freescale/fman/fm_common.h|   41 +
 .../ethernet/freescale/fman/inc/crc_mac_addr_ext.h |  343 ++
 drivers/net/ethernet/freescale/fman/mac/Makefile   |4 +-
 drivers/net/ethernet/freescale/fman/mac/fm_dtsec.c | 1089 
 drivers/net/ethernet/freescale/fman/mac/fm_dtsec.h |  227 
 .../ethernet/freescale/fman/mac/fm_dtsec_mii_acc.c |   82 ++
 .../ethernet/freescale/fman/mac/fm_dtsec_mii_acc.h |   43 +
 drivers/net/ethernet/freescale/fman/mac/fm_mac.h   |  250 +
 drivers/net/ethernet/freescale/fman/mac/fm_memac.c |  741 +
 drivers/net/ethernet/freescale/fman/mac/fm_memac.h |  124 +++
 .../ethernet/freescale/fman/mac/fm_memac_mii_acc.c |   66 ++
 .../ethernet/freescale/fman/mac/fm_memac_mii_acc.h |   50 +
 drivers/net/ethernet/freescale/fman/mac/fm_tgec.c  |  652 
 drivers/net/ethernet/freescale/fman/mac/fm_tgec.h  |  126 +++
 16 files changed, 3913 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/inc/crc_mac_addr_ext.h
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_dtsec.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_dtsec.h
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_dtsec_mii_acc.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_dtsec_mii_acc.h
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_mac.h
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_memac.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_memac.h
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_memac_mii_acc.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_memac_mii_acc.h
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_tgec.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fm_tgec.h

diff --git a/drivers/net/ethernet/freescale/fman/fm.c 
b/drivers/net/ethernet/freescale/fman/fm.c
index 5beb118..fd6de5a 100644
--- a/drivers/net/ethernet/freescale/fman/fm.c
+++ b/drivers/net/ethernet/freescale/fman/fm.c
@@ -703,6 +703,35 @@ static int fw_not_reset_erratum_bugzilla6173wa(struct fm_t 
*p_fm)
 #endif /* FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
 
 /*   Inter-Module functions */
+#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
+int fm_10g_tx_ecc_workaround(struct fm_t *p_fm, uint8_t mac_id)
+{
+   uint8_t rx_port_id, tx_port_id;
+   struct fman_fpm_regs __iomem *fpm_rg = p_fm-p_fm_fpm_regs;
+
+   if (!(is_fman_ctrl_code_loaded(p_fm)))
+   return -EINVAL;
+
+   SW_PORT_ID_TO_HW_PORT_ID(p_fm-p_fm_state_struct-rev_info.major_rev,
+rx_port_id,
+FM_PORT_TYPE_RX,
+mac_id);
+   SW_PORT_ID_TO_HW_PORT_ID(p_fm-p_fm_state_struct-rev_info.major_rev,
+tx_port_id,
+FM_PORT_TYPE_TX,
+mac_id);
+
+   if ((p_fm-p_fm_state_struct-ports_types[rx_port_id] !=
+FM_PORT_TYPE_DUMMY) ||
+   (p_fm-p_fm_state_struct-ports_types[tx_port_id] !=
+   FM_PORT_TYPE_DUMMY)) {
+   pr_err(Initialize MAC  prior to Rx  Tx ports!\n);
+   return -EINVAL;
+   }
+
+   return fman_set_erratum_10gmac_a004_wa(fpm_rg);
+}
+#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
 
 void fm_register_intr(struct fm_t *p_fm, enum fm_event_modules module,
  uint8_t mod_id, enum fm_intr_type intr_type,
@@ -735,6 +764,50 @@ uint8_t fm_get_id(struct fm_t *p_fm)
return p_fm-p_fm_state_struct-fm_id;
 }
 
+int fm_reset_mac(struct fm_t *p_fm, uint8_t mac_id)
+{
+   int err;
+   struct fman_fpm_regs __iomem *fpm_rg = p_fm-p_fm_fpm_regs;
+
+   if (p_fm-p_fm_state_struct-rev_info.major_rev = 6) {
+   pr_warn(FMan MAC reset!\n);
+   return -EINVAL;
+   }
+   if (!p_fm-base_addr) {
+   pr_warn('base_address' is required!\n);
+   return -EINVAL;
+   }
+   err =
+   (int)fman_reset_mac(fpm_rg, mac_id);
+
+   if (err == -EINVAL) {
+   pr_warn(Illegal MAC Id\n);
+   return -EINVAL;
+   } else if (err == EINVAL) {
+   return -EINVAL;
+   }
+   return 0;
+}
+
+int fm_set_mac_max_frame(struct fm_t *p_fm, enum fm_mac_type type,
+uint8_t mac_id,
+uint16_t 

[PATCH net-next 19/19] bna: use netdev_* and dev_* instead of printk and pr_*

2015-06-10 Thread Ivan Vecera
Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bnad.c | 46 +
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 34 --
 drivers/net/ethernet/brocade/bna/bnad_ethtool.c |  9 ++---
 drivers/net/ethernet/brocade/bna/cna_fwimg.c|  2 +-
 4 files changed, 36 insertions(+), 55 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bnad.c 
b/drivers/net/ethernet/brocade/bna/bnad.c
index ddda6f1..d9e0f81 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -945,8 +945,7 @@ bnad_cb_ethport_link_status(struct bnad *bnad,
if (link_up) {
if (!netif_carrier_ok(bnad-netdev)) {
uint tx_id, tcb_id;
-   printk(KERN_WARNING bna: %s link up\n,
-   bnad-netdev-name);
+   netdev_info(bnad-netdev, link up\n);
netif_carrier_on(bnad-netdev);
BNAD_UPDATE_CTR(bnad, link_toggle);
for (tx_id = 0; tx_id  bnad-num_tx; tx_id++) {
@@ -965,10 +964,6 @@ bnad_cb_ethport_link_status(struct bnad *bnad,
/*
 * Force an immediate
 * Transmit Schedule */
-   printk(KERN_INFO bna: %s %d 
- TXQ_STARTED\n,
-  bnad-netdev-name,
-  txq_id);
netif_wake_subqueue(
bnad-netdev,
txq_id);
@@ -986,8 +981,7 @@ bnad_cb_ethport_link_status(struct bnad *bnad,
}
} else {
if (netif_carrier_ok(bnad-netdev)) {
-   printk(KERN_WARNING bna: %s link down\n,
-   bnad-netdev-name);
+   netdev_info(bnad-netdev, link down\n);
netif_carrier_off(bnad-netdev);
BNAD_UPDATE_CTR(bnad, link_toggle);
}
@@ -1057,8 +1051,6 @@ bnad_cb_tx_stall(struct bnad *bnad, struct bna_tx *tx)
txq_id = tcb-id;
clear_bit(BNAD_TXQ_TX_STARTED, tcb-flags);
netif_stop_subqueue(bnad-netdev, txq_id);
-   printk(KERN_INFO bna: %s %d TXQ_STOPPED\n,
-   bnad-netdev-name, txq_id);
}
 }
 
@@ -1081,8 +1073,6 @@ bnad_cb_tx_resume(struct bnad *bnad, struct bna_tx *tx)
BUG_ON(*(tcb-hw_consumer_index) != 0);
 
if (netif_carrier_ok(bnad-netdev)) {
-   printk(KERN_INFO bna: %s %d TXQ_STARTED\n,
-   bnad-netdev-name, txq_id);
netif_wake_subqueue(bnad-netdev, txq_id);
BNAD_UPDATE_CTR(bnad, netif_queue_wakeup);
}
@@ -2135,7 +2125,7 @@ bnad_reinit_rx(struct bnad *bnad)
current_err = bnad_setup_rx(bnad, rx_id);
if (current_err  !err) {
err = current_err;
-   pr_err(RXQ:%u setup failed\n, rx_id);
+   netdev_err(netdev, RXQ:%u setup failed\n, rx_id);
}
}
 
@@ -2671,8 +2661,9 @@ bnad_enable_msix(struct bnad *bnad)
if (ret  0) {
goto intx_mode;
} else if (ret  bnad-msix_num) {
-   pr_warn(BNA: %d MSI-X vectors allocated  %d requested\n,
-   ret, bnad-msix_num);
+   dev_warn(bnad-pcidev-dev,
+%d MSI-X vectors allocated  %d requested\n,
+ret, bnad-msix_num);
 
spin_lock_irqsave(bnad-bna_lock, flags);
/* ret = #of vectors that we got */
@@ -2694,7 +2685,8 @@ bnad_enable_msix(struct bnad *bnad)
return;
 
 intx_mode:
-   pr_warn(BNA: MSI-X enable failed - operating in INTx mode\n);
+   dev_warn(bnad-pcidev-dev,
+MSI-X enable failed - operating in INTx mode\n);
 
kfree(bnad-msix_table);
bnad-msix_table = NULL;
@@ -3482,8 +3474,8 @@ bnad_init(struct bnad *bnad,
dev_err(pdev-dev, ioremap for bar0 failed\n);
return -ENOMEM;
}
-   pr_info(bar0 mapped to %p, len %llu\n, bnad-bar0,
-  (unsigned long long) bnad-mmio_len);
+   dev_info(pdev-dev, bar0 mapped to %p, len %llu\n, bnad-bar0,
+(unsigned long long) bnad-mmio_len);
 
spin_lock_irqsave(bnad-bna_lock, flags);
if (!bnad_msix_disable)
@@ -3604,13 +3596,10 @@ bnad_pci_probe(struct pci_dev *pdev,
struct bfa_pcidev pcidev_info;

[PATCH net-next 18/19] bna: fix timeout API argument type

2015-06-10 Thread Ivan Vecera
Timeout functions are defined with 'void *' ptr argument. They should
be defined directly with 'struct bfa_ioc *' type to avoid type conversions.

Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bfa_ioc.c | 16 +---
 drivers/net/ethernet/brocade/bna/bfa_ioc.h |  8 
 drivers/net/ethernet/brocade/bna/bnad.c|  8 
 3 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index 2c74beb..b009fd7 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -1895,10 +1895,8 @@ bfa_ioc_hwinit(struct bfa_ioc *ioc, bool force)
 }
 
 void
-bfa_nw_ioc_timeout(void *ioc_arg)
+bfa_nw_ioc_timeout(struct bfa_ioc *ioc)
 {
-   struct bfa_ioc *ioc = (struct bfa_ioc *) ioc_arg;
-
bfa_fsm_send_event(ioc, IOC_E_TIMEOUT);
 }
 
@@ -1963,10 +1961,9 @@ bfa_ioc_send_getattr(struct bfa_ioc *ioc)
 }
 
 void
-bfa_nw_ioc_hb_check(void *cbarg)
+bfa_nw_ioc_hb_check(struct bfa_ioc *ioc)
 {
-   struct bfa_ioc *ioc = cbarg;
-   u32 hb_count;
+   u32 hb_count;
 
hb_count = readl(ioc-ioc_regs.heartbeat);
if (ioc-hb_count == hb_count) {
@@ -2983,9 +2980,8 @@ bfa_iocpf_stop(struct bfa_ioc *ioc)
 }
 
 void
-bfa_nw_iocpf_timeout(void *ioc_arg)
+bfa_nw_iocpf_timeout(struct bfa_ioc *ioc)
 {
-   struct bfa_ioc  *ioc = (struct bfa_ioc *) ioc_arg;
enum bfa_iocpf_state iocpf_st;
 
iocpf_st = bfa_sm_to_state(iocpf_sm_table, ioc-iocpf.fsm);
@@ -2997,10 +2993,8 @@ bfa_nw_iocpf_timeout(void *ioc_arg)
 }
 
 void
-bfa_nw_iocpf_sem_timeout(void *ioc_arg)
+bfa_nw_iocpf_sem_timeout(struct bfa_ioc *ioc)
 {
-   struct bfa_ioc  *ioc = (struct bfa_ioc *) ioc_arg;
-
bfa_ioc_hw_sem_get(ioc);
 }
 
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.h 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.h
index b6ad2c5..2c0b4c0 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.h
@@ -304,10 +304,10 @@ int bfa_nw_ioc_debug_fwsave(struct bfa_ioc *ioc, void 
*trcdata, int *trclen);
 /*
  * Timeout APIs
  */
-void bfa_nw_ioc_timeout(void *ioc);
-void bfa_nw_ioc_hb_check(void *ioc);
-void bfa_nw_iocpf_timeout(void *ioc);
-void bfa_nw_iocpf_sem_timeout(void *ioc);
+void bfa_nw_ioc_timeout(struct bfa_ioc *ioc);
+void bfa_nw_ioc_hb_check(struct bfa_ioc *ioc);
+void bfa_nw_iocpf_timeout(struct bfa_ioc *ioc);
+void bfa_nw_iocpf_sem_timeout(struct bfa_ioc *ioc);
 
 /*
  * F/W Image Size  Chunk
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c 
b/drivers/net/ethernet/brocade/bna/bnad.c
index aea585b..ddda6f1 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -1702,7 +1702,7 @@ bnad_ioc_timeout(unsigned long data)
unsigned long flags;
 
spin_lock_irqsave(bnad-bna_lock, flags);
-   bfa_nw_ioc_timeout((void *) bnad-bna.ioceth.ioc);
+   bfa_nw_ioc_timeout(bnad-bna.ioceth.ioc);
spin_unlock_irqrestore(bnad-bna_lock, flags);
 }
 
@@ -1713,7 +1713,7 @@ bnad_ioc_hb_check(unsigned long data)
unsigned long flags;
 
spin_lock_irqsave(bnad-bna_lock, flags);
-   bfa_nw_ioc_hb_check((void *) bnad-bna.ioceth.ioc);
+   bfa_nw_ioc_hb_check(bnad-bna.ioceth.ioc);
spin_unlock_irqrestore(bnad-bna_lock, flags);
 }
 
@@ -1724,7 +1724,7 @@ bnad_iocpf_timeout(unsigned long data)
unsigned long flags;
 
spin_lock_irqsave(bnad-bna_lock, flags);
-   bfa_nw_iocpf_timeout((void *) bnad-bna.ioceth.ioc);
+   bfa_nw_iocpf_timeout(bnad-bna.ioceth.ioc);
spin_unlock_irqrestore(bnad-bna_lock, flags);
 }
 
@@ -1735,7 +1735,7 @@ bnad_iocpf_sem_timeout(unsigned long data)
unsigned long flags;
 
spin_lock_irqsave(bnad-bna_lock, flags);
-   bfa_nw_iocpf_sem_timeout((void *) bnad-bna.ioceth.ioc);
+   bfa_nw_iocpf_sem_timeout(bnad-bna.ioceth.ioc);
spin_unlock_irqrestore(bnad-bna_lock, flags);
 }
 
-- 
2.3.6

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


Re: [RFC 00/10] NFS: add AF_VSOCK support to NFS client

2015-06-10 Thread Stefan Hajnoczi
On Mon, Jun 08, 2015 at 05:02:47PM -0400, J. Bruce Fields wrote:
 On Thu, Jun 04, 2015 at 05:45:43PM +0100, Stefan Hajnoczi wrote:
  The approach in this series
  ---
  AF_VSOCK stream sockets can be used for NFSv4.1 much in the same way as TCP.
  RFC 1831 record fragments divide messages since SOCK_STREAM semantics are
  present.  The backchannel shares the connection just like the default TCP
  configuration.
 
 So the NFSv4 backchannel isn't handled for now, I assume.

Right, I did not touch nfs4_callback_up_net(), only
nfs41_callback_up_net().

If I'm reading the code right NFSv4 uses a separate listen port for the
backchannel instead of sharing the client's socket?

This is possible to implement with AF_VSOCK but I have only tested
NFSv4.1 so far.  Should I go ahead and do this?

 And I guess
 NFSv2/v3 is out too thanks to rpcbind?  Which maybe is fine.

Yes, I ignored rpcbind and didn't test NFSv2/v3.

 Do we need an IETF draft or similar to document how NFS should work over
 AF_VSOCK?

I am not familiar with the standards process but I came across a few
places where it makes sense to have a standard:

 * SUNRPC netid for AF_VSOCK (currently tcp, udp, and others exist)
 * The uaddr string format (vsock:...)
 * Use of RFC 1831 record fragments (just like TCP) over AF_VSOCK
   SOCK_STREAM sockets

These are all at the SUNRPC level rather than at the NFS protocol level.

Any idea who I need to talk to?

 NFS developers rely heavily on wireshark (and similar tools) for
 debugging.  Is that still possible over AF_VSOCK?

No, this will require kernel and libpcap patches.  Something like
drivers/net/nlmon.c is needed for AF_VSOCK.  Basically a dummy network
interface and code that clones skbs when monitoring is enabled.

It's on the TODO list and will be very useful.

  The next step is tackling NFS server.  In the meantime, I have tested the
  patches using the nc-vsock netcat-like utility that is available in my Linux
  kernel repo below.
 
 So by a netcat-like utility, you mean it's proxying between client and a
 server so the client thinks the server is communicating over AF_VSOCK
 and the server thinks the client is using TCP?  (Sorry, I haven't looked
 at the code.)

Yes, exactly.  It works since the TCP and AF_VSOCK streams are almost
bit-compatible.  I think the difference between the streams occurs when
network addresses are transmitted (e.g. SUNRPC netids), but I haven't
encountered that with NFSv4.1 and no pnfs or fancy features in use.

 Once we have a server and client, how will you recommend testing them?
 (Will the server side need to run on real hardware?)

I have been testing nfsd on the host and nfs client in a virtual
machine.  Vice versa should work in the same way.

It's also possible to run nfsd in VM #1 and nfs client in VM #2 and use
the netcat-like utility on the host to forward the traffic.  That way
any kernel panic happens in a VM and doesn't bring down the machine.
I'll probably begin using this approach when I start nfsd work.

 I guess if it works then the main question is whether it's worth
 supporting another transport type in order to get the zero-configuration
 host-guest NFS setup.  Or whether there's another way to get the same
 gains.

Thanks!  If anyone has suggestions to avoid adding the AF_VSOCK
transport I'd be interested to learn about that.

Stefan


pgppgiWgO1ta0.pgp
Description: PGP signature


[PATCH net-next 14/19] bna: use memdup_user to copy userspace buffers

2015-06-10 Thread Ivan Vecera
Patch converts kzalloc-copy_from_user sequence to memdup_user. There
is also one useless assignment of NULL to bnad-regdata as it is followed
by assignment of kzalloc output.

Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 27 -
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c 
b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 72c8955..ad7af5c 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -321,15 +321,10 @@ bnad_debugfs_write_regrd(struct file *file, const char 
__user *buf,
unsigned long flags;
void *kern_buf;
 
-   /* Allocate memory to store the user space buf */
-   kern_buf = kzalloc(nbytes, GFP_KERNEL);
-   if (!kern_buf)
-   return -ENOMEM;
-
-   if (copy_from_user(kern_buf, (void  __user *)buf, nbytes)) {
-   kfree(kern_buf);
-   return -ENOMEM;
-   }
+   /* Copy the user space buf */
+   kern_buf = memdup_user(buf, nbytes);
+   if (IS_ERR(kern_buf))
+   return PTR_ERR(kern_buf);
 
rc = sscanf(kern_buf, %x:%x, addr, len);
if (rc  2) {
@@ -341,7 +336,6 @@ bnad_debugfs_write_regrd(struct file *file, const char 
__user *buf,
 
kfree(kern_buf);
kfree(bnad-regdata);
-   bnad-regdata = NULL;
bnad-reglen = 0;
 
bnad-regdata = kzalloc(len  2, GFP_KERNEL);
@@ -388,15 +382,10 @@ bnad_debugfs_write_regwr(struct file *file, const char 
__user *buf,
unsigned long flags;
void *kern_buf;
 
-   /* Allocate memory to store the user space buf */
-   kern_buf = kzalloc(nbytes, GFP_KERNEL);
-   if (!kern_buf)
-   return -ENOMEM;
-
-   if (copy_from_user(kern_buf, (void  __user *)buf, nbytes)) {
-   kfree(kern_buf);
-   return -ENOMEM;
-   }
+   /* Copy the user space buf */
+   kern_buf = memdup_user(buf, nbytes);
+   if (IS_ERR(kern_buf))
+   return PTR_ERR(kern_buf);
 
rc = sscanf(kern_buf, %x:%x, addr, val);
if (rc  2) {
-- 
2.3.6

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


[PATCH net-next 15/19] bna: remove useless pointer assignment

2015-06-10 Thread Ivan Vecera
Pointer cmpl used to iterate through completion entries is updated at
the beginning of while loop as well as at the end. The update at the end
of the loop is useless.

Signed-off-by: Ivan Vecera ivec...@redhat.com
---
 drivers/net/ethernet/brocade/bna/bnad.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/brocade/bna/bnad.c 
b/drivers/net/ethernet/brocade/bna/bnad.c
index e871e27..aea585b 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -724,7 +724,6 @@ next:
cmpl-valid = 0;
BNA_QE_INDX_INC(ccb-producer_index, ccb-q_depth);
}
-   cmpl = cq[ccb-producer_index];
}
 
napi_gro_flush(rx_ctrl-napi, false);
-- 
2.3.6

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


Re: [PATCH v3 1/2] sctp: rcu-ify addr_waitq

2015-06-10 Thread Neil Horman
On Wed, Jun 10, 2015 at 10:31:42AM -0300, Marcelo Ricardo Leitner wrote:
 On Tue, Jun 09, 2015 at 04:32:59PM -0300, Marcelo Ricardo Leitner wrote:
  On Tue, Jun 09, 2015 at 07:36:38AM -0400, Neil Horman wrote:
   On Mon, Jun 08, 2015 at 05:37:05PM +0200, Hannes Frederic Sowa wrote:
On Mo, 2015-06-08 at 11:19 -0400, Neil Horman wrote:
 On Mon, Jun 08, 2015 at 04:59:18PM +0200, Hannes Frederic Sowa wrote:
  On Mon, Jun 8, 2015, at 16:46, Hannes Frederic Sowa wrote:
   Hi Marcelo,
   
   a few hints on rcuification, sorry I reviewed the code so late:
   
   On Fri, Jun 5, 2015, at 19:08, mleit...@redhat.com wrote:
From: Marcelo Ricardo Leitner marcelo.leit...@gmail.com

That's needed for the next patch, so we break the lock 
inversion between
netns_sctp-addr_wq_lock and socket lock on
sctp_addr_wq_timeout_handler(). With this, we can traverse 
addr_waitq
without taking addr_wq_lock, taking it just for the write 
operations.

Signed-off-by: Marcelo Ricardo Leitner 
marcelo.leit...@gmail.com
---

Notes:
v2-v3:
  placed break statement on sctp_free_addr_wq_entry()
  removed unnecessary spin_lock noticed by Neil

 include/net/netns/sctp.h |  2 +-
 net/sctp/protocol.c  | 80
 +---
 2 files changed, 49 insertions(+), 33 deletions(-)

diff --git a/include/net/netns/sctp.h 
b/include/net/netns/sctp.h
index
3573a81815ad9e0efb6ceb721eb066d3726419f0..9e53412c4ed829e8e4577
7a6d95406d490dbaa75
100644
--- a/include/net/netns/sctp.h
+++ b/include/net/netns/sctp.h
@@ -28,7 +28,7 @@ struct netns_sctp {
 * It is a list of sctp_sockaddr_entry.
 */
struct list_head local_addr_list;
-   struct list_head addr_waitq;
+   struct list_head __rcu addr_waitq;
struct timer_list addr_wq_timer;
struct list_head auto_asconf_splist;
spinlock_t addr_wq_lock;
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index
53b7acde9aa37bf3d4029c459421564d5270f4c0..9954fb8c9a9455d5ad7a6
27e2d7f9a1fef861fc2
100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -593,15 +593,47 @@ static void sctp_v4_ecn_capable(struct 
sock *sk)
INET_ECN_xmit(sk);
 }
 
+static void sctp_free_addr_wq(struct net *net)
+{
+   struct sctp_sockaddr_entry *addrw;
+
+   spin_lock_bh(net-sctp.addr_wq_lock);
   
   Instead of holding spin_lock_bh you need to hold 
   rcu_read_lock_bh, so
   kfree_rcu does not call free function at once (in theory ;) ).
   
+   del_timer(net-sctp.addr_wq_timer);
+   list_for_each_entry_rcu(addrw, net-sctp.addr_waitq, 
list) {
+   list_del_rcu(addrw-list);
+   kfree_rcu(addrw, rcu);
+   }
+   spin_unlock_bh(net-sctp.addr_wq_lock);
+}
+
+/* As there is no refcnt on sctp_sockaddr_entry, we must check 
inside
+ * the lock if it wasn't removed from addr_waitq already, 
otherwise we
+ * could double-free it.
+ */
+static void sctp_free_addr_wq_entry(struct net *net,
+   struct sctp_sockaddr_entry 
*addrw)
+{
+   struct sctp_sockaddr_entry *temp;
+
+   spin_lock_bh(net-sctp.addr_wq_lock);
   
   I don't think this spin_lock operation is needed. The del_timer
   functions do synchronize themselves.
   
  
  Sorry, those above two locks are needed, they are not implied by 
  other
  locks.
  
 What makes you say that? Multiple contexts can issue mod_timer calls 
 on the
 same timer safely no, because of the internal locking?

That's true for timer handling but not to protect net-sctp.addr_waitq
list (Marcelo just explained it to me off-list). Looking at the patch
only in patchworks lost quite a lot of context you were already
discussing. ;)

   I can imagine :)
   
We are currently checking if the double iteration can be avoided by
splicing addr_waitq on the local stack while holding the spin_lock and
later on notifying the sockets.

   As we discussed, this I think would make a good alternate approach.
  
  I was experimenting on this but this would introduce another complex
  logic instead, as not all elements are pruned from net-sctp.addr_waitq
  at sctp_addr_wq_timeout_handler(), mainly ipv6 addresses in DAD state
  (which I believe that break statement is misplaced 

Re: [PATCH net-next 2/2] net: phy: mdio-bcm-unimac: handle broken turn-around for specific PHYs

2015-06-10 Thread Florian Fainelli
On 10/06/15 12:14, Florian Fainelli wrote:
 Some Ethernet PHYs/switches such as Broadcom's BCM53125 have a hardware bug
 which makes them not release the MDIO line during turn-around time.  This gets
 flagged by the UniMAC MDIO controller as a read failure, and we fail the read
 transaction.
 
 Check the MDIO bus phy_ignore_ta_mask bitmask for the PHY we are reading
 from and if it is listed in this bitmask, ignore the read failure and
 proceed with returning the data we read out of the controller.

Scratch that version, it contains an unnecessary include and does not
have the same comment as the GENET version, let me resubmit that.

 
 Signed-off-by: Florian Fainelli f.faine...@gmail.com
 ---
  drivers/net/phy/mdio-bcm-unimac.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/net/phy/mdio-bcm-unimac.c 
 b/drivers/net/phy/mdio-bcm-unimac.c
 index 414fdf1f343f..2237d5554e02 100644
 --- a/drivers/net/phy/mdio-bcm-unimac.c
 +++ b/drivers/net/phy/mdio-bcm-unimac.c
 @@ -16,6 +16,7 @@
  #include linux/module.h
  #include linux/io.h
  #include linux/delay.h
 +#include linux/brcmphy.h
  
  #include linux/of.h
  #include linux/of_platform.h
 @@ -81,7 +82,7 @@ static int unimac_mdio_read(struct mii_bus *bus, int 
 phy_id, int reg)
   return -ETIMEDOUT;
  
   cmd = __raw_readl(priv-base + MDIO_CMD);
 - if (cmd  MDIO_READ_FAIL)
 + if (!(bus-phy_ignore_ta_mask  1  phy_id)  (cmd  MDIO_READ_FAIL))
   return -EIO;
  
   return cmd  0x;
 


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


[PATCH net-next v2 2/2] net: phy: mdio-bcm-unimac: handle broken turn-around for specific PHYs

2015-06-10 Thread Florian Fainelli
Some Ethernet PHYs/switches such as Broadcom's BCM53125 have a hardware bug
which makes them not release the MDIO line during turn-around time.  This gets
flagged by the UniMAC MDIO controller as a read failure, and we fail the read
transaction.

Check the MDIO bus phy_ignore_ta_mask bitmask for the PHY we are reading
from and if it is listed in this bitmask, ignore the read failure and
proceed with returning the data we read out of the controller.

Signed-off-by: Florian Fainelli f.faine...@gmail.com
---
 drivers/net/phy/mdio-bcm-unimac.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio-bcm-unimac.c 
b/drivers/net/phy/mdio-bcm-unimac.c
index 414fdf1f343f..fc7abc50b4f1 100644
--- a/drivers/net/phy/mdio-bcm-unimac.c
+++ b/drivers/net/phy/mdio-bcm-unimac.c
@@ -81,7 +81,13 @@ static int unimac_mdio_read(struct mii_bus *bus, int phy_id, 
int reg)
return -ETIMEDOUT;
 
cmd = __raw_readl(priv-base + MDIO_CMD);
-   if (cmd  MDIO_READ_FAIL)
+
+   /* Some broken devices are known not to release the line during
+* turn-around, e.g: Broadcom BCM53125 external switches, so check for
+* that condition here and ignore the MDIO controller read failure
+* indication.
+*/
+   if (!(bus-phy_ignore_ta_mask  1  phy_id)  (cmd  MDIO_READ_FAIL))
return -EIO;
 
return cmd  0x;
-- 
2.1.0

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


[PATCH net-next v2 0/2] net: broadcom MDIO support for broken turn-around

2015-06-10 Thread Florian Fainelli
Hi David,

These two patches update the GENET and UniMAC MDIO controllers to deal with
PHYs that are known to have a broken turn-around bug (e.g: BCM53125 and others)

This utilizes the infrastructure that code recently added to do that in 
'net-next'.

Note that the changes look nearly identical and I will try to address the MDIO
code duplication between GENET and UniMAC in a future patch series.

Thanks!

Changes in v2:
- remove brcmphy.h include in mdio-bcm-unimac.c
- use the same comment as with GENET's MDIO read function

Florian Fainelli (2):
  net: bcmgenet: handle broken turn-around for specific PHYs
  net: phy: mdio-bcm-unimac: handle broken turn-around for specific PHYs

 drivers/net/ethernet/broadcom/genet/bcmmii.c | 7 ++-
 drivers/net/phy/mdio-bcm-unimac.c| 8 +++-
 2 files changed, 13 insertions(+), 2 deletions(-)

-- 
2.1.0

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


Re: [PATCH 1/1 linux-next] ath5k: use swap() in ath5k_hw_get_median_noise_floor()

2015-06-10 Thread Julia Lawall


On Wed, 10 Jun 2015, Fabian Frederick wrote:

 
 
  On 10 June 2015 at 21:52 Joe Perches j...@perches.com wrote:
 
 
  On Wed, 2015-06-10 at 18:33 +0200, Fabian Frederick wrote:
   Use kernel.h macro definition.
  
   Thanks to Julia Lawall for Coccinelle scripting support.
  []
   diff --git a/drivers/net/wireless/ath/ath5k/phy.c
   b/drivers/net/wireless/ath/ath5k/phy.c
  []
   @@ -1566,17 +1566,13 @@ static s16
    ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah)
    {
       s16 sort[ATH5K_NF_CAL_HIST_MAX];
   -   s16 tmp;
       int i, j;
   
       memcpy(sort, ah-ah_nfcal_hist.nfval, sizeof(sort));
       for (i = 0; i  ATH5K_NF_CAL_HIST_MAX - 1; i++) {
               for (j = 1; j  ATH5K_NF_CAL_HIST_MAX - i; j++) {
   -                   if (sort[j]  sort[j - 1]) {
   -                           tmp = sort[j];
   -                           sort[j] = sort[j - 1];
   -                           sort[j - 1] = tmp;
   -                   }
   +                   if (sort[j]  sort[j - 1])
   +                           swap(sort[j], sort[j]);
 
  swap(a, a) doesn't look useful.
 Thanks a lot Joe, I'll fix this one :)

How did it come out like that?

julia

 
 Regards,
 Fabian
 
 
 

[PATCH net-next 1/2] net: bcmgenet: handle broken turn-around for specific PHYs

2015-06-10 Thread Florian Fainelli
Some Ethernet PHYs/switches such as Broadcom's BCM53125 have a hardware
bug which makes them not release the MDIO line during turn-around time.
This gets flagged by the GENET MDIO controller as a read failure, and we
fail the read transaction.

Check the MDIO bus phy_ignore_ta_mask bitmask for the PHY we are reading
from and if it is listed in this bitmask, ignore the read failure and
proceed with returning the data we read out of the controller.

Signed-off-by: Florian Fainelli f.faine...@gmail.com
---
 drivers/net/ethernet/broadcom/genet/bcmmii.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c 
b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 420949cc55aa..6bef04e2f735 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -47,7 +47,12 @@ static int bcmgenet_mii_read(struct mii_bus *bus, int 
phy_id, int location)
   HZ / 100);
ret = bcmgenet_umac_readl(priv, UMAC_MDIO_CMD);
 
-   if (ret  MDIO_READ_FAIL)
+   /* Some broken devices are known not to release the line during
+* turn-around, e.g: Broadcom BCM53125 external switches, so check for
+* that condition here and ignore the MDIO controller read failure
+* indication.
+*/
+   if (!(bus-phy_ignore_ta_mask  1  phy_id)  (ret  MDIO_READ_FAIL))
return -EIO;
 
return ret  0x;
-- 
2.1.0

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


[PATCH net-next 0/2] net: broadcom MDIO support for broken turn-around

2015-06-10 Thread Florian Fainelli
Hi David,

These two patches update the GENET and UniMAC MDIO controllers to deal with
PHYs that are known to have a broken turn-around bug (e.g: BCM53125 and others)

This utilizes the infrastructure that code recently added to do that in 
'net-next'.

Note that the changes look nearly identical and I will try to address the MDIO
code duplication between GENET and UniMAC in a future patch series.

Thanks!

Florian Fainelli (2):
  net: bcmgenet: handle broken turn-around for specific PHYs
  net: phy: mdio-bcm-unimac: handle broken turn-around for specific PHYs

 drivers/net/ethernet/broadcom/genet/bcmmii.c | 7 ++-
 drivers/net/phy/mdio-bcm-unimac.c| 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

-- 
2.1.0

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


[PATCH net-next v2 1/2] net: bcmgenet: handle broken turn-around for specific PHYs

2015-06-10 Thread Florian Fainelli
Some Ethernet PHYs/switches such as Broadcom's BCM53125 have a hardware
bug which makes them not release the MDIO line during turn-around time.
This gets flagged by the GENET MDIO controller as a read failure, and we
fail the read transaction.

Check the MDIO bus phy_ignore_ta_mask bitmask for the PHY we are reading
from and if it is listed in this bitmask, ignore the read failure and
proceed with returning the data we read out of the controller.

Signed-off-by: Florian Fainelli f.faine...@gmail.com
---
 drivers/net/ethernet/broadcom/genet/bcmmii.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c 
b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 420949cc55aa..6bef04e2f735 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -47,7 +47,12 @@ static int bcmgenet_mii_read(struct mii_bus *bus, int 
phy_id, int location)
   HZ / 100);
ret = bcmgenet_umac_readl(priv, UMAC_MDIO_CMD);
 
-   if (ret  MDIO_READ_FAIL)
+   /* Some broken devices are known not to release the line during
+* turn-around, e.g: Broadcom BCM53125 external switches, so check for
+* that condition here and ignore the MDIO controller read failure
+* indication.
+*/
+   if (!(bus-phy_ignore_ta_mask  1  phy_id)  (ret  MDIO_READ_FAIL))
return -EIO;
 
return ret  0x;
-- 
2.1.0

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


/net/mpls/conf/ethX//input duplicate entry

2015-06-10 Thread Scott Feldman
I'm getting this dump_stack when reloading rocker driver.  Did some
sysctl MPLS nodes not get cleaned up on NETDEV_UNREGISTER?

Steps to repro: load rocker (on system) with rocker device, rmmod
rocker, and then modprobe rocker.  I doubt this is specific to rocker:
and re-registration of a netdev should hit it. I am using UDEV rules
to rename kernel's ethX to a different name.  Maybe that's what
tripped it up?


[   68.587713] sysctl duplicate entry: /net/mpls/conf/eth4//input
[   68.590015] CPU: 0 PID: 2944 Comm: modprobe Not tainted 4.1.0-rc7+ #35
[   68.591514] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS rel-1.8.1-0-g4adadbd-20150316_085822-nilsson.home.kraxel.org
04/01/2014
[   68.594401]  88000f521f00 88000f73f848 81443991
0006
[   68.596885]   88000f73f8a8 811a4d5a
88000f73f8b8
[   68.599328]  81a9e400  00040020
88000f73f8c8
[   68.620961] Call Trace:
[   68.621770]  [81443991] dump_stack+0x4c/0x65
[   68.623147]  [811a4d5a] __register_sysctl_table+0x414/0x426
[   68.624659]  [81432c17] register_net_sysctl+0x10/0x12
[   68.626052]  [81435c85] mpls_dev_notify+0xd6/0x26f
[   68.627403]  [814297fa] ? packet_notifier+0x18c/0x19a
[   68.628821]  [81062337] notifier_call_chain+0x3f/0x6c
[   68.630225]  [8106236d] __raw_notifier_call_chain+0x9/0xb
[   68.631675]  [8106237e] raw_notifier_call_chain+0xf/0x11
[   68.633146]  [8135eb6c] call_netdevice_notifiers_info+0x4f/0x58
[   68.634695]  [8135ebb6] call_netdevice_notifiers+0x11/0x13
[   68.636175]  [8136718b] register_netdevice+0x2f6/0x365
[   68.637604]  [81367214] register_netdev+0x1a/0x27
[   68.638962]  [a039d3f8] rocker_probe+0x94d/0xc20 [rocker]
[   68.640424]  [8131] ? component_bind_all+0x5b/0x190
[   68.641861]  [812561fa] local_pci_probe+0x38/0x7e
[   68.643204]  [8125630e] pci_device_probe+0xce/0xf4
[   68.644579]  [81304312] driver_probe_device+0xcc/0x23d
[   68.646220]  [81304483] ? driver_probe_device+0x23d/0x23d
[   68.647679]  [813044d1] __driver_attach+0x4e/0x6f
[   68.649051]  [813029d0] bus_for_each_dev+0x5a/0x8c
[   68.650402]  [81303dc2] driver_attach+0x19/0x1b
[   68.651773]  [81303afd] bus_add_driver+0xf1/0x1d6
[   68.653305]  [81304c23] driver_register+0x87/0xbe
[   68.654652]  [81255a74] __pci_register_driver+0x5d/0x62
[   68.656087]  [a0378000] ? 0xa0378000
[   68.657367]  [a0378039] rocker_module_init+0x39/0x1000 [rocker]
[   68.658900]  [a0378000] ? 0xa0378000
[   68.660178]  [a0378000] ? 0xa0378000
[   68.661461]  [8100030d] do_one_initcall+0xe9/0x186
[   68.662813]  [8113d228] ? kmem_cache_alloc_trace+0xee/0x100
[   68.664316]  [814418bf] do_init_module+0x5b/0x1ca
[   68.665666]  [810b2364] load_module+0x1cf2/0x1ee1
[   68.667002]  [810aefed] ? __module_get+0x29/0x29
[   68.668336]  [8144a4e7] ? retint_kernel+0x10/0x10
[   68.669694]  [810b2666] SyS_init_module+0x113/0x124
[   68.671062]  [81449957] system_call_fastpath+0x12/0x6f
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next 01/19] bna: use ether_addr_copy instead of memcpy

2015-06-10 Thread Joe Perches
On Wed, 2015-06-10 at 18:43 +0200, Ivan Vecera wrote:
 Signed-off-by: Ivan Vecera ivec...@redhat.com

Have you verified that all of these are __aligned(2)?

I haven't, but you should verify that you have in the
commit log.

btw: this use looks odd to me:

static int
bnad_set_mac_address(struct net_device *netdev, void *mac_addr)
{
int err;
struct bnad *bnad = netdev_priv(netdev);
struct sockaddr *sa = (struct sockaddr *)mac_addr;
unsigned long flags;

spin_lock_irqsave(bnad-bna_lock, flags);

err = bnad_mac_addr_set_locked(bnad, sa-sa_data);

as it casts what seems to be a mac address to a
sockaddr and uses a different offset for sa-sa_data
than the mac_addr passed.

and the mac_addr as it's void doesn't need a cast.


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


Re: [RFC net-next 2/3] VRF driver and needed infrastructure

2015-06-10 Thread Alexander Duyck

On 06/08/2015 11:35 AM, Shrijeet Mukherjee wrote:

From: Shrijeet Mukherjee s...@cumulusnetworks.com

This driver borrows heavily from IPvlan and teaming drivers.

Routing domains (VRF-lite) are created by instantiating a device
and enslaving all routed interfaces that participate in the domain.
As part of the enslavement, all local routes pointing to enslaved
devices are re-pointed to the vrf device, thus forcing outgoing
sockets to bind to the vrf to function.

Standard FIB rules can then bind the VRF device to tables and regular
fib rule processing is followed.

Routed traffic through the box, is fwded by using the VRF device as
the IIF and following the IIF rule to a table which is mated with
the VRF.

Locally originated traffic is directed at the VRF device using
SO_BINDTODEVICE or cmsg headers. This in turn drops the packet into
the xmit function of the vrf driver, which then completes the ip lookup
and output.

This solution is completely orthogonal to namespaces and allow the L3
equivalent of vlans to exist allowing the routing space to be
partitioned.

Example use is
ip link add vrf0 type vrf table 5
ip link set eth1 master vrf0
ip link set vrf0 up

ip rule add iif vrf0 table 5
ip rule add oif vrf0 table 5

TODO:
This changeset is for IPv4 only
Connected route management can be made much better, but is deferred to
user space for now.

Signed-off-by: Shrijeet Mukherjee s...@cumulusnetworks.com
---
  drivers/net/Kconfig  |6 +
  drivers/net/Makefile |1 +
  drivers/net/vrf.c|  654 ++
  include/linux/netdevice.h|   10 +
  include/net/flow.h   |1 +
  include/net/vrf.h|   19 ++
  include/uapi/linux/if_link.h |9 +
  7 files changed, 700 insertions(+)
  create mode 100644 drivers/net/vrf.c
  create mode 100644 include/net/vrf.h

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 019fcef..27a333c 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -283,6 +283,12 @@ config NLMON
  diagnostics, etc. This is mostly intended for developers or support
  to debug netlink issues. If unsure, say N.

+config NET_VRF
+   tristate Virtual Routing and Forwarding (Lite)
+   ---help---
+  This option enables the support for mapping interfaces into VRF's. 
The
+  support enables VRF devices
+
  endif # NET_CORE

  config SUNGEM_PHY
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index c12cb22..ca16dd6 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
  obj-$(CONFIG_VXLAN) += vxlan.o
  obj-$(CONFIG_GENEVE) += geneve.o
  obj-$(CONFIG_NLMON) += nlmon.o
+obj-$(CONFIG_NET_VRF) += vrf.o

  #
  # Networking Drivers
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
new file mode 100644
index 000..08b3e79
--- /dev/null
+++ b/drivers/net/vrf.c
@@ -0,0 +1,654 @@
+/*
+ * vrf.c: device driver to encapsulate a VRF space
+ *
+ * Copyright (c) 2015 Cumulus Networks
+ *
+ * Based on dummy, team and ipvlan drivers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/netdevice.h
+#include linux/etherdevice.h
+#include linux/ip.h
+#include linux/init.h
+#include linux/moduleparam.h
+#include linux/rtnetlink.h
+#include net/rtnetlink.h
+#include net/arp.h
+#include linux/u64_stats_sync.h
+#include linux/hashtable.h
+
+#include linux/inetdevice.h
+#include net/ip.h
+#include net/ip_fib.h
+#include net/ip6_route.h
+#include net/rtnetlink.h
+#include net/route.h
+#include net/addrconf.h
+#include net/vrf.h
+
+#define DRV_NAME   vrf
+#define DRV_VERSION1.0
+
+#define vrf_is_slave(dev)   ((dev-flags  IFF_SLAVE) == IFF_SLAVE)
+#define vrf_is_master(dev)  ((dev-flags  IFF_MASTER) == IFF_MASTER)
+
+#define vrf_master_get_rcu(dev) \
+   ((struct net_device *)rcu_dereference(dev-rx_handler_data))
+
+struct pcpu_dstats {
+   u64 tx_pkts;
+   u64 tx_bytes;
+   u64 tx_drps;
+   u64 rx_pkts;
+   u64 rx_bytes;
+   struct u64_stats_sync   syncp;
+};


Do you really need a new pcpu_dstats or could you just use 
pcpu_sw_netstats?  I'm just wondering if you are expecting to see that 
many Tx packets dropped.  If not you could probably just move that to 
the standard netdev stat instead.



+struct slave {
+   struct list_headlist;
+   struct net_device   *dev;
+   longpriority;
+};
+
+struct slave_queue {
+   spinlock_t  lock; /* lock for slave insert/delete */
+   struct list_headall_slaves;
+   int   

Re: [PATCH v3 net-next 2/2] tcp: add CDG congestion control

2015-06-10 Thread Yuchung Cheng
On Wed, Jun 10, 2015 at 10:08 AM, Kenneth Klette Jonassen
kenne...@ifi.uio.no wrote:
 CAIA Delay-Gradient (CDG) is a TCP congestion control that modifies
 the TCP sender in order to [1]:

   o Use the delay gradient as a congestion signal.
   o Back off with an average probability that is independent of the RTT.
   o Coexist with flows that use loss-based congestion control, i.e.,
 flows that are unresponsive to the delay signal.
   o Tolerate packet loss unrelated to congestion. (Disabled by default.)

 Its FreeBSD implementation was presented for the ICCRG in July 2012;
 slides are available at http://www.ietf.org/proceedings/84/iccrg.html

 Running the experiment scenarios in [1] suggests that our implementation
 achieves more goodput compared with FreeBSD 10.0 senders, although it also
 causes more queueing delay for a given backoff factor.

 The loss tolerance heuristic is disabled by default due to safety concerns
 for its use in the Internet [2, p. 45-46].

 We use a variant of the Hybrid Slow start algorithm in tcp_cubic to reduce
 the probability of slow start overshoot.

 [1] D.A. Hayes and G. Armitage. Revisiting TCP congestion control using
 delay gradients. In Networking 2011, pages 328-341. Springer, 2011.
 [2] K.K. Jonassen. Implementing CAIA Delay-Gradient in Linux.
 MSc thesis. Department of Informatics, University of Oslo, 2015.

 Cc: Eric Dumazet eduma...@google.com
 Cc: Yuchung Cheng ych...@google.com
 Cc: Stephen Hemminger step...@networkplumber.org
 Cc: Neal Cardwell ncardw...@google.com
 Cc: David Hayes davi...@ifi.uio.no
 Cc: Andreas Petlund apetl...@simula.no
 Cc: Dave Taht dave.t...@bufferbloat.net
 Cc: Nicolas Kuhn nicolas.k...@telecom-bretagne.eu
 Signed-off-by: Kenneth Klette Jonassen kenne...@ifi.uio.no

 ---
Acked-by: Yuchung Cheng ych...@google.com

 V0: RFC
 V1: Feedback from Dumazet, Cheng, and Hemminger [3], Shadow window, HyStart.
 V2: Fix delayed ACK filter, add HyStart knob, remove shadow_wnd clamp [4].
 V3: Always keep shadow_wnd, remove ECN handling for now [5].

 [1] http://caia.swin.edu.au/cv/dahayes/content/networking2011-cdg-preprint.pdf
 [2] http://folk.uio.no/kennetkl/jonassen_thesis.pdf
 [3] http://thread.gmane.org/gmane.linux.network/363729
 [4] http://thread.gmane.org/gmane.linux.network/366449
 [5] http://thread.gmane.org/gmane.linux.network/366659
 ---
  net/ipv4/Kconfig   |  20 +++
  net/ipv4/Makefile  |   1 +
  net/ipv4/tcp_cdg.c | 433 
 +
  3 files changed, 454 insertions(+)
  create mode 100644 net/ipv4/tcp_cdg.c

 diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
 index d83071d..6fb3c90 100644
 --- a/net/ipv4/Kconfig
 +++ b/net/ipv4/Kconfig
 @@ -615,6 +615,22 @@ config TCP_CONG_DCTCP
 For further details see:
   http://simula.stanford.edu/~alizade/Site/DCTCP_files/dctcp-final.pdf

 +config TCP_CONG_CDG
 +   tristate CAIA Delay-Gradient (CDG)
 +   default n
 +   ---help---
 +   CAIA Delay-Gradient (CDG) is a TCP congestion control that modifies
 +   the TCP sender in order to:
 +
 + o Use the delay gradient as a congestion signal.
 + o Back off with an average probability that is independent of the 
 RTT.
 + o Coexist with flows that use loss-based congestion control.
 + o Tolerate packet loss unrelated to congestion.
 +
 +   For further details see:
 + D.A. Hayes and G. Armitage. Revisiting TCP congestion control using
 + delay gradients. In Networking 2011. Preprint: http://goo.gl/No3vdg
 +
  choice
 prompt Default TCP congestion control
 default DEFAULT_CUBIC
 @@ -646,6 +662,9 @@ choice
 config DEFAULT_DCTCP
 bool DCTCP if TCP_CONG_DCTCP=y

 +   config DEFAULT_CDG
 +   bool CDG if TCP_CONG_CDG=y
 +
 config DEFAULT_RENO
 bool Reno
  endchoice
 @@ -668,6 +687,7 @@ config DEFAULT_TCP_CONG
 default veno if DEFAULT_VENO
 default reno if DEFAULT_RENO
 default dctcp if DEFAULT_DCTCP
 +   default cdg if DEFAULT_CDG
 default cubic

  config TCP_MD5SIG
 diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
 index b36236d..efc43f3 100644
 --- a/net/ipv4/Makefile
 +++ b/net/ipv4/Makefile
 @@ -42,6 +42,7 @@ obj-$(CONFIG_INET_TCP_DIAG) += tcp_diag.o
  obj-$(CONFIG_INET_UDP_DIAG) += udp_diag.o
  obj-$(CONFIG_NET_TCPPROBE) += tcp_probe.o
  obj-$(CONFIG_TCP_CONG_BIC) += tcp_bic.o
 +obj-$(CONFIG_TCP_CONG_CDG) += tcp_cdg.o
  obj-$(CONFIG_TCP_CONG_CUBIC) += tcp_cubic.o
  obj-$(CONFIG_TCP_CONG_DCTCP) += tcp_dctcp.o
  obj-$(CONFIG_TCP_CONG_WESTWOOD) += tcp_westwood.o
 diff --git a/net/ipv4/tcp_cdg.c b/net/ipv4/tcp_cdg.c
 new file mode 100644
 index 000..a52ce2d
 --- /dev/null
 +++ b/net/ipv4/tcp_cdg.c
 @@ -0,0 +1,433 @@
 +/*
 + * CAIA Delay-Gradient (CDG) congestion control
 + *
 + * This implementation is based on the paper:
 + *   D.A. Hayes and G. Armitage. Revisiting TCP congestion control using
 + *   

[PATCH net-next 2/2] net: phy: mdio-bcm-unimac: handle broken turn-around for specific PHYs

2015-06-10 Thread Florian Fainelli
Some Ethernet PHYs/switches such as Broadcom's BCM53125 have a hardware bug
which makes them not release the MDIO line during turn-around time.  This gets
flagged by the UniMAC MDIO controller as a read failure, and we fail the read
transaction.

Check the MDIO bus phy_ignore_ta_mask bitmask for the PHY we are reading
from and if it is listed in this bitmask, ignore the read failure and
proceed with returning the data we read out of the controller.

Signed-off-by: Florian Fainelli f.faine...@gmail.com
---
 drivers/net/phy/mdio-bcm-unimac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio-bcm-unimac.c 
b/drivers/net/phy/mdio-bcm-unimac.c
index 414fdf1f343f..2237d5554e02 100644
--- a/drivers/net/phy/mdio-bcm-unimac.c
+++ b/drivers/net/phy/mdio-bcm-unimac.c
@@ -16,6 +16,7 @@
 #include linux/module.h
 #include linux/io.h
 #include linux/delay.h
+#include linux/brcmphy.h
 
 #include linux/of.h
 #include linux/of_platform.h
@@ -81,7 +82,7 @@ static int unimac_mdio_read(struct mii_bus *bus, int phy_id, 
int reg)
return -ETIMEDOUT;
 
cmd = __raw_readl(priv-base + MDIO_CMD);
-   if (cmd  MDIO_READ_FAIL)
+   if (!(bus-phy_ignore_ta_mask  1  phy_id)  (cmd  MDIO_READ_FAIL))
return -EIO;
 
return cmd  0x;
-- 
2.1.0

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


Re: [PATCH 1/1 linux-next] ath5k: use swap() in ath5k_hw_get_median_noise_floor()

2015-06-10 Thread Joe Perches
On Wed, 2015-06-10 at 18:33 +0200, Fabian Frederick wrote:
 Use kernel.h macro definition.
 
 Thanks to Julia Lawall for Coccinelle scripting support.
[]
 diff --git a/drivers/net/wireless/ath/ath5k/phy.c 
 b/drivers/net/wireless/ath/ath5k/phy.c
[]
 @@ -1566,17 +1566,13 @@ static s16
  ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah)
  {
   s16 sort[ATH5K_NF_CAL_HIST_MAX];
 - s16 tmp;
   int i, j;
  
   memcpy(sort, ah-ah_nfcal_hist.nfval, sizeof(sort));
   for (i = 0; i  ATH5K_NF_CAL_HIST_MAX - 1; i++) {
   for (j = 1; j  ATH5K_NF_CAL_HIST_MAX - i; j++) {
 - if (sort[j]  sort[j - 1]) {
 - tmp = sort[j];
 - sort[j] = sort[j - 1];
 - sort[j - 1] = tmp;
 - }
 + if (sort[j]  sort[j - 1])
 + swap(sort[j], sort[j]);

swap(a, a) doesn't look useful.


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


  1   2   >