/* * WfaStaWaitStop(): This function sends the stop packet on behalf of the * station, the idea is to keep sending the Stop * till a stop is recd from the console,the functions * quits after stop threshold reaches. */ int WfaStaWaitStop(char psave,int sleep_period,int *state) { int myid=wmmps_info.ps_thread; PRINTF("\n Entering Sendwait"); wUSLEEP(sleep_period); if(!num_stops) { wfaSetDUTPwrMgmt(psave); wfaTGSetPrio(psSockfd, TG_WMM_AC_BE); } num_stops++; create_apts_msg(APTS_STOP, psTxMsg,wmmps_info.my_sta_id); wSENDTO(psSockfd, psTxMsg, msgsize, 0, (struct sockaddr *)&wmmps_info.psToAddr, sizeof(struct sockaddr)); mpx("STA msg",psTxMsg,64); wmm_thr[myid].stop_flag = 1; wPT_MUTEX_LOCK(&wmm_thr[myid].thr_stop_mutex); wPT_COND_SIGNAL(&wmm_thr[myid].thr_stop_cond); wPT_MUTEX_UNLOCK(&wmm_thr[myid].thr_stop_mutex); if(num_stops > MAX_STOPS) { DPRINT_ERR(WFA_ERR, "Too many stops sent\n"); gtgWmmPS = 0; if(psSockfd != -1) { wCLOSE(psSockfd); psSockfd = -1; } wSIGNAL(SIGALRM, SIG_IGN); } return 0; }
/* * sender(): This is a generic function to send a packed for the given dsc * (ac:VI/VO/BE/BK), before sending the packet the function * puts the station into the PS mode indicated by psave and * sends the packet after sleeping for sllep_period */ int sender(char psave,int sleep_period, int userPriority) { int r; PRINTF("\nsender::sleeping for %d userPriority=%d psSockFd=%d",sleep_period, userPriority, psSockfd); wfaSetDUTPwrMgmt(psave); wUSLEEP(sleep_period); create_apts_msg(APTS_DEFAULT, psTxMsg,wmmps_info.my_sta_id); wfaTGSetPrio(psSockfd, userPriority); r = wSENDTO(psSockfd, psTxMsg, msgsize, 0, (struct sockaddr *)&wmmps_info.psToAddr, sizeof(struct sockaddr)); return r; }
/* * wfaStaSndConfirm(): This function sends the confirm packet * which is sent after the console sends the * test name to the station */ int WfaStaSndConfirm(char psave,int sleep_period,int *state) { static int num_hello=0; wfaSetDUTPwrMgmt(psave); if(!num_hello) create_apts_msg(APTS_CONFIRM, psTxMsg,0); wSENDTO(psSockfd, psTxMsg, msgsize, 0, (struct sockaddr *)&wmmps_info.psToAddr, sizeof(struct sockaddr)); mpx("STA msg",psTxMsg,64); printf("Confirm Sent\n"); (*state)++; return 0; }
/* * wfaStaSndHello(): This function sends a Hello packet * and sleeps for sleep_period, the idea is * to keep sending hello packets till the console * responds, the function keeps a check on the MAX * Hellos and if number of Hellos exceed that it quits */ int WfaStaSndHello(char psave,int sleep_period,int *state) { tgWMM_t *my_wmm = &wmm_thr[wmmps_info.ps_thread]; usleep(sleep_period); wfaSetDUTPwrMgmt(psave); if(!(num_hello++)) create_apts_msg(APTS_HELLO, psTxMsg,0); wfaTGSetPrio(psSockfd, 0); wSENDTO(psSockfd, psTxMsg, msgsize, 0, (struct sockaddr *)&wmmps_info.psToAddr, sizeof(struct sockaddr)); wPT_MUTEX_LOCK(&my_wmm->thr_flag_mutex); if(my_wmm->thr_flag) { (*state)++; num_hello=0; my_wmm->thr_flag=0; } wPT_MUTEX_UNLOCK(&my_wmm->thr_flag_mutex); if(num_hello > MAXHELLO) { DPRINT_ERR(WFA_ERR, "Too many Hellos sent\n"); gtgWmmPS = 0; num_hello=0; if(psSockfd != -1) { wCLOSE(psSockfd); psSockfd = -1; } wSIGNAL(SIGALRM, SIG_IGN); } return 0; }
void wmmps_wait_state_proc() { int ttypes[4], i, rbytes; for(i = 0; i<4; i++) { ttypes[i] = 0xFF; } switch(wmmps_info.wait_state) { case WFA_WAIT_NEXT_CODEC: ttypes[0] = -1; wmmps_info.wait_state = WFA_WAIT_NEXT_CODEC; break; case WFA_WAIT_FOR_AP_RESPONSE: wmmps_info.wait_state = WFA_WAIT_NEXT_CODEC; break; case WFA_WAIT_STAUT_00: rbytes = sendto(psSockfd, psTxMsg, 200+(wmmps_info.msgno%200), MSG_DONTWAIT,(struct sockaddr *) &wmmps_info.psToAddr, sizeof(wmmps_info.psToAddr)); wmmps_info.nextsleep = 1000000; /* one second */ break; case WFA_WAIT_STAUT_02: ttypes[0] = TOS_VO; wmmps_info.nextsleep = 1000000; // 1 sec return; break; case WFA_WAIT_STAUT_04: ttypes[0] = TOS_BE; ttypes[1] = TOS_VO; break; case WFA_WAIT_STAUT_0E: ttypes[0] = TOS_VO; ttypes[1] = TOS_VO; break; case WFA_WAIT_STAUT_VOLOAD: ttypes[0] = TOS_VO; break; case WFA_WAIT_STAUT_SEQ: if( wmmps_info.nsent < 0 || wmmps_info.nsent > sizeof(ac_seq[wmmps_info.sta_test]) ) wmmps_info.nsent = 0; if(( wmmps_info.sta_test == A_Y && wmmps_info.nsent == 3) || (wmmps_info.sta_test == A_U && wmmps_info.nsent == 1) || (wmmps_info.sta_test == A_U && wmmps_info.nsent == 3) || (wmmps_info.sta_test == A_U && wmmps_info.nsent == 5)) { wfaSetDUTPwrMgmt(PS_OFF); wmmps_info.nextsleep = 100000; // 100 ms } if((wmmps_info.sta_test == A_Y && wmmps_info.nsent == 4) || (wmmps_info.sta_test == A_U && wmmps_info.nsent == 2) || (wmmps_info.sta_test == A_U && wmmps_info.nsent == 4)) { wfaSetDUTPwrMgmt(PS_ON); wmmps_info.nextsleep = 100000; // 100 ms } ttypes[0] = ac_seq[wmmps_info.sta_test][wmmps_info.nsent]; printf("ttypes 0x%x\n", ttypes[0]); // do we need sample time for one sec? wmmps_info.nextsleep = 1000000; break; default: printf("unknow wait state\n"); } i=0; while(ttypes[i] != 0xFF) send_txmsg(ttypes[i++]); }
int wfaWmmPowerSaveProcess(int sockfd) { int rbytes = 0; int msg; struct sockaddr from; int len; rbytes = recvfrom(sockfd, (char *)psRxMsg, MAX_UDP_LEN, 0, &from, (socklen_t *)&len); if(rbytes < 0) { //perror("receive error"); printf("resceive error"); return rbytes; } if(wmmps_info.sta_state == 0) { #ifndef WIN32 signal(SIGALRM, SIG_IGN); #else #endif wmmps_info.sta_test = psRxMsg[10]; if(wmmps_info.sta_test == APTS_STOP) { gtgWmmPS = 0; asd_closeSocket(psSockfd); psSockfd = -1; #ifndef WIN32 signal(SIGALRM, SIG_IGN); #endif wfaSetDUTPwrMgmt(PS_OFF); } wmmps_info.wait_state = WFA_WAIT_STAUT_02; wmmps_info.nextsleep = 1000000; // 1 sec switch(wmmps_info.sta_test) { case APTS_HELLO_RESP: break; case L_1: wmmps_info.my_sta_id = psRxMsg[9]; apts_msgs[APTS_CONFIRM].param3 = wmmps_info.my_sta_id; break; case B_D: break; case M_D: break; case B_H: break; case B_B: break; case M_B: break; case B_K: break; case M_L: break; case M_G: break; case M_I: break; case B_Z: break; case M_Y: break; case M_V: break; case M_U: break; case A_U: break; case A_Y: break; case B_W: break; case M_W: break; case A_J: break; case B_M: break; default: printf("unknow\n"); return TRUE; } BUILD_APTS_MSG(APTS_CONFIRM, psTxMsg); rbytes = wfaTrafficSendTo(psSockfd, (char *)psTxMsg, sizeof(psTxMsg), (struct sockaddr *) &wmmps_info.psToAddr); wmmps_info.sta_state = 2; } wfaSetDUTPwrMgmt(PS_ON); if(wmmps_info.sta_test != B_M) { BUILD_APTS_MSG(APTS_CK_VO, psTxMsg); send_txmsg(TG_WMM_AC_VO); usleep(100000); BUILD_APTS_MSG(APTS_CK_VI, psTxMsg); send_txmsg(TG_WMM_AC_VI); usleep(100000); BUILD_APTS_MSG(APTS_CK_BE, psTxMsg); send_txmsg(TG_WMM_AC_BE); usleep(100000); BUILD_APTS_MSG(APTS_CK_BK, psTxMsg); send_txmsg(TG_WMM_AC_BK); } else // B_M test { asd_sleep(30); BUILD_APTS_MSG(APTS_CK_VI, psTxMsg); send_txmsg(TG_WMM_AC_VI); asd_sleep(1); // retrieve the STOP command and clean up BUILD_APTS_MSG(APTS_CK_BE, psTxMsg); send_txmsg(TG_WMM_AC_BE); return TRUE; } if(wmmps_info.sta_state == 2 ) { asd_sleep(1); msg = APTS_DEFAULT; wmmps_info.wait_state = WFA_WAIT_STAUT_02; wmmps_info.nextsleep = 1000000; // 1 sec switch(wmmps_info.sta_test) { case L_1: wmmps_info.nextsleep = 20000; msg = ULOAD; wmmps_info.wait_state = WFA_WAIT_STAUT_VOLOAD; case B_D: case M_D: case B_B: case B_K: case M_B: case M_K: case B_H: case B_W: case M_W: case M_L: case M_G: case M_I: case B_Z: case M_Y: case M_V: case M_U: case A_U: case A_Y: case A_J: if(wmmps_info.sta_test == B_E) wmmps_info.wait_state = WFA_WAIT_STAUT_0E; if(wmmps_info.sta_test == B_G) wmmps_info.wait_state = WFA_WAIT_STAUT_0E; if(wmmps_info.sta_test == M_G) wmmps_info.wait_state = WFA_WAIT_STAUT_0E; if(wmmps_info.sta_test == M_I) wmmps_info.wait_state = WFA_WAIT_STAUT_0E; if(wmmps_info.sta_test == B_B) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; if(wmmps_info.sta_test == B_K) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; if(wmmps_info.sta_test == M_B) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; if(wmmps_info.sta_test == M_K) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; if(wmmps_info.sta_test == M_U) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; if(wmmps_info.sta_test == M_V) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; if(wmmps_info.sta_test == M_W) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; if(wmmps_info.sta_test == M_Y) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; if(wmmps_info.sta_test == A_U) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; if(wmmps_info.sta_test == A_Y) wmmps_info.wait_state = WFA_WAIT_STAUT_SEQ; BUILD_APTS_MSG(msg, psTxMsg); gtgPsPktRecvd = 0; wmmps_info.nsent = 0; if(wmmps_info.sta_test == A_J) { wmmps_info.nextsleep = 5*1000000; } if(wmmps_info.sta_test == M_W) { wmmps_info.nextsleep = 500000; } wmmps_wait_state_proc(); if(wmmps_info.sta_test == A_J) { asd_sleep(1); wfaSetDUTPwrMgmt(PS_OFF); wmmps_wait_state_proc(); } wmmps_info.sta_state = 3; } } if(wmmps_info.sta_state == 3) { gtgPsPktRecvd++; wmmps_info.my_cookie = psRxMsg[0]; if(psRxMsg[10] == APTS_STOP) { gtgWmmPS = 0; asd_closeSocket(psSockfd); psSockfd = -1; #ifndef WIN32 signal(SIGALRM, SIG_IGN); #endif wfaSetDUTPwrMgmt(PS_OFF); } } return TRUE; }
/* * tgRecvStop: instruct traffic generator to stop receiving based on a profile * input: cmd -- not used * response: inform controller for "complete" * return: success or failed */ int wfaTGRecvStop(int len, BYTE *parms, int *respLen, BYTE *respBuf) { int status = STATUS_COMPLETE, i; int numStreams = len/4; unsigned int streamid; tgProfile_t *theProfile; tgStream_t *myStream=NULL; dutCmdResponse_t statResp; BYTE dutRspBuf[WFA_RESP_BUF_SZ]; int id_cnt = 0; DPRINT_INFO(WFA_OUT, "entering tgRecvStop with length %d\n",len); /* in case that send-stream not done yet, an optional delay */ while(sendThrId != 0) sleep(1); /* * After finishing the receiving command, it should lower itself back to * normal level. It is optional implementation if it is not called * while it starts receiving for raising priority level. */ //wfaSetProcPriority(30); wMEMSET(dutRspBuf, 0, WFA_RESP_BUF_SZ); for(i=0; i<numStreams; i++) { wMEMCPY(&streamid, parms+(4*i), 4); printf(" stop stream id %i\n", streamid); myStream = findStreamProfile(streamid); if(myStream == NULL) { status = STATUS_INVALID; wfaEncodeTLV(WFA_TRAFFIC_AGENT_RECV_STOP_RESP_TLV, 4, (BYTE *)&status, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; printf("stream table empty\n"); continue; } theProfile = &myStream->profile; if(theProfile == NULL) { status = STATUS_INVALID; wfaEncodeTLV(WFA_TRAFFIC_AGENT_RECV_STOP_RESP_TLV, 4, (BYTE *)&status, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return TRUE; } if(theProfile->direction != DIRECT_RECV) { status = STATUS_INVALID; wfaEncodeTLV(WFA_TRAFFIC_AGENT_RECV_STOP_RESP_TLV, 4, (BYTE *)&status, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return TRUE; } /* reset its flags , close sockets */ switch(theProfile->profile) { case PROF_TRANSC: case PROF_CALI_RTD: gtgTransac = 0; case PROF_MCAST: case PROF_FILE_TX: case PROF_IPTV: gtgRecv = 0; if(tgSockfds[myStream->tblidx] != -1) { wCLOSE(tgSockfds[myStream->tblidx]); tgSockfds[myStream->tblidx] = -1; } break; case PROF_UAPSD: #ifdef WFA_WMM_PS_EXT gtgWmmPS = 0; gtgPsPktRecvd = 0; if(psSockfd != -1) { wCLOSE(psSockfd); psSockfd = -1; } wMEMSET(&wmmps_info, 0, sizeof(wfaWmmPS_t)); wfaSetDUTPwrMgmt(PS_OFF); #endif /* WFA_WMM_PS_EXT */ break; } /* encode a TLV for response for "complete/error ..." */ statResp.status = STATUS_COMPLETE; statResp.streamId = streamid; #if 1 DPRINT_INFO(WFA_OUT, "stream Id %u rx %u total %llu\n", streamid, myStream->stats.rxFrames, myStream->stats.rxPayloadBytes); #endif wMEMCPY(&statResp.cmdru.stats, &myStream->stats, sizeof(tgStats_t)); wMEMCPY((dutRspBuf + i * sizeof(dutCmdResponse_t)), (BYTE *)&statResp, sizeof(dutCmdResponse_t)); id_cnt++; // Not empty it but require to reset the entire table before test starts. //wMEMSET(myStream, 0, sizeof(tgStream_t)); } // mark the stream inactive myStream->state = WFA_STREAM_INACTIVE; printf("Sending back the statistics at recvstop\n"); wfaEncodeTLV(WFA_TRAFFIC_AGENT_RECV_STOP_RESP_TLV, id_cnt * sizeof(dutCmdResponse_t), dutRspBuf, respBuf); /* done here */ *respLen = WFA_TLV_HDR_LEN + numStreams * sizeof(dutCmdResponse_t); return TRUE; }