-#if 0
-/**
- *******************************************************************************
- *
- * @fn app_ScatterGatherTransmitter
- * @brief transmitter of default test case (15/16).
- *
- * @param[h] hWls - app thread WLS handle
- * @return void
- *
- * @description
- * The routine is used in test case 0 (non-blocking sanity unit test)
- * The transmitter does allocate multiple blocks of the same size from the ICC
- * service. Then it fills each block with incremental counter and transfers
- * to other application specified by parameter TxID.
- *
- * @references
- * MS-111070-SP
- *
- * @ingroup icc_service_unit_test
- *
- ******************************************************************************/
-static void app_ScatterGatherTransmitter(HANDLE hWls)
-{
- U8 *pMsg;
- unsigned n = app_AllocMultiple(hWls, AppContext.TxMessages, AppContext.TxMessageSizes, AppContext.MsgPerMs + 2);
- unsigned i, cnt = 0, flags = 0;
- U8 *p, *pOriginMsg = (U8 *)App_Alloc(hWls, AppContext.MaxMsgSize);
- unsigned TotalSize = 0;
-
- unsigned fn = n;
- unsigned k = 0;
- unsigned alloc = n;
-
- if (!pOriginMsg) {
- printf("No memory for App_Alloc()\n");
- return;
- }
-
- flags = rand() & 0xff;
-
- for(i = 0; i < AppContext.MaxMsgSize; i++)
- pOriginMsg[i] = (flags + i) & 0xff;
-
- // scatter original message among several blocks
- for(i = 0; i < n; i++)
- {
- U32 size = (rand() % (AppContext.MaxMsgSize / n));
-
- if (size < AppContext.MinMsgSize)
- size = AppContext.MinMsgSize;
-
- TotalSize += size;
- AppContext.TxMessageSizes[i] = size;
- //printf("size%d=%lu\n", i, size);
- }
-
- // adjust size of the last block
- if (TotalSize < AppContext.MaxMsgSize)
- {
- AppContext.TxMessageSizes[n - 1] += AppContext.MaxMsgSize - TotalSize;
- }
- else if (TotalSize > AppContext.MaxMsgSize)
- {
- printf("error: size of the scatted blocks exceeding size of the original message\n");
- }
-
- p = pOriginMsg;
- for(i = 0; i < n; i++)
- {
- // copy data into the scattered blocks
- pMsg = AppContext.TxMessages[i];
- memcpy(pMsg, p, AppContext.TxMessageSizes[i]);
- p += AppContext.TxMessageSizes[i];
- }
-
- // transmit original message first
- if (AppContext.wls_put(hWls, (U64)WlsVaToPa(pOriginMsg), AppContext.MaxMsgSize, AppContext.TxID, 0) != 0)
- {
- printf("could not send the message_%p\n", pOriginMsg);
- if (App_Free(hWls, pOriginMsg) != 0)
- printf("could not release the message_%p\n", pOriginMsg);
- }
- else
- {
- AppContext.nTxOctets += AppContext.MaxMsgSize;
- AppContext.nTxMsgs += 1;
- }
-
- if(pOriginMsg){
- if (App_Free(hWls, pOriginMsg) != 0)
- printf("could not release the message_%p\n", pMsg);
- }
- else
- printf("pOriginMsg is NULL \n");
-
- // transmit scattered messages following their creation order
- while (n--)
- {
- pMsg = AppContext.TxMessages[cnt];
- if (!cnt)
- flags = WLS_SG_FIRST;
- else if (n == 0)
- flags = WLS_SG_LAST;
- else
- flags = WLS_SG_NEXT;
-
- if (AppContext.wls_put(hWls, (U64)WlsVaToPa(pMsg), AppContext.TxMessageSizes[cnt], AppContext.TxID, flags) != 0)
- {
- printf("could not send the message_%p\n", pMsg);
- if (App_Free(hWls, pMsg) != 0)
- printf("could not release the message_%p\n", pMsg);
- }
- else
- k++;
-
- AppContext.nTxOctets += AppContext.TxMessageSizes[cnt];
- AppContext.nTxMsgs += 1;
- cnt++;
- }
- if(alloc != k)
- printf("inorrect sent %d alloc %d \n", k, alloc);
-
- cnt = 0;
- while (fn--)
- {
- pMsg = AppContext.TxMessages[cnt++];
- if(pMsg){
- if (App_Free(hWls, pMsg) != 0)
- printf("could not release the message_%p\n", pMsg);
- }
- else
- printf("pMsg is NULL [%d]\n", cnt);
- }
- if(cnt != k)
- printf("inorrect free sent %d free %d \n", k, cnt);
-}
-#endif