[PATCH iproute2] ip/iproute: allow routes to be configured with expire values

2015-12-21 Thread Hangbin Liu
Signed-off-by: Hangbin Liu 
---
 include/linux/rtnetlink.h |  1 +
 ip/iproute.c  | 11 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 3244947..ff2fe31 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -310,6 +310,7 @@ enum rtattr_type_t {
RTA_PREF,
RTA_ENCAP_TYPE,
RTA_ENCAP,
+   RTA_EXPIRES,
__RTA_MAX
 };
 
diff --git a/ip/iproute.c b/ip/iproute.c
index eab512d..3f52e0f 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -84,7 +84,7 @@ static void usage(void)
fprintf(stderr, "   [ ssthresh NUMBER ] [ realms REALM ] [ src 
ADDRESS ]\n");
fprintf(stderr, "   [ rto_min TIME ] [ hoplimit NUMBER ] [ 
initrwnd NUMBER ]\n");
fprintf(stderr, "   [ features FEATURES ] [ quickack BOOL ] [ 
congctl NAME ]\n");
-   fprintf(stderr, "   [ pref PREF ]\n");
+   fprintf(stderr, "   [ pref PREF ] [ expires TIME ]\n");
fprintf(stderr, "TYPE := [ unicast | local | broadcast | multicast | 
throw |\n");
fprintf(stderr, "  unreachable | prohibit | blackhole | nat 
]\n");
fprintf(stderr, "TABLE_ID := [ local | main | default | all | NUMBER 
]\n");
@@ -811,6 +811,7 @@ static int iproute_modify(int cmd, unsigned flags, int 
argc, char **argv)
int table_ok = 0;
int raw = 0;
int type_ok = 0;
+   static int hz;
 
memset(&req, 0, sizeof(req));
 
@@ -881,6 +882,14 @@ static int iproute_modify(int cmd, unsigned flags, int 
argc, char **argv)
if (rtnl_dsfield_a2n(&tos, *argv))
invarg("\"tos\" value is invalid\n", *argv);
req.r.rtm_tos = tos;
+   } else if (strcmp(*argv, "expires") == 0 ) {
+   __u32 expires;
+   NEXT_ARG();
+   if (get_u32(&expires, *argv, 0))
+   invarg("\"expires\" value is invalid\n", *argv);
+   if (!hz)
+   hz = get_user_hz();
+   addattr32(&req.n, sizeof(req), RTA_EXPIRES, expires*hz);
} else if (matches(*argv, "metric") == 0 ||
   matches(*argv, "priority") == 0 ||
   strcmp(*argv, "preference") == 0) {
-- 
2.4.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] switchdev: bridge: Pass ageing time as clock_t instead of jiffies

2015-12-21 Thread Jiri Pirko
From: Ido Schimmel 

The bridge's ageing time is offloaded to hardware when:
1) A port joins a bridge
2) The ageing time of the bridge is changed

In the first case the ageing time is offloaded as jiffies, but in the
second case it's offloaded as clock_t, which is what existing switchdev
drivers expect to receive.

Fixes: 6ac311ae8bfb ("Adding switchdev ageing notification on port bridged")
Signed-off-by: Ido Schimmel 
Signed-off-by: Jiri Pirko 
---
 net/bridge/br_stp_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 5396ff08..12045de 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -39,7 +39,7 @@ void br_init_port(struct net_bridge_port *p)
struct switchdev_attr attr = {
.id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
.flags = SWITCHDEV_F_SKIP_EOPNOTSUPP | SWITCHDEV_F_DEFER,
-   .u.ageing_time = p->br->ageing_time,
+   .u.ageing_time = jiffies_to_clock_t(p->br->ageing_time),
};
int err;
 
-- 
2.4.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


Re: net, ipv6: out of bounds access in secret_stable

2015-12-21 Thread Hannes Frederic Sowa
On 19.12.2015 21:50, Cong Wang wrote:
> On Fri, Dec 18, 2015 at 5:13 PM, Sasha Levin  wrote:
>> Hi Hannes,
>>
>> I've hit the following out of bounds access while fuzzing on the latest 
>> -next kernel.
>>
>> This code was added in 3d1bec9932 ("ipv6: introduce secret_stable to 
>> ipv6_devconf").
>>
>> [  459.553655] BUG: KASAN: stack-out-of-bounds in strlen+0x58/0x90 at addr 
>> 8802ab0efb0e
>> [  459.554953] Read of size 1 by task trinity-c91/22576
>> [  459.555805] page:ea000aac3bc0 count:0 mapcount:0 mapping:  
>> (null) index:0x0
>> [  459.556899] flags: 0x26f8000()
>> [  459.557521] page dumped because: kasan: bad access detected
>> [  459.558320] CPU: 7 PID: 22576 Comm: trinity-c91 Not tainted 
>> 4.4.0-rc5-next-20151218-sasha-00021-gaba8d84-dirty #2750
>> [  459.559809]   549d0aa3 8802ab0ef860 
>> a1042384
>> [  459.561036]  41b58ab3 ac667cdb a10422d9 
>> 8802ab0ef848
>> [  459.562245]  9f6a417e 549d0aa3 8802ab0efb0e 
>> 8802ab0efb0e
>> [  459.563429] Call Trace:
>> [  459.563831] dump_stack (lib/dump_stack.c:52)
>> [  459.564623] ? _atomic_dec_and_lock (lib/dump_stack.c:27)
>> [  459.565628] ? __dump_page (mm/debug.c:126)
>> [  459.566538] kasan_report_error (include/linux/kasan.h:28 
>> mm/kasan/report.c:170 mm/kasan/report.c:237)
>> [  459.570997] __asan_report_load1_noabort (mm/kasan/report.c:277)
>> [  459.572119] ? check_preemption_disabled (lib/smp_processor_id.c:39)
>> [  459.573731] ? strlen (lib/string.c:481 (discriminator 1))
>> [  459.574646] strlen (lib/string.c:481 (discriminator 1))
>> [  459.575485] proc_dostring (kernel/sysctl.c:1825 kernel/sysctl.c:1906)
>> [  459.576445] ? alloc_debug_processing (mm/slub.c:1054)
>> [  459.577523] addrconf_sysctl_stable_secret (net/ipv6/addrconf.c:5395)
> 
> Looks like we don't initialize the array on stack for write case.
> At least other callers always initialize the data for both read
> and write.
> 
> Please try the attached patch.

Your patch is right. I am surprised you need to initialize the buffer
passed down to proc_dostring so that strlen can correctly operate on it,
but f4aacea2f5d1a5 ("sysctl: allow for strict write position handling")
explains why. Can you submit formally?

Acked-by: Hannes Frederic Sowa 

Thanks,
Hannes


--
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 V2 3/4] net/mlx5e: Add HW timestamping (TS) support

2015-12-21 Thread Richard Cochran
On Sun, Dec 20, 2015 at 11:46:30PM +0200, Saeed Mahameed wrote:
> +/* Should run once every mlx5e_tstamp->overflow_period */
> +static void mlx5e_timestamp_overflow(struct work_struct *work)
> +{
> + struct delayed_work *dwork = to_delayed_work(work);
> + struct mlx5e_tstamp *tstamp = container_of(dwork, struct mlx5e_tstamp, 
> overflow_work);
> + unsigned long flags;
> +
> + write_lock_irqsave(&tstamp->lock, flags);
> + timecounter_read(&tstamp->clock);
> + if (tstamp->overflow_period)
> + schedule_delayed_work(&tstamp->overflow_work, 
> tstamp->overflow_period);

You don't need this test, and the call to schedule_delayed_work can be
outside of the lock.

> + write_unlock_irqrestore(&tstamp->lock, flags);
> +}

> +void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv)
> +{
> + struct mlx5e_tstamp *tstamp = &priv->tstamp;
> +
> + if (!MLX5_CAP_GEN(priv->mdev, device_frequency_khz))
> + return;
> +
> + write_lock(&tstamp->lock);
> + tstamp->overflow_period = 0; /* Signal overflow_check to stop */
> + write_unlock(&tstamp->lock);

This is unnecessary because

> +
> + cancel_delayed_work_sync(&tstamp->overflow_work);

this will block until the work is cancelled.

> +}

Thanks,
Richard


--
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 V2 4/4] net/mlx5e: Add PTP Hardware Clock (PHC) support

2015-12-21 Thread Richard Cochran
On Sun, Dec 20, 2015 at 11:46:31PM +0200, Saeed Mahameed wrote:
> From: Eran Ben Elisha 
> 
> Add a PHC support to the mlx5_en driver. Use reader/writer spinlocks to
> protect the timecounter since every packet received needs to call
> timecounter_cycle2time() when timestamping is enabled.  This can become
> a performance bottleneck with RSS and multiple receive queues if normal
> spinlocks are used.
> 
> The driver has been tested with both Documentation/ptp/testptp and the
> linuxptp project (http://linuxptp.sourceforge.net/) on a Mellanox
> ConnectX-4 card.
> 
> Signed-off-by: Eran Ben Elisha 
> Cc: Richard Cochran 
> Signed-off-by: Saeed Mahameed 

Acked-by: Richard Cochran 
--
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] ipv6/addrlabel: fix ip6addrlbl_get()

2015-12-21 Thread Andrey Ryabinin
ip6addrlbl_get() has never worked. If ip6addrlbl_hold() succeeded,
ip6addrlbl_get() will exit with '-ESRCH'. If ip6addrlbl_hold() failed,
ip6addrlbl_get() will use about to be free ip6addrlbl_entry pointer.

Fix this by inverting ip6addrlbl_hold() check.

Fixes: 2a8cc6c89039 ("[IPV6] ADDRCONF: Support RFC3484 configurable address 
selection policy table.")
Signed-off-by: Andrey Ryabinin 
---
 net/ipv6/addrlabel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index 882124e..a8f6986 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -552,7 +552,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct 
nlmsghdr *nlh)
 
rcu_read_lock();
p = __ipv6_addr_label(net, addr, ipv6_addr_type(addr), 
ifal->ifal_index);
-   if (p && ip6addrlbl_hold(p))
+   if (p && !ip6addrlbl_hold(p))
p = NULL;
lseq = ip6addrlbl_table.seq;
rcu_read_unlock();
-- 
2.4.10

--
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] sctp: sctp should release assoc when sctp_make_abort_user return NULL in sctp_close

2015-12-21 Thread Xin Long
On Sat, Dec 19, 2015 at 12:23 AM, Marcelo Ricardo Leitner
 wrote:
> On Fri, Dec 18, 2015 at 09:08:46AM -0500, Vlad Yasevich wrote:
>> On 12/17/2015 02:33 PM, Vlad Yasevich wrote:
>> > On 12/17/2015 02:01 PM, Marcelo Ricardo Leitner wrote:
> ...
>> >> There is a check on sctp_cmd_delete_tcb() that avoids calling that on 
>> >> temp assocs on
>> >> listening sockets, but that condition is false due to the check on 
>> >> sk_shutdown so it will
>> >> call those two functions anyway.
>> >
>> > The condition I am a bit concerned about is one thread waiting in 
>> > sctp_wait_for_sndbuf
>> > while another does an abort.
>> >
>> > I think this is OK though.  I need to look a bit more...
>>
>> I think the only time this ends up biting us is if SO_SNDTIMEO was used and 
>> we ran out
>> of send buffer.  It looks to me like schedule_timeout() will wait until 
>> timer expired and
>> depending on the timer value, you could wait quite a while.
>>
>> With this path, since you don't transition state, the asoc->wait wait queue 
>> is never
>> notified and it could be hanging around for quite a while.

do you think it makes sense if we have this condition judgment there ?
if (waitqueue_active(&asoc->wait))
wake_up_interruptible(&asoc->wait);


>
> Yes, agreed. For blocking sockets, it could hang waiting until the
> application finally closes. Thanks Vlad.
>
>   Marcelo
>
--
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] mlxsw: core: Allow to reset temperature history via hwmon interface

2015-12-21 Thread Jiri Pirko
From: Jiri Pirko 

Add another sysfs hwmon attribute to expose possibility to reset
temperature sensors history.

Signed-off-by: Jiri Pirko 
---
 drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 37 +++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c 
b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
index b86db96..00ccf1c 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
@@ -49,7 +49,7 @@ struct mlxsw_hwmon_attr {
struct device_attribute dev_attr;
struct mlxsw_hwmon *hwmon;
unsigned int type_index;
-   char name[16];
+   char name[32];
 };
 
 struct mlxsw_hwmon {
@@ -107,6 +107,32 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device 
*dev,
return sprintf(buf, "%u\n", temp_max);
 }
 
+static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+   struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
+   container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
+   struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
+   char mtmp_pl[MLXSW_REG_MTMP_LEN];
+   unsigned long val;
+   int err;
+
+   err = kstrtoul(buf, 10, &val);
+   if (err)
+   return err;
+   if (val != 1)
+   return -EINVAL;
+
+   mlxsw_reg_mtmp_pack(mtmp_pl, mlwsw_hwmon_attr->type_index, true, true);
+   err = mlxsw_reg_write(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
+   if (err) {
+   dev_err(mlxsw_hwmon->bus_info->dev, "Failed to reset temp 
sensor history\n");
+   return err;
+   }
+   return err ? err : len;
+}
+
 static ssize_t mlxsw_hwmon_fan_rpm_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -175,6 +201,7 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev,
 enum mlxsw_hwmon_attr_type {
MLXSW_HWMON_ATTR_TYPE_TEMP,
MLXSW_HWMON_ATTR_TYPE_TEMP_MAX,
+   MLXSW_HWMON_ATTR_TYPE_TEMP_RST,
MLXSW_HWMON_ATTR_TYPE_FAN_RPM,
MLXSW_HWMON_ATTR_TYPE_PWM,
 };
@@ -201,6 +228,12 @@ static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon 
*mlxsw_hwmon,
snprintf(mlxsw_hwmon_attr->name, sizeof(mlxsw_hwmon_attr->name),
 "temp%u_highest", num + 1);
break;
+   case MLXSW_HWMON_ATTR_TYPE_TEMP_RST:
+   mlxsw_hwmon_attr->dev_attr.store = mlxsw_hwmon_temp_rst_store;
+   mlxsw_hwmon_attr->dev_attr.attr.mode = S_IWUSR;
+   snprintf(mlxsw_hwmon_attr->name, sizeof(mlxsw_hwmon_attr->name),
+"temp%u_reset_history", num + 1);
+   break;
case MLXSW_HWMON_ATTR_TYPE_FAN_RPM:
mlxsw_hwmon_attr->dev_attr.show = mlxsw_hwmon_fan_rpm_show;
mlxsw_hwmon_attr->dev_attr.attr.mode = S_IRUGO;
@@ -254,6 +287,8 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon 
*mlxsw_hwmon)
 MLXSW_HWMON_ATTR_TYPE_TEMP, i, i);
mlxsw_hwmon_attr_add(mlxsw_hwmon,
 MLXSW_HWMON_ATTR_TYPE_TEMP_MAX, i, i);
+   mlxsw_hwmon_attr_add(mlxsw_hwmon,
+MLXSW_HWMON_ATTR_TYPE_TEMP_RST, i, i);
}
return 0;
 }
-- 
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


Re: [iproute PATCH v2] ip{,6}tunnel: have a shared stats parser/printer

2015-12-21 Thread Daniel Borkmann

On 12/18/2015 11:58 AM, Phil Sutter wrote:

This has a slight side-effect of not aborting when /proc/net/dev is
malformed, but OTOH stats are not parsed for uninteresting interfaces.

Signed-off-by: Phil Sutter 
---
Changes since v1:
- Fix conflict resolution (sscan from 'buf' instead of 'ptr').

[...]

Hmm, did you actually compile that?

The code is still the same as in v1 ... the only thing added is the "Changes since 
v1"
description. ;)

[...]

+void tnl_print_stats(const char *buf)
+{
+   unsigned long rx_bytes, rx_packets, rx_errs, rx_drops,
+ rx_fifo, rx_frame,
+ tx_bytes, tx_packets, tx_errs, tx_drops,
+ tx_fifo, tx_colls, tx_carrier, rx_multi;
+
+   if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",


  s/ptr/buf/


+  &rx_bytes, &rx_packets, &rx_errs, &rx_drops,
+  &rx_fifo, &rx_frame, &rx_multi,
+  &tx_bytes, &tx_packets, &tx_errs, &tx_drops,
+  &tx_fifo, &tx_colls, &tx_carrier) != 14)
+   return;
+
+   printf("%s", _SL_);
+   printf("RX: PacketsBytesErrors CsumErrs OutOfSeq Mcasts%s", 
_SL_);
+   printf("%-10ld %-12ld %-6ld %-8ld %-8ld %-8ld%s",
+  rx_packets, rx_bytes, rx_errs, rx_frame, rx_fifo, rx_multi, 
_SL_);
+   printf("TX: PacketsBytesErrors DeadLoop NoRoute  NoBufs%s", 
_SL_);
+   printf("%-10ld %-12ld %-6ld %-8ld %-8ld %-6ld",
+  tx_packets, tx_bytes, tx_errs, tx_colls, tx_carrier, tx_drops);
+}


tunnel.c: In function ‘tnl_print_stats’:
tunnel.c:211:13: error: ‘buff’ undeclared (first use in this function)
  if (sscanf(buff, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
 ^
tunnel.c:211:13: note: each undeclared identifier is reported only once for 
each function it appears in
make[1]: *** [tunnel.o] Error 1
make[1]: *** Waiting for unfinished jobs
make: *** [all] Error 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


[v10, 4/6] fsl/fman: Add FMan SP support

2015-12-21 Thread igal.liberman
From: Igal Liberman 

The Storage Profiles contain parameters that are used
by the FMan for frame reception and transmission.

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile  |2 +-
 drivers/net/ethernet/freescale/fman/fman_sp.c |  167 +
 drivers/net/ethernet/freescale/fman/fman_sp.h |  103 +++
 3 files changed, 271 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_sp.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_sp.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 43360d70..5141532 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -2,5 +2,5 @@ subdir-ccflags-y +=  
-I$(srctree)/drivers/net/ethernet/freescale/fman
 
 obj-y  += fsl_fman.o fsl_fman_mac.o
 
-fsl_fman-objs  := fman_muram.o fman.o
+fsl_fman-objs  := fman_muram.o fman.o fman_sp.o
 fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o
diff --git a/drivers/net/ethernet/freescale/fman/fman_sp.c 
b/drivers/net/ethernet/freescale/fman/fman_sp.c
new file mode 100644
index 000..f36c622
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman_sp.c
@@ -0,0 +1,167 @@
+/*
+ * 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 "fman_sp.h"
+#include "fman.h"
+
+void fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools
+*fm_ext_pools,
+u8 *ordered_array,
+u16 *sizes_array)
+{
+   u16 buf_size = 0;
+   int i = 0, j = 0, k = 0;
+
+   /* First we copy the external buffers pools information
+* to an ordered local array
+*/
+   for (i = 0; i < fm_ext_pools->num_of_pools_used; i++) {
+   /* get pool size */
+   buf_size = fm_ext_pools->ext_buf_pool[i].size;
+
+   /* keep sizes in an array according to poolId
+* for direct access
+*/
+   sizes_array[fm_ext_pools->ext_buf_pool[i].id] = buf_size;
+
+   /* save poolId in an ordered array according to size */
+   for (j = 0; j <= i; j++) {
+   /* this is the next free place in the array */
+   if (j == i)
+   ordered_array[i] =
+   fm_ext_pools->ext_buf_pool[i].id;
+   else {
+   /* find the right place for this poolId */
+   if (buf_size < sizes_array[ordered_array[j]]) {
+   /* move the pool_ids one place ahead
+* to make room for this poolId
+*/
+   for (k = i; k > j; k--)
+   ordered_array[k] =
+   ordered_array[k - 1];
+
+   /* now k=

[v10, 3/6] fsl/fman: Add FMan MAC support

2015-12-21 Thread igal.liberman
From: Igal Liberman 

Add the Data Path Acceleration Architecture Frame Manger MAC support.
This patch adds The FMan MAC configuration, initialization and
runtime control routines.
This patch contains support for these types of MACs:
- dTSEC: Three speed Ethernet controller (10/100/1000 Mbps)
- tGEC: 10G Ethernet controller (10 Gbps)
- mEMAC: Multi-rate Ethernet MAC (10/100/1000/1 Mbps)
Different FMan revisions have different type and number of MACs.

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile |3 +-
 drivers/net/ethernet/freescale/fman/fman_dtsec.c | 1453 ++
 drivers/net/ethernet/freescale/fman/fman_dtsec.h |   59 +
 drivers/net/ethernet/freescale/fman/fman_mac.h   |  278 +
 drivers/net/ethernet/freescale/fman/fman_memac.c | 1170 +
 drivers/net/ethernet/freescale/fman/fman_memac.h |   60 +
 drivers/net/ethernet/freescale/fman/fman_tgec.c  |  786 
 drivers/net/ethernet/freescale/fman/fman_tgec.h  |   55 +
 8 files changed, 3863 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_dtsec.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_dtsec.h
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_mac.h
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_memac.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_memac.h
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_tgec.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_tgec.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index fb5a7f0..43360d70 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -1,5 +1,6 @@
 subdir-ccflags-y +=  -I$(srctree)/drivers/net/ethernet/freescale/fman
 
-obj-y  += fsl_fman.o
+obj-y  += fsl_fman.o fsl_fman_mac.o
 
 fsl_fman-objs  := fman_muram.o fman.o
+fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o
diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
new file mode 100644
index 000..d78e2ba
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -0,0 +1,1453 @@
+/*
+ * 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.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include "fman_dtsec.h"
+#include "fman.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* TBI register addresses */
+#define MII_TBICON 0x11
+
+/* TBICON register bit fields */
+#define TBICON_SOFT_RESET  0x8000  /* Soft reset */
+#define TBICON_DISABLE_RX_DIS  0x2000  /* Disable receive disparity */
+#define TBICON_DISABLE_TX_DIS  0x1000  /* Disable transmit disparity */
+#define TBICON_AN_SENSE0x0100  /* Auto-negotiation sense 
enable */
+#define TBICON_CLK_SELECT  0x0020  /* Clock select */
+#define TBICON_MI_MODE 0x0010  /* GMII mode (TBI if not set) */
+
+#define TBIANA_SGMII   0x4001
+#define TBIANA_1000X   0x01a0
+
+/* Interrupt Mask Register (IMASK) */
+#defin

[v10, 6/6] fsl/fman: Add FMan MAC driver

2015-12-21 Thread igal.liberman
From: Igal Liberman 

This patch adds the Ethernet MAC driver supporting the three
different types of MACs: dTSEC, tGEC and mEMAC.

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile |3 +-
 drivers/net/ethernet/freescale/fman/mac.c|  978 ++
 drivers/net/ethernet/freescale/fman/mac.h|   97 +++
 3 files changed, 1077 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/mac.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 2eb0b9b..51fd2e6 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -1,6 +1,7 @@
 subdir-ccflags-y +=  -I$(srctree)/drivers/net/ethernet/freescale/fman
 
-obj-y  += fsl_fman.o fsl_fman_mac.o
+obj-y  += fsl_fman.o fsl_fman_mac.o fsl_mac.o
 
 fsl_fman-objs  := fman_muram.o fman.o fman_sp.o fman_port.o
 fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o
+fsl_mac-objs += mac.o
diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
new file mode 100644
index 000..743a393
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -0,0 +1,978 @@
+/* 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.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mac.h"
+#include "fman_mac.h"
+#include "fman_dtsec.h"
+#include "fman_tgec.h"
+#include "fman_memac.h"
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("FSL FMan MAC API based driver");
+
+struct mac_priv_s {
+   struct device   *dev;
+   void __iomem*vaddr;
+   u8  cell_index;
+   phy_interface_t phy_if;
+   struct fman *fman;
+   struct device_node  *phy_node;
+   struct device_node  *internal_phy_node;
+   /* List of multicast addresses */
+   struct list_headmc_addr_list;
+   struct platform_device  *eth_dev;
+   struct fixed_phy_status *fixed_link;
+   u16 speed;
+   u16 max_speed;
+
+   int (*enable)(struct fman_mac *mac_dev, enum comm_mode mode);
+   int (*disable)(struct fman_mac *mac_dev, enum comm_mode mode);
+};
+
+struct mac_address {
+   u8 addr[ETH_ALEN];
+   struct list_head list;
+};
+
+static void mac_exception(void *handle, enum fman_mac_exceptions ex)
+{
+   struct mac_device   *mac_dev;
+   struct mac_priv_s   *priv;
+
+   mac_dev = handle;
+   priv = mac_dev->priv;
+
+   if (ex == FM_MAC_EX_10G_RX_FIFO_OVFL) {
+   /* don't flag RX FIFO after the first */
+   mac_dev->set_exception(mac_dev->fman_mac,
+  FM_MAC_EX_10G_RX_FIFO_OVFL, false);
+   dev_err(priv->dev, "10G MAC got RX FIFO Error = %x\n", ex);
+   }
+
+

[v10, 0/6] Freescale DPAA FMan

2015-12-21 Thread igal.liberman
From: Igal Liberman 

The Freescale Data Path Acceleration Architecture (DPAA) is a set
of hardware components on specific QorIQ multicore processors.
This architecture provides the infrastructure to support
simplified sharing of networking interfaces and accelerators
by multiple CPU cores and the accelerators.

One of the DPAA accelerators is the Frame Manager (FMan)
which contains a series of hardware blocks: ports, Ethernet MACs,
a multi user RAM (MURAM) and Storage Profile (SP).

This patch set introduce the FMan drivers.
Each driver configures and initializes the corresponding
FMan hardware module (described above).
The MAC driver offers support for three different
types of MACs (eTSEC, TGEC, MEMAC).

v9 --> v10:
- Addressed feedback from David Miller
Remove private CRC implementation
- Addressed feedback from Kenneth Klette Jonassen:
- Use Kernel PHY API to configure dTSEC TBI
- Use Kernel PHY API to configure mEMAC PCS
  This patchset requires device tree update:
  https://patchwork.ozlabs.org/patch/559501/
- Addressed feedback from Andy Fleming

v8 --> v9:
No changes

v7 --> v8:
- Addressed feedback from David Miller
- Support for ARM:
- Device tree parsing
- IO Accessors
- Addressed compilation issue on non-PPC targets

v6 --> v7:
- Addressed compilation issue on non-PPC targets
- Removed B4860 rev 1 support

v5 --> v6:
- Addressed feedback from Scott:
- Moved kernel doc to source files
- Removed a series of configurable settings
- Miscellaneous code updates

v4 --> v5:
- Addressed feedback from David Miller:
- Removed driver layering
- Reduce namespace pollution
- Reduce code complexity and size

v3 --> v4:
- Remove device_initcall call in driver registration (redundant)
- Remove hot/cold labels
- Minor update in FMan Clock read from device-tree
- Update fixed-link support
- Addressed feedback from Stephen Hemminger
- Remove bogus blank line

v2 --> v3:
- Addressed feedback from Scott:
- Remove typedefs
- Remove unnecessary memory barriers
- Remove unnecessary casting
- Remove KConfig options
- Remove early_params
- Remove Hungarian notation
- Remove __packed__  attribute and padding from structures
- Remove unlikely attribute (where it's not needed)
- Use proper error codes and remove unnecessary prints
- Use proper values for sleep routines
- Replace complex Macros with functions
- Improve device tree processing code
- Use symbolic defines
- Add time-out in busy-wait loops
- Removed exit code (loadable module support will be added 
later)
- Fixed "fixed-link" issue raised by Joakim Tjernlund

v1 --> v2:
- Addressed feedback from Paul Bolle:
- General feedback of FMan Driver layer
- Remove Errata defines
- Aligned comments to Kernel Doc
- Remove Loadable Module support (not yet supported)
- Removed not needed KConfig dependencies
- Addressed feedback from Scott Wood
- Use Kernel ioread/iowrite services
- Squash FLIB source and header patches together

This submission is based on the prior Freescale DPAA FMan V3,RFC submission.
Several issues addresses in this submission:
- Reduced MAC layering and complexity
- Reduced code base
- T1024/T2080 10G best effort support


Igal Liberman (6):
  fsl/fman: Add FMan MURAM support
  fsl/fman: Add FMan support
  fsl/fman: Add FMan MAC support
  fsl/fman: Add FMan SP support
  fsl/fman: Add FMan Port Support
  fsl/fman: Add FMan MAC driver

 drivers/net/ethernet/freescale/Kconfig   |1 +
 drivers/net/ethernet/freescale/Makefile  |2 +
 drivers/net/ethernet/freescale/fman/Kconfig  |8 +
 drivers/net/ethernet/freescale/fman/Makefile |7 +
 drivers/net/ethernet/freescale/fman/fman.c   | 2872 ++
 drivers/net/ethernet/freescale/fman/fman.h   |  325 +++
 drivers/net/ethernet/freescale/fman/fman_dtsec.c | 1453 +++
 drivers/net/ethernet/freescale/fman/fman_dtsec.h |   59 +
 drivers/net/ethernet/freescale/fman/fman_mac.h   |  278 +++
 drivers/net/ethernet/freescale/fman/fman_memac.c | 1170 +
 drivers/net/ethernet/freescale/fman/fman_memac.h |   60 +
 drivers/net/ethernet/freescale/fman/fman_muram.c |  159 ++
 drivers/net/ethernet/freescale/fman/fman_muram.h |   51 +
 drivers/net/ethernet/freescale/fman/fman_port.c  | 1779 +

[v10, 1/6] fsl/fman: Add FMan MURAM support

2015-12-21 Thread igal.liberman
From: Igal Liberman 

Add Frame Manager Multi-User RAM support.
This internal FMan memory block is used by the
FMan hardware modules, the management being made
through the generic allocator.

The FMan Internal memory, for example, is used for
allocating transmit and receive FIFOs.

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/Kconfig   |1 +
 drivers/net/ethernet/freescale/Makefile  |2 +
 drivers/net/ethernet/freescale/fman/Kconfig  |8 ++
 drivers/net/ethernet/freescale/fman/Makefile |5 +
 drivers/net/ethernet/freescale/fman/fman_muram.c |  159 ++
 drivers/net/ethernet/freescale/fman/fman_muram.h |   51 +++
 6 files changed, 226 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_muram.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_muram.h

diff --git a/drivers/net/ethernet/freescale/Kconfig 
b/drivers/net/ethernet/freescale/Kconfig
index bee32a9..d1ca45f 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -54,6 +54,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..66b7296
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/Kconfig
@@ -0,0 +1,8 @@
+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
+   (FMan) support
diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
new file mode 100644
index 000..fc2e194
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -0,0 +1,5 @@
+subdir-ccflags-y +=  -I$(srctree)/drivers/net/ethernet/freescale/fman
+
+obj-y  += fsl_fman.o
+
+fsl_fman-objs  := fman_muram.o
diff --git a/drivers/net/ethernet/freescale/fman/fman_muram.c 
b/drivers/net/ethernet/freescale/fman/fman_muram.c
new file mode 100644
index 000..35d4a50
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman_muram.c
@@ -0,0 +1,159 @@
+/*
+ * 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 "fman_muram.h"
+
+#include 
+#include 
+#include 
+
+struct muram_info {
+   struct gen_pool *pool;
+

[v10, 2/6] fsl/fman: Add FMan support

2015-12-21 Thread igal.liberman
From: Igal Liberman 

Add the Data Path Acceleration Architecture Frame Manger Driver.
The FMan embeds a series of hardware blocks that implement a group
of Ethernet interfaces. This patch adds The FMan configuration,
initialization and runtime control routines.

The FMan driver supports several hardware versions
differentiated by things like:
- Different type of MACs
- Number of MAC and ports
- Available resources
- Different hardware errata

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile |2 +-
 drivers/net/ethernet/freescale/fman/fman.c   | 2872 ++
 drivers/net/ethernet/freescale/fman/fman.h   |  325 +++
 3 files changed, 3198 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/fman.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index fc2e194..fb5a7f0 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -2,4 +2,4 @@ subdir-ccflags-y +=  
-I$(srctree)/drivers/net/ethernet/freescale/fman
 
 obj-y  += fsl_fman.o
 
-fsl_fman-objs  := fman_muram.o
+fsl_fman-objs  := fman_muram.o 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..98bae37
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -0,0 +1,2872 @@
+/*
+ * 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.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include "fman.h"
+#include "fman_muram.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* General defines */
+#define FMAN_LIODN_TBL 64  /* size of LIODN table */
+#define MAX_NUM_OF_MACS10
+#define FM_NUM_OF_FMAN_CTRL_EVENT_REGS 4
+#define BASE_RX_PORTID 0x08
+#define BASE_TX_PORTID 0x28
+
+/* Modules registers offsets */
+#define BMI_OFFSET 0x0008
+#define QMI_OFFSET 0x00080400
+#define DMA_OFFSET 0x000C2000
+#define FPM_OFFSET 0x000C3000
+#define IMEM_OFFSET0x000C4000
+#define CGP_OFFSET 0x000DB000
+
+/* Exceptions bit map */
+#define EX_DMA_BUS_ERROR   0x8000
+#define EX_DMA_READ_ECC0x4000
+#define EX_DMA_SYSTEM_WRITE_ECC0x2000
+#define EX_DMA_FM_WRITE_ECC0x1000
+#define EX_FPM_STALL_ON_TASKS  0x0800
+#define EX_FPM_SINGLE_ECC  0x0400
+#define EX_FPM_DOUBLE_ECC  0x0200
+#define EX_QMI_SINGLE_ECC  0x0100
+#define EX_QMI_DEQ_FROM_UNKNOWN_PORTID 0x0080
+#define EX_QMI_DOUBLE_ECC  0x0040
+#define EX_BMI_LIST_RAM_ECC0x0020
+#define EX_BMI_STORAGE_PROFILE_ECC 0x0010
+#define EX_BMI_STATISTICS_RAM_ECC  0x0008
+#define EX_IRAM_ECC0x0004
+#define EX_MURAM_ECC   0x0002
+#define EX_BMI_DISPATCH_RAM_ECC0x0001

[PATCH] BugFix in XHCI controller driver for scatter gather DMA

2015-12-21 Thread Vikas Bansal
Pre-Condition
At the time of reset resume of a USB device, both self and bus powered devices 
might go to a low power state or power off state depending on the acceptable 
suspend time power of the system.
In case the device experiences a power glitch or completely powers off during 
suspend-resume, the device will lose its internal state and hence it'll again 
need a set interface from class driver on reset resume operation.

Issue 
So far our experiments were based on a USB gadget working on cdc_eem protocol. 
We have seen that device is unable to continue the packet transfer on bulk 
endpoints after the reset resume operation.

Solution
We have added a .reset_resume function for cdc_eem protocol which sends a set 
interface command on the Control endpoint. And calls the existing usbnet_resume 
thereafter


Signed-off-by: Vikas Bansal 
Signed-off-by: Sumit Batra 
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
index f7180f8..1f6f7ea 100644
--- a/drivers/net/usb/cdc_eem.c
+++ b/drivers/net/usb/cdc_eem.c
@@ -342,6 +342,19 @@ next:
return 1;
 }
 
+static int cdc_eem_resume(struct usb_interface *intf)
+{
+   int ret = 0;
+   struct usbnet *dev = usb_get_intfdata(intf);
+
+   ret = usbnet_get_endpoints(dev, intf);
+   if(ret < 0)
+   goto err;
+   ret = usbnet_resume(intf);
+err:
+   return ret;
+}
+
 static const struct driver_info eem_info = {
.description =  "CDC EEM Device",
.flags =FLAG_ETHER | FLAG_POINTTOPOINT,
@@ -371,6 +384,7 @@ static struct usb_driver eem_driver = {
.disconnect =   usbnet_disconnect,
.suspend =  usbnet_suspend,
.resume =   usbnet_resume,
+   .reset_resume = cdc_eem_resume,
.disable_hub_initiated_lpm = 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


[v10, 5/6] fsl/fman: Add FMan Port Support

2015-12-21 Thread igal.liberman
From: Igal Liberman 

Add the Data Path Acceleration Architecture Frame Manger Port Driver.
The FMan driver uses a module called "Port" to represent the physical
TX and RX ports.
Each FMan version has different number of physical ports.
This patch adds The FMan Port configuration, initialization and
runtime control routines for both TX and RX.

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile|2 +-
 drivers/net/ethernet/freescale/fman/fman_port.c | 1779 +++
 drivers/net/ethernet/freescale/fman/fman_port.h |  151 ++
 3 files changed, 1931 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_port.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_port.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 5141532..2eb0b9b 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -2,5 +2,5 @@ subdir-ccflags-y +=  
-I$(srctree)/drivers/net/ethernet/freescale/fman
 
 obj-y  += fsl_fman.o fsl_fman_mac.o
 
-fsl_fman-objs  := fman_muram.o fman.o fman_sp.o
+fsl_fman-objs  := fman_muram.o fman.o fman_sp.o fman_port.o
 fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o
diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c 
b/drivers/net/ethernet/freescale/fman/fman_port.c
new file mode 100644
index 000..562d524
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -0,0 +1,1779 @@
+/*
+ * 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.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include "fman_port.h"
+#include "fman.h"
+#include "fman_sp.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Queue ID */
+#define DFLT_FQ_ID 0x00FF
+
+/* General defines */
+#define PORT_BMI_FIFO_UNITS0x100
+
+#define MAX_PORT_FIFO_SIZE(bmi_max_fifo_size)  \
+   min((u32)bmi_max_fifo_size, (u32)1024 * FMAN_BMI_FIFO_UNITS)
+
+#define PORT_CG_MAP_NUM8
+#define PORT_PRS_RESULT_WORDS_NUM  8
+#define PORT_IC_OFFSET_UNITS   0x10
+
+#define MIN_EXT_BUF_SIZE   64
+
+#define BMI_PORT_REGS_OFFSET   0
+#define QMI_PORT_REGS_OFFSET   0x400
+
+/* Default values */
+#define DFLT_PORT_BUFFER_PREFIX_CONTEXT_DATA_ALIGN \
+   DFLT_FM_SP_BUFFER_PREFIX_CONTEXT_DATA_ALIGN
+
+#define DFLT_PORT_CUT_BYTES_FROM_END   4
+
+#define DFLT_PORT_ERRORS_TO_DISCARDFM_PORT_FRM_ERR_CLS_DISCARD
+#define DFLT_PORT_MAX_FRAME_LENGTH 9600
+
+#define DFLT_PORT_RX_FIFO_PRI_ELEVATION_LEV(bmi_max_fifo_size) \
+   MAX_PORT_FIFO_SIZE(bmi_max_fifo_size)
+
+#define DFLT_PORT_RX_FIFO_THRESHOLD(major, bmi_max_fifo_size)  \
+   (major == 6 ?   \
+   MAX_PORT_FIFO_SIZE(bmi_max_fifo_size) : \
+   (MAX_PORT_FIFO_SIZE(bmi_max_fifo_size) * 3 / 4))\
+
+#define DFLT_PORT_EXTRA_NUM_OF_FIFO_BUFS   0
+
+/* QMI defines */
+#define QMI_DEQ_CFG_SUBPORTAL_MASK 0x1f
+
+#defin

[PATCH] Adding Reset resume support for CDC-EEM driver.

2015-12-21 Thread Vikas Bansal
Pre-Condition
At the time of reset resume of a USB device, both self and bus powered devices 
might go to a low power state or power off state depending on the acceptable 
suspend time power of the system.
In case the device experiences a power glitch or completely powers off during 
suspend-resume, the device will lose its internal state and hence it'll again 
need a set interface from class driver on reset resume operation.

Issue 
So far our experiments were based on a USB gadget working on cdc_eem protocol. 
We have seen that device is unable to continue the packet transfer on bulk 
endpoints after the reset resume operation.

Solution
We have added a .reset_resume function for cdc_eem protocol which sends a set 
interface command on the Control endpoint. And calls the existing usbnet_resume 
thereafter


Signed-off-by: Vikas Bansal 
Signed-off-by: Sumit Batra 
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
index f7180f8..1f6f7ea 100644
--- a/drivers/net/usb/cdc_eem.c
+++ b/drivers/net/usb/cdc_eem.c
@@ -342,6 +342,19 @@ next:
return 1;
 }
 
+static int cdc_eem_resume(struct usb_interface *intf)
+{
+   int ret = 0;
+   struct usbnet *dev = usb_get_intfdata(intf);
+
+   ret = usbnet_get_endpoints(dev, intf);
+   if(ret < 0)
+   goto err;
+   ret = usbnet_resume(intf);
+err:
+   return ret;
+}
+
 static const struct driver_info eem_info = {
.description =  "CDC EEM Device",
.flags =FLAG_ETHER | FLAG_POINTTOPOINT,
@@ -371,6 +384,7 @@ static struct usb_driver eem_driver = {
.disconnect =   usbnet_disconnect,
.suspend =  usbnet_suspend,
.resume =   usbnet_resume,
+   .reset_resume = cdc_eem_resume,
.disable_hub_initiated_lpm = 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: [PATCH] net: phy: adds backplane driver for Freescale's PCS PHY

2015-12-21 Thread Shaohui Xie
> On Fri, Dec 18, 2015 at 05:30:54PM +0800, shh@gmail.com wrote:
> > +static int fsl_backplane_probe(struct phy_device *phydev) {
> > +   struct fsl_xgkr_inst *xgkr_inst;
> > +   struct device_node *child, *parent, *lane_node;
> > +   const char *lane_name;
> > +   int len;
> > +   int ret;
> > +   u32 mode;
> > +   u32 lane[2];
> > +
> > +   child = phydev->dev.of_node;
> > +   parent = of_get_parent(child);
> > +   if (!parent) {
> > +   dev_err(&phydev->dev, "could not get parent node");
> > +   return 0;
> > +   }
> > +
> > +   lane_name = of_get_property(parent, "lane-instance", &len);
> > +   if (!lane_name)
> > +   return 0;
> > +
> > +   if (strstr(lane_name, "1000BASE-KX"))
> > +   mode = BACKPLANE_1G_KX;
> > +   else
> > +   mode = BACKPLANE_10G_KR;
> > +
> > +   lane_node = of_parse_phandle(child, "lane-handle", 0);
> 
> 
> Hi Shaohui
> 
> You are missing the device tree binding Documentation.
> 
> Parent will be the mdio bus device and you want 'lane-instance' and
> 'lane-handle' properties to be in the mdio bus node?
[S.H] Hi Andrew,

Thanks for reviewing the patch!

I did missed the device tree binding documentation.
This driver expected a property "lane-instance" in mdio bus node, and
"lane-handle" and "lane-range" properties in phy node.

The "lane-instance" indicates what the phy should be probed as,
1000BASE-KX or 10GBASE-KR, seems phy node is a better place than mdio bus node
to hold this property, maybe a better name "phy-mode" should be used?

The "lane-handle" pointed to a serdes node which looks like below:
E.g. in arch/powerpc/boot/dts/fsl/t4240si-post.dtsi:

serdes: serdes@ea000 {
compatible = "fsl,t4240-serdes";
reg= <0xea000 0x4000>;
};

The "lane-handle" property would be: lane-handle = <&serdes>;

The serdes node has "reg" property for the whole registers space,
for a PCS phy, only some serdes registers (lane control registers)
are related and needed to be configured at runtime, so I used the 
"lane-range" property to hold such information, it would be e.g.:
lane-range = <0x1800 0x40>;
'0x1800' is offset of the lane control registers in serdes, '0x40' is 
size of the space.
Different PCS phy has different offset, but the size is same.

"phy-mode" (if it can be used here) has been documented in: 
Documentation/devicetree/bindings/net/ethernet.txt,
I'm not sure where the serdes lane related properties should go, 
 'fsl-tsec-phy.txt' or a new binding like 'fsl-pcs-phy.txt'?
Please comment.

Thanks!
Shaohui
--
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] BugFix in XHCI controller driver for scatter gather DMA

2015-12-21 Thread Oliver Neukum
On Mon, 2015-12-21 at 17:34 +0530, Vikas Bansal wrote:
> Pre-Condition
> At the time of reset resume of a USB device, both self and bus powered 
> devices might go to a low power state or power off state depending on the 
> acceptable suspend time power of the system.
> In case the device experiences a power glitch or completely powers off during 
> suspend-resume, the device will lose its internal state and hence it'll again 
> need a set interface from class driver on reset resume operation.
> 
> Issue 
> So far our experiments were based on a USB gadget working on cdc_eem 
> protocol. 
> We have seen that device is unable to continue the packet transfer on bulk 
> endpoints after the reset resume operation.
> 
> Solution
> We have added a .reset_resume function for cdc_eem protocol which sends a set 
> interface command on the Control endpoint. And calls the existing 
> usbnet_resume thereafte

Hi,

something is wrong with your subject line. Could you fix
that and resend?

Regards
Oliver


--
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] Adding Reset resume support for CDC-EEM driver.

2015-12-21 Thread Vikas Bansal
Pre-Condition
At the time of reset resume of a USB device, both self and bus powered 
devices might go to a low power state or power off state depending on 
the acceptable suspend time power of the system.
In case the device experiences a power glitch or completely powers off 
during suspend-resume, the device will lose its internal state and 
hence it'll again need a set interface from class driver on reset resume 
operation.

Issue 
So far our experiments were based on a USB gadget working on cdc_eem 
protocol. 
We have seen that device is unable to continue the packet transfer on 
bulk endpoints after the reset resume operation.

Solution
We have added a .reset_resume function for cdc_eem protocol which sends a
set interface command on the Control endpoint. And calls the existing 
usbnet_resume thereafter


Signed-off-by: Vikas Bansal 
Signed-off-by: Sumit Batra 
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
index f7180f8..1f6f7ea 100644
--- a/drivers/net/usb/cdc_eem.c
+++ b/drivers/net/usb/cdc_eem.c
@@ -342,6 +342,19 @@ next:
return 1;
 }
 
+static int cdc_eem_resume(struct usb_interface *intf)
+{
+   int ret = 0;
+   struct usbnet *dev = usb_get_intfdata(intf);
+
+   ret = usbnet_get_endpoints(dev, intf);
+   if (ret < 0)
+   goto err;
+   ret = usbnet_resume(intf);
+err:
+   return ret;
+}
+
 static const struct driver_info eem_info = {
.description =  "CDC EEM Device",
.flags =FLAG_ETHER | FLAG_POINTTOPOINT,
@@ -371,6 +384,7 @@ static struct usb_driver eem_driver = {
.disconnect =   usbnet_disconnect,
.suspend =  usbnet_suspend,
.resume =   usbnet_resume,
+   .reset_resume = cdc_eem_resume,
.disable_hub_initiated_lpm = 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 1/1] use buf, not (non-existent) ptr

2015-12-21 Thread Christian Hesse
From: Christian Hesse 

Shared code was moved to a function, but variable name has not been
updated. Use buf (passed to the function) instead of ptr.

This fixes regressen from upstream commit
7d6aadcd0a1dc795d72e1ab311aee333c763fe71.

Signed-off-by: Christian Hesse 
---
 ip/tunnel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/tunnel.c b/ip/tunnel.c
index 1dd8092..39f825b 100644
--- a/ip/tunnel.c
+++ b/ip/tunnel.c
@@ -208,7 +208,7 @@ void tnl_print_stats(const char *buf)
  tx_bytes, tx_packets, tx_errs, tx_drops,
  tx_fifo, tx_colls, tx_carrier, rx_multi;
 
-   if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
+   if (sscanf(buf, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
   &rx_bytes, &rx_packets, &rx_errs, &rx_drops,
   &rx_fifo, &rx_frame, &rx_multi,
   &tx_bytes, &tx_packets, &tx_errs, &tx_drops,
-- 
2.6.4

--
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: net, ipv6: out of bounds access in secret_stable

2015-12-21 Thread Sasha Levin
On 12/21/2015 03:58 AM, Hannes Frederic Sowa wrote:
> On 19.12.2015 21:50, Cong Wang wrote:
>> On Fri, Dec 18, 2015 at 5:13 PM, Sasha Levin  wrote:
>>> Hi Hannes,
>>>
>>> I've hit the following out of bounds access while fuzzing on the latest 
>>> -next kernel.
>>>
>>> This code was added in 3d1bec9932 ("ipv6: introduce secret_stable to 
>>> ipv6_devconf").
>>>
>>> [  459.553655] BUG: KASAN: stack-out-of-bounds in strlen+0x58/0x90 at addr 
>>> 8802ab0efb0e
>>> [  459.554953] Read of size 1 by task trinity-c91/22576
>>> [  459.555805] page:ea000aac3bc0 count:0 mapcount:0 mapping:  
>>> (null) index:0x0
>>> [  459.556899] flags: 0x26f8000()
>>> [  459.557521] page dumped because: kasan: bad access detected
>>> [  459.558320] CPU: 7 PID: 22576 Comm: trinity-c91 Not tainted 
>>> 4.4.0-rc5-next-20151218-sasha-00021-gaba8d84-dirty #2750
>>> [  459.559809]   549d0aa3 8802ab0ef860 
>>> a1042384
>>> [  459.561036]  41b58ab3 ac667cdb a10422d9 
>>> 8802ab0ef848
>>> [  459.562245]  9f6a417e 549d0aa3 8802ab0efb0e 
>>> 8802ab0efb0e
>>> [  459.563429] Call Trace:
>>> [  459.563831] dump_stack (lib/dump_stack.c:52)
>>> [  459.564623] ? _atomic_dec_and_lock (lib/dump_stack.c:27)
>>> [  459.565628] ? __dump_page (mm/debug.c:126)
>>> [  459.566538] kasan_report_error (include/linux/kasan.h:28 
>>> mm/kasan/report.c:170 mm/kasan/report.c:237)
>>> [  459.570997] __asan_report_load1_noabort (mm/kasan/report.c:277)
>>> [  459.572119] ? check_preemption_disabled (lib/smp_processor_id.c:39)
>>> [  459.573731] ? strlen (lib/string.c:481 (discriminator 1))
>>> [  459.574646] strlen (lib/string.c:481 (discriminator 1))
>>> [  459.575485] proc_dostring (kernel/sysctl.c:1825 kernel/sysctl.c:1906)
>>> [  459.576445] ? alloc_debug_processing (mm/slub.c:1054)
>>> [  459.577523] addrconf_sysctl_stable_secret (net/ipv6/addrconf.c:5395)
>>
>> Looks like we don't initialize the array on stack for write case.
>> At least other callers always initialize the data for both read
>> and write.
>>
>> Please try the attached patch.
> 
> Your patch is right. I am surprised you need to initialize the buffer
> passed down to proc_dostring so that strlen can correctly operate on it,
> but f4aacea2f5d1a5 ("sysctl: allow for strict write position handling")
> explains why. Can you submit formally?
> 
> Acked-by: Hannes Frederic Sowa 

And that seems to fix the issue here as well.


Thanks,
Sasha

--
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] sctp: sctp should release assoc when sctp_make_abort_user return NULL in sctp_close

2015-12-21 Thread Marcelo Ricardo Leitner

Em 21-12-2015 07:56, Xin Long escreveu:

On Sat, Dec 19, 2015 at 12:23 AM, Marcelo Ricardo Leitner
 wrote:

On Fri, Dec 18, 2015 at 09:08:46AM -0500, Vlad Yasevich wrote:

On 12/17/2015 02:33 PM, Vlad Yasevich wrote:

On 12/17/2015 02:01 PM, Marcelo Ricardo Leitner wrote:

...

There is a check on sctp_cmd_delete_tcb() that avoids calling that on temp 
assocs on
listening sockets, but that condition is false due to the check on sk_shutdown 
so it will
call those two functions anyway.


The condition I am a bit concerned about is one thread waiting in 
sctp_wait_for_sndbuf
while another does an abort.

I think this is OK though.  I need to look a bit more...


I think the only time this ends up biting us is if SO_SNDTIMEO was used and we 
ran out
of send buffer.  It looks to me like schedule_timeout() will wait until timer 
expired and
depending on the timer value, you could wait quite a while.

With this path, since you don't transition state, the asoc->wait wait queue is 
never
notified and it could be hanging around for quite a while.


do you think it makes sense if we have this condition judgment there ?
 if (waitqueue_active(&asoc->wait))
 wake_up_interruptible(&asoc->wait);


No, because later if there is something else like this that we need to 
handle on this situation, we will have to update both places and we may 
forget to update one of them. It's better to just skip the packet 
transmission/CMD_REPLY if chunk is NULL and let rest execute, as Vlad 
suggested.


It will also be better for troubleshooting, as it may generate debug 
msgs about the state transition.


  Marcelo

--
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 V2 3/4] net/mlx5e: Add HW timestamping (TS) support

2015-12-21 Thread Saeed Mahameed
On Mon, Dec 21, 2015 at 11:15 AM, Richard Cochran
 wrote:
> On Sun, Dec 20, 2015 at 11:46:30PM +0200, Saeed Mahameed wrote:
>> +/* Should run once every mlx5e_tstamp->overflow_period */
>> +static void mlx5e_timestamp_overflow(struct work_struct *work)
>> +{
>> + struct delayed_work *dwork = to_delayed_work(work);
>> + struct mlx5e_tstamp *tstamp = container_of(dwork, struct mlx5e_tstamp, 
>> overflow_work);
>> + unsigned long flags;
>> +
>> + write_lock_irqsave(&tstamp->lock, flags);
>> + timecounter_read(&tstamp->clock);
>> + if (tstamp->overflow_period)
>> + schedule_delayed_work(&tstamp->overflow_work, 
>> tstamp->overflow_period);
>
> You don't need this test, and the call to schedule_delayed_work can be
> outside of the lock.
>

think of a case where:
CPU1: is just about to call
"schedule_delayed_work(&tstamp->overflow_work,
tstamp->overflow_period);"
CPU2: cancel_delayed_work

In this case cancel_dalyed_work_sync (CPU2) will wait for CPU1 to
complete but CPU1 will re-arm the work, and we will
be left with tstamp->overflow_work running forever.

>> + write_unlock_irqrestore(&tstamp->lock, flags);
>> +}
>
>> +void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv)
>> +{
>> + struct mlx5e_tstamp *tstamp = &priv->tstamp;
>> +
>> + if (!MLX5_CAP_GEN(priv->mdev, device_frequency_khz))
>> + return;
>> +
>> + write_lock(&tstamp->lock);
>> + tstamp->overflow_period = 0; /* Signal overflow_check to stop */
>> + write_unlock(&tstamp->lock);
>
> This is unnecessary because
>
>> +
>> + cancel_delayed_work_sync(&tstamp->overflow_work);
>
> this will block until the work is cancelled.
>
see my previous comment it sure will block but without the protected
signal " tstamp->overflow_period = 0;"
the work can reschedule itself.

>> +}
>
> Thanks,
> Richard
>
>
--
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: tcp: deal with listen sockets properly in tcp_abort.

2015-12-21 Thread Lorenzo Colitti
When closing a listen socket, tcp_abort currently calls
tcp_done without clearing the request queue. If the socket has a
child socket that is established but not yet accepted, the child
socket is then left without a parent, causing a leak.

Fix this by setting the socket state to TCP_CLOSE and calling
inet_csk_listen_stop with the socket lock held, like tcp_close
does.

Tested using net_test. With this patch, calling SOCK_DESTROY on a
listen socket that has an established but not yet accepted child
socket results in the parent and the child being closed, such
that they no longer appear in sock_diag dumps.

Reported-by: Eric Dumazet 
Signed-off-by: Lorenzo Colitti 
---
 net/ipv4/tcp.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index cc7aaa5..7bb1b09 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3099,6 +3099,11 @@ int tcp_abort(struct sock *sk, int err)
/* Don't race with userspace socket closes such as tcp_close. */
lock_sock(sk);
 
+   if (sk->sk_state == TCP_LISTEN) {
+   tcp_set_state(sk, TCP_CLOSE);
+   inet_csk_listen_stop(sk);
+   }
+
/* Don't race with BH socket closes such as inet_csk_listen_stop. */
local_bh_disable();
bh_lock_sock(sk);
-- 
2.6.0.rc2.230.g3dd15c0

--
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 07/14] batman-adv: use list_for_each_entry_safe

2015-12-21 Thread Antonio Quartulli
Hi Geliang,

>  static int batadv_socket_release(struct inode *inode, struct file *file)
>  {
> - struct batadv_socket_client *socket_client = file->private_data;
> - struct batadv_socket_packet *socket_packet;
> - struct list_head *list_pos, *list_pos_tmp;
> + struct batadv_socket_client *client = file->private_data;
> + struct batadv_socket_packet *packet, *tmp;
>  

[...]


> + list_for_each_entry_safe(packet, tmp, &client->queue_list, list) {

I guess you renamed those variables to make sure that the statement
above would fit in 80 chars.. in that case the patch looks good.


Acked-by: Antonio Quartulli 


-- 
Antonio Quartulli



signature.asc
Description: OpenPGP digital signature


[patch net-next] mlxsw: core: Use devm_kzalloc to allocate mlxsw_hwmon structure

2015-12-21 Thread Jiri Pirko
From: Jiri Pirko 

KASan reported use-after-free for the hwmon structure. So fix this by
using devm_kzalloc and let the core take care about freeing the memory
during device dettach.

Reported-by: Ido Schimmel 
Fixes: 89309da39 ("mlxsw: core: Implement temperature hwmon interface")
Signed-off-by: Jiri Pirko 
---
 drivers/net/ethernet/mellanox/mlxsw/core.c   | 2 --
 drivers/net/ethernet/mellanox/mlxsw/core.h   | 4 
 drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 8 ++--
 3 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c 
b/drivers/net/ethernet/mellanox/mlxsw/core.c
index af8a48b..22379eb 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -855,7 +855,6 @@ int mlxsw_core_bus_device_register(const struct 
mlxsw_bus_info *mlxsw_bus_info,
 err_debugfs_init:
mlxsw_core->driver->fini(mlxsw_core->driver_priv);
 err_driver_init:
-   mlxsw_hwmon_fini(mlxsw_core->hwmon);
 err_hwmon_init:
mlxsw_emad_fini(mlxsw_core);
 err_emad_init:
@@ -878,7 +877,6 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core 
*mlxsw_core)
 
mlxsw_core_debugfs_fini(mlxsw_core);
mlxsw_core->driver->fini(mlxsw_core->driver_priv);
-   mlxsw_hwmon_fini(mlxsw_core->hwmon);
mlxsw_emad_fini(mlxsw_core);
mlxsw_core->bus->fini(mlxsw_core->bus_priv);
kfree(mlxsw_core->lag.mapping);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h 
b/drivers/net/ethernet/mellanox/mlxsw/core.h
index 4833fb3..a017236 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -239,10 +239,6 @@ static inline int mlxsw_hwmon_init(struct mlxsw_core 
*mlxsw_core,
return 0;
 }
 
-static inline void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon)
-{
-}
-
 #endif
 
 #endif
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c 
b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
index 00ccf1c..0aacbf7 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
@@ -334,7 +334,8 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
struct device *hwmon_dev;
int err;
 
-   mlxsw_hwmon = kzalloc(sizeof(*mlxsw_hwmon), GFP_KERNEL);
+   mlxsw_hwmon = devm_kzalloc(mlxsw_bus_info->dev, sizeof(*mlxsw_hwmon),
+  GFP_KERNEL);
if (!mlxsw_hwmon)
return -ENOMEM;
mlxsw_hwmon->core = mlxsw_core;
@@ -370,8 +371,3 @@ err_temp_init:
kfree(mlxsw_hwmon);
return err;
 }
-
-void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon)
-{
-   kfree(mlxsw_hwmon);
-}
-- 
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


Re: [PATCH 1/2] can: sja1000: add documentation for Technologic Systems version

2015-12-21 Thread Damien Riegel
On Sat, Dec 19, 2015 at 09:37:42PM -0600, Rob Herring wrote:
> On Fri, Dec 18, 2015 at 03:17:24PM -0500, Damien Riegel wrote:
> > This commit adds documentation for the Technologic Systems version of
> > SJA1000. The difference with the NXP version is in the way the registers
> > are accessed.
> > 
> > Signed-off-by: Damien Riegel 
> > ---
> >  Documentation/devicetree/bindings/net/can/sja1000.txt | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/net/can/sja1000.txt 
> > b/Documentation/devicetree/bindings/net/can/sja1000.txt
> > index b4a6d53..7a158d5 100644
> > --- a/Documentation/devicetree/bindings/net/can/sja1000.txt
> > +++ b/Documentation/devicetree/bindings/net/can/sja1000.txt
> > @@ -2,7 +2,7 @@ Memory mapped SJA1000 CAN controller from NXP (formerly 
> > Philips)
> >  
> >  Required properties:
> >  
> > -- compatible : should be "nxp,sja1000".
> > +- compatible : should be one of "nxp,sja1000", "technologic,sja1000".
> >  
> >  - reg : should specify the chip select, address offset and size required
> > to map the registers of the SJA1000. The size is usually 0x80.
> > @@ -14,6 +14,7 @@ Optional properties:
> >  
> >  - reg-io-width : Specify the size (in bytes) of the IO accesses that
> > should be performed on the device.  Valid value is 1, 2 or 4.
> > +   Must be set to 2 for technologic version.
> > Default to 1 (8 bits).
> 
> Really, this should default to 2 for technologic version and not be 
> required.

Would something along the line of "This property is 
for technologic version." be more appropriate?

Thanks,
Damien
--
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] switchdev: bridge: Pass ageing time as clock_t instead of jiffies

2015-12-21 Thread David Ahern

On 12/21/15 3:56 AM, Jiri Pirko wrote:

diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 5396ff08..12045de 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -39,7 +39,7 @@ void br_init_port(struct net_bridge_port *p)
struct switchdev_attr attr = {
.id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
.flags = SWITCHDEV_F_SKIP_EOPNOTSUPP | SWITCHDEV_F_DEFER,
-   .u.ageing_time = p->br->ageing_time,
+   .u.ageing_time = jiffies_to_clock_t(p->br->ageing_time),
};
int err;



ageing_time is a u32; clock_t is a long.
--
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] Adding Reset resume support for CDC-EEM driver.

2015-12-21 Thread Alan Stern
On Mon, 21 Dec 2015, Vikas Bansal wrote:

> Pre-Condition
> At the time of reset resume of a USB device, both self and bus powered 
> devices might go to a low power state or power off state depending on the 
> acceptable suspend time power of the system.
> In case the device experiences a power glitch or completely powers off during 
> suspend-resume, the device will lose its internal state and hence it'll again 
> need a set interface from class driver on reset resume operation.
> 
> Issue 
> So far our experiments were based on a USB gadget working on cdc_eem 
> protocol. 
> We have seen that device is unable to continue the packet transfer on bulk 
> endpoints after the reset resume operation.
> 
> Solution
> We have added a .reset_resume function for cdc_eem protocol which sends a set 
> interface command on the Control endpoint. And calls the existing 
> usbnet_resume thereafter

You know, the USB core already issues a Set-Interface request on the
control endpoint whenever a reset-resume occurs (unless the interface
was using altsetting 0 beforehand).  Issuing another Set-Interface
shouldn't make any difference.

Alan Stern

--
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: tcp: deal with listen sockets properly in tcp_abort.

2015-12-21 Thread Eric Dumazet
On Tue, 2015-12-22 at 00:03 +0900, Lorenzo Colitti wrote:
> When closing a listen socket, tcp_abort currently calls
> tcp_done without clearing the request queue. If the socket has a
> child socket that is established but not yet accepted, the child
> socket is then left without a parent, causing a leak.
> 
> Fix this by setting the socket state to TCP_CLOSE and calling
> inet_csk_listen_stop with the socket lock held, like tcp_close
> does.
> 
> Tested using net_test. With this patch, calling SOCK_DESTROY on a
> listen socket that has an established but not yet accepted child
> socket results in the parent and the child being closed, such
> that they no longer appear in sock_diag dumps.
> 
> Reported-by: Eric Dumazet 
> Signed-off-by: Lorenzo Colitti 
> ---

Acked-by: Eric Dumazet 

Thanks !


--
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 -next] tcp: honour SO_BINDTODEVICE for TW_RST case too

2015-12-21 Thread Florian Westphal
Hannes points out that when we generate tcp reset for timewait sockets we
pretend we found no socket and pass NULL sk to tcp_vX_send_reset().

Make it cope with inet tw sockets and then provide tw sk so RST appears on
correct interface.

Packetdrill test case:
// want default route to be used, we rely on BINDTODEVICE
`ip route del 192.0.2.0/24 via 192.168.0.2 dev tun0`

0.000 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
0.001 setsockopt(3, SOL_SOCKET, SO_BINDTODEVICE, "tun0", 4) = 0
0.100...0.200 connect(3, ..., ...) = 0

0.100 > S 0:0(0) 
0.200 < S. 0:0(0) ack 1 win 32792 
0.200 > . 1:1(0) ack 1

0.210 close(3) = 0

0.210 > F. 1:1(0) ack 1 win 29200
0.300 < . 1:1(0) ack 2 win 46

// more data while in FIN_WAIT2, expect RST
1.300 < P. 1:1001(1000) ack 1 win 46

// fails without this change -- default route is used
1.301 > R 1:1(0) win 0

Reported-by: Hannes Frederic Sowa 
Signed-off-by: Florian Westphal 
---
 net/ipv4/tcp_ipv4.c  | 31 ++-
 net/ipv4/tcp_minisocks.c |  7 ++-
 net/ipv6/tcp_ipv6.c  | 15 +++
 3 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 46e92fb..24ba2e1 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -587,13 +587,14 @@ static void tcp_v4_send_reset(const struct sock *sk, 
struct sk_buff *skb)
} rep;
struct ip_reply_arg arg;
 #ifdef CONFIG_TCP_MD5SIG
-   struct tcp_md5sig_key *key;
+   struct tcp_md5sig_key *key = NULL;
const __u8 *hash_location = NULL;
unsigned char newhash[16];
int genhash;
struct sock *sk1 = NULL;
 #endif
struct net *net;
+   bool have_full_sk;
 
/* Never send a reset in response to a reset. */
if (th->rst)
@@ -624,10 +625,14 @@ static void tcp_v4_send_reset(const struct sock *sk, 
struct sk_buff *skb)
arg.iov[0].iov_base = (unsigned char *)&rep;
arg.iov[0].iov_len  = sizeof(rep.th);
 
-   net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);
+   have_full_sk = sk && sk_fullsock(sk);
+   net = have_full_sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);
 #ifdef CONFIG_TCP_MD5SIG
hash_location = tcp_parse_md5sig_option(th);
-   if (!sk && hash_location) {
+   if (have_full_sk) {
+   key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
+   &ip_hdr(skb)->saddr, AF_INET);
+   } else if (hash_location) {
/*
 * active side is lost. Try to find listening socket through
 * source port, and then find md5 key through listening socket.
@@ -651,10 +656,6 @@ static void tcp_v4_send_reset(const struct sock *sk, 
struct sk_buff *skb)
genhash = tcp_v4_md5_hash_skb(newhash, key, NULL, skb);
if (genhash || memcmp(hash_location, newhash, 16) != 0)
goto release_sk1;
-   } else {
-   key = sk ? tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
-&ip_hdr(skb)->saddr,
-AF_INET) : NULL;
}
 
if (key) {
@@ -675,7 +676,14 @@ static void tcp_v4_send_reset(const struct sock *sk, 
struct sk_buff *skb)
  ip_hdr(skb)->saddr, /* XXX */
  arg.iov[0].iov_len, IPPROTO_TCP, 0);
arg.csumoffset = offsetof(struct tcphdr, check) / 2;
-   arg.flags = (sk && inet_sk(sk)->transparent) ? IP_REPLY_ARG_NOSRCCHECK 
: 0;
+   arg.flags = 0;
+   if (have_full_sk) {
+   if (inet_sk(sk)->transparent)
+   arg.flags = IP_REPLY_ARG_NOSRCCHECK;
+   } else if (sk && inet_twsk(sk)->tw_transparent) {
+   arg.flags = IP_REPLY_ARG_NOSRCCHECK;
+   }
+
/* When socket is gone, all binding information is lost.
 * routing might fail in this case. No choice here, if we choose to 
force
 * input interface, we will misroute in case of asymmetric route.
@@ -683,6 +691,9 @@ static void tcp_v4_send_reset(const struct sock *sk, struct 
sk_buff *skb)
if (sk)
arg.bound_dev_if = sk->sk_bound_dev_if;
 
+   BUILD_BUG_ON(offsetof(struct sock, sk_bound_dev_if) !=
+offsetof(struct inet_timewait_sock, tw_bound_dev_if));
+
arg.tos = ip_hdr(skb)->tos;
ip_send_unicast_reply(*this_cpu_ptr(net->ipv4.tcp_sk),
  skb, &TCP_SKB_CB(skb)->header.h4.opt,
@@ -1706,7 +1717,9 @@ do_time_wait:
tcp_v4_timewait_ack(sk, skb);
break;
case TCP_TW_RST:
-   goto no_tcp_socket;
+   tcp_v4_send_reset(sk, skb);
+   inet_twsk_deschedule_put(inet_twsk(sk));
+   goto discard_it;
case TCP_TW_SUCCESS:;
}
goto discard_it;
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index ac6b196..75632a9 1

RE: [RFC 5/5] i40e/ethtool: support coalesce setting by queue

2015-12-21 Thread Nelson, Shannon


> From: Liang, Kan
> Sent: Friday, December 18, 2015 1:06 PM
> 
> Hi sln,
> 
> Thanks for the comments. I will fix it in V2.
> 
> Could you please check if the following code can find and set/get vector
> correctly?
> 
> Get rx_usecs and tx_usecs per queue
> 
> + if (queue > 0) {
> + if (queue >= vsi->num_queue_pairs) {
> + netif_info(pf, drv, netdev, "Invalid queue number\n");

Adding queue range information here like in the next chunk would be nice.

Otherwise, I think the rest of this looks reasonable.

sln

--
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] wlcore: consolidate kmalloc + memset 0 into kzalloc

2015-12-21 Thread Nicholas Mc Guire
This is an API consolidation only. The use of kmalloc + memset to 0
is equivalent to kzalloc.

Signed-off-by: Nicholas Mc Guire 
---

Found by coccinelle script (relaxed version of
scripts/coccinelle/api/alloc/kzalloc-simple.cocci)

Patch was compile tested with: x86_64_defconfig +
CONFIG_WL12XX=m (implies CONFIG_WLCORE=m)

Patch is against linux-next (localversion-next is -next-20151221)

 drivers/net/wireless/ti/wlcore/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ti/wlcore/main.c 
b/drivers/net/wireless/ti/wlcore/main.c
index ec7f6af..dfc49bf 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -838,7 +838,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
 
wl1271_info("Reading FW panic log");
 
-   block = kmalloc(wl->fw_mem_block_size, GFP_KERNEL);
+   block = kzalloc(wl->fw_mem_block_size, GFP_KERNEL);
if (!block)
return;
 
@@ -885,7 +885,6 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
goto out;
}
 
-   memset(block, 0, wl->fw_mem_block_size);
ret = wlcore_read_hwaddr(wl, addr, block,
wl->fw_mem_block_size, false);
 
-- 
2.1.4

--
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] switchdev: bridge: Pass ageing time as clock_t instead of jiffies

2015-12-21 Thread Ido Schimmel
Mon, Dec 21, 2015 at 05:53:19PM IST, dsah...@gmail.com wrote:
>On 12/21/15 3:56 AM, Jiri Pirko wrote:
>> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
>> index 5396ff08..12045de 100644
>> --- a/net/bridge/br_stp_if.c
>> +++ b/net/bridge/br_stp_if.c
>> @@ -39,7 +39,7 @@ void br_init_port(struct net_bridge_port *p)
>>  struct switchdev_attr attr = {
>>  .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
>>  .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP | SWITCHDEV_F_DEFER,
>> -.u.ageing_time = p->br->ageing_time,
>> +.u.ageing_time = jiffies_to_clock_t(p->br->ageing_time),
>>  };
>>  int err;
>
>
>ageing_time is a u32; clock_t is a long.

Hi,

p->br->ageing_time is set in br_set_ageing_time, where it's converted to
jiffies from clock_t, that is treated as u32.
--
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 -next] tcp: honour SO_BINDTODEVICE for TW_RST case too

2015-12-21 Thread Eric Dumazet
On Mon, 2015-12-21 at 17:20 +0100, Florian Westphal wrote:
> Hannes points out that when we generate tcp reset for timewait sockets we
> pretend we found no socket and pass NULL sk to tcp_vX_send_reset().
> 
> Make it cope with inet tw sockets and then provide tw sk so RST appears on
> correct interface.
> 
> Packetdrill test case:
> // want default route to be used, we rely on BINDTODEVICE
> `ip route del 192.0.2.0/24 via 192.168.0.2 dev tun0`
> 
> 0.000 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
> 0.001 setsockopt(3, SOL_SOCKET, SO_BINDTODEVICE, "tun0", 4) = 0
> 0.100...0.200 connect(3, ..., ...) = 0
> 
> 0.100 > S 0:0(0) 
> 0.200 < S. 0:0(0) ack 1 win 32792 
> 0.200 > . 1:1(0) ack 1
> 
> 0.210 close(3) = 0
> 
> 0.210 > F. 1:1(0) ack 1 win 29200
> 0.300 < . 1:1(0) ack 2 win 46
> 
> // more data while in FIN_WAIT2, expect RST
> 1.300 < P. 1:1001(1000) ack 1 win 46
> 
> // fails without this change -- default route is used
> 1.301 > R 1:1(0) win 0
> 
> Reported-by: Hannes Frederic Sowa 
> Signed-off-by: Florian Westphal 
> ---
>  net/ipv4/tcp_ipv4.c  | 31 ++-
>  net/ipv4/tcp_minisocks.c |  7 ++-
>  net/ipv6/tcp_ipv6.c  | 15 +++
>  3 files changed, 35 insertions(+), 18 deletions(-)
> 
> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index 46e92fb..24ba2e1 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -587,13 +587,14 @@ static void tcp_v4_send_reset(const struct sock *sk, 
> struct sk_buff *skb)
>   } rep;
>   struct ip_reply_arg arg;
>  #ifdef CONFIG_TCP_MD5SIG
> - struct tcp_md5sig_key *key;
> + struct tcp_md5sig_key *key = NULL;
>   const __u8 *hash_location = NULL;
>   unsigned char newhash[16];
>   int genhash;
>   struct sock *sk1 = NULL;
>  #endif
>   struct net *net;
> + bool have_full_sk;
>  
>   /* Never send a reset in response to a reset. */
>   if (th->rst)
> @@ -624,10 +625,14 @@ static void tcp_v4_send_reset(const struct sock *sk, 
> struct sk_buff *skb)
>   arg.iov[0].iov_base = (unsigned char *)&rep;
>   arg.iov[0].iov_len  = sizeof(rep.th);
>  
> - net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);
> + have_full_sk = sk && sk_fullsock(sk);
> + net = have_full_sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);

But the net pointer can be derived from timewait the same, not sure why
you changed this part ... This makes your patch look more complicated
than what is needed.

>  #ifdef CONFIG_TCP_MD5SIG
>   hash_location = tcp_parse_md5sig_option(th);
> - if (!sk && hash_location) {
> + if (have_full_sk) {
> + key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
> + &ip_hdr(skb)->saddr, AF_INET);
> + } else if (hash_location) {
>   /*
>* active side is lost. Try to find listening socket through
>* source port, and then find md5 key through listening socket.
> @@ -651,10 +656,6 @@ static void tcp_v4_send_reset(const struct sock *sk, 
> struct sk_buff *skb)
>   genhash = tcp_v4_md5_hash_skb(newhash, key, NULL, skb);
>   if (genhash || memcmp(hash_location, newhash, 16) != 0)
>   goto release_sk1;
> - } else {
> - key = sk ? tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
> -  &ip_hdr(skb)->saddr,
> -  AF_INET) : NULL;
>   }
>  
>   if (key) {
> @@ -675,7 +676,14 @@ static void tcp_v4_send_reset(const struct sock *sk, 
> struct sk_buff *skb)
> ip_hdr(skb)->saddr, /* XXX */
> arg.iov[0].iov_len, IPPROTO_TCP, 0);
>   arg.csumoffset = offsetof(struct tcphdr, check) / 2;
> - arg.flags = (sk && inet_sk(sk)->transparent) ? IP_REPLY_ARG_NOSRCCHECK 
> : 0;
> + arg.flags = 0;
> + if (have_full_sk) {
> + if (inet_sk(sk)->transparent)
> + arg.flags = IP_REPLY_ARG_NOSRCCHECK;
> + } else if (sk && inet_twsk(sk)->tw_transparent) {
> + arg.flags = IP_REPLY_ARG_NOSRCCHECK;
> + }
> +

Maybe a helper to retrieve the transparant status from a generic socket
(being full, timewait or request sock) would help.

This could be submitted as a separate patch to ease review.


>   /* When socket is gone, all binding information is lost.
>* routing might fail in this case. No choice here, if we choose to 
> force
>* input interface, we will misroute in case of asymmetric route.
> @@ -683,6 +691,9 @@ static void tcp_v4_send_reset(const struct sock *sk, 
> struct sk_buff *skb)
>   if (sk)
>   arg.bound_dev_if = sk->sk_bound_dev_if;
>  
> + BUILD_BUG_ON(offsetof(struct sock, sk_bound_dev_if) !=
> +  offsetof(struct inet_timewait_sock, tw_bound_dev_if));
> +
>   arg.tos = ip_hdr(skb)->tos;
>   ip_send_unicast_reply(*this_cpu_ptr(net->i

[PATCH net-next v3] Driver for IBM System i/p VNIC protocol

2015-12-21 Thread Thomas Falcon
This is a new device driver for a high performance SR-IOV assisted virtual
network for IBM System p and IBM System i systems.  The SR-IOV VF will be
attached to the VIOS partition and mapped to the Linux client via the
hypervisor's VNIC protocol that this driver implements.

This driver is able to perform basic tx and rx, new features
and improvements will be added as they are being developed and tested.

Signed-off-by: Thomas Falcon 
Signed-off-by: John Allen 
---
v2: -Removed module parameters in response to David Miller's comments
-Updated Santiago Leon's email address
-Added common prefix to H_VIOCTL functions
-Removed code handling large packets since feature is untested/disabled
v3: -Variables reordered in "reverse christmas tree" style throughout
-Audited driver to use bool type for logically boolean variables
-In alloc_rx_pool, check for allocation failure immediately after
 allocation
-In ibmvnic_xmit, check skb->protocol value before dereferencing
 protocol header
-Remove unsupported MII read/write functions
-Remove redundant ibmvnic_get_stats function
-Cleanup in garbage collection in ibmvnic_open and ibmvnic_close
-Separate allocation of long term mapped buffers into new functions
-Updated ibmvnic.c file header to document unique driver features
---
 MAINTAINERS|7 +
 arch/powerpc/include/asm/hvcall.h  |   20 +
 drivers/net/ethernet/ibm/Kconfig   |   10 +
 drivers/net/ethernet/ibm/Makefile  |1 +
 drivers/net/ethernet/ibm/ibmvnic.c | 3585 
 drivers/net/ethernet/ibm/ibmvnic.h | 1046 +++
 6 files changed, 4669 insertions(+)
 create mode 100644 drivers/net/ethernet/ibm/ibmvnic.c
 create mode 100644 drivers/net/ethernet/ibm/ibmvnic.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 233f834..4f4bd40 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5283,6 +5283,13 @@ L:   netdev@vger.kernel.org
 S: Supported
 F: drivers/net/ethernet/ibm/ibmveth.*
 
+IBM Power SRIOV Virtual NIC Device Driver
+M: Thomas Falcon 
+M: John Allen 
+L: netdev@vger.kernel.org
+S: Supported
+F: drivers/net/ethernet/ibm/ibmvnic.*
+
 IBM Power Virtual SCSI Device Drivers
 M: Tyrel Datwyler 
 L: linux-s...@vger.kernel.org
diff --git a/arch/powerpc/include/asm/hvcall.h 
b/arch/powerpc/include/asm/hvcall.h
index 85bc8c0..e3b54dd 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -258,11 +258,16 @@
 #define H_DEL_CONN 0x288
 #define H_JOIN 0x298
 #define H_VASI_STATE0x2A4
+#define H_VIOCTL   0x2A8
 #define H_ENABLE_CRQ   0x2B0
 #define H_GET_EM_PARMS 0x2B8
 #define H_SET_MPP  0x2D0
 #define H_GET_MPP  0x2D4
+#define H_REG_SUB_CRQ  0x2DC
 #define H_HOME_NODE_ASSOCIATIVITY 0x2EC
+#define H_FREE_SUB_CRQ 0x2E0
+#define H_SEND_SUB_CRQ 0x2E4
+#define H_SEND_SUB_CRQ_INDIRECT0x2E8
 #define H_BEST_ENERGY  0x2F4
 #define H_XIRR_X   0x2FC
 #define H_RANDOM   0x300
@@ -271,6 +276,21 @@
 #define H_SET_MODE 0x31C
 #define MAX_HCALL_OPCODE   H_SET_MODE
 
+/* H_VIOCTL functions */
+#define H_GET_VIOA_DUMP_SIZE   0x01
+#define H_GET_VIOA_DUMP0x02
+#define H_GET_ILLAN_NUM_VLAN_IDS 0x03
+#define H_GET_ILLAN_VLAN_ID_LIST 0x04
+#define H_GET_ILLAN_SWITCH_ID  0x05
+#define H_DISABLE_MIGRATION0x06
+#define H_ENABLE_MIGRATION 0x07
+#define H_GET_PARTNER_INFO 0x08
+#define H_GET_PARTNER_WWPN_LIST0x09
+#define H_DISABLE_ALL_VIO_INTS 0x0A
+#define H_DISABLE_VIO_INTERRUPT0x0B
+#define H_ENABLE_VIO_INTERRUPT 0x0C
+
+
 /* Platform specific hcalls, used by KVM */
 #define H_RTAS 0xf000
 
diff --git a/drivers/net/ethernet/ibm/Kconfig b/drivers/net/ethernet/ibm/Kconfig
index 99c1ceb..37dceab 100644
--- a/drivers/net/ethernet/ibm/Kconfig
+++ b/drivers/net/ethernet/ibm/Kconfig
@@ -37,4 +37,14 @@ config EHEA
  To compile the driver as a module, choose M here. The module
  will be called ehea.
 
+config IBMVNIC
+   tristate "IBM Virtual NIC support"
+   depends on PPC_PSERIES
+   ---help---
+ This driver supports Virtual NIC adapters on IBM i and IBM System p
+ systems.
+
+ To compile this driver as a module, choose M here. The module will
+ be called ibmvnic.
+
 endif # NET_VENDOR_IBM
diff --git a/drivers/net/ethernet/ibm/Makefile 
b/drivers/net/ethernet/ibm/Makefile
index 2f04e71..447865c 100644
--- a/drivers/net/ethernet/ibm/Makefile
+++ b/drivers/net/ethernet/ibm/Makefile
@@ -3,5 +3,6 @@
 #
 
 obj-$(CONFIG_IBMVETH) += ibmveth.o
+obj-$(CONFIG_IBMVNIC) += ibmvnic.o
 obj-$(CONFIG_IBM_EMAC) += emac/
 obj-$(CONFIG_EHEA) += ehea/
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
b/drivers/net/ethernet/ibm/ibmvnic.c
new file mode 100644
index 000..7d657084
--- /dev/null
+++ b/drivers/n

TUN works when SRC != own IP

2015-12-21 Thread Karl Krach

Hello,

I have to forward IP-packets from an FPGA via network. For this I use 
packet_mmap / PACKET_TX_RING for destinations within the ARP cache and 
the TUN interface for all others (incl. packets to my own device).


When I send these foreign packets (ip4h->saddr != device address) via 
TUN device, they are forwarded to the appropriate interface eth1 
correctly. But when I want to send packets from the own device 
(ip4h->saddr == device address) they get lost between tunX and ethX.


I use the following to setup the system (Linux 4.0.0, PowerPC TQMP2020):

# openvpn --mktun --dev tun16
# ip link set tun16 up
# ip rule add iif tun16 table 50
# ip route add 0/0 dev eth1 table 50

and this program (https://github.com/kkrach/tuncom) to test the data 
transfer over TUN. When I use "1.1.1.1" as source address, everything 
works fine. But when I use the device's IP (192.168.32.60) the packets 
can be seen on the TUN interface (tcpdump -i tun16) but not on the 
network interface (tcpdump -i eth1).


Can't I use TUN for this purpose - or is my setup somehow wrong?





I ve figured out, that when I remove the rule "local 192.168.32.60 dev 
eth1 proto kernel scope host src 192.168.32.60" from the table "local" 
all packets (also those with the correct SRC address) are sent correctly 
- but then the device stops to receive any.


Could the problem be somewhere in my (local) rules?


# ip route show table local
broadcast 127.0.0.0 dev lo proto kernel  scope link  src 127.0.0.1
local 127.0.0.0/8 dev lo proto kernel  scope host  src 127.0.0.1
local 127.0.0.1 dev lo proto kernel  scope host  src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link  src 127.0.0.1
broadcast 172.16.10.0 dev eth0 proto kernel scope link src 172.16.10.12
local 172.16.10.12 dev eth0 proto kernel scope host  src 172.16.10.12
broadcast 172.16.11.255 dev eth0 proto kernel scope link src 172.16.10.12
broadcast 192.168.32.0 dev eth1 proto kernel scope link src 192.168.32.60
local 192.168.32.60 dev eth1 proto kernel scope host  src 192.168.32.60
broadcast 192.168.32.255 dev eth1  proto kernel scope link  src 
192.168.32.60

#

Best regards,
Karl Krach
--
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: Does the Community use Coverity ?

2015-12-21 Thread Jeff Haran
> -Original Message-
> From: pavi1729 [mailto:pavitra1...@gmail.com]
> Sent: Thursday, December 17, 2015 2:04 AM
> To: Jeff Haran
> Cc: kernelnewb...@kernelnewbies.org; linux-fsde...@vger.kernel.org;
> linux-...@vger.kernel.org; netdev@vger.kernel.org
> Subject: Re: Does the Community use Coverity ?
> 
> Sanket, Jeff,
> Thanks a ton, that was helpful.
> 
> Cheers,
> Pavi

Pavi,

I suggest that if you get the chance, check out their code browser. Click on 
one of the bugs in the Linux project and then click the folder icon at the top 
of the lower left pane to get to the source code. It's ability to cross 
reference is the best out there. It eliminates all the false positives in cross 
reference results that you get from more traditional token matching based 
browsers like cscope, ctags, etc.

Jeff Haran
 
> On Wed, Dec 16, 2015 at 12:32 AM, Jeff Haran 
> wrote:
> >>-Original Message-
> >>From: kernelnewbies-
> bounces+jharan=bytemobile@kernelnewbies.org
> >>[mailto:kernelnewbies-
> >>bounces+jharan=bytemobile@kernelnewbies.org] On Behalf Of
> >>pavi1729
> >>Sent: Monday, December 14, 2015 11:03 PM
> >>To: kernelnewb...@kernelnewbies.org; linux-fsde...@vger.kernel.org;
> >>linux- m...@vger.kernel.org; linux-net...@vger.kernel.org
> >>Subject: Does the Community use Coverity ?
> >>
> >>Hi,
> >>  May I know if the community uses the Coverity tool and, if yes where
> >>can I find a repo of Coverity scans of kernels and IGNORE LIST; cause
> >>there obviously would be false positives.
> >>
> >>Cheers,
> >>Pavi
> >
> > https://scan.coverity.com/
> >
> > Sign up for an account and join the Linux project.
> >
> > Jeff Haran
> >


Re: [PATCH net-next V2 3/4] net/mlx5e: Add HW timestamping (TS) support

2015-12-21 Thread Richard Cochran
On Mon, Dec 21, 2015 at 04:35:23PM +0200, Saeed Mahameed wrote:
> think of a case where:
> CPU1: is just about to call
> "schedule_delayed_work(&tstamp->overflow_work,
> tstamp->overflow_period);"
> CPU2: cancel_delayed_work
> 
> In this case cancel_dalyed_work_sync (CPU2) will wait for CPU1 to
> complete but CPU1 will re-arm the work, and we will
> be left with tstamp->overflow_work running forever.

This is my understanding:  Once the work becomes re-queued, it will be
canceled before running again.

Thanks,
Richard

--
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 -next] tcp: honour SO_BINDTODEVICE for TW_RST case too

2015-12-21 Thread Florian Westphal
Eric Dumazet  wrote:
> > -   net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);
> > +   have_full_sk = sk && sk_fullsock(sk);
> > +   net = have_full_sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);
> 
> But the net pointer can be derived from timewait the same, not sure why
> you changed this part ... This makes your patch look more complicated
> than what is needed.

