Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree"
From: David Miller @ 2014-11-21 20:16 UTC (permalink / raw)
  To: elfring
  Cc: j.dumon, linux-usb, netdev, linux-kernel, kernel-janitors,
	julia.lawall
In-Reply-To: <546E05C0.9030703@users.sourceforge.net>

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:16:16 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 16:11:56 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply

* Re: [PATCH 1/2] net/am2150: fix nmclan_cs.c shared interrupt handling
From: David Miller @ 2014-11-21 20:17 UTC (permalink / raw)
  To: arnd; +Cc: netdev, jeffrey.t.kirsher, rpao, linux-kernel, linux-pcmcia
In-Reply-To: <4353896.15JnC91eLO@wuerfel>

From: Arnd Bergmann <arnd@arndb.de>
Date: Thu, 20 Nov 2014 16:11:14 +0100

> A recent patch tried to work around a valid warning for the use of a
> deprecated interface by blindly changing from the old
> pcmcia_request_exclusive_irq() interface to pcmcia_request_irq().
> 
> This driver has an interrupt handler that is not currently aware
> of shared interrupts, but can be easily converted to be.
> At the moment, the driver reads the interrupt status register
> repeatedly until it contains only zeroes in the interesting bits,
> and handles each bit individually.
> 
> This patch adds the missing part of returning IRQ_NONE in case none
> of the bits are set to start with, so we can move on to the next
> interrupt source.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 5f5316fcd08ef7 ("am2150: Update nmclan_cs.c to use update PCMCIA API")
> ---
> I had this patch in my queue of things to submit and noticed that
> the warning had gone away upstream but my patch was still there.
> 
> For all I can tell, the driver is broken without this, although it
> would rarely be a problem.

I'm happy for this to go alongside patch #2 via another tree:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH net-next v1 0/8] amd-xgbe: AMD XGBE driver updates 2014-11-20
From: David Miller @ 2014-11-21 20:20 UTC (permalink / raw)
  To: thomas.lendacky; +Cc: netdev
In-Reply-To: <20141120170320.15397.10583.stgit@tlendack-t1.amdoffice.net>

From: Tom Lendacky <thomas.lendacky@amd.com>
Date: Thu, 20 Nov 2014 11:03:20 -0600

> The following series of patches includes functional updates to the
> driver as well as some trivial changes.
> 
> - Add a read memory barrier in the Tx and Rx path after checking the
>   descriptor ownership bit
> - Wait for the Tx engine to stop/suspend before issuing a stop command
> - Implement a smatch tool suggestion to simplify an if statement
> - Separate out Tx and Rx ring data fields into their own structures
> - Add BQL support
> - Remove an unused variable
> - Change Tx coalescing support to operate on packet basis instead of
>   a descriptor basis
> - Add support for the skb->xmit_more flag
> 
> This patch series is based on net-next.

Lots of great stuff in here, series applied, thanks Tom.

^ permalink raw reply

* Re: [net-next v2 00/15][pull request] Intel Wired LAN Driver Updates 2014-11-20
From: David Miller @ 2014-11-21 20:24 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, nhorman, sassmann, jogreene
In-Reply-To: <1416524953-15161-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Thu, 20 Nov 2014 15:08:58 -0800

> This series contains updates to ixgbevf, i40e and i40evf.
...
> The following are changes since commit daaf427c6ab392bedcd018e326b2ffa1e1110cd6:
>   bpf: fix arraymap NULL deref and missing overflow and zero size checks
> and are available in the git repository at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next master

Pulled, thanks Jeff.

^ permalink raw reply

* Re: [PATCH v2 net] net: Revert "net: avoid one atomic operation in skb_clone()"
From: David Miller @ 2014-11-21 20:27 UTC (permalink / raw)
  To: eric.dumazet; +Cc: sd, clm, netdev
In-Reply-To: <1416599236.8629.124.camel@edumazet-glaptop2.roam.corp.google.com>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 21 Nov 2014 11:47:16 -0800

> From: Eric Dumazet <edumazet@google.com>
> 
> Not sure what I was thinking, but doing anything after
> releasing a refcount is suicidal or/and embarrassing.
> 
> By the time we set skb->fclone to SKB_FCLONE_FREE, another cpu
> could have released last reference and freed whole skb.
> 
> We potentially corrupt memory or trap if CONFIG_DEBUG_PAGEALLOC is set.
> 
> Reported-by: Chris Mason <clm@fb.com>
> Fixes: ce1a4ea3f1258 ("net: avoid one atomic operation in skb_clone()")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Sabrina Dubroca <sd@queasysnail.net>
> ---
> v2: the revert went wrong, as SKB_FCLONE_UNAVAILABLE
>     was later replaced by SKB_FCLONE_FREE, spotted by Sabrina Dubroca

Applied, thanks Eric.

^ permalink raw reply

* Re: [PATCH] tcp: Restore RFC5961-compliant behavior for SYN packets
From: David Miller @ 2014-11-21 20:34 UTC (permalink / raw)
  To: eric.dumazet
  Cc: calvinowens, kuznet, jmorris, edumazet, kernel-team, netdev,
	linux-kernel
In-Reply-To: <1416536527.8629.74.camel@edumazet-glaptop2.roam.corp.google.com>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 20 Nov 2014 18:22:07 -0800

> On Thu, 2014-11-20 at 17:47 -0800, Calvin Owens wrote:
> 
>> That's actually not what led to finding this, but it's a good point. :)
>> 
>> What if the challenge-ACK counter were decremented in tcp_validate_incoming()
>> when a valid RST packet is seen? That would allow legitimate remote
>> hosts to reestablish connections without being ratelimited, and still
>> prevent a malicious host from guessing sequence numbers.
>> 
>> There would need to be a way to tell if a challenge ACK had in fact been
>> sent and only decrement in that case, since otherwise a local attacker
>> could establish and immediately reset lots of connections to keep the
>> counter below the ratelimit threshold and guess sequence numbers.
>> 
>> Simply adding a flag to struct tcp_sock would work: just set the flag
>> whenever a challenge ACK is sent, and clear it and decrement the counter
>> only if it is set when a valid RST packet is seen.
> 
> Seems tricky, a Challenge ACK do not necessarily gives an RST.
> 
> Anyway this certainly can wait, as we already have a sysctl to
> eventually work around the issue.
> 
> Acked-by: Eric Dumazet <edumazet@google.com>

Applied, thanks everyone.

^ permalink raw reply

* Re: [PATCH net-next] vlan: Pass ethtool get_ts_info queries to real device.
From: David Miller @ 2014-11-21 20:36 UTC (permalink / raw)
  To: richardcochran; +Cc: netdev, stefan.sorensen
In-Reply-To: <1416575780-19132-1-git-send-email-richardcochran@gmail.com>

From: Richard Cochran <richardcochran@gmail.com>
Date: Fri, 21 Nov 2014 14:16:20 +0100

> Commit a6111d3c "vlan: Pass SIOC[SG]HWTSTAMP ioctls to real device"
> intended to enable hardware time stamping on VLAN interfaces, but
> passing SIOCSHWTSTAMP is only half of the story. This patch adds
> the second half, by letting user space find out the time stamping
> capabilities of the device backing a VLAN interface.
> 
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>

Applied, thanks Richard.

^ permalink raw reply

* [PATCH rfc] packet: zerocopy packet_snd
From: Willem de Bruijn @ 2014-11-21 20:44 UTC (permalink / raw)
  To: netdev; +Cc: davem, eric.dumazet, dborkman, mst, Willem de Bruijn

From: Willem de Bruijn <willemb@google.com>

Extend the copy avoidance ("zero copy") interface from virtio and tap
to packet sockets.

Interface (send):
  Pass MSG_ZEROCOPY flag in send to have the kernel link the original
  user pages into its skb_shinfo(skb)->frags.

Interface (recv notification):
  Process the socket error queue. Ancillary data of type
  SO_EE_ORIGIN_UPAGE will return the pointer to the buffer passed in
  send to notify the completion of that send request.

  If the process allows the error queue to overflow, notifications
  will be dropped.

