int command_main(int argc, char * argv[]) { unsigned int size; char * str; send_use(SERIAL_DEFAULT_DEVICE); while(True) { send_write("command> "); kz_recv(MSGBOX_ID_CONSINPUT, &size, &str); str[size] = '\0'; if( strncmp((cString)str, "echo ", 5) == Same ) { send_write((str + 5)); send_write("\n"); } else { send_write("unkown\n"); } kz_kmfree(str); } return EXIT_SUCCESS; }
int command_main(int argc, char *argv[]) { char *p; int size; send_use(SERIAL_DEFAULT_DEVICE); while (1) { send_write("command> "); /* プロンプト表示 */ /* コンソールからの受信文字列を受け取る */ kz_recv(MSGBOX_ID_CONSINPUT, &size, &p); p[size] = '\0'; if (!strncmp(p, "echo", 4)) { /* echoコマンド */ send_write(p + 4); /* echoに続く文字列を出力する */ send_write("\n"); } else { send_write("unknown.\n"); } kz_kmfree(p); } return 0; }
int command_main(int argc, char *argv[]) { char *p; int size; int num = 0; char *cmd[COMMAND_WORD_NUM]; int cmd_len = 0; int i, j; send_use(SERIAL_DEFAULT_DEVICE); command_init( cmd ); file_init(); while (1) { send_write("command> "); /* プロンプト表示 */ /* コマンド格納バッファを0クリアする */ for( j = 0; j < COMMAND_WORD_NUM; j++ ){ memset( cmd[j], 0, COMMAND_WORD_LENGTH ); } /* コンソールからの受信文字列を受け取る */ kz_recv(MSGBOX_ID_CONSINPUT, &size, &p); p[size] = '\0'; /* 入力文字列を分解する */ if( ( num = command_split( p, cmd ) ) == 0 ){ send_write("input nothing\n"); continue; } /* コマンドの実行 */ cmd_len = strlen( cmd[0] ); for( i = 0; command_table[i].cmd != NULL; i++ ){ if( !strncmp( cmd[0], command_table[i].cmd, (cmd_len>command_table[i].size?cmd_len:command_table[i].size) ) ){ command_table[i].func( num, cmd ); break; } } if( command_table[i].cmd == NULL ){ send_write("unknown.\n"); } kz_kmfree(p); } command_terminate( cmd ); return 0; }
static void cmd_timer( int cmdc, char *cmdv[COMMAND_WORD_NUM] ) { softvec_setintr(SOFTVEC_TYPE_TIMINTR, timer_intr); send_write("start timer .\n"); timer_start(0,3000); timer_start(1,4500); }
int command_main(int argc, char *argv[]) { char *p; int size; long prev_time; send_use(SERIAL_DEFAULT_DEVICE); while (1) { send_write("command> "); /* プロンプト表示 */ /* コンソールからの受信文字列を受け取る */ kz_recv(MSGBOX_ID_CONSINPUT, &size, &p); if (p == NULL) { send_write("expired.\n"); continue; } p[size] = '\0'; if (!strncmp(p, "echo", 4)) { /* echoコマンド */ send_write(p + 4); /* echoに続く文字列を出力する */ send_write("\n"); } else if (!strncmp(p, "timer", 5)) { /* timerコマンド */ send_write("timer start.\n"); send_start(1000); } else if (!strncmp(p, "ping", 4)) { /* pingコマンド */ send_write("ping start.\n"); send_icmp(); } else if (!strncmp(p, "tftp", 4)) { /* tftpコマンド */ send_write("tftp start.\n"); send_tftp(); } else if (!strncmp(p, "debug", 5)) { /* デバッガ起動 */ set_debug_traps(); force_break(); } else if (!strncmp(p, "call", 4)) { /* ダミー関数の呼び出し */ send_write(func(p + 4)); } else if (!strncmp(p, "get", 3)) { /* get */ prev_time = get_time(); putxval(prev_time, 8); puts("\n"); } else { send_write("unknown.\n"); } kz_kmfree(p); } return 0; }
static void send_string(int number, char *str) { int len, size; len = strlen(str); while (len > 0) { size = (len > 512) ? 512 : len; send_write(number, size, str); len -= size; str += size; } }
int clock_main(int argc, char *argv[]) { send_start(3000); while (1) { kz_recv(MSGBOX_ID_TIMEXPIRE, NULL, NULL); send_write("ready.\n"); send_start(3000); } return 0; }
static void cmd_show( int cmdc, char *cmdv[COMMAND_WORD_NUM] ) { int i; send_write("\n Command List\n"); send_write("-------------------------------\n"); for( i = 0; command_table[i].cmd != NULL; i++ ){ send_write( command_table[i].cmd ); send_write( " : " ); send_write( command_table[i].comment ); send_write( "\n" ); } }
static int send_reply_chunks(struct svcxprt_rdma *xprt, struct rpcrdma_msg *rdma_argp, struct rpcrdma_msg *rdma_resp, struct svc_rqst *rqstp, struct svc_rdma_req_map *vec) { u32 xfer_len = rqstp->rq_res.len; int write_len; int max_write; u32 xdr_off; int chunk_no; int chunk_off; struct rpcrdma_segment *ch; struct rpcrdma_write_array *arg_ary; struct rpcrdma_write_array *res_ary; int ret; arg_ary = svc_rdma_get_reply_array(rdma_argp); if (!arg_ary) return 0; /* XXX: need to fix when reply lists occur with read-list and or * write-list */ res_ary = (struct rpcrdma_write_array *) &rdma_resp->rm_body.rm_chunks[2]; if (vec->frmr) max_write = vec->frmr->map_len; else max_write = xprt->sc_max_sge * PAGE_SIZE; /* xdr offset starts at RPC message */ for (xdr_off = 0, chunk_no = 0; xfer_len && chunk_no < arg_ary->wc_nchunks; chunk_no++) { u64 rs_offset; ch = &arg_ary->wc_array[chunk_no].wc_target; write_len = min(xfer_len, ch->rs_length); /* Prepare the reply chunk given the length actually * written */ rs_offset = get_unaligned(&(ch->rs_offset)); svc_rdma_xdr_encode_array_chunk(res_ary, chunk_no, ch->rs_handle, rs_offset, write_len); chunk_off = 0; while (write_len) { int this_write; this_write = min(write_len, max_write); ret = send_write(xprt, rqstp, ch->rs_handle, rs_offset + chunk_off, xdr_off, this_write, vec); if (ret) { dprintk("svcrdma: RDMA_WRITE failed, ret=%d\n", ret); return -EIO; } chunk_off += this_write; xdr_off += this_write; xfer_len -= this_write; write_len -= this_write; } } /* Update the req with the number of chunks actually used */ svc_rdma_xdr_encode_reply_array(res_ary, chunk_no); return rqstp->rq_res.len; }
static int send_write_chunks(struct svcxprt_rdma *xprt, struct rpcrdma_msg *rdma_argp, struct rpcrdma_msg *rdma_resp, struct svc_rqst *rqstp, struct svc_rdma_req_map *vec) { u32 xfer_len = rqstp->rq_res.page_len + rqstp->rq_res.tail[0].iov_len; int write_len; int max_write; u32 xdr_off; int chunk_off; int chunk_no; struct rpcrdma_write_array *arg_ary; struct rpcrdma_write_array *res_ary; int ret; arg_ary = svc_rdma_get_write_array(rdma_argp); if (!arg_ary) return 0; res_ary = (struct rpcrdma_write_array *) &rdma_resp->rm_body.rm_chunks[1]; if (vec->frmr) max_write = vec->frmr->map_len; else max_write = xprt->sc_max_sge * PAGE_SIZE; /* Write chunks start at the pagelist */ for (xdr_off = rqstp->rq_res.head[0].iov_len, chunk_no = 0; xfer_len && chunk_no < arg_ary->wc_nchunks; chunk_no++) { struct rpcrdma_segment *arg_ch; u64 rs_offset; arg_ch = &arg_ary->wc_array[chunk_no].wc_target; write_len = min(xfer_len, arg_ch->rs_length); /* Prepare the response chunk given the length actually * written */ rs_offset = get_unaligned(&(arg_ch->rs_offset)); svc_rdma_xdr_encode_array_chunk(res_ary, chunk_no, arg_ch->rs_handle, rs_offset, write_len); chunk_off = 0; while (write_len) { int this_write; this_write = min(write_len, max_write); ret = send_write(xprt, rqstp, arg_ch->rs_handle, rs_offset + chunk_off, xdr_off, this_write, vec); if (ret) { dprintk("svcrdma: RDMA_WRITE failed, ret=%d\n", ret); return -EIO; } chunk_off += this_write; xdr_off += this_write; xfer_len -= this_write; write_len -= this_write; } } /* Update the req with the number of chunks actually used */ svc_rdma_xdr_encode_write_list(rdma_resp, chunk_no); return rqstp->rq_res.page_len + rqstp->rq_res.tail[0].iov_len; }
int test_clone_ioctl(int cmd) { struct ctx myctx; int i; pid_t cpid; struct ctx *p_ctx=&myctx; uint64_t nlba; uint64_t st_lba; uint64_t stride=0x1000; int rc=0; uint64_t src_ctx_id; uint64_t src_adap_fd; pthread_t thread; uint64_t resource[MAX_RES_HANDLE]; uint64_t RES_CLOSED=-1; int cl_index[5]={ 1,7,10,12,15 }; pid = getpid(); rc =ctx_init(p_ctx); CHECK_RC(rc, "Context init failed"); pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx); p_ctx->flags = DK_UVF_ALL_PATHS; for (i=0;i<MAX_RES_HANDLE;i++) { p_ctx->lun_size = (i+1)*p_ctx->chunk_size; rc = create_res(p_ctx); CHECK_RC(rc, "create res failed"); resource[i]=p_ctx->rsrc_handle; } for (i=0;i<5;i++) { p_ctx->rsrc_handle= resource[cl_index[i]]; close_res(p_ctx); resource[cl_index[i]]= RES_CLOSED; } for (i=0; i<MAX_RES_HANDLE;i++) { if (RES_CLOSED == resource[i]) continue; nlba = (i+1)*p_ctx->chunk_size; p_ctx->rsrc_handle = resource[i]; p_ctx->res_hndl = p_ctx->rsrc_handle & RES_HNDLR_MASK; for (st_lba=0;st_lba<nlba;st_lba += (NUM_CMDS*stride)) { rc = send_write(p_ctx,st_lba,stride,pid); CHECK_RC(rc, "send write failed\n"); } } //write done cancel thread now pthread_cancel(thread); cpid = fork(); if (cpid == 0) { //child process pid = getpid(); ppid = getppid(); //take backup parent ctx_id src_ctx_id= p_ctx->context_id; src_adap_fd = p_ctx->adap_fd; //do unmap parent mmio 1st rc =munmap((void *)p_ctx->p_host_map, p_ctx->mmio_size); CHECK_RC_EXIT(rc, "munmap failed\n"); //do fresh attach for child rc = ctx_init_internal(p_ctx,DK_AF_ASSIGN_AFU,p_ctx->devno); CHECK_RC_EXIT(rc, "ctx_init_internal failed"); pthread_create(&thread, NULL,ctx_rrq_rx,p_ctx); //do clone rc = ioctl_dk_capi_clone(p_ctx, src_ctx_id,src_adap_fd); CHECK_RC_EXIT(rc, "clone ioctl failed"); //do read data for (i=0; i< MAX_RES_HANDLE;i++) { if (RES_CLOSED == resource[i]) continue; p_ctx->rsrc_handle = resource[i]; p_ctx->res_hndl = p_ctx->rsrc_handle & RES_HNDLR_MASK; nlba = (i+1)*p_ctx->chunk_size; for (st_lba=0;st_lba<nlba; st_lba+=(NUM_CMDS*stride)) { rc = send_read(p_ctx,st_lba,stride); CHECK_RC_EXIT(rc,"send_read failed\n"); rc = rw_cmp_buf_cloned(p_ctx, st_lba); CHECK_RC_EXIT(rc,"rw_cmp_buf_cloned failed\n"); } } sleep(1); //now create closed resources p_ctx->flags = DK_UVF_ALL_PATHS; for (i=0; i < 5;i++) { p_ctx->lun_size = (cl_index[i]+1)*p_ctx->chunk_size; rc = create_res(p_ctx); CHECK_RC_EXIT(rc,"res_create failed\n"); resource[cl_index[i]] = p_ctx->rsrc_handle; } //do io on new resources p_ctx->st_lba = 0; for (i=0;i<5;i++) { p_ctx->last_lba = ((cl_index[i]+1)*p_ctx->chunk_size) -1; p_ctx->res_hndl = resource[cl_index[i]] & RES_HNDLR_MASK; rc = do_io(p_ctx, stride); CHECK_RC_EXIT(rc, "do_io failed\n"); } pthread_cancel(thread); ctx_close(p_ctx); exit(0); } //child process end else { //create pthread sleep(1); //let child process do clone & read written data pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx); //do open closed res //now create closed resources p_ctx->flags = DK_UVF_ALL_PATHS; for (i=0; i < 5;i++) { p_ctx->lun_size = (cl_index[i]+1)*p_ctx->chunk_size; rc = create_res(p_ctx); CHECK_RC_EXIT(rc,"res_create failed\n"); resource[cl_index[i]] = p_ctx->rsrc_handle; } //do resize all resources & IO for (i=0;i<MAX_RES_HANDLE;i++) { p_ctx->req_size = (rand()%MAX_RES_HANDLE +1) * p_ctx->chunk_size; p_ctx->rsrc_handle = resource[i]; p_ctx->res_hndl = p_ctx->rsrc_handle & RES_HNDLR_MASK; rc = ioctl_dk_capi_vlun_resize(p_ctx); CHECK_RC(rc, "dk_capi_resize_ioctl failed\n"); rc = do_io(p_ctx, stride); CHECK_RC(rc, "do_io failed\n"); } //close res for (i=0;i<MAX_RES_HANDLE;i++) { p_ctx->rsrc_handle = resource[i]; rc = close_res(p_ctx); CHECK_RC(rc, "cose_res failed\n"); } pthread_cancel(thread); ctx_close(p_ctx); rc = wait4all(); } return rc; }
int child_mc_reg_error(int cmd) { int rc; struct ctx myctx; struct ctx *p_ctx = &myctx; __u64 *map=(__u64 *)0xabcdf; __u64 actual_size=0; __u64 stride; __u64 st_lba =0; __u64 nlba; mc_hndl_t new_mc_hndl, dup_mc_hndl; int rc1, rc2, rc3, rc4, rc5; pthread_t thread; mc_stat_t l_mc_stat; __u64 size = 128; if(mc_init() !=0 ) { fprintf(stderr, "mc_init failed.\n"); return -1; } debug("mc_init success.\n"); rc = ctx_init(p_ctx); if(rc != 0) { fprintf(stderr, "Context init failed, errno %d\n", errno); return -1; } pid = getpid(); if(1 == cmd) //mc_reg with NULL MMIOP { pthread_create(&thread,NULL,ctx_rrq_rx, p_ctx); rc = mc_register(master_dev_path, p_ctx->ctx_hndl, NULL,&p_ctx->mc_hndl); if(rc) return rc; rc = mc_open(p_ctx->mc_hndl,MC_RDWR, &p_ctx->res_hndl); if(rc) return rc; rc = mc_open(p_ctx->mc_hndl,MC_RDWR, &p_ctx->res_hndl); if(rc) return rc; rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl, 2, &actual_size); if(rc) return rc; rc = mc_stat(p_ctx->mc_hndl, p_ctx->res_hndl, &l_mc_stat); if(rc) return rc; pid = getpid(); stride = (1 << l_mc_stat.nmask); st_lba = (actual_size * (1 << l_mc_stat.nmask))-1; rc = send_write(p_ctx, st_lba ,stride, pid, VLBA); if(rc) return rc; rc = send_read(p_ctx, st_lba ,stride, VLBA); if(rc) return rc; rc = rw_cmp_buf(p_ctx, st_lba); rc = rc ? 1:0; } else if(2 == cmd) //NULL device path { rc = mc_register(NULL, p_ctx->ctx_hndl, (volatile __u64 *) p_ctx->p_host_map,&p_ctx->mc_hndl); rc = rc ? 2:0; } else if(3 == cmd) //with afu_path device { rc = mc_register(afu_path, p_ctx->ctx_hndl, (volatile __u64 *) p_ctx->p_host_map,&p_ctx->mc_hndl); rc = rc ? 3:0; } else if(4 == cmd) //with invalid device path { rc = mc_register("/dev/cxl/afu50.0m", p_ctx->ctx_hndl, (volatile __u64 *) p_ctx->p_host_map,&p_ctx->mc_hndl); rc = rc ? 4:0; } else if(5 == cmd) //with invalid ctx hndl(not assigned) { debug("actual ctx hndl :%d\n", p_ctx->ctx_hndl); p_ctx->ctx_hndl = p_ctx->ctx_hndl + 4; debug("invalid ctx hndl :%d\n", p_ctx->ctx_hndl); rc = mc_register(master_dev_path, p_ctx->ctx_hndl, (volatile __u64 *) p_ctx->p_host_map,&p_ctx->mc_hndl); rc = rc ? 5:0; } else if(6 == cmd) //with invalid mmap adress { rc = mc_register(master_dev_path, p_ctx->ctx_hndl, (volatile __u64 *)map,&p_ctx->mc_hndl); rc = rc ? 6:0; } else if(7 == cmd) //twice mc_reg { pthread_create(&thread,NULL,ctx_rrq_rx, p_ctx); rc = mc_register(master_dev_path, p_ctx->ctx_hndl, (volatile __u64 *)p_ctx->p_host_map, &p_ctx->mc_hndl); CHECK_RC(rc, "mc_register"); rc = mc_open(p_ctx->mc_hndl, MC_RDWR, &p_ctx->res_hndl); CHECK_RC(rc, "mc_open"); rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl, size, &actual_size); CHECK_RC(rc, "mc_size"); rc = mc_stat(p_ctx->mc_hndl, p_ctx->res_hndl, &l_mc_stat); //twice mc_register on same ctx rc = mc_register(master_dev_path, p_ctx->ctx_hndl, (volatile __u64 *)p_ctx->p_host_map, &new_mc_hndl); //send write on 1st mc hndl rc1 = send_single_write(p_ctx, 0, pid); //do mc_size & open on old mc_reg rc2 = mc_open(p_ctx->mc_hndl, MC_RDWR, &p_ctx->res_hndl); rc3 = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl, size, &actual_size); rc4 = mc_stat(p_ctx->mc_hndl, p_ctx->res_hndl, &l_mc_stat); rc5 = mc_hdup(p_ctx->mc_hndl, &dup_mc_hndl); debug("mc_hdup rc is : %d\n", rc5); //now do mc_unreg on old one rc = mc_unregister(p_ctx->mc_hndl); CHECK_RC(rc, "mc_unregister"); //do everything on new mc hndl p_ctx->mc_hndl = new_mc_hndl; rc = mc_open(p_ctx->mc_hndl, MC_RDWR, &p_ctx->res_hndl); CHECK_RC(rc, "mc_open"); rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl, size, &actual_size); CHECK_RC(rc, "mc_size"); rc = mc_stat(p_ctx->mc_hndl, p_ctx->res_hndl, &l_mc_stat); nlba = l_mc_stat.size * (1 << l_mc_stat.nmask); stride = 1 << l_mc_stat.nmask; for(st_lba = 0; st_lba < nlba; st_lba += (stride * NUM_CMDS)) { rc = send_write(p_ctx, st_lba, stride, pid, VLBA); CHECK_RC(rc, "send_write"); } if(rc1 && rc2 && rc3 && rc4 && rc5) { rc = 7; } pthread_cancel(thread); mc_unregister(p_ctx->mc_hndl); } else if(8 == cmd) //mc_reg twice from 2 diff process { if(fork() == 0) {//mc_reg in child process as well pid = getpid(); rc = mc_register(master_dev_path, p_ctx->ctx_hndl, (volatile __u64 *)p_ctx->p_host_map, &p_ctx->mc_hndl); sleep(1); rc = mc_open(p_ctx->mc_hndl,MC_RDWR, &p_ctx->res_hndl); if(!rc) { fprintf(stderr, "%d : mc_open should fail rc = %d\n", pid, rc); exit(-1); } else { debug("%d : mc_open failed as expectd\n", pid); } rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl, 2, &actual_size); if(!rc) { fprintf(stderr, "%d : mc_size should fail rc = %d\n", pid, rc); exit(-1); } else { debug("%d : mc_size failed as expectd\n", pid); } rc = rc ? 8:0; exit(rc); } else { sleep(1); //let child proc cal mc_reg 1str rc = mc_register(master_dev_path, p_ctx->ctx_hndl, (volatile __u64 *)p_ctx->p_host_map, &p_ctx->mc_hndl); CHECK_RC(rc, "mc_register"); pthread_create(&thread,NULL,ctx_rrq_rx, p_ctx); rc = mc_open(p_ctx->mc_hndl,MC_RDWR, &p_ctx->res_hndl); CHECK_RC(rc, "mc_open"); rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl, 2, &actual_size); CHECK_RC(rc, "mc_mc_size"); rc = mc_stat(p_ctx->mc_hndl, p_ctx->res_hndl, &l_mc_stat); CHECK_RC(rc, "mc_stat"); st_lba = (actual_size * (1 << l_mc_stat.nmask))-1; rc += send_single_write(p_ctx, st_lba, pid); wait(&rc); pthread_cancel(thread); if (WIFEXITED(rc)) { rc = WEXITSTATUS(rc); rc = rc ? 8:0; } mc_unregister(p_ctx->mc_hndl); } } ctx_close(p_ctx); if(9 == cmd) //mc_reg with closed ctx { pthread_create(&thread,NULL,ctx_rrq_rx, p_ctx); printf("calling mc_reg api after ctx close..\n"); rc = mc_register(master_dev_path, p_ctx->ctx_hndl, (volatile __u64 *)p_ctx->p_host_map, &p_ctx->mc_hndl); rc = rc ? 9:0; } mc_term(); return rc; }
int ioctl_7_1_196() { int rc,i,j; struct ctx myctx[21],myctx_1, myctx_2; struct ctx *p_ctx[21],*p_ctx_1,*p_ctx_2; __u64 stride=0x1000,st_lba=0; pthread_t thread[20]; struct flash_disk disks[MAX_FDISK]; char disk1[30]; char disk2[30]; int cfdisk = MAX_FDISK; pid = getpid(); cfdisk = get_flash_disks(disks, FDISKS_SAME_ADPTR); //need to check the number of disks if (cfdisk < 2) { fprintf(stderr,"Must have 2 flash disks..\n"); TESTCASE_SKIP("Need disk from same adapter and each disk multipathed"); return 0; } strcpy(disk1,disks[0].dev); strcpy(disk2,disks[1].dev); // creating first context for (i=0;i<21;i++) { p_ctx[i]=&myctx[i]; } p_ctx_1=&myctx_1; p_ctx_2=&myctx_2; debug("1ST PROCEDURE\n"); // using p_ctx[[0] for LUN direct for firect disk /* rc = ctx_init2(p_ctx[0], disks[0].dev, DK_AF_ASSIGN_AFU, disks[0].devno[0]); pthread_create(&thread[0], NULL, ctx_rrq_rx, p_ctx[0]); */ /* rc = create_resource(p_ctx[0], 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT); CHECK_RC(rc, "create LUN_DIRECT failed"); */ // creating another 19 context LUN VIRTUAL for ( i=2;i<21;i++) { sleep(2); rc = ctx_init2(p_ctx[i], disks[1].dev, DK_AF_ASSIGN_AFU, disks[1].devno[0]); rc=create_resource(p_ctx[i], p_ctx[i]->chunk_size, DK_UVF_ASSIGN_PATH, LUN_VIRTUAL); } // do context reuse for direct LUN strcpy(p_ctx[0]->dev,disks[0].dev); strcpy(p_ctx[1]->dev,disks[1].dev); p_ctx[0]->fd = open_dev(disks[0].dev, O_RDWR); if (p_ctx[0]->fd < 0) { fprintf(stderr, "open() failed: device %s, errno %d\n", disks[0].dev, errno); g_error = -1; return -1; } p_ctx[1]->fd = open_dev(disks[1].dev, O_RDWR); //Hoping to open second disk if (p_ctx[1]->fd < 0) { fprintf(stderr, "open() failed: device %s, errno %d\n", disks[1].dev, errno); g_error = -1; } #ifdef _AIX rc = ioctl_dk_capi_query_path(p_ctx[0]); CHECK_RC(rc, "DK_CAPI_QUERY_PATH failed"); #else //TBD for linux #endif p_ctx[0]->work.num_interrupts = p_ctx[1]->work.num_interrupts = 4; rc=ioctl_dk_capi_attach_reuse(p_ctx[0],p_ctx[1],LUN_DIRECT); // CHECK_RC(rc, "DK_CAPI_ATTACH with reuse flag failed"); if ( rc != 0 ) { fprintf(stderr,"LUN DIRECT got attached to new disk with VLUN, should have succeeded"); return rc; } // initiate I/O on all the LUNs for (i=2;i<21;i++) { pthread_create(&thread[i], NULL, ctx_rrq_rx, p_ctx[i]); rc = do_io(p_ctx[i], stride); } if ( rc != 0 ) { fprintf(stderr,"io on some LUN failed"); return rc; } /* using a goto-label removes the compile warning (-O3 issue) */ i=2; for_loop: pthread_cancel(thread[i]); close_res(p_ctx[i]); if (++i < 21) {goto for_loop;} ctx_close(p_ctx[2]); debug("2nd PROCEDURE\n"); // procedure 2 of the same case debug("%d: ........Phase 1 done.. Starting 2nd Phase........\n",getpid()); memset(p_ctx_1, 0, sizeof(struct ctx)); memset(p_ctx_2, 0, sizeof(struct ctx)); // open the first flash disk in write mode and create a DIRECT LUN // restoring from backup strcpy(disks[0].dev,disk1); p_ctx_1->fd = open_dev(disks[0].dev, O_WRONLY); if (p_ctx_1->fd < 0) { fprintf(stderr, "open() failed: device %s, errno %d\n", disks[0].dev, errno); return -1; } rc = ctx_init2(p_ctx_1, disks[0].dev, DK_AF_ASSIGN_AFU, disks[0].devno[0]); pthread_create(&thread[0], NULL, ctx_rrq_rx, p_ctx_1); CHECK_RC(rc, "create context failed"); rc = create_resource(p_ctx_1, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT); CHECK_RC(rc, "create LUN_DIRECT failed"); // open the same flash disk in read mode again. p_ctx_2->fd = open_dev(disks[0].dev, O_RDONLY); if (p_ctx_2->fd < 0) { fprintf(stderr, "open() failed: device %s, errno %d\n", disks[0].dev, errno); return -1; } rc = ctx_init2(p_ctx_2, disks[0].dev, DK_AF_ASSIGN_AFU, disks[0].devno[0]); pthread_create(&thread[1], NULL, ctx_rrq_rx, p_ctx_2); CHECK_RC(rc, "create context failed"); rc = create_resource(p_ctx_2, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT); CHECK_RC(rc, "create LUN_DIRECT failed"); // now write to the disk and then read for (st_lba = 0; st_lba <= p_ctx_1->last_lba; st_lba += (NUM_CMDS*stride)) { rc = send_write(p_ctx_1, st_lba, stride, pid); CHECK_RC(rc, "send_write failed"); rc = send_read(p_ctx_2, st_lba, stride); CHECK_RC(rc, "send_read failed"); /*if (rc !=0 ) { rc = rw_cmp_buf(p_ctx_1, st_lba); if (rc != 0) { fprintf(stderr,"buf cmp failed for lba 0x%lX,rc =%d\n",st_lba,rc); break; } }*/ } if ( rc != 0 ) return rc; for (i=0;i<2;i++) { pthread_cancel(thread[i]); } //close_res(p_ctx_1); ctx_close(p_ctx_1); //close_res(p_ctx_2); ctx_close(p_ctx_2); debug("3rd PROCEDURE\n"); debug("%d: ........Phase 2 done.. Starting 3rd Phase........\n",getpid()); // case 3 of the same case // creating multiple process for LUN_DIRECT creation. for (j=0;j<long_run;j++) { for (i=0; i<20;i++) { if ( 0 == fork()) { rc = ctx_init(p_ctx[i]); CHECK_RC_EXIT(rc, "Context init failed"); // CHECK_RC(rc, "Context init failed"); //thread to handle AFU interrupt & events rc = create_resource(p_ctx[i], 0, DK_UDF_ASSIGN_PATH , LUN_DIRECT); CHECK_RC_EXIT(rc, "create LUN_DIRECT failed"); // do io on context pthread_create(&thread[i], NULL, ctx_rrq_rx, p_ctx[i]); stride=0x1000; sleep(2); //do_io(p_ctx[i], stride); pthread_cancel(thread[i]); close_res(p_ctx[i]); exit(rc); } } wait4all(); } return 0; }
////////////////////////////////////////////////////////////////////////// // PDES process ////////////////////////////////////////////////////////////////////////// tmpl (void)::execLoop () { while(true) { // deactivation if all channels are stopped: // send desactivation message... and deschedule if ( m_dma_activated and all_channels_stopped() ) { m_activity_extension.set_active(); send_activity(); m_dma_activated = false; wait( m_event ); } // activation if at least one channel not stopped // send activation message... and continue if ( not m_dma_activated and all_channels_idle() ) { m_activity_extension.set_inactive(); send_activity(); m_dma_activated = true; } // enters the loop on all channels when activated for ( size_t k = 0 ; k < m_channels ; k++ ) { // update local time : one cycle m_pdes_local_time->add(UNIT_TIME); switch ( m_state[k] ) { //////////////// case STATE_IDLE: { if ( not m_stop[k] ) m_state[k] = STATE_READ_CMD; break; } //////////////////// case STATE_READ_CMD: { if ( m_length[k] >= m_max_burst ) m_burst_length[k] = m_max_burst; else m_burst_length[k] = m_length[k]; send_read( k ); m_state[k] = STATE_READ_RSP; break; } //////////////////// case STATE_READ_RSP: { if ( m_rsp_received[k] ) { m_rsp_received[k] = false; if ( m_stop[k] ) { m_state[k] = STATE_IDLE; } else if( not m_vci_payload[k].is_response_error() ) { m_state[k] = STATE_WRITE_CMD; } else { m_state[k] = STATE_ERROR_WRITE; m_irq_value[k] = 0xFF; if ( not m_irq_disabled[k] ) send_irq( k ); } } break; } ///////////////////// case STATE_WRITE_CMD: { send_write( k ); m_state[k] = STATE_WRITE_RSP; break; } ///////////////////// case STATE_WRITE_RSP: { if ( m_rsp_received[k] ) { m_rsp_received[k] = false; if ( m_stop[k] ) { m_state[k] = STATE_IDLE; } else if ( m_vci_payload[k].is_response_error() ) { m_state[k] = STATE_ERROR_WRITE; m_irq_value[k] = 0xFF; if ( not m_irq_disabled[k] ) send_irq( k ); } else if ( m_length[k] == 0 ) { m_state[k] = STATE_SUCCESS; m_irq_value[k] = 0xFF; if ( not m_irq_disabled[k] ) send_irq( k ); } else { m_length[k] = m_length[k] - m_burst_length[k]; m_source[k] = m_source[k] + m_burst_length[k]; m_destination[k] = m_destination[k] + m_burst_length[k]; m_state[k] = STATE_READ_CMD; } } break; } ////////////////////// case STATE_ERROR_READ: case STATE_ERROR_WRITE: case STATE_SUCCESS: { if ( not m_stop[k] ) { m_state[k] = STATE_IDLE; m_irq_value[k] = 0x00; if ( not m_irq_disabled[k] ) send_irq( k ); } } } // end channel state switch } // end loop on channels // send NULL and deschedule if required if ( m_pdes_local_time->need_sync() and m_dma_activated ) { send_null(); wait( sc_core::SC_ZERO_TIME ); } } // end infinite while } // end execLoop
static void cmd_cancel( int cmdc, char *cmdv[COMMAND_WORD_NUM] ) { send_write("cancel timer.\n"); timer_cancel(0); }
static void cmd_echo( int cmdc, char *cmdv[COMMAND_WORD_NUM] ) { send_write(cmdv[1]); /* echoに続く文字列を出力する */ send_write("\n"); }