Duh, you're right -- I'll send a V2.

> >  #ifdef CONFIG_TCP_MD5SIG
> > hash_location = tcp_parse_md5sig_option(th);
> > -   if (!sk && hash_location) {
> > +   if (have_full_sk) {
> > +   key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
> > +   &ip_hdr(skb)->saddr, AF_INET);
> > +   } else if (hash_location) {
> > /*
> >  * active side is lost. Try to find listening socket through
> >  * source port, and then find md5 key through listening socket.
> > @@ -651,10 +656,6 @@ static void tcp_v4_send_reset(const struct sock *sk, 
> > struct sk_buff *skb)
> > genhash = tcp_v4_md5_hash_skb(newhash, key, NULL, skb);
> > if (genhash || memcmp(hash_location, newhash, 16) != 0)
> > goto release_sk1;
> > -   } else {
> > -   key = sk ? tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
> > -&ip_hdr(skb)->saddr,
> > -AF_INET) : NULL;
> > }
> >  
> > if (key) {
> > @@ -675,7 +676,14 @@ static void tcp_v4_send_reset(const struct sock *sk, 
> > struct sk_buff *skb)
> >   ip_hdr(skb)->saddr, /* XXX */
> >   arg.iov[0].iov_len, IPPROTO_TCP, 0);
> > arg.csumoffset = offsetof(struct tcphdr, check) / 2;
> > -   arg.flags = (sk && inet_sk(sk)->transparent) ? IP_REPLY_ARG_NOSRCCHECK 
> > : 0;
> > +   arg.flags = 0;
> > +   if (have_full_sk) {
> > +   if (inet_sk(sk)->transparent)
> > +   arg.flags = IP_REPLY_ARG_NOSRCCHECK;
> > +   } else if (sk && inet_twsk(sk)->tw_transparent) {
> > +   arg.flags = IP_REPLY_ARG_NOSRCCHECK;
> > +   }
> > +
> 
> Maybe a helper to retrieve the transparant status from a generic socket
> (being full, timewait or request sock) would help.
> 
> This could be submitted as a separate patch to ease review.

Makes sense, will do this.

> > oif = sk ? sk->sk_bound_dev_if : 0;
> > +   if (!have_full_sk)
> > +   sk = NULL;
> > +
> 
> I have no idea why you need to set sk to NULL here.

Its a followup error.  As sock_net(twsk) is fine this isn't
needed either and I'll remove this part.

> I found this hard to review...

Apologies.  Thanks for reviewing despite this, I will try
to address all of your comments.

> It seems you have multiple logical changes ?

> Splitting into at least 2 patches would be nice.

will do,

Thanks Eric.
--
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] addrconf: always initialize sysctl table data

2015-12-21 Thread Cong Wang
When sysctl performs restrict writes, it allows to write from
a middle position of a sysctl file, which requires us to initialize
the table data before calling proc_dostring() for the write case.

Fixes: 3d1bec99320d ("ipv6: introduce secret_stable to ipv6_devconf")
Reported-by: Sasha Levin 
Acked-by: Hannes Frederic Sowa 
Tested-by: Sasha Levin 
Signed-off-by: Cong Wang 
---
 net/ipv6/addrconf.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 17f8e7e..1f21087 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5369,13 +5369,10 @@ static int addrconf_sysctl_stable_secret(struct 
ctl_table *ctl, int write,
goto out;
}
 
-   if (!write) {
-   err = snprintf(str, sizeof(str), "%pI6",
-  &secret->secret);
-   if (err >= sizeof(str)) {
-   err = -EIO;
-   goto out;
-   }
+   err = snprintf(str, sizeof(str), "%pI6", &secret->secret);
+   if (err >= sizeof(str)) {
+   err = -EIO;
+   goto out;
}
 
err = proc_dostring(&lctl, write, buffer, lenp, ppos);
-- 
1.8.3.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: [PATCH] ath6kl: Use vmalloc to allocate ar->fw for api1 method

2015-12-21 Thread Souptick Joarder
Hi Brent,

On Tue, Dec 1, 2015 at 11:11 AM, Brent Taylor  wrote:
> Since commit 8437754c83351d6213c1a47ff029c1126d6042a7, ar->fw is expected to 
> be pointing to memory allocated by vmalloc.  If the api1 method (via 
> ath6kl_fetch_fw_api1) is used to allocate memory for ar->fw, then kmemdup is 
> used.  This patch checks if the firmware being loaded is the 'fw' image, then 
> use vmalloc, otherwise use kmalloc.
>
> Signed-off-by: Brent Taylor 
> ---
>  drivers/net/wireless/ath/ath6kl/init.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
> b/drivers/net/wireless/ath/ath6kl/init.c
> index 6ae0734..4f2b124d 100644
> --- a/drivers/net/wireless/ath/ath6kl/init.c
> +++ b/drivers/net/wireless/ath/ath6kl/init.c
> @@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char 
> *filename,
> return ret;
>
> *fw_len = fw_entry->size;
> -   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
> +   if (&ar->fw == fw)
> +   *fw = vmalloc(fw_entry->size);
> +   else
> +   *fw = kmalloc(fw_entry->size, GFP_KERNEL);

  Why vmalloc and kmalloc both are required? can't use either
vmalloc or kmalloc?
>
> if (*fw == NULL)
> ret = -ENOMEM;
> +   else
> +   memcpy(*fw, fw_entry->data, fw_entry->size);
>
> release_firmware(fw_entry);
>
> --
> 2.6.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-Souptick
--
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: [iproute PATCH v2] ip{,6}tunnel: have a shared stats parser/printer

2015-12-21 Thread Phil Sutter
On Mon, Dec 21, 2015 at 12:00:06PM +0100, Daniel Borkmann wrote:
> On 12/18/2015 11:58 AM, Phil Sutter wrote:
> > This has a slight side-effect of not aborting when /proc/net/dev is
> > malformed, but OTOH stats are not parsed for uninteresting interfaces.
> >
> > Signed-off-by: Phil Sutter 
> > ---
> > Changes since v1:
> > - Fix conflict resolution (sscan from 'buf' instead of 'ptr').
> [...]
> 
> Hmm, did you actually compile that?
> 
> The code is still the same as in v1 ... the only thing added is the "Changes 
> since v1"
> description. ;)

Oh man. I certainly double-checked it, especially since I messed it up
the first time already. Quick forensics in my local clone revealed what
had happened:

1) Exported the V2 patch into a dedicated patch subdir.
2) ???
3) Edited the V1 patch in $TOPDIR and sent that out.

Face -> Desk.

Fix follows. :(

Thanks for reporting,

Phil
--
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] ipv6/addrlabel: fix ip6addrlbl_get()

2015-12-21 Thread Cong Wang
On Mon, Dec 21, 2015 at 1:54 AM, Andrey Ryabinin
 wrote:
> ip6addrlbl_get() has never worked. If ip6addrlbl_hold() succeeded,
> ip6addrlbl_get() will exit with '-ESRCH'. If ip6addrlbl_hold() failed,
> ip6addrlbl_get() will use about to be free ip6addrlbl_entry pointer.
>
> Fix this by inverting ip6addrlbl_hold() check.
>
> Fixes: 2a8cc6c89039 ("[IPV6] ADDRCONF: Support RFC3484 configurable address 
> selection policy table.")
> Signed-off-by: Andrey Ryabinin 

Good catch!

Reviewed-by: Cong Wang 
--
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


[iproute PATCH] iptunnel: Fix compile error in ip/tunnel.c

2015-12-21 Thread Phil Sutter
I repeatedly failed to get this right, so now I have to clean up my mess
afterwards.

Fixes: 7d6aadcd0a1dc ("ip{,6}tunnel: have a shared stats parser/printer")
Signed-off-by: Phil Sutter 
---
 ip/tunnel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/tunnel.c b/ip/tunnel.c
index 1dd8092..39f825b 100644
--- a/ip/tunnel.c
+++ b/ip/tunnel.c
@@ -208,7 +208,7 @@ void tnl_print_stats(const char *buf)
  tx_bytes, tx_packets, tx_errs, tx_drops,
  tx_fifo, tx_colls, tx_carrier, rx_multi;
 
-   if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
+   if (sscanf(buf, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
   &rx_bytes, &rx_packets, &rx_errs, &rx_drops,
   &rx_fifo, &rx_frame, &rx_multi,
   &tx_bytes, &tx_packets, &tx_errs, &tx_drops,
-- 
2.5.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


Re: Commit-8b63ec18 breaks setting PHY pad-skew settings

2015-12-21 Thread Florian Fainelli
On 21/12/15 02:40, Roosen Henri wrote:
> Hi David,
> 
> Unfortunately Linux kernel commit-8b63ec1837fa4c1ea604b278d201454eb3b85066 
> breaks setting pad-skew settings for Micrel PHY's.
> 
> Please see Documentation/devicetree/bindings/net/micrel-ksz90x1.txt: at the 
> examples, it proposes to do PHY pad skew settings at the Ethernet device for 
> autodetected PHY's.
> 
> Multiple boards are using this at the devicetree files: see 
> imx6qdl-nitrogen6x.dtsi, imx6qdl-sabrelite.dtsi, socfpga_arria5_socdk.dts, 
> socfpga_cyclone5_socdk.dts and socfpga_cyclone5_sockit.dts. But of course 
> there might be more users depending on this than the ones which have an 
> in-kernel dts file.
> 
> The micrel.c file searches for the parent of its OpenFirmware node for the 
> skew settings: see ksz9031_config_init(): of_node = dev->parent->of_node; I 
> don't think that was a clean implementation to start with.. But for sure it's 
> incompatible with commit-8b63ec18, because the node of the Ethernet device 
> which has the settings is not found anymore.
> 
> I'm not sure who to put on the copy list to discuss a proper solution, so 
> feel free to get these persons and lists in the loop.

Usually, the best thing is to reply on the mailing-list directive, so
more people can jump in.

This particular issue is fixed with the following commit:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=651df2183543bc92f5dbcf99cd9e236ead0bc4c5
-- 
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


RE: [RFC 1/5] net/ethtool: introduce a new ioctl for per queue setting

2015-12-21 Thread Liang, Kan


> > +#define MAX_QUEUE  4096
> > +#define MAX_QUEUE_MASK (MAX_QUEUE / 64)
> > +
> > +/**
> > + * struct ethtool_per_queue_op - apply sub command to the queues in
> mask.
> > + * @cmd: ETHTOOL_PERQUEUE
> > + * @queue_mask: Mask the queues which sub command apply to
> > + * @sub_command: the sub command
> > + * @data: parameters of the command
> > + */
> > +struct ethtool_per_queue_op {
> > +   __u32   cmd;
> > +   __u64   queue_mask[MAX_QUEUE_MASK];
> > +   __u32   sub_command;
> 
> This leaves a hole in the structure on i386, which would then require
> conversion in the compat ioctl implementation.  I suggest you move the
> sub_command next to cmd.

OK. I will modify it in V2.

> 
> > +   chardata[];
> > +};
> >
> >  /* CMDs currently supported */
> >  #define ETHTOOL_GSET   0x0001 /* Get settings. */
> > @@ -1226,6 +1242,8 @@ enum ethtool_sfeatures_retval_bits {
> >  #define ETHTOOL_GTUNABLE   0x0048 /* Get tunable
> configuration */
> >  #define ETHTOOL_STUNABLE   0x0049 /* Set tunable
> configuration */
> >
> > +#define ETHTOOL_PERQUEUE   0x004a /* Set per queue
> options */
> 
> But it will actually be used for both set and get, right?

Right.

> 
> > +
> >  /* compatibility with older code */
> >  #define SPARC_ETH_GSET ETHTOOL_GSET
> >  #define SPARC_ETH_SSET ETHTOOL_SSET
> > diff --git a/net/core/ethtool.c b/net/core/ethtool.c index
> > 29edf74..125fb32 100644
> > --- a/net/core/ethtool.c
> > +++ b/net/core/ethtool.c
> > @@ -1748,6 +1748,20 @@ out:
> >     return ret;
> >  }
> >
> > +static int ethtool_set_per_queue(struct net_device *dev, void __user
> > +*useraddr) {
> > +   struct ethtool_per_queue_op per_queue_opt;
> > +
> > +   if (copy_from_user(&per_queue_opt, useraddr,
> sizeof(per_queue_opt)))
> > +   return -EFAULT;
> > +
> > +   switch (per_queue_opt.sub_command) {
> > +
> > +   default:
> > +   return -EOPNOTSUPP;
> > +   };
> > +}
> > +
> >  /* The main entry point in this file.  Called from
> > net/core/dev_ioctl.c */
> >
> >  int dev_ethtool(struct net *net, struct ifreq *ifr) @@ -1991,6
> > +2005,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
> >     case ETHTOOL_STUNABLE:
> >     rc = ethtool_set_tunable(dev, useraddr);
> >     break;
> > +   case ETHTOOL_PERQUEUE:
> > +   rc = ethtool_set_per_queue(dev, useraddr);
> > +   break;
> >     default:
> >     rc = -EOPNOTSUPP;
> >     }
> 
> I think the first switch statement to determine whether the command
> requires CAP_NET_ADMIN should also handle ETHTOOL_PERQUEUE,
> checking the sub-command number.
>

OK. I will add it in V2. Only 'get' can be done by anyone.

Thanks,
Kan

 


RE: [RFC 2/5] net/ethtool: support get coalesce per queue

2015-12-21 Thread Liang, Kan


> On Thu, 2015-12-17 at 06:51 +, kan.li...@intel.com wrote:
> > From: Kan Liang 
> >
> > Device driver has to provide an interface to get per queue coalesce.
> > The interrupt coalescing parameters of each masked queue will be
> > copied back to user space one by one.
> >
> > Signed-off-by: Kan Liang 
> > ---
> >  include/linux/ethtool.h |  5 -
> >  net/core/ethtool.c  | 33 -
> >  2 files changed, 36 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index
> > 653dc9c..107f75f 100644
> > --- a/include/linux/ethtool.h
> > +++ b/include/linux/ethtool.h
> > @@ -201,6 +201,8 @@ static inline u32 ethtool_rxfh_indir_default(u32
> > index, u32 n_rx_rings)
> >   * @get_module_eeprom: Get the eeprom information from the plug-in
> > module
> >   * @get_eee: Get Energy-Efficient (EEE) supported and status.
> >   * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
> > + * @get_per_queue_coalesce: Get interrupt coalescing parameters per
> queue.
> > + * Returns a negative error code or zero.
> 
> Is the ethtool core or the driver responsible for range-checking the queue
> number?
> 
> What is reported if the queue number is in range for RX queues but not for
> TX queues (or vice versa)?
> 
The driver should do the range-checking.
I think it's also driver to determine which should be reported
in tx_coalesce_usecs, if RX in range but TX not. Maybe ~0 is a good return
for tx_coalesce_usecs.


> >   *
> >   * All operations are optional (i.e. the function pointer may be set
> >   * to %NULL) and callers must take this into account.  Callers must
> > @@ -279,7 +281,8 @@ struct ethtool_ops {
> >        const struct ethtool_tunable *, void *);
> >     int (*set_tunable)(struct net_device *,
> >        const struct ethtool_tunable *, const void *);
> > -
> > +   int (*get_per_queue_coalesce)(struct net_device *, int,
> > +     struct ethtool_coalesce *);
> >
> >  };
> >  #endif /* _LINUX_ETHTOOL_H */
> > diff --git a/net/core/ethtool.c b/net/core/ethtool.c index
> > 125fb32..22ff69a 100644
> > --- a/net/core/ethtool.c
> > +++ b/net/core/ethtool.c
> > @@ -1748,6 +1748,36 @@ out:
> >     return ret;
> >  }
> >
> > +static int ethtool_get_per_queue_coalesce(struct net_device *dev,
> > +     void __user *useraddr,
> > +     struct ethtool_per_queue_op
> *per_queue_opt) {
> > +   u64 queue_mask;
> > +   int bit, i, ret;
> > +
> > +   if (!dev->ethtool_ops->get_per_queue_coalesce)
> > +   return -EOPNOTSUPP;
> > +
> > +   useraddr += sizeof(*per_queue_opt);
> > +   for (i = 0; i < MAX_QUEUE_MASK; i++) {
> > +   queue_mask = per_queue_opt->queue_mask[i];
> > +   if (queue_mask > 0) {
> > +   for_each_set_bit(bit, (unsigned long
> *)&queue_mask, 64) {
> [...]
> 
> This assumes a little-endian system.
> 
> You should probably build on top of David Decotigny's recent patch series
> that adds conversion of u32-based bitmaps to kernel bitmaps.
> 
Thanks for pointing me to the patch.
I will change the code based on his patch.

Thanks,
Kan



RE: [RFC 3/5] net/ethtool: support set coalesce per queue

2015-12-21 Thread Liang, Kan


> On Thu, 2015-12-17 at 06:51 +, kan.li...@intel.com wrote:
> [...]
> > --- a/net/core/ethtool.c
> > +++ b/net/core/ethtool.c
> > @@ -1778,6 +1778,37 @@ static int
> ethtool_get_per_queue_coalesce(struct net_device *dev,
> >     return 0;
> >  }
> >
> > +static int ethtool_set_per_queue_coalesce(struct net_device *dev,
> > +     void __user *useraddr,
> > +     struct ethtool_per_queue_op
> *per_queue_opt) {
> > +   u64 queue_mask;
> > +   int bit, i, ret;
> > +
> > +   if (!dev->ethtool_ops->set_per_queue_coalesce)
> > +   return -EOPNOTSUPP;
> > +
> > +   useraddr += sizeof(*per_queue_opt);
> > +   for (i = 0; i < MAX_QUEUE_MASK; i++) {
> > +   queue_mask = per_queue_opt->queue_mask[i];
> > +   if (queue_mask > 0) {
> > +   for_each_set_bit(bit, (unsigned long
> *)&queue_mask, 64) {
> > +   struct ethtool_coalesce coalesce;
> > +
> > +   if (copy_from_user(&coalesce, useraddr,
> sizeof(coalesce)))
> > +   return -EFAULT;
> > +
> > +   ret = dev->ethtool_ops-
> >set_per_queue_coalesce(dev, bit + i * 64, &coalesce);
> > +   if (ret != 0)
> > +   return ret;
> [...]
> 
> So there's no attempt to roll back on failure?
> 
No, ethtool core doesn’t save the old value for this version. So it's hard to
Rollback.
If we want this feature, the kernel will alloc a chunk of memory to store
coalesce value for masked queues. Is it OK?

> Then, what is the benefit of doing this iteration in the kernel rather than
> userland?
> 
It should save many ioctls.

Thanks,
Kan



[REGRESSION] tcp/ipv4: kernel panic because of (possible) division by zero

2015-12-21 Thread Oleksandr Natalenko
Commit 3759824da87b30ce7a35b4873b62b0ba38905ef5 (tcp: PRR uses CRB mode by 
default and SS mode conditionally) introduced changes to net/ipv4/tcp_input.c 
tcp_cwnd_reduction() that, possibly, cause division by zero, and therefore, 
kernel panic in interrupt handler [1].

Reverting 3759824da87b30ce7a35b4873b62b0ba38905ef5 seems to fix the issue.

I'm able to reproduce the issue on 4.3.0–4.3.3 once per several day 
(occasionally).

What could be done to help in debugging this issue?

Regards,
  Oleksandr.

[1] http://i.piccy.info/
i9/6f5cb187c4ff282d189f78c63f95af43/1450729403/283985/951663/panic.jpg
--
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 v2 -next 0/3] tcp: honour SO_BINDTODEVICE for TW_RST case too

2015-12-21 Thread Florian Westphal
This is V2, this time as a small series since I followed Erics advice
to split this into smaller chunks, I hope this makes it easier to
review.

First patch adds inet_sk_transparent helper.
Second patch contains an if/else swap that I split from the
original TW_RST v1 one.
Third patch is the actual change without the superfluous sock_net change.

Thanks,
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 -next 1/3] net: add inet_sk_transparent() helper

2015-12-21 Thread Florian Westphal
Avoids cluttering tcp_v4_send_reset when followup patch extends
it to deal with timewait sockets.

Suggested-by: Eric Dumazet 
Signed-off-by: Florian Westphal 
---
 include/net/request_sock.h |  2 +-
 include/net/tcp.h  | 12 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index a0dde04..f49759d 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -68,7 +68,7 @@ struct request_sock {
u32 peer_secid;
 };
 
-static inline struct request_sock *inet_reqsk(struct sock *sk)
+static inline struct request_sock *inet_reqsk(const struct sock *sk)
 {
return (struct request_sock *)sk;
 }
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3077735b..f33fecf 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1620,6 +1620,18 @@ static inline void tcp_highest_sack_combine(struct sock 
*sk,
tcp_sk(sk)->highest_sack = new;
 }
 
+/* This helper checks if socket has IP_TRANSPARENT set */
+static inline bool inet_sk_transparent(const struct sock *sk)
+{
+   switch (sk->sk_state) {
+   case TCP_TIME_WAIT:
+   return inet_twsk(sk)->tw_transparent;
+   case TCP_NEW_SYN_RECV:
+   return inet_rsk(inet_reqsk(sk))->no_srccheck;
+   }
+   return inet_sk(sk)->transparent;
+}
+
 /* Determines whether this is a thin stream (which may suffer from
  * increased latency). Used to trigger latency-reducing mechanisms.
  */
-- 
2.4.10

--
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 -next 2/3] tcp: send_reset: test for non-NULL sk first

2015-12-21 Thread Florian Westphal
tcp_md5_do_lookup requires a full socket, so once we extend
_send_reset() to also accept timewait socket we would have to change

if (!sk && hash_location)

to something like

if ((!sk || !sk_fullsock(sk)) && hash_location) {
  ...
} else {
  (sk && sk_fullsock(sk)) tcp_md5_do_lookup()
}

Switch the two branches: check if we have a socket first, then
fall back to a listener lookup if we saw a md5 option (hash_location).

Signed-off-by: Florian Westphal 
---
 net/ipv4/tcp_ipv4.c | 11 +--
 net/ipv6/tcp_ipv6.c |  6 +++---
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 46e92fb..eb29c2f 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -587,7 +587,7 @@ static void tcp_v4_send_reset(const struct sock *sk, struct 
sk_buff *skb)
} rep;
struct ip_reply_arg arg;
 #ifdef CONFIG_TCP_MD5SIG
-   struct tcp_md5sig_key *key;
+   struct tcp_md5sig_key *key = NULL;
const __u8 *hash_location = NULL;
unsigned char newhash[16];
int genhash;
@@ -627,7 +627,10 @@ static void tcp_v4_send_reset(const struct sock *sk, 
struct sk_buff *skb)
net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);
 #ifdef CONFIG_TCP_MD5SIG
hash_location = tcp_parse_md5sig_option(th);
-   if (!sk && hash_location) {
+   if (sk) {
+   key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
+   &ip_hdr(skb)->saddr, AF_INET);
+   } else if (hash_location) {
/*
 * active side is lost. Try to find listening socket through
 * source port, and then find md5 key through listening socket.
@@ -651,10 +654,6 @@ static void tcp_v4_send_reset(const struct sock *sk, 
struct sk_buff *skb)
genhash = tcp_v4_md5_hash_skb(newhash, key, NULL, skb);
if (genhash || memcmp(hash_location, newhash, 16) != 0)
goto release_sk1;
-   } else {
-   key = sk ? tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
-&ip_hdr(skb)->saddr,
-AF_INET) : NULL;
}
 
if (key) {
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index f03d2b0..32fa0de 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -854,7 +854,9 @@ static void tcp_v6_send_reset(const struct sock *sk, struct 
sk_buff *skb)
 
 #ifdef CONFIG_TCP_MD5SIG
hash_location = tcp_parse_md5sig_option(th);
-   if (!sk && hash_location) {
+   if (sk) {
+   key = tcp_v6_md5_do_lookup(sk, &ipv6h->saddr);
+   } else if (hash_location) {
/*
 * active side is lost. Try to find listening socket through
 * source port, and then find md5 key through listening socket.
@@ -877,8 +879,6 @@ static void tcp_v6_send_reset(const struct sock *sk, struct 
sk_buff *skb)
genhash = tcp_v6_md5_hash_skb(newhash, key, NULL, skb);
if (genhash || memcmp(hash_location, newhash, 16) != 0)
goto release_sk1;
-   } else {
-   key = sk ? tcp_v6_md5_do_lookup(sk, &ipv6h->saddr) : NULL;
}
 #endif
 
-- 
2.4.10

--
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 v2 -next 3/3] tcp: honour SO_BINDTODEVICE for TW_RST case too

2015-12-21 Thread Florian Westphal
Hannes points out that when we generate tcp reset for timewait sockets we
pretend we found no socket and pass NULL sk to tcp_vX_send_reset().

Make it cope with inet tw sockets and then provide tw sk.

This makes RSTs appear on correct interface when SO_BINDTODEVICE is used.

Packetdrill test case:
// want default route to be used, we rely on BINDTODEVICE
`ip route del 192.0.2.0/24 via 192.168.0.2 dev tun0`

0.000 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
// test case still works due to BINDTODEVICE
0.001 setsockopt(3, SOL_SOCKET, SO_BINDTODEVICE, "tun0", 4) = 0
0.100...0.200 connect(3, ..., ...) = 0

0.100 > S 0:0(0) 
0.200 < S. 0:0(0) ack 1 win 32792 
0.200 > . 1:1(0) ack 1

0.210 close(3) = 0

0.210 > F. 1:1(0) ack 1 win 29200
0.300 < . 1:1(0) ack 2 win 46

// more data while in FIN_WAIT2, expect RST
1.300 < P. 1:1001(1000) ack 1 win 46

// fails without this change -- default route is used
1.301 > R 1:1(0) win 0

Reported-by: Hannes Frederic Sowa 
Signed-off-by: Florian Westphal 
---
 Changes since v1:
 follow all of Erics suggestions, namely:
  - drop unneeded special-casing of sock_net(), it handles TW sk just fine
  - use new inet_sk_transparent() helper to reduce clutter
  - tcp_v6_send_response also handles TW sockets, no need to set
  TW sk to NULL
  - split if/else md5 change to extra patch

 net/ipv4/tcp_ipv4.c  | 12 +---
 net/ipv4/tcp_minisocks.c |  7 ++-
 net/ipv6/tcp_ipv6.c  |  6 --
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index eb29c2f..fc4f726 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -627,7 +627,7 @@ static void tcp_v4_send_reset(const struct sock *sk, struct 
sk_buff *skb)
net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);
 #ifdef CONFIG_TCP_MD5SIG
hash_location = tcp_parse_md5sig_option(th);
-   if (sk) {
+   if (sk && sk_fullsock(sk)) {
key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
&ip_hdr(skb)->saddr, AF_INET);
} else if (hash_location) {
@@ -674,7 +674,8 @@ static void tcp_v4_send_reset(const struct sock *sk, struct 
sk_buff *skb)
  ip_hdr(skb)->saddr, /* XXX */
  arg.iov[0].iov_len, IPPROTO_TCP, 0);
arg.csumoffset = offsetof(struct tcphdr, check) / 2;
-   arg.flags = (sk && inet_sk(sk)->transparent) ? IP_REPLY_ARG_NOSRCCHECK 
: 0;
+   arg.flags = (sk && inet_sk_transparent(sk)) ? IP_REPLY_ARG_NOSRCCHECK : 
0;
+
/* When socket is gone, all binding information is lost.
 * routing might fail in this case. No choice here, if we choose to 
force
 * input interface, we will misroute in case of asymmetric route.
@@ -682,6 +683,9 @@ static void tcp_v4_send_reset(const struct sock *sk, struct 
sk_buff *skb)
if (sk)
arg.bound_dev_if = sk->sk_bound_dev_if;
 
+   BUILD_BUG_ON(offsetof(struct sock, sk_bound_dev_if) !=
+offsetof(struct inet_timewait_sock, tw_bound_dev_if));
+
arg.tos = ip_hdr(skb)->tos;
ip_send_unicast_reply(*this_cpu_ptr(net->ipv4.tcp_sk),
  skb, &TCP_SKB_CB(skb)->header.h4.opt,
@@ -1705,7 +1709,9 @@ do_time_wait:
tcp_v4_timewait_ack(sk, skb);
break;
case TCP_TW_RST:
-   goto no_tcp_socket;
+   tcp_v4_send_reset(sk, skb);
+   inet_twsk_deschedule_put(inet_twsk(sk));
+   goto discard_it;
case TCP_TW_SUCCESS:;
}
goto discard_it;
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index ac6b196..75632a9 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -131,7 +131,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, 
struct sk_buff *skb,
goto kill;
 
if (th->syn && !before(TCP_SKB_CB(skb)->seq, tcptw->tw_rcv_nxt))
-   goto kill_with_rst;
+   return TCP_TW_RST;
 
/* Dup ACK? */
if (!th->ack ||
@@ -145,11 +145,8 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, 
struct sk_buff *skb,
 * reset.
 */
if (!th->fin ||
-   TCP_SKB_CB(skb)->end_seq != tcptw->tw_rcv_nxt + 1) {
-kill_with_rst:
-   inet_twsk_deschedule_put(tw);
+   TCP_SKB_CB(skb)->end_seq != tcptw->tw_rcv_nxt + 1)
return TCP_TW_RST;
-   }
 
/* FIN arrived, enter true time-wait state. */
tw->tw_substate   = TCP_TIME_WAIT;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 32fa0de..9ecb012 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -854,7 +854,7 @@ static void tcp_v6_send_reset(const struct sock *sk, struct 
sk_buff *skb)
 
 #ifdef CONFIG_TCP_MD5SIG

Re: [PATCH 1/1] net: Add SO_REUSEPORT_LISTEN_OFF socket option as drain mode

2015-12-21 Thread Tom Herbert
On Fri, Dec 18, 2015 at 11:00 PM, Willy Tarreau  wrote:
> On Fri, Dec 18, 2015 at 06:38:03PM -0800, Eric Dumazet wrote:
>> On Fri, 2015-12-18 at 19:58 +0100, Willy Tarreau wrote:
>> > Hi Josh,
>> >
>> > On Fri, Dec 18, 2015 at 08:33:45AM -0800, Josh Snyder wrote:
>> > > I was also puzzled that binding succeeded. Looking into the code paths
>> > > involved, in inet_csk_get_port, we quickly goto have_snum. From there, 
>> > > we end
>> > > up dropping into tb_found. Since !hlist_empty(&tb->owners), we end up 
>> > > checking
>> > > that (tb->fastreuseport > 0 && sk->sk_reuseport && uid_eq(tb->fastuid, 
>> > > uid)).
>> > > This test passes, so we goto success and bind.
>> > >
>> > > Crucially, we are checking the fastreuseport field on the 
>> > > inet_bind_bucket, and
>> > > not the sk_reuseport variable on the other sockets in the bucket. Since 
>> > > this
>> > > bit is set based on sk_reuseport at the time the first socket binds (see
>> > > tb_not_found), I can see no reason why sockets need to keep SO_REUSEPORT 
>> > > set
>> > > beyond initial binding.
>> > >
>> > > Given this, I believe Willy's patch elegantly solves the problem at hand.
>> >
>> > Great, thanks for your in-depth explanation.
>> >
>> > Eric, do you think that this patch may be acceptable material for next
>> > merge window (given that it's not a fix per-se) ? If so I'll resubmit
>> > later.
>>
>> I need to check with Craig Gallek, because he was about to upstream a
>> change to make SO_REUSEPORT more scalable & sexy (like having an [e]BPF
>> filter to perform the selection in an array of sockets)
>
> OK fine. Please note that I also considered using a new value instead of
> zero there but I preferred to avoid it since the man talked about zero/
> non-zero so I wanted to limit any API change. If Craig adds new values
> there then this is something we can reconsider.
>
Is there any reason why this turning off a soreuseport socket should
not apply to UDP also? (seems like we have a need to turn off RX but
not TX for a UDP socket).

Tom

> Have a nice week-end,
> Willy
>
--
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] net: Add SO_REUSEPORT_LISTEN_OFF socket option as drain mode

2015-12-21 Thread Willy Tarreau
On Mon, Dec 21, 2015 at 12:38:27PM -0800, Tom Herbert wrote:
> On Fri, Dec 18, 2015 at 11:00 PM, Willy Tarreau  wrote:
> > On Fri, Dec 18, 2015 at 06:38:03PM -0800, Eric Dumazet wrote:
> >> On Fri, 2015-12-18 at 19:58 +0100, Willy Tarreau wrote:
> >> > Hi Josh,
> >> >
> >> > On Fri, Dec 18, 2015 at 08:33:45AM -0800, Josh Snyder wrote:
> >> > > I was also puzzled that binding succeeded. Looking into the code paths
> >> > > involved, in inet_csk_get_port, we quickly goto have_snum. From there, 
> >> > > we end
> >> > > up dropping into tb_found. Since !hlist_empty(&tb->owners), we end up 
> >> > > checking
> >> > > that (tb->fastreuseport > 0 && sk->sk_reuseport && uid_eq(tb->fastuid, 
> >> > > uid)).
> >> > > This test passes, so we goto success and bind.
> >> > >
> >> > > Crucially, we are checking the fastreuseport field on the 
> >> > > inet_bind_bucket, and
> >> > > not the sk_reuseport variable on the other sockets in the bucket. 
> >> > > Since this
> >> > > bit is set based on sk_reuseport at the time the first socket binds 
> >> > > (see
> >> > > tb_not_found), I can see no reason why sockets need to keep 
> >> > > SO_REUSEPORT set
> >> > > beyond initial binding.
> >> > >
> >> > > Given this, I believe Willy's patch elegantly solves the problem at 
> >> > > hand.
> >> >
> >> > Great, thanks for your in-depth explanation.
> >> >
> >> > Eric, do you think that this patch may be acceptable material for next
> >> > merge window (given that it's not a fix per-se) ? If so I'll resubmit
> >> > later.
> >>
> >> I need to check with Craig Gallek, because he was about to upstream a
> >> change to make SO_REUSEPORT more scalable & sexy (like having an [e]BPF
> >> filter to perform the selection in an array of sockets)
> >
> > OK fine. Please note that I also considered using a new value instead of
> > zero there but I preferred to avoid it since the man talked about zero/
> > non-zero so I wanted to limit any API change. If Craig adds new values
> > there then this is something we can reconsider.
> >
> Is there any reason why this turning off a soreuseport socket should
> not apply to UDP also? (seems like we have a need to turn off RX but
> not TX for a UDP socket).

I didn't know it was supported for UDP :-) I guess that's the only reason.

willy

--
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: [Intel-wired-lan] [PATCH] ixgbevf: Fix handling of napi budget when multiple queues are enabled per vector

2015-12-21 Thread Schmitt, Phillip J


> -Original Message-
> From: Intel-wired-lan [mailto:intel-wired-lan-boun...@lists.osuosl.org] On
> Behalf Of William Dauchy
> Sent: Friday, October 30, 2015 10:16 AM
> To: da...@davemloft.net
> Cc: William Dauchy; netdev@vger.kernel.org; adu...@mirantis.com; intel-
> wired-...@lists.osuosl.org
> Subject: [Intel-wired-lan] [PATCH] ixgbevf: Fix handling of napi budget when
> multiple queues are enabled per vector
> 
> This is the same patch as for ixgbe but applied differently according to busy
> polling.
> see commit "ixgbe: Fix handling of napi budget when multiple queues are
> enabled per vector"
> 
> Signed-off-by: William Dauchy 

Tested-by: Phil Schmitt 
--
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] ath6kl: Use vmalloc to allocate ar->fw for api1 method

2015-12-21 Thread Brent Taylor
On Mon, Dec 21, 2015 at 1:23 PM, Souptick Joarder  wrote:
> Hi Brent,
>
> On Tue, Dec 1, 2015 at 11:11 AM, Brent Taylor  wrote:
>> Since commit 8437754c83351d6213c1a47ff029c1126d6042a7, ar->fw is expected to 
>> be pointing to memory allocated by vmalloc.  If the api1 method (via 
>> ath6kl_fetch_fw_api1) is used to allocate memory for ar->fw, then kmemdup is 
>> used.  This patch checks if the firmware being loaded is the 'fw' image, 
>> then use vmalloc, otherwise use kmalloc.
>>
>> Signed-off-by: Brent Taylor 
>> ---
>>  drivers/net/wireless/ath/ath6kl/init.c | 7 ++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
>> b/drivers/net/wireless/ath/ath6kl/init.c
>> index 6ae0734..4f2b124d 100644
>> --- a/drivers/net/wireless/ath/ath6kl/init.c
>> +++ b/drivers/net/wireless/ath/ath6kl/init.c
>> @@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char 
>> *filename,
>> return ret;
>>
>> *fw_len = fw_entry->size;
>> -   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
>> +   if (&ar->fw == fw)
>> +   *fw = vmalloc(fw_entry->size);
>> +   else
>> +   *fw = kmalloc(fw_entry->size, GFP_KERNEL);
>
>   Why vmalloc and kmalloc both are required? can't use either
> vmalloc or kmalloc?

My original problem was that kmemdup (which uses kmalloc) could not
allocate enough memory
to hold the firmware that is placed into "ar->fw".  In the function
ath6kl_core_cleanup (in core.c),
the "ar->fw" pointer is the only one that uses vfree which was changed in commit
8437754c83351d6213c1a47ff029c1126d6042a7.

I was trying to change as little as possible and I wasn't sure if
there was a reason that any of the
other firmware items needed to be allocated with kmalloc or if they
could be changed to use vmalloc.
--
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] ath6kl: Use vmalloc to allocate ar->fw for api1 method

2015-12-21 Thread Dan Kephart
Hi Brent and Souptick,




On 12/21/15, 2:23 PM, "ath6kl on behalf of Souptick Joarder" 
 wrote:

>Hi Brent,
>
>On Tue, Dec 1, 2015 at 11:11 AM, Brent Taylor  wrote:
>> Since commit 8437754c83351d6213c1a47ff029c1126d6042a7, ar->fw is expected to 
>> be pointing to memory allocated by vmalloc.  If the api1 method (via 
>> ath6kl_fetch_fw_api1) is used to allocate memory for ar->fw, then kmemdup is 
>> used.  This patch checks if the firmware being loaded is the 'fw' image, 
>> then use vmalloc, otherwise use kmalloc.
>>
>> Signed-off-by: Brent Taylor 
>> ---
>>  drivers/net/wireless/ath/ath6kl/init.c | 7 ++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
>> b/drivers/net/wireless/ath/ath6kl/init.c
>> index 6ae0734..4f2b124d 100644
>> --- a/drivers/net/wireless/ath/ath6kl/init.c
>> +++ b/drivers/net/wireless/ath/ath6kl/init.c
>> @@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char 
>> *filename,
>> return ret;
>>
>> *fw_len = fw_entry->size;
>> -   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
>> +   if (&ar->fw == fw)
>> +   *fw = vmalloc(fw_entry->size);
>> +   else
>> +   *fw = kmalloc(fw_entry->size, GFP_KERNEL);
>
>  Why vmalloc and kmalloc both are required? can't use either
>vmalloc or kmalloc?

My guess is the reason to use both vmalloc and kmalloc is that the firmware 
blob can be near 128KB.  I know our ar6003 firmwares approach that.  So vmalloc 
must have been chosen to avoid any issues if it was greater than 128KB.  So 
kmalloc is used for all the small firmware pieces (board data, otp.bin, etc) 
but vmalloc for the firmware itself.  

I personally fixed this issue for loading the firmware (but not board data, 
opt.bin, etc) in the api1 and testmode functions by have it call a new helper 
function:

static int ath6kl_get_fw_vm(struct ath6kl *ar, const char *filename,
 u8 **fw, size_t *fw_len)
{
const struct firmware *fw_entry;
int ret;

ret = request_firmware(&fw_entry, filename, ar->dev);
if (ret)
return ret;

*fw_len = fw_entry->size;
*fw = vmalloc(*fw_len);

if (*fw == NULL)
ret = -ENOMEM;

memcpy(*fw, fw_entry->data, *fw_len);

release_firmware(fw_entry);

return ret;
}



>>
>> if (*fw == NULL)
>> ret = -ENOMEM;
>> +   else
>> +   memcpy(*fw, fw_entry->data, fw_entry->size);
>>
>> release_firmware(fw_entry);
>>
>> --
>> 2.6.3
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>-Souptick
>
>___
>ath6kl mailing list
>ath...@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/ath6kl

- Dan Kephart
N�r��yb�X��ǧv�^�)޺{.n�+���z�^�)w*jg����ݢj/���z�ޖ��2�ޙ&�)ߡ�a�����G���h��j:+v���w��٥

