summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d5cd872)
raw | patch | inline | side by side (parent: d5cd872)
author | Justin Sobota <jsobota@ti.com> | |
Tue, 20 Nov 2012 23:20:35 +0000 (18:20 -0500) | ||
committer | Justin Sobota <jsobota@ti.com> | |
Tue, 20 Nov 2012 23:20:35 +0000 (18:20 -0500) |
config.bld | patch | blob | history | |
rm_services.h | patch | blob | history | |
rm_transport.h | patch | blob | history | |
src/rm.c | patch | blob | history | |
src/rm_nameserver.c | patch | blob | history | |
src/rm_services.c | patch | blob | history | |
src/rm_transport.c | patch | blob | history | |
test/rm_osal.c | patch | blob | history | |
test/rm_test.c | patch | blob | history | |
test/rm_test.cfg | patch | blob | history |
diff --git a/config.bld b/config.bld
index f929e70569113c43ade8f1cc5887eeb65d6f35ce..587bf55b6be77f539b537d981c2010bb37d5f058 100644 (file)
--- a/config.bld
+++ b/config.bld
/* C66 ELF compiler configuration for Little Endian Mode. */\r
var C66LE = xdc.useModule('ti.targets.elf.C66');\r
C66LE.rootDir = toolsBaseDir;\r
-C66LE.ccOpts.prefix = "-mo -o3 -q -k -eo.o";\r
+C66LE.ccOpts.prefix = "-mo -g -q -k -eo.o";\r
\r
/* C66 ELF compiler configuration for Big Endian Mode. */\r
var C66BE = xdc.useModule('ti.targets.elf.C66_big_endian');\r
C66BE.rootDir = toolsBaseDir;\r
-C66BE.ccOpts.prefix = "-mo -o3 -q -k -eo.o -DBIGENDIAN";\r
+C66BE.ccOpts.prefix = "-mo -g -q -k -eo.o -DBIGENDIAN";\r
\r
/* Check if we need to run the STATIC Analysis or not? */\r
var coverityAnalysis = java.lang.System.getenv("STATIC_ANALYZE");\r
diff --git a/rm_services.h b/rm_services.h
index f4b5e2493fdadeda15f3cb2e8d27d5ecd0cd0189..15904bc60d13ba09832321fddb7bd031ebfd86c1 100644 (file)
--- a/rm_services.h
+++ b/rm_services.h
@{
*/
-/** RM Service Request (serviceResult) Action Codes and Errors */
-/** RM Service Request Action Code Base */
-#define RM_SERVICE_ACTION_BASE (0)
-/** RM internal action okay - This value is for internal use by RM. It should never be
+/** RM Service Request State Codes and Errors */
+/** RM Service Request State Code Base */
+#define RM_SERVICE_STATE_BASE (0)
+/** RM internal state okay - This value is for internal use by RM. It should never be
* seen as a return value during normal operation */
-#define RM_SERVICE_ACTION_OKAY (RM_SERVICE_ACTION_BASE)
+#define RM_SERVICE_STATE_OKAY (RM_SERVICE_STATE_BASE)
+/** RM service is being processed. Typically this means the service is
+ * being sent to a higher level RM agent for processing */
+#define RM_SERVICE_PROCESSING (RM_SERVICE_STATE_BASE+1)
/** RM service was approved. The resource data in the response is valid if
* the service has been approved. */
-#define RM_SERVICE_APPROVED (RM_SERVICE_ACTION_BASE+1)
+#define RM_SERVICE_APPROVED (RM_SERVICE_STATE_BASE+2)
/** Beginning of resource denied reasons */
-#define RM_SERVICE_DENIED_BEGIN (RM_SERVICE_ACTION_BASE+2)
+#define RM_SERVICE_DENIED_BEGIN (RM_SERVICE_STATE_BASE+3)
/** End of resource denied reasons */
-#define RM_SERVICE_DENIED_END (RM_SERVICE_ACTION_BASE+2)
-/** RM service is being processed. Typically this means the service is
- * being sent to a higher level RM agent for processing */
-#define RM_SERVICE_PROCESSING (RM_SERVICE_ACTION_BASE+3)
+#define RM_SERVICE_DENIED_END (RM_SERVICE_STATE_BASE+3)
/** RM Service Request Error Code Base */
#define RM_SERVICE_ERROR_BASE (-64)
#define RM_SERVICE_ERROR_TRANSACTION_DOES_NOT_EXST_FOR_THIS_RM_INSTANCE (RM_SERVICE_ERROR_BASE-8)
/** RM failed to allocate memory for new service transaction */
#define RM_SERVICE_ERROR_TRANSACTION_FAILED_TO_ALLOCATE (RM_SERVICE_ERROR_BASE-9)
-/** RM found no service transactions queued when trying to delete a received service
- * transaction */
-#define RM_SERVICE_ERROR_NO_TRANSACTIONS_IN_QUEUE (RM_SERVICE_ERROR_BASE-10)
/** RM could not find the service transaction in the RM instance's transaction queue */
-#define RM_SERVICE_ERROR_SERVICE_TRANSACTION_DOES_NOT_EXIST (RM_SERVICE_ERROR_BASE-11)
-/** RM received a response transaction and found a request transaction awaiting a response.
- * However, the request transaction was not in the "awaiting response" state */
-#define RM_SERVICE_ERROR_INVALID_REQUEST_TRANSACTION_STATE_UPON_RESPONSE (RM_SERVICE_ERROR_BASE-12)
-/** RM Client instance received a service transaction response that did not have a
- * matching service request that originated on the Client instance */
-#define RM_SERVICE_ERROR_INVALID_TRANSACTION_RECEIVED_ON_CLIENT (RM_SERVICE_ERROR_BASE-13)
+#define RM_SERVICE_ERROR_SERVICE_TRANSACTION_DOES_NOT_EXIST (RM_SERVICE_ERROR_BASE-10)
/** A failure occurred within a registered transport's packet free API */
-#define RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR (RM_SERVICE_ERROR_BASE-14)
-/** Invalid NameServer object create on non-Server instance */
-#define RM_SERVICE_ERROR_NAMESERVER_OBJECT_CREATE_ON_INVALID_INSTANCE (RM_SERVICE_ERROR_BASE-15)
-/** Invalid NameServer object delete on non-Server instance */
-#define RM_SERVICE_ERROR_NAMESERVER_OBJECT_DELETE_ON_INVALID_INSTANCE (RM_SERVICE_ERROR_BASE-16)
+#define RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR (RM_SERVICE_ERROR_BASE-11)
+/** Invalid NameServer object modification on non-Server instance */
+#define RM_SERVICE_ERROR_NAMESERVER_OBJECT_MOD_ON_INVALID_INSTANCE (RM_SERVICE_ERROR_BASE-12)
/**
* @brief Maximum number of characters in the resource names
* requesting component
*/
typedef struct {
- /** Result of the service request
+ /** State of the service request.
* Non-negative result: RM has taken an action based on the request
* Negative result: RM has encountered an error handling the request */
- int32_t serviceResult;
- /** A request ID will be returned to the component if the requested service cannot
- * be completed immediately. The request ID can be used by the component to identify
- * service responses received via the component callback function. A request ID will not
+ int32_t serviceState;
+ /** A service ID will be returned to the component if the requested service cannot
+ * be completed immediately. The service ID can be used by the component to identify
+ * service responses received via the component callback function. A service ID will not
* be returned if the service request is satisfied immediately */
- uint32_t requestId;
+ uint32_t serviceId;
/** The base value of the returned resource. In the case of a block resource allocation
* response this field will contain the base value of the block. */
int32_t resourceBase;
uint32_t resourceRange;
} Rm_ServiceRespInfo;
+/**
+ * @brief RM service callback function structure
+ */
typedef struct {
/** Component callback function. RM will call this function when the
* resource service request is completed. The callback function supplied
diff --git a/rm_transport.h b/rm_transport.h
index d2906c6e9501d5b14ee22332fbfdd8fd588b2f4e..039fb12ebbb4aac8f50b453a0bb4f16b779f6b18 100644 (file)
--- a/rm_transport.h
+++ b/rm_transport.h
#define RM_TRANSPORT_ERROR_PACKET_RECEPTION_ERROR (RM_TRANSPORT_ERROR_BASE-3)
/** RM received a packet with an unknown RM packet type */
#define RM_TRANSPORT_ERROR_INVALID_PACKET_TYPE (RM_TRANSPORT_ERROR_BASE-4)
-
+/** RM resource request transaction could not be found matching the response received */
+#define RM_TRANSPORT_ERROR_MATCHING_RESOURCE_REQUEST_NOT_FOUND (RM_TRANSPORT_ERROR_BASE-5)
+/** RM NameServer request transaction could not be found matching the response received */
+#define RM_TRANSPORT_ERROR_MATCHING_NAME_SERVER_REQUEST_NOT_FOUND (RM_TRANSPORT_ERROR_BASE-6)
/**
* @brief Result of RM transport layer operations
diff --git a/src/rm.c b/src/rm.c
index 9484c8cb0e7ed73eca826f81dbb068160e25c91d..2ef6cc90c98a878a140a8efb485fe89a007f3808 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
void *key;\r
\r
/* Lock access to the RM instance's transaction queue */\r
- key = Rm_osalCsEnter();\r
+ key = Rm_osalMtCsEnter();\r
\r
/* Get memory for a new transaction from local memory */\r
newTransaction = Rm_osalMalloc(sizeof(Rm_Transaction), false);\r
/* Return if the memory allocated for the transaction entry is NULL */\r
if (newTransaction == NULL)\r
{\r
- Rm_osalCsExit(key);\r
+ Rm_osalMtCsExit(key);\r
return(newTransaction);\r
}\r
\r
rmInst->transactionQueue = newTransaction;\r
}\r
\r
- Rm_osalCsExit(key);\r
+ Rm_osalMtCsExit(key);\r
return (newTransaction);\r
}\r
\r
{\r
Rm_Transaction *transaction = (Rm_Transaction *) rmInst->transactionQueue;\r
Rm_Transaction *prevTransaction = NULL;\r
+ int32_t retVal = RM_SERVICE_STATE_OKAY;\r
void *key;\r
\r
/* Lock access to the RM instance's transaction queue */\r
- key = Rm_osalCsEnter();\r
-\r
- /* Make sure there is at least one entry in the transaction queue */\r
- if (transaction == NULL)\r
- {\r
- Rm_osalCsExit(key);\r
- return (RM_SERVICE_ERROR_NO_TRANSACTIONS_IN_QUEUE);\r
- }\r
+ key = Rm_osalMtCsEnter();\r
\r
/* Find the transaction ID within the specified RM instance's transaction queue. */\r
while (transaction != NULL)\r
/* Traversed entire queue but did not find transaction */\r
if (transaction == NULL)\r
{\r
- Rm_osalCsExit(key);\r
- return (RM_SERVICE_ERROR_SERVICE_TRANSACTION_DOES_NOT_EXIST);\r
+ retVal = RM_SERVICE_ERROR_SERVICE_TRANSACTION_DOES_NOT_EXIST;\r
}\r
else\r
{\r
/* Delete the transaction */\r
- if ((prevTransaction == NULL) && transaction->nextTransaction)\r
+ if (prevTransaction == NULL)\r
{\r
/* Transaction to be deleted exists at start of transaction queue. Map second\r
- * transaction to be start of transaction queue as long as there are more than\r
- * one transactions */\r
+ * transaction to be start of transaction queue. This covers case where there is\r
+ * only one transaction in the queue since the nextTransaction will be NULL */\r
rmInst->transactionQueue = transaction->nextTransaction;\r
}\r
else\r
Rm_osalFree((void *)transaction, sizeof(Rm_Transaction), false);\r
}\r
\r
- Rm_osalCsExit(key);\r
- return (RM_SERVICE_ACTION_OKAY);\r
+ Rm_osalMtCsExit(key);\r
+ return (retVal);\r
}\r
\r
uint32_t Rm_transactionInitSequenceNum(void)\r
{\r
- /* Sequence number can never have a value of 0 so that there are no conflicts\r
- * when searching for transactions that received a response of a higher level RM agent */\r
+ /* Sequence number can never have a value of zero so that there are no conflicts\r
+ * with transactions that have a remoteOriginatingId of zero */\r
return (1);\r
}\r
\r
uint32_t Rm_transactionGetSequenceNum(Rm_Inst *rmInst)\r
{\r
uint32_t sequenceNum = 0;\r
- void *key;\r
-\r
- /* Lock access to the RM instance */\r
- key = Rm_osalCsEnter();\r
\r
/* Get the next sequence number and then increment. If there's an overflow\r
* assign the initial value instead of incrementing. */\r
sequenceNum = rmInst->transactionSeqNum++;\r
} \r
\r
- Rm_osalCsExit(key);\r
return (sequenceNum);\r
}\r
\r
/* Function used to send RM response transactions to lower level agents */\r
-void Rm_transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction,\r
- Rm_TransactionReceipt *receipt)\r
+void Rm_transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
{\r
Rm_TransportNode *dstTransportNode = NULL;\r
Rm_Packet *rmPkt = NULL;\r
case Rm_service_RESOURCE_BLOCK_FREE:\r
case Rm_service_RESOURCE_FREE_BY_NAME:\r
rmPkt = Rm_transportCreateResourceResponsePkt(rmInst, dstTransportNode, \r
- transaction, receipt);\r
+ transaction);\r
break;\r
case Rm_service_RESOURCE_MAP_TO_NAME:\r
case Rm_service_RESOURCE_UNMAP_NAME:\r
rmPkt = Rm_transportCreateNsResponsePkt(rmInst, dstTransportNode,\r
- transaction, receipt);\r
+ transaction);\r
break;\r
default:\r
/* Invalid service type. Flag the error and return */\r
- receipt->serviceResult = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;\r
+ transaction->state = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;\r
break;\r
}\r
\r
- if (receipt->serviceResult <= RM_SERVICE_ERROR_BASE)\r
+ if (transaction->state <= RM_SERVICE_ERROR_BASE)\r
{\r
/* Delete the transaction and return immediately because an error occurred \r
* allocating the packet */\r
- Rm_transactionQueueDelete(rmInst, transaction->id);\r
+ Rm_transactionQueueDelete(rmInst, transaction->localId);\r
return;\r
}\r
\r
{\r
/* Negative value returned by transport send. An error occurred\r
* in the transport while attempting to send the packet.*/\r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
+ transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
/* Clean up the packet */\r
if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransportNode, rmPkt))\r
{\r
/* Non-NULL value returned by transport packet free. Flag the\r
* error */\r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR;\r
}\r
return;\r
}\r
\r
- /* Fill out the receipt information and delete the transaction */\r
- receipt->serviceResult = transaction->details;\r
- Rm_transactionQueueDelete(rmInst, transaction->id);\r
+ /* NEED TO DO SOMETHING IF GET AN ERROR IN THE transaction->state FIELD. CREATE\r
+ * NEW TRANSACTION WITH DATA FROM ORIGINAL? THEN TRY TO SEND FAILED REQUEST BACK\r
+ * TO REQUESTER??? KEEP RETRYING SEND OF RESPONSE??? */\r
+\r
+ /* Delete the transaction */\r
+ Rm_transactionQueueDelete(rmInst, transaction->localId);\r
}\r
\r
-void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction,\r
- Rm_TransactionReceipt *receipt)\r
+void Rm_allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
{\r
if (rmInst->instType == Rm_instType_CLIENT_DELEGATE)\r
{\r
#if 0 \r
/* Check local policy to see if the request can be satisfied with the\r
* resources stored locally */\r
- Rm_policy...API()\r
+ Rm_policy...API()\r
\r
if (policy check approves the resource)\r
{\r
/* call the allocator to allocate the resource */\r
if (allocator returns resource)\r
{\r
- /* Populate the receipt with the allocated resources and the result */\r
- receipt->serviceResult = approve reason;\r
- receipt->serviceId = transaction->id;\r
+ /* Populate the transaction with the allocated resources and the result */\r
+ transaction->state = approve reason;\r
return ...\r
}\r
else\r
else if (policy check denies resource)\r
{\r
/* Policy check denied resource. */\r
- receipt->serviceResult = deny reason;\r
- receipt->serviceId = transaction->id;\r
+ transaction->state= deny reason;\r
return ...\r
}\r
else if (policy check says forward to Server for validation)\r
{\r
/* Forward the transaction to the Server */\r
- Rm_transactionForwarder(rmInst, transaction, receipt);\r
+ Rm_transactionForwarder(rmInst, transaction);\r
}\r
#endif \r
}\r
/* call allocator to allocate resource */\r
}\r
\r
- receipt->serviceResult = approve or deny reason;\r
- receipt->serviceId = transaction->id;\r
- receipt->resourceBase = ...;\r
- receipt->resourceRange = ...;\r
+ transaction->state = approve or deny reason;\r
+ transaction->resourceInfo.base = ...;\r
+ transaction->resourceInfo.range = ...;\r
\r
/* If source instance name does not match the current instance\r
- * name the allocation request came from a client. The result\r
+ * name the allocation request came from a Client. The result\r
* must be sent back to the Client */\r
if (strcmp(transaction->sourceInstName, rmInst->name))\r
{\r
- /* Names don't match. Copy the allocation response resource data \r
- * into the original transaction and send it back to the Client */\r
- transaction->details = transaction->details;\r
- transaction->resourceInfo.base = receipt->resourceBase;\r
- transaction->resourceInfo.range = receipt->resourceRange;\r
- Rm_transactionResponder(rmInst, transaction, receipt);\r
+ /* Names don't match. Send the transaction back to the Client */\r
+ Rm_transactionResponder(rmInst, transaction);\r
}\r
else\r
{\r
/* Resource allocation request originated locally on the active\r
- * instance. Send the response via the service responder. */\r
- transaction->details = transaction->details;\r
- transaction->resourceInfo.base = receipt->resourceBase;\r
- transaction->resourceInfo.range = receipt->resourceRange; \r
- Rm_serviceResponder(rmInst, transaction, NULL, receipt); \r
+ * instance. Send the response via the service responder. */ \r
+ Rm_serviceResponder(rmInst, transaction); \r
}\r
#endif \r
} \r
}\r
\r
-void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction,\r
- Rm_TransactionReceipt *receipt)\r
+void Rm_freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
{\r
if (rmInst->instType == Rm_instType_CLIENT_DELEGATE)\r
{\r
#if 0 \r
/* Check local policy to see if the request can be satisfied with the\r
* resources stored locally */\r
- Rm_policy...API()\r
+ Rm_policy...API()\r
\r
if (policy check approves the free)\r
{\r
else\r
{\r
/* Populate the receipt with the freed resources and the result */\r
- receipt->serviceResult = approve reason;\r
- receipt->serviceId = transaction->id;\r
+ transaction->state = approve reason;\r
return ...\r
}\r
}\r
else if (policy check denies resource free)\r
{\r
/* Policy check denied resource. */\r
- receipt->serviceResult = deny reason;\r
- receipt->serviceId = transaction->id;\r
+ transaction->state = deny reason;\r
return ...\r
}\r
else if (policy check says forward to Server for validation)\r
{\r
/* Forward the transaction to the Server */\r
- Rm_transactionForwarder(rmInst, transaction, receipt);\r
+ Rm_transactionForwarder(rmInst, transaction);\r
}\r
#endif \r
}\r
/* call allocator to free resources */\r
}\r
\r
- receipt->serviceResult = approve or deny reason;\r
- receipt->serviceId = transaction->id;\r
- receipt->resourceBase = ...;\r
- receipt->resourceRange = ...;\r
+ transaction->state = approve or deny reason;\r
+ transaction->resourceInfo.base = ...;\r
+ transaction->resourceInfo.range = ...;\r
\r
/* If source instance name does not match the current instance\r
* name the allocation request came from a client. The result\r
* must be sent back to the Client */\r
if (strcmp(transaction->sourceInstName, rmInst->name))\r
{\r
- /* Names don't match. Copy the free response resource data \r
- * into the original transaction and send it back to the Client Delegate or Client */\r
- transaction->details = transaction->details;\r
- transaction->resourceInfo.base = receipt->resourceBase;\r
- transaction->resourceInfo.range = receipt->resourceRange;\r
- Rm_transactionResponder(rmInst, transaction, receipt);\r
+ /* Names don't match. Send the transaction back to the Client Delegate or Client */\r
+ Rm_transactionResponder(rmInst, transaction);\r
}\r
else\r
{\r
/* Resource allocation request originated locally on the active\r
* instance. Send the response via the service responder. */\r
- transaction->details = transaction->details;\r
- transaction->resourceInfo.base = receipt->resourceBase;\r
- transaction->resourceInfo.range = receipt->resourceRange;\r
- Rm_serviceResponder(rmInst, transaction, NULL, receipt); \r
+ Rm_serviceResponder(rmInst, transaction); \r
}\r
#endif \r
} \r
}\r
\r
/* Function used to forward RM transactions to higher level agents */\r
-void Rm_transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction,\r
- Rm_TransactionReceipt *receipt)\r
+void Rm_transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
{\r
Rm_TransportNode *dstTransportNode = NULL;\r
Rm_Packet *rmPkt = NULL;\r
/* Make sure the RM instance has a transport registered with a higher level agent */\r
if (rmInst->registeredWithDelegateOrServer == false)\r
{\r
- receipt->serviceResult = RM_SERVICE_ERROR_NOT_REGISTERED_WITH_DEL_OR_SERVER;\r
+ transaction->state = RM_SERVICE_ERROR_NOT_REGISTERED_WITH_DEL_OR_SERVER;\r
return;\r
}\r
\r
case Rm_service_RESOURCE_BLOCK_FREE:\r
case Rm_service_RESOURCE_FREE_BY_NAME:\r
rmPkt = Rm_transportCreateResourceReqPkt(rmInst, dstTransportNode, \r
- transaction, receipt);\r
+ transaction);\r
break;\r
case Rm_service_RESOURCE_MAP_TO_NAME:\r
case Rm_service_RESOURCE_UNMAP_NAME:\r
rmPkt = Rm_transportCreateNsRequestPkt(rmInst, dstTransportNode,\r
- transaction, receipt);\r
+ transaction);\r
break;\r
default:\r
/* Invalid service type. Flag the error and return */\r
- receipt->serviceResult = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;\r
+ transaction->state = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;\r
break;\r
}\r
\r
- if (receipt->serviceResult <= RM_SERVICE_ERROR_BASE)\r
+ if (transaction->state <= RM_SERVICE_ERROR_BASE)\r
{\r
/* Return immediately because an error occurred allocating the packet */\r
return;\r
}\r
\r
- /* Switch the queued transaction to the awaiting response state */\r
- transaction->state = Rm_transactionState_AWAITING_RESPONSE;\r
-\r
/* Send the RM packet to the application transport */\r
if (rmInst->transport.rmSend((Rm_TransportHandle) dstTransportNode, rmPkt) < RM_TRANSPORT_SUCCESSFUL)\r
{\r
/* Negative value returned by transport send. An error occurred\r
* in the transport while attempting to send the packet.*/\r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
+ transaction->state = RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR;\r
/* Clean up the packet */\r
if (rmInst->transport.rmFreePkt((Rm_TransportHandle) dstTransportNode, rmPkt))\r
{\r
/* Non-NULL value returned by transport packet free. Flag the\r
* error */\r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR;\r
}\r
return;\r
}\r
\r
- /* Inform requesting component that the service is being forwarded to a higher lever\r
- * RM agent for processing. The result of the service will be provided to the \r
- * component via the specified callback function */\r
- receipt->serviceResult = RM_SERVICE_PROCESSING;\r
- receipt->serviceId = transaction->id;\r
+ /* Transaction is not deleted because it is awaiting a response from the higher level\r
+ * RM instance */\r
}\r
\r
void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)\r
{\r
- Rm_Transaction *queuedTransaction = NULL;\r
-\r
/* Handle auto-forwarded transactions. These transactions include:\r
* - All request transactions received on Clients are forwarded to the Client Delegate\r
* - NameServer requests received on the Client Delegate are forwarded to the Server */\r
(transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||\r
(transaction->type == Rm_service_RESOURCE_UNMAP_NAME)))\r
{\r
- /* Check if the new transaction's ID matches any transactions waiting for\r
- * responses. A transaction received as a response will have an ID that \r
- * matches the transaction that originated the request packet */\r
- if (queuedTransaction = Rm_transactionQueueFind(rmInst, transaction->id))\r
+ /* Check if the transaction is a transaction that received a response to its\r
+ * request. */\r
+ if (transaction->state != RM_SERVICE_PROCESSING)\r
{\r
- if (queuedTransaction->state == Rm_transactionState_AWAITING_RESPONSE)\r
+\r
+ /* A transaction has received a response. Send the response to either the \r
+ * transaction or service responder based on the source instance */\r
+ if (strcmp(transaction->sourceInstName, rmInst->name))\r
{\r
- if (rmInst->instType == Rm_instType_CLIENT)\r
- {\r
- /* Client found a transaction awaiting a response. Pass both transactions\r
- * to the service responder for response processing */\r
- Rm_serviceResponder(rmInst, transaction, queuedTransaction, receipt);\r
- }\r
- else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE)\r
- {\r
- /* Client Delegate found a NameServer transaction awaiting a response. Send the \r
- * response to either the transaction or service responder based on the \r
- * source instance */\r
- if (strcmp(queuedTransaction->sourceInstName, rmInst->name))\r
- {\r
- /* NameServer transaction originated from another instance. Use the \r
- * transaction responder to send the NameServer result to the source instance.\r
- * Need to transfer the NameServer result details to the request transaction \r
- * which will be reused for the response. */\r
- queuedTransaction->details = transaction->details;\r
- Rm_transactionResponder(rmInst, queuedTransaction, receipt);\r
- /* Delete the response transaction */\r
- Rm_transactionQueueDelete(rmInst, transaction->id); \r
- }\r
- else\r
- {\r
- /* NameServer request originated on the Client Delegate instance. Send to the\r
- * service responder */\r
- Rm_serviceResponder(rmInst, transaction, queuedTransaction,\r
- receipt);\r
- }\r
- }\r
+ /* Transaction originated from another instance. Use the \r
+ * transaction responder to send the result to the source instance. This\r
+ * is not possible on RM Clients since they can't forward RM services */\r
+ Rm_transactionResponder(rmInst, transaction);\r
}\r
else\r
{\r
- /* Request transaction was not in the awaiting response state. Flag the\r
- * error in the receipt and return */\r
- receipt->serviceResult = RM_SERVICE_ERROR_INVALID_REQUEST_TRANSACTION_STATE_UPON_RESPONSE;\r
+ /* Transaction originated on this instance. Send to the\r
+ * service responder */\r
+ Rm_serviceResponder(rmInst, transaction);\r
}\r
}\r
else\r
{\r
- /* This is a new transaction. Make sure the transaction is not a \r
- * response transaction sent to the wrong RM instance */\r
- if ((transaction->state == Rm_transactionState_RESOURCE_APPROVED) ||\r
- (transaction->state == Rm_transactionState_RESOURCE_DENIED))\r
- {\r
- /* No matching request transaction. This transaction result was sent to the\r
- * wrong RM instance. Flag the error in the receipt and return */\r
- receipt->serviceResult = RM_SERVICE_ERROR_INVALID_TRANSACTION_RECEIVED_ON_CLIENT;\r
- }\r
- else\r
- {\r
- /* All service requests on Clients are forwarded to the higher level RM Client \r
- * Delegate. NameServer requests on Client Delegates are forwarded to the Server. */\r
- Rm_transactionForwarder(rmInst, transaction, receipt);\r
- }\r
+ /* This is a new transaction that must be forwarded to a higher level RM instance. */\r
+ Rm_transactionForwarder(rmInst, transaction);\r
}\r
}\r
else\r
case Rm_service_RESOURCE_ALLOCATE:\r
case Rm_service_RESOURCE_BLOCK_ALLOCATE:\r
case Rm_service_RESOURCE_ALLOCATE_BY_NAME:\r
- /* Run the transaction through the response handler to take care of any\r
- * transactions that are responses to sent allocation requests. */\r
- if (queuedTransaction = Rm_transactionQueueFind(rmInst, transaction->id))\r
+ case Rm_service_RESOURCE_FREE:\r
+ case Rm_service_RESOURCE_BLOCK_FREE:\r
+ case Rm_service_RESOURCE_FREE_BY_NAME: \r
+ /* Check if the transaction is fulfilled request */\r
+ if (transaction->state != RM_SERVICE_PROCESSING)\r
{\r
- if (queuedTransaction->state == Rm_transactionState_AWAITING_RESPONSE)\r
+ /* If source instance name does not match the current instance\r
+ * name the allocation request came from a client. The result\r
+ * must be sent back to the Client */\r
+ if (strcmp(transaction->sourceInstName, rmInst->name))\r
{\r
- /* If source instance name does not match the current instance\r
- * name the allocation request came from a client. The result\r
- * must be sent back to the Client */\r
- if (strcmp(queuedTransaction->sourceInstName, rmInst->name))\r
- {\r
- /* Names don't match. Copy the allocation response resource data \r
- * into the original transaction and send it back to the Client */\r
- queuedTransaction->details = transaction->details;\r
- memcpy ((void *)&(queuedTransaction->resourceInfo), \r
- (void *)&(transaction->resourceInfo), sizeof(Rm_ResourceInfo));\r
- Rm_transactionResponder(rmInst, queuedTransaction, receipt);\r
- /* Delete the response transaction */\r
- Rm_transactionQueueDelete(rmInst, transaction->id);\r
- }\r
- else\r
- {\r
- /* Resource allocation request originated locally on Client Delegate\r
- * instance. Send the response via the service responder. */\r
- Rm_serviceResponder(rmInst, transaction, queuedTransaction,\r
- receipt); \r
- }\r
+ Rm_transactionResponder(rmInst, transaction);\r
}\r
else\r
{\r
- /* Request transaction was not in the awaiting response state. Flag the\r
- * error in the receipt and return */\r
- receipt->serviceResult = RM_SERVICE_ERROR_INVALID_REQUEST_TRANSACTION_STATE_UPON_RESPONSE;\r
- }\r
+ /* Resource allocation request originated locally. Send the response\r
+ * via the service responder. */\r
+ Rm_serviceResponder(rmInst, transaction); \r
+\r
\r
+ /* WHAT IF TRANSACITON CAME FROM CD AND WAS SOLVED IMMEDIATELY. NEED TO RETURN\r
+ * THE TRANSACTION RATHER THAN GO THROUGH THE SERVICERESPONDER */\r
+ }\r
}\r
else\r
{\r
/* This is a new transaction request originating from an RM instance with fewer\r
- * allocate/free privileges. Run the allocation handler to see if the resource\r
+ * allocate/free privileges. Run the allocation or free handler to see if the resource\r
* request can be handled locally or if it needs to be forwarded to a higher level\r
* agent */\r
- Rm_allocationHandler(rmInst, transaction, receipt);\r
- }\r
- break;\r
- case Rm_service_RESOURCE_FREE:\r
- case Rm_service_RESOURCE_BLOCK_FREE:\r
- case Rm_service_RESOURCE_FREE_BY_NAME:\r
- /* Run the transaction through the response handler to take care of any\r
- * transactions that are responses to sent free requests. */\r
- if (queuedTransaction = Rm_transactionQueueFind(rmInst, transaction->id))\r
- {\r
- if (queuedTransaction->state == Rm_transactionState_AWAITING_RESPONSE)\r
+ if ((transaction->type == Rm_service_RESOURCE_ALLOCATE) ||\r
+ (transaction->type == Rm_service_RESOURCE_BLOCK_ALLOCATE) ||\r
+ (transaction->type == Rm_service_RESOURCE_ALLOCATE_BY_NAME))\r
{\r
- /* If source instance name does not match the current instance\r
- * name the allocation request came from a client. The result\r
- * must be sent back to the Client */\r
- if (strcmp(queuedTransaction->sourceInstName, rmInst->name))\r
- {\r
- /* Names don't match. Copy the free response resource data \r
- * into the original transaction and send it back to the Client */\r
- queuedTransaction->details = transaction->details;\r
- memcpy ((void *)&(queuedTransaction->resourceInfo), \r
- (void *)&(transaction->resourceInfo), sizeof(Rm_ResourceInfo));\r
- Rm_transactionResponder(rmInst, queuedTransaction, receipt);\r
- /* Delete the response transaction */\r
- Rm_transactionQueueDelete(rmInst, transaction->id);\r
- }\r
- else\r
- {\r
- /* Resource free request originated locally on Client Delegate\r
- * instance. Send the response via the service responder. */\r
- Rm_serviceResponder(rmInst, transaction, queuedTransaction,\r
- receipt); \r
- }\r
+ Rm_allocationHandler(rmInst, transaction);\r
}\r
else\r
{\r
- /* Request transaction was not in the awaiting response state. Flag the\r
- * error in the receipt and return */\r
- receipt->serviceResult = RM_SERVICE_ERROR_INVALID_REQUEST_TRANSACTION_STATE_UPON_RESPONSE;\r
+ Rm_freeHandler(rmInst, transaction);\r
}\r
-\r
- }\r
- else\r
- {\r
- /* This is a new transaction request originating from an RM instance with fewer\r
- * allocate/free privileges. Run the free handler to see if the resource\r
- * request can be handled locally or if it needs to be forwarded to a higher level\r
- * agent */\r
- Rm_freeHandler(rmInst, transaction, receipt);\r
}\r
-\r
break;\r
case Rm_service_RESOURCE_MAP_TO_NAME:\r
+ case Rm_service_RESOURCE_UNMAP_NAME: \r
/* Server is the only RM instance capable of adding NameServer objects */\r
if (rmInst->instType == Rm_instType_SERVER)\r
{\r
- /* Create a new NameServer object with the request transaction information */\r
- Rm_nsAddObject(rmInst, transaction, receipt);\r
-\r
- /* Return the result of the NameServer addition to the RM instance\r
- * that requested it */\r
- transaction->details = receipt->serviceResult;\r
-\r
- /* If source instance name does not match the current instance\r
- * name the NameServer request came from a Client or Client Delegate. The \r
- * result must be sent back to the Client or Client Delegate */\r
- if (strcmp(transaction->sourceInstName, rmInst->name))\r
+ if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME)\r
{\r
- Rm_transactionResponder(rmInst, queuedTransaction, receipt);\r
+ /* Create a new NameServer object with the request transaction information.\r
+ * Transaction will contain the state result of the NameServer addition. */\r
+ Rm_nsAddObject(rmInst, transaction);\r
}\r
else\r
{\r
- /* NameServer addition request originated locally on Server\r
- * instance. Send the response via the service responder. In this case\r
- * the request transaction will be passed as NULL since the request\r
- * is being reused as the response */\r
- Rm_serviceResponder(rmInst, transaction, NULL, receipt); \r
+ /* Delete an existing NameServer object with the request transaction information\r
+ * Transaction will contain the state result of the NameServer addition. */\r
+ Rm_nsDeleteObject(rmInst, transaction);\r
}\r
- }\r
- else\r
- {\r
- receipt->serviceResult = RM_SERVICE_ERROR_NAMESERVER_OBJECT_CREATE_ON_INVALID_INSTANCE;\r
- }\r
- break;\r
- case Rm_service_RESOURCE_UNMAP_NAME:\r
- /* Server is the only RM instance capable of deleting NameServer objects */\r
- if (rmInst->instType == Rm_instType_SERVER)\r
- {\r
- /* Delete an existing NameServer object with the request transaction information */\r
- Rm_nsDeleteObject(rmInst, transaction, receipt);\r
\r
- /* Return the result of the NameServer deletion to the RM instance\r
- * that requested it */\r
- transaction->details = receipt->serviceResult;\r
-\r
- /* If source instance name does not match the current instance\r
+ /* If source instance name does not match the local instance\r
* name the NameServer request came from a Client or Client Delegate. The \r
- * result must be sent back to the Client or Client Delegate */\r
+ * result must be sent back to the Client or Client Delegate. Just return if it does\r
+ * match since the NameServer transaction result can be returned immediately. */\r
if (strcmp(transaction->sourceInstName, rmInst->name))\r
{\r
- Rm_transactionResponder(rmInst, queuedTransaction, receipt);\r
+ Rm_transactionResponder(rmInst, transaction);\r
}\r
- else\r
- {\r
- /* NameServer delete request originated locally on Server\r
- * instance. Send the response via the service responder. In this case\r
- * the request transaction will be passed as NULL since the request\r
- * is being reused as the response */\r
- Rm_serviceResponder(rmInst, transaction, NULL, receipt); \r
- } \r
}\r
else\r
{\r
- receipt->serviceResult = RM_SERVICE_ERROR_NAMESERVER_OBJECT_DELETE_ON_INVALID_INSTANCE;\r
+ transaction->state = RM_SERVICE_ERROR_NAMESERVER_OBJECT_MOD_ON_INVALID_INSTANCE;\r
}\r
break;\r
}\r
diff --git a/src/rm_nameserver.c b/src/rm_nameserver.c
index 935951323f892ad314d7a1d6e705c102efffc23a..a4ac48618336690bcaa2fd80b076e2c2a6864130 100644 (file)
--- a/src/rm_nameserver.c
+++ b/src/rm_nameserver.c
********************** Internal Functions ****************************
**********************************************************************/
-void Rm_nsAddObject(Rm_Inst *rmInst, Rm_Transaction *transaction,
- Rm_TransactionReceipt *receipt)
+void Rm_nsAddObject(Rm_Inst *rmInst, Rm_Transaction *transaction)
{
/* STUB APPROVED FOR NOW */
- receipt->serviceResult = RM_SERVICE_APPROVED;
+ transaction->state = RM_SERVICE_APPROVED;
}
-void Rm_nsDeleteObject(Rm_Inst *rmInst, Rm_Transaction *transaction,
- Rm_TransactionReceipt *receipt)
+void Rm_nsDeleteObject(Rm_Inst *rmInst, Rm_Transaction *transaction)
{
/* STUB APPROVED FOR NOW */
- receipt->serviceResult = RM_SERVICE_APPROVED;
+ transaction->state = RM_SERVICE_APPROVED;
}
diff --git a/src/rm_services.c b/src/rm_services.c
index edfdd5a8e7b686bf479c44184fa0980dbfbe63f2..b334f096da247041f6155fb26244f41919705fc8 100644 (file)
--- a/src/rm_services.c
+++ b/src/rm_services.c
{
Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
Rm_Transaction *transaction;
- void *key;
-
- /* Prevent another component using the same instance from wiping out the current
- * service request */
- key = Rm_osalCsEnter();
/* Make sure serviceType is valid and that a callback function has been provided */
if ((serviceRequest->type < Rm_service_FIRST) ||
(serviceRequest->type > Rm_service_LAST))
{
serviceResponse->serviceState = RM_SERVICE_ERROR_INVALID_SERVICE_TYPE;
- Rm_osalCsExit(key);
return;
}
else if (serviceRequest->callback.serviceCallback == NULL)
* through the callback function provided by the component. Return an error
* if the component does not provide a callback function. */
serviceResponse->serviceState = RM_SERVICE_ERROR_CALLBACK_NOT_PROVIDED;
- Rm_osalCsExit(key);
return;
}
}
/* Delete the transaction since a response was received immediately */
- Rm_transactionQueueDelete(rmInst, transaction->id);
+ Rm_transactionQueueDelete(rmInst, transaction->localId);
}
else if ((serviceResponse->serviceState >= RM_SERVICE_DENIED_BEGIN) &&
(serviceResponse->serviceState <= RM_SERVICE_DENIED_END))
/* The serviceState field will contain information regarding why the
* service was denied. Just delete the transaction since a response was
* received immediately */
- Rm_transactionQueueDelete(rmInst, transaction->id);
+ Rm_transactionQueueDelete(rmInst, transaction->localId);
}
}
- Rm_osalCsExit(key);
return;
}
diff --git a/src/rm_transport.c b/src/rm_transport.c
index 4a2b5cb243e6d0b8d51977301b59b5576d6d6c7c..c209034c4d17058bd596851e983f8c284cf3dc91 100644 (file)
--- a/src/rm_transport.c
+++ b/src/rm_transport.c
{\r
Rm_TransportNode *routeMap = (Rm_TransportNode *)rmInst->routeMap;\r
Rm_TransportNode *newTransportNode = NULL;\r
- void *key;\r
-\r
- /* Lock access to the RM instance's route map */\r
- key = Rm_osalCsEnter();\r
\r
/* Get memory for a new transport node from local memory */\r
newTransportNode = Rm_osalMalloc (sizeof(Rm_TransportNode), false);\r
rmInst->routeMap = (void *)newTransportNode;\r
}\r
}\r
- \r
- Rm_osalCsExit(key);\r
\r
return (newTransportNode);\r
}\r
@@ -184,15 +178,10 @@ Rm_TransportResult Rm_transportNodeDelete(Rm_Inst *rmInst, Rm_TransportHandle tr
{\r
Rm_TransportNode *transportNode = (Rm_TransportNode *)rmInst->routeMap;\r
Rm_TransportNode *prevNode = NULL;\r
- void *key;\r
-\r
- /* Lock access to the RM instance's route map */\r
- key = Rm_osalCsEnter();\r
\r
/* Make sure there is at least one entry in the transaction queue */\r
if (transportNode == NULL)\r
{\r
- Rm_osalCsExit(key);\r
return (RM_TRANSPORT_ERROR_NO_TRANSPORTS_REGISTERED);\r
}\r
\r
@@ -212,7 +201,6 @@ Rm_TransportResult Rm_transportNodeDelete(Rm_Inst *rmInst, Rm_TransportHandle tr
/* Traversed entire queue but did not find transaction */\r
if (transportNode == NULL)\r
{\r
- Rm_osalCsExit(key);\r
return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED);\r
}\r
else\r
@@ -237,12 +225,11 @@ Rm_TransportResult Rm_transportNodeDelete(Rm_Inst *rmInst, Rm_TransportHandle tr
Rm_osalFree((void *) transportNode, sizeof(Rm_TransportNode), false);\r
}\r
\r
- Rm_osalCsExit(key);\r
return (RM_TRANSPORT_SUCCESSFUL);\r
}\r
\r
Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,\r
- Rm_Transaction *transaction, Rm_TransactionReceipt *receipt)\r
+ Rm_Transaction *transaction)\r
{\r
Rm_Packet *rmPkt = NULL;\r
Rm_ResourceRequestPkt *resourceReqPkt = NULL;\r
@@ -251,7 +238,7 @@ Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *d
if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransportNode, sizeof(Rm_Packet))) ==\r
NULL)\r
{\r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
return (NULL);\r
}\r
\r
@@ -259,7 +246,7 @@ Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *d
* rmPktLen and Rm_PktType fields */\r
if (rmPkt->pktLenBytes < (sizeof(Rm_ResourceRequestPkt) + sizeof(uint32_t) + sizeof(Rm_pktType)))\r
{ \r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
return (NULL);\r
}\r
\r
@@ -269,7 +256,7 @@ Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *d
/* Assign the packet's data field to be the start of the resource request packet */\r
resourceReqPkt = (Rm_ResourceRequestPkt *) rmPkt->data;\r
/* Populate the resource request packet using the transaction information */\r
- resourceReqPkt->requestId = transaction->id;\r
+ resourceReqPkt->requestId = transaction->localId;\r
if (transaction->type == Rm_service_RESOURCE_ALLOCATE)\r
{\r
resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE;\r
@@ -303,7 +290,7 @@ Rm_Packet *Rm_transportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_TransportNode *d
}\r
\r
Rm_Packet *Rm_transportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,\r
- Rm_Transaction *transaction, Rm_TransactionReceipt *receipt)\r
+ Rm_Transaction *transaction)\r
{\r
Rm_Packet *rmPkt = NULL;\r
Rm_ResourceResponsePkt *resourceRespPkt = NULL;\r
@@ -312,7 +299,7 @@ Rm_Packet *Rm_transportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_TransportNo
if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransportNode, sizeof(Rm_Packet))) ==\r
NULL)\r
{\r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
return (NULL);\r
}\r
\r
@@ -320,7 +307,7 @@ Rm_Packet *Rm_transportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_TransportNo
* rmPktLen and Rm_PktType fields */\r
if (rmPkt->pktLenBytes < (sizeof(Rm_ResourceResponsePkt) + sizeof(uint32_t) + sizeof(Rm_pktType)))\r
{ \r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
return (NULL);\r
}\r
\r
@@ -329,9 +316,11 @@ Rm_Packet *Rm_transportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_TransportNo
\r
/* Assign the packet's data field to be the start of the resource response packet */\r
resourceRespPkt = (Rm_ResourceResponsePkt *)rmPkt->data;\r
- /* Populate the resource response packet using the transaction information */\r
- resourceRespPkt->responseId = transaction->id;\r
- resourceRespPkt->requestResult = transaction->details;\r
+ /* Populate the resource response packet using the transaction information. The\r
+ * responseId is the remoteOriginatingId. The responseId must match the local ID \r
+ * of the transaction that originated the request */\r
+ resourceRespPkt->responseId = transaction->remoteOriginatingId;\r
+ resourceRespPkt->requestState = transaction->state;\r
/* Copy the resource data */\r
memcpy ((void *)&(resourceRespPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
sizeof(Rm_ResourceInfo));\r
@@ -340,7 +329,7 @@ Rm_Packet *Rm_transportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_TransportNo
}\r
\r
Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,\r
- Rm_Transaction *transaction, Rm_TransactionReceipt *receipt)\r
+ Rm_Transaction *transaction)\r
{\r
Rm_Packet *rmPkt = NULL;\r
Rm_NsRequestPkt *nsReqPkt = NULL;\r
@@ -349,7 +338,7 @@ Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dst
if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransportNode, sizeof(Rm_Packet))) ==\r
NULL)\r
{\r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
return (NULL);\r
}\r
\r
@@ -357,7 +346,7 @@ Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dst
* rmPktLen and Rm_PktType fields */\r
if (rmPkt->pktLenBytes < (sizeof(Rm_NsRequestPkt) + sizeof(uint32_t) + sizeof(Rm_pktType)))\r
{ \r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
return (NULL);\r
}\r
\r
@@ -367,7 +356,7 @@ Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dst
/* Assign the packet's data field to be the start of the NameServer request packet */\r
nsReqPkt = (Rm_NsRequestPkt *)rmPkt->data;\r
/* Populate the NameServer request packet using the transaction information */\r
- nsReqPkt->requestId = transaction->id;\r
+ nsReqPkt->requestId = transaction->localId;\r
if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME)\r
{\r
nsReqPkt->nsRequestType = Rm_nsReqPktType_MAP_RESOURCE;\r
@@ -385,7 +374,7 @@ Rm_Packet *Rm_transportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_TransportNode *dst
}\r
\r
Rm_Packet *Rm_transportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *dstTransportNode,\r
- Rm_Transaction *transaction, Rm_TransactionReceipt *receipt)\r
+ Rm_Transaction *transaction)\r
{\r
Rm_Packet *rmPkt = NULL;\r
Rm_NsResponsePkt *nsRespPkt = NULL;\r
@@ -394,7 +383,7 @@ Rm_Packet *Rm_transportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *ds
if ((rmPkt = rmInst->transport.rmAllocPkt((Rm_TransportHandle)dstTransportNode, sizeof(Rm_Packet))) ==\r
NULL)\r
{\r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
return (NULL);\r
}\r
\r
@@ -402,7 +391,7 @@ Rm_Packet *Rm_transportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *ds
* rmPktLen and Rm_PktType fields */\r
if (rmPkt->pktLenBytes < (sizeof(Rm_NsResponsePkt) + sizeof(uint32_t) + sizeof(Rm_pktType)))\r
{ \r
- receipt->serviceResult = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
+ transaction->state = RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL;\r
return (NULL);\r
}\r
\r
@@ -411,9 +400,11 @@ Rm_Packet *Rm_transportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_TransportNode *ds
\r
/* Assign the packet's data field to be the start of the NameServer response packet */\r
nsRespPkt = (Rm_NsResponsePkt *)rmPkt->data;\r
- /* Populate the NameServer response packet using the transaction information */\r
- nsRespPkt->responseId = transaction->id;\r
- nsRespPkt->requestResult = transaction->details;\r
+ /* Populate the NameServer response packet using the transaction information. The\r
+ * responseId is the remoteOriginatingId. The responseId must match the local ID \r
+ * of the transaction that originated the request */\r
+ nsRespPkt->responseId = transaction->remoteOriginatingId;\r
+ nsRespPkt->requestState = transaction->state;\r
\r
return (rmPkt);\r
}\r
@@ -429,7 +420,7 @@ Rm_TransportHandle Rm_transportRegister (Rm_Handle rmHandle, Rm_TransportCfg *tr
void *key;\r
\r
/* Lock access to the RM instance */\r
- key = Rm_osalCsEnter();\r
+ key = Rm_osalMtCsEnter();\r
\r
/* RM Servers cannot connect to other Servers. RM Client Delegates cannot\r
* connect to other Client Delegates. */\r
@@ -438,21 +429,18 @@ Rm_TransportHandle Rm_transportRegister (Rm_Handle rmHandle, Rm_TransportCfg *tr
((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
(transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)))\r
{\r
- Rm_osalCsExit(key);\r
- return (NULL); /* Error - return null */\r
+ goto exitCs; /* Error - return null */\r
}\r
\r
- /* Verify Clients and Client Delegates are not registering with more than one \r
- * Client Delegate or Server. Assuming a Client Delegate can register with another \r
- * Client Delegate that can "act" as a server */\r
- if (((rmInst->instType == Rm_instType_CLIENT) &&\r
- (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)) || \r
- ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
- (transportCfg->remoteInstType == Rm_instType_SERVER)) &&\r
- rmInst->registeredWithDelegateOrServer)\r
+ /* Verify Clients are not registering with more than one Client Delegate or Server. And\r
+ * that Client Delegate are not registering with more than one Server. */\r
+ if (rmInst->registeredWithDelegateOrServer &&\r
+ (((rmInst->instType == Rm_instType_CLIENT) &&\r
+ (transportCfg->remoteInstType == Rm_instType_CLIENT_DELEGATE)) || \r
+ ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
+ (transportCfg->remoteInstType == Rm_instType_SERVER))))\r
{\r
- Rm_osalCsExit(key);\r
- return (NULL); /* Error - return null */\r
+ goto exitCs; /* Error - return null */\r
} \r
\r
/* Copy the transport callout function pointers into the RM instance as long as they're\r
@@ -466,8 +454,7 @@ Rm_TransportHandle Rm_transportRegister (Rm_Handle rmHandle, Rm_TransportCfg *tr
(transportCfg->transportCallouts.rmReceive == NULL) ||\r
(transportCfg->transportCallouts.rmNumPktsReceived == NULL))\r
{\r
- Rm_osalCsExit(key);\r
- return (NULL); /* Error - return null */\r
+ goto exitCs; /* Error - return null */\r
}\r
\r
/* Populate the instance transport callouts */\r
@@ -489,7 +476,9 @@ Rm_TransportHandle Rm_transportRegister (Rm_Handle rmHandle, Rm_TransportCfg *tr
rmInst->registeredWithDelegateOrServer = true;\r
}\r
\r
- Rm_osalCsExit(key);\r
+exitCs:\r
+ \r
+ Rm_osalMtCsExit(key);\r
return ((Rm_TransportHandle) transportNode);\r
}\r
\r
@@ -501,7 +490,7 @@ Rm_TransportResult Rm_transportUnregister (Rm_Handle rmHandle, Rm_TransportHandl
void *key;\r
\r
/* Lock access to the RM instance */\r
- key = Rm_osalCsEnter(); \r
+ key = Rm_osalMtCsEnter(); \r
\r
/* Check if the transportHandle exists in the RM instance's route map */\r
transportNode = Rm_transportNodeFindTransportHandle(rmInst, transportHandle);\r
@@ -509,23 +498,24 @@ Rm_TransportResult Rm_transportUnregister (Rm_Handle rmHandle, Rm_TransportHandl
if (transportNode == NULL)\r
{\r
/* Error - transport node does not exist in RM instance route map */\r
- Rm_osalCsExit(key);\r
- return (RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED);\r
+ retVal = RM_TRANSPORT_ERROR_HANDLE_HAS_NOT_BEEN_REGISTERED;\r
}\r
-\r
- /* Remove specification that RM instance has been connected to an upper level agent\r
- * if the node to be deleted has a remote instance type of Client Delegate or Server */\r
- if ((transportNode->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
- (transportNode->remoteInstType == Rm_instType_SERVER))\r
+ else\r
{\r
- rmInst->registeredWithDelegateOrServer = false;\r
- }\r
\r
- /* Delete the transport node */\r
- retVal = Rm_transportNodeDelete(rmInst, transportHandle);\r
+ /* Remove specification that RM instance has been connected to an upper level agent\r
+ * if the node to be deleted has a remote instance type of Client Delegate or Server */\r
+ if ((transportNode->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
+ (transportNode->remoteInstType == Rm_instType_SERVER))\r
+ {\r
+ rmInst->registeredWithDelegateOrServer = false;\r
+ }\r
\r
- Rm_osalCsExit(key);\r
+ /* Delete the transport node */\r
+ retVal = Rm_transportNodeDelete(rmInst, transportHandle);\r
+ }\r
\r
+ Rm_osalMtCsExit(key);\r
return (retVal);\r
}\r
\r
Rm_ResourceResponsePkt *resourceRespPkt = (Rm_ResourceResponsePkt *)pkt->data;\r
\r
/* Find the transaction that is awaiting the response */\r
- transaction = Rm_transactionQueueFind(rmInst,resourceRespPkt->responseId);\r
- /* Transfer the result of the request to the transaction */\r
- transaction->state = resourceRespPkt->requestState;\r
-\r
- if ((transaction->state == RM_SERVICE_APPROVED) &&\r
- ((transaction->type == Rm_service_RESOURCE_ALLOCATE) ||\r
- (transaction->type == Rm_service_RESOURCE_BLOCK_ALLOCATE) ||\r
- (transaction->type == Rm_service_RESOURCE_ALLOCATE_BY_NAME)))\r
+ if (transaction = Rm_transactionQueueFind(rmInst,resourceRespPkt->responseId))\r
{\r
- /* Copy resources from request for allocations since an allocation\r
- * can be specified as unknown. Meaning the RM instance will specify the\r
- * resource value obtained */\r
- memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceRespPkt->resourceInfo),\r
- sizeof(Rm_ResourceInfo));\r
+ /* Transfer the result of the request to the transaction */\r
+ transaction->state = resourceRespPkt->requestState;\r
+\r
+ if ((transaction->state == RM_SERVICE_APPROVED) &&\r
+ ((transaction->type == Rm_service_RESOURCE_ALLOCATE) ||\r
+ (transaction->type == Rm_service_RESOURCE_BLOCK_ALLOCATE) ||\r
+ (transaction->type == Rm_service_RESOURCE_ALLOCATE_BY_NAME)))\r
+ {\r
+ /* Copy resources from request for allocations since an allocation\r
+ * can be specified as unknown. If the request resources were unspecified\r
+ * the RM instance will specify the resources obtained */\r
+ memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceRespPkt->resourceInfo),\r
+ sizeof(Rm_ResourceInfo));\r
+ }\r
+ \r
+ /* Process the transaction */\r
+ Rm_transactionProcessor(rmInst, transaction);\r
+ }\r
+ else\r
+ {\r
+ rmInst->transport.rmFreePkt(transportHandle, pkt);\r
+ return (RM_TRANSPORT_ERROR_MATCHING_RESOURCE_REQUEST_NOT_FOUND);\r
}\r
- \r
- /* Process the transaction */\r
- Rm_transactionProcessor(rmInst, transaction);\r
break;\r
}\r
case Rm_pktType_NAMESERVER_REQUEST:\r
Rm_NsResponsePkt *nsResponsePkt = (Rm_NsResponsePkt *)pkt->data;\r
\r
/* Find the transaction that is awaiting the response */\r
- transaction = Rm_transactionQueueFind(rmInst, nsResponsePkt->responseId);\r
- /* Transfer the state of the request to the transaction */\r
- transaction->state = nsResponsePkt->requestState; \r
+ if (transaction = Rm_transactionQueueFind(rmInst, nsResponsePkt->responseId))\r
+ {\r
+ /* Transfer the state of the request to the transaction */\r
+ transaction->state = nsResponsePkt->requestState; \r
\r
- /* Process the transaction */\r
- Rm_transactionProcessor(rmInst, transaction);\r
+ /* Process the transaction */\r
+ Rm_transactionProcessor(rmInst, transaction);\r
+ }\r
+ else\r
+ {\r
+ rmInst->transport.rmFreePkt(transportHandle, pkt);\r
+ return (RM_TRANSPORT_ERROR_MATCHING_NAME_SERVER_REQUEST_NOT_FOUND);\r
+ }\r
break;\r
}\r
case Rm_pktType_POLICY_REQUEST:\r
diff --git a/test/rm_osal.c b/test/rm_osal.c
index a67d0d441c5aa5a2def26034ef61357db092dc4a..e8c1856fd349a3cfe705ccd3f4636b292a74d332 100644 (file)
--- a/test/rm_osal.c
+++ b/test/rm_osal.c
uint32_t rmMallocCounter = 0;
uint32_t rmFreeCounter = 0;
+uint32_t rmMtSem = 0;
+
/**********************************************************************
*************************** OSAL Functions **************************
**********************************************************************/
/* Create Semaphore for protection against access from multiple threads
* Not created here becasue application is not multithreaded
* */
- return NULL;
+
+ /* Block while semaphore is taken */
+ while (rmMtSem){};
+
+ /* Take the semaphore if it's available */
+ rmMtSem = 1;
+
+ return ((void *)&rmMtSem);
}
/**
*/
void Osal_rmMtCsExit (void *CsHandle)
{
+ uint32_t *mtSem = (uint32_t *)CsHandle;
+
/* Release Semaphore using handle */
+ *mtSem = 0;
return;
}
diff --git a/test/rm_test.c b/test/rm_test.c
index a57dbfc06f3344a6033382686fb746e5a285149a..ceb440db3115ef7f6be9c9c8f3dbdf34f665291f 100644 (file)
--- a/test/rm_test.c
+++ b/test/rm_test.c
/* TEMP: Try mapping a resource in Name Server */
requestInfo.type = Rm_service_RESOURCE_MAP_TO_NAME;
requestInfo.resourceName = &resourceName[0];
- requestInfo.resourceBase = 0;
- requestInfo.resourceRange = 1;
+ requestInfo.resourceBase = 1;
+ requestInfo.resourceRange = 2;
requestInfo.resourceNsName = &resourceNsName[0];
requestInfo.callback.serviceCallback = testServiceCallback;
diff --git a/test/rm_test.cfg b/test/rm_test.cfg
index 13ad0bb15da92111fb1bdd712980bc77c83d6c5c..0af281fbf9a2cf185c061c87932596e135e0ae21 100644 (file)
--- a/test/rm_test.cfg
+++ b/test/rm_test.cfg
* Get the list of names that the build device supports.
* I.e. ["CORE0", "CORE1", "CORE2" ... ]
*/
-var nameList = MultiProc.getDeviceProcNames();
+// var nameList = MultiProc.getDeviceProcNames();
+var nameList = ["CORE0", "CORE1"];
/*
* Since this is a single-image example, we don't (at build-time) which