Beispiel #1
0
int
VIFHYPER_CREATE(const char *devstr, struct virtif_sc *vif_sc, uint8_t *enaddr,
	struct virtif_user **viup)
{
	struct rte_eth_conf portconf;
	struct rte_eth_link link;
	struct ether_addr ea;
	struct virtif_user *viu;
	int rv = EINVAL; /* XXX: not very accurate ;) */

	viu = malloc(sizeof(*viu));
	memset(viu, 0, sizeof(*viu));
	viu->viu_devstr = strdup(devstr);
	viu->viu_virtifsc = vif_sc;

	/* this is here only for simplicity */
	if ((rv = globalinit(viu)) != 0)
		goto out;

	memset(&portconf, 0, sizeof(portconf));
	if ((rv = rte_eth_dev_configure(IF_PORTID,
	    NQUEUE, NQUEUE, &portconf)) < 0)
		OUT("configure device");

	if ((rv = rte_eth_rx_queue_setup(IF_PORTID,
	    0, NDESCRX, 0, &rxconf, mbpool_rx)) <0)
		OUT("rx queue setup");

	if ((rv = rte_eth_tx_queue_setup(IF_PORTID, 0, NDESCTX, 0, &txconf)) < 0)
		OUT("tx queue setup");

	if ((rv = rte_eth_dev_start(IF_PORTID)) < 0)
		OUT("device start");

	rte_eth_link_get(IF_PORTID, &link);
	if (!link.link_status) {
		ifwarn(viu, "link down");
	}

	rte_eth_promiscuous_enable(IF_PORTID);
	rte_eth_macaddr_get(IF_PORTID, &ea);
	memcpy(enaddr, ea.addr_bytes, ETHER_ADDR_LEN);

	rv = pthread_create(&viu->viu_rcvpt, NULL, receiver, viu);

 out:
	/* XXX: well this isn't much of an unrolling ... */
	if (rv != 0)
		free(viu);
	else
		*viup = viu;
	return rumpuser_component_errtrans(-rv);
}
Beispiel #2
0
int main()
{
    long i;

    globalinit();

    printf("please input source program file name: ");
    //scanf("%s",infilename);
    printf("\n");
  
    //if((infile=fopen(infilename,"r"))==NULL)
    if((infile=fopen("test1.pl0","r"))==NULL)
    {
        printf("File %s can't be opened.\n", infilename);
        exit(1);
    }

    getsym();
    block(declbegsys|statbegsys|period);
    
    if(sym!=period)
    {
        error(9);
    }
    
    fclose(infile);

    if(err==0)
    {
        listcode(0);
        interpret();
    }
    else
    {
        printf("%3ld errors in PL/0 program\n",err);
    }

    return (0);
}
Beispiel #3
0
int
rumpcomp_virtif_create(int devnum, struct virtif_user **viup)
{
    struct rte_eth_conf portconf;
    struct rte_eth_link link;
    int rv = EINVAL; /* XXX: not very accurate ;) */

    /* this is here only for simplicity */
    if (globalinit() != 0)
        goto out;

    memset(&portconf, 0, sizeof(portconf));
    if (rte_eth_dev_configure(IF_PORTID, NQUEUE, NQUEUE, &portconf) < 0)
        OUT("configure device\n");

    if (rte_eth_rx_queue_setup(IF_PORTID, 0, NDESC, 0, &rxconf, mbpool) <0)
        OUT("rx queue setup\n");

    if (rte_eth_tx_queue_setup(IF_PORTID, 0, NDESC, 0, &txconf) < 0)
        OUT("tx queue setup\n");

    if (rte_eth_dev_start(IF_PORTID) < 0)
        OUT("device start\n");

    rte_eth_link_get(IF_PORTID, &link);
    if (!link.link_status) {
        printf("warning: virt link down\n");
    }

    rte_eth_promiscuous_enable(IF_PORTID);
    rv = 0;

out:
    *viup = NULL; /* not used by the driver in its current state */
    return rv;
}