[PATCH v2] net-next: Add tcindex to conntrack and add netfilter target/matches

2015-12-21 Thread Luuk Paulussen
This patch implements support for setting/matching the skb->tc_index
field from Xtables, as well as allowing it to be saved/restored using
connection tracking.

This provides 16 extra bits of mark space that can be saved/restored from
the connection (for performance benefits) when the marking is being done
for tc purposes.

Currently the tc_index field can be set by a number of ingress schedulers,
but if these are not being used, then there is no reason why this field
couldn't also be marked from netfilter.

Once the tc_index field has been set, it can be matched with the existing
tcindex filter in the scheduling code.

Benefits:
1. Marking for tc purposes can be done in this field, alleviating space
   restrictions in generic packet mark.
2. Doesn't increase sk_buff size.
3. tc_index can be saved/restored from connection so that if a flow has
   already been classified, it doesn't have to be done again.
4. save/restore can be done with a mark so that separate marking can be
   done for the two directions of the flow.

Reviewed-by: Matt Bennett 
Reviewed-by: Kyeong Yoo 
Signed-off-by: Luuk Paulussen 
---
 include/net/netfilter/nf_conntrack.h   |   6 +-
 include/uapi/linux/netfilter/Kbuild|   4 +
 include/uapi/linux/netfilter/nf_conntrack_common.h |   1 +
 include/uapi/linux/netfilter/nfnetlink_conntrack.h |   1 +
 include/uapi/linux/netfilter/xt_CONNTCINDEX.h  |   6 +
 include/uapi/linux/netfilter/xt_TCINDEX.h  |   6 +
 include/uapi/linux/netfilter/xt_conntcindex.h  |  31 
 include/uapi/linux/netfilter/xt_tcindex.h  |  15 ++
 net/netfilter/Kconfig  |  30 
 net/netfilter/Makefile |   2 +
 net/netfilter/nf_conntrack_netlink.c   |  38 -
 net/netfilter/xt_conntcindex.c | 165 +
 net/netfilter/xt_tcindex.c |  84 +++
 13 files changed, 385 insertions(+), 4 deletions(-)
 create mode 100644 include/uapi/linux/netfilter/xt_CONNTCINDEX.h
 create mode 100644 include/uapi/linux/netfilter/xt_TCINDEX.h
 create mode 100644 include/uapi/linux/netfilter/xt_conntcindex.h
 create mode 100644 include/uapi/linux/netfilter/xt_tcindex.h
 create mode 100644 net/netfilter/xt_conntcindex.c
 create mode 100644 net/netfilter/xt_tcindex.c

diff --git a/include/net/netfilter/nf_conntrack.h 
b/include/net/netfilter/nf_conntrack.h
index fde4068..9b0ab48 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -105,7 +105,11 @@ struct nf_conn {
 
 #if defined(CONFIG_NF_CONNTRACK_MARK)
u_int32_t mark;
-#endif
+
+#ifdef CONFIG_NET_SCHED
+   u_int16_t tc_index;
+#endif /* CONFIG_NET_SCHED */
+#endif /* CONFIG_NF_CONNTRACK_MARK */
 
 #ifdef CONFIG_NF_CONNTRACK_SECMARK
u_int32_t secmark;
diff --git a/include/uapi/linux/netfilter/Kbuild 
b/include/uapi/linux/netfilter/Kbuild
index 1d973d2..fedaaab 100644
--- a/include/uapi/linux/netfilter/Kbuild
+++ b/include/uapi/linux/netfilter/Kbuild
@@ -22,6 +22,7 @@ header-y += xt_CHECKSUM.h
 header-y += xt_CLASSIFY.h
 header-y += xt_CONNMARK.h
 header-y += xt_CONNSECMARK.h
+header-y += xt_CONNTCINDEX.h
 header-y += xt_CT.h
 header-y += xt_DSCP.h
 header-y += xt_HMARK.h
@@ -33,6 +34,7 @@ header-y += xt_NFLOG.h
 header-y += xt_NFQUEUE.h
 header-y += xt_RATEEST.h
 header-y += xt_SECMARK.h
+header-y += xt_TCINDEX.h
 header-y += xt_TCPMSS.h
 header-y += xt_TCPOPTSTRIP.h
 header-y += xt_TEE.h
@@ -46,6 +48,7 @@ header-y += xt_connbytes.h
 header-y += xt_connlabel.h
 header-y += xt_connlimit.h
 header-y += xt_connmark.h
+header-y += xt_conntcindex.h
 header-y += xt_conntrack.h
 header-y += xt_cpu.h
 header-y += xt_dccp.h
@@ -81,6 +84,7 @@ header-y += xt_socket.h
 header-y += xt_state.h
 header-y += xt_statistic.h
 header-y += xt_string.h
+header-y += xt_tcindex.h
 header-y += xt_tcpmss.h
 header-y += xt_tcpudp.h
 header-y += xt_time.h
diff --git a/include/uapi/linux/netfilter/nf_conntrack_common.h 
b/include/uapi/linux/netfilter/nf_conntrack_common.h
index 319f471..b211bb8 100644
--- a/include/uapi/linux/netfilter/nf_conntrack_common.h
+++ b/include/uapi/linux/netfilter/nf_conntrack_common.h
@@ -107,6 +107,7 @@ enum ip_conntrack_events {
IPCT_NATSEQADJ = IPCT_SEQADJ,
IPCT_SECMARK,   /* new security mark has been set */
IPCT_LABEL, /* new connlabel has been set */
+   IPCT_TCINDEX,   /* new tc_index has been set */
 };
 
 enum ip_conntrack_expect_events {
diff --git a/include/uapi/linux/netfilter/nfnetlink_conntrack.h 
b/include/uapi/linux/netfilter/nfnetlink_conntrack.h
index c1a4e144..cfdd15f 100644
--- a/include/uapi/linux/netfilter/nfnetlink_conntrack.h
+++ b/include/uapi/linux/netfilter/nfnetlink_conntrack.h
@@ -53,6 +53,7 @@ enum ctattr_type {
CTA_MARK_MASK,
CTA_LABELS,
CTA_LABELS_MASK,
+   CTA_TC_INDEX,
__CTA_MAX
 };
 #define CTA_MAX (__CTA_MAX - 1)
diff --git

Re: [PATCH] Octeon: Fix logic for waking octoen ethernet tx queue.

2015-12-21 Thread Luuk Paulussen
I see that this patch has been marked as "Not applicable" in patchworx.
Is this because I have sent it to the wrong place?  I also noticed that
I forgot to add a signoff line or CC a maintainer, so I'm happy to
resend if those are the issues.

The patch is a bugfix for an ethernet driver in the staging dir.


On 12/17/2015 09:59 AM, Luuk Paulussen wrote:
> The ethernet driver tx queue is stopped when the queue length exceeds
> what is allowed.  It should only be started again when the queue length
> is back within bounds.
>
> The logic here was just reenabling the queue when any buffers had been
> freed.  the queue was stopped whenever the length exceeded 1000
> (MAX_OUT_QUEUE_DEPTH), but then was essentially immediately started again.
> On a congested link, the queue length would just keep increasing up to around
> 8000 (for average size packets), at which point the hardware would start
> refusing the packets and they would begin to be dropped.
> This prevented the qdisc layer from effectively managing and prioritising
> packets, as essentially all packets were being allowed into the driver queue
> and then were being dropped by the hardware.
>
> This change only restarts the queue if the length is less than 1000
> (MAX_OUT_QUEUE_DEPTH).
>
> Reviewed-by: Kyeong Yoo 
> Reviewed-by: Chris Packham 
> Reviewed-by: Richard Laing 
> ---
>   drivers/staging/octeon/ethernet-tx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/octeon/ethernet-tx.c 
> b/drivers/staging/octeon/ethernet-tx.c
> index c053c4a..31292fe 100644
> --- a/drivers/staging/octeon/ethernet-tx.c
> +++ b/drivers/staging/octeon/ethernet-tx.c
> @@ -126,7 +126,7 @@ static void cvm_oct_free_tx_skbs(struct net_device *dev)
>   }
>   total_remaining += skb_queue_len(&priv->tx_free_list[qos]);
>   }
> - if (total_freed >= 0 && netif_queue_stopped(dev))
> + if (total_remaining < MAX_OUT_QUEUE_DEPTH && netif_queue_stopped(dev))
>   netif_wake_queue(dev);
>   if (total_remaining)
>   cvm_oct_kick_tx_poll_watchdog();

-- 

*Luuk Paulussen*

Software Team Lead
*Allied Telesis Labs* | 27 Nazareth Ave | Christchurch 8024 | New Zealand
Phone: +64 3 3399242
Web: *alliedtelesis*.com 

<%20http://go.alliedtelesis.com/icmg2015>
--
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] wlcore: consolidate kmalloc + memset 0 into kzalloc

2015-12-21 Thread Julian Calaby
Hi,

On Tue, Dec 22, 2015 at 3:47 AM, Nicholas Mc Guire  wrote:
> This is an API consolidation only. The use of kmalloc + memset to 0
> is equivalent to kzalloc.
>
> Signed-off-by: Nicholas Mc Guire 
> ---
>
> Found by coccinelle script (relaxed version of
> scripts/coccinelle/api/alloc/kzalloc-simple.cocci)
>
> Patch was compile tested with: x86_64_defconfig +
> CONFIG_WL12XX=m (implies CONFIG_WLCORE=m)
>
> Patch is against linux-next (localversion-next is -next-20151221)
>
>  drivers/net/wireless/ti/wlcore/main.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ti/wlcore/main.c 
> b/drivers/net/wireless/ti/wlcore/main.c
> index ec7f6af..dfc49bf 100644
> --- a/drivers/net/wireless/ti/wlcore/main.c
> +++ b/drivers/net/wireless/ti/wlcore/main.c
> @@ -838,7 +838,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
>
> wl1271_info("Reading FW panic log");
>
> -   block = kmalloc(wl->fw_mem_block_size, GFP_KERNEL);
> +   block = kzalloc(wl->fw_mem_block_size, GFP_KERNEL);
> if (!block)
> return;
>
> @@ -885,7 +885,6 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
> goto out;
> }
> -   memset(block, 0, wl->fw_mem_block_size);

I don't think you can't remove this line. It appears that the loop
this is part of resets block to be all zero, reads a chunk of data in,
then operates on it. I'm guessing that the code after the following
line expects that there isn't any data left over from previous runs
through the loop.

> ret = wlcore_read_hwaddr(wl, addr, block,
> wl->fw_mem_block_size, false);
>
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
--
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 V1 08/16] i40iw: add files for iwarp interface

2015-12-21 Thread Faisal Latif
i40iw_verbs.[ch] are to handle iwarp interface.

Added feedback provided by Christoph Hellwig

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_ucontext.h |  110 ++
 drivers/infiniband/hw/i40iw/i40iw_verbs.c| 2406 ++
 drivers/infiniband/hw/i40iw/i40iw_verbs.h|  173 ++
 3 files changed, 2689 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_ucontext.h
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_verbs.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_verbs.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw_ucontext.h 
b/drivers/infiniband/hw/i40iw/i40iw_ucontext.h
new file mode 100644
index 000..5c65c25
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_ucontext.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2006 - 2015 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2005 Topspin Communications.  All rights reserved.
+ * Copyright (c) 2005 Cisco Systems.  All rights reserved.
+ * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef I40IW_USER_CONTEXT_H
+#define I40IW_USER_CONTEXT_H
+
+#include 
+
+#define I40IW_ABI_USERSPACE_VER 4
+#define I40IW_ABI_KERNEL_VER4
+struct i40iw_alloc_ucontext_req {
+   __u32 reserved32;
+   __u8 userspace_ver;
+   __u8 reserved8[3];
+};
+
+struct i40iw_alloc_ucontext_resp {
+   __u32 max_pds;  /* maximum pds allowed for this user process */
+   __u32 max_qps;  /* maximum qps allowed for this user process */
+   __u32 wq_size;  /* size of the WQs (sq+rq) allocated to the 
mmaped area */
+   __u8 kernel_ver;
+   __u8 reserved[3];
+};
+
+struct i40iw_alloc_pd_resp {
+   __u32 pd_id;
+   __u8 reserved[4];
+};
+
+struct i40iw_create_cq_req {
+   __u64 user_cq_buffer;
+   __u64 user_shadow_area;
+};
+
+struct i40iw_create_qp_req {
+   __u64 user_wqe_buffers;
+   __u64 user_compl_ctx;
+
+   /* UDA QP PHB */
+   __u64 user_sq_phb;  /* place for VA of the sq phb buff */
+   __u64 user_rq_phb;  /* place for VA of the rq phb buff */
+};
+
+enum i40iw_memreg_type {
+   IW_MEMREG_TYPE_MEM = 0x,
+   IW_MEMREG_TYPE_QP = 0x0001,
+   IW_MEMREG_TYPE_CQ = 0x0002,
+   IW_MEMREG_TYPE_MW = 0x0003,
+   IW_MEMREG_TYPE_FMR = 0x0004,
+   IW_MEMREG_TYPE_FMEM = 0x0005,
+};
+
+struct i40iw_mem_reg_req {
+   __u16 reg_type; /* Memory, QP or CQ */
+   __u16 cq_pages;
+   __u16 rq_pages;
+   __u16 sq_pages;
+};
+
+struct i40iw_create_cq_resp {
+   __u32 cq_id;
+   __u32 cq_size;
+   __u32 mmap_db_index;
+   __u32 reserved;
+};
+
+struct i40iw_create_qp_resp {
+   __u32 qp_id;
+   __u32 actual_sq_size;
+   __u32 actual_rq_size;
+   __u32 i40iw_drv_opt;
+   __u16 push_idx;
+   __u8  lsmm;
+   __u8  rsvd2;
+};
+
+#endif
diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c 
b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
new file mode 100644
index 000..accc3dc
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
@@ -0,0 +1,2406 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD 

[PATCH V1 05/16] i40iw: add pble resource files

2015-12-21 Thread Faisal Latif
i40iw_pble.[ch] to manage pble resource for iwarp clients.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_pble.c | 618 +++
 drivers/infiniband/hw/i40iw/i40iw_pble.h | 131 +++
 2 files changed, 749 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_pble.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_pble.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw_pble.c 
b/drivers/infiniband/hw/i40iw/i40iw_pble.c
new file mode 100644
index 000..eb32cc7
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_pble.c
@@ -0,0 +1,618 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#include "i40iw_status.h"
+#include "i40iw_osdep.h"
+#include "i40iw_register.h"
+#include "i40iw_hmc.h"
+
+#include "i40iw_d.h"
+#include "i40iw_type.h"
+#include "i40iw_p.h"
+
+#include 
+#include 
+#include 
+#include "i40iw_pble.h"
+#include "i40iw.h"
+
+struct i40iw_device;
+static enum i40iw_status_code add_pble_pool(struct i40iw_sc_dev *dev,
+   struct i40iw_hmc_pble_rsrc 
*pble_rsrc);
+static void i40iw_free_vmalloc_mem(struct i40iw_hw *hw, struct i40iw_chunk 
*chunk);
+
+/**
+ * i40iw_destroy_pble_pool - destroy pool during module unload
+ * @pble_rsrc: pble resources
+ */
+void i40iw_destroy_pble_pool(struct i40iw_sc_dev *dev, struct 
i40iw_hmc_pble_rsrc *pble_rsrc)
+{
+   struct list_head *clist;
+   struct list_head *tlist;
+   struct i40iw_chunk *chunk;
+   struct i40iw_pble_pool *pinfo = &pble_rsrc->pinfo;
+
+   if (pinfo->pool) {
+   list_for_each_safe(clist, tlist, &pinfo->clist) {
+   chunk = list_entry(clist, struct i40iw_chunk, list);
+   if (chunk->type == I40IW_VMALLOC)
+   i40iw_free_vmalloc_mem(dev->hw, chunk);
+   kfree(chunk);
+   }
+   gen_pool_destroy(pinfo->pool);
+   }
+}
+
+/**
+ * i40iw_hmc_init_pble - Initialize pble resources during module load
+ * @dev: i40iw_sc_dev struct
+ * @pble_rsrc: pble resources
+ */
+enum i40iw_status_code i40iw_hmc_init_pble(struct i40iw_sc_dev *dev,
+  struct i40iw_hmc_pble_rsrc 
*pble_rsrc)
+{
+   struct i40iw_hmc_info *hmc_info;
+   u32 fpm_idx = 0;
+
+   hmc_info = dev->hmc_info;
+   pble_rsrc->fpm_base_addr = hmc_info->hmc_obj[I40IW_HMC_IW_PBLE].base;
+   /* Now start the pble' on 4k boundary */
+   if (pble_rsrc->fpm_base_addr & 0xfff)
+   fpm_idx = (PAGE_SIZE - (pble_rsrc->fpm_base_addr & 0xfff)) >> 3;
+
+   pble_rsrc->unallocated_pble =
+   hmc_info->hmc_obj[I40IW_HMC_IW_PBLE].cnt - fpm_idx;
+   pble_rsrc->next_fpm_addr = pble_rsrc->fpm_base_addr + (fpm_idx << 3);
+
+   pble_rsrc->pinfo.pool_shift = POOL_SHIFT;
+   pble_rsrc->pinfo.pool = gen_pool_create(pble_rsrc->pinfo.pool_shift, 
-1);
+   INIT_LIST_HEAD(&pble_rsrc->pinfo.clist);
+   if (!pble_rsrc->pinfo.pool)
+   goto error;
+
+   if (add_pble_pool(dev, pble_rsrc))
+   goto error;
+
+   return 0;
+
+ error:i40iw_destroy_pble_pool(dev, pble_rsrc);
+   return I40IW_ERR_NO_MEMORY;
+}
+
+/**
+ * get_sd_pd_idx -  Returns sd index, pd index and rel_pd_idx from fpm address
+ * @ pble_rsrc:structure containing fpm address
+ * @ idx: where to return indexe

[PATCH V1 15/16] i40iw: add entry in rdma_netlink

2015-12-21 Thread Faisal Latif
Add entry for port mapper services.

Signed-off-by: Faisal Latif 
---
 include/uapi/rdma/rdma_netlink.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h
index c19a5dc..4fa418d 100644
--- a/include/uapi/rdma/rdma_netlink.h
+++ b/include/uapi/rdma/rdma_netlink.h
@@ -8,6 +8,7 @@ enum {
RDMA_NL_NES,
RDMA_NL_C4IW,
RDMA_NL_LS, /* RDMA Local Services */
+   RDMA_NL_I40IW,
RDMA_NL_NUM_CLIENTS
 };
 
-- 
2.5.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 V1 16/16] i40iw: changes for build of i40iw module

2015-12-21 Thread Faisal Latif
MAINTAINERS, Kconfig, and Makefile to build i40iw module

