From mboxrd@z Thu Jan 1 00:00:00 1970 From: Teck Choon Giam Subject: Re: Trying to adapt Olaf's vif MTU patch for EL5.6's 2.6.18-238.9 kernel - patch in-line. Date: Sun, 17 Apr 2011 11:23:53 +0800 Message-ID: References: <4DAA4602.8080701@alteeve.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <4DAA4602.8080701@alteeve.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Digimer Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Sun, Apr 17, 2011 at 9:44 AM, Digimer wrote: > Hi all, > > =A0As per the request on ##xen, I'm reposting this with patches and > diff's inline. Please ignore my earlier post. > > =A0With a *lot* of help from Pasi yesterday, I was trying to get Olaf's > vif MTU patch > (http://lists.xensource.com/archives/html/xen-devel/2011-02/msg00352.html= ) > applied against the most recent EL5.6 (RHEL 5.6/CentOS 5.6) kernel > version 2.6.18-238.9. > > =A0The patch as-is didn't apply cleanly, as there seemed to be a line > shift issue with common.h and xenbus.c. I manually added the lines and > created a new patch, but I screwed something up and it fails to compile. > I should note that I am /not/ a C programmer. :) > > =A0Here is adapted patch: > > =3D=3D=3D=3D > --- linux-2.6.18.x86_64/drivers/xen/netback/common.h.orig =A0 =A0 =A0 201= 1-04-15 > 17:46:12.730677042 -0400 > +++ linux-2.6.18.x86_64/drivers/xen/netback/common.h =A0 =A02011-04-15 > 17:57:57.490721792 -0400 > @@ -76,8 +76,13 @@ > =A0 =A0 =A0 =A0struct vm_struct *tx_comms_area; > =A0 =A0 =A0 =A0struct vm_struct *rx_comms_area; > > - =A0 =A0 =A0 /* Set of features that can be turned on in dev->features. = */ > - =A0 =A0 =A0 int features; > + =A0 =A0 =A0 /* Flags that must not be set in dev->features */ > + =A0 =A0 =A0 int features_disabled; > + > + =A0 =A0 =A0 /* Frontend feature information. */ > + =A0 =A0 =A0 u8 can_sg:1; > + =A0 =A0 =A0 u8 gso:1; > + =A0 =A0 =A0 u8 csum:1; > > =A0 =A0 =A0 =A0/* Internal feature information. */ > =A0 =A0 =A0 =A0int can_queue:1; =A0 =A0 =A0 =A0/* can queue packets for r= eceiver? */ > @@ -110,6 +115,7 @@ > > =A0void netif_disconnect(netif_t *netif); > > +void netif_set_features(netif_t *netif); > =A0netif_t *netif_alloc(domid_t domid, unsigned int handle); > =A0int netif_map(netif_t *netif, unsigned long tx_ring_ref, > =A0 =A0 =A0 =A0 =A0 =A0 =A0unsigned long rx_ring_ref, unsigned int evtchn= ); > @@ -142,7 +148,7 @@ > =A0static inline int netbk_can_sg(struct net_device *dev) > =A0{ > =A0 =A0 =A0 =A0netif_t *netif =3D netdev_priv(dev); > - =A0 =A0 =A0 return netif->features & NETIF_F_SG; > + =A0 =A0 =A0 return netif->can_sg; > =A0} > > =A0#endif /* __NETIF__BACKEND__COMMON_H__ */ > --- linux-2.6.18.x86_64/drivers/xen/netback/interface.c.orig =A0 =A02011-= 04-15 > 17:46:57.205456542 -0400 > +++ linux-2.6.18.x86_64/drivers/xen/netback/interface.c 2011-04-15 > 17:50:46.027757042 -0400 > @@ -90,34 +90,75 @@ > =A0 =A0 =A0 =A0return 0; > =A0} > > -static int netbk_set_sg(struct net_device *dev, u32 data) > +void netif_set_features(netif_t *netif) > =A0{ > + =A0 =A0 =A0 struct net_device *dev =3D netif->dev; > + =A0 =A0 =A0 int features =3D dev->features; > + > + =A0 =A0 =A0 if (netif->can_sg) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 features |=3D NETIF_F_SG; > + =A0 =A0 =A0 if (netif->gso) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 features |=3D NETIF_F_TSO; > + =A0 =A0 =A0 if (netif->csum) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 features |=3D NETIF_F_IP_CSUM; > + > + =A0 =A0 =A0 features &=3D ~(netif->features_disabled); > + > + =A0 =A0 =A0 if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev->mtu =3D ETH_DATA_LEN; > + > + =A0 =A0 =A0 dev->features =3D features; > +} > + > +static int netbk_set_tx_csum(struct net_device *dev, u32 data) > +{ > + =A0 =A0 =A0 netif_t *netif =3D netdev_priv(dev); > =A0 =A0 =A0 =A0if (data) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif_t *netif =3D netdev_priv(dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!netif->csum) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENOSYS; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif->features_disabled &=3D ~NETIF_F_IP_C= SUM; > + =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif->features_disabled |=3D NETIF_F_IP_CS= UM; > + =A0 =A0 =A0 } > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!(netif->features & NETIF_F_SG)) > + =A0 =A0 =A0 netif_set_features(netif); > + =A0 =A0 =A0 return 0; > +} > + > +static int netbk_set_sg(struct net_device *dev, u32 data) > +{ > + =A0 =A0 =A0 netif_t *netif =3D netdev_priv(dev); > + =A0 =A0 =A0 if (data) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!netif->can_sg) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -ENOSYS; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif->features_disabled &=3D ~NETIF_F_SG; > + =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif->features_disabled |=3D NETIF_F_SG; > =A0 =A0 =A0 =A0} > > - =A0 =A0 =A0 return ethtool_op_set_sg(dev, data); > + =A0 =A0 =A0 netif_set_features(netif); > + =A0 =A0 =A0 return 0; > =A0} > > =A0static int netbk_set_tso(struct net_device *dev, u32 data) > =A0{ > + =A0 =A0 =A0 netif_t *netif =3D netdev_priv(dev); > =A0 =A0 =A0 =A0if (data) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif_t *netif =3D netdev_priv(dev); > - > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!(netif->features & NETIF_F_TSO)) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!netif->gso) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -ENOSYS; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif->features_disabled &=3D ~NETIF_F_TSO; > + =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif->features_disabled |=3D NETIF_F_TSO; > =A0 =A0 =A0 =A0} > > - =A0 =A0 =A0 return ethtool_op_set_tso(dev, data); > + =A0 =A0 =A0 netif_set_features(netif); > + =A0 =A0 =A0 return 0; > =A0} > > =A0static struct ethtool_ops network_ethtool_ops =3D > =A0{ > =A0 =A0 =A0 =A0.get_tx_csum =3D ethtool_op_get_tx_csum, > - =A0 =A0 =A0 .set_tx_csum =3D ethtool_op_set_tx_csum, > + =A0 =A0 =A0 .set_tx_csum =3D netbk_set_tx_csum, > =A0 =A0 =A0 =A0.get_sg =3D ethtool_op_get_sg, > =A0 =A0 =A0 =A0.set_sg =3D netbk_set_sg, > =A0 =A0 =A0 =A0.get_tso =3D ethtool_op_get_tso, > @@ -145,6 +186,8 @@ > =A0 =A0 =A0 =A0memset(netif, 0, sizeof(*netif)); > =A0 =A0 =A0 =A0netif->domid =A0=3D domid; > =A0 =A0 =A0 =A0netif->handle =3D handle; > + =A0 =A0 =A0 netif->can_sg =3D 1; > + =A0 =A0 =A0 netif->csum =3D 1; > =A0 =A0 =A0 =A0atomic_set(&netif->refcnt, 1); > =A0 =A0 =A0 =A0init_waitqueue_head(&netif->waiting_to_free); > =A0 =A0 =A0 =A0netif->dev =3D dev; > @@ -162,7 +205,8 @@ > =A0 =A0 =A0 =A0dev->open =A0 =A0 =A0 =A0 =A0 =A0=3D net_open; > =A0 =A0 =A0 =A0dev->stop =A0 =A0 =A0 =A0 =A0 =A0=3D net_close; > =A0 =A0 =A0 =A0dev->change_mtu =A0 =A0 =A0=3D netbk_change_mtu; > - =A0 =A0 =A0 dev->features =A0 =A0 =A0 =A0=3D NETIF_F_IP_CSUM; > + > + =A0 =A0 =A0 netif_set_features(netif); > > =A0 =A0 =A0 =A0SET_ETHTOOL_OPS(dev, &network_ethtool_ops); > > --- linux-2.6.18.x86_64/drivers/xen/netback/netback.c.orig =A0 =A0 =A0201= 1-04-15 > 17:46:58.141515042 -0400 > +++ linux-2.6.18.x86_64/drivers/xen/netback/netback.c =A0 2011-04-15 > 17:50:46.027757042 -0400 > @@ -215,7 +215,7 @@ > > =A0static inline int netbk_max_required_rx_slots(netif_t *netif) > =A0{ > - =A0 =A0 =A0 if (netif->features & (NETIF_F_SG|NETIF_F_TSO)) > + =A0 =A0 =A0 if (netif->can_sg || netif->gso) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return MAX_SKB_FRAGS + 2; /* header + extr= a_info + frags */ > =A0 =A0 =A0 =A0return 1; /* all in one */ > =A0} > --- linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c.orig =A0 =A0 =A0 201= 1-04-15 > 17:46:59.217582292 -0400 > +++ linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c =A0 =A02011-04-15 > 18:13:20.700418792 -0400 > @@ -345,6 +345,7 @@ > > =A0static int connect_rings(struct backend_info *be) > =A0{ > + =A0 =A0 =A0 netif_t *netif =3D be->netif; > =A0 =A0 =A0 =A0struct xenbus_device *dev =3D be->dev; > =A0 =A0 =A0 =A0unsigned long tx_ring_ref, rx_ring_ref; > =A0 =A0 =A0 =A0unsigned int evtchn, rx_copy; > @@ -375,46 +376,40 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev->othe= rend); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return err; > =A0 =A0 =A0 =A0} > - =A0 =A0 =A0 be->netif->copying_receiver =3D !!rx_copy; > + =A0 =A0 =A0 netif->copying_receiver =3D !!rx_copy; > > - =A0 =A0 =A0 if (be->netif->dev->tx_queue_len !=3D 0) { > + =A0 =A0 =A0 if (netif->dev->tx_queue_len !=3D 0) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (xenbus_scanf(XBT_NIL, dev->otherend, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "feature-= rx-notify", "%d", &val) < 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0val =3D 0; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (val) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 be->netif->can_queue =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif->can_queue =3D 1 You need to end semi-colon for the above which I think your compile error output is showing I guess. > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Must be non-zero for pf= ifo_fast to work. */ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 be->netif->dev->tx_queue_le= n =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 netif->dev->tx_queue_len = =3D 1; > =A0 =A0 =A0 =A0} > > =A0 =A0 =A0 =A0if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg", "%d= ", &val) < 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0val =3D 0; > - =A0 =A0 =A0 if (val) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 be->netif->features |=3D NETIF_F_SG; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 be->netif->dev->features |=3D NETIF_F_SG; > - =A0 =A0 =A0 } > + =A0 =A0 =A0 netif->can_sg =3D !!val; > > =A0 =A0 =A0 =A0if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv= 4", "%d", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &val) < 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0val =3D 0; > - =A0 =A0 =A0 if (val) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 be->netif->features |=3D NETIF_F_TSO; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 be->netif->dev->features |=3D NETIF_F_TSO; > - =A0 =A0 =A0 } > + =A0 =A0 =A0 netif->gso =3D !!val; > > =A0 =A0 =A0 =A0if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-no-csum-= offload", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "%d", &val) < 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0val =3D 0; > - =A0 =A0 =A0 if (val) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 be->netif->features &=3D ~NETIF_F_IP_CSUM; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 be->netif->dev->features &=3D ~NETIF_F_IP_C= SUM; > - =A0 =A0 =A0 } > + =A0 =A0 =A0 netif->csum =3D !val; > + > + =A0 =A0 =A0 /* Set dev->features */ > + =A0 =A0 =A0 netif_set_features(netif); > > =A0 =A0 =A0 =A0netdev_features_change(be->netif->dev); > > =A0 =A0 =A0 =A0/* Map the shared frame, irq etc. */ > - =A0 =A0 =A0 err =3D netif_map(be->netif, tx_ring_ref, rx_ring_ref, evtc= hn); > + =A0 =A0 =A0 err =3D netif_map(netif, tx_ring_ref, rx_ring_ref, evtchn); > =A0 =A0 =A0 =A0if (err) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xenbus_dev_fatal(dev, err, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "mapping = shared-frames %lu/%lu port %u", > =3D=3D=3D=3D > > =A0And here is the compile output with errors: > > =3D=3D=3D=3D > drivers/xen/blkfront/blkfront.c: In function 'do_blkif_request': > drivers/xen/blkfront/blkfront.c:629: warning: format '%lx' expects type > 'long unsigned int', but argument 4 has type 'sector_t' > drivers/xen/blktap/blktapmain.c:145: warning: 'set_blkif_reqs' defined > but not used > drivers/xen/netback/xenbus.c: In function 'connect_rings': > drivers/xen/netback/xenbus.c:387: error: expected ';' before 'else' Is the line 387 the one without the ; above? I guess so :p Thanks. Kindest regards, Giam Teck Choon