int max_ctx_cross_limit() { int i; int rc = 0; struct ctx myctx; struct ctx *p_ctx=&myctx; pid = getpid(); int max_p = MAX_OPENS; //int max_p = 1; for (i=0; i<max_p;i++) { if (0==fork()) { pid=getpid(); rc =ctx_init(p_ctx); sleep(10); exit(rc); } } sleep(5); rc=ctx_init(p_ctx); if(rc){ fprintf(stderr,"%d:expectd to fail....\n",pid); g_error=0; rc = 0; } else rc =10; rc = wait4all(); return rc; }
int test_spio_plun() { int rc; struct ctx myctx; struct ctx *p_ctx = &myctx; pthread_t thread; __u64 stride= 0x10000; pid = getpid(); rc = ctx_init(p_ctx); CHECK_RC(rc, "Context init failed"); //thread to handle AFU interrupt & events pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx); //for PLUN 2nd argument(lba_size) would be ignored rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT); CHECK_RC(rc, "create LUN_DIRECT failed"); rc = compare_size(p_ctx->last_lba, p_ctx->last_phys_lba); CHECK_RC(rc, "failed compare_size"); rc = do_io(p_ctx, stride); pthread_cancel(thread); close_res(p_ctx); ctx_close(p_ctx); return rc; }
// // Constructor // WGreMotif::WGreMotif( void *wg_parent_ctx, Widget wg_parent_wid, const char *name) : WGre( wg_parent_ctx, 0), parent_wid(wg_parent_wid), trace_timerid(0) { Arg args[20]; int i; static MrmRegisterArg reglist[] = { { (char*) "gre_ctx", 0 } }; /* Create object context */ reglist[0].value = (caddr_t) this; /* Fill in common part */ parent_wid = wg_parent_wid; ctx_init(); i = 0; XtSetArg( args[i], XmNwidth, 600);i++; XtSetArg( args[i], XmNheight, 600);i++; XtSetArg( args[i], XmNtopAttachment, XmATTACH_FORM);i++; XtSetArg( args[i], XmNrightAttachment, XmATTACH_FORM);i++; XtSetArg( args[i], XmNleftAttachment, XmATTACH_FORM);i++; XtSetArg( args[i], XmNbottomAttachment, XmATTACH_FORM);i++; form_widget = ScrolledFlowCreate( parent_wid, (char*) "Flow window", args, i, init_flow, this, &flow_widget); XtManageChild( form_widget); popupmenu_mode = GRE_POPUPMENUMODE_OBJECT; }
int init_mc(struct ctx *p_ctx, res_hndl_t *res_hndl) { int rc; __u64 chunks=16; __u64 actual_size=0; rc = mc_init(); CHECK_RC(rc, "mc_init failed"); debug("mc_init success :%d\n",rc); rc = ctx_init(p_ctx); CHECK_RC(rc, "Context init failed"); rc = mc_register(master_dev_path, p_ctx->ctx_hndl, (volatile __u64 *)p_ctx->p_host_map,&p_ctx->mc_hndl); CHECK_RC(rc, "ctx reg failed"); rc = mc_open(p_ctx->mc_hndl,MC_RDWR, &p_ctx->res_hndl); CHECK_RC(rc, "opening res_hndl"); rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl,chunks, &actual_size); CHECK_RC(rc, "mc_size"); rc = mc_open(p_ctx->mc_hndl,MC_RDWR, res_hndl); CHECK_RC(rc, "opening res_hndl"); rc = mc_size(p_ctx->mc_hndl, *res_hndl, chunks, &actual_size); CHECK_RC(rc, "mc_size"); return 0; }
int init_mc(struct ctx *p_ctx, res_hndl_t *res_hndl) { int rc; __u64 chunks=16; __u64 actual_size=0; rc = mc_init(); CHECK_RC(rc, "mc_init failed"); debug("mc_init success :%d\n",rc); rc = ctx_init(p_ctx); CHECK_RC(rc, "Context init failed"); rc = create_res(p_ctx); CHECK_RC(rc, "opening res_hndl"); rc = mc_size1(p_ctx,chunks, &actual_size); CHECK_RC(rc, "mc_size"); *res_hndl = p_ctx->res_hndl; rc = create_res(p_ctx); CHECK_RC(rc, "opening res_hndl"); rc = mc_size1(p_ctx, chunks, &actual_size); CHECK_RC(rc, "mc_size"); return 0; }
rc_t CC KMain ( int argc, char *argv [] ) { Args * args; rc_t rc = ArgsMakeAndHandle ( &args, argc, argv, 2, MyOptions, sizeof MyOptions / sizeof ( OptDef ), XMLLogger_Args, XMLLogger_ArgsQty ); KLogHandlerSetStdErr(); if ( rc != 0 ) { LOGERR( klogErr, rc, "error creating internal structure" ); } else { ld_context lctx; lctx_init( &lctx ); rc = KDirectoryNativeDir ( &lctx.wd ); if ( rc != 0 ) { LOGERR( klogErr, rc, "error creating internal structure" ); } else { rc = XMLLogger_Make( &lctx.xml_logger, lctx.wd, args ); if ( rc != 0 ) { LOGERR( klogErr, rc, "error creating internal structure" ); } else { context ctx; rc = ctx_init( args, &ctx ); if ( rc == 0 ) { rc = pacbio_check_sourcefile( &ctx, &lctx ); if ( rc == 0 ) { lctx.with_progress = ctx.with_progress; ctx_show( &ctx ); lctx.dst_path = ctx.dst_path; rc = pacbio_load( &ctx, &lctx, false, false ); if ( rc == 0 ) { rc = pacbio_meta_entry( &lctx, argv[ 0 ] ); } } ctx_free( &ctx ); } } } lctx_free( &lctx ); ArgsWhack ( args ); } return rc; }
int filter(struct image *img, xmlNodePtr node, void **instctx) { struct image work; struct flipctx *ctx; unsigned int x, y, vy; unsigned char *r, *w; if (!*instctx) { ctx = ctx_init(node); *instctx = ctx; } else ctx = *instctx; if (!ctx->h && !ctx->v) return 0; image_dup(&work, img); /* 3x3 * 0/00 RGBRGBRGB * 1/09 RGBRGBRGB * 2/18 RGBRGBRGB */ r = img->buf; for (y = 0; y < img->y; y++) { if (ctx->v) vy = img->y - y - 1; else vy = y; if (ctx->h) w = work.buf + (vy + 1) * work.x * 3 - 3; else w = work.buf + vy * work.x * 3; for (x = 0; x < img->x; x++) { w[0] = *r++; w[1] = *r++; w[2] = *r++; if (ctx->h) w -= 3; else w += 3; } } image_move(img, &work); return 0; }
int nv20_graph_create_context(struct nouveau_channel *chan) { struct drm_device *dev = chan->dev; struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; void (*ctx_init)(struct drm_device *, struct nouveau_gpuobj *); unsigned int idoffs = 0x28; int ret; switch (dev_priv->chipset) { case 0x20: ctx_init = nv20_graph_context_init; idoffs = 0; break; case 0x25: case 0x28: ctx_init = nv25_graph_context_init; break; case 0x2a: ctx_init = nv2a_graph_context_init; idoffs = 0; break; case 0x30: case 0x31: ctx_init = nv30_31_graph_context_init; break; case 0x34: ctx_init = nv34_graph_context_init; break; case 0x35: case 0x36: ctx_init = nv35_36_graph_context_init; break; default: BUG_ON(1); } ret = nouveau_gpuobj_new(dev, chan, pgraph->grctx_size, 16, NVOBJ_FLAG_ZERO_ALLOC, &chan->ramin_grctx); if (ret) return ret; /* Initialise default context values */ ctx_init(dev, chan->ramin_grctx); /* nv20: nv_wo32(dev, chan->ramin_grctx->gpuobj, 10, chan->id<<24); */ nv_wo32(chan->ramin_grctx, idoffs, (chan->id << 24) | 0x1); /* CTX_USER */ nv_wo32(pgraph->ctx_table, chan->id * 4, chan->ramin_grctx->pinst >> 4); return 0; }
int test_scsi_cmds() { int rc; struct ctx myctx; struct ctx *p_ctx = &myctx; __u64 chunk = 16; pthread_t thread; __u64 stride = 0x10; __u64 nlba; uint8_t opcode[]={ 0x00,0xA0,0x09E,0x12,0x03,0x1B,0x5A,0x55 }; int index; pid = getpid(); rc = ctx_init(p_ctx); int i; CHECK_RC(rc, "Context init failed"); pthread_create(&thread,NULL,ctx_rrq_rx, p_ctx); p_ctx->flags = DK_UVF_ALL_PATHS; p_ctx->lun_size = chunk * p_ctx->chunk_size; rc = create_res(p_ctx); CHECK_RC(rc, "create_res failed"); nlba = p_ctx->last_lba+1; for (index=0;index <sizeof(opcode);index++) { debug("%d:sending scsi cmd=0X%"PRIX8" ........\n",pid,opcode[index]); fill_send_write(p_ctx, nlba, pid, stride); for (i =0;i<NUM_CMDS;i++) { p_ctx->cmd[i].rcb.req_flags = SISL_REQ_FLAGS_RES_HNDL; p_ctx->cmd[i].rcb.req_flags |= SISL_REQ_FLAGS_HOST_READ; p_ctx->cmd[i].rcb.cdb[0] = opcode[index]; } send_cmd(p_ctx); rc = wait_resp(p_ctx); #ifndef _AIX if (rc != 0x21) { fprintf(stderr,"%d:failed rc =%d for scsi cmd=0X%"PRIX8",exptd rc=0x21\n", pid,rc,opcode[index]); break; } #endif debug("%d:rc =%d for scsi cmd=0X%"PRIX8" ........\n",pid,rc,opcode[index]); usleep(1000); } pthread_cancel(thread); ctx_close(p_ctx); return rc; }
LUA_API int luafan_objectbuf_symbol(lua_State *L) { if (lua_gettop(L) == 0) { luaL_error(L, "no argument."); } CTX ctx = {0}; ctx_init(&ctx, L); packer(L, &ctx, 1); lua_settop(L, ctx.index); return 1; }
int test_large_transfer() { int rc; struct ctx my_ctx; struct ctx *p_ctx = &my_ctx; pthread_t thread; struct rwlargebuf rwbuf; __u64 chunk=2; // do io on last 2 chunks on a plun __u64 buf_size[] = { 0x1000, //4KB 0x4000, //16KB 0x10000, //64KB 0x40000, //256KB 0x800000, //8MB 0x1000000 }; //16MB int i; //Large trasnfer size is for PLUN not Vluns(4K only) as per Jim pid = getpid(); #ifdef _AIX rc = setRUnlimited(); CHECK_RC(rc, "setRUnlimited failed"); #endif rc = ctx_init(p_ctx); CHECK_RC(rc, "Context init failed"); pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx); rc = create_resource(p_ctx,0,DK_UDF_ASSIGN_PATH,LUN_DIRECT); CHECK_RC(rc, "create LUN_DIRECT failed"); p_ctx->st_lba= p_ctx->last_lba +1 -(chunk*p_ctx->chunk_size); if (long_run_enable) p_ctx->st_lba=0; //let do IO on complete plun for (i=0;i< sizeof(buf_size)/sizeof(__u64);i++) { rc = allocate_buf(&rwbuf, buf_size[i]); CHECK_RC(rc, "memory allocation failed"); printf("%d: do large io size=0X%"PRIX64"\n",pid, buf_size[i]); rc = do_large_io(p_ctx, &rwbuf, buf_size[i]); deallocate_buf(&rwbuf); if (rc) break; //get out from here } pthread_cancel(thread); close_res(p_ctx); ctx_close(p_ctx); return rc; }
// 7.1.219 : Pass context token to different process & do detach/release. int test_detach_diff_proc() { int rc=0; int cstat; struct ctx myctx; struct ctx *p_ctx = &myctx; pid = getpid(); //ctx_init with default flash disk & devno rc = ctx_init(p_ctx); CHECK_RC(rc, "Context init failed"); rc = fork(); if ( rc == -1 ) CHECK_RC(1, "fork() failed"); // child process if ( rc == 0 ) { pid = getpid(); rc = ctx_close(p_ctx); if ( 22 != rc ) CHECK_RC_EXIT(1, "Context detach did not fail"); exit(0); } else { // Probe child's exit status. if ( wait(&cstat) == -1 ) CHECK_RC(1, "Failed while wait() for child"); // We expect child to exit itself if (WIFEXITED(cstat)) { // We expect child to exit with rc 0 only ! if ( WEXITSTATUS(cstat) != 0 ) rc=1; else rc=0; } } rc |= ctx_close(p_ctx); return rc; }
int child_mc_size_error(int cmd) { int rc; struct ctx myctx; struct ctx *p_ctx = &myctx; __u64 size=0; int invalid=0; pid = getpid(); rc =mc_init(); CHECK_RC(rc, "mc_init failed"); rc = ctx_init(p_ctx); CHECK_RC(rc, "ctx init failed"); rc = mc_register(master_dev_path, p_ctx->ctx_hndl, (volatile __u64 *)p_ctx->p_host_map,&p_ctx->mc_hndl); CHECK_RC(rc, "ctx reg failed"); rc = mc_open(p_ctx->mc_hndl,MC_RDWR, &p_ctx->res_hndl); CHECK_RC(rc, "opening res_hndl"); if(1 == cmd) { //invalid MCH rc = mc_size((mc_hndl_t)&invalid, p_ctx->res_hndl,1,&size); rc = rc ? 1:0; } else if( 2 == cmd) { //invalid RSH rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl+20,1,&size); rc = rc ? 2:0; } else if(3 == cmd) { //NULL size rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl,1, NULL); rc = rc ? 3:0; } else if(4 == cmd) { //after mc_close mc_close(p_ctx->mc_hndl, p_ctx->res_hndl); rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl,1, &size); rc = rc ? 4:0; } else if(5 == cmd) { //after mc_unregister mc_unregister(p_ctx->mc_hndl); rc = mc_size(p_ctx->mc_hndl, p_ctx->res_hndl,1, &size); rc = rc ? 5:0; } ctx_close(p_ctx); mc_term(); return rc; }
int test_large_trnsfr_boundary() { int rc; struct ctx my_ctx; struct ctx *p_ctx = &my_ctx; pthread_t thread; struct rwlargebuf rwbuf; __u64 buf_size = 0x1000000; //16MB __u64 chunk = 10; pid = getpid(); #ifdef _AIX system("ulimit -d unlimited"); system("ulimit -s unlimited"); system("ulimit -m unlimited"); #endif rc = ctx_init(p_ctx); CHECK_RC(rc, "Context init failed"); pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx); //do RW last cmd with crossed LBA boundary //i.e. last_lba size is 0x100; //do send rw with 0x10 & cross limit of 0x100 rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT); CHECK_RC(rc, "create LUN_DIRECT failed"); rc = allocate_buf(&rwbuf, buf_size); CHECK_RC(rc, "memory allocation failed"); //to make sure last cmd rw beyond boundary p_ctx->st_lba = p_ctx->last_lba - (chunk * p_ctx->chunk_size); p_ctx->st_lba = p_ctx->st_lba +20 ; rc = do_large_io(p_ctx, &rwbuf, buf_size); deallocate_buf(&rwbuf); pthread_cancel(thread); close_res(p_ctx); ctx_close(p_ctx); return rc; }
long atb_dp_paths(struct atombios *atb, struct atb_dp_path **dp_paths, u8 *dp_paths_n) { struct ctx ctx; long r; mutex_lock(&atb->mutex); ctx_init(atb, &ctx); r = paths_parse(&ctx); if (r == -ATB_ERR) goto err_free_mutex; *dp_paths = ctx.dp_paths; *dp_paths_n = ctx.dp_paths_n; err_free_mutex: mutex_unlock(&atb->mutex); return r; }
krb5_error_code krb5_db2_open(krb5_context context, char *conf_section, char **db_args, int mode) { krb5_error_code status = 0; krb5_clear_error_message(context); if (inited(context)) return 0; status = configure_context(context, conf_section, db_args); if (status != 0) return status; status = check_openable(context); if (status != 0) return status; return ctx_init(context->dal_handle->db_context); }
sageContext * sage_open (int db_flag, int red_size, int green_size, int blue_size, int alpha_size, int depth_size, int stencil_size) { sageContext *ctx; if (hardware < 0) { goto exit_error; } /* Create context */ ctx = malloc(sizeof(sageContext)); if (ctx == NULL) { goto exit_error; } /* Initialize the core */ if (ctx_init(db_flag, red_size, green_size, blue_size, alpha_size, depth_size, stencil_size) != 0) { goto exit_error1; } /* Finish driver setup */ vb = malloc((tnl_vb.max + TNL_CLIPPED_VERTS) * sizeof(SWvertex)); if (vb == NULL) { goto exit_error3; } drv_multipass = drv_multipass_none; return ctx; exit_error3: ctx_fini(); exit_error1: free(ctx); exit_error: return NULL; }
static ctx * load_ctx(int argc, char *argv[]) { const char *tlsfile = NULL; const char *encfile = NULL; const char *decdir = NULL; ctx *ctx; if (!deo_getopt(argc, argv, "ht:e:d:", "", NULL, NULL, option, &tlsfile, option, &encfile, option, &decdir)) goto usage; if (tlsfile == NULL || encfile == NULL || decdir == NULL) goto usage; ctx = ctx_init(tlsfile, encfile, decdir); if (ctx != NULL) return ctx; usage: fprintf(stderr, "Usage: deo decryptd " "-t <tlsfile> -e <encfile> -d <decdir>\n"); return NULL; }
int max_vlun_on_a_ctx() { int i; int rc; struct ctx myctx; struct ctx *p_ctx=&myctx; pid = getpid(); rc=ctx_init(p_ctx); __u64 vluns[MAX_VLUNS]; for (i=0;i<MAX_VLUNS;i++) { rc = create_resource(p_ctx,p_ctx->chunk_size,0,LUN_VIRTUAL); CHECK_RC(rc, "create_resource Failed\n"); vluns[i]=p_ctx->rsrc_handle; } for (i=0;i<MAX_VLUNS;i++) { p_ctx->rsrc_handle=vluns[i]; rc=close_res(p_ctx); CHECK_RC(rc, "close_res failed\n"); } rc = ctx_close(p_ctx); return rc; }
static int decryptd(int argc, char *argv[]) { const char *hp = DEO_SOCKET; const char *tlsfile = NULL; const char *encfile = NULL; const char *decdir = NULL; int ret = EXIT_FAILURE; AUTO(ctx, ctx); int lfds = 0; int sock = 0; signal(SIGINT, on_signal); signal(SIGQUIT, on_signal); signal(SIGTERM, on_signal); signal(SIGUSR1, on_signal); signal(SIGUSR2, on_signal); if (!deo_getopt(argc, argv, "ht:e:d:l:", "", NULL, NULL, option, &tlsfile, option, &encfile, option, &decdir, option, &hp) || tlsfile == NULL || encfile == NULL || decdir == NULL || (ctx = ctx_init(tlsfile, encfile, decdir)) == NULL) { ERR_print_errors_fp(stderr); fprintf(stderr, "Usage: deo decryptd " "[-l <[host:]port>] -t <tlsfile> " "-e <encfile> -d <decdir>\n"); return EXIT_FAILURE; } lfds = sd_listen_fds(0); if (lfds <= 0) { sock = BIO_get_accept_socket((char *) hp, 0); if (sock < 0) { ERR_print_errors_fp(stderr); goto error; } if (listen(sock, 64) != 0) goto error; } while (true) { DEO_ERR err = DEO_ERR_NONE; AUTO(ASN1_OCTET_STRING, pt); AUTO(DEO_MSG, in); AUTO(BIO, sio); AUTO_FD(cfd); int lfd; if (!have_conn(lfds, sock, &lfd)) break; if (!do_accept(ctx->ctx, lfd, &cfd, &sio)) continue; in = d2i_bio_max(&DEO_MSG_it, sio, NULL, DEO_MAX_INPUT); if (in == NULL) continue; switch (in->type) { case DEO_MSG_TYPE_CRT_REQ: ASN1_item_i2d_bio(&DEO_MSG_it, sio, &(DEO_MSG) { .type = DEO_MSG_TYPE_CRT_REP, .value.crt_rep = ctx->crt }); break; case DEO_MSG_TYPE_DEC_REQ: err = decrypt(ctx, in->value.dec_req, &pt); if (err != DEO_ERR_NONE) { SEND_ERR(sio, err); break; } ASN1_item_i2d_bio(&DEO_MSG_it, sio, &(DEO_MSG) { .type = DEO_MSG_TYPE_DEC_REP, .value.dec_rep = pt }); break; default: break; }
int test_fc_port_reset_vlun() { int rc; struct ctx myctx; struct ctx *p_ctx = &myctx; pthread_t thread; int ioCounter=0; __u64 nlba; __u64 stride=0x1; pid = getpid(); #ifdef _AIX memset(p_ctx, 0, sizeof(myctx)); strcpy(p_ctx->dev, cflash_path); if ((p_ctx->fd =open_dev(p_ctx->dev, O_RDWR)) < 0) { fprintf(stderr,"open %s failed, errno=%d\n",p_ctx->dev,errno); return -1; } rc = ioctl_dk_capi_query_path(p_ctx); CHECK_RC(rc,"dk_capi_query_path failed..\n"); rc = ctx_init_internal(p_ctx, 0,p_ctx->devno); #else rc = ctx_init(p_ctx); #endif CHECK_RC(rc, "Context init failed"); //thread to handle AFU interrupt & events pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx); nlba = 1 * (p_ctx->chunk_size); rc = create_resource(p_ctx, nlba, 0, LUN_VIRTUAL); CHECK_RC(rc, "create LUN_VIRTUAL failed"); rc = compare_size(p_ctx->last_lba, nlba-1); CHECK_RC(rc, "failed compare_size"); debug("-- Going to start IO.Please do chportfc -reset <pnum> at texan --\n"); debug("rc=%d,g_error=%d\n",rc,g_error); do { rc = do_io(p_ctx, stride); if (rc !=0 ) { debug("rc=%d,ioCounter=%d,IO failed..... \n",rc,ioCounter); if ( ioCounter==1 ) { debug("rc=%d, Going to verify.... \n",rc); p_ctx->flags=DK_VF_LUN_RESET; #ifdef _AIX p_ctx->hint = DK_HINT_SENSE; #else p_ctx->hint = DK_CXLFLASH_VERIFY_HINT_SENSE; #endif rc = ioctl_dk_capi_verify(p_ctx); CHECK_RC(rc, "ioctl_dk_capi_verify failed\n"); } else { if (ioCounter > 1) { rc=-1; // IO failed third time break; } } } else { debug("rc=%d,IO succeeded \n",rc); g_error=0; } ioCounter++; rc|=g_error; sleep(3); } while ( rc !=0); debug("rc=%d,g_error=%d\n",rc,g_error); if ( ioCounter <= 1) { debug("WARNING: Test case not excuted properly... Please rerun\n"); rc =255; } pthread_cancel(thread); close_res(p_ctx); ctx_close(p_ctx); rc |= g_error; return rc; }
int test_ctx_reset() { int rc; struct ctx myctx; struct ctx *p_ctx= &myctx; pthread_t thread; __u64 buf_size = 0x2000000; //32MB __u64 chunk = 10; __u64 stride = 0x1000; struct rwlargebuf rwbuf; int i; pid=getpid(); rc = ctx_init(p_ctx); CHECK_RC(rc, "ctx_init failed"); pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx); rc = create_resource(p_ctx,chunk*p_ctx->chunk_size,DK_UVF_ASSIGN_PATH,LUN_VIRTUAL); CHECK_RC(rc, "create LUN_VIRTUAL failed"); //do bad EA if (1) { debug("%d: ........place bad EA....\n", pid); fill_send_write(p_ctx, 0, pid, stride); for (i = 0; i < NUM_CMDS; i++) { p_ctx->cmd[i].rcb.data_ea = (__u64)0x1234; } bad_address = true; send_cmd(p_ctx); rc = wait_resp(p_ctx); sleep(1); //normal IO bad_address = false; debug("%d: .........after bad EA, do normal IO....\n", pid); rc = do_io(p_ctx, stride); CHECK_RC(rc,"Normal IO failed after bad EA"); //do bad RCB debug("%d: .........place bad RCB....\n", pid); bad_address = true; place_bad_addresses(p_ctx, 1); sleep(2); //normal IO debug("%d: ......after bad RCB, do normal IO....\n", pid); bad_address = false; rc = do_io(p_ctx, stride); CHECK_RC(rc,"Normal IO failed after bad RCB"); #ifdef _AIX rc = setRUnlimited(); CHECK_RC(rc,"setRUnlimited() failed"); #endif } //do large _transfer debug("%d: Do large transfer ....\n", pid); rc = allocate_buf(&rwbuf, buf_size); CHECK_RC(rc, "memory allocation failed"); rc = do_large_io(p_ctx, &rwbuf, buf_size); deallocate_buf(&rwbuf); buf_size = 0x100000; //4k rc = allocate_buf(&rwbuf, buf_size); CHECK_RC(rc, "memory allocation failed"); //normal io debug("%d: after large transfer,do normal IO ....\n", pid); rc = do_io(p_ctx, 0x10000); //rc = do_large_io(p_ctx, &rwbuf, buf_size); CHECK_RC(rc,"Normal IO failed after large transfer"); pthread_cancel(thread); close_res(p_ctx); ctx_close(p_ctx); return rc; }
int test_mc_invalid_opcode() { int rc; struct ctx myctx; struct ctx *p_ctx = &myctx; __u64 chunks=10; __u64 actual_size=0; __u64 vlba =0; __u64 *p_u64; __u32 *p_u32; mc_stat_t l_mc_stat; pthread_t thread; 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; } 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); if(rc != 0) { fprintf(stderr, "ctx _reg failed, ctx_hndl %d,rc %d\n",p_ctx->ctx_hndl, rc ); return -1; }*/ rc = create_res(p_ctx); if (rc != 0) { fprintf(stderr, "error opening res_hndl rc %d\n", rc); return -1; } rc = mc_size1(p_ctx,chunks, &actual_size); CHECK_RC(rc, "mc_size"); rc = mc_stat1(p_ctx, &l_mc_stat); CHECK_RC(rc, "mc_stat"); pid = getpid(); vlba = (actual_size * (1 << l_mc_stat.nmask))-1; fill_buf((__u64*)&p_ctx->wbuf[0][0], sizeof(p_ctx->wbuf[0])/sizeof(__u64),pid); memset((void *)&p_ctx->cmd[0].rcb.cdb[0], 0, sizeof(p_ctx->cmd[0].rcb.cdb)); p_u64 = (__u64*)&p_ctx->cmd[0].rcb.cdb[2]; p_ctx->cmd[0].rcb.res_hndl = p_ctx->res_hndl; p_ctx->cmd[0].rcb.req_flags = SISL_REQ_FLAGS_RES_HNDL; p_ctx->cmd[0].rcb.req_flags |= SISL_REQ_FLAGS_HOST_WRITE; write_lba(p_u64, vlba); p_ctx->cmd[0].rcb.data_ea = (__u64) &p_ctx->wbuf[0][0]; p_ctx->cmd[0].rcb.data_len = sizeof(p_ctx->wbuf[0]); p_ctx->cmd[0].rcb.cdb[0] = 0xFA; // invalid opcode p_u32 = (__u32*)&p_ctx->cmd[0].rcb.cdb[10]; write_32(p_u32, 8); // 8 LBAs for 4K p_ctx->cmd[0].sa.host_use[0] = 0; // 0 means active p_ctx->cmd[0].sa.ioasc = 0; send_single_cmd(p_ctx); rc = wait_single_resp(p_ctx); return rc; }
int mc_invalid_ioarcb(int cmd) { int rc; struct ctx myctx; struct ctx *p_ctx = &myctx; __u64 chunks=32; __u64 actual_size=0; __u64 vlba =0; __u32 *p_u32; __u64 stride; __u64 *p_u64; pthread_t thread; mc_stat_t l_mc_stat; int i; pid = getpid(); signal(SIGABRT, sig_handle); signal(SIGSEGV, sig_handle); rc = mc_init(); CHECK_RC(rc, "mc_init failed"); debug("mc_init success :%d\n",rc); rc = ctx_init(p_ctx); CHECK_RC(rc, "Context init failed"); pthread_create(&thread,NULL,ctx_rrq_rx, p_ctx); if (15 == cmd) { //PLBA out of range rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT); CHECK_RC(rc, "opening res_hndl"); actual_size = (p_ctx->last_lba+1)/p_ctx->chunk_size; } else { p_ctx->flags = DK_UVF_ALL_PATHS; rc = create_res(p_ctx); CHECK_RC(rc, "opening res_hndl"); rc = mc_size1(p_ctx,chunks, &actual_size); CHECK_RC(rc, "mc_size"); } rc = mc_stat1(p_ctx, &l_mc_stat); CHECK_RC(rc, "mc_stat"); stride = 1 << l_mc_stat.nmask; vlba = (actual_size * (1 << l_mc_stat.nmask))-1; fill_send_write(p_ctx, vlba, pid, stride); for (i = 0; i < NUM_CMDS; i++) { if (1 == cmd) { //invalid upcode debug("invalid upcode(0xFA) action = %d\n",cmd); p_ctx->cmd[i].rcb.cdb[0] = 0xFA; } else if (2 == cmd) { //EA = NULL debug("EA = NULL action = %d\n",cmd); p_ctx->cmd[i].rcb.data_ea = (__u64)NULL; #ifdef _AIX bad_address = true; #endif } else if (3 == cmd) { //invalid flgas p_ctx->cmd[i].rcb.req_flags = SISL_REQ_FLAGS_RES_HNDL; p_ctx->cmd[i].rcb.req_flags |= SISL_REQ_FLAGS_HOST_READ; debug("invalid flag = 0X%X\n",p_ctx->cmd[i].rcb.req_flags); } else if (5 == cmd) { //SISL_AFU_RC_RHT_INVALID p_ctx->cmd[i].rcb.res_hndl = p_ctx->res_hndl + 2; } else if ( 6 == cmd) { //SISL_AFU_RC_RHT_OUT_OF_BOUNDS p_ctx->cmd[i].rcb.res_hndl = MAX_RES_HANDLE; } else if (7 == cmd) { //invalid address for page fault debug("setting EA = 0x1234 to generate error page fault\n"); p_ctx->cmd[i].rcb.data_ea = (__u64)0x1234; #ifdef _AIX bad_address = true; #endif } else if (8 == cmd) { //invalid ctx_id debug("%d: sending invalid ctx id\n", pid); p_ctx->cmd[i].rcb.ctx_id = p_ctx->ctx_hndl +10; } else if (9 == cmd) { //test flag underrun p_ctx->cmd[i].rcb.data_len = sizeof(p_ctx->wbuf[0])/2; } else if (10 == cmd) { // test flag overrun p_ctx->cmd[i].rcb.data_len = sizeof(p_ctx->wbuf[0]); p_u32 = (__u32*)&p_ctx->cmd[i].rcb.cdb[10]; write_32(p_u32, 2); } else if (11 == cmd) { //rc scsi_rc_check p_u32 = (__u32*)&p_ctx->cmd[i].rcb.cdb[10]; write_32(p_u32, p_ctx->blk_len +1); } else if (12 == cmd) { //data len 0 in ioarcb p_ctx->cmd[i].rcb.data_len = 0; } else if (13 == cmd) { //NUM BLK to write 0 p_u32 = (__u32*)&p_ctx->cmd[i].rcb.cdb[10]; write_32(p_u32, 0); } else if ((14 == cmd) || (15 == cmd)) { //test out of range LBAs p_u64 = (__u64*)&p_ctx->cmd[i].rcb.cdb[2]; vlba += i+1; write_lba(p_u64, vlba); } } //test BAD IOARCB, IOASA & CMD room violation if (cmd >= 100) { if (100 == cmd) { //bad RCB place_bad_addresses(p_ctx, 1); usleep(1000); if (err_afu_intrpt) //cool expected res rc = 100; else rc = -1; goto END; } else if (101 == cmd) { //bad IOASA handle_bad_ioasa(p_ctx, pid); usleep(1000); //sleep sometime to process rcb cmd by AFU //And let handle rrq event //how to handle error, rrq thread should throw some error return -1; } else if (102 == cmd) { //cmd_room violation place_bad_addresses(p_ctx, 3); usleep(1000); #ifdef _AIX if (err_afu_intrpt) //cool expected res rc = 102; else rc = -1; goto END; #endif } else if (103 == cmd) { //bad HRRQ place_bad_addresses(p_ctx, 2); usleep(1000); if (err_afu_intrpt) //cool expected res rc = 103; else rc = -1; goto END; } } else { send_cmd(p_ctx); } rc = wait_resp(p_ctx); if ( cmd >= 9 && cmd <= 13) { if (!rc_flags) { if (!dont_displa_err_msg) fprintf(stderr, "%d: Expecting rc flags non zero\n", pid); rc = -1; } } if (4 == cmd) { //invalid fc port & lun id debug("invalid fc port(0xFF)&lun id(0X1200), action=%d",cmd); fill_send_write(p_ctx, vlba, pid, stride); for (i = 0; i < NUM_CMDS; i++) { p_ctx->cmd[i].rcb.lun_id = 0x12000; p_ctx->cmd[i].rcb.port_sel = 0xff; } //send_single_cmd(p_ctx); send_cmd(p_ctx); rc = wait_resp(p_ctx); } #ifdef _AIX if ((7 == cmd || 2 == cmd)&& (err_afu_intrpt)) rc = 7; #endif END: pthread_cancel(thread); close_res(p_ctx); //mc_unregister(p_ctx->mc_hndl); //xerror: ctx_close(p_ctx); mc_term(); return rc; }
int main(int argc, char *argv[]) { int i = 0; int size_max_pow = 24; int ret_val; struct report_options report; struct pingpong_context ctx; struct pingpong_dest *my_dest = NULL; struct pingpong_dest *rem_dest = NULL; struct mcast_parameters mcg_params; struct ibv_device *ib_dev = NULL; struct perftest_parameters user_param; struct perftest_comm user_comm; /* init default values to user's parameters */ memset(&ctx, 0, sizeof(struct pingpong_context)); memset(&user_param, 0, sizeof(struct perftest_parameters)); memset(&user_comm , 0, sizeof(struct perftest_comm)); memset(&mcg_params, 0, sizeof(struct mcast_parameters)); user_param.verb = SEND; user_param.tst = LAT; strncpy(user_param.version, VERSION, sizeof(user_param.version)); user_param.r_flag = &report; // Configure the parameters values according to user arguments or defalut values. ret_val = parser(&user_param,argv,argc); if (ret_val) { if (ret_val != VERSION_EXIT && ret_val != HELP_EXIT) fprintf(stderr," Parser function exited with Error\n"); return 1; } if(user_param.use_xrc || user_param.connection_type == DC) { user_param.num_of_qps *= 2; } //Checking that the user did not run with RawEth. for this we have raw_etherent_bw test. if (user_param.connection_type == RawEth) { fprintf(stderr," This test cannot run Raw Ethernet QPs (you have chosen RawEth as connection type\n"); return FAILURE; } // Finding the IB device selected (or defalut if no selected). ib_dev = ctx_find_dev(user_param.ib_devname); if (!ib_dev) { fprintf(stderr," Unable to find the Infiniband/RoCE device\n"); return 1; } if (user_param.use_mcg) GET_STRING(mcg_params.ib_devname,ibv_get_device_name(ib_dev)); // Getting the relevant context from the device ctx.context = ibv_open_device(ib_dev); if (!ctx.context) { fprintf(stderr, " Couldn't get context for the device\n"); return 1; } // See if MTU and link type are valid and supported. if (check_link(ctx.context,&user_param)) { fprintf(stderr, " Couldn't get context for the device\n"); return FAILURE; } // copy the relevant user parameters to the comm struct + creating rdma_cm resources. if (create_comm_struct(&user_comm,&user_param)) { fprintf(stderr," Unable to create RDMA_CM resources\n"); return 1; } if (user_param.output == FULL_VERBOSITY && user_param.machine == SERVER) { printf("\n************************************\n"); printf("* Waiting for client to connect... *\n"); printf("************************************\n"); } // Initialize the connection and print the local data. if (establish_connection(&user_comm)) { fprintf(stderr," Unable to init the socket connection\n"); return FAILURE; } exchange_versions(&user_comm, &user_param); check_sys_data(&user_comm, &user_param); // See if MTU and link type are valid and supported. if (check_mtu(ctx.context,&user_param, &user_comm)) { fprintf(stderr, " Couldn't get context for the device\n"); return FAILURE; } // Print basic test information. ctx_print_test_info(&user_param); ALLOCATE(my_dest , struct pingpong_dest , user_param.num_of_qps); memset(my_dest, 0, sizeof(struct pingpong_dest)*user_param.num_of_qps); ALLOCATE(rem_dest , struct pingpong_dest , user_param.num_of_qps); memset(rem_dest, 0, sizeof(struct pingpong_dest)*user_param.num_of_qps); // Allocating arrays needed for the test. alloc_ctx(&ctx,&user_param); // Create (if nessacery) the rdma_cm ids and channel. if (user_param.work_rdma_cm == ON) { if (user_param.machine == CLIENT) { if (retry_rdma_connect(&ctx,&user_param)) { fprintf(stderr,"Unable to perform rdma_client function\n"); return FAILURE; } } else { if (create_rdma_resources(&ctx,&user_param)) { fprintf(stderr," Unable to create the rdma_resources\n"); return FAILURE; } if (rdma_server_connect(&ctx,&user_param)) { fprintf(stderr,"Unable to perform rdma_client function\n"); return FAILURE; } } } else { // create all the basic IB resources (data buffer, PD, MR, CQ and events channel) if (ctx_init(&ctx,&user_param)) { fprintf(stderr, " Couldn't create IB resources\n"); return FAILURE; } } // Set up the Connection. if (send_set_up_connection(&ctx,&user_param,my_dest,&mcg_params,&user_comm)) { fprintf(stderr," Unable to set up socket connection\n"); return 1; } for (i=0; i < user_param.num_of_qps; i++) ctx_print_pingpong_data(&my_dest[i],&user_comm); user_comm.rdma_params->side = REMOTE; for (i=0; i < user_param.num_of_qps; i++) { // shaking hands and gather the other side info. if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { fprintf(stderr,"Failed to exchange data between server and clients\n"); return 1; } ctx_print_pingpong_data(&rem_dest[i],&user_comm); } if (user_param.work_rdma_cm == OFF) { if (ctx_check_gid_compatibility(&my_dest[0], &rem_dest[0])) { fprintf(stderr,"\n Found Incompatibility issue with GID types.\n"); fprintf(stderr," Please Try to use a different IP version.\n\n"); return 1; } } if (user_param.use_mcg) { memcpy(mcg_params.base_mgid.raw,mcg_params.mgid.raw,16); memcpy(mcg_params.mgid.raw,rem_dest[0].gid.raw,16); mcg_params.base_mlid = mcg_params.mlid; mcg_params.is_2nd_mgid_used = ON; if (!strcmp(link_layer_str(user_param.link_type),"IB")) { // Request for Mcast group create registery in SM. if (join_multicast_group(SUBN_ADM_METHOD_SET,&mcg_params)) { fprintf(stderr," Failed to Join Mcast request\n"); return 1; } } /* * The next stall in code (50 ms sleep) is a work around for fixing the * the bug this test had in Multicast for the past 1 year. * It appears, that when a switch involved, it takes ~ 10 ms for the join * request to propogate on the IB fabric, thus we need to wait for it. * what happened before this fix was reaching the post_send * code segment in about 350 ns from here, and the switch(es) dropped * the packet because join request wasn't finished. */ usleep(50000); } if (user_param.work_rdma_cm == OFF) { // Prepare IB resources for rtr/rts. if (ctx_connect(&ctx,rem_dest,&user_param,my_dest)) { fprintf(stderr," Unable to Connect the HCA's through the link\n"); return 1; } } // shaking hands and gather the other side info. if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr,"Failed to exchange data between server and clients\n"); return 1; } if (user_param.use_event) { if (ibv_req_notify_cq(ctx.send_cq, 0)) { fprintf(stderr, "Couldn't request RCQ notification\n"); return 1; } if (ibv_req_notify_cq(ctx.recv_cq, 0)) { fprintf(stderr, "Couldn't request RCQ notification\n"); return 1; } } if (user_param.output == FULL_VERBOSITY) { printf(RESULT_LINE); printf("%s",(user_param.test_type == ITERATIONS) ? RESULT_FMT_LAT : RESULT_FMT_LAT_DUR); printf((user_param.cpu_util_data.enable ? RESULT_EXT_CPU_UTIL : RESULT_EXT)); } ctx_set_send_wqes(&ctx,&user_param,rem_dest); if (user_param.test_method == RUN_ALL) { if (user_param.connection_type == UD) size_max_pow = (int)UD_MSG_2_EXP(MTU_SIZE(user_param.curr_mtu)) + 1; for (i = 1; i < size_max_pow ; ++i) { user_param.size = (uint64_t)1 << i; // Post recevie recv_wqes fo current message size if (ctx_set_recv_wqes(&ctx,&user_param)) { fprintf(stderr," Failed to post receive recv_wqes\n"); return 1; } // Sync between the client and server so the client won't send packets // Before the server has posted his receive wqes (in UC/UD it will result in a deadlock). if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr,"Failed to exchange data between server and clients\n"); return 1; } if(run_iter_lat_send(&ctx, &user_param)) return 17; user_param.test_type == ITERATIONS ? print_report_lat(&user_param) : print_report_lat_duration(&user_param); } } else { // Post recevie recv_wqes fo current message size if (ctx_set_recv_wqes(&ctx,&user_param)) { fprintf(stderr," Failed to post receive recv_wqes\n"); return 1; } // Sync between the client and server so the client won't send packets // Before the server has posted his receive wqes (in UC/UD it will result in a deadlock). if (ctx_hand_shake(&user_comm,my_dest,rem_dest)) { fprintf(stderr,"Failed to exchange data between server and clients\n"); return 1; } if(run_iter_lat_send(&ctx, &user_param)) return 17; user_param.test_type == ITERATIONS ? print_report_lat(&user_param) : print_report_lat_duration(&user_param); } if (user_param.output == FULL_VERBOSITY) { printf(RESULT_LINE); } if (ctx_close_connection(&user_comm,my_dest,rem_dest)) { fprintf(stderr,"Failed to close connection between server and client\n"); fprintf(stderr," Trying to close this side resources\n"); } return send_destroy_ctx(&ctx,&user_param,&mcg_params); }
int test_fc_port_reset_plun() { int rc; struct ctx myctx; struct ctx *p_ctx = &myctx; pthread_t thread; __u64 stride= 0x100; int ioCounter=0; pid = getpid(); rc = ctx_init(p_ctx); CHECK_RC(rc, "Context init failed"); //thread to handle AFU interrupt & events pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx); //for PLUN 2nd argument(lba_size) would be ignored rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT); CHECK_RC(rc, "create LUN_DIRECT failed"); rc = compare_size(p_ctx->last_lba, p_ctx->last_phys_lba); CHECK_RC(rc, "failed compare_size"); debug("-- Going to start IO.Please do chportfc -reset <pnum> at texan --\n"); do { rc = do_io(p_ctx, stride); if (rc !=0 ) { debug("rc=%d,ioCounter=%d,IO failed..... \n",rc,ioCounter); if ( ioCounter==1 ) { debug("rc=%d, Going to verify.... \n",rc); p_ctx->flags=DK_VF_LUN_RESET; #ifdef _AIX p_ctx->hint = DK_HINT_SENSE; #else p_ctx->hint = DK_CXLFLASH_VERIFY_HINT_SENSE; #endif rc = ioctl_dk_capi_verify(p_ctx); CHECK_RC(rc, "ioctl_dk_capi_verify failed\n"); } else { if (ioCounter > 1) { rc=-1; // IO failed third time break; } } } else { debug("rc=%d,IO succeeded \n",rc); g_error=0; } ioCounter++; rc|=g_error; sleep(3); } while ( rc !=0); debug("rc=%d,g_error=%d\n",rc,g_error); if ( ioCounter <= 1) { debug("WARNING: Test case not excuted properly... Please rerun\n"); rc =255; } pthread_cancel(thread); close_res(p_ctx); ctx_close(p_ctx); return rc; }
int main(int argc, char *argv[]) { struct ibv_device *ib_dev; struct pingpong_context ctx; struct pingpong_dest *my_dest,*rem_dest; struct perftest_parameters user_param; struct perftest_comm user_comm; int i = 0; memset(&ctx,0,sizeof(struct pingpong_context)); memset(&user_param, 0, sizeof(struct perftest_parameters)); memset(&user_comm,0,sizeof(struct perftest_comm)); user_param.verb = WRITE; user_param.tst = BW; user_param.spec = PL; user_param.version = VERSION; // Configure the parameters values according to user arguments or defalut values. if (parser(&user_param,argv,argc)) { fprintf(stderr," Parser function exited with Error\n"); return 1; } // Finding the IB device selected (or defalut if no selected). ib_dev = ctx_find_dev(user_param.ib_devname); if (!ib_dev) { fprintf(stderr," Unable to find the Infiniband/RoCE deivce\n"); return 1; } // Getting the relevant context from the device ctx.context = ibv_open_device(ib_dev); if (!ctx.context) { fprintf(stderr, " Couldn't get context for the device\n"); return 1; } // See if MTU and link type are valid and supported. if (check_link_and_mtu(ctx.context,&user_param)) { fprintf(stderr, " Couldn't get context for the device\n"); return FAILURE; } // Print basic test information. ctx_print_test_info(&user_param); ALLOCATE(my_dest , struct pingpong_dest , user_param.num_of_qps); memset(my_dest, 0, sizeof(struct pingpong_dest)*user_param.num_of_qps); ALLOCATE(rem_dest , struct pingpong_dest , user_param.num_of_qps); memset(rem_dest, 0, sizeof(struct pingpong_dest)*user_param.num_of_qps); // copy the rellevant user parameters to the comm struct + creating rdma_cm resources. if (create_comm_struct(&user_comm,&user_param)) { fprintf(stderr," Unable to create RDMA_CM resources\n"); return 1; } // Create (if nessacery) the rdma_cm ids and channel. if (user_param.work_rdma_cm == ON) { if (create_rdma_resources(&ctx,&user_param)) { fprintf(stderr," Unable to create the rdma_resources\n"); return FAILURE; } if (user_param.machine == CLIENT) { if (rdma_client_connect(&ctx,&user_param)) { fprintf(stderr,"Unable to perform rdma_client function\n"); return FAILURE; } } else { if (rdma_server_connect(&ctx,&user_param)) { fprintf(stderr,"Unable to perform rdma_client function\n"); return FAILURE; } } } else { // create all the basic IB resources (data buffer, PD, MR, CQ and events channel) if (ctx_init(&ctx,&user_param)) { fprintf(stderr, " Couldn't create IB resources\n"); return FAILURE; } } // Set up the Connection. if (set_up_connection(&ctx,&user_param,my_dest)) { fprintf(stderr," Unable to set up socket connection\n"); return FAILURE; } // Print this machine QP information for (i=0; i < user_param.num_of_qps; i++) ctx_print_pingpong_data(&my_dest[i],&user_comm); // Init the connection and print the local data. if (establish_connection(&user_comm)) { fprintf(stderr," Unable to init the socket connection\n"); return FAILURE; } // shaking hands and gather the other side info. for (i=0; i < user_param.num_of_qps; i++) { if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { fprintf(stderr," Failed to exchange date between server and clients\n"); return 1; } // Print remote machine QP information user_comm.rdma_params->side = REMOTE; ctx_print_pingpong_data(&rem_dest[i],&user_comm); if (user_param.work_rdma_cm == OFF) { if (pp_connect_ctx(&ctx,my_dest[i].psn,&rem_dest[i],&user_param,i)) { fprintf(stderr," Unable to Connect the HCA's through the link\n"); return FAILURE; } } // An additional handshake is required after moving qp to RTR. if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { fprintf(stderr," Failed to exchange date between server and clients\n"); return FAILURE; } } printf(RESULT_LINE); printf(RESULT_FMT); // For half duplex tests, server just waits for client to exit if (user_param.machine == SERVER && !user_param.duplex) { if (ctx_close_connection(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr,"Failed to close connection between server and client\n"); return 1; } printf(RESULT_LINE); return 0; } ALLOCATE(tposted,cycles_t,user_param.iters*user_param.num_of_qps); ALLOCATE(tcompleted,cycles_t,user_param.iters*user_param.num_of_qps); if (user_param.all == ON) { for (i = 1; i < 24 ; ++i) { user_param.size = 1 << i; if(run_iter(&ctx,&user_param,rem_dest)) return 17; print_report(&user_param); } } else { if(run_iter(&ctx,&user_param,rem_dest)) return 18; print_report(&user_param); } free(tposted); free(tcompleted); // Closing connection. if (ctx_close_connection(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr,"Failed to close connection between server and client\n"); return 1; } free(my_dest); free(rem_dest); printf(RESULT_LINE); return 0; }
int main(int argc, char *argv[]) { int i = 0; struct report_options report = {}; struct pingpong_context ctx; struct ibv_device *ib_dev; struct perftest_parameters user_param; struct pingpong_dest my_dest,rem_dest; struct perftest_comm user_comm; /* init default values to user's parameters */ memset(&ctx,0,sizeof(struct pingpong_context)); memset(&user_param,0,sizeof(struct perftest_parameters)); memset(&user_comm,0,sizeof(struct perftest_comm)); memset(&my_dest,0,sizeof(struct pingpong_dest)); memset(&rem_dest,0,sizeof(struct pingpong_dest)); user_param.verb = READ; user_param.tst = LAT; user_param.r_flag = &report; user_param.version = VERSION; // Configure the parameters values according to user arguments or defalut values. if (parser(&user_param,argv,argc)) { fprintf(stderr," Parser function exited with Error\n"); return FAILURE; } // Finding the IB device selected (or defalut if no selected). ib_dev = ctx_find_dev(user_param.ib_devname); if (!ib_dev) { fprintf(stderr," Unable to find the Infiniband/RoCE deivce\n"); return FAILURE; } // Getting the relevant context from the device ctx.context = ibv_open_device(ib_dev); if (!ctx.context) { fprintf(stderr, " Couldn't get context for the device\n"); return 1; } // See if MTU and link type are valid and supported. if (check_link_and_mtu(ctx.context,&user_param)) { fprintf(stderr, " Couldn't get context for the device\n"); return FAILURE; } // Print basic test information. ctx_print_test_info(&user_param); // copy the rellevant user parameters to the comm struct + creating rdma_cm resources. if (create_comm_struct(&user_comm,&user_param)) { fprintf(stderr," Unable to create RDMA_CM resources\n"); return 1; } // Create (if nessacery) the rdma_cm ids and channel. if (user_param.work_rdma_cm == ON) { if (create_rdma_resources(&ctx,&user_param)) { fprintf(stderr," Unable to create the rdma_resources\n"); return FAILURE; } if (user_param.machine == CLIENT) { if (rdma_client_connect(&ctx,&user_param)) { fprintf(stderr,"Unable to perform rdma_client function\n"); return FAILURE; } } else { if (rdma_server_connect(&ctx,&user_param)) { fprintf(stderr,"Unable to perform rdma_client function\n"); return FAILURE; } } } else { // create all the basic IB resources (data buffer, PD, MR, CQ and events channel) if (ctx_init(&ctx,&user_param)) { fprintf(stderr, " Couldn't create IB resources\n"); return FAILURE; } } // Set up the Connection. if (set_up_connection(&ctx,&user_param,&my_dest)) { fprintf(stderr," Unable to set up socket connection\n"); return 1; } ctx_print_pingpong_data(&my_dest,&user_comm); // Init the connection and print the local data. if (establish_connection(&user_comm)) { fprintf(stderr," Unable to init the socket connection\n"); return 1; } // shaking hands and gather the other side info. if (ctx_hand_shake(&user_comm,&my_dest,&rem_dest)) { fprintf(stderr,"Failed to exchange date between server and clients\n"); return 1; } user_comm.rdma_params->side = REMOTE; ctx_print_pingpong_data(&rem_dest,&user_comm); if (user_param.work_rdma_cm == OFF) { if (pp_connect_ctx(&ctx,my_dest.psn,&rem_dest,my_dest.out_reads,&user_param)) { fprintf(stderr," Unable to Connect the HCA's through the link\n"); return 1; } } // An additional handshake is required after moving qp to RTR. if (ctx_hand_shake(&user_comm,&my_dest,&rem_dest)) { fprintf(stderr,"Failed to exchange date between server and clients\n"); return 1; } ALLOCATE(tstamp,cycles_t,user_param.iters); // Only Client post read request. if (user_param.machine == SERVER) { if (ctx_close_connection(&user_comm,&my_dest,&rem_dest)) { fprintf(stderr,"Failed to close connection between server and client\n"); return 1; } printf(RESULT_LINE); return 0; // destroy_ctx(&ctx,&user_param); } if (user_param.use_event) { if (ibv_req_notify_cq(ctx.send_cq, 0)) { fprintf(stderr, "Couldn't request CQ notification\n"); return 1; } } printf(RESULT_LINE); printf(RESULT_FMT_LAT); if (user_param.all == ON) { for (i = 1; i < 24 ; ++i) { user_param.size = 1 << i; if(run_iter(&ctx,&user_param,&rem_dest)) return 17; print_report(&user_param); } } else { if(run_iter(&ctx,&user_param,&rem_dest)) return 18; print_report(&user_param); } if (ctx_close_connection(&user_comm,&my_dest,&rem_dest)) { fprintf(stderr,"Failed to close connection between server and client\n"); return 1; } printf(RESULT_LINE); return 0; // destroy_ctx(&ctx,&user_param); }
int main(int argc, char** argv) { struct timeval start_time, end_time; readstat_error_t error = READSTAT_OK; char *input_filename = NULL; char *catalog_filename = NULL; char *output_filename = NULL; if (argc == 2 && (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0)) { print_version(); return 0; } else if (argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)) { print_usage(argv[0]); return 0; } if (argc == 3) { if (!can_read(argv[1]) || !can_write(argv[2])) { print_usage(argv[0]); return 1; } input_filename = argv[1]; output_filename = argv[2]; } else if (argc == 4) { if (!can_read(argv[1]) || !is_catalog(argv[2]) || !can_write(argv[3])) { print_usage(argv[0]); return 1; } input_filename = argv[1]; catalog_filename = argv[2]; output_filename = argv[3]; } else { print_usage(argv[0]); return 1; } int input_format = format(input_filename); int output_format = format(output_filename); gettimeofday(&start_time, NULL); int fd = open(output_filename, O_CREAT | O_WRONLY | O_EXCL, 0644); if (fd == -1) { dprintf(STDERR_FILENO, "Error opening %s for writing: %s\n", output_filename, strerror(errno)); return 1; } readstat_parser_t *pass1_parser = readstat_parser_init(); readstat_parser_t *pass2_parser = readstat_parser_init(); readstat_writer_t *writer = readstat_writer_init(); readstat_writer_set_file_label(writer, "Created by ReadStat <https://github.com/WizardMac/ReadStat>"); rs_ctx_t *rs_ctx = ctx_init(); rs_ctx->writer = writer; rs_ctx->out_fd = fd; rs_ctx->out_format = output_format; readstat_set_data_writer(writer, &write_data); // Pass 1 - Collect fweight and value labels readstat_set_error_handler(pass1_parser, &handle_error); readstat_set_info_handler(pass1_parser, &handle_info); readstat_set_value_label_handler(pass1_parser, &handle_value_label); readstat_set_fweight_handler(pass1_parser, &handle_fweight); if (catalog_filename) { error = parse_file(pass1_parser, catalog_filename, RS_FORMAT_SAS_CATALOG, rs_ctx); } else { error = parse_file(pass1_parser, input_filename, input_format, rs_ctx); } if (error != READSTAT_OK) goto cleanup; // Pass 2 - Parse full file readstat_set_error_handler(pass2_parser, &handle_error); readstat_set_info_handler(pass2_parser, &handle_info); readstat_set_variable_handler(pass2_parser, &handle_variable); readstat_set_value_handler(pass2_parser, &handle_value); error = parse_file(pass2_parser, input_filename, input_format, rs_ctx); if (error != READSTAT_OK) goto cleanup; gettimeofday(&end_time, NULL); dprintf(STDERR_FILENO, "Converted %ld variables and %ld rows in %.2lf seconds\n", rs_ctx->var_count, rs_ctx->row_count, (end_time.tv_sec + 1e-6 * end_time.tv_usec) - (start_time.tv_sec + 1e-6 * start_time.tv_usec)); cleanup: readstat_parser_free(pass1_parser); readstat_parser_free(pass2_parser); readstat_writer_free(writer); ctx_free(rs_ctx); close(fd); if (error != READSTAT_OK) { dprintf(STDERR_FILENO, "%s\n", readstat_error_message(error)); unlink(output_filename); return 1; } return 0; }
int main(int argc, char **argv) { t_context *C = ctx_init(argc,argv); app_launch(C->app); return 0; }