Signed-off-by: Faisal Latif 
---
 MAINTAINERS| 10 ++
 drivers/infiniband/Kconfig |  1 +
 drivers/infiniband/hw/Makefile |  1 +
 3 files changed, 12 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9bff63c..fc85ad3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5601,6 +5601,16 @@ F:   Documentation/networking/i40evf.txt
 F: drivers/net/ethernet/intel/
 F: drivers/net/ethernet/intel/*/
 
+INTEL RDMA RNIC DRIVER
+M: Faisal Latif 
+R: Chien Tin Tung 
+R: Mustafa Ismail 
+R: Shiraz Saleem 
+R: Tatyana Nikolova 
+L: linux-r...@vger.kernel.org
+S: Supported
+F: drivers/infiniband/hw/i40iw/
+
 INTEL-MID GPIO DRIVER
 M: David Cohen 
 L: linux-g...@vger.kernel.org
diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig
index 282ec0b..cd8fa5c 100644
--- a/drivers/infiniband/Kconfig
+++ b/drivers/infiniband/Kconfig
@@ -59,6 +59,7 @@ source "drivers/infiniband/hw/mthca/Kconfig"
 source "drivers/infiniband/hw/qib/Kconfig"
 source "drivers/infiniband/hw/cxgb3/Kconfig"
 source "drivers/infiniband/hw/cxgb4/Kconfig"
+source "drivers/infiniband/hw/i40iw/Kconfig"
 source "drivers/infiniband/hw/mlx4/Kconfig"
 source "drivers/infiniband/hw/mlx5/Kconfig"
 source "drivers/infiniband/hw/nes/Kconfig"
diff --git a/drivers/infiniband/hw/Makefile b/drivers/infiniband/hw/Makefile
index aded2a5..8860057 100644
--- a/drivers/infiniband/hw/Makefile
+++ b/drivers/infiniband/hw/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_INFINIBAND_MTHCA)  += mthca/
 obj-$(CONFIG_INFINIBAND_QIB)   += qib/
 obj-$(CONFIG_INFINIBAND_CXGB3) += cxgb3/
 obj-$(CONFIG_INFINIBAND_CXGB4) += cxgb4/
+obj-$(CONFIG_INFINIBAND_I40IW) += i40iw/
 obj-$(CONFIG_MLX4_INFINIBAND)  += mlx4/
 obj-$(CONFIG_MLX5_INFINIBAND)  += mlx5/
 obj-$(CONFIG_INFINIBAND_NES)   += nes/
-- 
2.5.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 V1 01/16] i40e: Add support for client interface for IWARP driver

2015-12-21 Thread Faisal Latif
From: Anjali Singhai Jain 

This patch adds a Client interface for i40iw driver
support. Also expands the Virtchannel to support messages
from i40evf driver on behalf of i40iwvf driver.

This client API is used by the i40iw and i40iwvf driver
to access the core driver resources brokered by the i40e driver.

Signed-off-by: Anjali Singhai Jain 
---
 drivers/net/ethernet/intel/i40e/Makefile   |1 +
 drivers/net/ethernet/intel/i40e/i40e.h |   22 +
 drivers/net/ethernet/intel/i40e/i40e_client.c  | 1012 
 drivers/net/ethernet/intel/i40e/i40e_client.h  |  232 +
 drivers/net/ethernet/intel/i40e/i40e_main.c|  115 ++-
 drivers/net/ethernet/intel/i40e/i40e_type.h|3 +-
 drivers/net/ethernet/intel/i40e/i40e_virtchnl.h|   34 +
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  247 -
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h |4 +
 9 files changed, 1657 insertions(+), 13 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/i40e/i40e_client.c
 create mode 100644 drivers/net/ethernet/intel/i40e/i40e_client.h

diff --git a/drivers/net/ethernet/intel/i40e/Makefile 
b/drivers/net/ethernet/intel/i40e/Makefile
index b4729ba..3b3c63e 100644
--- a/drivers/net/ethernet/intel/i40e/Makefile
+++ b/drivers/net/ethernet/intel/i40e/Makefile
@@ -41,6 +41,7 @@ i40e-objs := i40e_main.o \
i40e_diag.o \
i40e_txrx.o \
i40e_ptp.o  \
+   i40e_client.o   \
i40e_virtchnl_pf.o
 
 i40e-$(CONFIG_I40E_DCB) += i40e_dcb.o i40e_dcb_nl.o
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h 
b/drivers/net/ethernet/intel/i40e/i40e.h
index 4dd3e26..1417ae8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -59,6 +59,7 @@
 #ifdef I40E_FCOE
 #include "i40e_fcoe.h"
 #endif
+#include "i40e_client.h"
 #include "i40e_virtchnl.h"
 #include "i40e_virtchnl_pf.h"
 #include "i40e_txrx.h"
@@ -178,6 +179,7 @@ struct i40e_lump_tracking {
u16 search_hint;
u16 list[0];
 #define I40E_PILE_VALID_BIT  0x8000
+#define I40E_IWARP_IRQ_PILE_ID  (I40E_PILE_VALID_BIT - 2)
 };
 
 #define I40E_DEFAULT_ATR_SAMPLE_RATE   20
@@ -264,6 +266,8 @@ struct i40e_pf {
 #endif /* I40E_FCOE */
u16 num_lan_qps;   /* num lan queues this PF has set up */
u16 num_lan_msix;  /* num queue vectors for the base PF vsi */
+   u16 num_iwarp_msix;/* num of iwarp vectors for this PF */
+   int iwarp_base_vector;
int queues_left;   /* queues left unclaimed */
u16 rss_size;  /* num queues in the RSS array */
u16 rss_size_max;  /* HW defined max RSS queues */
@@ -313,6 +317,7 @@ struct i40e_pf {
 #define I40E_FLAG_16BYTE_RX_DESC_ENABLED   BIT_ULL(13)
 #define I40E_FLAG_CLEAN_ADMINQ BIT_ULL(14)
 #define I40E_FLAG_FILTER_SYNC  BIT_ULL(15)
+#define I40E_FLAG_SERVICE_CLIENT_REQUESTED BIT_ULL(16)
 #define I40E_FLAG_PROCESS_MDD_EVENTBIT_ULL(17)
 #define I40E_FLAG_PROCESS_VFLR_EVENT   BIT_ULL(18)
 #define I40E_FLAG_SRIOV_ENABLEDBIT_ULL(19)
@@ -550,6 +555,8 @@ struct i40e_vsi {
struct kobject *kobj;  /* sysfs object */
bool current_isup; /* Sync 'link up' logging */
 
+   void *priv; /* client driver data reference. */
+
/* VSI specific handlers */
irqreturn_t (*irq_handler)(int irq, void *data);
 
@@ -702,6 +709,10 @@ void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi,
  struct i40e_vsi_context *ctxt,
  u8 enabled_tc, bool is_add);
 #endif
+void i40e_service_event_schedule(struct i40e_pf *pf);
+void i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id,
+ u8 *msg, u16 len);
+
 int i40e_vsi_control_rings(struct i40e_vsi *vsi, bool enable);
 int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count);
 struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, u16 uplink_seid,
@@ -724,6 +735,17 @@ static inline void i40e_dbg_pf_exit(struct i40e_pf *pf) {}
 static inline void i40e_dbg_init(void) {}
 static inline void i40e_dbg_exit(void) {}
 #endif /* CONFIG_DEBUG_FS*/
+/* needed by client drivers */
+int i40e_lan_add_device(struct i40e_pf *pf);
+int i40e_lan_del_device(struct i40e_pf *pf);
+void i40e_client_subtask(struct i40e_pf *pf);
+void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi);
+void i40e_notify_client_of_netdev_open(struct i40e_vsi *vsi);
+void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset);
+void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs);
+void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id);
+int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id,
+  enum i40e_client_type type);
 /**
  * i40e_irq_dynamic_enable - Enable default interrupt generation settings
  * @vsi:

[PATCH V1 00/16] add Intel(R) X722 iWARP driver

2015-12-21 Thread Faisal Latif

This (V1) series contains the addition of the i40iw.ko driver after
incorporating the feedback from Christoph Hellwig and Joe Perches for
initial series.

This driver provides iWARP RDMA functionality for the Intel(R) X722 Ethernet
controller for PCI Physical Functions. It also has support for Virtual
Function driver (i40iwvf.ko), which that will be part of separate patch
series.

It cooperates with the Intel(R) X722 base driver (i40e.ko) to allocate
resources and program the controller.

This series include 1 patch to i40e.ko to provide interface support to
i40iw.ko. The interface provides a driver registration mechanism, resource
allocations, and device reset coordination mechanisms.

This patch series is based on Doug Ledford's k.o/for-4.5.


Anjali Singhai Jain (1)
net/ethernet/intel/i40e: Add support for client interface for IWARP driver

Faisal Latif(15):
infiniband/hw/i40iw: add main, hdr, status
infiniband/hw/i40iw: add connection management code
infiniband/hw/i40iw: add puda code
infiniband/hw/i40iw: add pble resource files
infiniband/hw/i40iw: add hmc resource files
infiniband/hw/i40iw: add hw and utils files
infiniband/hw/i40iw: add files for iwarp interface
infiniband/hw/i40iw: add file to handle cqp calls
infiniband/hw/i40iw: add hardware related header files
infiniband/hw/i40iw: add X722 register file
infiniband/hw/i40iw: user kernel shared files
infiniband/hw/i40iw: virtual channel handling files
infiniband/hw/i40iw: Kconfig and Kbuild for iwarp module
infiniband/hw/i40iw: Add entry for I40IW rdma_netlink.h
infiniband/hw/i40iw: changes for build of i40iw module

Changes done from initial version to V1 are following.

Feedback received from Christoph Hellwig
*Remove pointless braces -improved after code review and changing
*kmap()/kunmap() - made it very short lived
*less casts -improved 
*Remove unused routine stubs - done
*no initialize to 0 or NULL when struct field were zeroed - done
*define UNREFERENCED_PARAMETER not needed -done
*remove define I40eE_MASK  -done
*rd32(), wr32() make them inline -done
*readq() use magic in linux/io-64-nonatomic-lo-hi.h -done
*SLEEP() define -done by removing it
*entry in rdma_netlink.h for I40IW should be in proper location
and separate patch -done

Feedback received from Joe Perches
*series to respuun re-spun against next - done with
Doug's Ledford's k.o/for-4.5
*Change to i40e client patch regarding mailing list - this is consistent
with other i40e files.
*Removed error from i40iw_pr_err() -done
*cqp_request() change from bitfields to bool -done
--
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 V1 02/16] i40iw: add main, hdr, status

2015-12-21 Thread Faisal Latif
i40iw_main.c contains routines for i40e <=> i40iw interface and setup.
i40iw.h is header file for main device data structures.
i40iw_status.h is for return status codes.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw.h|  568 +
 drivers/infiniband/hw/i40iw/i40iw_main.c   | 1907 
 drivers/infiniband/hw/i40iw/i40iw_status.h |  100 ++
 3 files changed, 2575 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw.h
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_main.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_status.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw.h 
b/drivers/infiniband/hw/i40iw/i40iw.h
new file mode 100644
index 000..8740ea4
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw.h
@@ -0,0 +1,568 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#ifndef I40IW_IW_H
+#define I40IW_IW_H
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "i40iw_status.h"
+#include "i40iw_osdep.h"
+#include "i40iw_d.h"
+#include "i40iw_hmc.h"
+
+#include 
+#include "i40iw_type.h"
+#include "i40iw_p.h"
+#include "i40iw_ucontext.h"
+#include "i40iw_pble.h"
+#include "i40iw_verbs.h"
+#include "i40iw_cm.h"
+#include "i40iw_user.h"
+#include "i40iw_puda.h"
+
+#define I40IW_FW_VERSION  2
+#define I40IW_HW_VERSION  2
+
+#define I40IW_ARP_ADD 1
+#define I40IW_ARP_DELETE  2
+#define I40IW_ARP_RESOLVE 3
+
+#define I40IW_MACIP_ADD 1
+#define I40IW_MACIP_DELETE  2
+
+#define IW_CCQ_SIZE (I40IW_CQP_SW_SQSIZE_2048 + 1)
+#define IW_CEQ_SIZE 2048
+#define IW_AEQ_SIZE 2048
+
+#define RX_BUF_SIZE(1536 + 8)
+#define IW_REG0_SIZE   (4 * 1024)
+#define IW_TX_TIMEOUT  (6 * HZ)
+#define IW_FIRST_QPN   1
+#define IW_SW_CONTEXT_ALIGN1024
+
+#define MAX_DPC_ITERATIONS 128
+
+#define I40IW_EVENT_TIMEOUT10
+#define I40IW_VCHNL_EVENT_TIMEOUT  10
+
+#defineI40IW_NO_VLAN   0x
+#defineI40IW_NO_QSET   0x
+
+/* access to mcast filter list */
+#define IW_ADD_MCAST false
+#define IW_DEL_MCAST true
+
+#define I40IW_DRV_OPT_ENABLE_MPA_VER_0 0x0001
+#define I40IW_DRV_OPT_DISABLE_MPA_CRC  0x0002
+#define I40IW_DRV_OPT_DISABLE_FIRST_WRITE  0x0004
+#define I40IW_DRV_OPT_DISABLE_INTF 0x0008
+#define I40IW_DRV_OPT_ENABLE_MSI   0x0010
+#define I40IW_DRV_OPT_DUAL_LOGICAL_PORT0x0020
+#define I40IW_DRV_OPT_NO_INLINE_DATA   0x0080
+#define I40IW_DRV_OPT_DISABLE_INT_MOD  0x0100
+#define I40IW_DRV_OPT_DISABLE_VIRT_WQ  0x0200
+#define I40IW_DRV_OPT_ENABLE_PAU   0x0400
+#define I40IW_DRV_OPT_MCAST_LOGPORT_MAP0x0800
+
+#define IW_HMC_OBJ_TYPE_NUM ARRAY_SIZE(iw_hmc_obj_types)
+#define IW_CFG_FPM_QP_COUNT32768
+
+#define I40IW_MTU_TO_MSS   40
+#define I40IW_DEFAULT_MSS  1460
+
+struct i40iw_cqp_compl_info {
+   u32 op_ret_val;
+   u16 maj_err_code;
+   u16 min_err_code;
+   bool error;
+   u8 op_code;
+};
+
+#define i40iw_pr_err(fmt, args ...) pr_err("%s: "fmt, __func__, ## args)
+
+#define i40iw_pr_info(fmt, args ...) pr_info("%s: " fmt, __func

[PATCH V1 10/16] i40iw: add hardware related header files

2015-12-21 Thread Faisal Latif
header files for hardware accesses

Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_d.h| 1713 ++
 drivers/infiniband/hw/i40iw/i40iw_p.h|  106 ++
 drivers/infiniband/hw/i40iw/i40iw_type.h | 1307 +++
 3 files changed, 3126 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_d.h
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_p.h
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_type.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw_d.h 
b/drivers/infiniband/hw/i40iw/i40iw_d.h
new file mode 100644
index 000..f6668d7
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_d.h
@@ -0,0 +1,1713 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#ifndef I40IW_D_H
+#define I40IW_D_H
+
+#define I40IW_DB_ADDR_OFFSET(4 * 1024 * 1024 - 64 * 1024)
+#define I40IW_VF_DB_ADDR_OFFSET (64 * 1024)
+
+#define I40IW_PUSH_OFFSET   (4 * 1024 * 1024)
+#define I40IW_PF_FIRST_PUSH_PAGE_INDEX 16
+#define I40IW_VF_PUSH_OFFSET((8 + 64) * 1024)
+#define I40IW_VF_FIRST_PUSH_PAGE_INDEX 2
+
+#define I40IW_PE_DB_SIZE_4M 1
+#define I40IW_PE_DB_SIZE_8M 2
+
+#define I40IW_DDP_VER 1
+#define I40IW_RDMAP_VER 1
+
+#define I40IW_RDMA_MODE_RDMAC 0
+#define I40IW_RDMA_MODE_IETF  1
+
+#define I40IW_QP_STATE_INVALID 0
+#define I40IW_QP_STATE_IDLE 1
+#define I40IW_QP_STATE_RTS 2
+#define I40IW_QP_STATE_CLOSING 3
+#define I40IW_QP_STATE_RESERVED 4
+#define I40IW_QP_STATE_TERMINATE 5
+#define I40IW_QP_STATE_ERROR 6
+
+#define I40IW_STAG_STATE_INVALID 0
+#define I40IW_STAG_STATE_VALID 1
+
+#define I40IW_STAG_TYPE_SHARED 0
+#define I40IW_STAG_TYPE_NONSHARED 1
+
+#define I40IW_MAX_USER_PRIORITY 8
+
+#define LS_64_1(val, bits)  ((u64)(uintptr_t)val << bits)
+#define RS_64_1(val, bits)  ((u64)(uintptr_t)val >> bits)
+#define LS_32_1(val, bits)  (u32)(val << bits)
+#define RS_32_1(val, bits)  (u32)(val >> bits)
+#define I40E_HI_DWORD(x)((u32)x) >> 16) >> 16) & 0x))
+
+#define LS_64(val, field) (((u64)val << field ## _SHIFT) & (field ## _MASK))
+
+#define RS_64(val, field) ((u64)(u64)(val & field ## _MASK) >> field ## _SHIFT)
+#define LS_32(val, field) ((val << field ## _SHIFT) & (field ## _MASK))
+#define RS_32(val, field) ((val & field ## _MASK) >> field ## _SHIFT)
+
+#define TERM_DDP_LEN_TAGGED 14
+#define TERM_DDP_LEN_UNTAGGED   18
+#define TERM_RDMA_LEN   28
+#define RDMA_OPCODE_MASK0x0f
+#define RDMA_READ_REQ_OPCODE1
+#define Q2_BAD_FRAME_OFFSET 72
+#define CQE_MAJOR_DRV   0x8000
+
+#define I40IW_TERM_SENT 0x01
+#define I40IW_TERM_RCVD 0x02
+#define I40IW_TERM_DONE 0x04
+#define I40IW_MAC_HLEN  14
+
+#define I40IW_INVALID_WQE_INDEX 0x
+
+#define I40IW_CQP_WAIT_POLL_REGS 1
+#define I40IW_CQP_WAIT_POLL_CQ 2
+#define I40IW_CQP_WAIT_EVENT 3
+
+#define I40IW_CQP_INIT_WQE(wqe) memset(wqe, 0, 64)
+
+#define I40IW_GET_CURRENT_CQ_ELEMENT(_cq) \
+   ( \
+   &((_cq)->cq_base[I40IW_RING_GETCURRENT_HEAD((_cq)->cq_ring)])  \
+   )
+#define I40IW_GET_CURRENT_EXTENDED_CQ_ELEMENT(_cq) \
+   ( \
+   &(((struct i40iw_extended_cqe *)\
+  
((_cq)->cq_base))[I40IW_RING_GETCURRENT_HEAD((_cq)->cq_ring)]) \
+   )
+
+#define I40IW_GET_CURRENT_AEQ_ELEMENT(_aeq) \
+   ( \
+   &_aeq->aeqe_base[I40IW_RING_GETCURRENT_TAIL(_aeq->aeq_ring)]   \
+   )
+
+#define I40IW_GET_CURRENT_CEQ_ELEMENT(_ceq) \
+  

[PATCH V1 14/16] i40iw: Kconfig and Kbuild for iwarp module

2015-12-21 Thread Faisal Latif
Kconfig and Kbuild needed to build iwarp module.

Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/Kbuild  | 43 +
 drivers/infiniband/hw/i40iw/Kconfig |  7 ++
 2 files changed, 50 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/Kbuild
 create mode 100644 drivers/infiniband/hw/i40iw/Kconfig

diff --git a/drivers/infiniband/hw/i40iw/Kbuild 
b/drivers/infiniband/hw/i40iw/Kbuild
new file mode 100644
index 000..ba84a78
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/Kbuild
@@ -0,0 +1,43 @@
+
+#
+# * Copyright (c) 2015 Intel Corporation.  All rights reserved.
+# *
+# * This software is available to you under a choice of one of two
+# * licenses.  You may choose to be licensed under the terms of the GNU
+# * General Public License (GPL) Version 2, available from the file
+# * COPYING in the main directory of this source tree, or the
+# * OpenFabrics.org BSD license below:
+# *
+# *   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.
+# *
+# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# * SOFTWARE.
+#
+
+
+ccflags-y :=  -Idrivers/net/ethernet/intel/i40e
+
+obj-m += i40iw.o
+
+i40iw-objs :=\
+   i40iw_cm.o i40iw_ctrl.o \
+   i40iw_hmc.o i40iw_hw.o i40iw_main.o  \
+   i40iw_pble.o i40iw_puda.o i40iw_uk.o i40iw_utils.o \
+   i40iw_verbs.o i40iw_virtchnl.o i40iw_vf.o
diff --git a/drivers/infiniband/hw/i40iw/Kconfig 
b/drivers/infiniband/hw/i40iw/Kconfig
new file mode 100644
index 000..6e7d27a
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/Kconfig
@@ -0,0 +1,7 @@
+config INFINIBAND_I40IW
+   tristate "Intel(R) Ethernet X722 iWARP Driver"
+   depends on INET && I40E
+   select GENERIC_ALLOCATOR
+   ---help---
+   Intel(R) Ethernet X722 iWARP Driver
+   INET && I40IW && INFINIBAND && I40E
-- 
2.5.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 V1 11/16] i40iw: add X722 register file

2015-12-21 Thread Faisal Latif
X722 Hardware registers defines for iWARP component.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_register.h | 1027 ++
 1 file changed, 1027 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_register.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw_register.h 
b/drivers/infiniband/hw/i40iw/i40iw_register.h
new file mode 100644
index 000..1bcac4f
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_register.h
@@ -0,0 +1,1027 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#ifndef I40IW_REGISTER_H
+#define I40IW_REGISTER_H
+
+#define I40E_GLGEN_STAT   0x000B612C /* Reset: POR */
+
+#define I40E_PFHMC_PDINV   0x000C0300 /* Reset: PFR */
+#define I40E_PFHMC_PDINV_PMSDIDX_SHIFT 0
+#define I40E_PFHMC_PDINV_PMSDIDX_MASK  (0xFFF <<  
I40E_PFHMC_PDINV_PMSDIDX_SHIFT)
+#define I40E_PFHMC_PDINV_PMPDIDX_SHIFT 16
+#define I40E_PFHMC_PDINV_PMPDIDX_MASK  (0x1FF <<  
I40E_PFHMC_PDINV_PMPDIDX_SHIFT)
+#define I40E_PFHMC_SDCMD_PMSDWR_SHIFT  31
+#define I40E_PFHMC_SDCMD_PMSDWR_MASK   (0x1 <<  I40E_PFHMC_SDCMD_PMSDWR_SHIFT)
+#define I40E_PFHMC_SDDATALOW_PMSDVALID_SHIFT   0
+#define I40E_PFHMC_SDDATALOW_PMSDVALID_MASK(0x1 <<  
I40E_PFHMC_SDDATALOW_PMSDVALID_SHIFT)
+#define I40E_PFHMC_SDDATALOW_PMSDTYPE_SHIFT1
+#define I40E_PFHMC_SDDATALOW_PMSDTYPE_MASK (0x1 <<  
I40E_PFHMC_SDDATALOW_PMSDTYPE_SHIFT)
+#define I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT 2
+#define I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_MASK  (0x3FF <<  
I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT)
+
+#define I40E_PFINT_DYN_CTLN(_INTPF) (0x00034800 + ((_INTPF) * 4)) /* 
_i=0...511 */ /* Reset: PFR */
+#define I40E_PFINT_DYN_CTLN_INTENA_SHIFT  0
+#define I40E_PFINT_DYN_CTLN_INTENA_MASK   (0x1 <<  
I40E_PFINT_DYN_CTLN_INTENA_SHIFT)
+#define I40E_PFINT_DYN_CTLN_CLEARPBA_SHIFT1
+#define I40E_PFINT_DYN_CTLN_CLEARPBA_MASK (0x1 <<  
I40E_PFINT_DYN_CTLN_CLEARPBA_SHIFT)
+#define I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT3
+#define I40E_PFINT_DYN_CTLN_ITR_INDX_MASK (0x3 <<  
I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT)
+
+#define I40E_VFINT_DYN_CTLN1(_INTVF)   (0x3800 + ((_INTVF) * 
4)) /* _i=0...15 */ /* Reset: VFR */
+#define I40E_GLHMC_VFPDINV(_i)   (0x000C8300 + ((_i) * 4)) /* 
_i=0...31 */ /* Reset: CORER */
+
+#define I40E_PFHMC_PDINV_PMSDPARTSEL_SHIFT 15
+#define I40E_PFHMC_PDINV_PMSDPARTSEL_MASK  (0x1 <<  
I40E_PFHMC_PDINV_PMSDPARTSEL_SHIFT)
+#define I40E_GLPCI_LBARCTRL0x000BE484 /* Reset: POR */
+#define I40E_GLPCI_LBARCTRL_PE_DB_SIZE_SHIFT4
+#define I40E_GLPCI_LBARCTRL_PE_DB_SIZE_MASK (0x3 <<  
I40E_GLPCI_LBARCTRL_PE_DB_SIZE_SHIFT)
+
+#define I40E_PFPE_AEQALLOC   0x00131180 /* Reset: PFR */
+#define I40E_PFPE_AEQALLOC_AECOUNT_SHIFT 0
+#define I40E_PFPE_AEQALLOC_AECOUNT_MASK  (0x <<  
I40E_PFPE_AEQALLOC_AECOUNT_SHIFT)
+#define I40E_PFPE_CCQPHIGH  0x8200 /* Reset: PFR */
+#define I40E_PFPE_CCQPHIGH_PECCQPHIGH_SHIFT 0
+#define I40E_PFPE_CCQPHIGH_PECCQPHIGH_MASK  (0x <<  
I40E_PFPE_CCQPHIGH_PECCQPHIGH_SHIFT)
+#define I40E_PFPE_CCQPLOW 0x8180 /* Reset: PFR */
+#define I40E_PFPE_CCQPLOW_PECCQPLOW_SHIFT 0
+#define I40E_PFPE_CCQPLOW_PECCQPLOW_MASK  (0x <<  
I40E_PFPE_CCQPLOW_PECCQPLOW_SHIFT)
+#define I40E_PFPE_CCQPSTATUS   0x8100 /* Reset

[PATCH V1 13/16] i40iw: virtual channel handling files

2015-12-21 Thread Faisal Latif
i40iw_vf.[ch] and i40iw_virtchnl[ch] are used for virtual
channel support for iWARP VF module.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_vf.c   |  85 +++
 drivers/infiniband/hw/i40iw/i40iw_vf.h   |  62 +++
 drivers/infiniband/hw/i40iw/i40iw_virtchnl.c | 748 +++
 drivers/infiniband/hw/i40iw/i40iw_virtchnl.h | 124 +
 4 files changed, 1019 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_vf.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_vf.h
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_virtchnl.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_virtchnl.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw_vf.c 
b/drivers/infiniband/hw/i40iw/i40iw_vf.c
new file mode 100644
index 000..b23f3c4
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_vf.c
@@ -0,0 +1,85 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#include "i40iw_osdep.h"
+#include "i40iw_register.h"
+#include "i40iw_status.h"
+#include "i40iw_hmc.h"
+#include "i40iw_d.h"
+#include "i40iw_type.h"
+#include "i40iw_p.h"
+#include "i40iw_vf.h"
+
+/**
+ * i40iw_manage_vf_pble_bp - manage vf pble
+ * @cqp: cqp for cqp' sq wqe
+ * @info: pble info
+ * @scratch: pointer for completion
+ * @post_sq: to post and ring
+ */
+enum i40iw_status_code i40iw_manage_vf_pble_bp(struct i40iw_sc_cqp *cqp,
+  struct i40iw_manage_vf_pble_info 
*info,
+  u64 scratch,
+  bool post_sq)
+{
+   u64 *wqe;
+   u64 temp, header, pd_pl_pba = 0;
+
+   wqe = i40iw_sc_cqp_get_next_send_wqe(cqp, scratch);
+   if (!wqe)
+   return I40IW_ERR_RING_FULL;
+
+   temp = LS_64(info->pd_entry_cnt, I40IW_CQPSQ_MVPBP_PD_ENTRY_CNT) |
+   LS_64(info->first_pd_index, I40IW_CQPSQ_MVPBP_FIRST_PD_INX) |
+   LS_64(info->sd_index, I40IW_CQPSQ_MVPBP_SD_INX);
+   set_64bit_val(wqe, 16, temp);
+
+   header = LS_64((info->inv_pd_ent ? 1 : 0), 
I40IW_CQPSQ_MVPBP_INV_PD_ENT) |
+   LS_64(I40IW_CQP_OP_MANAGE_VF_PBLE_BP, I40IW_CQPSQ_OPCODE) |
+   LS_64(cqp->polarity, I40IW_CQPSQ_WQEVALID);
+   set_64bit_val(wqe, 24, header);
+
+   pd_pl_pba = LS_64(info->pd_pl_pba >> 3, I40IW_CQPSQ_MVPBP_PD_PLPBA);
+   set_64bit_val(wqe, 32, pd_pl_pba);
+
+   i40iw_debug_buf(cqp->dev, I40IW_DEBUG_WQE, "MANAGE VF_PBLE_BP WQE", 
wqe, I40IW_CQP_WQE_SIZE * 8);
+
+   if (post_sq)
+   i40iw_sc_cqp_post_sq(cqp);
+   return 0;
+}
+
+struct i40iw_vf_cqp_ops iw_vf_cqp_ops = {
+   i40iw_manage_vf_pble_bp
+};
diff --git a/drivers/infiniband/hw/i40iw/i40iw_vf.h 
b/drivers/infiniband/hw/i40iw/i40iw_vf.h
new file mode 100644
index 000..cfe112d
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_vf.h
@@ -0,0 +1,62 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   Redistribution and use in source and binary forms, with or
+*

