Digimer
2011-Apr-17 01:44 UTC
[Xen-devel] Trying to adapt Olaf''s vif MTU patch for EL5.6''s 2.6.18-238.9 kernel - patch in-line.
Hi all, As per the request on ##xen, I''m reposting this with patches and diff''s inline. Please ignore my earlier post. With 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. The 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. :) Here is adapted patch: ===--- linux-2.6.18.x86_64/drivers/xen/netback/common.h.orig 2011-04-15 17:46:12.730677042 -0400 +++ linux-2.6.18.x86_64/drivers/xen/netback/common.h 2011-04-15 17:57:57.490721792 -0400 @@ -76,8 +76,13 @@ struct vm_struct *tx_comms_area; struct vm_struct *rx_comms_area; - /* Set of features that can be turned on in dev->features. */ - int features; + /* Flags that must not be set in dev->features */ + int features_disabled; + + /* Frontend feature information. */ + u8 can_sg:1; + u8 gso:1; + u8 csum:1; /* Internal feature information. */ int can_queue:1; /* can queue packets for receiver? */ @@ -110,6 +115,7 @@ void netif_disconnect(netif_t *netif); +void netif_set_features(netif_t *netif); netif_t *netif_alloc(domid_t domid, unsigned int handle); int netif_map(netif_t *netif, unsigned long tx_ring_ref, unsigned long rx_ring_ref, unsigned int evtchn); @@ -142,7 +148,7 @@ static inline int netbk_can_sg(struct net_device *dev) { netif_t *netif = netdev_priv(dev); - return netif->features & NETIF_F_SG; + return netif->can_sg; } #endif /* __NETIF__BACKEND__COMMON_H__ */ --- linux-2.6.18.x86_64/drivers/xen/netback/interface.c.orig 2011-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 @@ return 0; } -static int netbk_set_sg(struct net_device *dev, u32 data) +void netif_set_features(netif_t *netif) { + struct net_device *dev = netif->dev; + int features = dev->features; + + if (netif->can_sg) + features |= NETIF_F_SG; + if (netif->gso) + features |= NETIF_F_TSO; + if (netif->csum) + features |= NETIF_F_IP_CSUM; + + features &= ~(netif->features_disabled); + + if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) + dev->mtu = ETH_DATA_LEN; + + dev->features = features; +} + +static int netbk_set_tx_csum(struct net_device *dev, u32 data) +{ + netif_t *netif = netdev_priv(dev); if (data) { - netif_t *netif = netdev_priv(dev); + if (!netif->csum) + return -ENOSYS; + netif->features_disabled &= ~NETIF_F_IP_CSUM; + } else { + netif->features_disabled |= NETIF_F_IP_CSUM; + } - if (!(netif->features & NETIF_F_SG)) + netif_set_features(netif); + return 0; +} + +static int netbk_set_sg(struct net_device *dev, u32 data) +{ + netif_t *netif = netdev_priv(dev); + if (data) { + if (!netif->can_sg) return -ENOSYS; + netif->features_disabled &= ~NETIF_F_SG; + } else { + netif->features_disabled |= NETIF_F_SG; } - return ethtool_op_set_sg(dev, data); + netif_set_features(netif); + return 0; } static int netbk_set_tso(struct net_device *dev, u32 data) { + netif_t *netif = netdev_priv(dev); if (data) { - netif_t *netif = netdev_priv(dev); - - if (!(netif->features & NETIF_F_TSO)) + if (!netif->gso) return -ENOSYS; + netif->features_disabled &= ~NETIF_F_TSO; + } else { + netif->features_disabled |= NETIF_F_TSO; } - return ethtool_op_set_tso(dev, data); + netif_set_features(netif); + return 0; } static struct ethtool_ops network_ethtool_ops { .get_tx_csum = ethtool_op_get_tx_csum, - .set_tx_csum = ethtool_op_set_tx_csum, + .set_tx_csum = netbk_set_tx_csum, .get_sg = ethtool_op_get_sg, .set_sg = netbk_set_sg, .get_tso = ethtool_op_get_tso, @@ -145,6 +186,8 @@ memset(netif, 0, sizeof(*netif)); netif->domid = domid; netif->handle = handle; + netif->can_sg = 1; + netif->csum = 1; atomic_set(&netif->refcnt, 1); init_waitqueue_head(&netif->waiting_to_free); netif->dev = dev; @@ -162,7 +205,8 @@ dev->open = net_open; dev->stop = net_close; dev->change_mtu = netbk_change_mtu; - dev->features = NETIF_F_IP_CSUM; + + netif_set_features(netif); SET_ETHTOOL_OPS(dev, &network_ethtool_ops); --- linux-2.6.18.x86_64/drivers/xen/netback/netback.c.orig 2011-04-15 17:46:58.141515042 -0400 +++ linux-2.6.18.x86_64/drivers/xen/netback/netback.c 2011-04-15 17:50:46.027757042 -0400 @@ -215,7 +215,7 @@ static inline int netbk_max_required_rx_slots(netif_t *netif) { - if (netif->features & (NETIF_F_SG|NETIF_F_TSO)) + if (netif->can_sg || netif->gso) return MAX_SKB_FRAGS + 2; /* header + extra_info + frags */ return 1; /* all in one */ } --- linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c.orig 2011-04-15 17:46:59.217582292 -0400 +++ linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c 2011-04-15 18:13:20.700418792 -0400 @@ -345,6 +345,7 @@ static int connect_rings(struct backend_info *be) { + netif_t *netif = be->netif; struct xenbus_device *dev = be->dev; unsigned long tx_ring_ref, rx_ring_ref; unsigned int evtchn, rx_copy; @@ -375,46 +376,40 @@ dev->otherend); return err; } - be->netif->copying_receiver = !!rx_copy; + netif->copying_receiver = !!rx_copy; - if (be->netif->dev->tx_queue_len != 0) { + if (netif->dev->tx_queue_len != 0) { if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-rx-notify", "%d", &val) < 0) val = 0; if (val) - be->netif->can_queue = 1; + netif->can_queue = 1 else /* Must be non-zero for pfifo_fast to work. */ - be->netif->dev->tx_queue_len = 1; + netif->dev->tx_queue_len = 1; } if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg", "%d", &val) < 0) val = 0; - if (val) { - be->netif->features |= NETIF_F_SG; - be->netif->dev->features |= NETIF_F_SG; - } + netif->can_sg = !!val; if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4", "%d", &val) < 0) val = 0; - if (val) { - be->netif->features |= NETIF_F_TSO; - be->netif->dev->features |= NETIF_F_TSO; - } + netif->gso = !!val; if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-no-csum-offload", "%d", &val) < 0) val = 0; - if (val) { - be->netif->features &= ~NETIF_F_IP_CSUM; - be->netif->dev->features &= ~NETIF_F_IP_CSUM; - } + netif->csum = !val; + + /* Set dev->features */ + netif_set_features(netif); netdev_features_change(be->netif->dev); /* Map the shared frame, irq etc. */ - err = netif_map(be->netif, tx_ring_ref, rx_ring_ref, evtchn); + err = netif_map(netif, tx_ring_ref, rx_ring_ref, evtchn); if (err) { xenbus_dev_fatal(dev, err, "mapping shared-frames %lu/%lu port %u", === And here is the compile output with errors: ===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'' make[3]: *** [drivers/xen/netback/xenbus.o] Error 1 make[2]: *** [drivers/xen/netback] Error 2 make[1]: *** [drivers/xen] Error 2 make[1]: *** Waiting for unfinished jobs.... drivers/scsi/fcoe/fcoe.c: In function ''fcoe_interface_setup'': drivers/scsi/fcoe/fcoe.c:259: warning: unused variable ''ops'' drivers/scsi/fcoe/fcoe.c:256: warning: unused variable ''ha'' drivers/scsi/fcoe/fcoe.c: In function ''fcoe_interface_cleanup'': drivers/scsi/fcoe/fcoe.c:379: warning: unused variable ''ops'' drivers/net/phy/fixed.c: In function ''fixed_init'': drivers/net/phy/fixed.c:316: warning: unused variable ''duplex'' drivers/net/phy/fixed.c:315: warning: unused variable ''ret'' drivers/net/sfc/mtd.c:25:1: warning: "pr_fmt" redefined In file included from include/asm/mach-xen/asm/page.h:8, from include/asm/thread_info.h:12, from include/linux/thread_info.h:21, from include/linux/preempt.h:9, from include/linux/spinlock.h:49, from include/linux/capability.h:45, from include/linux/sched.h:44, from include/linux/module.h:9, from drivers/net/sfc/mtd.c:12: include/linux/kernel.h:261:1: warning: this is the location of the previous definition drivers/net/wireless/iwlwifi/iwl3945-base.c: In function ''store_antenna'': drivers/net/wireless/iwlwifi/iwl3945-base.c:3656: warning: unused variable ''priv'' drivers/net/wireless/iwlwifi/iwl3945-base.c: In function ''iwl3945_cancel_deferred_work'': drivers/net/wireless/iwlwifi/iwl3945-base.c:3739: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/iwlwifi/iwl3945-base.c: In function ''iwl3945_pci_remove'': drivers/net/wireless/iwlwifi/iwl3945-base.c:4147: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/iwlwifi/iwl-3945-rs.c: In function ''iwl3945_rate_scale_flush_windows'': drivers/net/wireless/iwlwifi/iwl-3945-rs.c:190: warning: unused variable ''priv'' drivers/net/wireless/iwlwifi/iwl-3945-rs.c: In function ''iwl3945_bg_rate_scale_flush'': drivers/net/wireless/iwlwifi/iwl-3945-rs.c:223: warning: unused variable ''priv'' drivers/net/wireless/iwlwifi/iwl-3945-rs.c: In function ''iwl3945_collect_tx_data'': drivers/net/wireless/iwlwifi/iwl-3945-rs.c:297: warning: unused variable ''priv'' drivers/net/wireless/iwlwifi/iwl-3945-rs.c: In function ''rs_free_sta'': drivers/net/wireless/iwlwifi/iwl-3945-rs.c:464: warning: unused variable ''priv'' drivers/net/wireless/iwlwifi/iwl-3945-rs.c: In function ''iwl3945_get_adjacent_rate'': drivers/net/wireless/iwlwifi/iwl-3945-rs.c:585: warning: unused variable ''priv'' drivers/net/wireless/iwlwifi/iwl-agn.c: In function ''iwl_cancel_deferred_work'': drivers/net/wireless/iwlwifi/iwl-agn.c:2850: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/ath/ath9k/main.c: In function ''ath_init_leds'': drivers/net/wireless/ath/ath9k/main.c:1122: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/ath/ath9k/main.c: In function ''ath9k_stop'': drivers/net/wireless/ath/ath9k/main.c:2138: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/ath/ath9k/main.c:2139: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/ath/ath9k/main.c:2142: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/iwlwifi/iwl-agn-rs.c: In function ''rs_free_sta'': drivers/net/wireless/iwlwifi/iwl-agn-rs.c:2849: warning: unused variable ''priv'' drivers/net/wireless/ath/ath9k/virtual.c: In function ''ath9k_wiphy_set_scheduler'': drivers/net/wireless/ath/ath9k/virtual.c:657: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/rt2x00/rt2x00link.c: In function ''rt2x00link_stop_tuner'': drivers/net/wireless/rt2x00/rt2x00link.c:372: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/rtl818x/rtl8187_dev.c: In function ''rtl8187_stop'': drivers/net/wireless/rtl818x/rtl8187_dev.c:1063: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/rtl818x/rtl8187_leds.c: In function ''rtl8187_leds_init'': drivers/net/wireless/rtl818x/rtl8187_leds.c:201: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/rtl818x/rtl8187_leds.c:202: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/rtl818x/rtl8187_leds.c: In function ''rtl8187_leds_exit'': drivers/net/wireless/rtl818x/rtl8187_leds.c:213: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type drivers/net/wireless/rtl818x/rtl8187_leds.c:214: warning: passing argument 1 of ''cancel_delayed_work_sync'' from incompatible pointer type make: *** [drivers] Error 2 + exit 1 error: Bad exit status from /var/tmp/rpm-tmp.88561 (%build) RPM build errors: Bad exit status from /var/tmp/rpm-tmp.88561 (%build) === I applied it as Patch 28000. Here is the diff on the kernel-2.6.spec (http://centos.alteeve.com/5.6/updates/SRPMS/kernel-2.6.18-238.9.1.el5.src.rpm). ===--- kernel-2.6.spec.orig 2011-04-16 12:39:33.000000000 -0400 +++ kernel-2.6.spec 2011-04-16 13:55:15.000000000 -0400 @@ -75,7 +75,7 @@ %define sublevel 18 %define kversion 2.6.%{sublevel} %define rpmversion 2.6.%{sublevel} -%define release 238.9.2%{?dist}%{?buildid} +%define release 238.9.3%{?dist}%{?buildid} %define signmodules 0 %define xen_hv_cset 15502 %define xen_abi_ver 3.1 @@ -6318,6 +6318,7 @@ Patch26314: linux-2.6-md-dm-mpath-hold-io-until-all-pg_inits-completed.patch Patch26315: linux-2.6-md-dm-mpath-wait-for-pg_init-completion-on-suspend.patch Patch26316: linux-2.6-md-dm-mpath-fix-null-deref-when-path-parameter-missing.patch +Patch28000: linux-2.6-xen-netback-allow-large-mtu-until-frontend-connects.patch # adds rhel version info to version.h Patch99990: linux-2.6-rhel-version-h.patch # empty final patch file to facilitate testing of kernel patches @@ -12392,6 +12393,7 @@ %patch26314 -p1 %patch26315 -p1 %patch26316 -p1 +%patch28000 -p1 # correction of SUBLEVEL/EXTRAVERSION in top-level source tree Makefile # patch the Makefile to include rhel version info %patch99990 -p1 === Any advice/help/clue-stick whacking would be much appreciated! -- Digimer E-Mail: digimer@alteeve.com AN!Whitepapers: http://alteeve.com Node Assassin: http://nodeassassin.org _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Teck Choon Giam
2011-Apr-17 03:23 UTC
Re: [Xen-devel] Trying to adapt Olaf''s vif MTU patch for EL5.6''s 2.6.18-238.9 kernel - patch in-line.
On Sun, Apr 17, 2011 at 9:44 AM, Digimer <linux@alteeve.com> wrote:> Hi all, > > As per the request on ##xen, I''m reposting this with patches and > diff''s inline. Please ignore my earlier post. > > With 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. > > The 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. :) > > Here is adapted patch: > > ===> --- linux-2.6.18.x86_64/drivers/xen/netback/common.h.orig 2011-04-15 > 17:46:12.730677042 -0400 > +++ linux-2.6.18.x86_64/drivers/xen/netback/common.h 2011-04-15 > 17:57:57.490721792 -0400 > @@ -76,8 +76,13 @@ > struct vm_struct *tx_comms_area; > struct vm_struct *rx_comms_area; > > - /* Set of features that can be turned on in dev->features. */ > - int features; > + /* Flags that must not be set in dev->features */ > + int features_disabled; > + > + /* Frontend feature information. */ > + u8 can_sg:1; > + u8 gso:1; > + u8 csum:1; > > /* Internal feature information. */ > int can_queue:1; /* can queue packets for receiver? */ > @@ -110,6 +115,7 @@ > > void netif_disconnect(netif_t *netif); > > +void netif_set_features(netif_t *netif); > netif_t *netif_alloc(domid_t domid, unsigned int handle); > int netif_map(netif_t *netif, unsigned long tx_ring_ref, > unsigned long rx_ring_ref, unsigned int evtchn); > @@ -142,7 +148,7 @@ > static inline int netbk_can_sg(struct net_device *dev) > { > netif_t *netif = netdev_priv(dev); > - return netif->features & NETIF_F_SG; > + return netif->can_sg; > } > > #endif /* __NETIF__BACKEND__COMMON_H__ */ > --- linux-2.6.18.x86_64/drivers/xen/netback/interface.c.orig 2011-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 @@ > return 0; > } > > -static int netbk_set_sg(struct net_device *dev, u32 data) > +void netif_set_features(netif_t *netif) > { > + struct net_device *dev = netif->dev; > + int features = dev->features; > + > + if (netif->can_sg) > + features |= NETIF_F_SG; > + if (netif->gso) > + features |= NETIF_F_TSO; > + if (netif->csum) > + features |= NETIF_F_IP_CSUM; > + > + features &= ~(netif->features_disabled); > + > + if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) > + dev->mtu = ETH_DATA_LEN; > + > + dev->features = features; > +} > + > +static int netbk_set_tx_csum(struct net_device *dev, u32 data) > +{ > + netif_t *netif = netdev_priv(dev); > if (data) { > - netif_t *netif = netdev_priv(dev); > + if (!netif->csum) > + return -ENOSYS; > + netif->features_disabled &= ~NETIF_F_IP_CSUM; > + } else { > + netif->features_disabled |= NETIF_F_IP_CSUM; > + } > > - if (!(netif->features & NETIF_F_SG)) > + netif_set_features(netif); > + return 0; > +} > + > +static int netbk_set_sg(struct net_device *dev, u32 data) > +{ > + netif_t *netif = netdev_priv(dev); > + if (data) { > + if (!netif->can_sg) > return -ENOSYS; > + netif->features_disabled &= ~NETIF_F_SG; > + } else { > + netif->features_disabled |= NETIF_F_SG; > } > > - return ethtool_op_set_sg(dev, data); > + netif_set_features(netif); > + return 0; > } > > static int netbk_set_tso(struct net_device *dev, u32 data) > { > + netif_t *netif = netdev_priv(dev); > if (data) { > - netif_t *netif = netdev_priv(dev); > - > - if (!(netif->features & NETIF_F_TSO)) > + if (!netif->gso) > return -ENOSYS; > + netif->features_disabled &= ~NETIF_F_TSO; > + } else { > + netif->features_disabled |= NETIF_F_TSO; > } > > - return ethtool_op_set_tso(dev, data); > + netif_set_features(netif); > + return 0; > } > > static struct ethtool_ops network_ethtool_ops > { > .get_tx_csum = ethtool_op_get_tx_csum, > - .set_tx_csum = ethtool_op_set_tx_csum, > + .set_tx_csum = netbk_set_tx_csum, > .get_sg = ethtool_op_get_sg, > .set_sg = netbk_set_sg, > .get_tso = ethtool_op_get_tso, > @@ -145,6 +186,8 @@ > memset(netif, 0, sizeof(*netif)); > netif->domid = domid; > netif->handle = handle; > + netif->can_sg = 1; > + netif->csum = 1; > atomic_set(&netif->refcnt, 1); > init_waitqueue_head(&netif->waiting_to_free); > netif->dev = dev; > @@ -162,7 +205,8 @@ > dev->open = net_open; > dev->stop = net_close; > dev->change_mtu = netbk_change_mtu; > - dev->features = NETIF_F_IP_CSUM; > + > + netif_set_features(netif); > > SET_ETHTOOL_OPS(dev, &network_ethtool_ops); > > --- linux-2.6.18.x86_64/drivers/xen/netback/netback.c.orig 2011-04-15 > 17:46:58.141515042 -0400 > +++ linux-2.6.18.x86_64/drivers/xen/netback/netback.c 2011-04-15 > 17:50:46.027757042 -0400 > @@ -215,7 +215,7 @@ > > static inline int netbk_max_required_rx_slots(netif_t *netif) > { > - if (netif->features & (NETIF_F_SG|NETIF_F_TSO)) > + if (netif->can_sg || netif->gso) > return MAX_SKB_FRAGS + 2; /* header + extra_info + frags */ > return 1; /* all in one */ > } > --- linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c.orig 2011-04-15 > 17:46:59.217582292 -0400 > +++ linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c 2011-04-15 > 18:13:20.700418792 -0400 > @@ -345,6 +345,7 @@ > > static int connect_rings(struct backend_info *be) > { > + netif_t *netif = be->netif; > struct xenbus_device *dev = be->dev; > unsigned long tx_ring_ref, rx_ring_ref; > unsigned int evtchn, rx_copy; > @@ -375,46 +376,40 @@ > dev->otherend); > return err; > } > - be->netif->copying_receiver = !!rx_copy; > + netif->copying_receiver = !!rx_copy; > > - if (be->netif->dev->tx_queue_len != 0) { > + if (netif->dev->tx_queue_len != 0) { > if (xenbus_scanf(XBT_NIL, dev->otherend, > "feature-rx-notify", "%d", &val) < 0) > val = 0; > if (val) > - be->netif->can_queue = 1; > + netif->can_queue = 1You need to end semi-colon for the above which I think your compile error output is showing I guess.> else > /* Must be non-zero for pfifo_fast to work. */ > - be->netif->dev->tx_queue_len = 1; > + netif->dev->tx_queue_len = 1; > } > > if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg", "%d", &val) < 0) > val = 0; > - if (val) { > - be->netif->features |= NETIF_F_SG; > - be->netif->dev->features |= NETIF_F_SG; > - } > + netif->can_sg = !!val; > > if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4", "%d", > &val) < 0) > val = 0; > - if (val) { > - be->netif->features |= NETIF_F_TSO; > - be->netif->dev->features |= NETIF_F_TSO; > - } > + netif->gso = !!val; > > if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-no-csum-offload", > "%d", &val) < 0) > val = 0; > - if (val) { > - be->netif->features &= ~NETIF_F_IP_CSUM; > - be->netif->dev->features &= ~NETIF_F_IP_CSUM; > - } > + netif->csum = !val; > + > + /* Set dev->features */ > + netif_set_features(netif); > > netdev_features_change(be->netif->dev); > > /* Map the shared frame, irq etc. */ > - err = netif_map(be->netif, tx_ring_ref, rx_ring_ref, evtchn); > + err = netif_map(netif, tx_ring_ref, rx_ring_ref, evtchn); > if (err) { > xenbus_dev_fatal(dev, err, > "mapping shared-frames %lu/%lu port %u", > ===> > And here is the compile output with errors: > > ===> 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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Digimer
2011-Apr-17 03:29 UTC
Re: [Xen-devel] Trying to adapt Olaf''s vif MTU patch for EL5.6''s 2.6.18-238.9 kernel - patch in-line.
On 04/16/2011 11:23 PM, Teck Choon Giam wrote:> On Sun, Apr 17, 2011 at 9:44 AM, Digimer <linux@alteeve.com> wrote: >> Hi all, >> >> As per the request on ##xen, I''m reposting this with patches and >> diff''s inline. Please ignore my earlier post. >> >> With 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. >> >> The 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. :) >> >> Here is adapted patch: >> >> ===>> --- linux-2.6.18.x86_64/drivers/xen/netback/common.h.orig 2011-04-15 >> 17:46:12.730677042 -0400 >> +++ linux-2.6.18.x86_64/drivers/xen/netback/common.h 2011-04-15 >> 17:57:57.490721792 -0400 >> @@ -76,8 +76,13 @@ >> struct vm_struct *tx_comms_area; >> struct vm_struct *rx_comms_area; >> >> - /* Set of features that can be turned on in dev->features. */ >> - int features; >> + /* Flags that must not be set in dev->features */ >> + int features_disabled; >> + >> + /* Frontend feature information. */ >> + u8 can_sg:1; >> + u8 gso:1; >> + u8 csum:1; >> >> /* Internal feature information. */ >> int can_queue:1; /* can queue packets for receiver? */ >> @@ -110,6 +115,7 @@ >> >> void netif_disconnect(netif_t *netif); >> >> +void netif_set_features(netif_t *netif); >> netif_t *netif_alloc(domid_t domid, unsigned int handle); >> int netif_map(netif_t *netif, unsigned long tx_ring_ref, >> unsigned long rx_ring_ref, unsigned int evtchn); >> @@ -142,7 +148,7 @@ >> static inline int netbk_can_sg(struct net_device *dev) >> { >> netif_t *netif = netdev_priv(dev); >> - return netif->features & NETIF_F_SG; >> + return netif->can_sg; >> } >> >> #endif /* __NETIF__BACKEND__COMMON_H__ */ >> --- linux-2.6.18.x86_64/drivers/xen/netback/interface.c.orig 2011-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 @@ >> return 0; >> } >> >> -static int netbk_set_sg(struct net_device *dev, u32 data) >> +void netif_set_features(netif_t *netif) >> { >> + struct net_device *dev = netif->dev; >> + int features = dev->features; >> + >> + if (netif->can_sg) >> + features |= NETIF_F_SG; >> + if (netif->gso) >> + features |= NETIF_F_TSO; >> + if (netif->csum) >> + features |= NETIF_F_IP_CSUM; >> + >> + features &= ~(netif->features_disabled); >> + >> + if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) >> + dev->mtu = ETH_DATA_LEN; >> + >> + dev->features = features; >> +} >> + >> +static int netbk_set_tx_csum(struct net_device *dev, u32 data) >> +{ >> + netif_t *netif = netdev_priv(dev); >> if (data) { >> - netif_t *netif = netdev_priv(dev); >> + if (!netif->csum) >> + return -ENOSYS; >> + netif->features_disabled &= ~NETIF_F_IP_CSUM; >> + } else { >> + netif->features_disabled |= NETIF_F_IP_CSUM; >> + } >> >> - if (!(netif->features & NETIF_F_SG)) >> + netif_set_features(netif); >> + return 0; >> +} >> + >> +static int netbk_set_sg(struct net_device *dev, u32 data) >> +{ >> + netif_t *netif = netdev_priv(dev); >> + if (data) { >> + if (!netif->can_sg) >> return -ENOSYS; >> + netif->features_disabled &= ~NETIF_F_SG; >> + } else { >> + netif->features_disabled |= NETIF_F_SG; >> } >> >> - return ethtool_op_set_sg(dev, data); >> + netif_set_features(netif); >> + return 0; >> } >> >> static int netbk_set_tso(struct net_device *dev, u32 data) >> { >> + netif_t *netif = netdev_priv(dev); >> if (data) { >> - netif_t *netif = netdev_priv(dev); >> - >> - if (!(netif->features & NETIF_F_TSO)) >> + if (!netif->gso) >> return -ENOSYS; >> + netif->features_disabled &= ~NETIF_F_TSO; >> + } else { >> + netif->features_disabled |= NETIF_F_TSO; >> } >> >> - return ethtool_op_set_tso(dev, data); >> + netif_set_features(netif); >> + return 0; >> } >> >> static struct ethtool_ops network_ethtool_ops >> { >> .get_tx_csum = ethtool_op_get_tx_csum, >> - .set_tx_csum = ethtool_op_set_tx_csum, >> + .set_tx_csum = netbk_set_tx_csum, >> .get_sg = ethtool_op_get_sg, >> .set_sg = netbk_set_sg, >> .get_tso = ethtool_op_get_tso, >> @@ -145,6 +186,8 @@ >> memset(netif, 0, sizeof(*netif)); >> netif->domid = domid; >> netif->handle = handle; >> + netif->can_sg = 1; >> + netif->csum = 1; >> atomic_set(&netif->refcnt, 1); >> init_waitqueue_head(&netif->waiting_to_free); >> netif->dev = dev; >> @@ -162,7 +205,8 @@ >> dev->open = net_open; >> dev->stop = net_close; >> dev->change_mtu = netbk_change_mtu; >> - dev->features = NETIF_F_IP_CSUM; >> + >> + netif_set_features(netif); >> >> SET_ETHTOOL_OPS(dev, &network_ethtool_ops); >> >> --- linux-2.6.18.x86_64/drivers/xen/netback/netback.c.orig 2011-04-15 >> 17:46:58.141515042 -0400 >> +++ linux-2.6.18.x86_64/drivers/xen/netback/netback.c 2011-04-15 >> 17:50:46.027757042 -0400 >> @@ -215,7 +215,7 @@ >> >> static inline int netbk_max_required_rx_slots(netif_t *netif) >> { >> - if (netif->features & (NETIF_F_SG|NETIF_F_TSO)) >> + if (netif->can_sg || netif->gso) >> return MAX_SKB_FRAGS + 2; /* header + extra_info + frags */ >> return 1; /* all in one */ >> } >> --- linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c.orig 2011-04-15 >> 17:46:59.217582292 -0400 >> +++ linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c 2011-04-15 >> 18:13:20.700418792 -0400 >> @@ -345,6 +345,7 @@ >> >> static int connect_rings(struct backend_info *be) >> { >> + netif_t *netif = be->netif; >> struct xenbus_device *dev = be->dev; >> unsigned long tx_ring_ref, rx_ring_ref; >> unsigned int evtchn, rx_copy; >> @@ -375,46 +376,40 @@ >> dev->otherend); >> return err; >> } >> - be->netif->copying_receiver = !!rx_copy; >> + netif->copying_receiver = !!rx_copy; >> >> - if (be->netif->dev->tx_queue_len != 0) { >> + if (netif->dev->tx_queue_len != 0) { >> if (xenbus_scanf(XBT_NIL, dev->otherend, >> "feature-rx-notify", "%d", &val) < 0) >> val = 0; >> if (val) >> - be->netif->can_queue = 1; >> + netif->can_queue = 1 > > You need to end semi-colon for the above which I think your compile > error output is showing I guess. > >> else >> /* Must be non-zero for pfifo_fast to work. */ >> - be->netif->dev->tx_queue_len = 1; >> + netif->dev->tx_queue_len = 1; >> } >> >> if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg", "%d", &val) < 0) >> val = 0; >> - if (val) { >> - be->netif->features |= NETIF_F_SG; >> - be->netif->dev->features |= NETIF_F_SG; >> - } >> + netif->can_sg = !!val; >> >> if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4", "%d", >> &val) < 0) >> val = 0; >> - if (val) { >> - be->netif->features |= NETIF_F_TSO; >> - be->netif->dev->features |= NETIF_F_TSO; >> - } >> + netif->gso = !!val; >> >> if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-no-csum-offload", >> "%d", &val) < 0) >> val = 0; >> - if (val) { >> - be->netif->features &= ~NETIF_F_IP_CSUM; >> - be->netif->dev->features &= ~NETIF_F_IP_CSUM; >> - } >> + netif->csum = !val; >> + >> + /* Set dev->features */ >> + netif_set_features(netif); >> >> netdev_features_change(be->netif->dev); >> >> /* Map the shared frame, irq etc. */ >> - err = netif_map(be->netif, tx_ring_ref, rx_ring_ref, evtchn); >> + err = netif_map(netif, tx_ring_ref, rx_ring_ref, evtchn); >> if (err) { >> xenbus_dev_fatal(dev, err, >> "mapping shared-frames %lu/%lu port %u", >> ===>> >> And here is the compile output with errors: >> >> ===>> 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 ChoonOh dear, now this is embarrassing! I''ll edit it and re-run the compile. I''ll post a follow-up in an hour or two. :P Thanks! -- Digimer E-Mail: digimer@alteeve.com AN!Whitepapers: http://alteeve.com Node Assassin: http://nodeassassin.org _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Digimer
2011-Apr-17 05:57 UTC
Re: [Xen-devel] Trying to adapt Olaf''s vif MTU patch for EL5.6''s 2.6.18-238.9 kernel - patch in-line.
On 04/16/2011 11:23 PM, Teck Choon Giam wrote:>> - be->netif->can_queue = 1; >> + netif->can_queue = 1 > > You need to end semi-colon for the above which I think your compile > error output is showing I guess.> Is the line 387 the one without the ; above? I guess so :p > > Thanks. > > Kindest regards, > Giam Teck ChoonThat was indeed the problem. I''ve got the new kernel installed on my test machines and will report success/failure tomorrow. :) -- Digimer E-Mail: digimer@alteeve.com AN!Whitepapers: http://alteeve.com Node Assassin: http://nodeassassin.org _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Digimer
2011-Apr-17 15:41 UTC
Re: [Xen-devel] Trying to adapt Olaf''s vif MTU patch for EL5.6''s 2.6.18-238.9 kernel - patch in-line.
Morning, I''ve been able to test this patch and it works, provided that the following patch is applied to /etc/xen/scripts/vif-bridge: ===--- vif-bridge.orig 2011-04-17 01:58:49.000000000 -0400 +++ vif-bridge 2011-04-17 11:20:14.000000000 -0400 @@ -56,6 +56,11 @@ case "$command" in online) setup_bridge_port "$vif" + mtu="`ip link show $bridge | awk ''/mtu/ { print $5 }''`" + if [ -n "$mtu" ] && [ "$mtu" -gt 0 ] + then + ip link set $vif mtu $mtu || : + fi add_to_bridge "$bridge" "$vif" ;; === Please note, this differs slightly from Olaf''s patch found here: http://lists.xensource.com/archives/html/xen-devel/2011-02/msg00351.html The only difference is that, in Xen 3.0.3/EL5.6, the variable name is ''$vif'', not ''$dev''. I''m trying to create a proper patch for the xen-3.0.3 but am having trouble with source rpm. I''ll post back with a proper patch once I get it working. This is related to bz 697021 (https://bugzilla.redhat.com/show_bug.cgi?id=697021). -- Digimer E-Mail: digimer@alteeve.com AN!Whitepapers: http://alteeve.com Node Assassin: http://nodeassassin.org _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Digimer
2011-Apr-17 16:51 UTC
Re: [Xen-devel] Trying to adapt Olaf''s vif MTU patch for EL5.6''s 2.6.18-238.9 kernel - patch in-line.
I''ve created two rhbz tickets for these two patches. Patch for vif MTU: https://bugzilla.redhat.com/show_bug.cgi?id=697021 Patch for vif-bridge: https://bugzilla.redhat.com/show_bug.cgi?id=697310 -- Digimer E-Mail: digimer@alteeve.com AN!Whitepapers: http://alteeve.com Node Assassin: http://nodeassassin.org _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Konrad Rzeszutek Wilk
2011-Apr-18 16:22 UTC
Re: [Xen-devel] Trying to adapt Olaf''s vif MTU patch for EL5.6''s 2.6.18-238.9 kernel - patch in-line.
On Sun, Apr 17, 2011 at 12:51:10PM -0400, Digimer wrote:> I''ve created two rhbz tickets for these two patches. > > Patch for vif MTU: > https://bugzilla.redhat.com/show_bug.cgi?id=697021 > > Patch for vif-bridge: > https://bugzilla.redhat.com/show_bug.cgi?id=697310You might want to mention where those patches exist upstream. As in, did you back-port them from 2.6.32, 2.6.38 (or 2.6.39) and if so what git tree. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Digimer
2011-Apr-18 16:31 UTC
Re: [Xen-devel] Trying to adapt Olaf''s vif MTU patch for EL5.6''s 2.6.18-238.9 kernel - patch in-line.
On 04/18/2011 12:22 PM, Konrad Rzeszutek Wilk wrote:> On Sun, Apr 17, 2011 at 12:51:10PM -0400, Digimer wrote: >> I''ve created two rhbz tickets for these two patches. >> >> Patch for vif MTU: >> https://bugzilla.redhat.com/show_bug.cgi?id=697021 >> >> Patch for vif-bridge: >> https://bugzilla.redhat.com/show_bug.cgi?id=697310 > > You might want to mention where those patches exist upstream. As in, > did you back-port them from 2.6.32, 2.6.38 (or 2.6.39) and if so > what git tree.Looking at Olaf''s original email, it looks like the patch was created against 2.6.18. There are some git hashes in the thread*, but I couldn''t say which is best to reference. I''ll link to the original thread again and ask those wiser than I to sort out which hash(es) is(are) most important. http://lists.xensource.com/archives/html/xen-devel/2011-02/msg00351.html -- Digimer E-Mail: digimer@alteeve.com AN!Whitepapers: http://alteeve.com Node Assassin: http://nodeassassin.org _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Digimer
2011-Apr-19 04:46 UTC
Re: [Xen-devel] Trying to adapt Olaf''s vif MTU patch for EL5.6''s 2.6.18-238.9 kernel - patch in-line.
On 04/17/2011 11:41 AM, Digimer wrote:> Morning, > > I''ve been able to test this patch and it works, provided that the > following patch is applied to /etc/xen/scripts/vif-bridge: ><snip> I''ve run into a problem where live migrations of the VMs fail with MTU>1500. It would seem that the system tried to create a tapX device,which is at 1500, and brings the bridge down. I''m not familiar enough with Xen''s internals with regard to migration. If anyone here could offer some help getting this working in EL 5.6, I''d appreciate it. I''m in over my head now, I think. :) -- Digimer E-Mail: digimer@alteeve.com AN!Whitepapers: http://alteeve.com Node Assassin: http://nodeassassin.org _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel