Beispiel #1
0
int main (int argc, char *argv[]) {
   int i;
   int sects;
   int time1;
   int ticks;
   int rate = ae_getrate ();
   int bpms;
   char *buf;
   int diskno;

   if (argc != 2) {
      printf ("Usage: %s <diskno>\n", argv[0]);
      exit (0);
   }
   diskno = atoi(argv[1]);

   buf = malloc (BUF_SIZE);
   assert (buf != NULL);
   assert (((u_int)buf % 4096) == 0);
   bzero (buf, BUF_SIZE);

printf ("Read Bandwidth\n");

   for (sects = 1; sects <= TEST_MAXSIZE; sects *= 2) {
      time1 = ae_gettick ();

      for (i = START_SECT; (i+sects) <= (START_SECT + MAX_NUMSECTS); i += sects) {
         do_io (diskno, i, (sects * SECT_SIZE), &buf[((i-START_SECT) * SECT_SIZE)], B_READ);
      }

      ticks = max (1, (ae_gettick () - time1));
      bpms = (MAX_NUMSECTS * SECT_SIZE) / (ticks * rate / 1000) * 1000;
      printf ("block_size %5d, bytes/sec %4d, ticks %d\n",
               (sects * SECT_SIZE), bpms, ticks);
   }

printf ("\n");
  
printf ("Write Bandwidth\n");

   for (sects = 1; sects <= TEST_MAXSIZE; sects *= 2) {
      time1 = ae_gettick ();

      for (i = START_SECT; (i+sects) <= (START_SECT + MAX_NUMSECTS); i += sects) {
/*
printf ("going to write block %d for %d sectors\n", i, sects);
*/
         do_io (diskno, i, (sects * SECT_SIZE), &buf[((i-START_SECT) * SECT_SIZE)], B_WRITE);
      }

      ticks = max (1, (ae_gettick () - time1));
      bpms = (MAX_NUMSECTS * SECT_SIZE) / (ticks * rate / 1000) * 1000;
      printf ("block_size %5d, bytes/sec %4d, ticks %d\n",
               (sects * SECT_SIZE), bpms, ticks);

   }

   printf ("completed successfully\n");
   exit (0);
}
Beispiel #2
0
	bool app::process_events(i_event_processing_context&)
	{
		bool didSome = false;
		try
		{
			didSome = pump_messages();
			didSome = (do_io(neolib::yield_type::Sleep) || didSome);
			didSome = (do_process_events() || didSome);
			rendering_engine().render_now();
		}
		catch (std::exception& e)
		{
			if (!halted())
			{
				halt();
				std::cerr << "neogfx::app::process_events: terminating with exception: " << e.what() << std::endl;
				iSurfaceManager->display_error_message(iName.empty() ? "Abnormal Program Termination" : "Abnormal Program Termination - " + iName, std::string("neogfx::app::process_events: terminating with exception: ") + e.what());
				std::exit(EXIT_FAILURE);
			}
		}
		catch (...)
		{
			if (!halted())
			{
				halt();
				std::cerr << "neogfx::app::process_events: terminating with unknown exception" << std::endl;
				iSurfaceManager->display_error_message(iName.empty() ? "Abnormal Program Termination" : "Abnormal Program Termination - " + iName, "neogfx::app::process_events: terminating with unknown exception");
				std::exit(EXIT_FAILURE);
			}
		}
		return didSome;
	}
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;
}
int max_ctx_on_plun(int cmd)
{
    int i;
    int rc = 0;
    struct ctx myctx;
    struct ctx *p_ctx=&myctx;
    pid = getpid();
    pthread_t thread;
    int max_p = MAX_OPENS;
    for (i=0; i<max_p;i++)
    {
        if (0==fork())
        {
            //child process
            pid = getpid();
            debug("%d: ......process %d created...\n",pid,i);
            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 failed %s, errno %d\n",cflash_path, errno);
                exit(rc);
            }
#ifdef _AIX
            rc |= ioctl_dk_capi_query_path(p_ctx);
            rc|=ctx_init_internal(p_ctx, 0, p_ctx->devno);
#else
            rc|=ctx_init_internal(p_ctx, 0x2, p_ctx->devno);
#endif
            if (2 == cmd)
                rc |=create_resource(p_ctx,0,0,LUN_VIRTUAL);
            if (3 == cmd)
                rc |=create_resource(p_ctx,0,0,LUN_DIRECT);
            if (4 == cmd)
            {
                //do io all vluns created on path_id_mask
                pthread_create(&thread, NULL,ctx_rrq_rx,p_ctx);
                rc |= create_resource(p_ctx,p_ctx->chunk_size,0,LUN_VIRTUAL);
                rc |= do_io(p_ctx,0x10);

                pthread_cancel(thread);
            }
            sleep(10); //lets all context get created
            if ( 1 != cmd )
                rc|=close_res(p_ctx);
            rc|=ctx_close(p_ctx);
            debug("%d:.exiting with rc=%d\n",pid,rc);
            exit(rc);
        }
    }
    rc=wait4all();
    return rc;
}
Beispiel #5
0
int main()
{
  tty_mode(0);
  signal(SIGQUIT, SIG_IGN);
  signal(SIGINT, ctrl_c_handler);
  set_crmode();
  // set_nodelay_mode();
  int ret;
  ret = atexit(exit_reset_mode);
  if(ret != 0) {
    perror("atexit");
    exit(1);
  }

  do_io();
}
Beispiel #6
0
// creating thread for creation VLUN or PLUN
void *create_lun1(void *arg )
{
    struct ctx *p_ctx = (struct ctx *)arg;
    int rc;
    __u64 stride=0x8;
    rc = create_resource(p_ctx, p_ctx->lun_size, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
    if ( rc == 0 )
    {
        rc = do_io(p_ctx, stride);
        if ( rc !=0 )
        {   fprintf(stderr,"io failed on attached LUN\n");
            //TBD Fix this return 2;
            return NULL;
        }
    }
    //TBD Fix this return 1;
    //return 1;
    return NULL;
}
void* res_thread(void *arg)
{
    int rc;
    struct ctx *p_ctx = (struct ctx *)arg;
    res_hndl_t res_hndl;
    __u64 rsrc_handle;
    __u64 stride = 0x1000;

    pthread_mutex_lock(&mutex);
    rc = create_resource(p_ctx, p_ctx->lun_size, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
    res_hndl = p_ctx->res_hndl;
    rsrc_handle = p_ctx->rsrc_handle;
    if (rc)
    {
        g_error = -1;
        pthread_mutex_unlock(&mutex);
        return NULL;
    }
    p_ctx->res_hndl = res_hndl;
    rc = do_io(p_ctx, stride);
    if (rc)
    {
        g_error = -1;
        pthread_mutex_unlock(&mutex);
        return NULL;
    }
    pthread_mutex_unlock(&mutex);
    sleep(1);

    // Closing the resource after IO done
    sleep(2);
    pthread_mutex_lock(&mutex);
    p_ctx->rsrc_handle = rsrc_handle;
    rc = close_res(p_ctx);
    pthread_mutex_unlock(&mutex);
    return 0;
}
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;
}
Beispiel #9
0
	void io_thread::task()
	{
		while(!finished())
			do_io(yield_type::Sleep);
	}
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;
}
Beispiel #11
0
void a2bus_ssramcard_device::write_c0nx(address_space &space, UINT8 offset, UINT8 data)
{
	do_io(offset & 0xf);
}
Beispiel #12
0
int main(int argc, char *argv[])
{
    struct option long_opts[] = {
        { "async",         no_argument,       NULL, 'a' },
        { "break",         no_argument,       NULL, 'b' },
        { "disk",          required_argument, NULL, 'd' },
        { "get-status",    no_argument,       NULL, 'G' },
        { "help",          no_argument,       NULL, 'h' },
        { "list-statuses", no_argument,       NULL, 'L' },
        { "offset",        required_argument, NULL, 'o' },
/*      { "random",        no_argument,       NULL, 'r' }, */
        { "size",          required_argument, NULL, 's' },
        { "set-status",    required_argument, NULL, 'S' },
        { "write",         no_argument,       NULL, 'w' },
        { NULL,            0,                 NULL, '\0' }
    };
    int long_idx;
    int opt;
    enum {
        OP_IO,
        OP_LIST_STATUSES,
        OP_GET_STATUS,
        OP_SET_STATUS,
        OP_DEACTIVATE_DEVICE
    } op = OP_IO;
    char *disk_path = NULL;
/*     bool random = false; */
    bool async = false;
    bool write = false;
    uint64_t size_in_bytes = 0;
    uint64_t offset = 0;
    char status_str[256] = "";
    int err;

#ifdef WIN32
    os_windows_disable_crash_popup();
#endif

    program = argv[0];

    if (argc == 1)
    {
	fprintf(stderr, "%s: no option given\nType %s --help for usage help\n",
                program, program);
	return -1;
    }

    while (true)
    {
	opt = os_getopt_long(argc, argv, "ad:bGhLo:r:s:wS:", long_opts, &long_idx);
        /* Missing argument, quit right away (os_getopt_long() takes care of
         * printing an error message) */
        if (opt == ':' || opt == '?')
            return 1;

        if (opt == -1)
            break;

	switch (opt)
	{
	case 'a':
	    async = true;
	    break;

	case 'b':
	    op = OP_DEACTIVATE_DEVICE;
	    break;

	case 'd':
	    disk_path = optarg;
	    break;

        case 'G':
            op = OP_GET_STATUS;
            break;

	case 'h':
	    usage();
	    break;

        case 'L':
            op = OP_LIST_STATUSES;
            break;

	case 'o':
            if (to_uint64(optarg, &offset) != EXA_SUCCESS)
            {
                fprintf(stderr, "invalid offset\n");
                exit(1);
            }
	    break;

/* 	case 'r': */
/* 	    random = true; */
/* 	    break; */

	case 's':
            if (to_uint64(optarg, &size_in_bytes) != EXA_SUCCESS)
            {
                fprintf(stderr, "invalid size\n");
                exit(1);
            }
	    break;

	case 'w':
	    write = true;
	    break;

        case 'S':
            op = OP_SET_STATUS;
            strlcpy(status_str, optarg, sizeof(status_str));
            break;
	}
    }

    if (optind < argc)
    {
        fprintf(stderr, "%s: too many arguments\nType %s --help for usage help\n",
                program, program);
        return 1;
    }

    err = exa_rdev_static_init(RDEV_STATIC_GET);
    if (err != 0)
    {
        fprintf(stderr, "failed initializating RDEV statics: error %d\n", err);
        fprintf(stderr, "\tExanodes is probably not running on this node.\n");
        return 1;
    }

    if (disk_path == NULL && op != OP_LIST_STATUSES)
    {
        fprintf(stderr, "no disk path specified\n");
        err = -1;
        goto done;
    }

    switch (op)
    {
    case OP_IO:
        err = do_io(disk_path, async, write, offset, size_in_bytes);
        break;

    case OP_LIST_STATUSES:
        err = list_statuses();
        break;

    case OP_GET_STATUS:
        err = do_status(disk_path, 'g', NULL);
        break;

    case OP_SET_STATUS:
        err = do_status(disk_path, 's', status_str);
        break;

    case OP_DEACTIVATE_DEVICE:
	err = deactivate_device(disk_path);
	break;
    }

done:
    exa_rdev_static_clean(RDEV_STATIC_RELEASE);
    return err ? 1 : 0;
}
Beispiel #13
0
void a2bus_ssramcard_device::write_c0nx(address_space &space, uint8_t offset, uint8_t data)
{
	do_io(offset & 0xf);
}
	void io_thread::task()
	{
		while(!finished())
			do_io();
	}
int test_spio_vlun(int cmd)
{
    int rc;
    struct ctx myctx;
    struct ctx *p_ctx = &myctx;
    pthread_t thread;

    __u64 chunk = 0x10;
    __u64 nlba;
    __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);
    if (3 == cmd)
    {
        //IO ON NO RES expect AFURC
        p_ctx->last_lba = chunk * p_ctx->chunk_size -1;
        rc = do_io(p_ctx, stride);
        pthread_cancel(thread);
        ctx_close(p_ctx);
        return rc;
    }

    //create 0 vlun size & later call resize ioctl
    if (1 == cmd)
    {
        //0 size
        debug("%d: create VLUN with 0 size\n", pid);
        rc = create_resource(p_ctx, 0, DK_UVF_ASSIGN_PATH, LUN_VIRTUAL);
        CHECK_RC(rc, "create LUN_VIRTUAL failed");
#ifdef _AIX
        rc = compare_size(p_ctx->last_lba, 0);
#else
        rc = compare_size(p_ctx->last_lba, -1);
#endif
        CHECK_RC(rc, "failed compare_size");
        p_ctx->last_lba=0xFFFF;
        rc = do_io(p_ctx,stride);
        if (rc != 0x13 )
        {
            CHECK_RC(1,"IO should fail with afu_rc=0x13\n");
        }
        else
        {
            fprintf(stderr, "IO failed as expected, don't worry....\n");
            g_error=0;
            rc=0;
        }
    }
    else
    {
        nlba = 1 * (p_ctx->chunk_size);
        rc = create_resource(p_ctx, nlba, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
        CHECK_RC(rc, "create LUN_VIRTUAL failed");
        rc = compare_size(p_ctx->last_lba, nlba-1);
        CHECK_RC(rc, "failed compare_size");
    }
    nlba = chunk * (p_ctx->chunk_size);
    rc = vlun_resize(p_ctx, nlba);
    CHECK_RC(rc, "vlun_resize failed");
    rc = compare_size(p_ctx->last_lba, nlba-1);
    CHECK_RC(rc, "failed compare_size");

    //i would like to write/read all lbas
    //stride = p_ctx->blk_len;

    rc |= do_io(p_ctx, stride);
    rc |= vlun_resize(p_ctx, 0);
    rc |= vlun_resize(p_ctx, nlba);
    rc |= do_io(p_ctx, stride);

    pthread_cancel(thread);
    close_res(p_ctx);
    ctx_close(p_ctx);
    rc |= g_error;
    return rc;
}
//int create_res_hndl_afu_reset(char *dev, dev64_t devno, __u64 chunk)
int create_res_hndl_afu_reset(bool do_recover, bool last)
{
    int rc;
    struct ctx my_ctx;
    struct ctx *p_ctx = &my_ctx;
    //int i;
    pthread_t thread;
    __u64 chunk = 0x1;
    __u64 stride= 0x1;
    int msgid;
    struct mymsgbuf msg_buf;
    pthread_t ioThreadId;
    do_io_thread_arg_t ioThreadData;
    do_io_thread_arg_t * p_ioThreadData=&ioThreadData;
    // we have to export "NO_IO; if we want to avoid IO
    char * noIOP   = getenv("NO_IO");

    pid = getpid();
#ifdef _AIX
    memset(p_ctx,0,sizeof(my_ctx));
    strcpy(p_ctx->dev,cflash_path);
    if ((p_ctx->fd = open_dev(p_ctx->dev, O_RDWR)) < 0)
    {
        fprintf(stderr,"open failed %s, errno %d\n",p_ctx->dev, errno);
        return -1;
    }
    rc = ioctl_dk_capi_query_path(p_ctx);
    CHECK_RC(rc, "ioctl_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
    if ( noIOP == NULL )
        pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx);

    //create 0 vlun size & later call resize ioctl
    rc = create_resource(p_ctx, chunk * (p_ctx->chunk_size),
                         0, LUN_VIRTUAL);
    CHECK_RC(rc, "create LUN_VIRTUAL failed");

    //last new process send message to waiting process
    //that new ctx created now you can try to reattach
    msgid = msgget(key, IPC_CREAT | 0666);
    if (msgid < 0 )
    {
        fprintf(stderr, "%d: msgget() failed before msgsnd()\n", pid);
        return -1;
    }
    memset(&msg_buf, 0, sizeof(struct mymsgbuf));
    if (last)
    {
        goto end;
    }
    if ( noIOP == NULL )
    {
        p_ioThreadData->p_ctx=p_ctx;
        p_ioThreadData->stride=stride;
        p_ioThreadData->loopCount=0x100000; // Need this to go on 10 secs
        debug("%d: things look good, doing IO...\n",pid);
        rc =pthread_create(&ioThreadId,NULL, do_io_thread, (void *)p_ioThreadData);
        CHECK_RC(rc, "do_io_thread() pthread_create failed");
    }
#ifdef _AIX
    rc = do_eeh(p_ctx);
#else
    rc = do_poll_eeh(p_ctx);
#endif
    g_error=0; //reset any prev error might caught while EEH
    if ( noIOP == NULL )
    {
        pthread_join(ioThreadId, NULL);
    }
#ifndef _AIX //for linux
    if ( noIOP == NULL )
        pthread_cancel(thread);
#endif

    //We here after EEH done
    if (do_recover)
    {
        //do if recover true
        debug("%d: woow EEH is done recovering...\n",pid);
        rc = ioctl_dk_capi_recover_ctx(p_ctx);
        CHECK_RC(rc, "ctx reattached failed");
        msg_buf.mtype =2;
        strcpy(msg_buf.mtext, "K");
        if (msgsnd(msgid, &msg_buf, 2, IPC_NOWAIT) < 0)
        {
            fprintf(stderr, "%d: msgsnd failed\n", pid);
            return -1;
        }
#ifdef _AIX
        if (p_ctx->return_flags != DK_RF_REATTACHED)
            CHECK_RC(1, "recover ctx, expected DK_RF_REATTACHED");
        p_ctx->flags = DK_VF_HC_TUR;
        p_ctx->hint = DK_HINT_SENSE;
#endif
        fflush(stdout);
        ctx_reinit(p_ctx);
#ifdef _AIX
        p_ctx->hint=DK_HINT_SENSE;
#else
        p_ctx->hint=DK_CXLFLASH_VERIFY_HINT_SENSE;
        // if dummy_sense_flag is set;
        // a dummy sense data will be copied into ioctl input
        p_ctx->dummy_sense_flag=1; // if dummy_sense_flag is set;
#endif
        rc = ioctl_dk_capi_verify(p_ctx);
        CHECK_RC(rc, "ioctl_dk_capi_verify failed");
#ifndef _AIX //for linux
        pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx);
#endif
    }
    else
    {
        //last one is
        /*msgid = msgget(key, IPC_CREAT | 0666);
           if(msgid < 0 ){
                   fprintf(stderr, "%d: msgget() failed before msgrcv()\n", pid);
                   return -1;
           }
           debug("%d: Going to wait at msgrcv()..\n", pid);
           fflush(stdout);
           if(msgrcv(msgid, &msg_buf, 2, 1, 0) < 0) {
                   fprintf(stderr, "%d: msgrcv failed with errno %d\n", pid, errno);
                   return -1;
           }

           debug("%d: Got out of msgrcv()..EEH is done, Try to recover....\n",pid);
         */
        //as per today(9/28/2015) discussion with Sanket that
        //new attach will fail until holding context not exited
        //hope same apply for Linux as well
        return 100;
        /*rc = ioctl_dk_capi_recover_ctx(p_ctx);
           if(rc) return 100; //this to make sure recover failed
           else {
                   fprintf(stderr,"%d:com'on recover should fail here...\n",pid);
                   return 1; // we don't want to try IO anyway
           }*/
    }

