Пример #1
0
static int init_suite(void)
{
	odp_pool_param_t pool_params;
	ofp_pkt_hook pkt_hook[OFP_HOOK_MAX];
	odp_pool_t pool;
	odph_linux_thr_params_t thr_params;
	odp_instance_t instance;

	/* Init ODP before calling anything else */
	if (odp_init_global(&instance, NULL, NULL)) {
		OFP_ERR("Error: ODP global init failed.\n");
		return -1;
	}

	/* Init this thread */
	if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
		OFP_ERR("Error: ODP local init failed.\n");
		return -1;
	}

	memset(pkt_hook, 0, sizeof(pkt_hook));

	pool_params.pkt.seg_len = SHM_PKT_POOL_BUFFER_SIZE;
	pool_params.pkt.len     = SHM_PKT_POOL_BUFFER_SIZE;
	pool_params.pkt.num     = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUFFER_SIZE;
	pool_params.type        = ODP_POOL_PACKET;

	(void) ofp_init_pre_global(pool_name, &pool_params, pkt_hook, &pool,
				   ARP_AGE_INTERVAL, ARP_ENTRY_TIMEOUT);

	/*
	 * Start a packet processing thread to service timer events.
	 */
	odp_atomic_store_u32(&still_running, 1);

	odp_cpumask_t cpumask;
	odp_cpumask_zero(&cpumask);
	odp_cpumask_set(&cpumask, 0x1);
	thr_params.start = pp_thread;
	thr_params.arg = NULL;
	thr_params.thr_type = ODP_THREAD_WORKER;
	thr_params.instance = instance;
	odph_linux_pthread_create(&pp_thread_handle,
				&cpumask,
				&thr_params);

	return 0;
}
Пример #2
0
static int
init_suite(void)
{
	odp_pool_param_t pool_params;
	ofp_pkt_hook pkt_hook[OFP_HOOK_MAX];
	odp_pool_t pool;
	odp_instance_t instance;

	/* Init ODP before calling anything else */
	if (odp_init_global(&instance, NULL, NULL)) {
		OFP_ERR("Error: ODP global init failed.\n");
		return -1;
	}

	/* Init this thread */
	if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
		OFP_ERR("Error: ODP local init failed.\n");
		return -1;
	}

	memset(pkt_hook, 0, sizeof(pkt_hook));
	pkt_hook[OFP_HOOK_OUT_IPv4] = fastpath_hook_out_IPv4;
#ifdef INET6
	pkt_hook[OFP_HOOK_OUT_IPv6] = fastpath_hook_out_IPv6;