Tested by injecting max sized TCP packets on a host with TSO enabled
and GSO disabled. This passes the full packet to the NIC. Perf shows
a large drop in cycles spent (perf record -C 4 -a sleep 4)

Sending 10 Kpps without MSG_ZEROCOPY:

    Event count (approx.): 1191500371
    30.63%  psock_reinject  [kernel.kallsyms]  [k] copy_user_enhanced_fast_string
     7.50%  psock_reinject  [kernel.kallsyms]  [k] __rmqueue
     6.26%         swapper  [kernel.kallsyms]  [k] intel_idle
     5.06%  psock_reinject  [kernel.kallsyms]  [k] get_page_from_freelist
     1.99%  psock_reinject  [kernel.kallsyms]  [k] mlx4_en_xmit
     1.60%  psock_reinject  [kernel.kallsyms]  [k] __alloc_pages_nodemask

and the same with MSG_ZEROCOPY:

    Event count (approx.): 390783801
    13.96%         swapper  [kernel.kallsyms]  [k] intel_idle
     3.11%  psock_reinject  [kernel.kallsyms]  [k] mlx4_en_xmit
     2.75%  psock_reinject  [kernel.kallsyms]  [k] _raw_spin_lock
     2.67%         swapper  [kernel.kallsyms]  [k] lapic_next_deadline
     2.33%  psock_reinject  [kernel.kallsyms]  [k] gup_huge_pmd
     1.90%         swapper  [kernel.kallsyms]  [k] apic_timer_interrupt

The idle is probably due to using usleep to pace the sender, so this
underreports the effect.

Another test sent packets over loopback to a UDP socket. The test
executes mostly synchronously in a single thread:
  sendmsg(fd_packet);
  recvmsg(fd_inet);
  recvmsg(fd_packet, .., MSG_ERRQUEUE);

Result from that at various packet sizes:

            no-zc    zc   !ubufs  recvmmsg !callback
1           573     368      359       439       517
10          569     368      361       441       507
100         572     299      340       408       478
1000        564     300      338       412       486
10000       475     247      331       405       479
30000       328     177      324       385       450
65000       218     117      307       359       417

Legend:
  zc:         pass MSG_ZEROCOPY
  !ubufs:     (gross hack) comment out skb_orphan_frags
                  in __netif_receive_skb_core
  recvmmsg:   switch from synchronous completion notification
                  handling to batching.
  !callback:  (gross hack) disable upcall mechanism completely,
                  to expose its cost.

This demonstrates one of the large blocking issues to the practical
use of this feature in many datapaths: the kernel copies data of
sk_buffs with field SKBTX_DEV_ZEROCOPY at skb_clone and other points
to ensure safe reference counting. Follow on work would be needed
to refine this mechanism and increase the number of datapaths where
user pages can safely be used. This is one reason why I demonstrate
with TSO, as opposed to GSO: GSO also has to copy.

Implementation note: returning the pointer is somewhat ugly. An
alternative is to keep a per-socket counter, increment that for
each MSG_ZEROCOPY sendmsg() call and return this counter as
notification.

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 include/linux/skbuff.h        |   1 +
 include/linux/socket.h        |   1 +
 include/uapi/linux/errqueue.h |   1 +
 net/packet/af_packet.c        | 110 ++++++++++++++++++++++++++++++++++++++----
 4 files changed, 103 insertions(+), 10 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 78c299f..8e661d2 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -295,6 +295,7 @@ struct ubuf_info {
 	void (*callback)(struct ubuf_info *, bool zerocopy_success);
 	void *ctx;
 	unsigned long desc;
+	void *callback_priv;
 };
 
 /* This data is invariant across clones and lives at
diff --git a/include/linux/socket.h b/include/linux/socket.h
index de52228..0a2e0ea 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -265,6 +265,7 @@ struct ucred {
 #define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */
 #define MSG_EOF         MSG_FIN
 
+#define MSG_ZEROCOPY	0x4000000	/* Pin user pages */
 #define MSG_FASTOPEN	0x20000000	/* Send data in TCP SYN */
 #define MSG_CMSG_CLOEXEC 0x40000000	/* Set close_on_exec for file
 					   descriptor received through
diff --git a/include/uapi/linux/errqueue.h b/include/uapi/linux/errqueue.h
index 07bdce1..61bf318 100644
--- a/include/uapi/linux/errqueue.h
+++ b/include/uapi/linux/errqueue.h
@@ -19,6 +19,7 @@ struct sock_extended_err {
 #define SO_EE_ORIGIN_ICMP6	3
 #define SO_EE_ORIGIN_TXSTATUS	4
 #define SO_EE_ORIGIN_TIMESTAMPING SO_EE_ORIGIN_TXSTATUS
+#define SO_EE_ORIGIN_UPAGE	5
 
 #define SO_EE_OFFENDER(ee)	((struct sockaddr*)((ee)+1))
 
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 58af5802..367c23a 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2370,28 +2370,112 @@ out:
 
 static struct sk_buff *packet_alloc_skb(struct sock *sk, size_t prepad,
 				        size_t reserve, size_t len,
-				        size_t linear, int noblock,
+					size_t linear, int flags,
 				        int *err)
 {
 	struct sk_buff *skb;
+	size_t data_len;
 
-	/* Under a page?  Don't bother with paged skb. */
-	if (prepad + len < PAGE_SIZE || !linear)
-		linear = len;
+	if (flags & MSG_ZEROCOPY) {
+		/* Minimize linear, but respect header lower bound */
+		linear = min(len, max_t(size_t, linear, MAX_HEADER));
+		data_len = 0;
+	} else {
+		/* Under a page? Don't bother with paged skb. */
+		if (prepad + len < PAGE_SIZE || !linear)
+			linear = len;
+		data_len = len - linear;
+	}
 
-	skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
-				   err, 0);
+	skb = sock_alloc_send_pskb(sk, prepad + linear, data_len,
+				   flags & MSG_DONTWAIT, err, 0);
 	if (!skb)
 		return NULL;
 
 	skb_reserve(skb, reserve);
 	skb_put(skb, linear);
-	skb->data_len = len - linear;
-	skb->len += len - linear;
+	skb->data_len = data_len;
+	skb->len += data_len;
 
 	return skb;
 }
 
+/* release zerocopy resources and avoid destructor callback on kfree */
+static void packet_snd_zerocopy_free(struct sk_buff *skb)
+{
+	struct ubuf_info *uarg = skb_shinfo(skb)->destructor_arg;
+
+	if (uarg) {
+		kfree_skb(uarg->callback_priv);
+		sock_put((struct sock *) uarg->ctx);
+		kfree(uarg);
+
+		skb_shinfo(skb)->destructor_arg = NULL;
+		skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY;
+	}
+}
+
+static void packet_snd_zerocopy_callback(struct ubuf_info *uarg,
+					 bool zerocopy_success)
+{
+	struct sk_buff *err_skb;
+	struct sock *err_sk;
+	struct sock_exterr_skb *serr;
+
+	err_sk = uarg->ctx;
+	err_skb = uarg->callback_priv;
+
+	serr = SKB_EXT_ERR(err_skb);
+	memset(serr, 0, sizeof(*serr));
+	serr->ee.ee_errno = ENOMSG;
+	serr->ee.ee_origin = SO_EE_ORIGIN_UPAGE;
+	serr->ee.ee_data = uarg->desc & 0xFFFFFFFF;
+	serr->ee.ee_info = ((u64) uarg->desc) >> 32;
+	if (sock_queue_err_skb(err_sk, err_skb))
+		kfree_skb(err_skb);
+
+	kfree(uarg);
+	sock_put(err_sk);
+}
+
+static int packet_zerocopy_sg_from_iovec(struct sk_buff *skb,
+					 struct msghdr *msg)
+{
+	struct ubuf_info *uarg = NULL;
+	int ret;
+
+	if (iov_pages(msg->msg_iov, 0, msg->msg_iovlen) > MAX_SKB_FRAGS)
+		return -EMSGSIZE;
+
+	uarg = kzalloc(sizeof(*uarg), GFP_KERNEL);
+	if (!uarg)
+		return -ENOMEM;
+
+	uarg->callback_priv = alloc_skb(0, GFP_KERNEL);
+	if (!uarg->callback_priv) {
+		kfree(uarg);
+		return -ENOMEM;
+	}
+
+	ret = zerocopy_sg_from_iovec(skb, msg->msg_iov, 0, msg->msg_iovlen);
+	if (ret) {
+		kfree_skb(uarg->callback_priv);
+		kfree(uarg);
+		return -EIO;
+	}
+
+	sock_hold(skb->sk);
+	uarg->ctx = skb->sk;
+	uarg->callback = packet_snd_zerocopy_callback;
+	uarg->desc = (unsigned long) msg->msg_iov[0].iov_base;
+
+	skb_shinfo(skb)->destructor_arg = uarg;
+	skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
+	skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
+
+	return 0;
+}
+
 static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
