int mapper_router_remove_map(mapper_router rtr, mapper_map map) { // do not free local names since they point to signal's copy int i, j; if (!map || !map->local) return 1; // remove map and slots from router_signal lists if necessary if (map->destination.local->router_sig) { mapper_router_signal rs = map->destination.local->router_sig; for (i = 0; i < rs->num_slots; i++) { if (rs->slots[i] == &map->destination) { rs->slots[i] = 0; break; } } } else if (map->status >= STATUS_READY && map->destination.link) { --map->destination.link->num_maps[0]; check_link(rtr, map->destination.link); } free_slot_memory(&map->destination); for (i = 0; i < map->num_sources; i++) { if (map->sources[i]->local->router_sig) { mapper_router_signal rs = map->sources[i]->local->router_sig; for (j = 0; j < rs->num_slots; j++) { if (rs->slots[j] == map->sources[i]) { rs->slots[j] = 0; } } } else if (map->status >= STATUS_READY && map->sources[i]->link) { --map->sources[i]->link->num_maps[1]; check_link(rtr, map->sources[i]->link); } free_slot_memory(map->sources[i]); } // free buffers associated with user-defined expression variables if (map->local->expr_vars) { for (i = 0; i < map->local->num_var_instances; i++) { if (map->local->num_expr_vars) { for (j = 0; j < map->local->num_expr_vars; j++) { free(map->local->expr_vars[i][j].value); free(map->local->expr_vars[i][j].timetag); } } free(map->local->expr_vars[i]); } free(map->local->expr_vars); } if (map->local->expr) mapper_expr_free(map->local->expr); free(map->local); return 0; }
int main(int argc, char **argv) { int rc; err_setarg0(argv[0]); if (argc != 3) err_usage("oldname newname"); check_link("B1", argv[1]); check_link("B2", argv[2]); if ((rc = rename(argv[1], argv[2])) != 0) err_sysrem("rename(\"%s\", \"%s\") failed: ", argv[1], argv[2]); check_link("A1", argv[1]); check_link("A2", argv[2]); return rc; }
static void countline(int dir, struct field *line) { int i; int max; int counter = -1; struct count count; if (hori(dir)) max = XMAX; else max = YMAX; count.zero = count.one = count.num = 0; count.empty = -1; for (i=0; i<max; i++) { init_link(&(line[i])); make_count(counter, &(line[i]), &count); if (line[i].value == -1) count.empty = i; } fill_remain(max, line, count); make_link(max, line, count); check_link(max, line); counter = 0; count.zero = count.one = count.num = 0; count.empty = -1; for (i=0; i<max; i++) { counter = make_count(counter, &(line[i]), &count); if ((line[i].value == -1) && (line[i].link.x == -1)) count.empty = i; } fill_remain(max, line, count); }
int links(t_lem *lem, char *line) { int i; t_room *tmp; t_room *tmp_2; i = 0; tmp = lem->room; tmp_2 = lem->room; fill_buffer(lem, line); if (check_tiret(line) != 1) return(-1); while(line[i] && line[i] != '-') i++; tmp = check_link(lem, line, i); if (lem->match != 0) return (-3); tmp_2 = check_link(lem, &line[i + 1], ft_strlen(line) - i); if (lem->match != 0) return (-3); if (ft_strcmp(tmp->name, tmp_2->name) != 0) link_em(tmp, tmp_2); return (0); }
/* ARGSUSED2 */ static int dev_entry(const char *name, const struct stat *sp, int flags, struct FTW *ftwp) { int type; char target[MAXPATHLEN + 1]; int targetlen; struct symlink *slp; if (flags == FTW_NS) { /* couldn't stat the file */ (void) fprintf(stderr, gettext("%s: cannot stat %s\n"), progname, name); return (0); } if (flags == FTW_DNR) { /* couldn't read a directory */ (void) fprintf(stderr, gettext("%s: cannot read " "directory %s\n"), progname, name); return (0); } type = sp->st_mode & S_IFMT; if (type != S_IFLNK) return (0); name += 2; /* skip "./" */ targetlen = readlink(name, target, sizeof (target)); if (targetlen == -1) xperror(name); target[targetlen] = '\0'; slp = xmalloc(sizeof (struct symlink)); slp->linkname = xstrdup(name); slp->target = xstrdup(target); slp->already = 0; insert_link_sym(slp); check_link(slp); return (0); }
static int parse_line(t_env *env, t_parser *p) { int c_r; int c_l; if (p->line[0] == '\0') return (0); if (p->line[0] == '#' && p->line[1] == '#') { if (!check_start_end(env, p)) return (0); } else { if (!(c_r = check_room(env, p))) return (0); else if (!(c_l = check_link(env, p))) return (0); if (c_r == -1 && c_l == -1) return (0); } return (1); }
static FILE *openfile(const char *file) { FILE *fp; struct stat st; if (stat(file, &st) < 0) { logger(-1, errno, "Unable to stat %s", file); return NULL; } if (!S_ISREG(st.st_mode)) { logger(-1, errno, "password database %s is not regular file\n", file); return NULL; } if ((fp = fopen(file, "r")) == NULL) { logger(-1, errno, "Unable to open %s", file); return NULL; } if (check_link(file, fileno(fp))) { fclose(fp); return NULL; } return fp; }
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); }
void init() { set_and_wait(ma.mode.enable); set_and_wait(bufman.mode.enable); cpmu.control.hide_pcie_function = 7; cpmu.megabit_policy.mac_clock_switch = 0; cpmu.link_aware_policy.mac_clock_switch = 0; cpmu.d0u_policy.mac_clock_switch = 0; cpmu.link_idle_policy.mac_clock_switch = 0; cpmu.no_link_or_10mb_policy.mac_clock_switch = 0; rxcpu.mode.icache_pref_en = 1; grc.rxcpu_event.word = 0xffffffff; grc.rxcpu_event.word = 0; grc.fastboot_pc.addr = 0x8008000; grc.fastboot_pc.enable = 1; grc.rxcpu_event_enable.word = 0; grc.rxcpu_event_enable.emac = 1; if (gencomm[0] == 0x4b657654) state.flags |= HANDSHAKE_MAGIC_SEEN; else state.flags &= ~HANDSHAKE_MAGIC_SEEN; grc.misc_config.timer_prescaler = 0x7f; grc.power_management_debug.perst_override = 1; if (config.flags & CLOAK_EN) cloak_engage(); if (config.flags & LOCAL_CTRL) { cfg_port.bar_ctrl.bar0_sz = 1; lgate_setup(); } else { cfg_port.bar_ctrl.bar0_sz = 0; } cfg_port.bar_ctrl.rom_bar_sz = 0x6; grc.exp_rom_addr.base = read_nvram(0x1c); if (config.flags & OPROM_EN) pci.state.rom_enable = 1; ftq.reset.word = 0xffffffff; ftq.reset.word = 0; while (ftq.reset.word); emac.mode.port_mode = 2; set_and_wait(emac.mode.en_fhde); set_and_wait(emac.mode.en_rde); set_and_wait(emac.mode.en_tde); emac.mode.magic_packet_detection = 1; emac.mode.keep_frame_in_wol = 1; emac.event_enable.link_state_changed = 1; emac.rx_mac_mode.promiscuous_mode = 1; emac.tx_mac_mode.enable_bad_txmbuf_lockup_fix = 1; emac.tx_mac_lengths.slot = 0x20; emac.tx_mac_lengths.ipg_crs = 0x2; emac.tx_mac_lengths.ipg = 0x6; emac.mii_mode.enable_constant_mdc_clock_speed = 1; emac.mii_mode.phy_address = 1; emac.mii_mode.mii_clock_count = 0xb; set_and_wait(emac.tx_mac_mode.enable); set_and_wait(emac.rx_mac_mode.enable); wdma.mode.write_dma_pci_target_abort_attention_enable = 1; wdma.mode.write_dma_pci_master_abort_attention_enable = 1; wdma.mode.write_dma_pci_parity_error_attention_enable = 1; wdma.mode.write_dma_pci_host_address_overflow_error_attention_enable = 1; wdma.mode.write_dma_pci_fifo_overrun_attention_enable = 1; wdma.mode.write_dma_pci_fifo_underrun_attention_enable = 1; wdma.mode.write_dma_pci_fifo_overwrite_attention_enable = 1; set_and_wait(wdma.mode.enable); rdma.mode.read_dma_pci_target_abort_attention_enable = 1; rdma.mode.read_dma_pci_master_abort_attention_enable = 1; rdma.mode.read_dma_pci_parity_error_attention_enable = 1; rdma.mode.read_dma_pci_host_address_overflow_error_attention_enable = 1; rdma.mode.read_dma_pci_fifo_overrun_attention_enable = 1; rdma.mode.read_dma_pci_fifo_underrun_attention_enable = 1; rdma.mode.read_dma_pci_fifo_overread_attention_enable = 1; rdma.mode.read_dma_local_memory_write_longer_than_dma_length_attention_enable = 1; rdma.mode.jumbo_2k_mmrr_mode = 1; rdma.mode.hardware_ipv6_post_dma_processing_enable = 0; rdma.mode.in_band_vtag_enable = 0; rdma.mode.post_dma_debug_enable = 1; set_and_wait(rdma.mode.enable); set_and_wait(hc.mode.enable); nv_load_mac(state.my_mac); mac_cpy(state.my_mac, (void *)0xc0000412); gencomm[0] = 0xb49a89ab; pci.command.bus_master = 1; if (config.flags & PEER_CTRL) rx_setup(); if (config.flags & BEACON_EN) beacon(); check_link(); main(); }
int main(int argc, char *argv[]) { struct ibv_device *ib_dev = NULL; struct pingpong_context ctx; struct pingpong_dest *my_dest = NULL; struct pingpong_dest *rem_dest = NULL; struct perftest_parameters user_param; struct perftest_comm user_comm; struct mcast_parameters mcg_params; struct bw_report_data my_bw_rep, rem_bw_rep; int ret_parser,i = 0; int size_max_pow = 24; /* init default values to user's parameters */ memset(&ctx, 0,sizeof(struct pingpong_context)); memset(&user_param, 0 , sizeof(struct perftest_parameters)); memset(&mcg_params, 0 , sizeof(struct mcast_parameters)); memset(&user_comm, 0,sizeof(struct perftest_comm)); user_param.verb = SEND; user_param.tst = BW; strncpy(user_param.version, VERSION, sizeof(user_param.version)); /* Configure the parameters values according to user arguments or defalut values. */ ret_parser = parser(&user_param,argv,argc); if (ret_parser) { if (ret_parser != VERSION_EXIT && ret_parser != HELP_EXIT) fprintf(stderr," Parser function exited with Error\n"); return 1; } if((user_param.connection_type == DC || user_param.use_xrc) && user_param.duplex) { 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"); fprintf(stderr," For this we have raw_ethernet_bw test in this package.\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); if (user_param.transport_type == IBV_TRANSPORT_IWARP) ctx.send_rcredit = 1; /* 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; } if (ctx.send_rcredit) ctx_alloc_credit(&ctx,&user_param,my_dest); 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 credit for available recieve buffers is necessary, * the credit sending is done via RDMA WRITE ops and the ctx_hand_shake above * is used to exchange the rkeys and buf addresses for the RDMA WRITEs */ if (ctx.send_rcredit) ctx_set_credit_wqes(&ctx,&user_param,rem_dest); /* Joining the Send side port the Mcast gid */ if (user_param.use_mcg && (user_param.machine == CLIENT || user_param.duplex)) { memcpy(mcg_params.mgid.raw, rem_dest[0].gid.raw, 16); if (set_mcast_group(&ctx,&user_param,&mcg_params)) { fprintf(stderr," Unable to Join Sender to Mcast gid\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 client 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 CQ notification\n"); return 1; } if (ibv_req_notify_cq(ctx.recv_cq, 0)) { fprintf(stderr, " Couldn't request CQ notification\n"); return 1; } } if (user_param.output == FULL_VERBOSITY) { if (user_param.report_per_port) { printf(RESULT_LINE_PER_PORT); printf((user_param.report_fmt == MBS ? RESULT_FMT_PER_PORT : RESULT_FMT_G_PER_PORT)); } else { printf(RESULT_LINE); printf((user_param.report_fmt == MBS ? RESULT_FMT : RESULT_FMT_G)); } printf((user_param.cpu_util_data.enable ? RESULT_EXT_CPU_UTIL : RESULT_EXT)); } 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; if (user_param.machine == CLIENT || user_param.duplex) ctx_set_send_wqes(&ctx,&user_param,rem_dest); if (user_param.machine == SERVER || user_param.duplex) { if (ctx_set_recv_wqes(&ctx,&user_param)) { fprintf(stderr," Failed to post receive recv_wqes\n"); return 1; } } 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 (ctx.send_rcredit) { int j; for (j = 0; j < user_param.num_of_qps; j++) ctx.credit_buf[j] = 0; } if (user_param.duplex) { if(run_iter_bi(&ctx,&user_param)) return 17; } else if (user_param.machine == CLIENT) { if(run_iter_bw(&ctx,&user_param)) { return 17; } } else { if(run_iter_bw_server(&ctx,&user_param)) { return 17; } } print_report_bw(&user_param,&my_bw_rep); if (user_param.duplex && user_param.test_type != DURATION) { xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); print_full_bw_report(&user_param, &my_bw_rep, &rem_bw_rep); } 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; } /* Check if last iteration ended well in UC/UD */ if (user_param.check_alive_exited) { break; } } } else if (user_param.test_method == RUN_REGULAR) { if (user_param.machine == CLIENT || user_param.duplex) ctx_set_send_wqes(&ctx,&user_param,rem_dest); if (user_param.machine == SERVER || user_param.duplex) { if (ctx_set_recv_wqes(&ctx,&user_param)) { fprintf(stderr," Failed to post receive recv_wqes\n"); return 1; } } 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.duplex) { if(run_iter_bi(&ctx,&user_param)) return 17; } else if (user_param.machine == CLIENT) { if(run_iter_bw(&ctx,&user_param)) { return 17; } } else if(run_iter_bw_server(&ctx,&user_param)) { return 17; } print_report_bw(&user_param,&my_bw_rep); if (user_param.duplex && user_param.test_type != DURATION) { xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); print_full_bw_report(&user_param, &my_bw_rep, &rem_bw_rep); } if (user_param.report_both && user_param.duplex) { printf(RESULT_LINE); printf("\n Local results: \n"); printf(RESULT_LINE); printf((user_param.report_fmt == MBS ? RESULT_FMT : RESULT_FMT_G)); printf((user_param.cpu_util_data.enable ? RESULT_EXT_CPU_UTIL : RESULT_EXT)); print_full_bw_report(&user_param, &my_bw_rep, NULL); printf(RESULT_LINE); printf("\n Remote results: \n"); printf(RESULT_LINE); printf((user_param.report_fmt == MBS ? RESULT_FMT : RESULT_FMT_G)); printf((user_param.cpu_util_data.enable ? RESULT_EXT_CPU_UTIL : RESULT_EXT)); print_full_bw_report(&user_param, &rem_bw_rep, NULL); } } else if (user_param.test_method == RUN_INFINITELY) { if (user_param.machine == CLIENT) ctx_set_send_wqes(&ctx,&user_param,rem_dest); else if (user_param.machine == SERVER) { if (ctx_set_recv_wqes(&ctx,&user_param)) { fprintf(stderr," Failed to post receive recv_wqes\n"); return 1; } } 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.machine == CLIENT) { if(run_iter_bw_infinitely(&ctx,&user_param)) { fprintf(stderr," Error occured while running infinitely! aborting ...\n"); return 1; } } else if (user_param.machine == SERVER) { if(run_iter_bw_infinitely_server(&ctx,&user_param)) { fprintf(stderr," Error occured while running infinitely on server! aborting ...\n"); return 1; } } } if (user_param.output == FULL_VERBOSITY) { if (user_param.report_per_port) printf(RESULT_LINE_PER_PORT); else printf(RESULT_LINE); } if (ctx_close_connection(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr," Failed to close connection between server and client\n"); fprintf(stderr," Trying to close this side resources\n"); } /* Destory all test resources, including Mcast if exists */ if (send_destroy_ctx(&ctx,&user_param,&mcg_params)) { fprintf(stderr,"Couldn't Destory all SEND resources\n"); return FAILURE; } if (user_param.work_rdma_cm == ON) { user_comm.rdma_params->work_rdma_cm = ON; if (destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params)) { fprintf(stderr,"Failed to destroy resources\n"); return 1; } } if (!user_param.is_bw_limit_passed && (user_param.is_limit_bw == ON ) ) { fprintf(stderr,"Error: BW result is below bw limit\n"); return 1; } if (!user_param.is_msgrate_limit_passed && (user_param.is_limit_bw == ON )) { fprintf(stderr,"Error: Msg rate is below msg_rate limit\n"); return 1; } return 0; }
static void prepare_shaders(void) { static const char *fragShaderText = "void main() {\n" " gl_FragColor = gl_Color;\n" "}\n"; static const char *vertShaderText = "void main() {\n" " gl_FrontColor = gl_Color;\n" " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" "}\n"; static const char *geoShaderText = "#version 120\n" "#extension GL_ARB_geometry_shader4 : enable\n" "void main()\n" "{\n" " for(int i = 0; i < gl_VerticesIn; ++i)\n" " {\n" " gl_FrontColor = gl_FrontColorIn[i];\n" " gl_Position = gl_PositionIn[i];\n" " EmitVertex();\n" " }\n" "}\n"; if (!glutExtensionSupported("GL_ARB_geometry_shader4")) { fprintf(stderr, "needs GL_ARB_geometry_shader4 extension\n"); exit(1); } fragShader = glCreateShader(GL_FRAGMENT_SHADER); load_and_compile_shader(fragShader, fragShaderText); vertShader = glCreateShader(GL_VERTEX_SHADER); load_and_compile_shader(vertShader, vertShaderText); geoShader = glCreateShader(GL_GEOMETRY_SHADER_ARB); if (filename) read_shader(geoShader, filename); else load_and_compile_shader(geoShader, geoShaderText); program = glCreateProgram(); glAttachShader(program, vertShader); glAttachShader(program, geoShader); glAttachShader(program, fragShader); glProgramParameteriARB(program, GL_GEOMETRY_INPUT_TYPE_ARB, GL_TRIANGLES); glProgramParameteriARB(program, GL_GEOMETRY_OUTPUT_TYPE_ARB, GL_TRIANGLE_STRIP); { int temp; glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB,&temp); glProgramParameteriARB(program,GL_GEOMETRY_VERTICES_OUT_ARB,temp); } glLinkProgram(program); check_link(program); glUseProgram(program); }
int main(int argc, char *argv[]) { int ret_parser,i = 0; struct ibv_device *ib_dev = NULL; struct pingpong_context ctx; struct pingpong_dest *my_dest = NULL; struct pingpong_dest *rem_dest = NULL; struct perftest_parameters user_param; struct perftest_comm user_comm; struct bw_report_data my_bw_rep, rem_bw_rep; /* 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)); user_param.verb = READ; user_param.tst = BW; strncpy(user_param.version, VERSION, sizeof(user_param.version)); ret_parser = parser(&user_param,argv,argc); if (ret_parser) { if (ret_parser != VERSION_EXIT && ret_parser != HELP_EXIT) fprintf(stderr," Parser function exited with Error\n"); return 1; } if((user_param.connection_type == DC || user_param.use_xrc) && user_param.duplex) { user_param.num_of_qps *= 2; } ib_dev =ctx_find_dev(user_param.ib_devname); if (!ib_dev) return 7; /* 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. */ 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); 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.work_rdma_cm == OFF) { if (ctx_connect(&ctx,rem_dest,&user_param,my_dest)) { 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[0],&rem_dest[0])) { fprintf(stderr,"Failed to exchange data between server and clients\n"); return 1; } if (user_param.output == FULL_VERBOSITY) { if (user_param.report_per_port) { printf(RESULT_LINE_PER_PORT); printf((user_param.report_fmt == MBS ? RESULT_FMT_PER_PORT : RESULT_FMT_G_PER_PORT)); } else { printf(RESULT_LINE); printf((user_param.report_fmt == MBS ? RESULT_FMT : RESULT_FMT_G)); } printf((user_param.cpu_util_data.enable ? RESULT_EXT_CPU_UTIL : RESULT_EXT)); } /* For half duplex tests, server just waits for client to exit */ if (user_param.machine == SERVER && !user_param.duplex) { if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr," Failed to exchange data between server and clients\n"); return FAILURE; } xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); print_full_bw_report(&user_param, &rem_bw_rep, NULL); 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; } if (user_param.output == FULL_VERBOSITY) { if (user_param.report_per_port) printf(RESULT_LINE_PER_PORT); else printf(RESULT_LINE); } if (user_param.work_rdma_cm == ON) { if (destroy_ctx(&ctx,&user_param)) { fprintf(stderr, "Failed to destroy resources\n"); return 1; } user_comm.rdma_params->work_rdma_cm = ON; return destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params); } return 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; } } if (user_param.test_method == RUN_ALL) { for (i = 1; i < 24 ; ++i) { user_param.size = (uint64_t)1 << i; ctx_set_send_wqes(&ctx,&user_param,rem_dest); if(perform_warm_up(&ctx,&user_param)) { fprintf(stderr,"Problems with warm up\n"); return 1; } if(user_param.duplex) { if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr,"Failed to sync between server and client between different msg sizes\n"); return 1; } } if(run_iter_bw(&ctx,&user_param)) return 17; if (user_param.duplex && (atof(user_param.version) >= 4.6)) { if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr,"Failed to sync between server and client between different msg sizes\n"); return 1; } } print_report_bw(&user_param,&my_bw_rep); if (user_param.duplex) { xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); print_full_bw_report(&user_param, &my_bw_rep, &rem_bw_rep); } } } else if (user_param.test_method == RUN_REGULAR) { ctx_set_send_wqes(&ctx,&user_param,rem_dest); if(perform_warm_up(&ctx,&user_param)) { fprintf(stderr,"Problems with warm up\n"); return 1; } if(user_param.duplex) { if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr,"Failed to sync between server and client between different msg sizes\n"); return 1; } } if(run_iter_bw(&ctx,&user_param)) { fprintf(stderr," Failed to complete run_iter_bw function successfully\n"); return 1; } print_report_bw(&user_param,&my_bw_rep); if (user_param.duplex) { xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); print_full_bw_report(&user_param, &my_bw_rep, &rem_bw_rep); } if (user_param.report_both && user_param.duplex) { printf(RESULT_LINE); printf("\n Local results: \n"); printf(RESULT_LINE); printf((user_param.report_fmt == MBS ? RESULT_FMT : RESULT_FMT_G)); printf((user_param.cpu_util_data.enable ? RESULT_EXT_CPU_UTIL : RESULT_EXT)); print_full_bw_report(&user_param, &my_bw_rep, NULL); printf(RESULT_LINE); printf("\n Remote results: \n"); printf(RESULT_LINE); printf((user_param.report_fmt == MBS ? RESULT_FMT : RESULT_FMT_G)); printf((user_param.cpu_util_data.enable ? RESULT_EXT_CPU_UTIL : RESULT_EXT)); print_full_bw_report(&user_param, &rem_bw_rep, NULL); } } else if (user_param.test_method == RUN_INFINITELY) { ctx_set_send_wqes(&ctx,&user_param,rem_dest); if(run_iter_bw_infinitely(&ctx,&user_param)) { fprintf(stderr," Error occured while running! aborting ...\n"); return 1; } } if (user_param.output == FULL_VERBOSITY) { if (user_param.report_per_port) printf(RESULT_LINE_PER_PORT); else printf(RESULT_LINE); } /* For half duplex tests, server just waits for client to exit */ if (user_param.machine == CLIENT && !user_param.duplex) { if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { fprintf(stderr," Failed to exchange data between server and clients\n"); return FAILURE; } xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); } 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; } if (!user_param.is_bw_limit_passed && (user_param.is_limit_bw == ON ) ) { fprintf(stderr,"Error: BW result is below bw limit\n"); return 1; } if (!user_param.is_msgrate_limit_passed && (user_param.is_limit_bw == ON )) { fprintf(stderr,"Error: Msg rate is below msg_rate limit\n"); return 1; } if (user_param.work_rdma_cm == ON) { if (destroy_ctx(&ctx,&user_param)) { fprintf(stderr, "Failed to destroy resources\n"); return 1; } user_comm.rdma_params->work_rdma_cm = ON; return destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params); } return destroy_ctx(&ctx,&user_param); }
vmxnet3::vmxnet3(hw::PCI_Device& d, const uint16_t mtu) : Link(Link_protocol{{this, &vmxnet3::transmit}, mac()}, bufstore_), m_pcidev(d), m_mtu(mtu), bufstore_{1024, buffer_size_for_mtu(mtu)} { INFO("vmxnet3", "Driver initializing (rev=%#x)", d.rev_id()); assert(d.rev_id() == REVISION_ID); // find and store capabilities d.parse_capabilities(); // find BARs etc. d.probe_resources(); if (d.msix_cap()) { d.init_msix(); uint8_t msix_vectors = d.get_msix_vectors(); INFO2("[x] Device has %u MSI-X vectors", msix_vectors); assert(msix_vectors >= 3); if (msix_vectors > 2 + NUM_RX_QUEUES) msix_vectors = 2 + NUM_RX_QUEUES; for (int i = 0; i < msix_vectors; i++) { auto irq = Events::get().subscribe(nullptr); this->irqs.push_back(irq); d.setup_msix_vector(SMP::cpu_id(), IRQ_BASE + irq); } Events::get().subscribe(irqs[0], {this, &vmxnet3::msix_evt_handler}); Events::get().subscribe(irqs[1], {this, &vmxnet3::msix_xmit_handler}); for (int q = 0; q < NUM_RX_QUEUES; q++) Events::get().subscribe(irqs[2 + q], {this, &vmxnet3::msix_recv_handler}); } else { assert(0 && "This driver does not support legacy IRQs"); } // dma areas this->iobase = d.get_bar(PCI_BAR_VD); assert(this->iobase); this->ptbase = d.get_bar(PCI_BAR_PT); assert(this->ptbase); // verify and select version bool ok = check_version(); assert(ok); // reset device ok = reset(); assert(ok); // get mac address retrieve_hwaddr(); // check link status auto link_spd = check_link(); if (link_spd) { INFO2("Link up at %u Mbps", link_spd); } else { INFO2("LINK DOWN! :("); return; } // set MAC set_hwaddr(this->hw_addr); // initialize DMA areas this->dma = (vmxnet3_dma*) memalign(VMXNET3_DMA_ALIGN, sizeof(vmxnet3_dma)); memset(this->dma, 0, sizeof(vmxnet3_dma)); auto& queues = dma->queues; // setup tx queues queues.tx.cfg.desc_address = (uintptr_t) &dma->tx_desc; queues.tx.cfg.comp_address = (uintptr_t) &dma->tx_comp; queues.tx.cfg.num_desc = vmxnet3::NUM_TX_DESC; queues.tx.cfg.num_comp = VMXNET3_NUM_TX_COMP; queues.tx.cfg.intr_index = 1; // temp rxq buffer storage memset(tx.buffers, 0, sizeof(tx.buffers)); // setup rx queues for (int q = 0; q < NUM_RX_QUEUES; q++) { memset(rx[q].buffers, 0, sizeof(rx[q].buffers)); rx[q].desc0 = &dma->rx0_desc[0]; rx[q].desc1 = &dma->rx1_desc[0]; rx[q].comp = &dma->rx_comp[0]; rx[q].index = q; auto& queue = queues.rx[q]; queue.cfg.desc_address[0] = (uintptr_t) rx[q].desc0; queue.cfg.desc_address[1] = (uintptr_t) rx[q].desc1; queue.cfg.comp_address = (uintptr_t) rx[q].comp; queue.cfg.num_desc[0] = vmxnet3::NUM_RX_DESC; queue.cfg.num_desc[1] = vmxnet3::NUM_RX_DESC; queue.cfg.num_comp = VMXNET3_NUM_RX_COMP; queue.cfg.driver_data_len = sizeof(vmxnet3_rx_desc) + 2 * sizeof(vmxnet3_rx_desc); queue.cfg.intr_index = 2 + q; } auto& shared = dma->shared; // setup shared physical area shared.magic = VMXNET3_REV1_MAGIC; shared.misc.guest_info.arch = (sizeof(void*) == 4) ? GOS_BITS_32_BITS : GOS_BITS_64_BITS; shared.misc.guest_info.type = GOS_TYPE_LINUX; shared.misc.version = VMXNET3_VERSION_MAGIC; shared.misc.version_support = 1; shared.misc.upt_version_support = 1; shared.misc.upt_features = UPT1_F_RXVLAN; shared.misc.driver_data_address = (uintptr_t) &dma; shared.misc.queue_desc_address = (uintptr_t) &dma->queues; shared.misc.driver_data_len = sizeof(vmxnet3_dma); shared.misc.queue_desc_len = sizeof(vmxnet3_queues); shared.misc.mtu = packet_len(); // 60-9000 shared.misc.num_tx_queues = 1; shared.misc.num_rx_queues = NUM_RX_QUEUES; shared.interrupt.mask_mode = VMXNET3_IT_AUTO | (VMXNET3_IMM_AUTO << 2); shared.interrupt.num_intrs = 2 + NUM_RX_QUEUES; shared.interrupt.event_intr_index = 0; memset(shared.interrupt.moderation_level, UPT1_IML_ADAPTIVE, VMXNET3_MAX_INTRS); shared.interrupt.control = 0x1; // disable all shared.rx_filter.mode = VMXNET3_RXM_UCAST | VMXNET3_RXM_BCAST | VMXNET3_RXM_ALL_MULTI; // location of shared area to device uintptr_t shabus = (uintptr_t) &shared; mmio_write32(this->iobase + 0x10, shabus); // shared low mmio_write32(this->iobase + 0x18, 0x0); // shared high // activate device int status = command(VMXNET3_CMD_ACTIVATE_DEV); if (status) { assert(0 && "Failed to activate device"); } // initialize and fill RX queue... for (int q = 0; q < NUM_RX_QUEUES; q++) { refill(rx[q]); } // deferred transmit this->deferred_irq = Events::get().subscribe(handle_deferred); // enable interrupts enable_intr(0); enable_intr(1); for (int q = 0; q < NUM_RX_QUEUES; q++) enable_intr(2 + q); }
void SurfaceEdgeCollapse::Reduce(int &red_tri, int &red_pnt) { Edge current; Star star; int v1, v2; float cur_percent; int okay; char buf[100]; float x_0, y_0, z_0; clock_t starttime, endtime; double time; pair link[MAXTRI]; int num_link = 0; heap = new PQ<Edge>(num_triangles * 3); cur_percent = percent / 100.0; red_tri = num_triangles; red_pnt = num_points; starttime = clock(); preprocess(red_tri); while ((heap->getSize() > TERMINATE) && (red_tri / (float)num_triangles > cur_percent)) { current = heap->get_next(); v1 = current.get_v1(); v2 = current.get_v2(); // valence test if (stars[v1].num_tri + stars[v2].num_tri > 5 && v1 >= 0 && v1 < num_points && v2 >= 0 && v2 < num_points) { // prevent too large stars if (stars[v1].num_tri + stars[v2].num_tri < MAXTRI) { merge_stars(v1, v2, star); make_link(v1, v2, star, link, num_link); if (check_link(v1, v2, star, link, num_link)) { okay = sort_link(link, num_link); // topology preserving tests if (okay && star.manifold && !((angle[v1] || angle[v2]) && star.boundary)) { // simplify edge if (angle[v1] && angle[v2]) okay = straighten_edge(v1, v2, star, link, num_link, x_0, y_0, z_0); else { if (stars[v1].boundary && stars[v2].boundary) { okay = straighten_boundary(v1, v2, star, link, num_link, x_0, y_0, z_0); } else { okay = compute_newpoint(v1, v2, star, link, num_link, x_0, y_0, z_0); } } if (okay && (volume_bound >= fabs(compute_star_volume(v1, v2, star, link, num_link, x_0, y_0, z_0)))) { update(red_tri, v1, v2, star, link, num_link, x_0, y_0, z_0); red_pnt -= 1; } else delete[] star.tri; } else delete[] star.tri; } else delete[] star.tri; } } } cur_percent = 100.0 * red_tri / (float)num_triangles; endtime = clock(); time = (endtime - starttime) / (double)CLOCKS_PER_SEC; if (heap->getSize() == TERMINATE) sprintf(buf, "Reduction capacity exceeded: Removed %d triangles of %d, i.e. %.2f %% are left", num_triangles - red_tri, num_triangles, cur_percent); else sprintf(buf, "Removed %d triangles of %d, i.e. %.2f %% are left\n", num_triangles - red_tri, num_triangles, percent); Covise::sendInfo(buf); sprintf(buf, "Time: %.2f seconds\n", time); Covise::sendInfo(buf); delete heap; }
/* * copy_entry - copy the entry of a directory * * Copy the entry src to dst. * Depending on the type of entry, this function will forward the * request to copy_dir(), copy_symlink(), copy_hardlink(), * copy_special(), or copy_file(). * * The access and modification time will not be modified. * * The permissions will be set to new_uid/new_gid. * * If new_uid (resp. new_gid) is equal to -1, the user (resp. group) will * not be modified. * * Only the files owned (resp. group-owned) by old_uid (resp. * old_gid) will be modified, unless old_uid (resp. old_gid) is set * to -1. */ static int copy_entry (const char *src, const char *dst, bool reset_selinux, uid_t old_uid, uid_t new_uid, gid_t old_gid, gid_t new_gid) { int err = 0; struct stat sb; struct link_name *lp; struct timeval mt[2]; if (LSTAT (src, &sb) == -1) { /* If we cannot stat the file, do not care. */ } else { #ifdef HAVE_STRUCT_STAT_ST_ATIM mt[0].tv_sec = sb.st_atim.tv_sec; mt[0].tv_usec = sb.st_atim.tv_nsec / 1000; #else /* !HAVE_STRUCT_STAT_ST_ATIM */ mt[0].tv_sec = sb.st_atime; # ifdef HAVE_STRUCT_STAT_ST_ATIMENSEC mt[0].tv_usec = sb.st_atimensec / 1000; # else /* !HAVE_STRUCT_STAT_ST_ATIMENSEC */ mt[0].tv_usec = 0; # endif /* !HAVE_STRUCT_STAT_ST_ATIMENSEC */ #endif /* !HAVE_STRUCT_STAT_ST_ATIM */ #ifdef HAVE_STRUCT_STAT_ST_MTIM mt[1].tv_sec = sb.st_mtim.tv_sec; mt[1].tv_usec = sb.st_mtim.tv_nsec / 1000; #else /* !HAVE_STRUCT_STAT_ST_MTIM */ mt[1].tv_sec = sb.st_mtime; # ifdef HAVE_STRUCT_STAT_ST_MTIMENSEC mt[1].tv_usec = sb.st_mtimensec / 1000; # else /* !HAVE_STRUCT_STAT_ST_MTIMENSEC */ mt[1].tv_usec = 0; # endif /* !HAVE_STRUCT_STAT_ST_MTIMENSEC */ #endif /* !HAVE_STRUCT_STAT_ST_MTIM */ if (S_ISDIR (sb.st_mode)) { err = copy_dir (src, dst, reset_selinux, &sb, mt, old_uid, new_uid, old_gid, new_gid); } #ifdef S_IFLNK /* * Copy any symbolic links */ else if (S_ISLNK (sb.st_mode)) { err = copy_symlink (src, dst, reset_selinux, &sb, mt, old_uid, new_uid, old_gid, new_gid); } #endif /* S_IFLNK */ /* * See if this is a previously copied link */ else if ((lp = check_link (src, &sb)) != NULL) { err = copy_hardlink (dst, reset_selinux, lp); } /* * Deal with FIFOs and special files. The user really * shouldn't have any of these, but it seems like it * would be nice to copy everything ... */ else if (!S_ISREG (sb.st_mode)) { err = copy_special (src, dst, reset_selinux, &sb, mt, old_uid, new_uid, old_gid, new_gid); } /* * Create the new file and copy the contents. The new * file will be owned by the provided UID and GID values. */ else { err = copy_file (src, dst, reset_selinux, &sb, mt, old_uid, new_uid, old_gid, new_gid); } } return err; }
static void init(void) { static const char *fragShaderText = "void main() {\n" " gl_FragColor = gl_Color;\n" "}\n"; static const char *vertShaderText = "void main() {\n" " gl_FrontColor = gl_Color;\n" " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" "}\n"; static const char *geoShaderText = "#version 120\n" "#extension GL_ARB_geometry_shader4 : enable\n" "void main()\n" "{\n" " for(int i = 0; i < gl_VerticesIn; ++i)\n" " {\n" " gl_FrontColor = gl_FrontColorIn[i];\n" " gl_Position = gl_PositionIn[i];\n" " EmitVertex();\n" " }\n" "}\n"; if (!ShadersSupported()) exit(1); if (!glutExtensionSupported("GL_ARB_geometry_shader4")) { printf("This demo requires GL_ARB_geometry_shader4\n"); exit(1); } menu_init(); fragShader = glCreateShader(GL_FRAGMENT_SHADER); load_and_compile_shader(fragShader, fragShaderText); vertShader = glCreateShader(GL_VERTEX_SHADER); load_and_compile_shader(vertShader, vertShaderText); geoShader = glCreateShader(GL_GEOMETRY_SHADER_ARB); if (filename) read_shader(geoShader, filename); else load_and_compile_shader(geoShader, geoShaderText); program = glCreateProgram(); glAttachShader(program, vertShader); glAttachShader(program, geoShader); glAttachShader(program, fragShader); glProgramParameteriARB(program, GL_GEOMETRY_INPUT_TYPE_ARB, GL_LINES_ADJACENCY_ARB); glProgramParameteriARB(program, GL_GEOMETRY_OUTPUT_TYPE_ARB, GL_LINE_STRIP); { int temp; glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB,&temp); glProgramParameteriARB(program,GL_GEOMETRY_VERTICES_OUT_ARB,temp); } glLinkProgram(program); check_link(program); glUseProgram(program); SetUniformValues(program, Uniforms); PrintUniforms(Uniforms); assert(glGetError() == 0); glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_COLOR_ARRAY ); glVertexPointer( 3, GL_FLOAT, sizeof(vertices[0]), vertices ); glColorPointer( 4, GL_FLOAT, sizeof(color[0]), color ); }
int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid) { char src_name[1024]; char dst_name[1024]; char buf[1024]; int ifd; int ofd; int err = 0; int cnt; int set_orig = 0; struct DIRECT *ent; struct stat sb; struct link_name *lp; DIR *dir; /* * Make certain both directories exist. This routine is called * after the home directory is created, or recursively after the * target is created. It assumes the target directory exists. */ if (access (src_root, F_OK) != 0 || access (dst_root, F_OK) != 0) return -1; /* * Open the source directory and read each entry. Every file * entry in the directory is copied with the UID and GID set * to the provided values. As an added security feature only * regular files (and directories ...) are copied, and no file * is made set-ID. */ if (!(dir = opendir (src_root))) return -1; if (src_orig == 0) { src_orig = src_root; dst_orig = dst_root; set_orig++; } while ((ent = readdir (dir))) { /* * Skip the "." and ".." entries */ if (strcmp (ent->d_name, ".") == 0 || strcmp (ent->d_name, "..") == 0) continue; /* * Make the filename for both the source and the * destination files. */ if (strlen (src_root) + strlen (ent->d_name) + 2 > sizeof src_name) { err++; break; } snprintf (src_name, sizeof src_name, "%s/%s", src_root, ent->d_name); if (strlen (dst_root) + strlen (ent->d_name) + 2 > sizeof dst_name) { err++; break; } snprintf (dst_name, sizeof dst_name, "%s/%s", dst_root, ent->d_name); if (LSTAT (src_name, &sb) == -1) continue; if (S_ISDIR (sb.st_mode)) { /* * Create a new target directory, make it owned by * the user and then recursively copy that directory. */ #ifdef WITH_SELINUX selinux_file_context (dst_name); #endif mkdir (dst_name, sb.st_mode & 0777); chown (dst_name, uid == (uid_t) - 1 ? sb.st_uid : uid, gid == (gid_t) - 1 ? sb.st_gid : gid); if (copy_tree (src_name, dst_name, uid, gid)) { err++; break; } continue; } #ifdef S_IFLNK /* * Copy any symbolic links */ if (S_ISLNK (sb.st_mode)) { char oldlink[1024]; char dummy[1024]; int len; /* * Get the name of the file which the link points * to. If that name begins with the original * source directory name, that part of the link * name will be replaced with the original * destinateion directory name. */ if ((len = readlink (src_name, oldlink, sizeof (oldlink) - 1)) < 0) { err++; break; } oldlink[len] = '\0'; /* readlink() does not NUL-terminate */ if (!strncmp (oldlink, src_orig, strlen (src_orig))) { snprintf (dummy, sizeof dummy, "%s%s", dst_orig, oldlink + strlen (src_orig)); strcpy (oldlink, dummy); } #ifdef WITH_SELINUX selinux_file_context (dst_name); #endif if (symlink (oldlink, dst_name) || lchown (dst_name, uid == (uid_t) - 1 ? sb.st_uid : uid, gid == (gid_t) - 1 ? sb.st_gid : gid)) { err++; break; } continue; } #endif /* * See if this is a previously copied link */ if ((lp = check_link (src_name, &sb))) { if (link (lp->ln_name, dst_name)) { err++; break; } if (unlink (src_name)) { err++; break; } if (--lp->ln_count <= 0) remove_link (lp); continue; } /* * Deal with FIFOs and special files. The user really * shouldn't have any of these, but it seems like it * would be nice to copy everything ... */ if (!S_ISREG (sb.st_mode)) { #ifdef WITH_SELINUX selinux_file_context (dst_name); #endif if (mknod (dst_name, sb.st_mode & ~07777, sb.st_rdev) || chown (dst_name, uid == (uid_t) - 1 ? sb.st_uid : uid, gid == (gid_t) - 1 ? sb.st_gid : gid) || chmod (dst_name, sb.st_mode & 07777)) { err++; break; } continue; } /* * Create the new file and copy the contents. The new * file will be owned by the provided UID and GID values. */ if ((ifd = open (src_name, O_RDONLY)) < 0) { err++; break; } #ifdef WITH_SELINUX selinux_file_context (dst_name); #endif if ((ofd = open (dst_name, O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0 || chown (dst_name, uid == (uid_t) - 1 ? sb.st_uid : uid, gid == (gid_t) - 1 ? sb.st_gid : gid) || chmod (dst_name, sb.st_mode & 07777)) { close (ifd); err++; break; } while ((cnt = read (ifd, buf, sizeof buf)) > 0) { if (write (ofd, buf, cnt) != cnt) { cnt = -1; break; } } close (ifd); close (ofd); if (cnt == -1) { err++; break; } } closedir (dir); if (set_orig) { src_orig = 0; dst_orig = 0; } return err ? -1 : 0; }