Example #1
0
void app_main_loop()
{
    uint8_t ports_to_poll[1] = { 0 };
	int skip = 0;
	int drv_poll_interval = get_max_drv_poll_interval_in_micros(0);

	app_glue_init_poll_intervals(drv_poll_interval/2,
			1000 /*timer_poll_interval*/,
			drv_poll_interval/10,drv_poll_interval/10);
	while(1) {
		app_glue_periodic(0,ports_to_poll,1);
		skip++;
		if(skip == 100) {
			user_on_transmission_opportunity(udp_socket);
			user_data_available_cbk(udp_socket);
			skip = 0;
		}
	}
}
void ipaugenblick_main_loop()
{
    struct rte_mbuf *mbuf;
    uint8_t ports_to_poll[1] = { 0 };
    int drv_poll_interval = get_max_drv_poll_interval_in_micros(0);
    app_glue_init_poll_intervals(drv_poll_interval/(2*MAX_PKT_BURST),
                                 100 /*timer_poll_interval*/,
                                 drv_poll_interval/(10*MAX_PKT_BURST),
                                drv_poll_interval/(60*MAX_PKT_BURST));
    
    ipaugenblick_service_api_init(COMMAND_POOL_SIZE,DATA_RINGS_SIZE,DATA_RINGS_SIZE);
    TAILQ_INIT(&buffers_available_notification_socket_list_head);
    TAILQ_INIT(&ipaugenblick_clients_list_head);
    init_systick(rte_lcore_id());
    ipaugenblick_log(IPAUGENBLICK_LOG_INFO,"IPAugenblick service initialized\n");
    while(1) {
        process_commands();
	app_glue_periodic(1,ports_to_poll,1);
        while(!TAILQ_EMPTY(&buffers_available_notification_socket_list_head)) {
            if(get_buffer_count() > 0) {
                struct socket *sock = TAILQ_FIRST(&buffers_available_notification_socket_list_head);
                socket_satelite_data_t *socket_data = get_user_data(sock);
		if(socket_data->socket->type == SOCK_DGRAM)
		   	user_set_socket_tx_space(&g_ipaugenblick_sockets[socket_data->ringset_idx].tx_space,sk_stream_wspace(socket_data->socket->sk));
		//printf("%s %d %d %d %d\n",__FILE__,__LINE__,socket_data->ringset_idx,g_ipaugenblick_sockets[socket_data->ringset_idx].tx_space,sk_stream_wspace(socket_data->socket->sk));
                if(!ipaugenblick_mark_writable(socket_data)) { 
                    sock->buffers_available_notification_queue_present = 0;
                    TAILQ_REMOVE(&buffers_available_notification_socket_list_head,sock,buffers_available_notification_queue_entry); 
                }
                else {
                    break;
                }
            }
            else {
                break;
            }
        }
    }
}
Example #3
0
int main(int argc,char **argv)
{
    int ret;
    void *ifp;

    ret = rte_eal_init(argc, argv);
    if (ret < 0) {
        //rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
        printf("cannot initialize EAL\n");
        exit(0);
    }
    softint_init();
    callout_startup(); 
    printf("%s %d\n",__FILE__,__LINE__);
    domaininit(1);
    printf("%s %d\n",__FILE__,__LINE__);
    bpf_setops();
    rt_init();
    soinit();
    mbinit();
    app_glue_init();
    ifp = createInterface(0);
    printf("%s %d %p\n",__FILE__,__LINE__,ifp);
    configure_if_addr(ifp,inet_addr("192.168.1.1"),inet_addr("255.255.255.0"));
    printf("%s %d\n",__FILE__,__LINE__);
    void *socket1,*socket2;

    createLoopbackInterface();
    unsigned i = 0,iterations_count = 100000;

    sender_so = create_udp_socket("127.0.0.1",7777);
    printf("%s %d\n",__FILE__,__LINE__);
    receiver_so = create_udp_socket("127.0.0.1",7778);
    user_on_transmission_opportunity(sender_so); 
    while(i < iterations_count) {
	    user_on_transmission_opportunity(sender_so);
	    softint_run();
	    app_glue_periodic(1,NULL,0);
	    i++;
    }
printf("%s %d\n",__FILE__,__LINE__);
    if(sender_so) {
        app_glue_close_socket(sender_so);
    }
    if(receiver_so) {
        app_glue_close_socket(receiver_so);
    }

printf("%s %d\n",__FILE__,__LINE__);
    receiver_so = create_server_socket("127.0.0.1",7777);
    if(!receiver_so) {
        printf("cannot open server socket\n");
        return -1;
    }
    sender_so = create_client_socket("127.0.0.1",11111,"127.0.0.1",7777);
    if(!sender_so) {
        printf("cannot open client socket\n");
        return -1;
    }
    softint_run();
    softint_run();
    softint_run();
    i = 0;
    while(i < iterations_count) {
	    user_on_transmission_opportunity(sender_so);
	    softint_run();
	    softint_run();
            softint_run();
	    app_glue_periodic(1,NULL,0);
	    i++;
    }
    //app_glue_close_socket(socket1);
    //app_glue_close_socket(socket2);
    printf("The END\n");
    return 0;
}