@@ -2408,6 +2492,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 	unsigned short gso_type = 0;
 	int hlen, tlen;
 	int extra_len = 0;
+	bool zerocopy = msg->msg_flags & MSG_ZEROCOPY;
 
 	/*
 	 *	Get and verify the address.
@@ -2501,7 +2586,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 	hlen = LL_RESERVED_SPACE(dev);
 	tlen = dev->needed_tailroom;
 	skb = packet_alloc_skb(sk, hlen + tlen, hlen, len, vnet_hdr.hdr_len,
-			       msg->msg_flags & MSG_DONTWAIT, &err);
+			       msg->msg_flags, &err);
 	if (skb == NULL)
 		goto out_unlock;
 
@@ -2518,7 +2603,11 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 	}
 
 	/* Returns -EFAULT on error */
-	err = skb_copy_datagram_from_iovec(skb, offset, msg->msg_iov, 0, len);
+	if (zerocopy)
+		err = packet_zerocopy_sg_from_iovec(skb, msg);
+	else
+		err = skb_copy_datagram_from_iovec(skb, offset, msg->msg_iov,
+						   0, len);
 	if (err)
 		goto out_free;
 
@@ -2578,6 +2667,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 	return len;
 
 out_free:
+	packet_snd_zerocopy_free(skb);
 	kfree_skb(skb);
 out_unlock:
 	if (dev)
-- 
2.1.0.rc2.206.gedb03e5

^ permalink raw reply related

* Re: [PATCH v2 net] net: Revert "net: avoid one atomic operation in skb_clone()"
From: Chris Mason @ 2014-11-21 21:15 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Sabrina Dubroca, David Miller, netdev
In-Reply-To: <1416599236.8629.124.camel@edumazet-glaptop2.roam.corp.google.com>

On Fri, Nov 21, 2014 at 2:47 PM, Eric Dumazet <eric.dumazet@gmail.com> 
wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> v2: the revert went wrong, as SKB_FCLONE_UNAVAILABLE
>     was later replaced by SKB_FCLONE_FREE, spotted by Sabrina Dubroca
> 

v2 is happy here too.  I'll let it keep going over the weekend and add 
more memory pressure, but my crashes seem to be gone.

-chris

^ permalink raw reply

* Re: [PATCH 0/4] defxx: Assorted fixes, mainly for EISA
From: David Miller @ 2014-11-21 21:37 UTC (permalink / raw)
  To: macro; +Cc: netdev
In-Reply-To: <alpine.LFD.2.11.1411211107150.4773@eddie.linux-mips.org>

From: "Maciej W. Rozycki" <macro@linux-mips.org>
Date: Fri, 21 Nov 2014 14:09:47 +0000 (GMT)

>  This is another small series fixing issues with the defxx driver, 
> mainly for EISA boards, but there's one patch for PCI as well.
> 
>  In the end, with the inexistent second IDE channel forcefully disabled 
> in the IDE driver, I wasn't able to retrigger spurious IRQ 15 interrupts 
> I previously saw and suspected the DEFEA to be the cause.  So it looks 
> to me these were real noise on IRQ 15 rather than the latency in 
> interrupt acknowledge in the DEFEA board causing the slave 8259A to 
> issue the spurious interrupt vector.  In any case not an issue with the 
> defxx driver, so nothing to do here unless the problem resurfaces.
> 
>  I haven't seen your announcement about opening net-next since the 
> closure on Oct 6th, but from the patch traffic and the policy described 
> in Documentation/networking/netdev-FAQ.txt I gather your tree is open.  
> And these are bug fixes anyway, not new features, so please apply.

Series applied to net-next, thanks.

^ permalink raw reply

* Re: pull request: wireless-next 2014-11-21
From: David Miller @ 2014-11-21 21:40 UTC (permalink / raw)
  To: linville-2XuSBdqkA4R54TAoqtyWWQ
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20141121183014.GA24984-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>

From: "John W. Linville" <linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Date: Fri, 21 Nov 2014 13:30:15 -0500

> Please pull this batch of updates intended for the 3.19 stream...

Pulled into net-next, thanks John.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* RE: i40e/i40e_ethtool.c weirdness?
From: Sullivan, Catherine @ 2014-11-21 21:46 UTC (permalink / raw)
  To: Valdis Kletnieks, Williams, Mitch A, Kirsher, Jeffrey T
  Cc: Nelson, Shannon, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
In-Reply-To: <51793.1416511307@turing-police.cc.vt.edu>

> From: Valdis Kletnieks [mailto:Valdis.Kletnieks@vt.edu]
> 
> (spotted while looking at a 'git bisect visualize' for something else)
> 
> After this commit:
> 
> Author: Mitch Williams <mitch.a.williams@intel.com>  2014-09-13 03:40:47
> Committer: Jeff Kirsher <jeffrey.t.kirsher@intel.com>  2014-10-23 23:38:04
> 
>     i40e: Add 10GBaseT support
> 
>     Add driver support for 10GBaseT device.
> 
> we have the following chunk of code in i40e_ethtool.c:
> 
>         case I40E_PHY_TYPE_10GBASE_SFPP_CU:
>                 ecmd->supported = SUPPORTED_10000baseT_Full;
>                 break;
>         case I40E_PHY_TYPE_1000BASE_KX:
>         case I40E_PHY_TYPE_1000BASE_T:
>                 ecmd->supported = SUPPORTED_Autoneg |
>                                   SUPPORTED_10000baseT_Full |
>                                   SUPPORTED_1000baseT_Full |
>                                   SUPPORTED_100baseT_Full;
>                 ecmd->advertising = ADVERTISED_Autoneg |
>                                     ADVERTISED_10000baseT_Full |
>                                     ADVERTISED_1000baseT_Full |
>                                     ADVERTISED_100baseT_Full;
>                 break;
>         case I40E_PHY_TYPE_100BASE_TX:
>                 ecmd->supported = SUPPORTED_Autoneg |
>                                   SUPPORTED_10000baseT_Full |
>                                   SUPPORTED_1000baseT_Full |
>                                   SUPPORTED_100baseT_Full;
>                 ecmd->advertising = ADVERTISED_Autoneg |
>                                     ADVERTISED_10000baseT_Full |
>                                     ADVERTISED_1000baseT_Full |
>                                     ADVERTISED_100baseT_Full;
>                 break;
>         case I40E_PHY_TYPE_SGMII:
>                 ecmd->supported = SUPPORTED_Autoneg |
> 
> I'm confused by the fact that 2 cases that by name are 100M and 1G parts got
> bits saying that 10G is "supported" - was that intentional?

Yes, it was intentional. The 100M and 1G phy types that got 10G support are actually 10G parts that show up as 100M and 1G when that is the link speed. All three phy types therefore need to support all three speeds so that it is possible to toggle between them. 

-Catherine

^ permalink raw reply

