From: VMware, Inc <> Date: Thu, 15 Oct 2009 21:20:57 +0000 (-0700) Subject: Internal branch sync. Included in this change: X-Git-Tag: 2009.10.15-201664~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3056d8d64c2ddb779b54b4d8b38c76b537baa0e7;p=thirdparty%2Fopen-vm-tools.git Internal branch sync. Included in this change: . 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 --- diff --git a/open-vm-tools/lib/foundryMsg/foundryMsg.c b/open-vm-tools/lib/foundryMsg/foundryMsg.c index 53bd7373a..4bc94a21a 100644 --- a/open-vm-tools/lib/foundryMsg/foundryMsg.c +++ b/open-vm-tools/lib/foundryMsg/foundryMsg.c @@ -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), }; diff --git a/open-vm-tools/lib/foundryMsg/foundryPropertyListCommon.c b/open-vm-tools/lib/foundryMsg/foundryPropertyListCommon.c index f01643189..66e36dd25 100644 --- a/open-vm-tools/lib/foundryMsg/foundryPropertyListCommon.c +++ b/open-vm-tools/lib/foundryMsg/foundryPropertyListCommon.c @@ -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 + + diff --git a/open-vm-tools/lib/include/fileIO.h b/open-vm-tools/lib/include/fileIO.h index d23272734..e3a67eb3f 100644 --- a/open-vm-tools/lib/include/fileIO.h +++ b/open-vm-tools/lib/include/fileIO.h @@ -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) diff --git a/open-vm-tools/lib/include/vixCommands.h b/open-vm-tools/lib/include/vixCommands.h index b728e5dc1..ce7200f87 100644 --- a/open-vm-tools/lib/include/vixCommands.h +++ b/open-vm-tools/lib/include/vixCommands.h @@ -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, diff --git a/open-vm-tools/lib/include/vixOpenSource.h b/open-vm-tools/lib/include/vixOpenSource.h index d1a10c3f7..ba24e240a 100644 --- a/open-vm-tools/lib/include/vixOpenSource.h +++ b/open-vm-tools/lib/include/vixOpenSource.h @@ -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 diff --git a/open-vm-tools/modules/linux/shared/compat_netdevice.h b/open-vm-tools/modules/linux/shared/compat_netdevice.h index fa1422025..5af03ced4 100644 --- a/open-vm-tools/modules/linux/shared/compat_netdevice.h +++ b/open-vm-tools/modules/linux/shared/compat_netdevice.h @@ -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__ */ diff --git a/open-vm-tools/modules/linux/vmxnet3/vmxnet3_drv.c b/open-vm-tools/modules/linux/vmxnet3/vmxnet3_drv.c index e7ed33b5d..5b3f810e7 100644 --- a/open-vm-tools/modules/linux/vmxnet3/vmxnet3_drv.c +++ b/open-vm-tools/modules/linux/vmxnet3/vmxnet3_drv.c @@ -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; } } diff --git a/open-vm-tools/modules/linux/vmxnet3/vmxnet3_shm.c b/open-vm-tools/modules/linux/vmxnet3/vmxnet3_shm.c index 67c2cc534..5256acf11 100644 --- a/open-vm-tools/modules/linux/vmxnet3/vmxnet3_shm.c +++ b/open-vm-tools/modules/linux/vmxnet3/vmxnet3_shm.c @@ -71,6 +71,11 @@ 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; +} + /* *-----------------------------------------------------------------------------