Ejemplo n.º 1
0
/**
 * rw_piot_get_flow_ctrl()
 *
 * Get flow-control on an Ethernet device
 */
int
rw_piot_get_flow_ctrl(rw_piot_api_handle_t api_handle,
		      rw_piot_port_fc_conf_t *fc_cfgp)
{
  int rc = 0;
  rw_piot_device_t *rw_piot_dev = RWPIOT_GET_DEVICE(api_handle);
  ASSERT(NULL != fc_cfgp);
  

  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");
    rc = -1;
  }
  else {
    if (rw_piot_dev->device_group->device_group_type == PIOT_PCI) {
      rc = rte_eth_dev_flow_ctrl_get(rw_piot_dev->rte_port_id, fc_cfgp);
      if (rc != 0) {
        RW_PIOT_LOG(RTE_LOG_ERR, "PIOT rte_eth_dev_flow_ctrl_set() returned error_code=%d\n",rc);
      }
    }
  }
  
  return rc;
}
Ejemplo n.º 2
0
uint32_t
rw_piot_get_rte_port_id(rw_piot_api_handle_t api_handle)
{
   rw_piot_device_t *rw_piot_dev = RWPIOT_GET_DEVICE(api_handle);
  DP_ASSERT(RWPIOT_VALID_DEVICE(rw_piot_dev));
  return rw_piot_dev->rte_port_id;
}
Ejemplo n.º 3
0
int
rw_piot_update_mtu(rw_piot_api_handle_t api_handle, uint32_t mtu)
{
  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;
  }
  return(rte_eth_dev_set_mtu(rw_piot_dev->rte_port_id, mtu));  
}
Ejemplo n.º 4
0
int
rw_piot_mac_addr_delete(rw_piot_api_handle_t api_handle, struct ether_addr *addr)
{
  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;
  }
  return(rte_eth_dev_mac_addr_remove(rw_piot_dev->rte_port_id, addr));
}
Ejemplo n.º 5
0
int
rw_piot_get_vlan_offload(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) {
    RW_PIOT_LOG(RTE_LOG_ERR, "PIOT Could not find device by handle\n");
    return -1;
  }
  return rte_eth_dev_get_vlan_offload(rw_piot_dev->rte_port_id);
}
Ejemplo n.º 6
0
void 
rw_piot_get_link_info(rw_piot_api_handle_t api_handle, rw_piot_link_info_t *eth_link_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 || NULL == eth_link_info) {
    RW_PIOT_LOG(RTE_LOG_ERR, "PIOT Could not find device by handle or invalid input param\n");
    return;
  }
  rte_eth_link_get_nowait(rw_piot_dev->rte_port_id, eth_link_info);
  return;
}
Ejemplo n.º 7
0
void 
rw_piot_reset_link_stats(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) {
    RW_PIOT_LOG(RTE_LOG_ERR, "PIOT Could not find device by handle or invalid input param\n");
    return;
  }
  rte_eth_stats_reset(rw_piot_dev->rte_port_id);
  return;
}
Ejemplo n.º 8
0
int rw_piot_is_raw(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 ){
    return 0;
  }
  if (strstr(rw_piot_dev->device_group->device_group_name, "raw"))
    return 1;
  
  return 0;
}
Ejemplo n.º 9
0
int rw_piot_dev_callback_unregister(rw_piot_api_handle_t api_handle,
                                  enum rte_eth_event_type event,
                                  rte_eth_dev_cb_fn cb_fn, void *cb_arg)
{
  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;
  }
  return(rte_eth_dev_callback_unregister(rw_piot_dev->rte_port_id, event, cb_fn, cb_arg));
}
Ejemplo n.º 10
0
int
rw_piot_set_rx_queue_stats_mapping(rw_piot_api_handle_t api_handle, uint16_t rx_queue_id, uint8_t stat_idx)
{
  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;
  }
  ret = rte_eth_dev_set_rx_queue_stats_mapping(rw_piot_dev->rte_port_id, rx_queue_id, stat_idx);
  return(ret);
}
Ejemplo n.º 11
0
int
rw_piot_get_extended_stats(rw_piot_api_handle_t api_handle,
                           struct rte_eth_xstats *xstats, unsigned n)
{
  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 or invalid input param\n");
    return -1;
  }
  return rte_eth_xstats_get(rw_piot_dev->rte_port_id,
                            xstats, n);
}
Ejemplo n.º 12
0
int
rw_piot_device_free(rw_piot_device_t *dev)
{
  ASSERT(RWPIOT_VALID_DEVICE(dev));
  if ((NULL == dev) || (0 == dev->used)) {
    return -1;
  }
  dev->used = 0;
  dev->piot_api_handle = 0;
  dev->device_group->num_open_instances --;
  dev->device_group = NULL;
  return 0;
}
Ejemplo n.º 13
0
int 
rw_piot_get_device_info(rw_piot_api_handle_t api_handle,
                        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(dev_info);
  rte_eth_dev_info_get(rw_piot_dev->rte_port_id, dev_info);
  return 0;
}
Ejemplo n.º 14
0
int
rw_piot_update_vlan_filter(rw_piot_api_handle_t api_handle, uint16_t vlan_id,
                           int on)
{
  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;
  }

  return rte_eth_dev_vlan_filter(rw_piot_dev->rte_port_id,
                                 vlan_id, on);
}
Ejemplo n.º 15
0
int
rw_piot_set_mc_addr_list(rw_piot_api_handle_t api_handle,
                         struct ether_addr *mc_addr_set,
                         uint32_t nb_mc_addr)
{
  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 to set multicast addresses\n");
    return -1;
  }

  
  return rte_eth_dev_set_mc_addr_list(rw_piot_dev->rte_port_id, mc_addr_set, nb_mc_addr);  
}
Ejemplo n.º 16
0
int 
rw_piot_tx_queue_setup(rw_piot_api_handle_t api_handle,
                       uint16_t tx_queue_id,
                       uint16_t nb_tx_desc, 
                       unsigned int socket_id,
                       const struct rte_eth_txconf *tx_conf)