end:
    if ( noIOP == NULL )
    {
        stride=0x1;
        rc = do_io(p_ctx, stride);
        CHECK_RC(rc, "IO failed after EEH/recover");
    }
    if ( noIOP == NULL )
        pthread_cancel(thread);
    sleep(1);
    fflush(stdout);
    sleep(5); // additional time to be safe !
    rc=close_res(p_ctx);

    sleep(5); // Don't let child exit to keep max ctx alive
    rc |= ctx_close(p_ctx);
    CHECK_RC(rc,"ctx close or close_res failed\n");
    return rc;
}
int test_spio_lun(char *dev, dev64_t devno,
                   __u16 lun_type, __u64 chunk)
{
    int rc;
    struct ctx myctx;
    struct ctx *p_ctx = &myctx;
    pthread_t thread;
    int loop=5;
    int i=0;

    __u64 nlba = 0;
    __u64 stride= 0x1000;

    pid = getpid();

    rc = ctx_init2(p_ctx, dev, DK_AF_ASSIGN_AFU, devno);
    CHECK_RC(rc, "Context init failed");

    //thread to handle AFU interrupt & events
    pthread_create(&thread, NULL, ctx_rrq_rx, p_ctx);

    if ( LUN_DIRECT == lun_type)
    {
        rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
        CHECK_RC(rc, "create LUN_DIRECT failed");
        if (long_run_enable) stride=0x100;
        rc = do_io(p_ctx, stride);
    }
    else
    {
        rc = create_resource(p_ctx, nlba,
                             DK_UVF_ALL_PATHS, LUN_VIRTUAL);
        CHECK_RC(rc, "create LUN_VIRTUAL failed");
        nlba = chunk * p_ctx->chunk_size;
        rc = vlun_resize(p_ctx, nlba);
        if (rc == 28)
        {
            fprintf(stderr, "%d:Requested was more..try with half now...\n",pid);
            nlba = nlba/2;
            rc = vlun_resize(p_ctx, nlba);
            if (rc == 28)
            {
                fprintf(stderr, "%d: No space left.. terminate this context..\n",pid);
                return 0;
            }
        }
        CHECK_RC(rc, "vlun_resize failed");
        if (long_run_enable)
        {
            stride=0x1;
            //loop=20;
        }
        while (i++<loop)
        {
            if (long_run_enable)
                printf("%d:IO loop %d(%d) started....\n",pid,i,loop);
            rc = do_io(p_ctx, stride);
            if (rc) break;
        }
    }

    usleep(1000); //let all process do io
    pthread_cancel(thread);
    close_res(p_ctx);
    ctx_close(p_ctx);
    return rc;
}
Beispiel #18
0
// 7.1.200 : Send signal to kill process when it has cmds queued.
int test_spio_killprocess()
{
    int rc;
    int isFailed=0;
    int i, nTimes;
    pid_t cpid;
    int cstat;
    struct ctx myctx;
    struct ctx *p_ctx = &myctx;
    struct sigaction action;
    sigset_t sigset;
    pthread_t threadId;
    __u64 chunk = 0x10;
    __u64 nlba;
    __u64 stride=0x1000;

    pid = getpid();

    sigemptyset(&sigset);
    sigprocmask(SIG_SETMASK, &sigset, NULL);

    // Set up the signal handler
    action.sa_handler = callme;
    action.sa_flags = 0;
    sigemptyset(&action.sa_mask);

    if (sigaction(SIGUSR1, &action, NULL) < 0)
        CHECK_RC(1, "sigaction() failed");

    char *str = getenv("LONG_RUN");
    if (str == NULL) nTimes=10;
    else nTimes=100;

    for (i=0; i<nTimes; i++)
    {
        rc = fork();
        if ( rc == -1 ) CHECK_RC(1, "fork() failed");

        // child process
        if ( rc == 0 )
        {
            debug("...... Child process: Iteration : %d .....\n",i);
            // pid used to create unique data patterns & logging from util !
            pid = getpid();

            //ctx_init with default flash disk & devno
            rc = ctx_init(p_ctx);
            CHECK_RC(rc, "Context init failed");

            //thread to handle AFU interrupt & events
            rc = pthread_create(&threadId, NULL, ctx_rrq_rx, p_ctx);
            CHECK_RC(rc, "pthread_create failed");

            // Test with vluns one after another
            if ( i < nTimes/5 )
            {
                nlba = chunk * p_ctx->chunk_size;
                //create vlun
                rc = create_resource(p_ctx,nlba, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
                CHECK_RC(rc, "create LUN_VIRTUAL failed");
            }
            // Test with pluns one after another
            else if ( i > nTimes/5 && i < 2*nTimes/5 )
            {
                // Create PLUN
                rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
                CHECK_RC(rc, "create LUN_DIRECT failed");
                stride=0x10000;
            }
            // Test with vluns/pluns alternately !
            else if ( i % 2 )
            {
                nlba = chunk * p_ctx->chunk_size;
                //create vlun
                rc = create_resource(p_ctx,nlba, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
                CHECK_RC(rc, "create LUN_VIRTUAL failed");
                stride=0x1000;
            }
            else
            {
                // Create PLUN
                rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
                CHECK_RC(rc, "create LUN_DIRECT failed");
                stride=0x10000;
            }

            rc = do_io(p_ctx, stride);

            // Signal parent to kill itself after this point.
            kill(getppid(), SIGUSR1);

            // Exit at this point if we failed in initial IO
            CHECK_RC_EXIT(rc, "Initial IO failed");

            // Keep driving IO till killed
            for (;;) do_io(p_ctx, stride);
        }
        // parent process
        else
        {
            pid = getpid();

            cpid = rc;
            // Wait for child to complete at-least 1 successful IO.
            pause();

            // Let the child IO go on some more time !
            sleep(1);

            // Send signal 9 - process can't ignore it;
            kill(cpid, 9);

            // Probe child's exit status.
            if ( wait(&cstat) == -1 )
                CHECK_RC(1, "Failed while wait() for child");

            // We don't expect child to exit itself
            if (WIFEXITED(cstat)) isFailed = 1;
            else if (WIFSIGNALED(cstat))
            {
                // We expect this !
                debug("%d :  killed by %d signal\n", cpid, WTERMSIG(cstat));
                if (WCOREDUMP(cstat))
                    fprintf(stderr, "%d :  was core dupmed ...\n", cpid);
            }

            debug("pid %d exited with rc = %d\n", cpid, cstat);
        }
    }

    return isFailed;
}
Beispiel #19
0
// 7.1.185 : EEH while super-pipe IO(VIRTUAL)(root user)
int test_vSpio_eehRecovery(int cmd)
{
    int rc;
    struct ctx myctx;
    struct ctx *p_ctx = &myctx;
    pthread_t threadId, ioThreadId, thread2;
    do_io_thread_arg_t ioThreadData;
    do_io_thread_arg_t * p_ioThreadData=&ioThreadData;
    __u64 chunk;
    __u64 nlba;
    __u64 stride= 0x1000;
    __u64 last_lba;

    // pid used to create unique data patterns & logging from util !
    pid = getpid();

    //ctx_init with default flash disk & devno
    rc = ctx_init(p_ctx);
    CHECK_RC(rc, "Context init failed");

    //thread to handle AFU interrupt & events
    rc = pthread_create(&threadId, NULL, ctx_rrq_rx, p_ctx);
    CHECK_RC(rc, "pthread_create failed");

    chunk = (p_ctx->last_phys_lba+1)/p_ctx->chunk_size;
    nlba = chunk * p_ctx->chunk_size;
    //create vlun
    rc = create_resource(p_ctx, nlba, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
    CHECK_RC(rc, "create LUN_VIRTUAL failed");

    // We wish to do IO in a different thread... Setting up for that !
    p_ioThreadData->p_ctx=p_ctx;
    p_ioThreadData->stride=stride;
    p_ioThreadData->loopCount=1000;
    rc = pthread_create(&ioThreadId,NULL, do_io_thread, (void *)p_ioThreadData);
    CHECK_RC(rc, "do_io_thread() pthread_create failed");

    //Trigger EEH
    rc = do_eeh(p_ctx);
    CHECK_RC(rc, "do_eeh() failed");

    // Wait for IO thread to complete
    pthread_join(ioThreadId, NULL);
#ifndef _AIX
    pthread_cancel(threadId);
#endif

    // Heading for context recovery using ioctl !
    //p_ctx->flags = DK_CAPI_REATTACHED;
    rc = ioctl_dk_capi_recover_ctx(p_ctx);
    CHECK_RC(rc, "ioctl_dk_capi_recover_ctx failed");

#ifdef _AIX
    if ( DK_RF_REATTACHED != p_ctx->return_flags )
#else
    if ( DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET != p_ctx->return_flags )
#endif
        CHECK_RC(1, "ioctl_dk_capi_recover_ctx flag verification failed");

    rc = ctx_reinit(p_ctx);
    CHECK_RC(rc, "ctx_reinit() failed");
#ifndef _AIX
    pthread_create(&thread2, NULL, ctx_rrq_rx, p_ctx);
#endif

    rc = do_io(p_ctx, stride);
    if ( rc == 2) rc=0;
    else CHECK_RC(rc, "1st IO attempt didn't fail");

#ifdef _AIX
    last_lba = p_ctx->last_phys_lba;
#else
    last_lba = p_ctx->last_lba;
#endif

#ifdef _AIX
    p_ctx->flags = DK_VF_HC_TUR;
    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");

#ifdef _AIX
    if ( 0 != p_ctx->return_flags )
        CHECK_RC(1, "ioctl_dk_capi_verify flag verification failed");
#endif
    if ( p_ctx->verify_last_lba != last_lba )
        CHECK_RC(1, "ioctl_dk_capi_verify last_lba verification failed");


    // After adapter reset,
    //  AFU interrupt monitoring thread need to be restarted.
    //rc = pthread_create(&threadId, NULL, ctx_rrq_rx, p_ctx);
    //CHECK_RC(rc, "pthread_create failed");

    // Re-start the io using new context
    if (2 == cmd)
    {
        //its for long run
#ifndef _AIX
        pthread_cancel(thread2);
#endif
        rc = keep_doing_eeh_test(p_ctx);
    }
    else
    {
        //its for one attempt, sanity check of eeh
        debug("%d:Try once more IO & expecting to pass this time..\n",pid);
        rc = do_io(p_ctx, stride);
        CHECK_RC(rc, "do_io() failed");
    }

#ifndef _AIX
    pthread_cancel(thread2);
#endif

    cleanup(p_ctx, threadId);

    return rc;
}
Beispiel #20
0
// 7.1.201 : Queue up commands, do not wait for completion and
// exit w/o detach/close,
// and do detach/close while commands in queue
int test_spio_exit()
{
    int rc;
    int isFailed=0;
    int i, nTimes;
    pid_t cpid;
    int cstat;
    struct ctx myctx;
    struct ctx *p_ctx = &myctx;
    pthread_t threadId, ioThreadId;
    do_io_thread_arg_t ioThreadData;
    do_io_thread_arg_t * p_ioThreadData=&ioThreadData;
    __u64 chunk = 0x10;
    __u64 nlba;
    __u64 stride= 0x10000;

    for (i=0, nTimes=50; i<nTimes; i++)
    {
        rc = fork();
        if ( rc == -1 ) CHECK_RC(1, "fork() failed");

        // child process
        if ( rc == 0 )
        {
            signal(SIGABRT, sig_handle);
            signal(SIGSEGV, sig_handle);
            // pid used to create unique data patterns & logging from util !
            pid = getpid();
            debug("...... Child process: Iteration : %d .....\n",i);
            //ctx_init with default flash disk & devno
            rc = ctx_init(p_ctx);
            CHECK_RC(rc, "Context init failed");

            //thread to handle AFU interrupt & events
            rc = pthread_create(&threadId, NULL, ctx_rrq_rx, p_ctx);
            CHECK_RC(rc, "pthread_create failed");

            // Test with vluns one after another
            if ( i < nTimes/5 )
            {
                nlba = chunk * p_ctx->chunk_size;
                //create vlun
                rc = create_resource(p_ctx,nlba, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
                CHECK_RC(rc, "create LUN_VIRTUAL failed");
            }
            // Test with pluns one after another
            else if ( i > nTimes/5 && i < 2*nTimes/5 )
            {
                // Create PLUN
                rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
                CHECK_RC(rc, "create LUN_DIRECT failed");
                stride = 0x10000;
            }
            // Test with vluns/pluns alternately !
            else if ( i % 2 )
            {
                nlba = chunk * p_ctx->chunk_size;
                //create vlun
                rc = create_resource(p_ctx,nlba, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
                CHECK_RC(rc, "create LUN_VIRTUAL failed");
            }
            else
            {
                // Create PLUN
                rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
                CHECK_RC(rc, "create LUN_DIRECT failed");
                stride = 0x10000;
            }

            // Make sure at-least 1 IO is successful before proceeding !
            rc = do_io(p_ctx, stride);
            CHECK_RC_EXIT(rc, "Initial IO attempt failed");

            // We wish to do IO in a different thread... Setting up for that !
            p_ioThreadData->p_ctx=p_ctx;
            p_ioThreadData->stride=stride;
            p_ioThreadData->loopCount=100;
            rc = pthread_create(&ioThreadId,NULL,
                                do_io_thread, (void *)p_ioThreadData);
            CHECK_RC_EXIT(rc, "do_io_thread() pthread_create failed");

            // Sleep for a sec before exiting
            sleep(1);

            if ( i % 2 )
            {
                debug("%d:Exiting w/o detach/close",pid);
            }
            else
            {
                debug("%d:Exiting after detach/close",pid);
                cleanup(p_ctx, threadId);
            }

            exit(10);
        }
        // parent process
        else
        {
            pid = getpid();

            cpid = rc;

            // 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))
            {
                debug("Exiting w/o getting killed %d \n",cpid);
                // We expect child to exit with rc 10 only !
                if ( WEXITSTATUS(cstat) != 10 ) isFailed=1;
            }
            else if (WIFSIGNALED(cstat))
            {
                //isFailed=1;
                debug("%d :  killed by %d signal\n", cpid, WTERMSIG(cstat));
                if (WCOREDUMP(cstat)) //expected if exiting without cancelling poll thread
                    fprintf(stderr, "%d :  was core dupmed ...\n", cpid);
            }

            debug("pid %d exited with rc = %d\n", cpid, cstat);
        }
    }

    return isFailed;
}
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 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;
}
Beispiel #23
0
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;

}
Beispiel #24
0
uint8_t a2bus_ssramcard_device::read_c0nx(address_space &space, uint8_t offset)
{
	do_io(offset & 0xf);
	return 0xff;
}
Beispiel #25
0
UINT8 a2bus_ssramcard_device::read_c0nx(address_space &space, UINT8 offset)
{
	do_io(offset & 0xf);
	return 0xff;
}
Beispiel #26
0
static void do_service(config_t *cpe, config_t *config, struct rs_config *rs_config)
{
	struct rs_start *rs_start = &rs_config->rs_start;
	config_t *cp;

	/* At this point we expect one sublist that contains the varios
	 * resource allocations
	 */
	if (!(cpe->flags & CFG_SUBLIST))
	{
		fatal("do_service: expected list at %s:%d",
			cpe->file, cpe->line);
	}
	if (cpe->next != NULL)
	{
		cpe= cpe->next;
		fatal("do_service: expected end of list at %s:%d",
			cpe->file, cpe->line);
	}
	cpe= cpe->list;

	/* Process the list */
	for (cp= cpe; cp; cp= cp->next)
	{
		if (!(cp->flags & CFG_SUBLIST))
		{
			fatal("do_service: expected list at %s:%d",
				cp->file, cp->line);
		}
		cpe= cp->list;
		if ((cpe->flags & CFG_STRING) || (cpe->flags & CFG_SUBLIST))
		{
			fatal("do_service: expected word at %s:%d",
				cpe->file, cpe->line);
		}

		if (strcmp(cpe->word, KW_CLASS) == 0)
		{
			do_class(cpe->next, config, rs_config);
			continue;
		}
		if (strcmp(cpe->word, KW_UID) == 0)
		{
			do_uid(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_SIGMGR) == 0)
		{
			do_sigmgr(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_TYPE) == 0)
		{
			do_type(cpe->next, rs_config);
			continue;
		}
		if (strcmp(cpe->word, KW_DESCR) == 0)
		{
			do_descr(cpe->next, rs_config);
			continue;
		}
		if (strcmp(cpe->word, KW_SCHEDULER) == 0)
		{
			do_scheduler(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_PRIORITY) == 0)
		{
			do_priority(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_QUANTUM) == 0)
		{
			do_quantum(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_CPU) == 0)
		{
			do_cpu(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_IRQ) == 0)
		{
			do_irq(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_IO) == 0)
		{
			do_io(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_PCI) == 0)
		{
			do_pci(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_SYSTEM) == 0)
		{
			do_system(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_IPC) == 0)
		{
			do_ipc(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_VM) == 0)
		{
			do_vm(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_CONTROL) == 0)
		{
			do_control(cpe->next, rs_start);
			continue;
		}
	}
}
int test_dcqexp_ioctl(int cnum)
{

    DEBUG_MORE("inside test_dcqexp_ioctl");
    int rc=0;
#ifdef _AIX
    __u64 stride=0x10;

    struct ctx u_ctx;
    struct exceptionPacket excpVar;
    struct exceptionPacket * excpPrt =&excpVar;

    pthread_t thread_intr;
    uint64_t  verify_exception;

    struct ctx *p_ctx = &u_ctx;
    struct ctx *p_ctx_backup = &u_ctx;
    struct dk_capi_exceptions exceptions;
    char errorMsg[MSG_LENGTH];
    pthread_t thread;
    pthread_mutexattr_t mattrVar;
    pthread_condattr_t cattrVar;

    pthread_mutexattr_init(&mattrVar);
    pthread_condattr_init(&cattrVar);

    pthread_mutex_init(&excpPrt->mutex , &mattrVar);
    pthread_cond_init(&excpPrt->cv , &cattrVar);

    __u64 chunk   =0;
    __u64 nlba    =0;

    memset(p_ctx, 0, sizeof(struct ctx));
    memset(excpPrt, 0, sizeof(struct exceptionPacket));
    memset(errorMsg, 0, MSG_LENGTH+1);

    rc = ctx_init(p_ctx);
    CHECK_RC(rc, "Context init failed");

    pthread_create(&thread_intr, NULL, ctx_rrq_rx, p_ctx);

    excpPrt->excpCtx = p_ctx ;

    /* Started do_poll_for_event thread until desired exception generated*/
    pthread_create(&thread,NULL,do_poll_for_event, excpPrt);

    sleep(5); // its rare but still avoiding race condition

    switch (cnum)
    {
        case EXCP_VLUN_DISABLE: // 7.1.230

            nlba = p_ctx->last_phys_lba + 1;

            rc = create_resource(p_ctx, nlba, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
            CHECK_RC(rc, "Create resource failed \n");

            debug(" ----------- Please unmap disk from the host now -------\n");

            *p_ctx_backup=*p_ctx;

            debug(" ------ Let the I/O start and then do UA stuff at texan--------\n");

            do
            {
                rc = do_io(p_ctx, stride);
                if (rc !=0)
                {
                    debug("rc=%d,IO failed..... bye from loop\n",rc);
                    break;
                }
                else
                {
                    debug("rc=%d,IO succeeded \n",rc);
                }
                *p_ctx=*p_ctx_backup;

            }while ( rc ==0);


            g_error=0;

            p_ctx->flags = DK_VF_HC_TUR;
            p_ctx->hint = DK_HINT_SENSE;
            rc = ioctl_dk_capi_verify(p_ctx);
            CHECK_RC(rc, "dk_capi_verify FAILED\n");

            pthread_mutex_lock( &excpPrt->mutex );

            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }

            p_ctx->flags=DK_QEF_ALL_RESOURCE;


            rc = ioctl_dk_capi_query_exception(p_ctx);
            CHECK_RC(rc, "dk_capi_query FAILED\n");
            verify_exception=DK_CE_PATH_LOST|DK_CE_VERIFY_IN_PROGRESS;
            if ( p_ctx->exceptions != verify_exception )
            {
                rc=255; /* Non zero rc value */
                debug("%d: expected : 0x%llx and recieved : 0x%llx\n", pid, verify_exception, p_ctx->exceptions);
                strcpy(errorMsg, "Fail:EXCP_VLUN_DISABLE:bad excp");
                goto xerror;
            }

            break ;

        case EXCP_PLUN_DISABLE: // 7.1.230

            rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
            CHECK_RC(rc, "create LUN_DIRECT failed");

            debug(" ----------- Please unmap disk from the host now -------\n");

            *p_ctx_backup=*p_ctx;

            debug(" ------ Let the I/O start and then do UA stuff at texan--------\n");

            do
            {
                rc = do_io(p_ctx, stride);
                if (rc !=0)
                {
                    debug("rc=%d,IO failed..... bye from loop\n",rc);
                    break;
                }
                else
                {
                    debug("rc=%d,IO succeeded \n",rc);
                }
                *p_ctx=*p_ctx_backup;

            }while ( rc ==0);


            g_error=0;

            p_ctx->flags = DK_VF_HC_TUR;
            p_ctx->hint = DK_HINT_SENSE;
            rc = ioctl_dk_capi_verify(p_ctx);
            CHECK_RC(rc, "dk_capi_verify FAILED\n");

            pthread_mutex_lock( &excpPrt->mutex );

            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }

            p_ctx->flags=DK_QEF_ALL_RESOURCE;
            rc = ioctl_dk_capi_query_exception(p_ctx);
            CHECK_RC(rc, "dk_capi_query FAILED\n");
            verify_exception=DK_CE_PATH_LOST|DK_CE_VERIFY_IN_PROGRESS;
            if ( p_ctx->exceptions != verify_exception )
            {
                rc=255; /* Non zero rc value */
                strcpy(errorMsg, "Fail:EXCP_VLUN_DISABLE:bad excp");
                goto xerror;
            }

            break ;
        case EXCP_VLUN_VERIFY: // 7.1.232 //7.1.225

            chunk = 0x10;
            rc = create_resource(p_ctx, 0, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
            CHECK_RC(rc, "Create resource failed \n");
            nlba = chunk * (p_ctx->chunk_size);
            rc = vlun_resize(p_ctx, nlba);

            //TBD input need to check once
            // Heading for verification using ioctl
            p_ctx->flags = DK_VF_HC_TUR;
            p_ctx->hint = DK_HINT_SENSE;
            //strcpy(p_ctx->sense_data,"TBD");

            rc = ioctl_dk_capi_verify(p_ctx);
            CHECK_RC(rc, "failed : ioctl_dk_capi_verify()");
            pthread_mutex_lock( &excpPrt->mutex );

            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }

            // reset the flag
            exceptionDoneFlag=0;
            pthread_mutex_unlock(&excpPrt->mutex);

            p_ctx->flags=DK_QEF_ALL_RESOURCE;
            rc = ioctl_dk_capi_query_exception(p_ctx);

            CHECK_RC(rc, "dk_capi_query FAILED\n");

            verify_exception=DK_CE_VERIFY_IN_PROGRESS|DK_CE_VERIFY_SUCCEEDED;

            if ( p_ctx->exceptions != verify_exception )
            {
                rc=255; /* Non zero rc value */
                strcpy(errorMsg, "Fail:EXCP_VLUN_VERIFY:bad excp");
                goto xerror;

            }


            break;

        case EXCP_PLUN_VERIFY : // 7.1.232 // 7.1.225
            rc=ioctl_dk_capi_udirect(p_ctx);
            CHECK_RC(rc, "PLUN resource failed \n");

            //TBD input need to check once
            // Heading for verification using ioctl
            p_ctx->flags = DK_VF_HC_TUR;
            p_ctx->hint = DK_HINT_SENSE;

            rc = ioctl_dk_capi_verify(p_ctx);
            CHECK_RC(rc, "failed : ioctl_dk_capi_verify()");

            pthread_mutex_lock( &excpPrt->mutex );

            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }

            // reset the flag
            exceptionDoneFlag=0;
            pthread_mutex_unlock(&excpPrt->mutex);

            p_ctx->flags=DK_QEF_ALL_RESOURCE;
            rc = ioctl_dk_capi_query_exception(p_ctx);
            CHECK_RC(rc, "dk_capi_query FAILED\n");

            verify_exception=DK_CE_VERIFY_IN_PROGRESS|DK_CE_VERIFY_SUCCEEDED;

            if ( p_ctx->exceptions != verify_exception )
            {
                rc=255; /* Non zero rc value */
                strcpy(errorMsg, "Fail:EXCP_VLUN_VERIFY:bad excp");
                goto xerror;

            }

            break ;

        case EXCP_VLUN_INCREASE : //7.1.231
            rc = create_resource(p_ctx, 0, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
            CHECK_RC(rc, "Create resource failed \n");
            // Just increasing by 10 chunk
            nlba = 10 * (p_ctx->chunk_size);

            rc = vlun_resize(p_ctx, nlba);
            CHECK_RC(rc, "vlun_resize failedi\n");

            pthread_mutex_lock( &excpPrt->mutex );
            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }

            pthread_mutex_unlock(&excpPrt->mutex);

            p_ctx->flags=DK_QEF_ALL_RESOURCE;
            rc = ioctl_dk_capi_query_exception(p_ctx);
            CHECK_RC(rc, "dk_capi_query FAILED\n");

            if ( p_ctx->exceptions != DK_CE_SIZE_CHANGE )
            {
                rc=255; /* Non zero rc value */
                strcpy(errorMsg, "Fail:EXCP_PLUN_VERIFY:bad excp");
                goto xerror;
            }


            break;

        case EXCP_VLUN_REDUCE : //7.1.233
            //  taking all the vlun
            nlba = p_ctx->last_phys_lba + 1;

            rc = create_resource(p_ctx, nlba, DK_UVF_ALL_PATHS, LUN_VIRTUAL);
            CHECK_RC(rc, "Create resource failed \n");

            debug("---------- Waiting at poll().. Please decrease Disk size in texan box -----\n");
            pthread_mutex_lock( &excpPrt->mutex );
            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }

            pthread_mutex_unlock(&excpPrt->mutex);

            p_ctx->flags=DK_QEF_ALL_RESOURCE;

            rc = ioctl_dk_capi_query_exception(p_ctx);
            CHECK_RC(rc, "dk_capi_query FAILED\n");

            if ( p_ctx->exceptions != DK_CE_VLUN_TRUNCATED)
            {
                rc=255; /* Non zero rc value */
                strcpy(errorMsg, "Fail:EXCP_PLUN_VERIFY:bad excp");
                goto xerror;
            }

            break;

        case  EXCP_VLUN_UATTENTION : // going to manual 7.1.234

            nlba = p_ctx->last_phys_lba + 1;

            rc = create_resource(p_ctx, nlba, DK_UVF_ALL_PATHS, LUN_VIRTUAL);

            CHECK_RC(rc, "Create resource failed \n");
            p_ctx_backup=p_ctx;


            debug(" ------ Let the I/O start and then do UA stuff at texan--------\n");

            do
            {
                rc = do_io(p_ctx, stride);
                if (rc !=0)
                {
                    debug("rc=%d,IO failed..... bye from loop\n",rc);
                    break;
                }
                else
                {
                    debug("rc=%d,IO succeeded \n",rc);
                }
                p_ctx=p_ctx_backup;

            }while ( rc ==0);

            g_error=0;
            p_ctx->flags = DK_VF_HC_TUR;
            p_ctx->hint = DK_HINT_SENSE;
            rc = ioctl_dk_capi_verify(p_ctx);
            debug("rc = %d , g_error =%d\n",rc,g_error);
            CHECK_RC(rc, "dk_capi_verify FAILED\n");

            debug(" -------- I am waiting at poll() for POLLPRI ---------- \n");

            pthread_mutex_lock( &excpPrt->mutex );
            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }
            pthread_mutex_unlock(&excpPrt->mutex);


            p_ctx->flags=DK_QEF_ALL_RESOURCE;

            rc = ioctl_dk_capi_query_exception(p_ctx);
            CHECK_RC(rc, "dk_capi_query FAILED\n");

            if ( p_ctx->exceptions != (DK_CE_UA_RECEIVED|DK_CE_VERIFY_IN_PROGRESS|DK_CE_VERIFY_SUCCEEDED|DK_CE_SIZE_CHANGE) )
            {
                rc=255; /* Non zero rc value */
                strcpy(errorMsg, "Fail:EXCP_VLUN_ATTENTION:bad excp");
                goto xerror;
            }

            break;

        case EXCP_PLUN_UATTENTION :

            rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
            CHECK_RC(rc, "create LUN_DIRECT failed");
            p_ctx_backup=p_ctx;


            debug(" ------ Let the I/O start and then do UA stuff at texan--------\n");

            do
            {
                rc = do_io(p_ctx, stride);
                if (rc !=0)
                {
                    debug("rc=%d,IO failed..... bye from loop\n",rc);
                    break;
                }
                else
                {
                    debug("rc=%d,IO succeeded \n",rc);
                }
                p_ctx=p_ctx_backup;

            }while ( rc ==0);

            g_error=0;
            p_ctx->flags = DK_VF_HC_TUR;
            p_ctx->hint = DK_HINT_SENSE;
            rc = ioctl_dk_capi_verify(p_ctx);
            debug("rc = %d , g_error =%d\n",rc,g_error);
            CHECK_RC(rc, "dk_capi_verify FAILED\n");

            debug(" -------- I am waiting at poll() for POLLPRI ---------- \n");


            pthread_mutex_lock( &excpPrt->mutex );
            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }
            pthread_mutex_unlock(&excpPrt->mutex);

            p_ctx->flags=DK_QEF_ALL_RESOURCE;

            rc = ioctl_dk_capi_query_exception(p_ctx);
            CHECK_RC(rc, "dk_capi_query FAILED\n");
            if ( p_ctx->exceptions != (DK_CE_UA_RECEIVED|DK_CE_VERIFY_IN_PROGRESS|DK_CE_VERIFY_SUCCEEDED|DK_CE_SIZE_CHANGE) )
            {
                rc=255; /* Non zero rc value */
                strcpy(errorMsg, "Fail:EXCP_PLUN_UATTENTION:bad excp");
                goto xerror;
            }

            break;

        case EXCP_EEH_SIMULATION : // 7.1.229

            rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
            CHECK_RC(rc, "Create resource failed \n");

            rc = do_eeh(p_ctx);
            CHECK_RC(rc, "do_eeh() failed");

            p_ctx->flags = DK_VF_HC_TUR;

            rc = ioctl_dk_capi_verify(p_ctx);
            CHECK_RC(rc, "failed : ioctl_dk_capi_verify()");


            pthread_mutex_lock( &excpPrt->mutex );
            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }

            pthread_mutex_unlock(&excpPrt->mutex);


            p_ctx->flags=DK_QEF_ADAPTER;
            rc = ioctl_dk_capi_query_exception(p_ctx);
            CHECK_RC(rc, "dk_capi_query FAILED\n");

            verify_exception=DK_CE_ADAPTER_EXCEPTION|DK_CE_VERIFY_IN_PROGRESS | DK_CE_VERIFY_SUCCEEDED ;
            if ( p_ctx->exceptions != verify_exception )
            {
                rc=255; /* Non zero rc value */
                strcpy(errorMsg, "Fail:EXCP_EEH_SIMULATION:bad excp");
                goto xerror;
            }

            // EEH code is still not tested

            if ( p_ctx->adap_except_count != 0 )
            {
                rc=255; // Non zero rc value
                strcpy(errorMsg, "Fail:EXCP_EEH_SIMULATION:bad excp");
                goto xerror;
            }

            if ( p_ctx->adap_except_type != DK_AET_EEH_EVENT|DK_AET_BAD_PF|DK_AET_AFU_ERROR )
            {
                rc=255;
                strcpy(errorMsg, "Fail:EXCP_EEH_SIMULATION:bad excp");
                goto xerror;
            }


            break;
        case EXCP_DISK_INCREASE : //7.1.226

            rc = create_resource(p_ctx, 0, DK_UDF_ASSIGN_PATH, LUN_DIRECT);
            CHECK_RC(rc, "create LUN_DIRECT failed");

            debug("---------- Please increase Disk size in texan box -----\n");
            debug("---------- You have 15 secs to do that -----\n");
            sleep(15);
            debug("---------- Sleep over. Moving on... -----\n");

            p_ctx->flags = DK_VF_HC_TUR;
            p_ctx->hint = 0;
            rc = ioctl_dk_capi_verify(p_ctx);
            CHECK_RC(rc, "dk_capi_verify FAILED\n");

            pthread_mutex_lock( &excpPrt->mutex );
            while ( exceptionDoneFlag!=1)
            {
                pthread_cond_wait(&excpPrt->cv,&excpPrt->mutex);
            }

            pthread_mutex_unlock(&excpPrt->mutex);

            p_ctx->flags=DK_QEF_ALL_RESOURCE;
            rc = ioctl_dk_capi_query_exception(p_ctx);
            CHECK_RC(rc, "dk_capi_query FAILED\n");

            verify_exception=DK_CE_VERIFY_IN_PROGRESS|DK_CE_VERIFY_SUCCEEDED|DK_CE_SIZE_CHANGE;
            if ( p_ctx->exceptions != verify_exception )
            {
                rc=255; /* Non zero rc value */
                debug("%d: expected : 0x%llx and recieved : 0x%llx\n", pid, verify_exception, p_ctx->exceptions);
                strcpy(errorMsg, "Fail:EXCP_DISK_INCREASE:bad excp");
                goto xerror;
            }

            break;

        default:
            rc = -1;
            break;
    }

xerror:

    pthread_mutexattr_destroy(&mattrVar);
    pthread_condattr_destroy(&cattrVar);
    pthread_cancel(thread);
    pthread_cancel(thread_intr);
    close_res(p_ctx);
    ctx_close(p_ctx);
    CHECK_RC(rc, errorMsg);
#endif
    return rc;

}