Advertisement
digimer

Untitled

Apr 16th, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.25 KB | None | 0 0
  1. --- linux-2.6.18.x86_64/drivers/xen/netback/common.h.orig   2011-04-15 17:46:12.730677042 -0400
  2. +++ linux-2.6.18.x86_64/drivers/xen/netback/common.h    2011-04-15 17:57:57.490721792 -0400
  3. @@ -76,8 +76,13 @@
  4.     struct vm_struct *tx_comms_area;
  5.     struct vm_struct *rx_comms_area;
  6.  
  7. -   /* Set of features that can be turned on in dev->features. */
  8. -   int features;
  9. +   /* Flags that must not be set in dev->features */
  10. +   int features_disabled;
  11. +
  12. +   /* Frontend feature information. */
  13. +   u8 can_sg:1;
  14. +   u8 gso:1;
  15. +   u8 csum:1;
  16.  
  17.     /* Internal feature information. */
  18.     int can_queue:1;    /* can queue packets for receiver? */
  19. @@ -110,6 +115,7 @@
  20.  
  21.  void netif_disconnect(netif_t *netif);
  22.  
  23. +void netif_set_features(netif_t *netif);
  24.  netif_t *netif_alloc(domid_t domid, unsigned int handle);
  25.  int netif_map(netif_t *netif, unsigned long tx_ring_ref,
  26.           unsigned long rx_ring_ref, unsigned int evtchn);
  27. @@ -142,7 +148,7 @@
  28.  static inline int netbk_can_sg(struct net_device *dev)
  29.  {
  30.     netif_t *netif = netdev_priv(dev);
  31. -   return netif->features & NETIF_F_SG;
  32. +   return netif->can_sg;
  33.  }
  34.  
  35.  #endif /* __NETIF__BACKEND__COMMON_H__ */
  36. --- linux-2.6.18.x86_64/drivers/xen/netback/interface.c.orig    2011-04-15 17:46:57.205456542 -0400
  37. +++ linux-2.6.18.x86_64/drivers/xen/netback/interface.c 2011-04-15 17:50:46.027757042 -0400
  38. @@ -90,34 +90,75 @@
  39.     return 0;
  40.  }
  41.  
  42. -static int netbk_set_sg(struct net_device *dev, u32 data)
  43. +void netif_set_features(netif_t *netif)
  44.  {
  45. +   struct net_device *dev = netif->dev;
  46. +   int features = dev->features;
  47. +
  48. +   if (netif->can_sg)
  49. +       features |= NETIF_F_SG;
  50. +   if (netif->gso)
  51. +       features |= NETIF_F_TSO;
  52. +   if (netif->csum)
  53. +       features |= NETIF_F_IP_CSUM;
  54. +
  55. +   features &= ~(netif->features_disabled);
  56. +
  57. +   if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN)
  58. +       dev->mtu = ETH_DATA_LEN;
  59. +
  60. +   dev->features = features;
  61. +}
  62. +
  63. +static int netbk_set_tx_csum(struct net_device *dev, u32 data)
  64. +{
  65. +   netif_t *netif = netdev_priv(dev);
  66.     if (data) {
  67. -       netif_t *netif = netdev_priv(dev);
  68. +       if (!netif->csum)
  69. +           return -ENOSYS;
  70. +       netif->features_disabled &= ~NETIF_F_IP_CSUM;
  71. +   } else {
  72. +       netif->features_disabled |= NETIF_F_IP_CSUM;
  73. +   }
  74.  
  75. -       if (!(netif->features & NETIF_F_SG))
  76. +   netif_set_features(netif);
  77. +   return 0;
  78. +}
  79. +
  80. +static int netbk_set_sg(struct net_device *dev, u32 data)
  81. +{
  82. +   netif_t *netif = netdev_priv(dev);
  83. +   if (data) {
  84. +       if (!netif->can_sg)
  85.             return -ENOSYS;
  86. +       netif->features_disabled &= ~NETIF_F_SG;
  87. +   } else {
  88. +       netif->features_disabled |= NETIF_F_SG;
  89.     }
  90.  
  91. -   return ethtool_op_set_sg(dev, data);
  92. +   netif_set_features(netif);
  93. +   return 0;
  94.  }
  95.  
  96.  static int netbk_set_tso(struct net_device *dev, u32 data)
  97.  {
  98. +   netif_t *netif = netdev_priv(dev);
  99.     if (data) {
  100. -       netif_t *netif = netdev_priv(dev);
  101. -
  102. -       if (!(netif->features & NETIF_F_TSO))
  103. +       if (!netif->gso)
  104.             return -ENOSYS;
  105. +       netif->features_disabled &= ~NETIF_F_TSO;
  106. +   } else {
  107. +       netif->features_disabled |= NETIF_F_TSO;
  108.     }
  109.  
  110. -   return ethtool_op_set_tso(dev, data);
  111. +   netif_set_features(netif);
  112. +   return 0;
  113.  }
  114.  
  115.  static struct ethtool_ops network_ethtool_ops =
  116.  {
  117.     .get_tx_csum = ethtool_op_get_tx_csum,
  118. -   .set_tx_csum = ethtool_op_set_tx_csum,
  119. +   .set_tx_csum = netbk_set_tx_csum,
  120.     .get_sg = ethtool_op_get_sg,
  121.     .set_sg = netbk_set_sg,
  122.     .get_tso = ethtool_op_get_tso,
  123. @@ -145,6 +186,8 @@
  124.     memset(netif, 0, sizeof(*netif));
  125.     netif->domid  = domid;
  126.     netif->handle = handle;
  127. +   netif->can_sg = 1;
  128. +   netif->csum = 1;
  129.     atomic_set(&netif->refcnt, 1);
  130.     init_waitqueue_head(&netif->waiting_to_free);
  131.     netif->dev = dev;
  132. @@ -162,7 +205,8 @@
  133.     dev->open            = net_open;
  134.     dev->stop            = net_close;
  135.     dev->change_mtu      = netbk_change_mtu;
  136. -   dev->features        = NETIF_F_IP_CSUM;
  137. +
  138. +   netif_set_features(netif);
  139.  
  140.     SET_ETHTOOL_OPS(dev, &network_ethtool_ops);
  141.  
  142. --- linux-2.6.18.x86_64/drivers/xen/netback/netback.c.orig  2011-04-15 17:46:58.141515042 -0400
  143. +++ linux-2.6.18.x86_64/drivers/xen/netback/netback.c   2011-04-15 17:50:46.027757042 -0400
  144. @@ -215,7 +215,7 @@
  145.  
  146.  static inline int netbk_max_required_rx_slots(netif_t *netif)
  147.  {
  148. -   if (netif->features & (NETIF_F_SG|NETIF_F_TSO))
  149. +   if (netif->can_sg || netif->gso)
  150.         return MAX_SKB_FRAGS + 2; /* header + extra_info + frags */
  151.     return 1; /* all in one */
  152.  }
  153. --- linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c.orig   2011-04-15 17:46:59.217582292 -0400
  154. +++ linux-2.6.18.x86_64/drivers/xen/netback/xenbus.c    2011-04-15 18:13:20.700418792 -0400
  155. @@ -345,6 +345,7 @@
  156.  
  157.  static int connect_rings(struct backend_info *be)
  158.  {
  159. +   netif_t *netif = be->netif;
  160.     struct xenbus_device *dev = be->dev;
  161.     unsigned long tx_ring_ref, rx_ring_ref;
  162.     unsigned int evtchn, rx_copy;
  163. @@ -375,46 +376,40 @@
  164.                  dev->otherend);
  165.         return err;
  166.     }
  167. -   be->netif->copying_receiver = !!rx_copy;
  168. +   netif->copying_receiver = !!rx_copy;
  169.  
  170. -   if (be->netif->dev->tx_queue_len != 0) {
  171. +   if (netif->dev->tx_queue_len != 0) {
  172.         if (xenbus_scanf(XBT_NIL, dev->otherend,
  173.                  "feature-rx-notify", "%d", &val) < 0)
  174.             val = 0;
  175.         if (val)
  176. -           be->netif->can_queue = 1;
  177. +           netif->can_queue = 1
  178.         else
  179.             /* Must be non-zero for pfifo_fast to work. */
  180. -           be->netif->dev->tx_queue_len = 1;
  181. +           netif->dev->tx_queue_len = 1;
  182.     }
  183.  
  184.     if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg", "%d", &val) < 0)
  185.         val = 0;
  186. -   if (val) {
  187. -       be->netif->features |= NETIF_F_SG;
  188. -       be->netif->dev->features |= NETIF_F_SG;
  189. -   }
  190. +   netif->can_sg = !!val;
  191.  
  192.     if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4", "%d",
  193.              &val) < 0)
  194.         val = 0;
  195. -   if (val) {
  196. -       be->netif->features |= NETIF_F_TSO;
  197. -       be->netif->dev->features |= NETIF_F_TSO;
  198. -   }
  199. +   netif->gso = !!val;
  200.  
  201.     if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-no-csum-offload",
  202.              "%d", &val) < 0)
  203.         val = 0;
  204. -   if (val) {
  205. -       be->netif->features &= ~NETIF_F_IP_CSUM;
  206. -       be->netif->dev->features &= ~NETIF_F_IP_CSUM;
  207. -   }
  208. +   netif->csum = !val;
  209. +
  210. +   /* Set dev->features */
  211. +   netif_set_features(netif);
  212.  
  213.     netdev_features_change(be->netif->dev);
  214.  
  215.     /* Map the shared frame, irq etc. */
  216. -   err = netif_map(be->netif, tx_ring_ref, rx_ring_ref, evtchn);
  217. +   err = netif_map(netif, tx_ring_ref, rx_ring_ref, evtchn);
  218.     if (err) {
  219.         xenbus_dev_fatal(dev, err,
  220.                  "mapping shared-frames %lu/%lu port %u",
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement