示例#1
0
/* Allocate datapath manager. */
struct dpmgr *
dpmgr_alloc(void) {
  struct dpmgr *dpmgr;

  dpmgr = (struct dpmgr *)calloc(1, sizeof(struct dpmgr));
  if (dpmgr == NULL) {
    return NULL;
  }

  dpmgr->ports = ports_alloc();
  if (dpmgr->ports == NULL) {
    return NULL;
  }

  TAILQ_INIT(&dpmgr->bridge_list);

#if defined(HAVE_DPDK)
  rte_rwlock_init(&dpmgr_lock);
#endif /* HAVE_DPDK */

  init_flow_timer();

  dpmgr_singleton = dpmgr;

  return dpmgr;
}
示例#2
0
int sflow_init() {
    sflow_sample_cb = &sflow_sample_callback;

    rte_rwlock_init(&sflow_hash_lock);

    sflow_hash = rte_hash_create(&sflow_hash_params);
    if (sflow_hash == NULL) {
        RTE_LOG(ERR, L3L4, "could not initialize sflow socket hash\n");
        return -1;
    }

    memset(sflow_sockets, 0, sizeof(sflow_sockets));

    return 0;
}
示例#3
0
文件: arp.c 项目: jiakai1000/ustack
int 
arp_init()
{
    //const struct rte_table_ops *ops = &rte_table_hash_key8_ext_ops;
    //struct rte_table_hash_key8_ext_params hash_params = {
    //    .n_entries = 1 << 10,
    //    .n_entries_ext = 1 << 4,
    //    //.f_hash = pipeline_test_hash,
    //    //.seed = 0,
    //    //.signature_offset = APP_METADATA_OFFSET(1),
    //    //.key_offset = APP_METADATA_OFFSET(32),
    //    .key_mask = NULL,
    //};

    //uint32_t aa = rte_jhash_1word(0x1234, 0);
    //assert(!arp_table);
    //arp_table = ops->f_create(&hash_params, 0, 1);
    //if (arp_table != NULL)
    //    return -1;

    rte_rwlock_init(&lock);

    return 0;
}