[PATCH V1 03/16] i40iw: add connection management code

2015-12-21 Thread Faisal Latif
i40iw_cm.c i40iw_cm.h are used for connection management.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_cm.c |  
 drivers/infiniband/hw/i40iw/i40iw_cm.h |  456 
 2 files changed, 4900 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_cm.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_cm.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw_cm.c 
b/drivers/infiniband/hw/i40iw/i40iw_cm.c
new file mode 100644
index 000..e559e1c
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_cm.c
@@ -0,0 +1, @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "i40iw.h"
+
+static void i40iw_rem_ref_cm_node(struct i40iw_cm_node *);
+static void i40iw_cm_post_event(struct i40iw_cm_event *event);
+static void i40iw_disconnect_worker(struct work_struct *work);
+
+/**
+ * i40iw_free_sqbuf - put back puda buffer if refcount = 0
+ * @dev: FPK device
+ * @buf: puda buffer to free
+ */
+void i40iw_free_sqbuf(struct i40iw_sc_dev *dev, void *bufp)
+{
+   struct i40iw_puda_buf *buf = (struct i40iw_puda_buf *)bufp;
+   struct i40iw_puda_rsrc *ilq = dev->ilq;
+
+   if (!atomic_dec_return(&buf->refcount))
+   i40iw_puda_ret_bufpool(ilq, buf);
+}
+
+/**
+ * i40iw_derive_hw_ird_setting - Calculate IRD
+ *
+ * @cm_ird: IRD of connection's node
+ *
+ * The ird from the connection is rounded to a supported HW
+ * setting (2,8,32,64) and then encoded for ird_size field of
+ * qp_ctx
+ */
+static u8 i40iw_derive_hw_ird_setting(u16 cm_ird)
+{
+   u8 encoded_ird_size;
+   u8 pof2_cm_ird = 1;
+
+   /* round-off to next powerof2 */
+   while (pof2_cm_ird < cm_ird)
+   pof2_cm_ird *= 2;
+
+   /* ird_size field is encoded in qp_ctx */
+   switch (pof2_cm_ird) {
+   case I40IW_HW_IRD_SETTING_64:
+   encoded_ird_size = 3;
+   break;
+   case I40IW_HW_IRD_SETTING_32:
+   case I40IW_HW_IRD_SETTING_16:
+   encoded_ird_size = 2;
+   break;
+   case I40IW_HW_IRD_SETTING_8:
+   case I40IW_HW_IRD_SETTING_4:
+   encoded_ird_size = 1;
+   break;
+   case I40IW_HW_IRD_SETTING_2:
+   default:
+   encoded_ird_size = 0;
+   break;
+   }
+   return encoded_ird_size;
+}
+
+/**
+ * i40iw_record_ird_ord - Record IRD/ORD passed in
+ * @cm_node: connection's node
+ * @conn_ird: connection IRD
+ * @conn_ord: connection ORD
+ */
+static void i40iw_record_ird_ord(struct i40iw_cm_node *cm_node, u16 conn_ird, 
u16 conn_ord)
+{
+   if (conn_ird > I40IW_MAX_IRD_SIZE)
+   conn_ird = I40IW_MAX_IRD_SIZE;
+
+   if (conn_ord > I40IW_MAX_ORD_SIZE)
+   conn_ord = I40IW_MAX_ORD_SIZE;
+
+   cm_node->ird_size = conn_ird;
+   cm_node->ord_size = conn_ord;
+}
+
+/**
+ * i40iw_copy_ip_ntohl - change network to host ip
+ * @dst: host ip
+ * @src: big endian
+ */
+void i40iw_copy_ip_ntohl(u32 *dst, __be32 *src)
+{
+   *dst++ = ntohl(*src++);
+   *dst++ = ntohl(*src++);
+   *dst++ = ntohl(*src++);
+  

[PATCH V1 06/16] i40iw: add hmc resource files

2015-12-21 Thread Faisal Latif
i40iw_hmc.[ch] are to manage hmc for the device.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_hmc.c | 821 
 drivers/infiniband/hw/i40iw/i40iw_hmc.h | 241 ++
 2 files changed, 1062 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_hmc.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_hmc.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw_hmc.c 
b/drivers/infiniband/hw/i40iw/i40iw_hmc.c
new file mode 100644
index 000..96bec54
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_hmc.c
@@ -0,0 +1,821 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#include "i40iw_osdep.h"
+#include "i40iw_register.h"
+#include "i40iw_status.h"
+#include "i40iw_hmc.h"
+#include "i40iw_d.h"
+#include "i40iw_type.h"
+#include "i40iw_p.h"
+#include "i40iw_vf.h"
+#include "i40iw_virtchnl.h"
+
+/**
+ * i40iw_find_sd_index_limit - finds segment descriptor index limit
+ * @hmc_info: pointer to the HMC configuration information structure
+ * @type: type of HMC resources we're searching
+ * @index: starting index for the object
+ * @cnt: number of objects we're trying to create
+ * @sd_idx: pointer to return index of the segment descriptor in question
+ * @sd_limit: pointer to return the maximum number of segment descriptors
+ *
+ * This function calculates the segment descriptor index and index limit
+ * for the resource defined by i40iw_hmc_rsrc_type.
+ */
+
+static inline void i40iw_find_sd_index_limit(struct i40iw_hmc_info *hmc_info,
+u32 type,
+u32 idx,
+u32 cnt,
+u32 *sd_idx,
+u32 *sd_limit)
+{
+   u64 fpm_addr, fpm_limit;
+
+   fpm_addr = hmc_info->hmc_obj[(type)].base +
+   hmc_info->hmc_obj[type].size * idx;
+   fpm_limit = fpm_addr + hmc_info->hmc_obj[type].size * cnt;
+   *sd_idx = (u32)(fpm_addr / I40IW_HMC_DIRECT_BP_SIZE);
+   *sd_limit = (u32)((fpm_limit - 1) / I40IW_HMC_DIRECT_BP_SIZE);
+   *sd_limit += 1;
+}
+
+/**
+ * i40iw_find_pd_index_limit - finds page descriptor index limit
+ * @hmc_info: pointer to the HMC configuration information struct
+ * @type: HMC resource type we're examining
+ * @idx: starting index for the object
+ * @cnt: number of objects we're trying to create
+ * @pd_index: pointer to return page descriptor index
+ * @pd_limit: pointer to return page descriptor index limit
+ *
+ * Calculates the page descriptor index and index limit for the resource
+ * defined by i40iw_hmc_rsrc_type.
+ */
+
+static inline void i40iw_find_pd_index_limit(struct i40iw_hmc_info *hmc_info,
+u32 type,
+u32 idx,
+u32 cnt,
+u32 *pd_idx,
+u32 *pd_limit)
+{
+   u64 fpm_adr, fpm_limit;
+
+   fpm_adr = hmc_info->hmc_obj[type].base +
+   hmc_info->hmc_obj[type].size * idx;
+   fpm_limit = fpm_adr + (hmc_info)->hmc_obj[(type)].size * (cnt);
+   *(pd_idx) = (u32)(fpm_adr / I40IW_HMC_PAGED_BP_SIZE);
+   *(pd_limit) = (u32)((fpm_limit - 1) / I40IW_HMC_PAGED_BP_SIZE);

[PATCH V1 04/16] i40iw: add puda code

2015-12-21 Thread Faisal Latif
i40iw_puda.[ch] are files to handle iwarp connection packets as
well as exception packets over multiple privilege mode uda queues.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_puda.c | 1437 ++
 drivers/infiniband/hw/i40iw/i40iw_puda.h |  183 
 2 files changed, 1620 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_puda.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_puda.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw_puda.c 
b/drivers/infiniband/hw/i40iw/i40iw_puda.c
new file mode 100644
index 000..cfbef59
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_puda.c
@@ -0,0 +1,1437 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#include "i40iw_osdep.h"
+#include "i40iw_register.h"
+#include "i40iw_status.h"
+#include "i40iw_hmc.h"
+
+#include "i40iw_d.h"
+#include "i40iw_type.h"
+#include "i40iw_p.h"
+#include "i40iw_puda.h"
+
+static void i40iw_ieq_receive(struct i40iw_sc_dev *dev,
+ struct i40iw_puda_buf *buf);
+static void i40iw_ieq_tx_compl(struct i40iw_sc_dev *dev, void *sqwrid);
+static void i40iw_ilq_putback_rcvbuf(struct i40iw_sc_qp *qp, u32 wqe_idx);
+static enum i40iw_status_code i40iw_puda_replenish_rq(struct i40iw_puda_rsrc
+ *rsrc, bool initial);
+/**
+ * i40iw_puda_get_listbuf - get buffer from puda list
+ * @list: list to use for buffers (ILQ or IEQ)
+ */
+static struct i40iw_puda_buf *i40iw_puda_get_listbuf(struct list_head *list)
+{
+   struct i40iw_puda_buf *buf = NULL;
+
+   if (!list_empty(list)) {
+   buf = (struct i40iw_puda_buf *)list->next;
+   list_del((struct list_head *)&buf->list);
+   }
+   return buf;
+}
+
+/**
+ * i40iw_puda_get_bufpool - return buffer from resource
+ * @rsrc: resource to use for buffer
+ */
+struct i40iw_puda_buf *i40iw_puda_get_bufpool(struct i40iw_puda_rsrc *rsrc)
+{
+   struct i40iw_puda_buf *buf = NULL;
+   struct list_head *list = &rsrc->bufpool;
+   unsigned long   flags;
+
+   spin_lock_irqsave(&rsrc->bufpool_lock, flags);
+   buf = i40iw_puda_get_listbuf(list);
+   if (buf)
+   rsrc->avail_buf_count--;
+   else
+   rsrc->stats_buf_alloc_fail++;
+   spin_unlock_irqrestore(&rsrc->bufpool_lock, flags);
+   return buf;
+}
+
+/**
+ * i40iw_puda_ret_bufpool - return buffer to rsrc list
+ * @rsrc: resource to use for buffer
+ * @buf: buffe to return to resouce
+ */
+void i40iw_puda_ret_bufpool(struct i40iw_puda_rsrc *rsrc,
+   struct i40iw_puda_buf *buf)
+{
+   unsigned long   flags;
+
+   spin_lock_irqsave(&rsrc->bufpool_lock, flags);
+   list_add(&buf->list, &rsrc->bufpool);
+   spin_unlock_irqrestore(&rsrc->bufpool_lock, flags);
+   rsrc->avail_buf_count++;
+}
+
+/**
+ * i40iw_puda_post_recvbuf - set wqe for rcv buffer
+ * @rsrc: resource ptr
+ * @wqe_idx: wqe index to use
+ * @buf: puda buffer for rcv q
+ * @initial: flag if during init time
+ */
+static void i40iw_puda_post_recvbuf(struct i40iw_puda_rsrc *rsrc, u32 wqe_idx,
+   struct i40iw_puda_buf *buf, bool initial)
+{
+   u64 *wqe;
+   struct i40iw_sc_qp *qp = &rsrc->qp;
+   u64 offset24 = 0;
+
+   qp->qp_uk.rq_wrid_array[wqe_idx] = (uintptr_t)buf;
+   wqe = &qp->qp_uk.rq_base[

[PATCH V1 07/16] i40iw: add hw and utils files

2015-12-21 Thread Faisal Latif
i40iw_hw.c, i40iw_utils.c and i40iw_osdep.h are files to handle
interrupts and processing.

Added feeback from Cristoph Hellwig.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_hw.c|  730 +
 drivers/infiniband/hw/i40iw/i40iw_osdep.h |  215 +
 drivers/infiniband/hw/i40iw/i40iw_utils.c | 1256 +
 3 files changed, 2201 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_hw.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_osdep.h
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_utils.c

diff --git a/drivers/infiniband/hw/i40iw/i40iw_hw.c 
b/drivers/infiniband/hw/i40iw/i40iw_hw.c
new file mode 100644
index 000..93ef834
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_hw.c
@@ -0,0 +1,730 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "i40iw.h"
+
+/**
+ * i40iw_initialize_hw_resources - initialize hw resource during open
+ * @iwdev: iwarp device
+ */
+u32 i40iw_initialize_hw_resources(struct i40iw_device *iwdev)
+{
+   unsigned long num_pds;
+   u32 resources_size;
+   u32 max_mr;
+   u32 max_qp;
+   u32 max_cq;
+   u32 arp_table_size;
+   u32 mrdrvbits;
+   void *resource_ptr;
+
+   max_qp = iwdev->sc_dev.hmc_info->hmc_obj[I40IW_HMC_IW_QP].cnt;
+   max_cq = iwdev->sc_dev.hmc_info->hmc_obj[I40IW_HMC_IW_CQ].cnt;
+   max_mr = iwdev->sc_dev.hmc_info->hmc_obj[I40IW_HMC_IW_MR].cnt;
+   arp_table_size = iwdev->sc_dev.hmc_info->hmc_obj[I40IW_HMC_IW_ARP].cnt;
+   iwdev->max_cqe = 0xF;
+   num_pds = max_qp * 4;
+   resources_size = sizeof(struct i40iw_arp_entry) * arp_table_size;
+   resources_size += sizeof(unsigned long) * BITS_TO_LONGS(max_qp);
+   resources_size += sizeof(unsigned long) * BITS_TO_LONGS(max_mr);
+   resources_size += sizeof(unsigned long) * BITS_TO_LONGS(max_cq);
+   resources_size += sizeof(unsigned long) * BITS_TO_LONGS(num_pds);
+   resources_size += sizeof(unsigned long) * BITS_TO_LONGS(arp_table_size);
+   resources_size += sizeof(struct i40iw_qp **) * max_qp;
+   iwdev->mem_resources = kzalloc(resources_size, GFP_KERNEL);
+
+   if (!iwdev->mem_resources)
+   return -ENOMEM;
+
+   iwdev->max_qp = max_qp;
+   iwdev->max_mr = max_mr;
+   iwdev->max_cq = max_cq;
+   iwdev->max_pd = num_pds;
+   iwdev->arp_table_size = arp_table_size;
+   iwdev->arp_table = (struct i40iw_arp_entry *)iwdev->mem_resources;
+   resource_ptr = iwdev->mem_resources + (sizeof(struct i40iw_arp_entry) * 
arp_table_size);
+
+   iwdev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY |
+   IB_DEVICE_MEM_WINDOW | IB_DEVICE_MEM_MGT_EXTENSIONS;
+
+   iwdev->allocated_qps = resource_ptr;
+   iwdev->allocated_cqs = &iwdev->allocated_qps[BITS_TO_LONGS(max_qp)];
+   iwdev->allocated_mrs = &iwdev->allocated_cqs[BITS_TO_LONGS(max_cq)];
+   iwdev->allocated_pds = &iwdev->allocated_mrs[BITS_TO_LONGS(max_mr)];
+   iwdev->allocated_arps = &iwdev->allocated_pds[BITS_TO_LONGS(num_pds)];
+   iwdev->qp_table = (struct i40iw_qp 
**)(&iwdev->allocated_arps[BITS_TO_LONGS(arp_table_size)]);
+   set_bit(0, iwdev->allocated_mrs);
+   set_bit(0, iwdev->allocated_qps);
+   set_bit(0, iwdev->allocated_cqs);
+   set_bi

[PATCH V1 12/16] i40iw: user kernel shared files

2015-12-21 Thread Faisal Latif
i40iw_user.h and i40iw_uk.c are used by both user library as well as
kernel requests.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_uk.c   | 1209 ++
 drivers/infiniband/hw/i40iw/i40iw_user.h |  442 +++
 2 files changed, 1651 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_uk.c
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_user.h

diff --git a/drivers/infiniband/hw/i40iw/i40iw_uk.c 
b/drivers/infiniband/hw/i40iw/i40iw_uk.c
new file mode 100644
index 000..9f2a6e2
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_uk.c
@@ -0,0 +1,1209 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#include "i40iw_osdep.h"
+#include "i40iw_status.h"
+#include "i40iw_d.h"
+#include "i40iw_user.h"
+#include "i40iw_register.h"
+
+static u32 nop_signature = 0x;
+
+/**
+ * i40iw_nop_1 - insert a nop wqe and move head. no post work
+ * @qp: hw qp ptr
+ */
+static enum i40iw_status_code i40iw_nop_1(struct i40iw_qp_uk *qp)
+{
+   u64 header, *wqe;
+   u64 *wqe_0 = NULL;
+   u32 wqe_idx, peek_head;
+   bool signaled = false;
+
+   if (!qp->sq_ring.head)
+   return I40IW_ERR_PARAM;
+
+   wqe_idx = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring);
+   wqe = &qp->sq_base[wqe_idx << 2];
+   peek_head = (qp->sq_ring.head + 1) % qp->sq_ring.size;
+   wqe_0 = &qp->sq_base[peek_head << 2];
+   if (peek_head)
+   wqe_0[3] = LS_64(!qp->swqe_polarity, I40IWQPSQ_VALID);
+   else
+   wqe_0[3] = LS_64(qp->swqe_polarity, I40IWQPSQ_VALID);
+
+   set_64bit_val(wqe, 0, 0);
+   set_64bit_val(wqe, 8, 0);
+   set_64bit_val(wqe, 16, 0);
+
+   header = LS_64(I40IWQP_OP_NOP, I40IWQPSQ_OPCODE) |
+   LS_64(signaled, I40IWQPSQ_SIGCOMPL) |
+   LS_64(qp->swqe_polarity, I40IWQPSQ_VALID) | nop_signature++;
+
+   wmb();  /* Memory barrier to ensure data is written before valid bit is 
set */
+
+   set_64bit_val(wqe, 24, header);
+   return 0;
+}
+
+/**
+ * i40iw_qp_post_wr - post wr to hrdware
+ * @qp: hw qp ptr
+ */
+void i40iw_qp_post_wr(struct i40iw_qp_uk *qp)
+{
+   u64 temp;
+   u32 hw_sq_tail;
+   u32 sw_sq_head;
+
+   wmb(); /* make sure valid bit is written */
+
+   /* read the doorbell shadow area */
+   get_64bit_val(qp->shadow_area, 0, &temp);
+
+   rmb(); /* make sure read is finished */
+
+   hw_sq_tail = (u32)RS_64(temp, I40IW_QP_DBSA_HW_SQ_TAIL);
+   sw_sq_head = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring);
+   if (sw_sq_head != hw_sq_tail) {
+   if (sw_sq_head > qp->initial_ring.head) {
+   if ((hw_sq_tail >= qp->initial_ring.head) &&
+   (hw_sq_tail < sw_sq_head)) {
+   writel(qp->qp_id, qp->wqe_alloc_reg);
+   }
+   } else if (sw_sq_head != qp->initial_ring.head) {
+   if ((hw_sq_tail >= qp->initial_ring.head) ||
+   (hw_sq_tail < sw_sq_head)) {
+   writel(qp->qp_id, qp->wqe_alloc_reg);
+   }
+   }
+   }
+
+   qp->initial_ring.head = qp->sq_ring.head;
+}
+
+/**
+ * i40iw_qp_ring_push_db -  ring qp doorbell
+ * @qp: hw qp ptr
+ * @wqe_idx: wqe index
+ */
+static void i40iw_qp_ring_push_db(struct i40iw_qp_uk *qp, u32

[PATCH V1 09/16] i40iw: add file to handle cqp calls

2015-12-21 Thread Faisal Latif
i40iw_ctrl.c provides for hardware wqe supporti and cqp.

Acked-by: Anjali Singhai Jain 
Acked-by: Shannon Nelson 
Signed-off-by: Faisal Latif 
---
 drivers/infiniband/hw/i40iw/i40iw_ctrl.c | 4740 ++
 1 file changed, 4740 insertions(+)
 create mode 100644 drivers/infiniband/hw/i40iw/i40iw_ctrl.c

diff --git a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c 
b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
new file mode 100644
index 000..dba742a
--- /dev/null
+++ b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
@@ -0,0 +1,4740 @@
+/***
+*
+* Copyright (c) 2015 Intel Corporation.  All rights reserved.
+*
+* This software is available to you under a choice of one of two
+* licenses.  You may choose to be licensed under the terms of the GNU
+* General Public License (GPL) Version 2, available from the file
+* COPYING in the main directory of this source tree, or the
+* OpenFabrics.org BSD license below:
+*
+*   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.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+***/
+
+#include "i40iw_osdep.h"
+#include "i40iw_register.h"
+#include "i40iw_status.h"
+#include "i40iw_hmc.h"
+
+#include "i40iw_d.h"
+#include "i40iw_type.h"
+#include "i40iw_p.h"
+#include "i40iw_vf.h"
+#include "i40iw_virtchnl.h"
+
+/**
+ * i40iw_insert_wqe_hdr - write wqe header
+ * @wqe: cqp wqe for header
+ * @header: header for the cqp wqe
+ */
+static inline void i40iw_insert_wqe_hdr(u64 *wqe, u64 header)
+{
+   wmb();/* make sure WQE is populated before valid bit is set 
*/
+   set_64bit_val(wqe, 24, header);
+}
+
+/**
+ * i40iw_get_cqp_reg_info - get head and tail for cqp using registers
+ * @cqp: struct for cqp hw
+ * @val: cqp tail register value
+ * @tail:wqtail register value
+ * @error: cqp processing err
+ */
+static inline void i40iw_get_cqp_reg_info(struct i40iw_sc_cqp *cqp,
+ u32 *val,
+ u32 *tail,
+ u32 *error)
+{
+   if (cqp->dev->is_pf) {
+   *val = i40iw_rd32(cqp->dev->hw, I40E_PFPE_CQPTAIL);
+   *tail = RS_32(*val, I40E_PFPE_CQPTAIL_WQTAIL);
+   *error = RS_32(*val, I40E_PFPE_CQPTAIL_CQP_OP_ERR);
+   } else {
+   *val = i40iw_rd32(cqp->dev->hw, I40E_VFPE_CQPTAIL1);
+   *tail = RS_32(*val, I40E_VFPE_CQPTAIL_WQTAIL);
+   *error = RS_32(*val, I40E_VFPE_CQPTAIL_CQP_OP_ERR);
+   }
+}
+
+/**
+ * i40iw_cqp_poll_registers - poll cqp registers
+ * @cqp: struct for cqp hw
+ * @tail:wqtail register value
+ * @count: how many times to try for completion
+ */
+static enum i40iw_status_code i40iw_cqp_poll_registers(
+   struct i40iw_sc_cqp *cqp,
+   u32 tail,
+   u32 count)
+{
+   u32 i = 0;
+   u32 newtail, error, val;
+
+   while (i < count) {
+   i++;
+   i40iw_get_cqp_reg_info(cqp, &val, &newtail, &error);
+   if (error) {
+   error = (cqp->dev->is_pf) ?
+i40iw_rd32(cqp->dev->hw, 
I40E_PFPE_CQPERRCODES) :
+i40iw_rd32(cqp->dev->hw, 
I40E_VFPE_CQPERRCODES1);
+   return I40IW_ERR_CQP_COMPL_ERROR;
+   }
+   if (newtail != tail) {
+   /* SUCCESS */
+   I40IW_RING_MOVE_TAIL(cqp->sq_ring);
+   return 0;
+   }
+   udelay(I40IW_SLEEP_COUNT);
+   }
+   return I40IW_ERR_TIMEOUT;
+}
+
+/**
+ * i40iw_sc_parse_fpm_commit_buf - parse fpm commit buffer
+ * @buf: ptr to fpm commit buffer
+ * @info: ptr to i40iw_hmc_obj_info struct
+ *
+ * parses fpm commit info and copy base value
+ * of hmc objects in hmc_info
+ *

Re: [PATCH 3/8] cgroup: implement cgroup_get_from_path() and expose cgroup_put()

2015-12-21 Thread Serge E. Hallyn
On Mon, Dec 07, 2015 at 05:38:50PM -0500, Tejun Heo wrote:
> Implement cgroup_get_from_path() using kernfs_walk_and_get() which
> obtains a default hierarchy cgroup from its path.  This will be used
> to allow cgroup path based matching from outside cgroup proper -
> e.g. networking and perf.

Hi Tejun,

I'm trying to figure out how to handle this in the cgroup ns patchset.
Is this going to be purely used internally?  From the user i see in
this patchset it looks like I should leave it be (and have @path always
be absolute)  Is that right?

thanks,
-serge

> v2: Add EXPORT_SYMBOL_GPL(cgroup_get_from_path).
> 
> Signed-off-by: Tejun Heo 
> ---
>  include/linux/cgroup.h |  7 +++
>  kernel/cgroup.c| 39 ++-
>  2 files changed, 41 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index b5ee2c4..4c3ffab 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -81,6 +81,8 @@ struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup 
> *cgroup,
>  struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
>  struct cgroup_subsys 
> *ss);
>  
> +struct cgroup *cgroup_get_from_path(const char *path);
> +
>  int cgroup_attach_task_all(struct task_struct *from, struct task_struct *);
>  int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from);
>  
> @@ -351,6 +353,11 @@ static inline void css_put_many(struct 
> cgroup_subsys_state *css, unsigned int n)
>   percpu_ref_put_many(&css->refcnt, n);
>  }
>  
> +static inline void cgroup_put(struct cgroup *cgrp)
> +{
> + css_put(&cgrp->self);
> +}
> +
>  /**
>   * task_css_set_check - obtain a task's css_set with extra access conditions
>   * @task: the task to obtain css_set for
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 3190040..3db5e8f 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -434,11 +434,6 @@ static bool cgroup_tryget(struct cgroup *cgrp)
>   return css_tryget(&cgrp->self);
>  }
>  
> -static void cgroup_put(struct cgroup *cgrp)
> -{
> - css_put(&cgrp->self);
> -}
> -
>  struct cgroup_subsys_state *of_css(struct kernfs_open_file *of)
>  {
>   struct cgroup *cgrp = of->kn->parent->priv;
> @@ -5753,6 +5748,40 @@ struct cgroup_subsys_state *css_from_id(int id, struct 
> cgroup_subsys *ss)
>   return id > 0 ? idr_find(&ss->css_idr, id) : NULL;
>  }
>  
> +/**
> + * cgroup_get_from_path - lookup and get a cgroup from its default hierarchy 
> path
> + * @path: path on the default hierarchy
> + *
> + * Find the cgroup at @path on the default hierarchy, increment its
> + * reference count and return it.  Returns pointer to the found cgroup on
> + * success, ERR_PTR(-ENOENT) if @path doens't exist and ERR_PTR(-ENOTDIR)
> + * if @path points to a non-directory.
> + */
> +struct cgroup *cgroup_get_from_path(const char *path)
> +{
> + struct kernfs_node *kn;
> + struct cgroup *cgrp;
> +
> + mutex_lock(&cgroup_mutex);
> +
> + kn = kernfs_walk_and_get(cgrp_dfl_root.cgrp.kn, path);
> + if (kn) {
> + if (kernfs_type(kn) == KERNFS_DIR) {
> + cgrp = kn->priv;
> + cgroup_get(cgrp);
> + } else {
> + cgrp = ERR_PTR(-ENOTDIR);
> + }
> + kernfs_put(kn);
> + } else {
> + cgrp = ERR_PTR(-ENOENT);
> + }
> +
> + mutex_unlock(&cgroup_mutex);
> + return cgrp;
> +}
> +EXPORT_SYMBOL_GPL(cgroup_get_from_path);
> +
>  #ifdef CONFIG_CGROUP_DEBUG
>  static struct cgroup_subsys_state *
>  debug_css_alloc(struct cgroup_subsys_state *parent_css)
> -- 
> 2.5.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
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] ip_tunnel: Move stats update to iptunnel_xmit()

2015-12-21 Thread Pravin B Shelar
By moving stats update into iptunnel_xmit(), we can simplify
iptunnel_xmit() usage. With this change there is no need to
call another function (iptunnel_xmit_stats()) to update stats
in tunnel xmit code path.

Signed-off-by: Pravin B Shelar 
---
 drivers/net/geneve.c  | 17 -
 drivers/net/vxlan.c   |  9 -
 include/net/ip6_tunnel.h  | 17 -
 include/net/ip_tunnels.h  | 18 --
 include/net/udp_tunnel.h  |  8 
 net/ipv4/ip_gre.c |  7 +++
 net/ipv4/ip_tunnel.c  |  7 ++-
 net/ipv4/ip_tunnel_core.c |  9 +
 net/ipv4/ip_vti.c |  2 +-
 net/ipv4/udp_tunnel.c | 11 +--
 net/ipv6/sit.c|  7 ++-
 net/tipc/udp_media.c  | 12 +++-
 12 files changed, 49 insertions(+), 75 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index e6e0092..20dd664 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -918,12 +918,11 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, 
struct net_device *dev,
ttl = ttl ? : ip4_dst_hoplimit(&rt->dst);
df = 0;
}
-   err = udp_tunnel_xmit_skb(rt, gs4->sock->sk, skb, fl4.saddr, fl4.daddr,
- tos, ttl, df, sport, geneve->dst_port,
- !net_eq(geneve->net, dev_net(geneve->dev)),
- !(flags & GENEVE_F_UDP_CSUM));
+   udp_tunnel_xmit_skb(rt, gs4->sock->sk, skb, fl4.saddr, fl4.daddr,
+   tos, ttl, df, sport, geneve->dst_port,
+   !net_eq(geneve->net, dev_net(geneve->dev)),
+   !(flags & GENEVE_F_UDP_CSUM));
 
-   iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
return NETDEV_TX_OK;
 
 tx_error:
@@ -1005,10 +1004,10 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff 
*skb, struct net_device *dev,
ttl = 1;
ttl = ttl ? : ip6_dst_hoplimit(dst);
}
-   err = udp_tunnel6_xmit_skb(dst, gs6->sock->sk, skb, dev,
-  &fl6.saddr, &fl6.daddr, prio, ttl,
-  sport, geneve->dst_port,
-  !!(flags & GENEVE_F_UDP_ZERO_CSUM6_TX));
+   udp_tunnel6_xmit_skb(dst, gs6->sock->sk, skb, dev,
+&fl6.saddr, &fl6.daddr, prio, ttl,
+sport, geneve->dst_port,
+!!(flags & GENEVE_F_UDP_ZERO_CSUM6_TX));
return NETDEV_TX_OK;
 
 tx_error:
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index ba363ce..fecf7b6 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1841,9 +1841,10 @@ static int vxlan_xmit_skb(struct rtable *rt, struct sock 
*sk, struct sk_buff *sk
 
skb_set_inner_protocol(skb, htons(ETH_P_TEB));
 
-   return udp_tunnel_xmit_skb(rt, sk, skb, src, dst, tos,
-  ttl, df, src_port, dst_port, xnet,
-  !(vxflags & VXLAN_F_UDP_CSUM));
+   udp_tunnel_xmit_skb(rt, sk, skb, src, dst, tos, ttl, df,
+   src_port, dst_port, xnet,
+   !(vxflags & VXLAN_F_UDP_CSUM));
+   return 0;
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
@@ -2056,8 +2057,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct 
net_device *dev,
skb = NULL;
goto rt_tx_error;
}
-
-   iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
 #if IS_ENABLED(CONFIG_IPV6)
} else {
struct dst_entry *ndst;
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
index ff788b6..a46769a 100644
--- a/include/net/ip6_tunnel.h
+++ b/include/net/ip6_tunnel.h
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define IP6TUNNEL_ERR_TIMEO (30*HZ)
 
@@ -83,22 +84,12 @@ int ip6_tnl_get_iflink(const struct net_device *dev);
 static inline void ip6tunnel_xmit(struct sock *sk, struct sk_buff *skb,
  struct net_device *dev)
 {
-   struct net_device_stats *stats = &dev->stats;
int pkt_len, err;
 
pkt_len = skb->len - skb_inner_network_offset(skb);
err = ip6_local_out(dev_net(skb_dst(skb)->dev), sk, skb);
-
-   if (net_xmit_eval(err) == 0) {
-   struct pcpu_sw_netstats *tstats = get_cpu_ptr(dev->tstats);
-   u64_stats_update_begin(&tstats->syncp);
-   tstats->tx_bytes += pkt_len;
-   tstats->tx_packets++;
-   u64_stats_update_end(&tstats->syncp);
-   put_cpu_ptr(tstats);
-   } else {
-   stats->tx_errors++;
-   stats->tx_aborted_errors++;
-   }
+   if (unlikely(net_xmit_eval(err)))
+   pkt_len = 0;
+   iptunnel_xmit_stats(dev, pkt_len);
 }
 #endif
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 62a750

Re: [PATCH V1 16/16] i40iw: changes for build of i40iw module

2015-12-21 Thread kbuild test robot
Hi Faisal,

[auto build test ERROR on net/master]
[also build test ERROR on v4.4-rc6 next-20151221]
[cannot apply to net-next/master]

url:
https://github.com/0day-ci/linux/commits/Faisal-Latif/add-Intel-R-X722-iWARP-driver/20151222-071852
config: x86_64-allmodconfig (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/infiniband/hw/i40iw/i40iw_verbs.c: In function 
'i40iw_init_rdma_device':
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2280:39: error: 'struct ib_device' 
>> has no member named 'sys_image_guid'
 ether_addr_copy((u8 *)&iwibdev->ibdev.sys_image_guid, 
iwdev->netdev->dev_addr);
  ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2281:16: error: 'struct ib_device' 
>> has no member named 'fw_ver'
 iwibdev->ibdev.fw_ver = I40IW_FW_VERSION;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2282:16: error: 'struct ib_device' 
>> has no member named 'device_cap_flags'
 iwibdev->ibdev.device_cap_flags = iwdev->device_cap_flags;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2283:16: error: 'struct ib_device' 
>> has no member named 'vendor_id'
 iwibdev->ibdev.vendor_id = iwdev->vendor_id;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2284:16: error: 'struct ib_device' 
>> has no member named 'vendor_part_id'
 iwibdev->ibdev.vendor_part_id = iwdev->vendor_part_id;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2285:16: error: 'struct ib_device' 
>> has no member named 'hw_ver'
 iwibdev->ibdev.hw_ver = I40IW_HW_VERSION;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2286:16: error: 'struct ib_device' 
>> has no member named 'max_mr_size'
 iwibdev->ibdev.max_mr_size = I40IW_MAX_OUTBOUND_MESSAGE_SIZE;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2287:16: error: 'struct ib_device' 
>> has no member named 'max_qp'
 iwibdev->ibdev.max_qp = iwdev->max_qp;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2288:16: error: 'struct ib_device' 
>> has no member named 'max_qp_wr'
 iwibdev->ibdev.max_qp_wr = (I40IW_MAX_WQ_ENTRIES >> 2) - 1;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2289:16: error: 'struct ib_device' 
>> has no member named 'max_sge'
 iwibdev->ibdev.max_sge = I40IW_MAX_WQ_FRAGMENT_COUNT;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2290:16: error: 'struct ib_device' 
>> has no member named 'max_cq'
 iwibdev->ibdev.max_cq = iwdev->max_cq;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2291:16: error: 'struct ib_device' 
>> has no member named 'max_cqe'
 iwibdev->ibdev.max_cqe = iwdev->max_cqe;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2293:16: error: 'struct ib_device' 
>> has no member named 'max_mr'
 iwibdev->ibdev.max_mr = iwdev->max_mr;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2294:16: error: 'struct ib_device' 
>> has no member named 'max_mw'
 iwibdev->ibdev.max_mw = iwdev->max_mr;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2295:16: error: 'struct ib_device' 
>> has no member named 'max_pd'
 iwibdev->ibdev.max_pd = iwdev->max_pd;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2296:16: error: 'struct ib_device' 
>> has no member named 'max_qp_rd_atom'
 iwibdev->ibdev.max_qp_rd_atom = I40IW_MAX_IRD_SIZE;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2297:16: error: 'struct ib_device' 
>> has no member named 'max_sge_rd'
 iwibdev->ibdev.max_sge_rd = 1;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2299:16: error: 'struct ib_device' 
>> has no member named 'max_qp_init_rd_atom'
 iwibdev->ibdev.max_qp_init_rd_atom = I40IW_MAX_IRD_SIZE;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2300:16: error: 'struct ib_device' 
>> has no member named 'atomic_cap'
 iwibdev->ibdev.atomic_cap = IB_ATOMIC_NONE;
   ^
>> drivers/infiniband/hw/i40iw/i40iw_verbs.c:2301:16: error: 'struct ib_device' 
>> ha

Re: 4.4-rc5 crash (af_unix)

2015-12-21 Thread Cong Wang
(Cc'ing netdev and Rainer)

On Thu, Dec 17, 2015 at 9:12 PM, Mika Penttilä
 wrote:
> Still something with af_unix and/or wake code on rc5 :
>
>
> [34971.300210] Unable to handle kernel paging request at virtual address
> 56ac56ac
>
> [34971.307455] pgd = a8c3
>
> [34971.310164] [56ac56ac] *pgd=
>
> [34971.313761] Internal error: Oops: 8005 [#1] PREEMPT SMP ARM
>
> [34971.319683] Modules linked in: btwilink st_drv
>
> [34971.324174] CPU: 1 PID: 333 Comm: compositor Not tainted 4.4.0-rc5 #1
>
> [34971.330620] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
>
> [34971.337152] task: a8c71c80 ti: a8aea000 task.ti: a8aea000
>
> [34971.342554] PC is at 0x56ac56ac
>
> [34971.345710] LR is at __wake_up_common+0x4c/0x80
>
> [34971.350246] pc : [<56ac56ac>]lr : [<800585e4>]psr: 200f0093
>
> [34971.350246] sp : a8aebd20  ip : a8ea56bc  fp : 0001
>
> [34971.361725] r10: 0001  r9 : 0001  r8 : 0304
>
> [34971.366952] r7 : a8ea5744  r6 : 8023a9e4  r5 : 56ac56ac  r4 : a8c95d28
>
> [34971.373480] r3 : 0304  r2 : 0001  r1 : 0001  r0 : a8ea56bc
>
> [34971.380010] Flags: nzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM
> Segment user
>
> [34971.387234] Control: 10c5387d  Table: 38c3004a  DAC: 0055
>
> [34971.392982] Process compositor (pid: 333, stack limit = 0xa8aea210)
>
> [34971.399250] Stack: (0xa8aebd20 to 0xa8aec000)
>
> [34971.403612] bd20: 0001 a8ea5740 0001 0304 0001
> a00f0013 0098 a8aebe4c
>
> [34971.411793] bd40:  80058bc8 0304 a8aebe78 a8db42c0
> a8db42c0 a8db4000 0f68
>
> [34971.419974] bd60: a8db4084 805bd7c0 a8db4394 805196d8 a9e37600
>  a8db4000 805bd270
>
> [34971.428155] bd80: a8aebd94    
>  a9e37600 8051a810
>
> [34971.436336] bda0: a9e37600 8051a970 a9e37600 8051aa44 a9e37600
> 805be498 7ec113e8 8025f2e4
>
> [34971.444517] bdc0: a8f35044 0098 a8db420c 0098 a653e780
> 0001  
>
> [34971.452697] bde0: a8db41e4  a8aebdf8  a8aea000
> 800e4928  
>
> [34971.460878] be00:     7ec115a8
> 80264d8c a8aebe78 a8aebe24
>
> [34971.469059] be20: 00a5cda4 80513658 a8aebf6c 4040 7ec115b8
> 7ec115d4 a8aebeb8 a653e780
>
> [34971.477240] be40: 00c50388 805be604 00c87240 805bd130 a653e780
> a8aebf6c  1000
>
> [34971.485420] be60: 4040  00c50388 8051515c 
>  00c506fc 0c8c
>
> [34971.493601] be80: 00c50388 0374 014d  0004
> 0320 00a70664 00983dcc
>
> [34971.501782] bea0: 758ce8e0 00983dcc 758ce8e0 758ce8ec 00a70664
> 758ce8ec  80513a8c
>
> [34971.509963] bec0: a8b6df8c a8aebf10 a8b6df8c a8aebf10 7ec116d8
> 8011da50 00a70664 
>
> [34971.518143] bee0: 0001 600f0013 a8aebefc 8004559c a8c07500
> 600f0013 a8c07534 806de1a0
>
> [34971.526324] bf00: a8c07534 806de414  8011df1c a8aebf10
> a8aebf10 a8aebf2c 0020
>
> [34971.534505] bf20: a895ccc0 800fd364 a8aebf68 a8aebf64 4040
> 0129 a653e780 7ec115b8
>
> [34971.542686] bf40: 4040 0129 8000f6a4 a8aea000 
> 80515eb0  
>
> [34971.550867] bf60: 0020 0001 fff7  
>  0098 0f68
>
> [34971.559047] bf80: a8aebe78 0002 7ec115d4 007c 4000
>  0040 001c
>
> [34971.567227] bfa0: 7ec115b8 8000f500 0040 001c 001c
> 7ec115b8 4040 
>
> [34971.575409] bfc0: 0040 001c 7ec115b8 0129 0006
> 7ec115b8 76145d68 00c50388
>
> [34971.583589] bfe0:  7ec11588 73d6f4c0 75bef794 800f0010
> 001c 3bf5e861 3bf5ec61
>
> [34971.591782] [<800585e4>] (__wake_up_common) from [<80058bc8>]
> (__wake_up_sync_key+0x44/0x60)
>
> [34971.600235] [<80058bc8>] (__wake_up_sync_key) from [<805bd7c0>]
> (unix_write_space+0x58/0x88)
>
> [34971.608686] [<805bd7c0>] (unix_write_space) from [<805196d8>]
> (sock_wfree+0x78/0x80)
>
> [34971.616437] [<805196d8>] (sock_wfree) from [<805bd270>]
> (unix_destruct_scm+0x64/0x6c)
>
> [34971.624276] [<805bd270>] (unix_destruct_scm) from [<8051a810>]
> (skb_release_head_state+0x84/0xec)
>
> [34971.633154] [<8051a810>] (skb_release_head_state) from [<8051a970>]
> (skb_release_all+0xc/0x24)
>
> [34971.641772] [<8051a970>] (skb_release_all) from [<8051aa44>]
> (consume_skb+0x24/0x60)
>
> [34971.649523] [<8051aa44>] (consume_skb) from [<805be498>]
> (unix_stream_read_generic+0x71c/0x7d0)
>
> [34971.658228] [<805be498>] (unix_stream_read_generic) from [<805be604>]
> (unix_stream_recvmsg+0x38/0x40)
>
> [34971.667453] [<805be604>] (unix_stream_recvmsg) from [<8051515c>]
> (___sys_recvmsg+0x94/0x12c)
>
> [34971.675897] [<8051515c>] (___sys_recvmsg) from [<80515eb0>]
> (__sys_recvmsg+0x3c/0x6c)
>
> [34971.683738] [<80515eb0>] (__sys_recvmsg) from [<8000f500>]
> (ret_fast_syscall+0x0/0x34)
>
> [34971.691659] Code: bad PC value
>
> [34971.694718] ---[ end trace b54a6d4b7a89f212 ]---
>
> [34971.699339] Kernel panic -

Re: [REGRESSION] tcp/ipv4: kernel panic because of (possible) division by zero

2015-12-21 Thread Yuchung Cheng
On Mon, Dec 21, 2015 at 12:25 PM, Oleksandr Natalenko
 wrote:
> Commit 3759824da87b30ce7a35b4873b62b0ba38905ef5 (tcp: PRR uses CRB mode by
> default and SS mode conditionally) introduced changes to net/ipv4/tcp_input.c
> tcp_cwnd_reduction() that, possibly, cause division by zero, and therefore,
> kernel panic in interrupt handler [1].
>
> Reverting 3759824da87b30ce7a35b4873b62b0ba38905ef5 seems to fix the issue.
>
> I'm able to reproduce the issue on 4.3.0–4.3.3 once per several day
> (occasionally).
>
> What could be done to help in debugging this issue?
Do you have ECN enabled (i.e. sysctl net.ipv4.tcp_ecn > 0)?

If so I suspect an ACK carrying ECE during CA_Loss causes entering CWR
state w/o calling tcp_init_cwnd_reduct() to set tp->prior_cwnd. Can
you try this debug / quick-fix patch and send me the error message if
any?


>
> Regards,
>   Oleksandr.
>
> [1] http://i.piccy.info/
> i9/6f5cb187c4ff282d189f78c63f95af43/1450729403/283985/951663/panic.jpg


0001-tcp-debug-tcp_cwnd_reduction-div0.patch
Description: Binary data


Re: [PATCH 1/2] [iproute2] tc/q_htb.c: remove printing of a deprecated overhead value previously encoded as a part of mpu field

2015-12-21 Thread Stephen Hemminger
On Sat, 19 Dec 2015 18:25:52 +0300
Dmitrii Shcherbakov  wrote:

> Remove printing according to the previously used encoding of mpu and overhead 
> values within the tc_ratespec's mpu field. This encoding is no longer being 
> used as a separate 'overhead' field in the ratespec structure has been 
> introduced.
> 
> Signed-off-by: Dmitrii Shcherbakov 
> Acked-by: Jesper Dangaard Brouer 
> Acked-by: Phil Sutter 
> ---
>  tc/q_htb.c | 11 ---
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/tc/q_htb.c b/tc/q_htb.c
> index 7075a4c..e76d20a 100644
> --- a/tc/q_htb.c
> +++ b/tc/q_htb.c
> @@ -273,7 +273,6 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, 
> struct rtattr *opt)
>   __u64 rate64, ceil64;
>   SPRINT_BUF(b1);
>   SPRINT_BUF(b2);
> - SPRINT_BUF(b3);
>   SPRINT_BUF(b4);
>  
>   if (opt == NULL)
> @@ -313,16 +312,14 @@ static int htb_print_opt(struct qdisc_util *qu, FILE 
> *f, struct rtattr *opt)
>   if (linklayer > TC_LINKLAYER_ETHERNET || show_details)
>   fprintf(f, "linklayer %s ", sprint_linklayer(linklayer, 
> b4));
>   if (show_details) {
> - fprintf(f, "burst %s/%u mpu %s overhead %s ",
> + fprintf(f, "burst %s/%u mpu %s ",
>   sprint_size(buffer, b1),
>   1 - sprint_size(hopt->rate.mpu&0xFF, b2),
> - sprint_size((hopt->rate.mpu>>8)&0xFF, b3));
> - fprintf(f, "cburst %s/%u mpu %s overhead %s ",
> + sprint_size(hopt->rate.mpu, b2));
> + fprintf(f, "cburst %s/%u mpu %s ",
>   sprint_size(cbuffer, b1),
>   1 - sprint_size(hopt->ceil.mpu&0xFF, b2),
> - sprint_size((hopt->ceil.mpu>>8)&0xFF, b3));
> + sprint_size(hopt->ceil.mpu, b2));
>   fprintf(f, "level %d ", (int)hopt->level);
>   } else {
>   fprintf(f, "burst %s ", sprint_size(buffer, b1));

Not sure if this a good thing to do. There are people who screenscrape the 
output of
iproute2 commands, and this might break that.
--
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] Octeon: Fix logic for waking octoen ethernet tx queue.

2015-12-21 Thread David Miller
From: Luuk Paulussen 
Date: Mon, 21 Dec 2015 22:53:06 +

> The patch is a bugfix for an ethernet driver in the staging dir.

Changes to things under drivers/staging get submitted to the
staging maintainer, not here.
--
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: [iproute PATCH] iptunnel: Fix compile error in ip/tunnel.c

2015-12-21 Thread Stephen Hemminger
On Mon, 21 Dec 2015 20:42:56 +0100
Phil Sutter  wrote:

> I repeatedly failed to get this right, so now I have to clean up my mess
> afterwards.
> 
> Fixes: 7d6aadcd0a1dc ("ip{,6}tunnel: have a shared stats parser/printer")
> Signed-off-by: Phil Sutter 
> ---
>  ip/tunnel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ip/tunnel.c b/ip/tunnel.c
> index 1dd8092..39f825b 100644
> --- a/ip/tunnel.c
> +++ b/ip/tunnel.c
> @@ -208,7 +208,7 @@ void tnl_print_stats(const char *buf)
> tx_bytes, tx_packets, tx_errs, tx_drops,
> tx_fifo, tx_colls, tx_carrier, rx_multi;
>  
> - if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
> + if (sscanf(buf, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
>  &rx_bytes, &rx_packets, &rx_errs, &rx_drops,
>  &rx_fifo, &rx_frame, &rx_multi,
>  &tx_bytes, &tx_packets, &tx_errs, &tx_drops,

Applied..
--
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 iproute2] ip/iproute: allow routes to be configured with expire values

2015-12-21 Thread Stephen Hemminger
OK, applied to net-next branch (not master).

Also, please update man pages as well.


--
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: [iproute PATCH v2 2/2] ss: support closing inet sockets via SOCK_DESTROY.

2015-12-21 Thread Stephen Hemminger
On Thu, 17 Dec 2015 22:22:18 +0900
Lorenzo Colitti  wrote:

> diff --git a/misc/ss.c b/misc/ss.c
> index 0dab32c..be70c41 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -160,6 +160,9 @@ struct filter
>   int states;
>   int families;
>   struct ssfilter *f;
> + struct {
> + __u8 kill:1;
> + } action;
>  };
>  
>  stati

Please just make it a boolean or integer, not a structure wrapped around a bit 
field.
If you need to extend in the future then change it then. Please don't write code
based on speculative future additions.
--
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][iproute2] tc/q_htb.c: Fix the MPU value output in 'tc -d class show dev ' command

2015-12-21 Thread Stephen Hemminger
On Sat, 19 Dec 2015 00:45:40 +0300
Dmitrii Shcherbakov  wrote:

> Phil,
> 
> 18.12.2015, 19:55, "Phil Sutter" :
> > On Fri, Dec 18, 2015 at 07:39:25PM +0300, Dmitrii Shcherbakov wrote:
> >>  > Dmitrii, did iproute2 without your change even print the overhead as set
> >>  > by you before? Looking at the code, I'd assume not.
> >>
> >>  Tried building iproute2 (as of tag 4.2) and using the upstream linux 
> >> kernel (also tag 4.2 - 64291f7db5bd8150a74ad2036f1037e6a0428df2):
> >
> > This is without your patch, right?
> 
> Yes (ec4ef6aebd5a52ab1acf1f5be1749320b3188659). 
> 
> >
> >>  ~/src/iproute2/tc$ sudo ./tc class add dev eth0 parent 1: classid 1:1 htb 
> >> rate 100kbps ceil 100kbps mpu 256 overhead 64
> >
> > Setting an mpu of 256 is suitable to get 0 as output value, as the code
> > before your patch ANDs it with 0xff.
> 
> True, but then I think I would get the 'old' (encoded) overhead output of 
> '1b' then and the first 8 bits which are treated as mpu would be 0 anyway. 
> And its 0 for both mpu and overhead ("mpu 0b overhead 0b") which is strange. 
> I am going to have to take a look at the kernel state with gdb.
> 
> What I would expect instead (notice 'overhead 1b'):
> 
> [root@localhost ~]# tc -d class show dev eth0
> [root@localhost ~]# tc qdisc add dev eth0 root handle 1: htb default 12
> [root@localhost ~]# tc class add dev eth0 parent 1: classid 1:1 htb rate 
> 100kbps ceil 100kbps mpu 256 overhead 64
> [root@localhost ~]# tc -d class show dev eth0
> class htb 1:1 root prio 0 quantum 1 rate 80bit overhead 64 ceil 
> 80bit burst 1600b/1 mpu 0b overhead 1b cburst 1600b/1 mpu 0b overhead 1b 
> level 0  
> 
> >
> >>  So it looks like the overhead is being set correctly, but the mpu is not, 
> >> even though the respective kernel module is loaded judging by what I see.
> >
> > To really know what is being set, you would have to look at the kernel
> > variables not what iproute prints. This is nitpicking mostly, but
> > relevant in this case as your patches to fix iproute's output show.
> >
> > Cheers, Phil
> 
> I am going to try and take a look at it. I have not delved into the kernel's 
> network subsystem so it may take some time.
> 
> Thanks,
> Dima

I am going to hold off on this, if it hasn't been urgent for years, there is no
requirement to do it right away. If you come to a conclusion let me know.

It might be possible to troll back through Internet to get more data on this...
--
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] wlcore: consolidate kmalloc + memset 0 into kzalloc

2015-12-21 Thread Souptick Joarder
On Mon, Dec 21, 2015 at 10:17 PM, Nicholas Mc Guire  wrote:
> This is an API consolidation only. The use of kmalloc + memset to 0
> is equivalent to kzalloc.
>
> Signed-off-by: Nicholas Mc Guire 
> ---
>
> Found by coccinelle script (relaxed version of
> scripts/coccinelle/api/alloc/kzalloc-simple.cocci)
>
> Patch was compile tested with: x86_64_defconfig +
> CONFIG_WL12XX=m (implies CONFIG_WLCORE=m)
>
> Patch is against linux-next (localversion-next is -next-20151221)
>
>  drivers/net/wireless/ti/wlcore/main.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ti/wlcore/main.c 
> b/drivers/net/wireless/ti/wlcore/main.c
> index ec7f6af..dfc49bf 100644
> --- a/drivers/net/wireless/ti/wlcore/main.c
> +++ b/drivers/net/wireless/ti/wlcore/main.c
> @@ -838,7 +838,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
>
> wl1271_info("Reading FW panic log");
>
> -   block = kmalloc(wl->fw_mem_block_size, GFP_KERNEL);
> +   block = kzalloc(wl->fw_mem_block_size, GFP_KERNEL);
> if (!block)
> return;
>
> @@ -885,7 +885,6 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
> goto out;
> }
>
> -   memset(block, 0, wl->fw_mem_block_size);

