Esempio n. 1
0
/*
 * Open and close
 */
static int
kni_net_open(struct net_device *dev)
{
	int ret;
	struct rte_kni_request req;
	struct kni_dev *kni = netdev_priv(dev);

	if (kni->kni_released) {
		return -EAGAIN;
	}

	if (kni->lad_dev)
		memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN);
	else
		/*
		 * Generate random mac address. eth_random_addr() is the newer
		 * version of generating mac address in linux kernel.
		 */
		random_ether_addr(dev->dev_addr);

	netif_start_queue(dev);

	memset(&req, 0, sizeof(req));
	req.req_id = RTE_KNI_REQ_CFG_NETWORK_IF;

	/* Setting if_up to non-zero means up */
	req.if_up = 1;
	ret = kni_net_process_request(kni, &req);

	return (ret == 0 ? req.result : ret);
}
Esempio n. 2
0
static int
kni_net_change_mtu(struct net_device *dev, int new_mtu)
{
	int ret;
	struct rte_kni_request req;
	struct kni_dev *kni = netdev_priv(dev);

	KNI_DBG("kni_net_change_mtu new mtu %d to be set\n", new_mtu);

	memset(&req, 0, sizeof(req));
	req.req_id = RTE_KNI_REQ_CHANGE_MTU;
	req.new_mtu = new_mtu;
	ret = kni_net_process_request(kni, &req);
	if (ret == 0 && req.result == 0)
		dev->mtu = new_mtu;

	return (ret == 0 ? req.result : ret);
}
Esempio n. 3
0
static int
kni_net_release(struct net_device *dev)
{
	int ret;
	struct rte_kni_request req;
	struct kni_dev *kni = netdev_priv(dev);

	netif_stop_queue(dev); /* can't transmit any more */

	memset(&req, 0, sizeof(req));
	req.req_id = RTE_KNI_REQ_CFG_NETWORK_IF;

	/* Setting if_up to 0 means down */
	req.if_up = 0;
	ret = kni_net_process_request(kni, &req);

	return (ret == 0 ? req.result : ret);
}
Esempio n. 4
0
/*
 * Open and close
 */
static int
kni_net_open(struct net_device *dev)
{
	int ret;
	struct rte_kni_request req;
	struct kni_dev *kni = netdev_priv(dev);

	if (kni->lad_dev)
		memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN);
#ifdef RTE_LIBRW_PIOT
	else if (kni->dev_addr)
          memcpy(dev->dev_addr, kni->dev_addr, ETH_ALEN);
#endif
	else
		/*
		 * Generate random mac address. eth_random_addr() is the newer
		 * version of generating mac address in linux kernel.
		 */
		random_ether_addr(dev->dev_addr);

	netif_start_queue(dev);

	memset(&req, 0, sizeof(req));
	req.req_id = RTE_KNI_REQ_CFG_NETWORK_IF;

	/* Setting if_up to non-zero means up */
	req.if_up = 1;
	ret = kni_net_process_request(kni, &req);
#ifdef RTE_LIBRW_PIOT
        kni->rx_treat_as_tx=0;
        kni->rx_treat_as_tx_delivered=0;
        kni->rx_treat_as_tx_filtered=0;
        kni->rx_only=0;
        kni->rx_filtered=0;
        kni->rx_delivered=0;
        kni->tx_no_txq=0;
        kni->tx_no_allocq=0;
        kni->tx_enq_fail=0;
        kni->tx_deq_fail=0;
#endif
	return (ret == 0 ? req.result : ret);
}