* Re: [PATCH v2 9/9] netfilter: Replace smp_read_barrier_depends() with lockless_dereference()
From: Pranith Kumar @ 2014-11-21 21:57 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
	David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, netfilter-devel, coreteam,
	open list:NETWORKING [IPv4/..., open list
In-Reply-To: <1416586364.8629.104.camel@edumazet-glaptop2.roam.corp.google.com>

On Fri, Nov 21, 2014 at 11:12 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Fri, 2014-11-21 at 10:06 -0500, Pranith Kumar wrote:
>> Recently lockless_dereference() was added which can be used in place of
>> hard-coding smp_read_barrier_depends(). The following PATCH makes the change.
>>
>> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
>> ---
>>  net/ipv4/netfilter/arp_tables.c | 3 +--
>>  net/ipv4/netfilter/ip_tables.c  | 3 +--
>>  net/ipv6/netfilter/ip6_tables.c | 3 +--
>>  3 files changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
>> index f95b6f9..fc7533d 100644
>> --- a/net/ipv4/netfilter/arp_tables.c
>> +++ b/net/ipv4/netfilter/arp_tables.c
>> @@ -270,12 +270,11 @@ unsigned int arpt_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 = lockless_dereference(table->private);
>>       table_base = private->entries[smp_processor_id()];
>>
>
>
> Please carefully read the code, before and after your change, then
> you'll see this change broke the code.
>
> Problem is that a bug like that can be really hard to diagnose and fix
> later, so really you have to be very careful doing these mechanical
> changes.
>
> IMO, current code+comment is better than with this
> lockless_dereference() which in this particular case obfuscates the
> code. more than anything.
>
> In this case we do have a lock (sort of), so lockless_dereference() is
> quite misleading.
>

Hi Eric,

Thanks for looking at this patch.

I've been scratching my head since morning trying to find out what was
so obviously wrong with this patch. Alas, I don't see what you do.

Could you point it out and show me how incompetent I am, please?

Thanks!
-- 
Pranith

^ permalink raw reply

* Re: [PATCH] vxlan: move listen socket creation from workqueue to vxlan_open
From: David Miller @ 2014-11-21 22:11 UTC (permalink / raw)
  To: mleitner; +Cc: netdev, stephen, pshelar
In-Reply-To: <a66c29751c354fe08acd459479f2eacf66e9b284.1416486751.git.mleitner@redhat.com>

From: Marcelo Ricardo Leitner <mleitner@redhat.com>
Date: Thu, 20 Nov 2014 10:33:32 -0200

> But this doesn't apply to vxlan_open() scenario. We can unlock/lock
> in there safely and, with that, we can return a better error value
> to the user if that's the case.

This is not safe.

Now nothing prevents another parallel open of this vxlan device to
occur while you dropped the RTNL semaphore.

^ permalink raw reply

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
From: SF Markus Elfring @ 2014-11-21 22:15 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall,
	devel
In-Reply-To: <20141121.151503.1986113223309494197.davem@davemloft.net>

> This does not apply to the net-next tree, please respin.

Thanks for your reply.

How do you think about to try out the scripts which I published
in March to get more constructive feedback?
Will they run faster for another analysis on current
Linux source files with your test systems (than my computer)?

Regards,
Markus

^ permalink raw reply

* Re: [PATCH v2 net-next 0/2] bonding: Introduce 4 AD link speed
From: David Miller @ 2014-11-21 22:16 UTC (permalink / raw)
  To: Jianhua.Xie; +Cc: netdev, edumazet, j.vosburgh, vfalico, andy
In-Reply-To: <1416386939-24591-1-git-send-email-Jianhua.Xie@freescale.com>

From: Xie Jianhua <Jianhua.Xie@freescale.com>
Date: Wed, 19 Nov 2014 16:48:57 +0800

> From: Jianhua Xie <Jianhua.Xie@freescale.com>
> 
> The speed field of AD Port Key was based on bitmask, it supported 5
> kinds of link speed at most, as there were only 5 bits in the speed
> field of the AD Port Key.  This patches series change the speed type
> (AD_LINK_SPEED_BITMASK) from bitmask to enum type in order to enhance
> speed type from 5 to 32, and then introduce 4 AD link speed to fix
> agg_bandwidth.
> 
> Jianhua Xie (2):
>   bonding: change AD_LINK_SPEED_BITMASK to enum to suport more speed
>   bonding: Introduce 4 AD link speed to fix agg_bandwidth
> 
>  drivers/net/bonding/bond_3ad.c | 102 ++++++++++++++++++++++++++++-------------
>  1 file changed, 70 insertions(+), 32 deletions(-)
> 
> -- 
> v2:
>  * Use an enum type to instead of the bitmask, not expand speed field, 
> 
> v1:
>  * Compress RFC patches #2 to #5 into one single patch.
>  * Fix inexact commit information.

Series applied, thanks.

^ permalink raw reply

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
From: David Miller @ 2014-11-21 22:27 UTC (permalink / raw)
  To: elfring
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall,
	devel
In-Reply-To: <546FB98E.5070703@users.sourceforge.net>

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 23:15:42 +0100

>> This does not apply to the net-next tree, please respin.
> 
> Thanks for your reply.
> 
> How do you think about to try out the scripts which I published
> in March to get more constructive feedback?

This has nothing to do with me asking you to frame your patches
against the correct tree.

If I had time to investigate automation of changes using such
tools, I would participate in such discussions, but I don't.

^ permalink raw reply

* [GIT] Networking
From: David Miller @ 2014-11-21 22:37 UTC (permalink / raw)
  To: torvalds; +Cc: akpm, netdev, linux-kernel


1) Fix BUG when decrypting empty packets in mac80211, from Ronald Wahl.

2) nf_nat_range is not fully initialized and this is copied back to
   userspace, from Daniel Borkmann.

3) Fix read past end of b uffer in netfilter ipset, also from Dan
   Carpenter.

4) Signed integer overflow in ipv4 address mask creation helper
   inet_make_mask(), from Vincent BENAYOUN.

5) VXLAN, be2net, mlx4_en, and qlcnic need ->ndo_gso_check() methods
   to properly describe the device's capabilities, from Joe
   Stringer.

6) Fix memory leaks and checksum miscalculations in openvswitch, from
   Pravin B SHelar and Jesse Gross.

7) FIB rules passes back ambiguous error code for unreachable routes,
   making behavior confusing for userspace.  Fix from Panu Matilainen.

8) ieee802154fake_probe() doesn't release resources properly on error,
   from Alexey Khoroshilov.

9) Fix skb_over_panic in add_grhead(), from Daniel Borkmann.

10) Fix access of stale slave pointers in bonding code, from Nikolay
    Aleksandrov.

11) Fix stack info leak in PPP pptp code, from Mathias Krause.

12) Cure locking bug in IPX stack, from Jiri Bohac.

13) Revert SKB fclone memory freeing optimization that is racey and can
    allow accesses to freed up memory, from Eric Dumazet.

Please pull, thanks a lot!

The following changes since commit b23dc5a7cc6ebc9a0d57351da7a0e8454c9ffea3:

  Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost (2014-11-13 18:07:52 -0800)

are available in the git repository at:


  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git master

for you to fetch changes up to 0c228e833c88e3aa029250f5db77d5968c5ce5b5:

  tcp: Restore RFC5961-compliant behavior for SYN packets (2014-11-21 15:33:50 -0500)

----------------------------------------------------------------
Alexey Khoroshilov (2):
      ieee802154: fix error handling in ieee802154fake_probe()
      can: esd_usb2: fix memory leak on disconnect

Anish Bhatt (3):
      dcbnl : Disable software interrupts before taking dcb_lock
      cxgb4i : Don't block unload/cxgb4 unload when remote closes TCP connection
      cxgb4 : Fix DCB priority groups being returned in wrong order

Arend van Spriel (1):
      brcmfmac: fix conversion of channel width 20MHZ_NOHT

Ben Greear (1):
      ath9k: fix regression in bssidmask calculation

Calvin Owens (2):
      ipvs: Keep skb->sk when allocating headroom on tunnel xmit
      tcp: Restore RFC5961-compliant behavior for SYN packets

Dan Carpenter (1):
      netfilter: ipset: small potential read beyond the end of buffer

Daniel Borkmann (2):
      netfilter: nft_masq: fix uninitialized range in nft_masq_{ipv4, ipv6}_eval
      ipv6: mld: fix add_grhead skb_over_panic for devs with large MTUs

Daniele Di Proietto (1):
      openvswitch: Fix NDP flow mask validation

David Cohen (1):
      can: m_can: add CONFIG_HAS_IOMEM dependence

David S. Miller (7):
      Merge tag 'master-2014-11-11' of git://git.kernel.org/.../linville/wireless
      Merge branch 'vxlan_gso_check'
      Merge git://git.kernel.org/.../pablo/nf
      Merge branch 'net_ovs' of git://git.kernel.org/.../pshelar/openvswitch
      Merge tag 'linux-can-fixes-for-3.18-20141118' of git://gitorious.org/linux-can/linux-can
      Merge tag 'master-2014-11-20' of git://git.kernel.org/.../linville/wireless
      Merge git://git.kernel.org/.../pablo/nf

Dmitry Torokhov (1):
      brcmfmac: fix error handling of irq_of_parse_and_map

Dong Aisheng (8):
      can: dev: add can_is_canfd_skb() API
      can: m_can: add .ndo_change_mtu function
      can: m_can: add missing message RAM initialization
      can: m_can: fix possible sleep in napi poll
      can: m_can: fix not set can_dlc for remote frame
      can: m_can: add missing delay after setting CCCR_INIT bit
      can: m_can: fix incorrect error messages
      can: m_can: update to support CAN FD features

Duan Jiong (1):
      ipv6: delete protocol and unregister rtnetlink when cleanup

Emmanuel Grumbach (1):
      iwlwifi: mvm: abort scan upon RFKILL

Eric Dumazet (1):
      net: Revert "net: avoid one atomic operation in skb_clone()"

Felix Fietkau (1):
      mac80211: minstrel_ht: fix a crash in rate sorting

Hannes Frederic Sowa (1):
      reciprocal_div: objects with exported symbols should be obj-y rather than lib-y

Hauke Mehrtens (1):
      b43: fix NULL pointer dereference in b43_phy_copy()

Jarno Rajahalme (1):
      openvswitch: Validate IPv6 flow key and mask values.

Jason Wang (1):
      virtio-net: validate features during probe

Jesse Gross (1):
      openvswitch: Fix checksum calculation when modifying ICMPv6 packets.

Jiri Bohac (1):
      ipx: fix locking regression in ipx_sendmsg and ipx_recvmsg

Joe Stringer (6):
      net: Add vxlan_gso_check() helper
      be2net: Implement ndo_gso_check()
      net/mlx4_en: Implement ndo_gso_check()
      qlcnic: Implement ndo_gso_check()
      vxlan: Inline vxlan_gso_check().
      openvswitch: Don't validate IPv6 label masks.

Johannes Berg (1):
      brcmfmac: don't include linux/unaligned/access_ok.h

John Ogness (1):
      drivers: net: cpsw: Fix TX_IN_SEL offset

John W. Linville (3):
      Merge tag 'mac80211-for-john-2014-11-10' of git://git.kernel.org/.../jberg/mac80211
      Merge tag 'iwlwifi-for-john-2014-11-10' of git://git.kernel.org/.../iwlwifi/iwlwifi-fixes
      Merge tag 'mac80211-for-john-2014-11-18' of git://git.kernel.org/.../jberg/mac80211

Larry Finger (3):
      rtlwifi: Fix setting of tx descriptor for new trx flow
      rtlwifi: Fix errors in descriptor manipulation
      rtlwifi: rtl8192se: Fix connection problems

Liad Kaufman (1):
      iwlwifi: pcie: fix prph dump length

Linus Lüssing (1):
      bridge: fix netfilter/NF_BR_LOCAL_OUT for own, locally generated queries

Marc Kleine-Budde (3):
      can: xilinx_can: add .ndo_change_mtu function
      can: rcar_can: add .ndo_change_mtu function
      can: gs_usb: add .ndo_change_mtu function

Martin Hauke (1):
      qmi_wwan: Add support for HP lt4112 LTE/HSPA+ Gobi 4G Modem

Mathias Krause (1):
      pptp: fix stack info leak in pptp_getname()

Mathy Vanhoef (1):
      brcmfmac: kill URB when request timed out

Miaoqing Pan (1):
      ath9k: Fix RTC_DERIVED_CLK usage

Nikolay Aleksandrov (1):
      bonding: fix curr_active_slave/carrier with loadbalance arp monitoring

Or Gerlitz (1):
      net/mlx4_en: Add VXLAN ndo calls to the PF net device ops too

Pablo Neira Ayuso (5):
      netfilter: nft_compat: use current net namespace
      netfilter: nft_compat: relax chain type validation
      netfilter: nft_compat: use the match->table to validate dependencies
      netfilter: nf_tables: restore synchronous object release from commit/abort
      netfilter: nfnetlink: fix insufficient validation in nfnetlink_bind

Panu Matilainen (1):
      ipv4: Fix incorrect error code when adding an unreachable route

Pravin B Shelar (2):
      openvswitch: Fix memory leak.
      openvswitch: Convert dp rcu read operation to locked operations

Roman Fietze (1):
      can: dev: fix typo CIA -> CiA, CAN in Automation

Ronald Wahl (1):
      mac80211: Fix regression that triggers a kernel BUG with CCMP

Stanislaw Gruszka (1):
      rt2x00: do not align payload on modern H/W

Sudip Mukherjee (2):
      can: remove unused variable
      can: xilinx_can: fix comparison of unsigned variable

Thomas Körper (1):
      can: dev: avoid calling kfree_skb() from interrupt context

Vincent BENAYOUN (1):
      inetdevice: fixed signed integer overflow

bill bonaparte (1):
      netfilter: conntrack: fix race in __nf_conntrack_confirm against get_next_corpse

 drivers/net/bonding/bond_main.c                       |   3 +-
 drivers/net/can/dev.c                                 |   4 +-
 drivers/net/can/m_can/Kconfig                         |   1 +
 drivers/net/can/m_can/m_can.c                         | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
 drivers/net/can/rcar_can.c                            |   1 +
 drivers/net/can/sja1000/kvaser_pci.c                  |   5 +-
 drivers/net/can/usb/ems_usb.c                         |   3 +-
 drivers/net/can/usb/esd_usb2.c                        |   3 +-
 drivers/net/can/usb/gs_usb.c                          |   1 +
 drivers/net/can/xilinx_can.c                          |   4 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c        |   2 +-
 drivers/net/ethernet/emulex/benet/be_main.c           |   6 ++
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c        |  13 ++++-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c      |   6 ++
 drivers/net/ethernet/ti/cpsw.c                        |   6 +-
 drivers/net/ieee802154/fakehard.c                     |  13 +++--
 drivers/net/ppp/pptp.c                                |   4 +-
 drivers/net/usb/qmi_wwan.c                            |   1 +
 drivers/net/virtio_net.c                              |  37 ++++++++++++
 drivers/net/vxlan.c                                   |   6 --
 drivers/net/wireless/ath/ath9k/ar9003_phy.c           |  13 +++++
 drivers/net/wireless/ath/ath9k/hw.c                   |  13 -----
 drivers/net/wireless/ath/ath9k/main.c                 |   9 ++-
 drivers/net/wireless/b43/phy_common.c                 |   4 +-
 drivers/net/wireless/brcm80211/brcmfmac/of.c          |   4 +-
 drivers/net/wireless/brcm80211/brcmfmac/pcie.c        |   2 +-
 drivers/net/wireless/brcm80211/brcmfmac/usb.c         |   6 +-
 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c |   6 ++
 drivers/net/wireless/iwlwifi/mvm/scan.c               |  20 +++----
 drivers/net/wireless/iwlwifi/pcie/trans.c             |   3 +-
 drivers/net/wireless/rt2x00/rt2x00queue.c             |  50 ++++-------------
 drivers/net/wireless/rtlwifi/pci.c                    |  19 ++++---
 drivers/net/wireless/rtlwifi/rtl8192se/hw.c           |   7 ++-
 drivers/net/wireless/rtlwifi/rtl8192se/phy.c          |   2 +
 drivers/net/wireless/rtlwifi/rtl8192se/sw.c           |  16 ++++++
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c                    |   2 +
 drivers/scsi/cxgbi/libcxgbi.c                         |   2 +-
 include/linux/can/dev.h                               |   6 ++
 include/linux/inetdevice.h                            |   2 +-
 include/net/netfilter/nf_tables.h                     |   2 -
 include/net/vxlan.h                                   |  18 ++++++
 lib/Makefile                                          |   4 +-
 net/bridge/br_multicast.c                             |   3 +-
 net/core/skbuff.c                                     |  23 ++------
 net/dcb/dcbnl.c                                       |  36 ++++++------
 net/ipv4/fib_rules.c                                  |   4 ++
 net/ipv4/igmp.c                                       |  11 ++--
 net/ipv4/netfilter/nft_masq_ipv4.c                    |   1 +
 net/ipv4/tcp_input.c                                  |   4 +-
 net/ipv6/ip6mr.c                                      |   4 ++
 net/ipv6/mcast.c                                      |   9 +--
 net/ipv6/netfilter/nft_masq_ipv6.c                    |   1 +
 net/ipx/af_ipx.c                                      |   6 +-
 net/mac80211/aes_ccm.c                                |   3 +
 net/mac80211/rc80211_minstrel_ht.c                    |  15 ++---
 net/netfilter/ipset/ip_set_core.c                     |   6 ++
 net/netfilter/ipvs/ip_vs_xmit.c                       |   2 +
 net/netfilter/nf_conntrack_core.c                     |  14 +++--
 net/netfilter/nf_tables_api.c                         |  24 +++-----
 net/netfilter/nfnetlink.c                             |  12 +++-
 net/netfilter/nft_compat.c                            |  40 ++-----------
 net/openvswitch/actions.c                             |  10 ++--
 net/openvswitch/datapath.c                            |  14 ++---
 net/openvswitch/flow_netlink.c                        |   9 ++-
 64 files changed, 500 insertions(+), 299 deletions(-)

^ permalink raw reply

* [RFC PATCH 0/4] switch device: offload policy attributes
From: roopa @ 2014-11-21 22:49 UTC (permalink / raw)
  To: jiri, sfeldma, jhs, bcrl, tgraf, john.fastabend, stephen,
	linville, nhorman, nicolas.dichtel, vyasevic, f.fainelli, buytenh,
	aviadr
  Cc: netdev, davem, shrijeet, gospo, Roopa Prabhu

From: Roopa Prabhu <roopa@cumulusnetworks.com>


This series aims at introducing new policy attibutes/flags to enable
selective offloading of kernel network objects.
This is in the context of supporting switch devices in the linux kernel.

Assumption:
    - All kernel network objects (routes, neighs, bridges, bonds, vxlans)
      can be offloaded (This is true today with a few exceptions maybe)

policy points:
    - By default all objects exist in software (kernel)
    - Per object flag to add/del/show in kernel, hardware or both
    - System global option to turn on/off offloads for all network objects.
      This is for systems who want to turn offloading on for all network objects
      by default. us :). Apps dont need to know about offloading in this
      model. (TBD)

Patches are based on jiri/sfeldma's rocker work.

Apologize for the incomplete and untested code. This is a sample patch
 to get some initial feedback.

Roopa Prabhu (4):
  rtnetlink: new flag NLM_F_HW_OFFLOAD to indicate kernel object
    offload to hardware
  netdev: new feature flag NETIF_F_HW_OFFLOAD to indicate netdev object
    offload to hardware
  swdevice: new generic op to set bridge port attr
  bridge: make hw offload conditional on bridge and bridge port offload
    flags

 include/linux/netdev_features.h |    1 +
 include/net/switchdev.h         |    8 ++++++-
 include/uapi/linux/netlink.h    |    2 ++
 net/bridge/br_netlink.c         |   50 +++++++++++++++++++++++++++++++--------
 net/bridge/br_private.h         |    2 ++
 net/bridge/br_stp.c             |    9 ++++---
 net/bridge/br_stp_if.c          |    8 +++++--
 net/core/rtnetlink.c            |    7 ++++++
 net/switchdev/switchdev.c       |   17 +++++++++++++
 9 files changed, 88 insertions(+), 16 deletions(-)

-- 
1.7.10.4

^ permalink raw reply

* [RFC PATCH 1/4] rtnetlink: new flag NLM_F_HW_OFFLOAD to indicate kernel object offload to hardware
From: roopa @ 2014-11-21 22:49 UTC (permalink / raw)
  To: jiri, sfeldma, jhs, bcrl, tgraf, john.fastabend, stephen,
	linville, nhorman, nicolas.dichtel, vyasevic, f.fainelli, buytenh,
	aviadr
  Cc: netdev, davem, shrijeet, gospo, Roopa Prabhu

From: Roopa Prabhu <roopa@cumulusnetworks.com>

This patch adds new flags in netlink header nlmsg_flags to signal if the
message is for the kernel, hw or both.

This can be used to indicate hw offload for all kind of objects
routes, fdb entries, neighs, link objects like bonds, bridges, vxlan.

Adding it in the header makes it possible to use it accross all objects and
across all messages (sets/gets/deletes).

Other alternative to this is a per kernel object netlink attribute/flag.
But that leads to duplicating the attribute in different subsystems.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
 include/uapi/linux/netlink.h |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/netlink.h b/include/uapi/linux/netlink.h
index 1a85940..f78522d 100644
--- a/include/uapi/linux/netlink.h
+++ b/include/uapi/linux/netlink.h
@@ -54,6 +54,8 @@ struct nlmsghdr {
 #define NLM_F_ACK		4	/* Reply with ack, with zero or error code */
 #define NLM_F_ECHO		8	/* Echo this request 		*/
 #define NLM_F_DUMP_INTR		16	/* Dump was inconsistent due to sequence change */
++#define NLM_F_KERNEL       32      /* This msg is only for the kernel */
+#define NLM_F_HW_OFFLOAD	64	/* offload this msg to hw */
 
 /* Modifiers to GET request */
 #define NLM_F_ROOT	0x100	/* specify tree	root	*/
-- 
1.7.10.4

^ permalink raw reply related

* [RFC PATCH 2/4] netdev: new feature flag NETIF_F_HW_OFFLOAD to indicate netdev object offload to hardware
From: roopa @ 2014-11-21 22:49 UTC (permalink / raw)
  To: jiri, sfeldma, jhs, bcrl, tgraf, john.fastabend, stephen,
	linville, nhorman, nicolas.dichtel, vyasevic, f.fainelli, buytenh,
	aviadr
  Cc: netdev, davem, shrijeet, gospo, Roopa Prabhu

From: Roopa Prabhu <roopa@cumulusnetworks.com>

This patch adds a new NETIF_F_HW_OFFLOAD feature flag to offload logical
interfaces to hw.

Useful in cases of bridges, bonds etc where you want to offload the
logical interface attributes to hw.
---
 include/linux/netdev_features.h |    1 +
 net/core/rtnetlink.c            |    7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 8e30685..09da213 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -66,6 +66,7 @@ enum {
 	NETIF_F_HW_VLAN_STAG_FILTER_BIT,/* Receive filtering on VLAN STAGs */
 	NETIF_F_HW_L2FW_DOFFLOAD_BIT,	/* Allow L2 Forwarding in Hardware */
 	NETIF_F_BUSY_POLL_BIT,		/* Busy poll */
+	NETIF_F_HW_OFFLOAD,			/* generic hw offload */
 
 	/*
 	 * Add your fresh new feature above and remember to update
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index f839354..97b8f48 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2106,6 +2106,13 @@ replay:
 			goto out;
 		}
 
+		/*
+		 * If the newlink request came in with a HW_OFFLOAD
+		 * flag, then set hw offload feature flag
+		 */
+		if (nlh->nlmsg_flags & NLM_F_HW_OFFLOAD)
+			dev->features |= NETIF_F_HW_OFFLOAD;
+
 		dev->ifindex = ifm->ifi_index;
 
 		if (ops->newlink) {
-- 
1.7.10.4

^ permalink raw reply related

* [RFC PATCH 3/4] swdevice: new generic op to set bridge port attr
From: roopa @ 2014-11-21 22:49 UTC (permalink / raw)
  To: jiri, sfeldma, jhs, bcrl, tgraf, john.fastabend, stephen,
	linville, nhorman, nicolas.dichtel, vyasevic, f.fainelli, buytenh,
	aviadr
  Cc: netdev, davem, shrijeet, gospo, Roopa Prabhu

From: Roopa Prabhu <roopa@cumulusnetworks.com>

A generic switch device op to offload any type of bridge port attribute.

(This is still TBD)
---
 include/net/switchdev.h   |    8 +++++++-
 net/switchdev/switchdev.c |   17 +++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index a9ccfa4..c97994d 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -145,7 +145,8 @@ int netdev_sw_parent_flow_insert(struct net_device *dev,
 				 const struct swdev_flow *flow);
 int netdev_sw_parent_flow_remove(struct net_device *dev,
 				 const struct swdev_flow *flow);
-
+int netdev_sw_port_set_attr(struct net_device *dev, int attrtype,
+                            void *attrval);
 #else
 
 static inline int netdev_sw_parent_id_get(struct net_device *dev,
@@ -202,6 +203,11 @@ static inline int netdev_sw_parent_flow_remove(struct net_device *dev,
 	return -EOPNOTSUPP;
 }
 
+static int netdev_sw_port_set_attr(struct net_device *dev, int attrtype,
+                                   void *attrval)
+{
+	return -EOPNOTSUPP;
+}
 #endif
 
 #endif /* _LINUX_SWITCHDEV_H_ */
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index dc8e769..48f451b 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -314,3 +314,20 @@ int netdev_sw_parent_flow_remove(struct net_device *dev,
 	return ops->ndo_sw_parent_flow_remove(dev, flow);
 }
 EXPORT_SYMBOL(netdev_sw_parent_flow_remove);
+
+/**
+ *	netdev_sw_port_set_attr - set a port attr
+ *	@dev: port device
+ *	@attrttype: netlink attribute
+ *	@attrval: attribute value
+ *
+ *	Set switch port attribute
+ */
+int netdev_sw_port_set_attr(struct net_device *dev,
+					int attrttype, void *attrval)
+{
+	/* XXX: yet to be implemented */
+
+	return 0;
+}
+EXPORT_SYMBOL(netdev_sw_port_set_attr);
-- 
1.7.10.4

^ permalink raw reply related

* [RFC PATCH 4/4] bridge: make hw offload conditional on bridge and bridge port offload flags
From: roopa @ 2014-11-21 22:49 UTC (permalink / raw)
  To: jiri, sfeldma, jhs, bcrl, tgraf, john.fastabend, stephen,
	linville, nhorman, nicolas.dichtel, vyasevic, f.fainelli, buytenh,
	aviadr
  Cc: netdev, davem, shrijeet, gospo, Roopa Prabhu

From: Roopa Prabhu <roopa@cumulusnetworks.com>

If bridge has NETIF_F_HW_OFFLOAD feature flag set, offload all bridge and
bridge port attributes to hardware.

Two new flags BRPORT_KERNEL and BRPORT_HW_OFFLOAD to control offloading of
a few bridge port flags to hardware. These can be encoded in the upper bits
of all bridge port flag netlink attributes.

Control/Override bridge port flag (learning, flooding etc) offloading
with BRPORT_KERNEL and BRPORT_HW_OFFLOAD flags:
    If the brport offload flags are not present (current default)
	    - set bridge port flag attribute only in the kernel
    else:
        if BRPORT_KERNEL and BRPORT_HW_OFFLOAD:
            - set bridge port flag both in kernel and hw
        elif BRPORT_KERNEL:
            - set bridge port flag attribute only in kernel
        elif BRPORT_HW_OFFLOAD:
            - set bridge port flag attribute only in hw

The 'gets' needs more work. The idea is that the gets can also be controlled
by the KERNEL or HW_OFFLOAD flags.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
 net/bridge/br_netlink.c |   50 +++++++++++++++++++++++++++++++++++++----------
 net/bridge/br_private.h |    2 ++
 net/bridge/br_stp.c     |    9 ++++++---
 net/bridge/br_stp_if.c  |    8 ++++++--
 4 files changed, 54 insertions(+), 15 deletions(-)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 13fecf1..e92e810 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -57,12 +57,19 @@ static int br_port_fill_attrs(struct sk_buff *skb,
 	    nla_put_u16(skb, IFLA_BRPORT_PRIORITY, p->priority) ||
 	    nla_put_u32(skb, IFLA_BRPORT_COST, p->path_cost) ||
 	    nla_put_u8(skb, IFLA_BRPORT_MODE, mode) ||
-	    nla_put_u8(skb, IFLA_BRPORT_GUARD, !!(p->flags & BR_BPDU_GUARD)) ||
-	    nla_put_u8(skb, IFLA_BRPORT_PROTECT, !!(p->flags & BR_ROOT_BLOCK)) ||
-	    nla_put_u8(skb, IFLA_BRPORT_FAST_LEAVE, !!(p->flags & BR_MULTICAST_FAST_LEAVE)) ||
-	    nla_put_u8(skb, IFLA_BRPORT_LEARNING, !!(p->flags & BR_LEARNING)) ||
-	    nla_put_u8(skb, IFLA_BRPORT_UNICAST_FLOOD, !!(p->flags & BR_FLOOD)) ||
-	    nla_put_u8(skb, IFLA_BRPORT_PROXYARP, !!(p->flags & BR_PROXYARP)))
+	    nla_put_u8(skb, IFLA_BRPORT_GUARD,
+		           br_get_port_flag(p, IFLA_BRPORT_GUARD, BR_BPDU_GUARD)) ||
+	    nla_put_u8(skb, IFLA_BRPORT_PROTECT,
+	               br_get_port_flag(p, IFLA_BRPORT_PROTECT, BR_ROOT_BLOCK)) ||
+	    nla_put_u8(skb, IFLA_BRPORT_FAST_LEAVE,
+	               br_get_port_flag(p, IFLA_BRPORT_FAST_LEAVE,
+	               BR_MULTICAST_FAST_LEAVE)) ||
+	    nla_put_u8(skb, IFLA_BRPORT_LEARNING,
+	               br_get_port_flag(p, IFLA_BRPORT_LEARNING, BR_LEARNING)) ||
+	    nla_put_u8(skb, IFLA_BRPORT_UNICAST_FLOOD,
+			       br_get_port_flag(p, IFLA_UNICAST_FLOOD, BR_FLOOD)) ||
+	    nla_put_u8(skb, IFLA_BRPORT_PROXYARP, 
+	               br_get_port_flag(p, IFLA_UNICAST_FLOOD, BR_PROXYARP)))
 		return -EMSGSIZE;
 
 	return 0;
@@ -305,7 +312,9 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state)
 
 	br_set_state(p, state);
 	br_log_state(p);
-	netdev_sw_port_stp_update(p->dev, p->state);
+
+	if (BR_HW_OFFLOAD(p->br))
+	    netdev_sw_port_set_attr(p->dev, IFLA_BRPORT_STATE, &p->state);
 	br_port_state_selection(p->br);
 	return 0;
 }
@@ -316,13 +325,34 @@ static void br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[],
 {
 	if (tb[attrtype]) {
 		u8 flag = nla_get_u8(tb[attrtype]);
-		if (flag)
-			p->flags |= mask;
-		else
+		if (flag) {
+			flag_upper = flag & 0xf0
+			if (!flag_upper || (flag_upper & BRPORT_KERNEL))
+				p->flags |= mask;
+			if ((flag_upper & BRPORT_HW_OFFLOAD) ||
+				(BR_HW_OFFLOAD(p->br)))
+				/* Also set the port flag in hw */
+			netdev_sw_port_set_attr(p->dev, attrtype, 1);
+		} else {
 			p->flags &= ~mask;
+			if (BR_HW_OFFLOAD(p->br))
+				netdev_sw_port_set_attr(p->dev, attrtype, 0);
+		}
 	}
 }
 
+/* Set/clear or port flags based on attribute */
+static u8 br_get_port_flag(struct net_bridge_port *p,
+			   int attrtype, u8 flag)
+{
+	attrvalue = !!(p->flags & flag)
+	if (attrvalue)
+		attrvalue |= BRPORT_KERNEL
+	if (netdev_sw_port_get_flag(p->dev, attrtype))
+		attrvalue |= BRPORT_HW_OFFLOAD
+	return attrvalue;
+}
+
 /* Process bridge protocol info on port */
 static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])
 {
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 8f3f081..3ebd196 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -41,6 +41,8 @@
 /* Path to usermode spanning tree program */
 #define BR_STP_PROG	"/sbin/bridge-stp"
 
+#define BR_HW_OFFLOAD(br) !!(br->dev->features & NETIF_F_HW_OFFLOAD)
+
 typedef struct bridge_id bridge_id;
 typedef struct mac_addr mac_addr;
 typedef __u16 port_id;
diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
index c00139b..bb61dc0 100644
--- a/net/bridge/br_stp.c
+++ b/net/bridge/br_stp.c
@@ -115,7 +115,8 @@ static void br_root_port_block(const struct net_bridge *br,
 
 	br_set_state(p, BR_STATE_LISTENING);
 	br_log_state(p);
-	netdev_sw_port_stp_update(p->dev, p->state);
+	if (BR_HW_OFFLOAD(p->br))
+	    netdev_sw_port_set_attr(p->dev, IFLA_BRPORT_STATE, &p->state);
 	br_ifinfo_notify(RTM_NEWLINK, p);
 
 	if (br->forward_delay > 0)
@@ -396,7 +397,8 @@ static void br_make_blocking(struct net_bridge_port *p)
 
 		br_set_state(p, BR_STATE_BLOCKING);
 		br_log_state(p);
-		netdev_sw_port_stp_update(p->dev, p->state);
+		if (BR__HW_OFFLOAD(p->br))
+	        netdev_sw_port_set_attr(p->dev, IFLA_BRPORT_STATE, &p->state);
 		br_ifinfo_notify(RTM_NEWLINK, p);
 
 		del_timer(&p->forward_delay_timer);
@@ -422,7 +424,8 @@ static void br_make_forwarding(struct net_bridge_port *p)
 
 	br_multicast_enable_port(p);
 	br_log_state(p);
-	netdev_sw_port_stp_update(p->dev, p->state);
+	if (BR_OFFLOAD(p->br))
+	    netdev_sw_port_set_attr(p->dev, IFLA_BRPORT_STATE, &p->state);
 	br_ifinfo_notify(RTM_NEWLINK, p);
 
 	if (br->forward_delay != 0)
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 91279f8..8435b4d 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -90,7 +90,8 @@ void br_stp_enable_port(struct net_bridge_port *p)
 	br_init_port(p);
 	br_port_state_selection(p->br);
 	br_log_state(p);
-	netdev_sw_port_stp_update(p->dev, p->state);
+	if (BR_HW_OFFLOAD(p->br))
+	    netdev_sw_port_set_attr(p->dev, IFLA_BRPORT_STATE, &p->state);
 	br_ifinfo_notify(RTM_NEWLINK, p);
 }
 
@@ -107,7 +108,8 @@ void br_stp_disable_port(struct net_bridge_port *p)
 	p->config_pending = 0;
 
 	br_log_state(p);
-	netdev_sw_port_stp_update(p->dev, p->state);
+	if (BR_HW_OFFLOAD(p->br))
+	    netdev_sw_port_set_attr(p->dev, IFLA_BRPORT_STATE, &p->state);
 	br_ifinfo_notify(RTM_NEWLINK, p);
 
 	del_timer(&p->message_age_timer);
@@ -290,6 +292,8 @@ int br_stp_set_port_priority(struct net_bridge_port *p, unsigned long newprio)
 		br_become_designated_port(p);
 		br_port_state_selection(p->br);
 	}
