int rw_piot_set_led(rw_piot_api_handle_t api_handle, int on) { rw_piot_device_t *rw_piot_dev = RWPIOT_GET_DEVICE(api_handle); int ret; ASSERT(RWPIOT_VALID_DEVICE(rw_piot_dev)); if (NULL == rw_piot_dev) { RW_PIOT_LOG(RTE_LOG_ERR, "PIOT Could not find device by handle\n"); return -1; } if (on) { ret = rte_eth_led_on(rw_piot_dev->rte_port_id); } else { ret = rte_eth_led_off(rw_piot_dev->rte_port_id); } return ret; }
int rw_piot_is_virtio(rw_piot_api_handle_t api_handle) { rw_piot_device_t *rw_piot_dev = RWPIOT_GET_DEVICE(api_handle); struct rte_eth_dev_info dev_info; memset(&dev_info, 0, sizeof(dev_info)); ASSERT(RWPIOT_VALID_DEVICE(rw_piot_dev)); if (NULL == rw_piot_dev ){ return 0; } rte_eth_dev_info_get(rw_piot_dev->rte_port_id, &dev_info); if (strstr(dev_info.driver_name, "rte_virtio_pmd")){ return 1; } return 0; }
int rw_piot_close(rw_piot_api_handle_t api_handle) { rw_piot_device_t *rw_piot_dev = RWPIOT_GET_DEVICE(api_handle); ASSERT(RWPIOT_VALID_DEVICE(rw_piot_dev)); if (NULL == rw_piot_dev) { printf("Could not fine device by handle\n"); return -1; } /* * Close the device */ rte_eth_dev_close(rw_piot_dev->rte_port_id); rw_piot_device_free(rw_piot_dev); return 0; }
int rw_piot_dev_reconfigure(rw_piot_api_handle_t api_handle, rw_piot_open_request_info_t *req_info, rw_piot_open_response_info_t *rsp_info) { int ret; rw_piot_device_t *rw_piot_dev = RWPIOT_GET_DEVICE(api_handle); ASSERT(RWPIOT_VALID_DEVICE(rw_piot_dev)); if (NULL == rw_piot_dev) { RW_PIOT_LOG(RTE_LOG_ERR, "PIOT Could not find device by handle\n"); return -1; } if (rw_piot_dev->device_group->device_group_type != PIOT_PCI) { req_info->dev_conf.intr_conf.lsc = 0; } ret = rw_piot_config_device(api_handle, req_info, rsp_info); return ret; }
int rw_piot_get_device_offload_capability(rw_piot_api_handle_t api_handle, uint32_t *rx_offload_capa, uint32_t *tx_offload_capa) { struct rte_eth_dev_info dev_info; rw_piot_device_t *rw_piot_dev = RWPIOT_GET_DEVICE(api_handle); ASSERT(RWPIOT_VALID_DEVICE(rw_piot_dev)); if (NULL == rw_piot_dev) { RW_PIOT_LOG(RTE_LOG_ERR, "PIOT Could not find device by handle\n"); return -1; } ASSERT(rx_offload_capa); ASSERT(tx_offload_capa); memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(rw_piot_dev->rte_port_id, &dev_info); *rx_offload_capa = dev_info.rx_offload_capa; *tx_offload_capa = dev_info.tx_offload_capa; return 0; }
/* * Create KNI for specified device */ struct rte_kni * rw_piot_kni_create(rw_piot_api_handle_t api_handle, struct rte_kni_conf *conf, struct rte_mempool * pktmbuf_pool) { struct rte_kni_ops ops; struct rte_eth_dev_info dev_info; struct rte_kni *kni; rw_piot_device_t *rw_piot_dev = RWPIOT_GET_DEVICE(api_handle); if ((conf->name[0] == 0)) { ASSERT(rw_piot_dev); rte_snprintf(conf->name, RTE_KNI_NAMESIZE,"vEth%u", rw_piot_dev->rte_port_id); } conf->mbuf_size = MAX_PACKET_SZ; memset(&dev_info, 0, sizeof(dev_info)); memset(&ops, 0, sizeof(ops)); if (rw_piot_dev) { rte_eth_dev_info_get(rw_piot_dev->rte_port_id, &dev_info); conf->group_id = (uint16_t)rw_piot_dev->rte_port_id; conf->addr = dev_info.pci_dev->addr; conf->id = dev_info.pci_dev->id; ops.port_id = rw_piot_dev->rte_port_id; } ops.change_mtu = rw_piot_kni_change_mtu; ops.config_network_if = rw_piot_kni_config_network_interface; kni = rte_kni_alloc(pktmbuf_pool, conf, &ops); if (NULL == kni) { printf("rte_kni_alloc returned failure\n"); return NULL; } return kni; }