Beispiel #1
0
int main(int argc, char** argv)
{
    char **args = &argv[1];

    /*
     * Scan command line options.
     */
    while (*args) {
        char* opt = NULL;

        if ((opt = shift_option(&args, "--queue_index=")))
            queue_index = strtoul(opt, NULL, 0);
        else if ((opt = shift_option(&args, "--card=")))
            card_index = strtoul(opt, NULL, 0);
        else if ((opt = shift_option(&args, "--debug")))
            debug = 1;
        else if ((opt = shift_option(&args, "--drop")))
            drop_alerts = 1;
        else if ((opt = shift_option(&args, "--prefix=")))
            path_prefix = opt;
        else {
            fprintf(stderr, "Unknown option '%s'.\n", args[0]);
            exit(EXIT_FAILURE);
        }
    }

    run_pcie_logging();

    return 0;
}
int 
main(int argc, char**argv)
{	
  // Scan options.
  char **args = &argv[1];
  while (*args)
  {
    char *opt = NULL;

    if ((opt = shift_option(&args, "--test_num=")))
      g_run_multiplier = atoi(opt);
  }

  printf("This test will run %d times.\n",
         ((1 << LG2_CAPACITY) * g_run_multiplier));
  
  // Make sure we have enough cpus.
  // if (tmc_cpus_get_dataplane_cpus(&cpus) != 0)
  if (tmc_cpus_get_my_affinity(&cpus) != 0)
    tmc_task_die("tmc_cpus_get_my_affinity() failed.");
  if (tmc_cpus_count(&cpus) < NUM_THREADS)
    tmc_task_die("Insufficient cpus available.");
    
  // Call the main thread function on each cpu, then wait for them all
  // to exit.
  run_threads(NUM_THREADS, thread_func);
  finish_threads(NUM_THREADS);
  
  return 0;
}
Beispiel #3
0
// Parses command line arguments in order to fill in the MAC and bus
// address variables.
void parse_args(int argc, char** argv)
{
  char **args = &argv[1];

  // Scan options.
  //
  while (*args)
  {
    char* opt = NULL;

    if ((opt = shift_option(&args, "--mac=")))
      loc_mac = atoi(opt);
    else if ((opt = shift_option(&args, "--size=")))
      packet_size = atoi(opt);
    else
    {
      fprintf(stderr, "Unknown option '%s'.\n", args[0]);
      fprintf(stderr,
              "Usage: t2h --mac=0 --size=1344\n");
      exit(EXIT_FAILURE);
    }
  }
}
Beispiel #4
0
void parse_configuration_args(int argc, char** argv)
{

  // Scan options.
  //
  char **args = &argv[1];
  while (*args)
  {
    char *opt = NULL;

    //TODO handle conflicts between args & conf file ?
    if ((opt = shift_option(&args, "--conf=")))
      confFilename = opt;
    else if ((opt = shift_option(&args, "--ip-conf=")))
      config_ip_file_name = opt;
    else if ((opt = shift_option(&args, "--discard")))
      packet_drop = 1;
#if OFP_LOOP_STATISTICS
    else if ((opt = shift_option(&args, "--limit-packets=")))
      limit_packets = strtoul(opt,NULL,0);
#endif
    else if ((opt = shift_option(&args, "--workers=")))
      work_size = atoi(opt);
#if TILEGX
    else if ((opt = shift_option(&args, "--links=")))
      parse_links(0, opt);
#else
#if TWOINTERFACE
    else if ((opt = shift_option(&args, "--interface1=")))
      interface1 = opt;
    else if ((opt = shift_option(&args, "--interface2=")))
      interface2 = opt;
#else
    else if ((opt = shift_option(&args, "--interface=")))
      interface1 = opt;
#endif
#endif
#if MODE_VLAN
    else if ((opt = shift_option(&args, "--vlan1=")))
      packet_vlan_swap1 = strtoul(opt,NULL,0);
    else if ((opt = shift_option(&args, "--vlan2=")))
      packet_vlan_swap2 = strtoul(opt,NULL,0);
#endif
    else if ((opt = shift_option(&args, "--daemon")))
      config_daemonize = 1;

    else
      tmc_task_die("Unknown option '%s'.\n", args[0]);
  }
}