char **result,
size_t *bufferLength);
+static VixError VMAutomationMsgParserInit(const char *caller,
+ unsigned int line,
+ VMAutomationMsgParser *state,
+ const VixMsgHeader *msg,
+ size_t headerLength,
+ size_t fixedLength,
+ const char *packetType);
+
/*
*----------------------------------------------------------------------------
} // VixMsg_ParseGenericRequestMsg
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VixMsg_ParseSimpleResponseWithString --
+ *
+ * Takes a response packet that consists of a VixCommandResponseHeader
+ * followed by a string containing the response data, validates
+ * the packet, and then passes out a pointer to that string.
+ *
+ * Results:
+ * VixError
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+VixError
+VixMsg_ParseSimpleResponseWithString(const VixCommandResponseHeader *response, // IN
+ const char **result) // OUT
+{
+ VixError err;
+ VMAutomationMsgParser parser;
+
+ err = VMAutomationMsgParserInitResponse(&parser, response, sizeof *response);
+ if (VIX_OK != err) {
+ goto abort;
+ }
+
+ err = VMAutomationMsgParserGetOptionalString(&parser,
+ response->commonHeader.bodyLength,
+ result);
+
+abort:
+ return err;
+}
+
+
/*
*-----------------------------------------------------------------------------
*
/*
*-----------------------------------------------------------------------------
*
- * __VMAutomationRequestParserInit --
- * VMAutomationRequestParserInit --
+ * __VMAutomationMsgParserInitRequest --
+ * VMAutomationMsgParserInitRequest --
*
* Initializes request parser, and performs basic message validation
* not performed elsewhere.
*/
VixError
-__VMAutomationRequestParserInit(const char *caller, // IN
- unsigned int line, // IN
- VMAutomationRequestParser *state, // OUT (opt)
- const VixCommandRequestHeader *msg, // IN
- size_t fixedLength) // IN
+__VMAutomationMsgParserInitRequest(const char *caller, // IN
+ unsigned int line, // IN
+ VMAutomationMsgParser *state, // OUT (opt)
+ const VixCommandRequestHeader *msg, // IN
+ size_t fixedLength) // IN
+{
+ return VMAutomationMsgParserInit(caller, line, state, &msg->commonHeader,
+ sizeof *msg, fixedLength, "request");
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * __VMAutomationMsgParserInitResponse --
+ * VMAutomationMsgParserInitResponse --
+ *
+ * Initializes response parser, and performs basic message validation
+ * not performed elsewhere.
+ *
+ * Results:
+ * VixError. VIX_OK on success. Some other VIX_* code if message is malformed.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+VixError
+__VMAutomationMsgParserInitResponse(const char *caller, // IN
+ unsigned int line, // IN
+ VMAutomationMsgParser *state, // OUT (opt)
+ const VixCommandResponseHeader *msg, // IN
+ size_t fixedLength) // IN
+{
+ return VMAutomationMsgParserInit(caller, line, state, &msg->commonHeader,
+ sizeof *msg, fixedLength, "response");
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMAutomationMsgParserInit --
+ *
+ * Initializes message parser, and performs basic message validation
+ * not performed elsewhere.
+ *
+ * Results:
+ * VixError. VIX_OK on success. Some other VIX_* code if message is malformed.
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static VixError
+VMAutomationMsgParserInit(const char *caller, // IN
+ unsigned int line, // IN
+ VMAutomationMsgParser *state, // OUT (opt)
+ const VixMsgHeader *msg, // IN
+ size_t headerLength, // IN
+ size_t fixedLength, // IN
+ const char *packetType) // IN
{
- uint32 requestLength;
+ uint32 headerAndBodyLength;
// use int64 to prevent overflow
- int64 computedTotalLength = (int64)msg->commonHeader.headerLength +
- (int64)msg->commonHeader.bodyLength +
- (int64)msg->commonHeader.credentialLength;
+ int64 computedTotalLength = (int64)msg->headerLength +
+ (int64)msg->bodyLength + (int64)msg->credentialLength;
- int64 extBodySize =
- (int64)msg->commonHeader.headerLength +
- (int64)msg->commonHeader.bodyLength -
+ int64 extBodySize = (int64)msg->headerLength + (int64)msg->bodyLength -
(int64)fixedLength;
- if (computedTotalLength != (int64)msg->commonHeader.totalMessageLength) {
+ if (computedTotalLength != (int64)msg->totalMessageLength) {
Log("%s:%d, header information mismatch.\n", __FILE__, __LINE__);
return VIX_E_INVALID_MESSAGE_HEADER;
}
if (extBodySize < 0) {
- Log("%s:%d, request too short.\n", __FILE__, __LINE__);
+ Log("%s:%d, %s too short.\n", __FILE__, __LINE__, packetType);
return VIX_E_INVALID_MESSAGE_HEADER;
}
* incompatible with our structures.
*/
- if (msg->commonHeader.headerLength != sizeof *msg) {
- Log("%s(%u): Request header length %u is not supported "
+ if (msg->headerLength != headerLength) {
+ Log("%s(%u): %s header length %u is not supported "
"(%"FMTSZ"u is required).\n",
- caller, line,
- msg->commonHeader.headerLength, sizeof *msg);
+ caller, line, packetType, msg->headerLength, headerLength);
return VIX_E_INVALID_MESSAGE_HEADER;
}
* Message looks reasonable. Skip over fixed part.
*/
- requestLength = msg->commonHeader.headerLength +
- msg->commonHeader.bodyLength;
+ headerAndBodyLength = msg->headerLength + msg->bodyLength;
if (state) {
state->currentPtr = (const char *)msg + fixedLength;
- state->endPtr = (const char *)msg + requestLength;
+ state->endPtr = (const char *)msg + headerAndBodyLength;
}
return VIX_OK;
}
VMAutomation_VerifyRequestLength(const VixCommandRequestHeader *request, // IN
size_t fixedLength) // IN
{
- return VMAutomationRequestParserInit(NULL, request, fixedLength);
+ return VMAutomationMsgParserInitRequest(NULL, request, fixedLength);
}
/*
*-----------------------------------------------------------------------------
*
- * VMAutomationRequestParserGetRemainingData --
+ * VMAutomationMsgParserGetRemainingData --
*
* Fetches all data remaining in the request.
*
*/
const void *
-VMAutomationRequestParserGetRemainingData(VMAutomationRequestParser *state, // IN/OUT
- size_t *length) // OUT
+VMAutomationMsgParserGetRemainingData(VMAutomationMsgParser *state, // IN/OUT
+ size_t *length) // OUT
{
const void *data;
/*
*-----------------------------------------------------------------------------
*
- * VMAutomationRequestParserGetData --
- * __VMAutomationRequestParserGetData --
+ * VMAutomationMsgParserGetData --
+ * __VMAutomationMsgParserGetData --
*
* Fetches specified number of bytes.
*
*/
VixError
-__VMAutomationRequestParserGetData(const char *caller, // IN
- unsigned int line, // IN
- VMAutomationRequestParser *state, // IN/OUT
- size_t length, // IN
- const char **result) // OUT (opt)
+__VMAutomationMsgParserGetData(const char *caller, // IN
+ unsigned int line, // IN
+ VMAutomationMsgParser *state, // IN/OUT
+ size_t length, // IN
+ const char **result) // OUT (opt)
{
size_t available;
/*
*-----------------------------------------------------------------------------
*
- * VMAutomationRequestParserGetOptionalString --
- * __VMAutomationRequestParserGetOptionalString --
+ * VMAutomationMsgParserGetOptionalString --
+ * __VMAutomationMsgParserGetOptionalString --
*
* Fetches string of specified length from the request. Length includes
* terminating NUL byte, which must be present. Length of zero results
*/
VixError
-__VMAutomationRequestParserGetOptionalString(const char *caller, // IN
- unsigned int line, // IN
- VMAutomationRequestParser *state, // IN/OUT
- size_t length, // IN
- const char **result) // OUT
+__VMAutomationMsgParserGetOptionalString(const char *caller, // IN
+ unsigned int line, // IN
+ VMAutomationMsgParser *state, // IN/OUT
+ size_t length, // IN
+ const char **result) // OUT
{
if (length) {
VixError err;
const char *string;
- err = __VMAutomationRequestParserGetData(caller, line, state, length,
- &string);
+ err = __VMAutomationMsgParserGetData(caller, line, state, length,
+ &string);
if (VIX_OK != err) {
return err;
}
/*
*-----------------------------------------------------------------------------
*
- * VMAutomationRequestParserGetOptionalStrings --
- * __VMAutomationRequestParserGetOptionalStrings --
+ * VMAutomationMsgParserGetOptionalStrings --
+ * __VMAutomationMsgParserGetOptionalStrings --
*
* Fetches an array of strings from the request. Length includes the
* terminating NUL byte of each string.
*/
VixError
-__VMAutomationRequestParserGetOptionalStrings(const char *caller, // IN
- unsigned int line, // IN
- VMAutomationRequestParser *state, // IN/OUT
- uint32 count, // IN
- size_t length, // IN
- const char **result) // OUT
+__VMAutomationMsgParserGetOptionalStrings(const char *caller, // IN
+ unsigned int line, // IN
+ VMAutomationMsgParser *state, // IN/OUT
+ uint32 count, // IN
+ size_t length, // IN
+ const char **result) // OUT
{
VixError err = VIX_OK;
const char *buffer;
goto abort;
}
- err = __VMAutomationRequestParserGetData(caller, line, state, length,
- &buffer);
+ err = __VMAutomationMsgParserGetData(caller, line, state, length,
+ &buffer);
if (VIX_OK != err) {
return err;
}
/*
*-----------------------------------------------------------------------------
*
- * VMAutomationRequestParserGetString --
- * __VMAutomationRequestParserGetString --
+ * VMAutomationMsgParserGetString --
+ * __VMAutomationMsgParserGetString --
*
* Fetches string of specified length from the request. Length of
* string is specified in number of usable characters: function consumes
*/
VixError
-__VMAutomationRequestParserGetString(const char *caller, // IN
- unsigned int line, // IN
- VMAutomationRequestParser *state, // IN/OUT
- size_t length, // IN
- const char **result) // OUT
+__VMAutomationMsgParserGetString(const char *caller, // IN
+ unsigned int line, // IN
+ VMAutomationMsgParser *state, // IN/OUT
+ size_t length, // IN
+ const char **result) // OUT
{
VixError err;
const char *string;
Log("%s(%u): String is too long.\n", caller, line);
return VIX_E_INVALID_ARG;
}
- err = __VMAutomationRequestParserGetData(caller, line, state, length,
- &string);
+ err = __VMAutomationMsgParserGetData(caller, line, state, length,
+ &string);
if (VIX_OK != err) {
return err;
}
/*
*-----------------------------------------------------------------------------
*
- * VMAutomationRequestParserGetPropertyList --
- * __VMAutomationRequestParserGetPropertyList --
+ * VMAutomationMsgParserGetPropertyList --
+ * __VMAutomationMsgParserGetPropertyList --
*
* Fetches specified number of bytes.
*
*/
VixError
-__VMAutomationRequestParserGetPropertyList(const char *caller, // IN
- unsigned int line, // IN
- VMAutomationRequestParser *state, // IN/OUT
- size_t length, // IN
- VixPropertyListImpl *propList) // IN/OUT
+__VMAutomationMsgParserGetPropertyList(const char *caller, // IN
+ unsigned int line, // IN
+ VMAutomationMsgParser *state, // IN/OUT
+ size_t length, // IN
+ VixPropertyListImpl *propList) // IN/OUT
{
VixError err;
if (length) {
const char *data;
- err = __VMAutomationRequestParserGetData(caller, line, state, length,
- &data);
+ err = __VMAutomationMsgParserGetData(caller, line, state, length,
+ &data);
if (VIX_OK == err) {
err = VixPropertyList_Deserialize(propList, data, length,
VIX_PROPERTY_LIST_BAD_ENCODING_ERROR);
size_t bufferSize = 0;
size_t pos = 0;
+ ASSERT_ON_COMPILE(PROPERTY_LENGTH_SIZE == sizeof valueLength);
+
if ((NULL == propList) ||
(NULL == resultSize) ||
(NULL == resultBuffer)) {
property = property->next;
}
- *resultBuffer = (char*) Util_SafeCalloc(1, bufferSize);
+ *resultBuffer = (char*) VixMsg_MallocClientData(bufferSize);
+ if (NULL == *resultBuffer) {
+ err = VIX_E_OUT_OF_MEMORY;
+ goto abort;
+ }
serializeBuffer = *resultBuffer;
pos = 0;
int *options,
VixPropertyListImpl *propertyList);
+VixError
+VixMsg_ParseSimpleResponseWithString(const VixCommandResponseHeader *response,
+ const char **result);
+
void *VixMsg_MallocClientData(size_t size);
void *VixMsg_ReallocClientData(void *ptr, size_t size);
char *VixMsg_StrdupClientData(const char *s, Bool *allocateFailed);
/*
- * Parser state used by VMAutomationRequestParser* group of functions.
+ * Parser state used by VMAutomationMsgParser* group of functions.
*/
typedef struct {
const char *currentPtr;
const char *endPtr;
-} VMAutomationRequestParser;
-
-#define VMAutomationRequestParserInit(state, msg, fixedLength) \
- __VMAutomationRequestParserInit(__FUNCTION__, __LINE__, state, msg, fixedLength)
-VixError __VMAutomationRequestParserInit(const char *caller,
- unsigned int line,
- VMAutomationRequestParser *state,
- const struct VixCommandRequestHeader *msg,
- size_t fixedLength);
-
-const void * VMAutomationRequestParserGetRemainingData(VMAutomationRequestParser *state,
- size_t *length);
-
-#define VMAutomationRequestParserGetData(state, length, result) \
- __VMAutomationRequestParserGetData(__FUNCTION__, __LINE__, \
- state, length, (const char **)result)
-VixError __VMAutomationRequestParserGetData(const char *caller,
- unsigned int line,
- VMAutomationRequestParser *state,
- size_t length,
- const char **result);
-
-#define VMAutomationRequestParserGetOptionalString(state, length, result) \
- __VMAutomationRequestParserGetOptionalString(__FUNCTION__, __LINE__, \
- state, length, result)
-VixError __VMAutomationRequestParserGetOptionalString(const char *caller,
- unsigned int line,
- VMAutomationRequestParser *state,
- size_t length,
- const char **result);
-
-#define VMAutomationRequestParserGetOptionalStrings(state, count, length, \
+} VMAutomationMsgParser;
+
+/* Keep the original type name around all the old code can stay the same. */
+typedef VMAutomationMsgParser VMAutomationRequestParser;
+
+
+#define VMAutomationRequestParserInit VMAutomationMsgParserInitRequest
+#define VMAutomationMsgParserInitRequest(state, msg, fixedLength) \
+ __VMAutomationMsgParserInitRequest(__FUNCTION__, __LINE__, state, msg, fixedLength)
+VixError
+__VMAutomationMsgParserInitRequest(const char *caller,
+ unsigned int line,
+ VMAutomationMsgParser *state,
+ const struct VixCommandRequestHeader *msg,
+ size_t fixedLength);
+
+#define VMAutomationMsgParserInitResponse(state, msg, fixedLength) \
+ __VMAutomationMsgParserInitResponse(__FUNCTION__, __LINE__, state, msg, fixedLength)
+VixError
+__VMAutomationMsgParserInitResponse(const char *caller,
+ unsigned int line,
+ VMAutomationMsgParser *state,
+ const struct VixCommandResponseHeader *msg,
+ size_t fixedLength);
+
+#define VMAutomationRequestParserGetRemainingData \
+ VMAutomationMsgParserGetRemainingData
+const void *
+VMAutomationMsgParserGetRemainingData(VMAutomationMsgParser *state,
+ size_t *length);
+
+#define VMAutomationRequestParserGetData VMAutomationMsgParserGetData
+#define VMAutomationMsgParserGetData(state, length, result) \
+ __VMAutomationMsgParserGetData(__FUNCTION__, __LINE__, \
+ state, length, (const char **)result)
+VixError __VMAutomationMsgParserGetData(const char *caller,
+ unsigned int line,
+ VMAutomationMsgParser *state,
+ size_t length,
+ const char **result);
+
+#define VMAutomationRequestParserGetOptionalString \
+ VMAutomationMsgParserGetOptionalString
+#define VMAutomationMsgParserGetOptionalString(state, length, result) \
+ __VMAutomationMsgParserGetOptionalString(__FUNCTION__, __LINE__, \
+ state, length, result)
+VixError __VMAutomationMsgParserGetOptionalString(const char *caller,
+ unsigned int line,
+ VMAutomationMsgParser *state,
+ size_t length,
+ const char **result);
+
+#define VMAutomationRequestParserGetOptionalStrings \
+ VMAutomationMsgParserGetOptionalStrings
+#define VMAutomationMsgParserGetOptionalStrings(state, count, length, \
result) \
- __VMAutomationRequestParserGetOptionalStrings(__FUNCTION__, __LINE__, \
- state, count, length, result)
-VixError __VMAutomationRequestParserGetOptionalStrings
- (const char *caller,
- unsigned int line,
- VMAutomationRequestParser *state,
- uint32 count,
- size_t length,
- const char **result);
-
-#define VMAutomationRequestParserGetString(state, length, result) \
- __VMAutomationRequestParserGetString(__FUNCTION__, __LINE__, \
- state, length, result)
-VixError __VMAutomationRequestParserGetString(const char *caller,
- unsigned int line,
- VMAutomationRequestParser *state,
- size_t length,
- const char **result);
-
-
-#define VMAutomationRequestParserGetPropertyList(state, length, propList) \
- __VMAutomationRequestParserGetPropertyList(__FUNCTION__, __LINE__, \
- state, length, propList)
-VixError __VMAutomationRequestParserGetPropertyList(const char *caller,
- unsigned int line,
- VMAutomationRequestParser *state,
- size_t length,
- VixPropertyListImpl *propList);
+ __VMAutomationMsgParserGetOptionalStrings(__FUNCTION__, __LINE__, \
+ state, count, length, result)
+VixError __VMAutomationMsgParserGetOptionalStrings
+ (const char *caller,
+ unsigned int line,
+ VMAutomationMsgParser *state,
+ uint32 count,
+ size_t length,
+ const char **result);
+
+#define VMAutomationRequestParserGetString VMAutomationMsgParserGetString
+#define VMAutomationMsgParserGetString(state, length, result) \
+ __VMAutomationMsgParserGetString(__FUNCTION__, __LINE__, \
+ state, length, result)
+VixError __VMAutomationMsgParserGetString(const char *caller,
+ unsigned int line,
+ VMAutomationMsgParser *state,
+ size_t length,
+ const char **result);
+
+#define VMAutomationRequestParserGetPropertyList \
+ VMAutomationMsgParserGetPropertyList
+#define VMAutomationMsgParserGetPropertyList(state, length, propList) \
+ __VMAutomationMsgParserGetPropertyList(__FUNCTION__, __LINE__, \
+ state, length, propList)
+VixError
+__VMAutomationMsgParserGetPropertyList(const char *caller,
+ unsigned int line,
+ VMAutomationMsgParser *state,
+ size_t length,
+ VixPropertyListImpl *propList);
#endif // VIX_HIDE_FROM_JAVA
FIELDDEFA( 81D,EAX, AMD, 5, 3, CACHE_LEVEL, NA, FALSE, AMD_CACHE_LEVEL) \
FLAGDEF( 81D, EAX, AMD, 8, 1, CACHE_SELF_INIT, NA, FALSE) \
FLAGDEF( 81D, EAX, AMD, 9, 1, CACHE_FULLY_ASSOC, NA, FALSE) \
-FIELDDEF(81D, EAX, AMD, 14, 12, NUM_SHARING_CACHE, NA, FALSE) \
+FIELDDEFA(81D, EAX, AMD, 14, 12, NUM_SHARING_CACHE, NA, FALSE, AMD_NUM_SHARING_CACHE) \
FIELDDEF(81D, EBX, AMD, 0, 12, CACHE_LINE_SIZE, NA, FALSE) \
FIELDDEF(81D, EBX, AMD, 12, 10, CACHE_PHYS_PARTITIONS, NA, FALSE) \
FIELDDEFA(81D,EBX, AMD, 22, 10, CACHE_WAYS, NA, FALSE, AMD_CACHE_WAYS) \
FLAGDEF( 81D, EDX, AMD, 1, 1, CACHE_INCLUSIVE, NA, FALSE) \
FIELDDEF(81E, EAX, AMD, 0, 32, EXTENDED_APICID, NA, FALSE) \
FIELDDEF(81E, EBX, AMD, 0, 8, COMPUTE_UNIT_ID, NA, FALSE) \
-FIELDDEF(81E, EBX, AMD, 8, 2, CORES_PER_COMPUTE_UNIT, NA, FALSE) \
+FIELDDEFA(81E, EBX, AMD, 8, 2, CORES_PER_COMPUTE_UNIT, NA, FALSE, AMD_CORES_PER_COMPUTE_UNIT) \
FIELDDEF(81E, ECX, AMD, 0, 8, NODEID, NA, FALSE) \
FIELDDEFA( 81E,ECX, AMD, 8, 3, NODES_PER_PKG, NA, FALSE, AMD_NODES_PER_PKG)
FIELD_FUNC(AMD_CACHE_LEVEL, CPUID_AMD_ID81DEAX_CACHE_LEVEL)
FIELD_FUNC(AMD_CACHE_WAYS, CPUID_AMD_ID81DEBX_CACHE_WAYS)
FIELD_FUNC(AMD_NODES_PER_PKG, CPUID_AMD_ID81EECX_NODES_PER_PKG)
+FIELD_FUNC(AMD_NUM_SHARING_CACHE, CPUID_AMD_ID81DEAX_NUM_SHARING_CACHE)
+FIELD_FUNC(AMD_CORES_PER_COMPUTE_UNIT, CPUID_AMD_ID81EEBX_CORES_PER_COMPUTE_UNIT)
#undef FIELD_FUNC
GUESTLIB_HOST_MEM_KERN_OVHD_MB = 28,
GUESTLIB_HOST_MEM_MAPPED_MB = 29,
GUESTLIB_HOST_MEM_UNMAPPED_MB = 30,
- GUESTLIB_RESOURCE_POOL_PATH_LONG = 31,
+
+ /* Counters added in ESX5.0 */
+ GUESTLIB_MEM_ZIPPED_MB = 31,
+ GUESTLIB_MEM_ZIPSAVED_MB = 32,
+ GUESTLIB_MEM_LLSWAPPED_MB = 33,
+ GUESTLIB_MEM_SWAP_TARGET_MB = 34,
+ GUESTLIB_MEM_BALLOON_TARGET_MB = 35,
+ GUESTLIB_MEM_BALLOON_MAX_MB = 36,
+ GUESTLIB_RESOURCE_POOL_PATH_LONG = 37,
/*------ Add any new statistics above this line. ------- */
/*------ Bump this when adding to this list. -------*/
- GUESTLIB_MAX_STATISTIC_ID = 32
+ GUESTLIB_MAX_STATISTIC_ID = 38
};
union GuestLibV3Stat switch (GuestLibV3TypeIds d) {
struct GuestLibV3StatUint64 hostMemMappedMB;
case GUESTLIB_HOST_MEM_UNMAPPED_MB:
struct GuestLibV3StatUint64 hostMemUnmappedMB;
+ case GUESTLIB_MEM_ZIPPED_MB:
+ struct GuestLibV3StatUint32 memZippedMB;
+ case GUESTLIB_MEM_ZIPSAVED_MB:
+ struct GuestLibV3StatUint32 memZipSavedMB;
+ case GUESTLIB_MEM_LLSWAPPED_MB:
+ struct GuestLibV3StatUint32 memLLSwappedMB;
+ case GUESTLIB_MEM_SWAP_TARGET_MB:
+ struct GuestLibV3StatUint32 memSwapTargetMB;
+ case GUESTLIB_MEM_BALLOON_TARGET_MB:
+ struct GuestLibV3StatUint32 memBalloonTargetMB;
+ case GUESTLIB_MEM_BALLOON_MAX_MB:
+ struct GuestLibV3StatUint32 memBalloonMaxMB;
case GUESTLIB_RESOURCE_POOL_PATH_LONG:
struct GuestLibV3ByteArray resourcePoolPathLong;
};
}
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMGuestLib_GetMemZippedMB --
+ *
+ * Total zipped VM memory
+ *
+ * Results:
+ * VMGuestLibError
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+VMGuestLibError
+VMGuestLib_GetMemZippedMB(VMGuestLibHandle handle, // IN
+ uint32 *memZippedMB) // OUT
+{
+ VMGuestLibError error = VMGUESTLIB_ERROR_OTHER;
+ VMGUESTLIB_GETSTAT_V3(handle, error,
+ memZippedMB, memZippedMB,
+ GUESTLIB_MEM_ZIPPED_MB);
+ return error;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMGuestLib_GetMemZipSavedMB --
+ *
+ * Total memopry saved by zipping VM memory
+ *
+ * Results:
+ * VMGuestLibError
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+VMGuestLibError
+VMGuestLib_GetMemZipSavedMB(VMGuestLibHandle handle, // IN
+ uint32 *memZipSavedMB) // OUT
+{
+ VMGuestLibError error = VMGUESTLIB_ERROR_OTHER;
+ VMGUESTLIB_GETSTAT_V3(handle, error,
+ memZipSavedMB, memZipSavedMB,
+ GUESTLIB_MEM_ZIPSAVED_MB);
+ return error;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMGuestLib_GetMemLLSwappedMB --
+ *
+ * VM memory swapped to SSD
+ *
+ * Results:
+ * VMGuestLibError
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+VMGuestLibError
+VMGuestLib_GetMemLLSwappedMB(VMGuestLibHandle handle, // IN
+ uint32 *memLLSwappedMB) // OUT
+{
+ VMGuestLibError error = VMGUESTLIB_ERROR_OTHER;
+ VMGUESTLIB_GETSTAT_V3(handle, error,
+ memLLSwappedMB, memLLSwappedMB,
+ GUESTLIB_MEM_LLSWAPPED_MB);
+ return error;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMGuestLib_GetMemSwapTargetMB --
+ *
+ * VM memory swap target
+ *
+ * Results:
+ * VMGuestLibError
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+VMGuestLibError
+VMGuestLib_GetMemSwapTargetMB(VMGuestLibHandle handle, // IN
+ uint32 *memSwapTargetMB) // OUT
+{
+ VMGuestLibError error = VMGUESTLIB_ERROR_OTHER;
+ VMGUESTLIB_GETSTAT_V3(handle, error,
+ memSwapTargetMB, memSwapTargetMB,
+ GUESTLIB_MEM_SWAP_TARGET_MB);
+ return error;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMGuestLib_GetMemBalloonTargetMB --
+ *
+ * VM memory balloon target size
+ *
+ * Results:
+ * VMGuestLibError
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+VMGuestLibError
+VMGuestLib_GetMemBalloonTargetMB(VMGuestLibHandle handle, // IN
+ uint32 *memBalloonTargetMB) // OUT
+{
+ VMGuestLibError error = VMGUESTLIB_ERROR_OTHER;
+ VMGUESTLIB_GETSTAT_V3(handle, error,
+ memBalloonTargetMB, memBalloonTargetMB,
+ GUESTLIB_MEM_BALLOON_TARGET_MB);
+ return error;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMGuestLib_GetMemBalloonMaxMB --
+ *
+ * VM memory balloon limit
+ *
+ * Results:
+ * VMGuestLibError
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+VMGuestLibError
+VMGuestLib_GetMemBalloonMaxMB(VMGuestLibHandle handle, // IN
+ uint32 *memBalloonMaxMB) // OUT
+{
+ VMGuestLibError error = VMGUESTLIB_ERROR_OTHER;
+ VMGUESTLIB_GETSTAT_V3(handle, error,
+ memBalloonMaxMB, memBalloonMaxMB,
+ GUESTLIB_MEM_BALLOON_MAX_MB);
+ return error;
+}
+
+
/*
*-----------------------------------------------------------------------------
*
#define VMXWIFI_DRIVER_SHARED_LEN 8192
+#define VMXNET3_DID_PASSTHRU 0xFFFF
+
#endif /* _VMXNET3_DEFS_H_ */
static int vmxnet3_start(void *);
static void vmxnet3_stop(void *);
static int vmxnet3_setpromisc(void *, boolean_t);
+static void vmxnet3_ioctl(void *arg, queue_t *wq, mblk_t *mp);
static int vmxnet3_multicst(void *, boolean_t, const uint8_t *);
static int vmxnet3_unicst(void *, const uint8_t *);
static boolean_t vmxnet3_getcapab(void *, mac_capab_t, void *);
/* MAC callbacks */
static mac_callbacks_t vmxnet3_mac_callbacks = {
- MC_GETCAPAB, /* mc_callbacks */
- vmxnet3_getstat, /* mc_getstat */
- vmxnet3_start, /* mc_start */
- vmxnet3_stop, /* mc_stop */
- vmxnet3_setpromisc, /* mc_setpromisc */
- vmxnet3_multicst, /* mc_multicst */
- vmxnet3_unicst, /* mc_unicst */
- vmxnet3_tx, /* mc_tx */
+ .mc_callbacks = MC_GETCAPAB | MC_IOCTL,
+ .mc_getstat = vmxnet3_getstat,
+ .mc_start = vmxnet3_start,
+ .mc_stop = vmxnet3_stop,
+ .mc_setpromisc = vmxnet3_setpromisc,
+ .mc_multicst = vmxnet3_multicst,
+ .mc_unicst = vmxnet3_unicst,
+ .mc_tx = vmxnet3_tx,
#ifndef OPEN_SOLARIS
- NULL, /* mc_resources */
+ .mc_resources = NULL,
#endif
- NULL, /* mc_ioctl */
- vmxnet3_getcapab /* mc_getcapab */
+ .mc_ioctl = vmxnet3_ioctl,
+ .mc_getcapab = *vmxnet3_getcapab,
};
/* Tx DMA engine description */
ds->devRead.misc.driverInfo.uptVerSpt = 1;
ds->devRead.misc.uptFeatures = UPT1_F_RXCSUM;
- ds->devRead.misc.mtu = ETHERMTU;
+ ds->devRead.misc.mtu = dp->cur_mtu;
+
// XXX: ds->devRead.misc.maxNumRxSG
ds->devRead.misc.numTxQueues = 1;
ds->devRead.misc.numRxQueues = 1;
*/
rxQueueSize = vmxnet3_getprop(dp, "RxRingSize", 32, 4096,
VMXNET3_DEF_RX_RING_SIZE);
- if (!(txQueueSize & VMXNET3_RING_SIZE_MASK)) {
+ if (!(rxQueueSize & VMXNET3_RING_SIZE_MASK)) {
dp->rxQueue.cmdRing.size = rxQueueSize;
dp->rxQueue.compRing.size = rxQueueSize;
dp->rxQueue.sharedCtrl = &rqdesc->ctrl;
return DDI_SUCCESS;
}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * vmxnet3_change_mtu --
+ *
+ * Change the MTU as seen by the driver. Reset the device and tx/rx queues
+ * so that buffers of right size are posted in rx queues.
+ *
+ * Results:
+ * EINVAL for invalid MTUs or other failures. 0 for success.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+static int
+vmxnet3_change_mtu(vmxnet3_softc_t *dp, uint32_t new_mtu)
+{
+ int ret = 0, do_reset = 0;
+ ASSERT(dp);
+ if (new_mtu == dp->cur_mtu) {
+ VMXNET3_WARN(dp, "New MTU is same as old mtu : %d.\n", new_mtu);
+ return 0;
+ }
+
+ if (new_mtu < VMXNET3_MIN_MTU || new_mtu > VMXNET3_MAX_MTU) {
+ VMXNET3_WARN(dp, "New MTU not in valid range [%d, %d].\n",
+ VMXNET3_MIN_MTU, VMXNET3_MAX_MTU);
+ return EINVAL;
+ }
+
+ if (dp->devEnabled) {
+ do_reset = 1;
+ vmxnet3_stop(dp);
+ VMXNET3_BAR1_PUT32(dp, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV);
+ }
+
+ dp->cur_mtu = new_mtu;
+
+ if (do_reset)
+ ret = vmxnet3_start(dp);
+
+ return ret;
+}
+
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * vmxnet3_ioctl --
+ *
+ * DDI/DDK callback to handle IOCTL in driver. Currently it only handles
+ * ND_SET ioctl. Rest all are ignored. The ND_SET is used to set/reset
+ * accept-jumbo ndd parameted for the interface.
+ *
+ * Results:
+ * Nothing is returned directly. An ACK or NACK is conveyed to the calling
+ * function from the mblk which was used to call this function.
+ *
+ * Side effects:
+ * MTU can be changed and device can be reset.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+static void
+vmxnet3_ioctl(void *arg, queue_t *wq, mblk_t *mp)
+{
+ vmxnet3_softc_t *dp = arg;
+ int ret = EINVAL;
+ IOCP iocp;
+ mblk_t *mp1;
+ char *valp, *param;
+ int data;
+
+ iocp = (void *)mp->b_rptr;
+ iocp->ioc_error = 0;
+
+ switch (iocp->ioc_cmd) {
+ case ND_SET:
+
+ /* the mblk in continuation would contain the ndd parameter name
+ * and data value to be set
+ */
+ mp1 = mp->b_cont;
+ if (!mp1) {
+ VMXNET3_WARN(dp, "Error locating parameter name.\n");
+ ret = EINVAL;
+ break;
+ }
+
+ mp1->b_datap->db_lim[-1] = '\0'; /* Force null termination */
+
+ /*
+ * From /usr/src/uts/common/inet/nd.c : nd_getset()
+ * "logic throughout nd_xxx assumes single data block for ioctl.
+ * However, existing code sends in some big buffers."
+ */
+ if (mp1->b_cont) {
+ freemsg(mp1->b_cont);
+ mp1->b_cont = NULL;
+ }
+
+ valp = (char *)mp1->b_rptr; /* Points to param name*/
+ ASSERT(valp);
+ param = valp;
+ VMXNET3_DEBUG(dp, 3, "ND Set ioctl for %s\n", param);
+
+ /* Go past the end of this null terminated string to get the data value.*/
+ while (*valp && valp <= (char *)mp1->b_wptr)
+ valp++;
+
+ if (valp > (char *)mp1->b_wptr) {
+ /* We are already beyond the readable area of mblk and still havent
+ * found the end of param string.
+ */
+ VMXNET3_WARN(dp, "No data value found to be set to param.\n");
+ data = -1;
+ } else {
+ valp++; /* Now this points to data string */
+ data = (int)*valp - (int)'0'; /* Get numeric value of first letter */
+ }
+
+ if (strcmp("accept-jumbo", param) == 0) {
+ if (data == 1) {
+ VMXNET3_DEBUG(dp, 2, "Accepting jumbo frames\n");
+ ret = vmxnet3_change_mtu(dp, VMXNET3_MAX_MTU);
+ } else if (data == 0) {
+ VMXNET3_DEBUG(dp, 2, "Rejecting jumbo frames\n");
+ ret = vmxnet3_change_mtu(dp, ETHERMTU);
+ } else {
+ VMXNET3_WARN(dp, "Invalid data value to be set, use 1 or 0.\n");
+ ret = -1;
+ }
+ }
+ freemsg(mp1);
+ mp->b_cont = NULL;
+ break;
+
+ default:
+ if (mp->b_cont) {
+ freemsg(mp->b_cont);
+ mp->b_cont = NULL;
+ }
+ ret = -1;
+ break;
+ }
+
+ if (ret == 0)
+ miocack(wq, mp, 0, 0);
+ else
+ miocnak(wq, mp, 0, EINVAL);
+}
+
+
/*
*---------------------------------------------------------------------------
*
return DDI_INTR_UNCLAIMED;
}
+
/*
*---------------------------------------------------------------------------
*
dp->dip = dip;
dp->instance = ddi_get_instance(dip);
+ dp->cur_mtu = ETHERMTU;
VMXNET3_DEBUG(dp, 1, "attach()\n");
macr->m_src_addr = dp->macaddr;
macr->m_dst_addr = NULL;
macr->m_callbacks = &vmxnet3_mac_callbacks;
- macr->m_min_sdu = 0;
- macr->m_max_sdu = ETHERMTU;
+ macr->m_min_sdu = VMXNET3_MIN_MTU;
+ macr->m_max_sdu = VMXNET3_MAX_MTU;
macr->m_pdata = NULL;
macr->m_pdata_size = 0;
#include "vmxnet3_solaris.h"
-#define VMXNET3_RXBUF_SIZE (ETHERMTU + 18)
-
static void vmxnet3_put_rxbuf(vmxnet3_rxbuf_t *rxBuf);
/*
{
vmxnet3_rxbuf_t *rxBuf;
int flag = canSleep ? KM_SLEEP : KM_NOSLEEP;
+ int err;
rxBuf = kmem_zalloc(sizeof(vmxnet3_rxbuf_t), flag);
if (!rxBuf) {
return NULL;
}
- if (vmxnet3_alloc_dma_mem_1(dp, &rxBuf->dma, VMXNET3_RXBUF_SIZE,
- canSleep) != DDI_SUCCESS) {
+ if ((err = vmxnet3_alloc_dma_mem_1(dp, &rxBuf->dma, (dp->cur_mtu + 18),
+ canSleep)) != DDI_SUCCESS) {
+
+ VMXNET3_DEBUG(dp, 0, "Failed to allocate %d bytes for rx buf, err:%d.\n",
+ (dp->cur_mtu + 18), err);
kmem_free(rxBuf, sizeof(vmxnet3_rxbuf_t));
return NULL;
}
Vmxnet3_RxQueueCtrl *sharedCtrl;
} vmxnet3_rxqueue_t;
-#if 0
-enum {
- PARAM_ACCEPT_JUMBO = 0,
- PARAM_MTU
- VMXNET3_PARAM_COUNT
-};
-
-#endif
typedef struct vmxnet3_softc_t {
dev_info_t *dip;
uint32_t rxMode;
vmxnet3_dmabuf_t mfTable;
-// caddr_t nd_arg_p;
} vmxnet3_softc_t;
int vmxnet3_alloc_dma_mem_1(vmxnet3_softc_t *dp, vmxnet3_dmabuf_t *dma,
success = File_Rename(srcFilePathName, destFilePathName);
if (!success) {
- Debug("%s: File_Rename failed.\n", __FUNCTION__);
err = FoundryToolsDaemon_TranslateSystemErr();
+ Debug("%s: File_Rename failed.\n", __FUNCTION__);
goto abort;
}
}
if (!Win32U_SetFileAttributes(filePathName, fileAttr)) {
- Debug("%s: Failed to set the file attributes\n", __FUNCTION__);
err = FoundryToolsDaemon_TranslateSystemErr();
+ Debug("%s: Failed to set the file attributes\n", __FUNCTION__);
goto abort;
}
} else {
- Debug("%s: Failed to get the file attributes\n", __FUNCTION__);
err = FoundryToolsDaemon_TranslateSystemErr();
+ Debug("%s: Failed to get the file attributes\n", __FUNCTION__);
goto abort;
}
}
success = File_SetFilePermissions(filePathName,
setGuestFileAttributesRequest->permissions);
if (!success) {
- Debug("%s: Failed to set the file permissions\n", __FUNCTION__);
err = FoundryToolsDaemon_TranslateSystemErr();
+ Debug("%s: Failed to set the file permissions\n", __FUNCTION__);
goto abort;
}
}
ownerId = statbuf.st_uid;
groupId = statbuf.st_gid;
} else {
+ err = FoundryToolsDaemon_TranslateSystemErr();
Debug("%s: Posix_Stat(%s) failed with %d\n",
__FUNCTION__, filePathName, errno);
- err = FoundryToolsDaemon_TranslateSystemErr();
goto abort;
}
}
if (Posix_Chown(filePathName, ownerId, groupId)) {
- Debug("%s: Failed to set the owner/group Id\n", __FUNCTION__);
err = FoundryToolsDaemon_TranslateSystemErr();
+ Debug("%s: Failed to set the owner/group Id\n", __FUNCTION__);
goto abort;
}
}
&processToken);
if (!retVal || !processToken) {
+ err = FoundryToolsDaemon_TranslateSystemErr();
Warning("unable to open process token: windows error code %d\n",
GetLastError());
- err = FoundryToolsDaemon_TranslateSystemErr();
goto abort;
}
&processTokenInfoSize);
if (ERROR_INSUFFICIENT_BUFFER != GetLastError()) {
+ err = FoundryToolsDaemon_TranslateSystemErr();
Warning("unable to get token info: windows error code %d\n",
GetLastError());
- err = FoundryToolsDaemon_TranslateSystemErr();
+
goto abort;
}
processTokenInfo,
processTokenInfoSize,
&processTokenInfoSize)) {
+ err = FoundryToolsDaemon_TranslateSystemErr();
Warning("unable to get token info: windows error code %d\n",
GetLastError());
- err = FoundryToolsDaemon_TranslateSystemErr();
+
goto abort;
}
&sidNameUse);
if (ERROR_INSUFFICIENT_BUFFER != GetLastError()) {
+ err = FoundryToolsDaemon_TranslateSystemErr();
Warning("unable to lookup account sid: windows error code %d\n",
GetLastError());
- err = FoundryToolsDaemon_TranslateSystemErr();
goto abort;
}
sidDomainName,
&sidDomainNameSize,
&sidNameUse)) {
+ err = FoundryToolsDaemon_TranslateSystemErr();
Warning("unable to lookup account sid: windows error code %d\n",
GetLastError());
- err = FoundryToolsDaemon_TranslateSystemErr();
goto abort;
}