Jason Wang
2018-Jan-23 10:33 UTC
[RFC PATCH net-next v2 2/2] virtio_net: Extend virtio to use VF datapath when available
On 2018?01?12? 13:58, Sridhar Samudrala wrote:> static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) > { > struct virtnet_info *vi = netdev_priv(dev); > int qnum = skb_get_queue_mapping(skb); > struct send_queue *sq = &vi->sq[qnum]; > + struct net_device *vf_netdev; > int err; > struct netdev_queue *txq = netdev_get_tx_queue(dev, qnum); > bool kick = !skb->xmit_more; > bool use_napi = sq->napi.weight; > > + /* If VF is present and up then redirect packets > + * called with rcu_read_lock_bh > + */ > + vf_netdev = rcu_dereference_bh(vi->vf_netdev); > + if (vf_netdev && netif_running(vf_netdev) && > + !netpoll_tx_running(dev) && > + is_unicast_ether_addr(eth_hdr(skb)->h_dest)) > + return virtnet_vf_xmit(dev, vf_netdev, skb); > +A question here. If I read the code correctly, all features were validated against virtio instead VF before transmitting. This assumes VF's feature is a superset of virtio, does this really work? Do we need to sanitize the feature before joining? (e.g at last NETIF_R_GSO_ROBUST needs to be removed). Thanks
Samudrala, Sridhar
2018-Jan-23 16:03 UTC
[RFC PATCH net-next v2 2/2] virtio_net: Extend virtio to use VF datapath when available
On 1/23/2018 2:33 AM, Jason Wang wrote:> > > On 2018?01?12? 13:58, Sridhar Samudrala wrote: >> ? static netdev_tx_t start_xmit(struct sk_buff *skb, struct >> net_device *dev) >> ? { >> ????? struct virtnet_info *vi = netdev_priv(dev); >> ????? int qnum = skb_get_queue_mapping(skb); >> ????? struct send_queue *sq = &vi->sq[qnum]; >> +??? struct net_device *vf_netdev; >> ????? int err; >> ????? struct netdev_queue *txq = netdev_get_tx_queue(dev, qnum); >> ????? bool kick = !skb->xmit_more; >> ????? bool use_napi = sq->napi.weight; >> ? +??? /* If VF is present and up then redirect packets >> +???? * called with rcu_read_lock_bh >> +???? */ >> +??? vf_netdev = rcu_dereference_bh(vi->vf_netdev); >> +??? if (vf_netdev && netif_running(vf_netdev) && >> +??????? !netpoll_tx_running(dev) && >> +??????? is_unicast_ether_addr(eth_hdr(skb)->h_dest)) >> +??????? return virtnet_vf_xmit(dev, vf_netdev, skb); >> + > > A question here. > > If I read the code correctly, all features were validated against > virtio instead VF before transmitting. This assumes VF's feature is a > superset of virtio, does this really work? Do we need to sanitize the > feature before joining? (e.g at last NETIF_R_GSO_ROBUST needs to be > removed).Actually, virtnet_vf_xmit() calls dev_queue_xmit() after updating skb->dev to vf netdev. So the features get validated against VF features and the right tx queue is selected before the real transmit. Thanks Sridhar
Jason Wang
2018-Jan-29 03:32 UTC
[RFC PATCH net-next v2 2/2] virtio_net: Extend virtio to use VF datapath when available
On 2018?01?24? 00:03, Samudrala, Sridhar wrote:> > > On 1/23/2018 2:33 AM, Jason Wang wrote: >> >> >> On 2018?01?12? 13:58, Sridhar Samudrala wrote: >>> ? static netdev_tx_t start_xmit(struct sk_buff *skb, struct >>> net_device *dev) >>> ? { >>> ????? struct virtnet_info *vi = netdev_priv(dev); >>> ????? int qnum = skb_get_queue_mapping(skb); >>> ????? struct send_queue *sq = &vi->sq[qnum]; >>> +??? struct net_device *vf_netdev; >>> ????? int err; >>> ????? struct netdev_queue *txq = netdev_get_tx_queue(dev, qnum); >>> ????? bool kick = !skb->xmit_more; >>> ????? bool use_napi = sq->napi.weight; >>> ? +??? /* If VF is present and up then redirect packets >>> +???? * called with rcu_read_lock_bh >>> +???? */ >>> +??? vf_netdev = rcu_dereference_bh(vi->vf_netdev); >>> +??? if (vf_netdev && netif_running(vf_netdev) && >>> +??????? !netpoll_tx_running(dev) && >>> +??????? is_unicast_ether_addr(eth_hdr(skb)->h_dest)) >>> +??????? return virtnet_vf_xmit(dev, vf_netdev, skb); >>> + >> >> A question here. >> >> If I read the code correctly, all features were validated against >> virtio instead VF before transmitting. This assumes VF's feature is a >> superset of virtio, does this really work? Do we need to sanitize the >> feature before joining? (e.g at last NETIF_R_GSO_ROBUST needs to be >> removed). > > Actually, virtnet_vf_xmit() calls dev_queue_xmit() after updating > skb->dev to vf netdev. > So the features get validated against VF features and the right tx > queue is selected > before the real transmit.I see, the the packet will go through qdiscs twice which is suboptimal. And the device may lose some ability of VF like tunnel GSO. Thanks> > Thanks > Sridhar > > >
Maybe Matching Threads
- [RFC PATCH net-next v2 2/2] virtio_net: Extend virtio to use VF datapath when available
- [RFC PATCH net-next v2 2/2] virtio_net: Extend virtio to use VF datapath when available
- [RFC PATCH net-next v2 2/2] virtio_net: Extend virtio to use VF datapath when available
- [RFC PATCH] virtio_net: Extend virtio to use VF datapath when available
- [RFC PATCH net-next v2 2/2] virtio_net: Extend virtio to use VF datapath when available