#endif /* INET6 */

	pool_params.pkt.seg_len = SHM_PKT_POOL_BUFFER_SIZE;
	pool_params.pkt.len     = SHM_PKT_POOL_BUFFER_SIZE;
	pool_params.pkt.num     = SHM_PKT_POOL_NB_PKTS;
	pool_params.type        = ODP_POOL_PACKET;

	(void) ofp_init_pre_global(pool_name, &pool_params, pkt_hook, &pool,
				   ARP_AGE_INTERVAL, ARP_ENTRY_TIMEOUT);

	ofp_arp_init_local();

	init_ifnet();

	ofp_arp_ipv4_insert(tun_rem_ip, tun_rem_mac, dev);

	return 0;
}
Пример #3
0
static int
init_suite(void)
{
    odp_pool_param_t pool_params;
    ofp_pkt_hook pkt_hook[OFP_HOOK_MAX];
    odp_instance_t instance;

    /* Init ODP before calling anything else */
    if (odp_init_global(&instance, NULL, NULL)) {
        OFP_ERR("Error: ODP global init failed.\n");
        return -1;
    }

    /* Init this thread */
    if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
        OFP_ERR("Error: ODP local init failed.\n");
        return -1;
    }

    memset(pkt_hook, 0, sizeof(pkt_hook));

    pool_params.pkt.seg_len = SHM_PKT_POOL_BUFFER_SIZE;
    pool_params.pkt.len     = SHM_PKT_POOL_BUFFER_SIZE;
    pool_params.pkt.num     = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUFFER_SIZE;
    pool_params.type        = ODP_POOL_PACKET;

    (void) ofp_init_pre_global("packet_pool", &pool_params,
                               pkt_hook, &ofp_packet_pool,
                               ARP_AGE_INTERVAL, ARP_ENTRY_TIMEOUT);

    ofp_arp_init_local();

    init_ifnet();

    ofp_arp_ipv4_insert(dst_ipaddr, dst_mac, dev);

    nexthop.gw = dst_ipaddr;
    nexthop.vlan = vlan;
    nexthop.port = port;

    return 0;
}
Пример #4
0
static int
init_suite(void)
{
    odp_pool_param_t pool_params;
    ofp_pkt_hook pkt_hook[OFP_HOOK_MAX];

    /* Init ODP before calling anything else */
    if (odp_init_global(NULL, NULL)) {
        OFP_ERR("Error: ODP global init failed.\n");
        return -1;
    }

    /* Init this thread */
    if (odp_init_local(ODP_THREAD_CONTROL)) {
        OFP_ERR("Error: ODP local init failed.\n");
        return -1;
    }

    memset(pkt_hook, 0, sizeof(pkt_hook));
    pkt_hook[OFP_HOOK_LOCAL]    = fastpath_local_hook;
    pkt_hook[OFP_HOOK_LOCAL_IPv4]    = fastpath_local_IPv4_hook;
    pkt_hook[OFP_HOOK_LOCAL_UDPv4]    = fastpath_local_UDPv4_hook;
    pkt_hook[OFP_HOOK_FWD_IPv4] = fastpath_ip4_forward_hook;
    pkt_hook[OFP_HOOK_FWD_IPv6] = fastpath_ip6_forward_hook;
    pkt_hook[OFP_HOOK_GRE]	    = fastpath_gre_hook;

    pool_params.pkt.seg_len = SHM_PKT_POOL_BUFFER_SIZE;
    pool_params.pkt.len     = SHM_PKT_POOL_BUFFER_SIZE;
    pool_params.pkt.num     = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUFFER_SIZE;
    pool_params.type        = ODP_POOL_PACKET;

    (void) ofp_init_pre_global("packet_pool", &pool_params,
                               pkt_hook, &ofp_packet_pool,
                               ARP_AGE_INTERVAL, ARP_ENTRY_TIMEOUT);

    ofp_arp_init_local();

    ofp_ip_init();

    return 0;
}
Пример #5
0
int ofp_init_global(ofp_init_global_t *params)
{
	int i;

	HANDLE_ERROR(ofp_init_pre_global(NULL, NULL,
					 params->pkt_hook, NULL,
					 ARP_AGE_INTERVAL, ARP_ENTRY_TIMEOUT));

	/* cpu mask for slow path threads */
	odp_cpumask_zero(&cpumask);
	odp_cpumask_set(&cpumask, params->linux_core_id);

	OFP_INFO("Slow path threads on core %d", odp_cpumask_first(&cpumask));

	HANDLE_ERROR(ofp_set_vxlan_interface_queue());

	/* Create interfaces */

	for (i = 0; i < params->if_count; ++i)
		HANDLE_ERROR(ofp_ifnet_create(params->if_names[i],
			params->burst_recv_mode ? ODP_PKTIN_MODE_RECV :
						ODP_PKTIN_MODE_SCHED));

#ifdef SP
	/* Start Netlink server process */
	if (!ofp_linux_pthread_create(&shm->nl_thread,
				  &cpumask,
				  START_NL_SERVER,
				  NULL,
				  ODP_THREAD_CONTROL)) {

		OFP_ERR("Failed to start Netlink thread.");
		return -1;
	}
	shm->nl_thread_is_running = 1;
#endif /* SP */

	odp_schedule_resume();
	return 0;
}
Пример #6
0
/*
 * INIT
 */
static int
init_suite(void)
{
	odp_pool_param_t pool_params;
	ofp_pkt_hook pkt_hook[OFP_HOOK_MAX];
	struct ofp_ifnet *dev;
	odp_pool_t pool;

	/* Init ODP before calling anything else */
	if (odp_init_global(NULL, NULL)) {
		OFP_ERR("Error: ODP global init failed.\n");
		return -1;
	}

	/* Init this thread */
	if (odp_init_local(ODP_THREAD_CONTROL)) {
		OFP_ERR("Error: ODP local init failed.\n");
		return -1;
	}

	memset(pkt_hook, 0, sizeof(pkt_hook));

	pool_params.pkt.seg_len = SHM_PKT_POOL_BUFFER_SIZE;
	pool_params.pkt.len     = SHM_PKT_POOL_BUFFER_SIZE;
	pool_params.pkt.num     = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUFFER_SIZE;
	pool_params.type        = ODP_POOL_PACKET;

	(void) ofp_init_pre_global("packet_pool", &pool_params, pkt_hook, &pool,
				   ARP_AGE_INTERVAL, ARP_ENTRY_TIMEOUT);

	ofp_arp_init_local();

	dev = ofp_get_ifnet(0, 0);
	dev->if_mtu = ifmtu;
	memcpy(dev->mac, ifmac, OFP_ETHER_ADDR_LEN);
	ofp_mac_to_link_local(ifmac, link_local);

	return 0;
}