{
  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;
  }
  return(rte_eth_tx_queue_setup(rw_piot_dev->rte_port_id, tx_queue_id, nb_tx_desc, socket_id, tx_conf));
}
Ejemplo n.º 17
0
void 
rw_piot_set_promiscuous(rw_piot_api_handle_t api_handle, int on) 
{
  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;
  }
  if (on) {
     rte_eth_promiscuous_enable(rw_piot_dev->rte_port_id);
  }
  else {
     rte_eth_promiscuous_disable(rw_piot_dev->rte_port_id);
  }
  return;
}
Ejemplo n.º 18
0
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;
}
Ejemplo n.º 19
0
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;
}
Ejemplo n.º 20
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;
}
Ejemplo n.º 21
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;
}
Ejemplo n.º 22
0
rw_piot_device_t *
rw_piot_device_alloc(rw_piot_devgroup_t *devgroup)
{
  int i;
  rw_piot_device_t *dev = NULL;

  for (i=0; i<RWPIOT_MAX_DEVICES; i++) {
    if (0 == rw_piot_global_config.device[i].used) {
      dev = &rw_piot_global_config.device[i];
      dev->used = 1;
      dev->device_group = devgroup;
      dev->device_group->num_open_instances ++;
      dev->piot_api_handle = RWPIOT_GENERATE_HANDLE(dev);
      break;
    }
  }
  ASSERT(RWPIOT_VALID_DEVICE(dev));
  return(dev);
}
Ejemplo n.º 23
0
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;
}
Ejemplo n.º 24
0
int
rw_piot_config_device(rw_piot_device_t *dev,
                      rw_piot_open_request_info_t *req,
                      rw_piot_open_response_info_t *rsp)
{
  struct rte_eth_dev_info dev_info;

  ASSERT(RWPIOT_VALID_DEVICE(dev));

  bzero(rsp, sizeof(*rsp));
  bzero(&dev_info, sizeof(dev_info));

  rte_eth_dev_info_get(dev->rte_port_id, &dev_info);
  if (0 == dev_info.max_rx_queues ||  0 == dev_info.max_tx_queues) {
    printf("Eth device return 0 max rx/tx queues\n");
    return 0;
  } 
  rsp->num_rx_queues = req->num_rx_queues;
  if (rsp->num_rx_queues > dev_info.max_rx_queues) {
    rsp->num_rx_queues = dev_info.max_rx_queues;
  }
  rsp->num_tx_queues = req->num_tx_queues;
  if (rsp->num_tx_queues > dev_info.max_tx_queues) {
    rsp->num_tx_queues = dev_info.max_tx_queues;
  }

  if (!dev_info.rx_offload_capa) {
    req->dev_conf.rxmode.hw_ip_checksum = 0;
  }
  if (dev_info.pci_dev){
    if (dev_info.pci_dev->driver) {
      if (!(dev_info.pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
        req->dev_conf.intr_conf.lsc = 0;
      }
    }
  }
  return(rte_eth_dev_configure(dev->rte_port_id,  rsp->num_rx_queues,
                               rsp->num_tx_queues, &req->dev_conf));
}