]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Thu, 15 Oct 2009 21:20:57 +0000 (14:20 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 15 Oct 2009 21:20:57 +0000 (14:20 -0700)
. Changes in shared code that don't affect open-vm-tools functionality.

. Don't linearize vmxnet3-shm tx packets. We don't need/want to linearize
  shm packets, and the re-estimate of the number of TX descriptors needed was
  too low. This led to next2fill skipping over next2comp and corruption of the
  TX ring. This corruption caused device resets, which uncovered a race between
  tq_xmit and reset_work. Finally, remove some suspicious code duplication and
  replace with a call to vmxnet3_dev_kfree_skb.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/foundryMsg/foundryMsg.c
open-vm-tools/lib/foundryMsg/foundryPropertyListCommon.c
open-vm-tools/lib/include/fileIO.h
open-vm-tools/lib/include/vixCommands.h
open-vm-tools/lib/include/vixOpenSource.h
open-vm-tools/modules/linux/shared/compat_netdevice.h
open-vm-tools/modules/linux/vmxnet3/vmxnet3_drv.c
open-vm-tools/modules/linux/vmxnet3/vmxnet3_shm.c

index 53bd7373a2585307bca10310bd7aba4aeda7cfda..4bc94a21af2a8b7dc1d79e0ac054fb1a6afc56da 100644 (file)
@@ -435,6 +435,9 @@ static const VixCommandInfo vixCommandInfoTable[] = {
 
    VIX_DEFINE_COMMAND_INFO(VIX_COMMAND_GENERATE_NONCE,
                            VIX_COMMAND_CATEGORY_ALWAYS_ALLOWED),
+
+   VIX_DEFINE_COMMAND_INFO(VIX_COMMAND_CHANGE_DISPLAY_TOPOLOGY_MODES,
+                            VIX_COMMAND_CATEGORY_ALWAYS_ALLOWED),
 };
 
 
index f016431890e28c9ce24fb67798409c32f751052e..66e36dd2515515083adbb1629b2a7867669c6a39 100644 (file)
@@ -1505,3 +1505,60 @@ VixPropertyList_PropertyExists(VixPropertyListImpl *propList,     // IN
 } // VixPropertyList_PropertyExists
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VixPropertyList_NumItems --
+ *
+ *       Returns a count of the properties in the list.
+ *
+ * Results:
+ *       int - Number of properties in property list.
+ *
+ * Side effects:
+ *       None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int
+VixPropertyList_NumItems(VixPropertyListImpl *propList)     // IN
+{
+   VixPropertyValue *prop;
+   int count = 0;
+
+   if (propList == NULL) {
+      return 0;
+   }
+
+   for (prop = propList->properties; prop != NULL; prop = prop->next) {
+      ++count;
+   }
+
+   return count;
+} // VixPropertyList_NumItems
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VixPropertyList_Empty --
+ *
+ *       Returns whether the property list has no properties.
+ *
+ * Results:
+ *       Bool - True iff property list has no properties.
+ *
+ * Side effects:
+ *       None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+VixPropertyList_Empty(VixPropertyListImpl *propList)     // IN
+{
+   return (propList == NULL || propList->properties == NULL);
+} // VixPropertyList_Empty
+
+
index d23272734c961f976938bc7bbfd32eb4f705194e..e3a67eb3fe08784d21943504aab4d7eecc1855b2 100644 (file)
@@ -170,12 +170,19 @@ typedef enum {
  */
 #define FILEIO_OPEN_NO_TIME_MACHINE      (1 << 15)
 
-// Flag passed to open() to get exclusive VMFS lock.  This definition must
-// match USEROBJ_OPEN_EXCLUSIVE_LOCK in user_vsiTypes.h.
-#define O_EXCLUSIVE_LOCK 0x10000000
+/*
+ * Flag passed to open() to not attempt to get the lun attributes as part of
+ * the open operation. Applicable only to opening of SCSI devices. This
+ * definition must match the definition of USEROBJ_OPEN_NOATTR in
+ * user_vsiTypes.h and FS_OPEN_NOATTR in fs_public.h
+ */
+#define O_NOATTR 0x04000000
 // Flag passed to open() to get multiwriter VMFS lock.  This definition must
 // match USEROBJ_OPEN_MULTIWRITER_LOCK in user_vsiTypes.h.
 #define O_MULTIWRITER_LOCK 0x08000000
+// Flag passed to open() to get exclusive VMFS lock.  This definition must
+// match USEROBJ_OPEN_EXCLUSIVE_LOCK in user_vsiTypes.h.
+#define O_EXCLUSIVE_LOCK 0x10000000
 
 /* File Access check args */
 #define FILEIO_ACCESS_READ       (1 << 0)
index b728e5dc10ccd18788395e3a5cf2b68fff19feb8..ce7200f879a8e3106b5c62305bfd2b3a7f4b2dd4 100644 (file)
@@ -1297,6 +1297,15 @@ struct VixMsgFaultToleranceControlRequest {
 #include "vmware_pack_end.h"
 VixMsgFaultToleranceControlRequest;
 
+typedef
+#include "vmware_pack_begin.h"
+struct VixFaultToleranceControlResponse {
+   VixCommandResponseHeader header;
+   uint32 propertyListBufferSize;
+   // Followed by a serialized property list containing error context.
+}
+#include "vmware_pack_end.h"
+VixFaultToleranceControlResponse;
 
 
 /*
@@ -2425,6 +2434,8 @@ enum {
 
    VIX_COMMAND_GENERATE_NONCE                   = 174,
 
+   VIX_COMMAND_CHANGE_DISPLAY_TOPOLOGY_MODES    = 175,
+
    /*
     * HOWTO: Adding a new Vix Command. Step 2a.
     *
@@ -2435,7 +2446,7 @@ enum {
     * Once a new command is added here, a command info field needs to be added
     * in bora/lib/foundryMsg. as well.
     */
-   VIX_COMMAND_LAST_NORMAL_COMMAND              = 175,
+   VIX_COMMAND_LAST_NORMAL_COMMAND              = 176,
 
    VIX_TEST_UNSUPPORTED_TOOLS_OPCODE_COMMAND    = 998,
    VIX_TEST_UNSUPPORTED_VMX_OPCODE_COMMAND      = 999,
index d1a10c3f74d729d86d65b70fca3362b021b92a36..ba24e240a4ec900a348c902278d4f4f2bd5c55db 100644 (file)
@@ -338,6 +338,9 @@ VixError VixPropertyList_SetPtr(VixPropertyListImpl *propList,
                                 int propertyID,
                                 void *value);
 
+int VixPropertyList_NumItems(VixPropertyListImpl *propList);
+
+Bool VixPropertyList_Empty(VixPropertyListImpl *propList);
 
 
 #endif   // VIX_HIDE_FROM_JAVA
index fa1422025305cf634e54ec5b447faa1bb33ec578..5af03ced4c16b9224bce606637c05c41ac59425b 100644 (file)
@@ -320,4 +320,17 @@ static inline int compat_unregister_netdevice_notifier(struct notifier_block *nb
 
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
+#   define compat_netif_tx_lock(dev) netif_tx_lock(dev)
+#   define compat_netif_tx_unlock(dev) netif_tx_unlock(dev)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
+#   define compat_netif_tx_lock(dev) spin_lock(&dev->xmit_lock)
+#   define compat_netif_tx_unlock(dev) spin_unlock(&dev->xmit_lock)
+#else
+/* Vendor backporting (SLES 10) has muddled the tx_lock situation. Pick whichever
+ * of the above works for you. */
+#   define compat_netif_tx_lock(dev) do {} while (0)
+#   define compat_netif_tx_unlock(dev) do {} while (0)
+#endif
+
 #endif /* __COMPAT_NETDEVICE_H__ */
index e7ed33b5d3da37f467464425a9d191556268b77a..5b3f810e74e09cb61a81fe511d2985403dc9e64d 100644 (file)
@@ -1023,17 +1023,17 @@ vmxnet3_tq_xmit(struct sk_buff *skb,
                tq->stats.drop_too_many_frags++;
                goto drop_pkt;
             }
-         }
+         } else {
+            /* non-tso pkts must not use more than VMXNET3_MAX_TXD_PER_PKT entries */
+            if (compat_skb_linearize(skb) != 0) {
+               tq->stats.drop_too_many_frags++;
+               goto drop_pkt;
+            }
+            tq->stats.linearized++;
 
-         /* non-tso pkts must not use more than VMXNET3_MAX_TXD_PER_PKT entries */
-         if (compat_skb_linearize(skb) != 0) {
-            tq->stats.drop_too_many_frags++;
-            goto drop_pkt;
+            /* recalculate the # of descriptors to use */
+            count = VMXNET3_TXD_NEEDED(vmxnet3_skb_headlen(adapter, skb)) + 1;
          }
-         tq->stats.linearized++;
-
-         /* recalculate the # of descriptors to use */
-         count = VMXNET3_TXD_NEEDED(vmxnet3_skb_headlen(adapter, skb)) + 1;
       }
    }
 
index 67c2cc534478f1dc9dcb72c9cb5f7965cada11e7..5256acf118b25afa04f842a3f699c8f5bf4ba0ab 100644 (file)
 static int
 vmxnet3_shm_consume_user_tx_queue(struct vmxnet3_shm_pool *shm);
 
+int
+vmxnet3_shm_tq_xmit(struct sk_buff *skb,
+                    struct vmxnet3_tx_queue *tq,
+                    struct vmxnet3_adapter *adapter,
+                    struct net_device *netdev);
 
 /*
  *----------------------------------------------------------------------------
@@ -1150,6 +1155,8 @@ vmxnet3_shm_start_tx(struct sk_buff *skb,
  *
  *    Send a packet (collection of ring entries) using h/w tx routine.
  *
+ *    Protected by shm.tx_lock
+ *
  * Results:
  *    0 on success. Negative value to indicate error
  *
@@ -1194,15 +1201,11 @@ vmxnet3_shm_tx_pkt(struct vmxnet3_adapter *adapter,
    {
       struct vmxnet3_tx_queue *tq = &adapter->tx_queue;
       int ret;
-      skb->protocol = cpu_to_be16(0x86dd);
+      skb->protocol = htons(ETH_P_IPV6);
       adapter->shm->ctl.ptr->stats.kernel_tx += frags; // XXX: move to better place
-      ret = vmxnet3_tq_xmit(skb, tq, adapter, adapter->netdev);
+      ret = vmxnet3_shm_tq_xmit(skb, tq, adapter, adapter->netdev);
       if (ret == COMPAT_NETDEV_TX_BUSY) {
-         for (i = 0; i < frags; i++) {
-            vmxnet3_shm_free_page(adapter->shm, res[i].idx);
-         }
-         skb_shinfo(skb)->nr_frags = 0;
-         kfree_skb(skb);
+         vmxnet3_dev_kfree_skb(adapter, skb);
       }
 
       return ret;
@@ -1211,6 +1214,38 @@ vmxnet3_shm_tx_pkt(struct vmxnet3_adapter *adapter,
    return 0;
 }
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmxnet3_shm_tq_xmit --
+ *
+ *    Wrap vmxnet3_tq_xmit holding the netdev tx lock to better emulate the
+ *    Linux stack. Also check for a stopped tx queue to avoid racing with
+ *    vmxnet3_close.
+ *
+ * Results:
+ *    Same as vmxnet3_tq_xmit.
+ *
+ * Side effects:
+ *    None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+int
+vmxnet3_shm_tq_xmit(struct sk_buff *skb,
+                    struct vmxnet3_tx_queue *tq,
+                    struct vmxnet3_adapter *adapter,
+                    struct net_device *netdev)
+{
+   int ret = COMPAT_NETDEV_TX_BUSY;
+   compat_netif_tx_lock(netdev);
+   if (!netif_queue_stopped(netdev)) {
+      ret = vmxnet3_tq_xmit(skb, tq, adapter, netdev);
+   }
+   compat_netif_tx_unlock(netdev);
+   return ret;
+}
+
 
 /*
  *-----------------------------------------------------------------------------