Message ID | 33f51c5eddec843260451eccbfa3c5fdea13b479.1287132437.git.xiaohui.xin@intel.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
From: xiaohui.xin@intel.com Date: Fri, 15 Oct 2010 17:12:11 +0800 > @@ -2891,6 +2922,11 @@ static int __netif_receive_skb(struct sk_buff *skb) > ncls: > #endif > > + /* To intercept mediate passthru(zero-copy) packets here */ > + skb = handle_mpassthru(skb, &pt_prev, &ret, orig_dev); > + if (!skb) > + goto out; > + > /* Handle special case of bridge or macvlan */ > rx_handler = rcu_dereference(skb->dev->rx_handler); > if (rx_handler) { If you consume the packet here, devices in passthru mode cannot be use with bonding. But there is nothing that prevents a bond being created with such a device. So we have to either prevent such configurations (bad) or make it work somehow (good) :-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
>-----Original Message----- >From: David Miller [mailto:davem@davemloft.net] >Sent: Tuesday, October 19, 2010 11:24 PM >To: Xin, Xiaohui >Cc: netdev@vger.kernel.org; kvm@vger.kernel.org; linux-kernel@vger.kernel.org; >mst@redhat.com; mingo@elte.hu; herbert@gondor.apana.org.au; jdike@linux.intel.com >Subject: Re: [PATCH v13 10/16] Add a hook to intercept external buffers from NIC driver. > >From: xiaohui.xin@intel.com >Date: Fri, 15 Oct 2010 17:12:11 +0800 > >> @@ -2891,6 +2922,11 @@ static int __netif_receive_skb(struct sk_buff *skb) >> ncls: >> #endif >> >> + /* To intercept mediate passthru(zero-copy) packets here */ >> + skb = handle_mpassthru(skb, &pt_prev, &ret, orig_dev); >> + if (!skb) >> + goto out; >> + >> /* Handle special case of bridge or macvlan */ >> rx_handler = rcu_dereference(skb->dev->rx_handler); >> if (rx_handler) { > >If you consume the packet here, devices in passthru mode cannot >be use with bonding. > >But there is nothing that prevents a bond being created with such >a device. > >So we have to either prevent such configurations (bad) or make >it work somehow (good) :-) The big picture may like this: To prevent such configurations, we should add code to check in both mp and bonding driver. If a nic is in zero-copy mode , bonding can't be made with it, and if nic is in bonding mode, we can't bind the device to do zero-copy. If we want to support such configurations, it also has some constraints. If bonding is created first, we need code to check if all the slaves support zero-copy mode, and if yes, all the slaves should be assigned a same page_ctor(), all the packets received should be intercepted with master nic. If not, fails. If zero-copy is enabled first, bonding created with it should fail. Somehow, it seems not a trivial work to support it now. Can we support it later and as a todo with our current work? Thanks Xiaohui -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: "Xin, Xiaohui" <xiaohui.xin@intel.com> Date: Wed, 27 Oct 2010 09:33:12 +0800 > Somehow, it seems not a trivial work to support it now. Can we support it > later and as a todo with our current work? I would prefer the feature work properly, rather than only in specific cases, before being integated. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
I have addressed this issue in v14 patch set. Thanks Xiaohui >-----Original Message----- >From: David Miller [mailto:davem@davemloft.net] >Sent: Saturday, October 30, 2010 4:29 AM >To: Xin, Xiaohui >Cc: netdev@vger.kernel.org; kvm@vger.kernel.org; linux-kernel@vger.kernel.org; >mst@redhat.com; mingo@elte.hu; herbert@gondor.apana.org.au; jdike@linux.intel.com >Subject: Re: [PATCH v13 10/16] Add a hook to intercept external buffers from NIC driver. > >From: "Xin, Xiaohui" <xiaohui.xin@intel.com> >Date: Wed, 27 Oct 2010 09:33:12 +0800 > >> Somehow, it seems not a trivial work to support it now. Can we support it >> later and as a todo with our current work? > >I would prefer the feature work properly, rather than only in specific >cases, before being integated. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/core/dev.c b/net/core/dev.c index e48639d..235eaab 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2814,6 +2814,37 @@ int __skb_bond_should_drop(struct sk_buff *skb, struct net_device *master) } EXPORT_SYMBOL(__skb_bond_should_drop); +#if defined(CONFIG_MEDIATE_PASSTHRU) || defined(CONFIG_MEDIATE_PASSTHRU_MODULE) +/* Add a hook to intercept mediate passthru(zero-copy) packets, + * and insert it to the socket queue owned by mp_port specially. + */ +static inline struct sk_buff *handle_mpassthru(struct sk_buff *skb, + struct packet_type **pt_prev, + int *ret, + struct net_device *orig_dev) +{ + struct mp_port *mp_port = NULL; + struct sock *sk = NULL; + + if (!dev_is_mpassthru(skb->dev)) + return skb; + mp_port = skb->dev->mp_port; + + if (*pt_prev) { + *ret = deliver_skb(skb, *pt_prev, orig_dev); + *pt_prev = NULL; + } + + sk = mp_port->sock->sk; + skb_queue_tail(&sk->sk_receive_queue, skb); + sk->sk_state_change(sk); + + return NULL; +} +#else +#define handle_mpassthru(skb, pt_prev, ret, orig_dev) (skb) +#endif + static int __netif_receive_skb(struct sk_buff *skb) { struct packet_type *ptype, *pt_prev; @@ -2891,6 +2922,11 @@ static int __netif_receive_skb(struct sk_buff *skb) ncls: #endif + /* To intercept mediate passthru(zero-copy) packets here */ + skb = handle_mpassthru(skb, &pt_prev, &ret, orig_dev); + if (!skb) + goto out; + /* Handle special case of bridge or macvlan */ rx_handler = rcu_dereference(skb->dev->rx_handler); if (rx_handler) { @@ -2991,6 +3027,7 @@ err: EXPORT_SYMBOL(netdev_mp_port_prep); #endif + /** * netif_receive_skb - process receive buffer from network * @skb: buffer to process