Example #1
0
/* TODO populate more fields of the port desc */
indigo_error_t indigo_port_features_get(
    of_features_reply_t *features)
{
    indigo_error_t      result             = INDIGO_ERROR_NONE;
    of_list_port_desc_t *of_list_port_desc = 0;
    of_port_desc_t      *of_port_desc      = 0;

    if (features->version >= OF_VERSION_1_3) {
        return INDIGO_ERROR_NONE;
    }

    if ((of_port_desc = of_port_desc_new(features->version)) == 0) {
        LOG_ERROR("of_port_desc_new() failed");
        result = INDIGO_ERROR_UNKNOWN;
        goto done;
    }

    if ((of_list_port_desc = of_list_port_desc_new(features->version)) == 0) {
        LOG_ERROR("of_list_port_desc_new() failed");
        result = INDIGO_ERROR_UNKNOWN;
        goto done;
    }

    int i;
    for (i = 0; i < IND_OVS_MAX_PORTS; i++) {
        if (ind_ovs_ports[i]) {
            port_desc_set(of_port_desc, i);
            /* TODO error handling */
            of_list_port_desc_append(of_list_port_desc, of_port_desc);
        }
    }

    port_desc_set_local(of_port_desc);
    /* TODO error handling */
    of_list_port_desc_append(of_list_port_desc, of_port_desc);

    if (LOXI_FAILURE(of_features_reply_ports_set(features,
                                                 of_list_port_desc
                                                 )
                     )
        ) {
        LOG_ERROR("of_features_reply_ports_set() failed");
        result = INDIGO_ERROR_UNKNOWN;
        goto done;
    }

 done:
    if (of_list_port_desc)  of_list_port_desc_delete(of_list_port_desc);
    if (of_port_desc)       of_port_desc_delete(of_port_desc);

    return (result);
}
Example #2
0
indigo_error_t indigo_port_features_get(of_features_reply_t *features)
{
  indigo_error_t      err             = INDIGO_ERROR_NONE;
  of_list_port_desc_t *of_list_port_desc = 0;
  of_port_desc_t      *of_port_desc      = 0;
  uint32_t port = 0, nextPort = 0;
  OFDPA_ERROR_t ofdpa_rv = OFDPA_E_NONE;


  LOG_TRACE("%s() called\n",__FUNCTION__);

  if (features->version < OF_VERSION_1_3)
  {
    return INDIGO_ERROR_VERSION;
  }

  /* Allocates memory for of_port_desc */
  of_port_desc = of_port_desc_new(features->version);
  if (of_port_desc == NULL)
  {
    LOG_ERROR("of_port_desc_new() failed");
    return INDIGO_ERROR_RESOURCE;
  }

  /* Allocates memory for of_list_port_desc */
  of_list_port_desc = of_list_port_desc_new(features->version);
  if (of_list_port_desc == NULL)
  {
    LOG_ERROR("of_list_port_desc_new() failed");

    /* free of_list_port_desc */
    of_port_desc_delete(of_port_desc);

    return INDIGO_ERROR_RESOURCE;
  }

  ofdpa_rv = ofdpaPortNextGet(port, &nextPort);
  while(ofdpa_rv == OFDPA_E_NONE)
  {
    err = ind_ofdpa_port_features_set(nextPort, of_port_desc);
    if (err != INDIGO_ERROR_NONE)
    {
      LOG_ERROR("Failed to get OpenFlow port stats.");
      break;
    }
    of_list_port_desc_append(of_list_port_desc, of_port_desc);
    port = nextPort;
    ofdpa_rv = ofdpaPortNextGet(port, &nextPort);
  }

  /* free the allocated memory */
  of_port_desc_delete(of_port_desc);
  of_list_port_desc_delete(of_list_port_desc);

  return err;
}
Example #3
0
indigo_error_t indigo_port_desc_stats_get(of_port_desc_stats_reply_t *port_desc_stats_reply)
{
  indigo_error_t err = INDIGO_ERROR_NONE;
  OFDPA_ERROR_t ofdpa_rv = OFDPA_E_NONE;
  of_port_desc_t *of_port_desc = 0;
  of_list_port_desc_t *of_list_port_desc = 0;
  uint32_t port= 0, nextPort = 0;

  LOG_TRACE("%s() called.", __FUNCTION__);

  if (port_desc_stats_reply->version < OF_VERSION_1_3)
  {
    return INDIGO_ERROR_VERSION;
  }

  /* Allocates memory for of_port_desc */
  of_port_desc = of_port_desc_new(port_desc_stats_reply->version);
  if (of_port_desc == NULL)
  {
    LOG_ERROR("of_port_desc_new() failed");
    return INDIGO_ERROR_RESOURCE;
  }

  /* Allocates memory for of_list_port_desc */
  of_list_port_desc = of_list_port_desc_new(port_desc_stats_reply->version);
  if (of_list_port_desc == NULL)
  {
    LOG_ERROR("of_list_port_desc_new() failed");
    of_port_desc_delete(of_port_desc);
    return INDIGO_ERROR_RESOURCE;
  }

  ofdpa_rv = ofdpaPortNextGet(port, &nextPort);
  while(ofdpa_rv == OFDPA_E_NONE)
  {
    /* Set the port description parameters in LOCI structure (of_port_desc)
       to be sent in the reply message */
    err = ind_ofdpa_port_desc_set(nextPort, of_port_desc);
    if (err != INDIGO_ERROR_NONE)
    {
      LOG_ERROR("Failed to get OpenFlow port description for port %d.", nextPort);
      break;
    }

    if (of_list_port_desc_append(of_list_port_desc, of_port_desc) < 0)
    {
      LOG_ERROR("of_list_port_desc_append() failed");
      err = INDIGO_ERROR_UNKNOWN;
      break;
    }
    port = nextPort;
    ofdpa_rv = ofdpaPortNextGet(port, &nextPort);
  }

  if (of_port_desc_stats_reply_entries_set(port_desc_stats_reply, of_list_port_desc) < 0)
  {
    LOG_ERROR("of_port_desc_stats_reply_entries_set() failed");
    err = INDIGO_ERROR_UNKNOWN;
  }

  /* free the allocated memory */
  of_port_desc_delete(of_port_desc);
  of_list_port_desc_delete(of_list_port_desc);

  return err;
}