예제 #1
0
static int dpdk_events_preinit(void) {
  DPDK_EVENTS_TRACE();

  if (g_hc != NULL) {
    /* already initialized if config callback was called before init callback */
    DEBUG("dpdk_events_preinit: helper already initialized.");
    return 0;
  }

  int ret =
      dpdk_helper_init(DPDK_EVENTS_NAME, sizeof(dpdk_events_ctx_t), &g_hc);
  if (ret != 0) {
    ERROR(DPDK_EVENTS_PLUGIN ": failed to initialize %s helper(error: %s)",
          DPDK_EVENTS_NAME, strerror(ret));
    return ret;
  }

  dpdk_events_default_config();

  dpdk_events_ctx_t *ec = DPDK_EVENTS_CTX_GET(g_hc);
  for (int i = 0; i < RTE_MAX_ETHPORTS; i++) {
    ec->link_info[i].link_status = ETH_LINK_NA;
  }

  for (int i = 0; i < RTE_KEEPALIVE_MAXCORES; i++) {
    ec->core_info[i].lcore_state = ETH_LINK_NA;
  }

  return ret;
}
예제 #2
0
static int dpdk_stats_preinit(void) {
  DPDK_STATS_TRACE();

  if (g_hc != NULL) {
    /* already initialized if config callback was called before init callback */
    DEBUG("dpdk_stats_preinit: helper already initialized");
    return 0;
  }

  int ret = dpdk_helper_init(g_shm_name, sizeof(dpdk_stats_ctx_t), &g_hc);
  if (ret != 0) {
    ERROR("%s: failed to initialize %s helper(error: %s)", DPDK_STATS_PLUGIN,
          g_shm_name, STRERRNO);
    return ret;
  }

  dpdk_stats_default_config();
  return ret;
}
예제 #3
0
파일: dpdkstat.c 프로젝트: Feandil/collectd
static int dpdk_stats_reinit_helper() {
  DPDK_STATS_TRACE();

  dpdk_stats_ctx_t *ctx = DPDK_STATS_CTX_GET(g_hc);

  size_t data_size = sizeof(dpdk_stats_ctx_t) +
                     (ctx->stats_count * DPDK_STATS_CTX_GET_XSTAT_SIZE);

  DEBUG("%s:%d helper reinit (new_size=%zu)", __FUNCTION__, __LINE__,
        data_size);

  dpdk_stats_ctx_t tmp_ctx;
  dpdk_eal_config_t tmp_eal;

  memcpy(&tmp_ctx, ctx, sizeof(dpdk_stats_ctx_t));
  dpdk_helper_eal_config_get(g_hc, &tmp_eal);

  dpdk_helper_shutdown(g_hc);

  g_hc = NULL;

  int ret;
  ret = dpdk_helper_init(g_shm_name, data_size, &g_hc);
  if (ret != 0) {
    char errbuf[ERR_BUF_SIZE];
    ERROR("%s: failed to initialize %s helper(error: %s)", DPDK_STATS_PLUGIN,
          g_shm_name, sstrerror(errno, errbuf, sizeof(errbuf)));
    return ret;
  }

  ctx = DPDK_STATS_CTX_GET(g_hc);
  memcpy(ctx, &tmp_ctx, sizeof(dpdk_stats_ctx_t));
  DPDK_STATS_CTX_INIT(ctx);
  dpdk_helper_eal_config_set(g_hc, &tmp_eal);

  return ret;
}