Current code is reseting the block value to 0 in each iterations and
perform some operations.
But if you are using kzalloc as mentioned above it will memset 0 to
block pointer only once.
So both are not equivalent operations.

> ret = wlcore_read_hwaddr(wl, addr, block,
> wl->fw_mem_block_size, false);
>
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-Souptick
--
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] wlcore: consolidate kmalloc + memset 0 into kzalloc

2015-12-21 Thread Nicholas Mc Guire
On Tue, Dec 22, 2015 at 09:56:10AM +1100, Julian Calaby wrote:
> Hi,
> 
> On Tue, Dec 22, 2015 at 3:47 AM, Nicholas Mc Guire  wrote:
> > This is an API consolidation only. The use of kmalloc + memset to 0
> > is equivalent to kzalloc.
> >
> > Signed-off-by: Nicholas Mc Guire 
> > ---
> >
> > Found by coccinelle script (relaxed version of
> > scripts/coccinelle/api/alloc/kzalloc-simple.cocci)
> >
> > Patch was compile tested with: x86_64_defconfig +
> > CONFIG_WL12XX=m (implies CONFIG_WLCORE=m)
> >
> > Patch is against linux-next (localversion-next is -next-20151221)
> >
> >  drivers/net/wireless/ti/wlcore/main.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/wireless/ti/wlcore/main.c 
> > b/drivers/net/wireless/ti/wlcore/main.c
> > index ec7f6af..dfc49bf 100644
> > --- a/drivers/net/wireless/ti/wlcore/main.c
> > +++ b/drivers/net/wireless/ti/wlcore/main.c
> > @@ -838,7 +838,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
> >
> > wl1271_info("Reading FW panic log");
> >
> > -   block = kmalloc(wl->fw_mem_block_size, GFP_KERNEL);
> > +   block = kzalloc(wl->fw_mem_block_size, GFP_KERNEL);
> > if (!block)
> > return;
> >
> > @@ -885,7 +885,6 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
> > goto out;
> > }
> > -   memset(block, 0, wl->fw_mem_block_size);
> 
> I don't think you can't remove this line. It appears that the loop
> this is part of resets block to be all zero, reads a chunk of data in,
> then operates on it. I'm guessing that the code after the following
> line expects that there isn't any data left over from previous runs
> through the loop.
>
the rational for this being ok is thta the copy operation into block is: 
ret = wlcore_read_hwaddr(wl, addr, block,
wl->fw_mem_block_size, false);

this will end up in the .read methods where block should be completely 
overwritten (length == full block size), so within the loop if successful
this should be correct - if not successful it would "goto out" witout 
using the content of block.

Am I overlooking something here ?

thx!
hofrat
--
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] wlcore: consolidate kmalloc + memset 0 into kzalloc

2015-12-21 Thread Julian Calaby
Hi Nicholas,

On Tue, Dec 22, 2015 at 6:29 PM, Nicholas Mc Guire  wrote:
> On Tue, Dec 22, 2015 at 09:56:10AM +1100, Julian Calaby wrote:
>> Hi,
>>
>> On Tue, Dec 22, 2015 at 3:47 AM, Nicholas Mc Guire  wrote:
>> > This is an API consolidation only. The use of kmalloc + memset to 0
>> > is equivalent to kzalloc.
>> >
>> > Signed-off-by: Nicholas Mc Guire 
>> > ---
>> >
>> > Found by coccinelle script (relaxed version of
>> > scripts/coccinelle/api/alloc/kzalloc-simple.cocci)
>> >
>> > Patch was compile tested with: x86_64_defconfig +
>> > CONFIG_WL12XX=m (implies CONFIG_WLCORE=m)
>> >
>> > Patch is against linux-next (localversion-next is -next-20151221)
>> >
>> >  drivers/net/wireless/ti/wlcore/main.c | 3 +--
>> >  1 file changed, 1 insertion(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/net/wireless/ti/wlcore/main.c 
>> > b/drivers/net/wireless/ti/wlcore/main.c
>> > index ec7f6af..dfc49bf 100644
>> > --- a/drivers/net/wireless/ti/wlcore/main.c
>> > +++ b/drivers/net/wireless/ti/wlcore/main.c
>> > @@ -838,7 +838,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
>> >
>> > wl1271_info("Reading FW panic log");
>> >
>> > -   block = kmalloc(wl->fw_mem_block_size, GFP_KERNEL);
>> > +   block = kzalloc(wl->fw_mem_block_size, GFP_KERNEL);
>> > if (!block)
>> > return;
>> >
>> > @@ -885,7 +885,6 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
>> > goto out;
>> > }
>> > -   memset(block, 0, wl->fw_mem_block_size);
>>
>> I don't think you can't remove this line. It appears that the loop
>> this is part of resets block to be all zero, reads a chunk of data in,
>> then operates on it. I'm guessing that the code after the following
>> line expects that there isn't any data left over from previous runs
>> through the loop.
>>
> the rational for this being ok is thta the copy operation into block is:
> ret = wlcore_read_hwaddr(wl, addr, block,
> wl->fw_mem_block_size, false);
>
> this will end up in the .read methods where block should be completely
> overwritten (length == full block size), so within the loop if successful
> this should be correct - if not successful it would "goto out" witout
> using the content of block.
>
> Am I overlooking something here ?

It's quite possible I am. I didn't look at the implementation of
wlcore_read_hwaddr() so I'm only guessing that it could do partial
reads.

That said, if it does overwrite the entire buffer each time, then
there's no need to use kzalloc() to allocate the buffer in the first
place.

Either way, it needs a review from someone more familiar with the code.

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
--
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