Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] rtnetlink: allow GSO maximums to be passed to device
From: Stephen Hemminger @ 2017-12-01 20:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger
In-Reply-To: <20171201201158.25594-1-sthemmin@microsoft.com>

Allow GSO maximum segments and size as netlink parameters on input.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 net/core/rtnetlink.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index dabba2a91fc8..8138194c5f81 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1569,6 +1569,8 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
 	[IFLA_PROMISCUITY]	= { .type = NLA_U32 },
 	[IFLA_NUM_TX_QUEUES]	= { .type = NLA_U32 },
 	[IFLA_NUM_RX_QUEUES]	= { .type = NLA_U32 },
+	[IFLA_GSO_MAX_SEGS]	= { .type = NLA_U32 },
+	[IFLA_GSO_MAX_SIZE]	= { .type = NLA_U32 },
 	[IFLA_PHYS_PORT_ID]	= { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
 	[IFLA_CARRIER_CHANGES]	= { .type = NLA_U32 },  /* ignored */
 	[IFLA_PHYS_SWITCH_ID]	= { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
-- 
2.11.0

^ permalink raw reply related

* [PATCH net-next 0/2] allow setting gso_maximum values
From: Stephen Hemminger @ 2017-12-01 20:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

This is another way of addressing the GSO maximum performance issues for
containers on Azure. What happens is that the underlying infrastructure uses
a overlay network such that GSO packets over 64K - vlan header end up cause
either guest or host to have do expensive software copy and fragmentation.

The netvsc driver reports GSO maximum settings correctly, the issue
is that containers on veth devices still have the larger settings.
One solution that was examined was propogating the values back
through the bridge device, but this does not work for cases where
virtual container network is done on L3.

This patch set punts the problem to the orchestration layer that sets
up the container network. It also enables other virtual devices
to have configurable settings for GSO maximum.

Stephen Hemminger (2):
  rtnetlink: allow GSO maximums to be passed to device
  veth: allow configuring GSO maximums

 drivers/net/veth.c   | 20 ++++++++++++++++++++
 net/core/rtnetlink.c |  2 ++
 2 files changed, 22 insertions(+)

-- 
2.11.0

^ permalink raw reply

* Re: [RFC] virtio-net: help live migrate SR-IOV devices
From: Shannon Nelson @ 2017-12-01 20:08 UTC (permalink / raw)
  To: Michael S. Tsirkin, achiad shochat
  Cc: Jason Wang, Jesse Brandeburg, virtualization, Jakub Kicinski,
	Sridhar Samudrala, Achiad, Peter Waskiewicz Jr, Singhai, Anjali,
	Andy Gospodarek, Or Gerlitz, Hannes Frederic Sowa, netdev
In-Reply-To: <20171130155612-mutt-send-email-mst@kernel.org>

On 11/30/2017 6:11 AM, Michael S. Tsirkin wrote:
> On Thu, Nov 30, 2017 at 10:08:45AM +0200, achiad shochat wrote:
>> Re. problem #2:
>> Indeed the best way to address it seems to be to enslave the VF driver
>> netdev under a persistent anchor netdev.
>> And it's indeed desired to allow (but not enforce) PV netdev and VF
>> netdev to work in conjunction.
>> And it's indeed desired that this enslavement logic work out-of-the box.
>> But in case of PV+VF some configurable policies must be in place (and
>> they'd better be generic rather than differ per PV technology).
>> For example - based on which characteristics should the PV+VF coupling
>> be done? netvsc uses MAC address, but that might not always be the
>> desire.
> 
> It's a policy but not guest userspace policy.
> 
> The hypervisor certainly knows.
> 
> Are you concerned that someone might want to create two devices with the
> same MAC for an unrelated reason?  If so, hypervisor could easily set a
> flag in the virtio device to say "this is a backup, use MAC to find
> another device".

This is something I was going to suggest: a flag or other configuration 
on the virtio device to help control how this new feature is used.  I 
can imagine this might be useful to control from either the hypervisor 
side or the VM side.

The hypervisor might want to (1) disable it (force it off), (2) enable 
it for VM choice, or (3) force it on for the VM.  In case (2), the VM 
might be able to chose whether it wants to make use of the feature, or 
stick with the bonding solution.

Either way, the kernel is making a feature available, and the user (VM 
or hypervisor) is able to control it by selecting the feature based on 
the policy desired.

sln

^ permalink raw reply

* Re: [PATCH net-next 00/13] nfp: bpf: jump resolution and memcpy update
From: Daniel Borkmann @ 2017-12-01 20:04 UTC (permalink / raw)
  To: Jakub Kicinski, netdev; +Cc: oss-drivers
In-Reply-To: <20171201053300.17503-1-jakub.kicinski@netronome.com>

On 12/01/2017 06:32 AM, Jakub Kicinski wrote:
> Hi!
> 
> Jiong says:
> 
> Currently, compiler will lower memcpy function call in XDP/eBPF C program
> into a sequence of eBPF load/store pairs for some scenarios.
> 
> Compiler is thinking this "inline" optimiation is beneficial as it could
> avoid function call and also increase code locality.
> 
> However, Netronome NPU is not an tranditional load/store architecture that
> doing a sequence of individual load/store actions are not efficient.
> 
> This patch set tries to identify the load/store sequences composed of
> load/store pairs that comes from memcpy lowering, then accelerates them
> through NPU's Command Push Pull (CPP) instruction.
> 
> This patch set registered an new optimization pass before doing the actual
> JIT work, it traverse through eBPF IR, once found candidate sequence then
> record the memory copy source, destination and length information in the
> first load instruction starting the sequence and marks all remaining
> instructions in the sequence into skipable status. Later, when JITing the
> first load instructoin, optimal instructions will be generated using those
> record information.
> 
> For this safety of this transformation:
> 
>   - jump into the middle of the sequence will cancel the optimization.
> 
>   - overlapped memory access will cancel the optimization.
> 
>   - the load destination register still contains the same value as before
>     the transformation.

Series applied to bpf-next, thanks guys!

^ permalink raw reply

* Re: [PATCH v4 3/8] MIPS: Octeon: Add a global resource manager.
From: David Daney @ 2017-12-01 20:01 UTC (permalink / raw)
  To: Philippe Ombredanne, Greg Kroah-Hartman
  Cc: Carlos Munoz, David Daney, linux-mips, ralf, netdev,
	David S. Miller, Rob Herring, Mark Rutland, devel, LKML,
	Steven J. Hill,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Andrew Lunn, Florian Fainelli, James Hogan
In-Reply-To: <CAOFm3uEy52yog4H_Hco0X+OHF5yiHUZYAHaGz4MefKcYQz3LUg@mail.gmail.com>

On 12/01/2017 11:49 AM, Philippe Ombredanne wrote:
> David, Greg,
> 
> On Fri, Dec 1, 2017 at 6:42 PM, David Daney <ddaney@caviumnetworks.com> wrote:
>> On 11/30/2017 11:53 PM, Philippe Ombredanne wrote:
> [...]
>>>>> --- /dev/null
>>>>> +++ b/arch/mips/cavium-octeon/resource-mgr.c
>>>>> @@ -0,0 +1,371 @@
>>>>> +// SPDX-License-Identifier: GPL-2.0
>>>>> +/*
>>>>> + * Resource manager for Octeon.
>>>>> + *
>>>>> + * This file is subject to the terms and conditions of the GNU General
>>>>> Public
>>>>> + * License.  See the file "COPYING" in the main directory of this
>>>>> archive
>>>>> + * for more details.
>>>>> + *
>>>>> + * Copyright (C) 2017 Cavium, Inc.
>>>>> + */
>>>
>>>
>>> Since you nicely included an SPDX id, you would not need the
>>> boilerplate anymore. e.g. these can go alright?
>>
>>
>> They may not be strictly speaking necessary, but I don't think they hurt
>> anything.  Unless there is a requirement to strip out the license text, we
>> would stick with it as is.
> 
> I think the requirement is there and that would be much better for
> everyone: keeping both is redundant and does not bring any value, does
> it? Instead it kinda removes the benefits of having the SPDX id in the
> first place IMHO.
> 
> Furthermore, as there have been already ~12K+ files cleaned up and
> still over 60K files to go, it would really nice if new files could
> adopt the new style: this way we will not have to revisit and repatch
> them in the future.
> 

I am happy to follow any style Greg would suggest.  There doesn't seem 
to be much documentation about how this should be done yet.

David Daney

^ permalink raw reply

* Re: [PATCH iproute2] iproute2: Fix undeclared __kernel_long_t type build error in RHEL 6.8
From: Michal Kubecek @ 2017-12-01 19:56 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Leon Romanovsky, netdev, Leon Romanovsky, Riad Abo Raed,
	Guy Ergas
In-Reply-To: <20171201084807.0ccfcc86@xeon-e3>

On Fri, Dec 01, 2017 at 08:48:07AM -0800, Stephen Hemminger wrote:
> On Fri,  1 Dec 2017 13:04:51 +0200
> Leon Romanovsky <leon@kernel.org> wrote:
> 
> > From: Leon Romanovsky <leonro@mellanox.com>
> > 
> > Add asm/posix_types.h header file to the list of needed includes,
> > because the headers files in RHEL 6.8 are too old and doesn't
> > have declaration of __kernel_long_t.
> > 
> > In file included from ../include/uapi/linux/kernel.h:5,
> >                  from ../include/uapi/linux/netfilter/x_tables.h:4,
> >                  from ../include/xtables.h:20,
> >                  from em_ipset.c:26:
> > ../include/uapi/linux/sysinfo.h:9: error: expected specifier-qualifier-list before ‘__kernel_long_t’
> > 
> > Cc: Riad Abo Raed <riada@mellanox.com>
> > Cc: Guy Ergas <guye@mellanox.com>
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> 
> I see the problem, but the solution of dragging in posix_types.h
> would be too much of a long term maintenance issue.
> All the headers in uapi are regularly generated from upstream
> kernel headers; I don't want to start making exceptions.
> 
> Is it just the xtables stuff (which has always been problematic)?

Actually, the only place where __kernel_long_t and __kernel_ulong_t
appear is struct sysinfo in include/uapi/linux/sysinfo.h and this
structure isn't even used anywhere in iproute2 source (not even in the
include/uapi/linux/kernel.h file which includes <linux/sysinfo.h>).

So one could work around the problem by defining _LINUX_SYSINFO_H but
that seems a bit dirty hack.

Michal Kubecek

^ permalink raw reply

* [PATCH tip/core/rcu 03/21] drivers/net/ethernet/qlogic/qed: Fix __qed_spq_block() ordering
From: Paul E. McKenney @ 2017-12-01 19:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg,
	Paul E. McKenney, Ariel Elior, everest-linux-l2, netdev
In-Reply-To: <20171201195053.GA23494@linux.vnet.ibm.com>

The __qed_spq_block() function expects an smp_read_barrier_depends()
to order a prior READ_ONCE() against a later load that does not depend
on the prior READ_ONCE(), an expectation that can fail to be met.
This commit therefore replaces the READ_ONCE() with smp_load_acquire()
and removes the smp_read_barrier_depends().

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ariel Elior <Ariel.Elior@cavium.com>
Cc: <everest-linux-l2@cavium.com>
Cc: <netdev@vger.kernel.org>
---
 drivers/net/ethernet/qlogic/qed/qed_spq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_spq.c b/drivers/net/ethernet/qlogic/qed/qed_spq.c
index be48d9abd001..c1237ec58b6c 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_spq.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_spq.c
@@ -97,9 +97,7 @@ static int __qed_spq_block(struct qed_hwfn *p_hwfn,
 
 	while (iter_cnt--) {
 		/* Validate we receive completion update */
-		if (READ_ONCE(comp_done->done) == 1) {
-			/* Read updated FW return value */
-			smp_read_barrier_depends();
+		if (smp_load_acquire(&comp_done->done) == 1) { /* ^^^ */
 			if (p_fw_ret)
 				*p_fw_ret = comp_done->fw_return_code;
 			return 0;
-- 
2.5.2

^ permalink raw reply related

* [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
From: Paul E. McKenney @ 2017-12-01 19:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: tglx, kvm, Michael S. Tsirkin, peterz, fweisbec, jiangshanlai,
	josh, rostedt, oleg, dhowells, edumazet, netdev,
	mathieu.desnoyers, dipankar, akpm, Paul E. McKenney,
	virtualization, mingo
In-Reply-To: <20171201195053.GA23494@linux.vnet.ibm.com>

Because READ_ONCE() now implies read_barrier_depends(), the
read_barrier_depends() in next_desc() is now redundant.  This commit
therefore removes it and the related comments.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: <kvm@vger.kernel.org>
Cc: <virtualization@lists.linux-foundation.org>
Cc: <netdev@vger.kernel.org>
---
 drivers/vhost/vhost.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 33ac2b186b85..78b5940a415a 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1877,12 +1877,7 @@ static unsigned next_desc(struct vhost_virtqueue *vq, struct vring_desc *desc)
 		return -1U;
 
 	/* Check they're not leading us off end of descriptors. */
-	next = vhost16_to_cpu(vq, desc->next);
-	/* Make sure compiler knows to grab that: we don't want it changing! */
-	/* We will use the result as an index in an array, so most
-	 * architectures only need a compiler barrier here. */
-	read_barrier_depends();
-
+	next = vhost16_to_cpu(vq, READ_ONCE(desc->next));
 	return next;
 }
 
-- 
2.5.2

^ permalink raw reply related

* [PATCH tip/core/rcu 14/21] netfilter: Remove now-redundant smp_read_barrier_depends()
From: Paul E. McKenney @ 2017-12-01 19:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg,
	Paul E. McKenney, Pablo Neira Ayuso, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, netfilter-devel, coreteam,
	netdev
In-Reply-To: <20171201195053.GA23494@linux.vnet.ibm.com>

READ_ONCE() now implies smp_read_barrier_depends(), which means that
the instances in arpt_do_table(), ipt_do_table(), and ip6t_do_table()
are now redundant.  This commit removes them and adjusts the comments.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Florian Westphal <fw@strlen.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: <netfilter-devel@vger.kernel.org>
Cc: <coreteam@netfilter.org>
Cc: <netdev@vger.kernel.org>
---
 net/ipv4/netfilter/arp_tables.c | 7 +------
 net/ipv4/netfilter/ip_tables.c  | 7 +------
 net/ipv6/netfilter/ip6_tables.c | 7 +------
 3 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index f88221aebc9d..d242c2d29161 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -202,13 +202,8 @@ unsigned int arpt_do_table(struct sk_buff *skb,
 
 	local_bh_disable();
 	addend = xt_write_recseq_begin();
-	private = table->private;
+	private = READ_ONCE(table->private); /* Address dependency. */
 	cpu     = smp_processor_id();
-	/*
-	 * Ensure we load private-> members after we've fetched the base
-	 * pointer.
-	 */
-	smp_read_barrier_depends();
 	table_base = private->entries;
 	jumpstack  = (struct arpt_entry **)private->jumpstack[cpu];
 
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 4cbe5e80f3bf..46866cc24a84 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -260,13 +260,8 @@ ipt_do_table(struct sk_buff *skb,
 	WARN_ON(!(table->valid_hooks & (1 << hook)));
 	local_bh_disable();
 	addend = xt_write_recseq_begin();
-	private = table->private;
+	private = READ_ONCE(table->private); /* Address dependency. */
 	cpu        = smp_processor_id();
-	/*
-	 * Ensure we load private-> members after we've fetched the base
-	 * pointer.
-	 */
-	smp_read_barrier_depends();
 	table_base = private->entries;
 	jumpstack  = (struct ipt_entry **)private->jumpstack[cpu];
 
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index f06e25065a34..ac1db84722a7 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -282,12 +282,7 @@ ip6t_do_table(struct sk_buff *skb,
 
 	local_bh_disable();
 	addend = xt_write_recseq_begin();
-	private = table->private;
-	/*
-	 * Ensure we load private-> members after we've fetched the base
-	 * pointer.
-	 */
-	smp_read_barrier_depends();
+	private = READ_ONCE(table->private); /* Address dependency. */
 	cpu        = smp_processor_id();
 	table_base = private->entries;
 	jumpstack  = (struct ip6t_entry **)private->jumpstack[cpu];
-- 
2.5.2


^ permalink raw reply related

* Re: [PATCH v4 3/8] MIPS: Octeon: Add a global resource manager.
From: Philippe Ombredanne @ 2017-12-01 19:49 UTC (permalink / raw)
  To: David Daney, Greg Kroah-Hartman
  Cc: Carlos Munoz, David Daney, linux-mips, ralf, netdev,
	David S. Miller, Rob Herring, Mark Rutland, devel, LKML,
	Steven J. Hill,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Andrew Lunn, Florian Fainelli, James Hogan
In-Reply-To: <99dd185d-6e5d-f474-90aa-ebee63045c42@caviumnetworks.com>

David, Greg,

On Fri, Dec 1, 2017 at 6:42 PM, David Daney <ddaney@caviumnetworks.com> wrote:
> On 11/30/2017 11:53 PM, Philippe Ombredanne wrote:
[...]
>>>> --- /dev/null
>>>> +++ b/arch/mips/cavium-octeon/resource-mgr.c
>>>> @@ -0,0 +1,371 @@
>>>> +// SPDX-License-Identifier: GPL-2.0
>>>> +/*
>>>> + * Resource manager for Octeon.
>>>> + *
>>>> + * This file is subject to the terms and conditions of the GNU General
>>>> Public
>>>> + * License.  See the file "COPYING" in the main directory of this
>>>> archive
>>>> + * for more details.
>>>> + *
>>>> + * Copyright (C) 2017 Cavium, Inc.
>>>> + */
>>
>>
>> Since you nicely included an SPDX id, you would not need the
>> boilerplate anymore. e.g. these can go alright?
>
>
> They may not be strictly speaking necessary, but I don't think they hurt
> anything.  Unless there is a requirement to strip out the license text, we
> would stick with it as is.

I think the requirement is there and that would be much better for
everyone: keeping both is redundant and does not bring any value, does
it? Instead it kinda removes the benefits of having the SPDX id in the
first place IMHO.

Furthermore, as there have been already ~12K+ files cleaned up and
still over 60K files to go, it would really nice if new files could
adopt the new style: this way we will not have to revisit and repatch
them in the future.

-- 
Cordially
Philippe Ombredanne

^ permalink raw reply

* Re: Fixing CVE-2017-16939 in v4.4.y and possibly v3.18.y
From: Michal Kubecek @ 2017-12-01 19:48 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: netdev, stable, Greg Kroah-Hartman
In-Reply-To: <20171130183740.GA20343@roeck-us.net>

On Thu, Nov 30, 2017 at 10:37:40AM -0800, Guenter Roeck wrote:
> Hi,
> 
> The fix for CVE-2017-16939 has been applied to v4.9.y, but not to v4.4.y
> and older kernels. However, I confirmed that running the published POC
> (see https://blogs.securiteam.com/index.php/archives/3535) does crash a 4.4
> kernel.
> 
> I confirmed that the following two patches fix the problem in v4.4.y.
> Please consider applying them to v4.4.y (and possibly v3.18.y).
> 
> fc9e50f5a5a4e ("netlink: add a start callback for starting a netlink dump")
> 1137b5e2529a8 ("ipsec: Fix aborted xfrm policy dump crash")
> 
> My apologies for the noise if this is already under consideration.

It's a bit too big hammer. As Nicolai Stange noticed when we were
handling this for SLE12 (where fc9e50f5a5a4e would break kABI), it's
much simpler to use the flag we already have in cb->args[0] to let
xfrm_dump_policy_done() call xfrm_policy_walk_done() only if the walk
structure has been initialized. Thus all you need is the patch below.

Michal Kubecek

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 7a5a64e70b4d..c01c7a7eb4d3 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1655,7 +1655,9 @@ static int xfrm_dump_policy_done(struct netlink_callback *cb)
 	struct xfrm_policy_walk *walk = (struct xfrm_policy_walk *) &cb->args[1];
 	struct net *net = sock_net(cb->skb->sk);
 
-	xfrm_policy_walk_done(walk, net);
+	/* cb->args[0] is set when walk is initialized */
+	if (cb->args[0])
+		xfrm_policy_walk_done(walk, net);
 	return 0;
 }
 

^ permalink raw reply related

* Re: [PATCH] bpf: Fix compile warnings when !CONFIG_BPF_SYSCALL
From: Steven Rostedt @ 2017-12-01 19:48 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Ingo Molnar, Jesper Dangaard Brouer, linux-kernel, netdev
In-Reply-To: <20171201190605.GA21174@ziepe.ca>

On Fri, 1 Dec 2017 12:06:05 -0700
Jason Gunthorpe <jgg@mellanox.com> wrote:

> Such as:
> 
> In file included from ./include/trace/events/xdp.h:10:0,
>                  from ./include/linux/bpf_trace.h:6,
>                  from drivers/net/ethernet/intel/i40e/i40e_txrx.c:29:
> ./include/trace/events/xdp.h:94:17: warning: ‘struct bpf_map’ declared inside parameter list
>     const struct bpf_map *map, u32 map_index),
>                  ^
> 
> By adding a forward declaration for struct bpf_map. In the
> CONFIG_BPF_SYSCALL case the declaration comes in via
> trace/events/bpf.h

This was already fixed:

 http://lkml.kernel.org/r/1512006089-180279-1-git-send-email-xiexiuqi@huawei.com

-- Steve

> 
> Fixes: 59a308967589 ("xdp: separate xdp_redirect tracepoint in map case")
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> ---
>  include/trace/events/xdp.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/trace/events/xdp.h b/include/trace/events/xdp.h
> index 4cd0f05d01134d..36b2a9043189be 100644
> --- a/include/trace/events/xdp.h
> +++ b/include/trace/events/xdp.h
> @@ -9,6 +9,8 @@
>  #include <linux/filter.h>
>  #include <linux/tracepoint.h>
>  
> +struct bpf_map;
> +
>  #define __XDP_ACT_MAP(FN)	\
>  	FN(ABORTED)		\
>  	FN(DROP)		\

^ permalink raw reply

* Re: [PATCH net v2 2/3] xfrm: Add an activate() offload dev op
From: Shannon Nelson @ 2017-12-01 19:47 UTC (permalink / raw)
  To: avivh, Steffen Klassert
  Cc: Herbert Xu, Boris Pismenny, Yossi Kuperman, Yevgeny Kliteynik,
	netdev
In-Reply-To: <1511891742-84759-2-git-send-email-avivh@mellanox.com>

On 11/28/2017 9:55 AM, avivh@mellanox.com wrote:
> From: Aviv Heller <avivh@mellanox.com>
> 
> Adding the state to the offload device prior to replay init in
> xfrm_state_construct() will result in NULL dereference if a matching
> ESP packet is received in between.
> 
> In order to inhibit driver offload logic from processing the state's
> packets prior to the xfrm_state object being completely initialized and
> added to the SADBs, a new activate() operation was added to inform the
> driver the aforementioned conditions have been met.

Are there also conditions where you would want to temporarily 
deactivate, or pause, the incoming driver offload, followed then by 
another activate?

sln

> 
> Signed-off-by: Aviv Heller <avivh@mellanox.com>
> Signed-off-by: Yossi Kuperman <yossiku@mellanox.com>
> ---
> v1 -> v2:
> 	- Separate to state addition and then activation, instead
> 	  of relocating dev state addition call.
> ---
>   include/linux/netdevice.h |  1 +
>   include/net/xfrm.h        | 12 ++++++++++++
>   net/xfrm/xfrm_user.c      |  5 +++++
>   3 files changed, 18 insertions(+)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 2eaac7d..c6ca356 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -819,6 +819,7 @@ struct netdev_xdp {
>   #ifdef CONFIG_XFRM_OFFLOAD
>   struct xfrmdev_ops {
>   	int	(*xdo_dev_state_add) (struct xfrm_state *x);
> +	void	(*xdo_dev_state_activate) (struct xfrm_state *x);
>   	void	(*xdo_dev_state_delete) (struct xfrm_state *x);
>   	void	(*xdo_dev_state_free) (struct xfrm_state *x);
>   	bool	(*xdo_dev_offload_ok) (struct sk_buff *skb,
> diff --git a/include/net/xfrm.h b/include/net/xfrm.h
> index e015e16..324374e 100644
> --- a/include/net/xfrm.h
> +++ b/include/net/xfrm.h
> @@ -1877,6 +1877,14 @@ static inline bool xfrm_dst_offload_ok(struct dst_entry *dst)
>   	return false;
>   }
>   
> +static inline void xfrm_dev_state_activate(struct xfrm_state *x)
> +{
> +	struct xfrm_state_offload *xso = &x->xso;
> +
> +	if (xso->dev && xso->dev->xfrmdev_ops->xdo_dev_state_activate)
> +		xso->dev->xfrmdev_ops->xdo_dev_state_activate(x);
> +}
> +
>   static inline void xfrm_dev_state_delete(struct xfrm_state *x)
>   {
>   	struct xfrm_state_offload *xso = &x->xso;
> @@ -1907,6 +1915,10 @@ static inline int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, stru
>   	return 0;
>   }
>   
> +static inline void xfrm_dev_state_activate(struct xfrm_state *x)
> +{
> +}
> +
>   static inline void xfrm_dev_state_delete(struct xfrm_state *x)
>   {
>   }
> diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> index e44a0fe..d06f579 100644
> --- a/net/xfrm/xfrm_user.c
> +++ b/net/xfrm/xfrm_user.c
> @@ -662,6 +662,11 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
>   		goto out;
>   	}
>   
> +	spin_lock_bh(&x->lock);
> +	if (x->km.state == XFRM_STATE_VALID)
> +		xfrm_dev_state_activate(x);
> +	spin_unlock_bh(&x->lock);
> +
>   	c.seq = nlh->nlmsg_seq;
>   	c.portid = nlh->nlmsg_pid;
>   	c.event = nlh->nlmsg_type;
> 

^ permalink raw reply

* Re: [PATCH] bpf: Fix compile warnings when !CONFIG_BPF_SYSCALL
From: Daniel Borkmann @ 2017-12-01 19:32 UTC (permalink / raw)
  To: Jason Gunthorpe, Steven Rostedt, Ingo Molnar
  Cc: Jesper Dangaard Brouer, linux-kernel, netdev
In-Reply-To: <20171201190605.GA21174@ziepe.ca>

On 12/01/2017 08:06 PM, Jason Gunthorpe wrote:
> Such as:
> 
> In file included from ./include/trace/events/xdp.h:10:0,
>                  from ./include/linux/bpf_trace.h:6,
>                  from drivers/net/ethernet/intel/i40e/i40e_txrx.c:29:
> ./include/trace/events/xdp.h:94:17: warning: ‘struct bpf_map’ declared inside parameter list
>     const struct bpf_map *map, u32 map_index),
>                  ^
> 
> By adding a forward declaration for struct bpf_map. In the
> CONFIG_BPF_SYSCALL case the declaration comes in via
> trace/events/bpf.h
> 
> Fixes: 59a308967589 ("xdp: separate xdp_redirect tracepoint in map case")
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

Thanks! Fixed here already in the bpf tree:

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit/?id=23721a755f98ac846897a013c92cccb281c1bcc8

>  include/trace/events/xdp.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/trace/events/xdp.h b/include/trace/events/xdp.h
> index 4cd0f05d01134d..36b2a9043189be 100644
> --- a/include/trace/events/xdp.h
> +++ b/include/trace/events/xdp.h
> @@ -9,6 +9,8 @@
>  #include <linux/filter.h>
>  #include <linux/tracepoint.h>
>  
> +struct bpf_map;
> +
>  #define __XDP_ACT_MAP(FN)	\
>  	FN(ABORTED)		\
>  	FN(DROP)		\
> 

^ permalink raw reply

* Re: [PATCH net-next 3/3] xfrm: Add ESN support for IPSec HW offload
From: Shannon Nelson @ 2017-12-01 19:23 UTC (permalink / raw)
  To: yossefe, David S. Miller, Steffen Klassert, Herbert Xu, netdev,
	linux-kernel
  Cc: borisp, kliteyn, yossiku
In-Reply-To: <1511862571-3494-3-git-send-email-yossefe@mellanox.com>

On 11/28/2017 1:49 AM, yossefe@mellanox.com wrote:
> From: Yossef Efraim <yossefe@mellanox.com>
> 
> This patch adds ESN support to IPsec device offload.
> Adding new xfrm device operation to synchronize device ESN.
> 
> Signed-off-by: Yossef Efraim <yossefe@mellanox.com>
> ---
>   include/linux/netdevice.h |  1 +
>   include/net/xfrm.h        | 12 ++++++++++++
>   net/xfrm/xfrm_device.c    |  4 ++--
>   net/xfrm/xfrm_replay.c    |  2 ++
>   4 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 7de7656..d4e9198 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -825,6 +825,7 @@ struct xfrmdev_ops {
>   	void	(*xdo_dev_state_free) (struct xfrm_state *x);
>   	bool	(*xdo_dev_offload_ok) (struct sk_buff *skb,
>   				       struct xfrm_state *x);
> +	void	(*xdo_dev_state_advance_esn) (struct xfrm_state *x);
>   };
>   #endif
>   
> diff --git a/include/net/xfrm.h b/include/net/xfrm.h
> index dc28a98..372bfcb 100644
> --- a/include/net/xfrm.h
> +++ b/include/net/xfrm.h
> @@ -1863,6 +1863,14 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
>   		       struct xfrm_user_offload *xuo);
>   bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x);
>   
> +static inline void xfrm_dev_state_advance_esn(struct xfrm_state *x)
> +{
> +	struct xfrm_state_offload *xso = &x->xso;
> +
> +	if (xso->dev && xso->dev->xfrmdev_ops->xdo_dev_state_advance_esn)
> +		xso->dev->xfrmdev_ops->xdo_dev_state_advance_esn(x);

If there isn't an implementation for xdo_dev_state_advance_esn, should 
this even have been called?  See my comment below about checking the 
XFRM_STATE_ESN.

What is the driver expected to do with this?  I would guess that maybe 
the hardware doing the offload needs to know when the ESN is advanced so 
that it can change the ICV calculation accordingly, but that only is 
useful for hardware that knows about ESN.

> +}
> +
>   static inline bool xfrm_dst_offload_ok(struct dst_entry *dst)
>   {
>   	struct xfrm_state *x = dst->xfrm;
> @@ -1920,6 +1928,10 @@ static inline bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x
>   	return false;
>   }
>   
> +static inline void xfrm_dev_state_advance_esn(struct xfrm_state *x)
> +{
> +}
> +
>   static inline bool xfrm_dst_offload_ok(struct dst_entry *dst)
>   {
>   	return false;
> diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
> index dc68d9c..fc7e1e44 100644
> --- a/net/xfrm/xfrm_device.c
> +++ b/net/xfrm/xfrm_device.c
> @@ -65,8 +65,8 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
>   	if (!x->type_offload)
>   		return -EINVAL;
>   
> -	/* We don't yet support UDP encapsulation, TFC padding and ESN. */
> -	if (x->encap || x->tfcpad || (x->props.flags & XFRM_STATE_ESN))
> +	/* We don't yet support UDP encapsulation and TFC padding. */
> +	if (x->encap || x->tfcpad)
>   		return -EINVAL;

Maybe we should check to see that xdo_dev_state_advance_esn is 
implemented before allowing XFRM_STATE_ESN?

sln

>   
>   	dev = dev_get_by_index(net, xuo->ifindex);
> diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
> index 0250181..1d38c6a 100644
> --- a/net/xfrm/xfrm_replay.c
> +++ b/net/xfrm/xfrm_replay.c
> @@ -551,6 +551,8 @@ static void xfrm_replay_advance_esn(struct xfrm_state *x, __be32 net_seq)
>   			bitnr = replay_esn->replay_window - (diff - pos);
>   	}
>   
> +	xfrm_dev_state_advance_esn(x);
> +
>   	nr = bitnr >> 5;
>   	bitnr = bitnr & 0x1F;
>   	replay_esn->bmp[nr] |= (1U << bitnr);
> 

^ permalink raw reply

* Re: [PATCH net-next 3/3] xfrm: Add ESN support for IPSec HW offload
From: Shannon Nelson @ 2017-12-01 19:23 UTC (permalink / raw)
  To: Steffen Klassert, yossefe
  Cc: David S. Miller, Herbert Xu, netdev, linux-kernel, borisp,
	kliteyn, yossiku
In-Reply-To: <20171201062321.dt3jbrfs4svwpgqx@gauss3.secunet.de>

On 11/30/2017 10:23 PM, Steffen Klassert wrote:
> On Tue, Nov 28, 2017 at 11:49:30AM +0200, yossefe@mellanox.com wrote:
>> From: Yossef Efraim <yossefe@mellanox.com>
>>
>> This patch adds ESN support to IPsec device offload.
>> Adding new xfrm device operation to synchronize device ESN.
>>
>> Signed-off-by: Yossef Efraim <yossefe@mellanox.com>
>> ---
>>   include/linux/netdevice.h |  1 +
>>   include/net/xfrm.h        | 12 ++++++++++++
>>   net/xfrm/xfrm_device.c    |  4 ++--
>>   net/xfrm/xfrm_replay.c    |  2 ++
>>   4 files changed, 17 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>> index 7de7656..d4e9198 100644
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -825,6 +825,7 @@ struct xfrmdev_ops {
>>   	void	(*xdo_dev_state_free) (struct xfrm_state *x);
>>   	bool	(*xdo_dev_offload_ok) (struct sk_buff *skb,
>>   				       struct xfrm_state *x);
>> +	void	(*xdo_dev_state_advance_esn) (struct xfrm_state *x);
> 
> We now have a documentation for the xfrm offloadin API in the
> ipsec-next tree. Please document the new device operation
> there and resubmit.

Please be sure to specify what the offloading driver is expected to do 
with this.

sln

> 
> Thanks!
> 

^ permalink raw reply

* Re: [PATCH 1/1] phy: Add 2.5G SGMII interface mode
From: Andrew Lunn @ 2017-12-01 19:12 UTC (permalink / raw)
  To: Bhaskar Upadhaya
  Cc: Russell King - ARM Linux, netdev@vger.kernel.org,
	davem@davemloft.net, linux-arm-kernel@lists.infradead.org
In-Reply-To: <AM3PR04MB449A2C7FDF78431360961E48C390@AM3PR04MB449.eurprd04.prod.outlook.com>

> So do we need to introduce a new interface type
> PHY_INTERFACE_MODE_2500SGMII or is there a way to deal with 2.5G
> SGMII ?

And just adding to what Florian said, you don't just add a new define
like this, you also need to add a user of it. Posting your MAC and PHY
driver making use of this symbol will make it a lot clearer why it is
needed and how it should be used.

       Andrew

^ permalink raw reply

* [PATCH] bpf: Fix compile warnings when !CONFIG_BPF_SYSCALL
From: Jason Gunthorpe @ 2017-12-01 19:06 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar; +Cc: Jesper Dangaard Brouer, linux-kernel, netdev

Such as:

In file included from ./include/trace/events/xdp.h:10:0,
                 from ./include/linux/bpf_trace.h:6,
                 from drivers/net/ethernet/intel/i40e/i40e_txrx.c:29:
./include/trace/events/xdp.h:94:17: warning: ‘struct bpf_map’ declared inside parameter list
    const struct bpf_map *map, u32 map_index),
                 ^

By adding a forward declaration for struct bpf_map. In the
CONFIG_BPF_SYSCALL case the declaration comes in via
trace/events/bpf.h

Fixes: 59a308967589 ("xdp: separate xdp_redirect tracepoint in map case")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
 include/trace/events/xdp.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/trace/events/xdp.h b/include/trace/events/xdp.h
index 4cd0f05d01134d..36b2a9043189be 100644
--- a/include/trace/events/xdp.h
+++ b/include/trace/events/xdp.h
@@ -9,6 +9,8 @@
 #include <linux/filter.h>
 #include <linux/tracepoint.h>
 
+struct bpf_map;
+
 #define __XDP_ACT_MAP(FN)	\
 	FN(ABORTED)		\
 	FN(DROP)		\
-- 
2.7.4

^ permalink raw reply related

* [PATCH net-next 2/6] hv_netvsc: don't need local xmit_more
From: Stephen Hemminger @ 2017-12-01 19:01 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev
In-Reply-To: <20171201190149.22683-1-sthemmin@microsoft.com>

Since skb is always non-NULL in the copy portion of netvsc_send
do not need local variable.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/netvsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index bfc79698b8f4..ee31faa67cad 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -848,7 +848,6 @@ int netvsc_send(struct net_device_context *ndev_ctx,
 	struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL;
 	struct sk_buff *msd_skb = NULL;
 	bool try_batch;
-	bool xmit_more = (skb != NULL) ? skb->xmit_more : false;
 
 	/* If device is rescinded, return error and packet will get dropped. */
 	if (unlikely(!net_device || net_device->destroy))
@@ -922,7 +921,7 @@ int netvsc_send(struct net_device_context *ndev_ctx,
 		if (msdp->skb)
 			dev_consume_skb_any(msdp->skb);
 
-		if (xmit_more && !packet->cp_partial) {
+		if (skb->xmit_more && !packet->cp_partial) {
 			msdp->skb = skb;
 			msdp->pkt = packet;
 			msdp->count++;
-- 
2.11.0

^ permalink raw reply related

* [PATCH net-next 0/6] hv_netvsc: minor optimizations
From: Stephen Hemminger @ 2017-12-01 19:01 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev

These are a set of local optimizations the Hyper-V networking driver.
Also include a vmbus patch in this set, because it depends on the
netvsc that last used that function.

Stephen Hemminger (6):
  hv_netvsc: drop unused macros
  hv_netvsc: don't need local xmit_more
  hv_netvsc: replace divide with mask when computing padding
  hv_netvsc: use reciprocal divide to speed up percent calculation
  hv_netvsc: optimize initialization of RNDIS header
  vmbus: make hv_get_ringbuffer_availbytes local

 drivers/hv/ring_buffer.c          | 23 ++++++++++++
 drivers/net/hyperv/hyperv_net.h   | 32 ++---------------
 drivers/net/hyperv/netvsc.c       | 26 ++++++--------
 drivers/net/hyperv/netvsc_drv.c   | 74 ++++++++++++++++++---------------------
 drivers/net/hyperv/rndis_filter.c |  4 +--
 include/linux/hyperv.h            | 22 ------------
 6 files changed, 73 insertions(+), 108 deletions(-)

-- 
2.11.0

^ permalink raw reply

* [PATCH net-next 6/6] vmbus: make hv_get_ringbuffer_availbytes local
From: Stephen Hemminger @ 2017-12-01 19:01 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev
In-Reply-To: <20171201190149.22683-1-sthemmin@microsoft.com>

The last use of hv_get_ringbuffer_availbytes in drivers is now
gone. Only used by the debug info routine so make it static. Also, add
READ_ONCE() to avoid any possible issues with potentially volatile
index values.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/hv/ring_buffer.c | 23 +++++++++++++++++++++++
 include/linux/hyperv.h   | 22 ----------------------
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 12eb8caa4263..50e071444a5c 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -140,6 +140,29 @@ static u32 hv_copyto_ringbuffer(
 	return start_write_offset;
 }
 
+/*
+ *
+ * hv_get_ringbuffer_availbytes()
+ *
+ * Get number of bytes available to read and to write to
+ * for the specified ring buffer
+ */
+static void
+hv_get_ringbuffer_availbytes(const struct hv_ring_buffer_info *rbi,
+			     u32 *read, u32 *write)
+{
+	u32 read_loc, write_loc, dsize;
+
+	/* Capture the read/write indices before they changed */
+	read_loc = READ_ONCE(rbi->ring_buffer->read_index);
+	write_loc = READ_ONCE(rbi->ring_buffer->write_index);
+	dsize = rbi->ring_datasize;
+
+	*write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
+		read_loc - write_loc;
+	*read = dsize - *write;
+}
+
 /* Get various debug metrics for the specified ring buffer. */
 void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
 				 struct hv_ring_buffer_debug_info *debug_info)
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index f3e97c5f94c9..5f8bd0cebddf 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -127,28 +127,6 @@ struct hv_ring_buffer_info {
 	u32 priv_read_index;
 };
 
-/*
- *
- * hv_get_ringbuffer_availbytes()
- *
- * Get number of bytes available to read and to write to
- * for the specified ring buffer
- */
-static inline void
-hv_get_ringbuffer_availbytes(const struct hv_ring_buffer_info *rbi,
-			     u32 *read, u32 *write)
-{
-	u32 read_loc, write_loc, dsize;
-
-	/* Capture the read/write indices before they changed */
-	read_loc = rbi->ring_buffer->read_index;
-	write_loc = rbi->ring_buffer->write_index;
-	dsize = rbi->ring_datasize;
-
-	*write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
-		read_loc - write_loc;
-	*read = dsize - *write;
-}
 
 static inline u32 hv_get_bytes_to_read(const struct hv_ring_buffer_info *rbi)
 {
-- 
2.11.0

^ permalink raw reply related

* [PATCH net-next 5/6] hv_netvsc: optimize initialization of RNDIS header
From: Stephen Hemminger @ 2017-12-01 19:01 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev
In-Reply-To: <20171201190149.22683-1-sthemmin@microsoft.com>

The memset of the whole maximum possible RNDIS header is unnecessary.
For the main part of the header use a structure assignment.

No need to memset the whole per packet info. Instead rely on caller to
set what it wants. Also get rid of cast to void and signed/unsigned
conversion. Now return pointer to per packet data (rather than the
header) which simplifies use by code setting up the packet data.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c | 57 +++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 31 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index ba690e1737ab..dc70de674ca9 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -177,17 +177,15 @@ static int netvsc_close(struct net_device *net)
 	return ret;
 }
 
-static void *init_ppi_data(struct rndis_message *msg, u32 ppi_size,
-			   int pkt_type)
+static inline void *init_ppi_data(struct rndis_message *msg,
+				  u32 ppi_size, u32 pkt_type)
 {
-	struct rndis_packet *rndis_pkt;
+	struct rndis_packet *rndis_pkt = &msg->msg.pkt;
 	struct rndis_per_packet_info *ppi;
 
-	rndis_pkt = &msg->msg.pkt;
 	rndis_pkt->data_offset += ppi_size;
-
-	ppi = (struct rndis_per_packet_info *)((void *)rndis_pkt +
-		rndis_pkt->per_pkt_info_offset + rndis_pkt->per_pkt_info_len);
+	ppi = (void *)rndis_pkt + rndis_pkt->per_pkt_info_offset
+		+ rndis_pkt->per_pkt_info_len;
 
 	ppi->size = ppi_size;
 	ppi->type = pkt_type;
@@ -195,7 +193,7 @@ static void *init_ppi_data(struct rndis_message *msg, u32 ppi_size,
 
 	rndis_pkt->per_pkt_info_len += ppi_size;
 
-	return ppi;
+	return ppi + 1;
 }
 
 /* Azure hosts don't support non-TCP port numbers in hashing for fragmented
@@ -472,10 +470,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 	int ret;
 	unsigned int num_data_pgs;
 	struct rndis_message *rndis_msg;
-	struct rndis_packet *rndis_pkt;
 	struct net_device *vf_netdev;
 	u32 rndis_msg_size;
-	struct rndis_per_packet_info *ppi;
 	u32 hash;
 	struct hv_page_buffer pb[MAX_PAGE_BUFFER_COUNT];
 
@@ -530,34 +526,36 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 
 	rndis_msg = (struct rndis_message *)skb->head;
 
-	memset(rndis_msg, 0, RNDIS_AND_PPI_SIZE);
-
 	/* Add the rndis header */
 	rndis_msg->ndis_msg_type = RNDIS_MSG_PACKET;
 	rndis_msg->msg_len = packet->total_data_buflen;
-	rndis_pkt = &rndis_msg->msg.pkt;
-	rndis_pkt->data_offset = sizeof(struct rndis_packet);
-	rndis_pkt->data_len = packet->total_data_buflen;
-	rndis_pkt->per_pkt_info_offset = sizeof(struct rndis_packet);
+
+	rndis_msg->msg.pkt = (struct rndis_packet) {
+		.data_offset = sizeof(struct rndis_packet),
+		.data_len = packet->total_data_buflen,
+		.per_pkt_info_offset = sizeof(struct rndis_packet),
+	};
 
 	rndis_msg_size = RNDIS_MESSAGE_SIZE(struct rndis_packet);
 
 	hash = skb_get_hash_raw(skb);
 	if (hash != 0 && net->real_num_tx_queues > 1) {
+		u32 *hash_info;
+
 		rndis_msg_size += NDIS_HASH_PPI_SIZE;
-		ppi = init_ppi_data(rndis_msg, NDIS_HASH_PPI_SIZE,
-				    NBL_HASH_VALUE);
-		*(u32 *)((void *)ppi + ppi->ppi_offset) = hash;
+		hash_info = init_ppi_data(rndis_msg, NDIS_HASH_PPI_SIZE,
+					  NBL_HASH_VALUE);
+		*hash_info = hash;
 	}
 
 	if (skb_vlan_tag_present(skb)) {
 		struct ndis_pkt_8021q_info *vlan;
 
 		rndis_msg_size += NDIS_VLAN_PPI_SIZE;
-		ppi = init_ppi_data(rndis_msg, NDIS_VLAN_PPI_SIZE,
-				    IEEE_8021Q_INFO);
+		vlan = init_ppi_data(rndis_msg, NDIS_VLAN_PPI_SIZE,
+				     IEEE_8021Q_INFO);
 
-		vlan = (void *)ppi + ppi->ppi_offset;
+		vlan->value = 0;
 		vlan->vlanid = skb->vlan_tci & VLAN_VID_MASK;
 		vlan->pri = (skb->vlan_tci & VLAN_PRIO_MASK) >>
 				VLAN_PRIO_SHIFT;
@@ -567,11 +565,10 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 		struct ndis_tcp_lso_info *lso_info;
 
 		rndis_msg_size += NDIS_LSO_PPI_SIZE;
-		ppi = init_ppi_data(rndis_msg, NDIS_LSO_PPI_SIZE,
-				    TCP_LARGESEND_PKTINFO);
-
-		lso_info = (void *)ppi + ppi->ppi_offset;
+		lso_info = init_ppi_data(rndis_msg, NDIS_LSO_PPI_SIZE,
+					 TCP_LARGESEND_PKTINFO);
 
+		lso_info->value = 0;
 		lso_info->lso_v2_transmit.type = NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE;
 		if (skb->protocol == htons(ETH_P_IP)) {
 			lso_info->lso_v2_transmit.ip_version =
@@ -596,12 +593,10 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 			struct ndis_tcp_ip_checksum_info *csum_info;
 
 			rndis_msg_size += NDIS_CSUM_PPI_SIZE;
-			ppi = init_ppi_data(rndis_msg, NDIS_CSUM_PPI_SIZE,
-					    TCPIP_CHKSUM_PKTINFO);
-
-			csum_info = (struct ndis_tcp_ip_checksum_info *)((void *)ppi +
-									 ppi->ppi_offset);
+			csum_info = init_ppi_data(rndis_msg, NDIS_CSUM_PPI_SIZE,
+						  TCPIP_CHKSUM_PKTINFO);
 
+			csum_info->value = 0;
 			csum_info->transmit.tcp_header_offset = skb_transport_offset(skb);
 
 			if (skb->protocol == htons(ETH_P_IP)) {
-- 
2.11.0

^ permalink raw reply related

* [PATCH net-next 4/6] hv_netvsc: use reciprocal divide to speed up percent calculation
From: Stephen Hemminger @ 2017-12-01 19:01 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev
In-Reply-To: <20171201190149.22683-1-sthemmin@microsoft.com>

Every packet sent checks the available ring space. The calculation
can be sped up by using reciprocal divide which is multiplication.

Since ring_size can only be configured by module parameter, so it doesn't
have to be passed around everywhere. Also it should be unsigned
since it is number of pages.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/hyperv_net.h   |  6 +++---
 drivers/net/hyperv/netvsc.c       | 20 +++++++-------------
 drivers/net/hyperv/netvsc_drv.c   | 17 +++++++++--------
 drivers/net/hyperv/rndis_filter.c |  4 ++--
 4 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 7226230561de..3d940c67ea94 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -146,7 +146,6 @@ struct hv_netvsc_packet {
 
 struct netvsc_device_info {
 	unsigned char mac_adr[ETH_ALEN];
-	int  ring_size;
 	u32  num_chn;
 	u32  send_sections;
 	u32  recv_sections;
@@ -188,6 +187,9 @@ struct rndis_message;
 struct netvsc_device;
 struct net_device_context;
 
+extern u32 netvsc_ring_bytes;
+extern struct reciprocal_value netvsc_ring_reciprocal;
+
 struct netvsc_device *netvsc_device_add(struct hv_device *device,
 					const struct netvsc_device_info *info);
 int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx);
@@ -804,8 +806,6 @@ struct netvsc_device {
 
 	struct rndis_device *extension;
 
-	int ring_size;
-
 	u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
 	u32 pkt_align; /* alignment bytes, e.g. 8 */
 
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 4b931f017a25..e4bcd202a56a 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -31,6 +31,7 @@
 #include <linux/vmalloc.h>
 #include <linux/rtnetlink.h>
 #include <linux/prefetch.h>
+#include <linux/reciprocal_div.h>
 
 #include <asm/sync_bitops.h>
 
@@ -588,14 +589,11 @@ void netvsc_device_remove(struct hv_device *device)
  * Get the percentage of available bytes to write in the ring.
  * The return value is in range from 0 to 100.
  */
-static inline u32 hv_ringbuf_avail_percent(
-		struct hv_ring_buffer_info *ring_info)
+static u32 hv_ringbuf_avail_percent(const struct hv_ring_buffer_info *ring_info)
 {
-	u32 avail_read, avail_write;
+	u32 avail_write = hv_get_bytes_to_write(ring_info);
 
-	hv_get_ringbuffer_availbytes(ring_info, &avail_read, &avail_write);
-
-	return avail_write * 100 / ring_info->ring_datasize;
+	return reciprocal_divide(avail_write  * 100, netvsc_ring_reciprocal);
 }
 
 static inline void netvsc_free_send_slot(struct netvsc_device *net_device,
@@ -1249,7 +1247,6 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
 				const struct netvsc_device_info *device_info)
 {
 	int i, ret = 0;
-	int ring_size = device_info->ring_size;
 	struct netvsc_device *net_device;
 	struct net_device *ndev = hv_get_drvdata(device);
 	struct net_device_context *net_device_ctx = netdev_priv(ndev);
@@ -1261,8 +1258,6 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
 	for (i = 0; i < VRSS_SEND_TAB_SIZE; i++)
 		net_device_ctx->tx_table[i] = 0;
 
-	net_device->ring_size = ring_size;
-
 	/* Because the device uses NAPI, all the interrupt batching and
 	 * control is done via Net softirq, not the channel handling
 	 */
@@ -1289,10 +1284,9 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
 		       netvsc_poll, NAPI_POLL_WEIGHT);
 
 	/* Open the channel */
-	ret = vmbus_open(device->channel, ring_size * PAGE_SIZE,
-			 ring_size * PAGE_SIZE, NULL, 0,
-			 netvsc_channel_cb,
-			 net_device->chan_table);
+	ret = vmbus_open(device->channel, netvsc_ring_bytes,
+			 netvsc_ring_bytes,  NULL, 0,
+			 netvsc_channel_cb, net_device->chan_table);
 
 	if (ret != 0) {
 		netif_napi_del(&net_device->chan_table[0].napi);
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 5129647d420c..ba690e1737ab 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -35,6 +35,7 @@
 #include <linux/slab.h>
 #include <linux/rtnetlink.h>
 #include <linux/netpoll.h>
+#include <linux/reciprocal_div.h>
 
 #include <net/arp.h>
 #include <net/route.h>
@@ -54,9 +55,11 @@
 #define LINKCHANGE_INT (2 * HZ)
 #define VF_TAKEOVER_INT (HZ / 10)
 
-static int ring_size = 128;
-module_param(ring_size, int, S_IRUGO);
+static unsigned int ring_size __ro_after_init = 128;
+module_param(ring_size, uint, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
+unsigned int netvsc_ring_bytes __ro_after_init;
+struct reciprocal_value netvsc_ring_reciprocal __ro_after_init;
 
 static const u32 default_msg = NETIF_MSG_DRV | NETIF_MSG_PROBE |
 				NETIF_MSG_LINK | NETIF_MSG_IFUP |
@@ -860,7 +863,6 @@ static int netvsc_set_channels(struct net_device *net,
 
 	memset(&device_info, 0, sizeof(device_info));
 	device_info.num_chn = count;
-	device_info.ring_size = ring_size;
 	device_info.send_sections = nvdev->send_section_cnt;
 	device_info.send_section_size = nvdev->send_section_size;
 	device_info.recv_sections = nvdev->recv_section_cnt;
@@ -975,7 +977,6 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 		rndis_filter_close(nvdev);
 
 	memset(&device_info, 0, sizeof(device_info));
-	device_info.ring_size = ring_size;
 	device_info.num_chn = nvdev->num_chn;
 	device_info.send_sections = nvdev->send_section_cnt;
 	device_info.send_section_size = nvdev->send_section_size;
@@ -1539,7 +1540,6 @@ static int netvsc_set_ringparam(struct net_device *ndev,
 
 	memset(&device_info, 0, sizeof(device_info));
 	device_info.num_chn = nvdev->num_chn;
-	device_info.ring_size = ring_size;
 	device_info.send_sections = new_tx;
 	device_info.send_section_size = nvdev->send_section_size;
 	device_info.recv_sections = new_rx;
@@ -1995,7 +1995,6 @@ static int netvsc_probe(struct hv_device *dev,
 
 	/* Notify the netvsc driver of the new device */
 	memset(&device_info, 0, sizeof(device_info));
-	device_info.ring_size = ring_size;
 	device_info.num_chn = VRSS_CHANNEL_DEFAULT;
 	device_info.send_sections = NETVSC_DEFAULT_TX;
 	device_info.send_section_size = NETVSC_SEND_SECTION_SIZE;
@@ -2158,11 +2157,13 @@ static int __init netvsc_drv_init(void)
 
 	if (ring_size < RING_SIZE_MIN) {
 		ring_size = RING_SIZE_MIN;
-		pr_info("Increased ring_size to %d (min allowed)\n",
+		pr_info("Increased ring_size to %u (min allowed)\n",
 			ring_size);
 	}
-	ret = vmbus_driver_register(&netvsc_drv);
+	netvsc_ring_bytes = ring_size * PAGE_SIZE;
+	netvsc_ring_reciprocal = reciprocal_value(netvsc_ring_bytes);
 
+	ret = vmbus_driver_register(&netvsc_drv);
 	if (ret)
 		return ret;
 
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 7b637c7dd1e5..673492063307 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -1040,8 +1040,8 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
 	/* Set the channel before opening.*/
 	nvchan->channel = new_sc;
 
-	ret = vmbus_open(new_sc, nvscdev->ring_size * PAGE_SIZE,
-			 nvscdev->ring_size * PAGE_SIZE, NULL, 0,
+	ret = vmbus_open(new_sc, netvsc_ring_bytes,
+			 netvsc_ring_bytes, NULL, 0,
 			 netvsc_channel_cb, nvchan);
 	if (ret == 0)
 		napi_enable(&nvchan->napi);
-- 
2.11.0

^ permalink raw reply related

* [PATCH net-next 3/6] hv_netvsc: replace divide with mask when computing padding
From: Stephen Hemminger @ 2017-12-01 19:01 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev
In-Reply-To: <20171201190149.22683-1-sthemmin@microsoft.com>

Packet alignment is always a power of 2 therefore modulus can
be replaced with a faster and operation

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/netvsc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index ee31faa67cad..4b931f017a25 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -712,11 +712,12 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
 	int i;
 	u32 msg_size = 0;
 	u32 padding = 0;
-	u32 remain = packet->total_data_buflen % net_device->pkt_align;
 	u32 page_count = packet->cp_partial ? packet->rmsg_pgcnt :
 		packet->page_buf_cnt;
+	u32 remain;
 
 	/* Add padding */
+	remain = packet->total_data_buflen & (net_device->pkt_align - 1);
 	if (skb->xmit_more && remain && !packet->cp_partial) {
 		padding = net_device->pkt_align - remain;
 		rndis_msg->msg_len += padding;
-- 
2.11.0

^ permalink raw reply related

* [PATCH net-next 1/6] hv_netvsc: drop unused macros
From: Stephen Hemminger @ 2017-12-01 19:01 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev
In-Reply-To: <20171201190149.22683-1-sthemmin@microsoft.com>

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/hyperv_net.h | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 88ddfb92122b..7226230561de 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -1425,32 +1425,6 @@ struct rndis_message {
 	(sizeof(msg) + (sizeof(struct rndis_message) -	\
 	 sizeof(union rndis_message_container)))
 
-/* get pointer to info buffer with message pointer */
-#define MESSAGE_TO_INFO_BUFFER(msg)				\
-	(((unsigned char *)(msg)) + msg->info_buf_offset)
-
-/* get pointer to status buffer with message pointer */
-#define MESSAGE_TO_STATUS_BUFFER(msg)			\
-	(((unsigned char *)(msg)) + msg->status_buf_offset)
-
-/* get pointer to OOBD buffer with message pointer */
-#define MESSAGE_TO_OOBD_BUFFER(msg)				\
-	(((unsigned char *)(msg)) + msg->oob_data_offset)
-
-/* get pointer to data buffer with message pointer */
-#define MESSAGE_TO_DATA_BUFFER(msg)				\
-	(((unsigned char *)(msg)) + msg->per_pkt_info_offset)
-
-/* get pointer to contained message from NDIS_MESSAGE pointer */
-#define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_msg)		\
-	((void *) &rndis_msg->msg)
-
-/* get pointer to contained message from NDIS_MESSAGE pointer */
-#define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_msg)	\
-	((void *) rndis_msg)
-
-
-
 #define RNDIS_HEADER_SIZE	(sizeof(struct rndis_message) - \
 				 sizeof(union rndis_message_container))
 
-- 
2.11.0

^ permalink raw reply related


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