示例#1
0
文件: main.c 项目: AMildner/MoonGen
int
MAIN(int argc, char **argv)
{
	uint32_t lcore;
	int ret;

	/* Init EAL */
	ret = rte_eal_init(argc, argv);
	if (ret < 0)
		return -1;
	argc -= ret;
	argv += ret;

	/* Parse application arguments (after the EAL ones) */
	ret = app_parse_args(argc, argv);
	if (ret < 0) {
		app_print_usage();
		return -1;
	}

	/* Init */
	app_init();
	app_print_params();

	/* Launch per-lcore init on every lcore */
	rte_eal_mp_remote_launch(app_lcore_main_loop, NULL, CALL_MASTER);
	RTE_LCORE_FOREACH_SLAVE(lcore) {
		if (rte_eal_wait_lcore(lcore) < 0) {
			return -1;
		}
	}

	return 0;
}
示例#2
0
文件: dpdk.c 项目: tidatida/lagopus
lagopus_result_t
lagopus_dataplane_init(int argc, const char *const argv[]) {
  int ret;
  size_t argsize;
  char **copy_argv;
  int i;

  argsize = sizeof(char *) * (argc + 1);
  copy_argv = malloc(argsize);
  if (copy_argv == NULL) {
    return LAGOPUS_RESULT_NO_MEMORY;
  }
  copy_argv[0] = argv[0];
  for (i = 1; i < argc; i++) {
    if (!strcmp(argv[i], "--")) {
      memcpy(&copy_argv[1], &argv[i + 1], sizeof(char *) * (argc - i - 1));
      break;
    }
  }
  if (i == argc) {
    /* "--" is not found in argv */
    memcpy(copy_argv, argv, argsize);
    rawsocket_only_mode = true;
  } else {
    argc -= i;
    optind = 1;

    /* init EAL */
    ret = rte_eal_init(argc, copy_argv);
    if (ret < 0) {
      return LAGOPUS_RESULT_INVALID_ARGS;
    }
    optind = ret + 1;
    rawsocket_only_mode = false;
  }

  /* parse application arguments (after the EAL ones) */
  ret = app_parse_args(argc, copy_argv);
  free(copy_argv);
  if (ret < 0) {
    return LAGOPUS_RESULT_INVALID_ARGS;
  }

  if (rawsocket_only_mode != true) {
    /* Init */
    app_init();
    app_print_params();
  }

  return LAGOPUS_RESULT_OK;
}