+	if (BR_HW_OFFLOAD(p->br))
+	    netdev_sw_port_set_attr(p->dev, IFLA_BRPORT_PRIORITY, &newprio)
 
 	return 0;
 }
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH] xen-netback: do not report success if xenvif_alloc() fails
From: Alexey Khoroshilov @ 2014-11-21 22:56 UTC (permalink / raw)
  To: Ian Campbell, Wei Liu
  Cc: Alexey Khoroshilov, xen-devel, netdev, linux-kernel, ldv-project

If xenvif_alloc() failes, netback_probe() reports success as well as
"online" uevent is emitted. It does not make any sense, but it just
misleads users.

The patch implements propagation of error code if xenvif creation fails.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/net/xen-netback/xenbus.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 4e56a27f9689..fab0d4b42f58 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -39,7 +39,7 @@ struct backend_info {
 static int connect_rings(struct backend_info *be, struct xenvif_queue *queue);
 static void connect(struct backend_info *be);
 static int read_xenbus_vif_flags(struct backend_info *be);
-static void backend_create_xenvif(struct backend_info *be);
+static int backend_create_xenvif(struct backend_info *be);
 static void unregister_hotplug_status_watch(struct backend_info *be);
 static void set_backend_state(struct backend_info *be,
 			      enum xenbus_state state);
@@ -352,7 +352,9 @@ static int netback_probe(struct xenbus_device *dev,
 	be->state = XenbusStateInitWait;
 
 	/* This kicks hotplug scripts, so do it immediately. */
-	backend_create_xenvif(be);
+	err = backend_create_xenvif(be);
+	if (err)
+		goto fail;
 
 	return 0;
 
@@ -397,19 +399,19 @@ static int netback_uevent(struct xenbus_device *xdev,
 }
 
 
-static void backend_create_xenvif(struct backend_info *be)
+static int backend_create_xenvif(struct backend_info *be)
 {
 	int err;
 	long handle;
 	struct xenbus_device *dev = be->dev;
 
 	if (be->vif != NULL)
-		return;
+		return 0;
 
 	err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%li", &handle);
 	if (err != 1) {
 		xenbus_dev_fatal(dev, err, "reading handle");
-		return;
+		return (err < 0) ? err : -EINVAL;
 	}
 
 	be->vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle);
@@ -417,10 +419,11 @@ static void backend_create_xenvif(struct backend_info *be)
 		err = PTR_ERR(be->vif);
 		be->vif = NULL;
 		xenbus_dev_fatal(dev, err, "creating interface");
-		return;
+		return err;
 	}
 
 	kobject_uevent(&dev->dev.kobj, KOBJ_ONLINE);
+	return 0;
 }
 
 static void backend_disconnect(struct backend_info *be)
-- 
1.9.1

^ permalink raw reply related

* Re: [RFC PATCH 1/4] rtnetlink: new flag NLM_F_HW_OFFLOAD to indicate kernel object offload to hardware
From: Thomas Graf @ 2014-11-21 23:12 UTC (permalink / raw)
  To: roopa
  Cc: jiri, sfeldma, jhs, bcrl, john.fastabend, stephen, linville,
	nhorman, nicolas.dichtel, vyasevic, f.fainelli, buytenh, aviadr,
	netdev, davem, shrijeet, gospo
In-Reply-To: <1416610170-21224-2-git-send-email-roopa@cumulusnetworks.com>

On 11/21/14 at 02:49pm, roopa@cumulusnetworks.com wrote:
> diff --git a/include/uapi/linux/netlink.h b/include/uapi/linux/netlink.h
> index 1a85940..f78522d 100644
> --- a/include/uapi/linux/netlink.h
> +++ b/include/uapi/linux/netlink.h
> @@ -54,6 +54,8 @@ struct nlmsghdr {
>  #define NLM_F_ACK		4	/* Reply with ack, with zero or error code */
>  #define NLM_F_ECHO		8	/* Echo this request 		*/
>  #define NLM_F_DUMP_INTR		16	/* Dump was inconsistent due to sequence change */
> ++#define NLM_F_KERNEL       32      /* This msg is only for the kernel */
> +#define NLM_F_HW_OFFLOAD	64	/* offload this msg to hw */
>  
>  /* Modifiers to GET request */
>  #define NLM_F_ROOT	0x100	/* specify tree	root	*/

The NLM_F_ flag space applies to all Netlink messages including non
networking bits and is reserved for flags vital to the functioning
of the Netlink protocol itself. I suggest you move this to a
RTNETLINK specific flags space.

^ permalink raw reply


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