#include "sfc.h"
#include "sfc_ev.h"
#include "sfc_rx.h"
+#include "sfc_tx.h"
/**
* Amount of time to wait for the representor proxy routine (which is
return 0;
}
+static int
+sfc_repr_proxy_txq_attach(struct sfc_adapter *sa)
+{
+ struct sfc_adapter_shared * const sas = sfc_sa2shared(sa);
+ struct sfc_repr_proxy *rp = &sa->repr_proxy;
+ unsigned int i;
+
+ sfc_log_init(sa, "entry");
+
+ for (i = 0; i < sfc_repr_nb_txq(sas); i++) {
+ sfc_sw_index_t sw_index = sfc_repr_txq_sw_index(sas, i);
+
+ rp->dp_txq[i].sw_index = sw_index;
+ }
+
+ sfc_log_init(sa, "done");
+
+ return 0;
+}
+
+static void
+sfc_repr_proxy_txq_detach(struct sfc_adapter *sa)
+{
+ struct sfc_adapter_shared * const sas = sfc_sa2shared(sa);
+ struct sfc_repr_proxy *rp = &sa->repr_proxy;
+ unsigned int i;
+
+ sfc_log_init(sa, "entry");
+
+ for (i = 0; i < sfc_repr_nb_txq(sas); i++)
+ rp->dp_txq[i].sw_index = 0;
+
+ sfc_log_init(sa, "done");
+}
+
+int
+sfc_repr_proxy_txq_init(struct sfc_adapter *sa)
+{
+ struct sfc_adapter_shared * const sas = sfc_sa2shared(sa);
+ struct sfc_repr_proxy *rp = &sa->repr_proxy;
+ const struct rte_eth_txconf tx_conf = {
+ .tx_free_thresh = SFC_REPR_PROXY_TXQ_FREE_THRESH,
+ };
+ struct sfc_txq_info *txq_info;
+ unsigned int init_i;
+ unsigned int i;
+ int rc;
+
+ sfc_log_init(sa, "entry");
+
+ if (!sfc_repr_available(sas)) {
+ sfc_log_init(sa, "representors not supported - skip");
+ return 0;
+ }
+
+ for (init_i = 0; init_i < sfc_repr_nb_txq(sas); init_i++) {
+ struct sfc_repr_proxy_dp_txq *txq = &rp->dp_txq[init_i];
+
+ txq_info = &sfc_sa2shared(sa)->txq_info[txq->sw_index];
+ if (txq_info->state == SFC_TXQ_INITIALIZED) {
+ sfc_log_init(sa,
+ "representor proxy TxQ %u is already initialized - skip",
+ init_i);
+ continue;
+ }
+
+ sfc_tx_qinit_info(sa, txq->sw_index);
+
+ rc = sfc_tx_qinit(sa, txq->sw_index,
+ SFC_REPR_PROXY_TX_DESC_COUNT, sa->socket_id,
+ &tx_conf);
+
+ if (rc != 0) {
+ sfc_err(sa, "failed to init representor proxy TxQ %u",
+ init_i);
+ goto fail_init;
+ }
+ }
+
+ sfc_log_init(sa, "done");
+
+ return 0;
+
+fail_init:
+ for (i = 0; i < init_i; i++) {
+ struct sfc_repr_proxy_dp_txq *txq = &rp->dp_txq[i];
+
+ txq_info = &sfc_sa2shared(sa)->txq_info[txq->sw_index];
+ if (txq_info->state == SFC_TXQ_INITIALIZED)
+ sfc_tx_qfini(sa, txq->sw_index);
+ }
+ sfc_log_init(sa, "failed: %s", rte_strerror(rc));
+
+ return rc;
+}
+
+void
+sfc_repr_proxy_txq_fini(struct sfc_adapter *sa)
+{
+ struct sfc_adapter_shared * const sas = sfc_sa2shared(sa);
+ struct sfc_repr_proxy *rp = &sa->repr_proxy;
+ struct sfc_txq_info *txq_info;
+ unsigned int i;
+
+ sfc_log_init(sa, "entry");
+
+ if (!sfc_repr_available(sas)) {
+ sfc_log_init(sa, "representors not supported - skip");
+ return;
+ }
+
+ for (i = 0; i < sfc_repr_nb_txq(sas); i++) {
+ struct sfc_repr_proxy_dp_txq *txq = &rp->dp_txq[i];
+
+ txq_info = &sfc_sa2shared(sa)->txq_info[txq->sw_index];
+ if (txq_info->state != SFC_TXQ_INITIALIZED) {
+ sfc_log_init(sa,
+ "representor proxy TxQ %u is already finalized - skip",
+ i);
+ continue;
+ }
+
+ sfc_tx_qfini(sa, txq->sw_index);
+ }
+
+ sfc_log_init(sa, "done");
+}
+
+static int
+sfc_repr_proxy_txq_start(struct sfc_adapter *sa)
+{
+ struct sfc_repr_proxy *rp = &sa->repr_proxy;
+
+ sfc_log_init(sa, "entry");
+
+ RTE_SET_USED(rp);
+
+ sfc_log_init(sa, "done");
+
+ return 0;
+}
+
+static void
+sfc_repr_proxy_txq_stop(struct sfc_adapter *sa)
+{
+ sfc_log_init(sa, "entry");
+ sfc_log_init(sa, "done");
+}
+
static int
sfc_repr_proxy_rxq_attach(struct sfc_adapter *sa)
{
if (rc != 0)
goto fail_rxq_attach;
+ rc = sfc_repr_proxy_txq_attach(sa);
+ if (rc != 0)
+ goto fail_txq_attach;
+
rc = sfc_repr_proxy_ports_init(sa);
if (rc != 0)
goto fail_ports_init;
sfc_repr_proxy_ports_fini(sa);
fail_ports_init:
+ sfc_repr_proxy_txq_detach(sa);
+
+fail_txq_attach:
sfc_repr_proxy_rxq_detach(sa);
fail_rxq_attach:
rte_service_component_unregister(rp->service_id);
sfc_repr_proxy_ports_fini(sa);
sfc_repr_proxy_rxq_detach(sa);
+ sfc_repr_proxy_txq_detach(sa);
sfc_log_init(sa, "done");
}
if (rc != 0)
goto fail_rxq_start;
+ rc = sfc_repr_proxy_txq_start(sa);
+ if (rc != 0)
+ goto fail_txq_start;
+
/* Service core may be in "stopped" state, start it */
rc = rte_service_lcore_start(rp->service_core_id);
if (rc != 0 && rc != -EALREADY) {
/* Service lcore may be shared and we never stop it */
fail_start_core:
+ sfc_repr_proxy_txq_stop(sa);
+
+fail_txq_start:
sfc_repr_proxy_rxq_stop(sa);
fail_rxq_start:
/* Service lcore may be shared and we never stop it */
sfc_repr_proxy_rxq_stop(sa);
+ sfc_repr_proxy_txq_stop(sa);
rp->started = false;
#define SFC_REPR_PROXY_RXQ_REFILL_LEVEL (SFC_REPR_PROXY_RX_DESC_COUNT / 4)
#define SFC_REPR_PROXY_RX_BURST 32
+#define SFC_REPR_PROXY_TX_DESC_COUNT 256
+#define SFC_REPR_PROXY_TXQ_FREE_THRESH (SFC_REPR_PROXY_TX_DESC_COUNT / 4)
+#define SFC_REPR_PROXY_TX_BURST 32
+
struct sfc_repr_proxy_rxq {
struct rte_ring *ring;
struct rte_mempool *mb_pool;
sfc_sw_index_t sw_index;
};
+struct sfc_repr_proxy_dp_txq {
+ sfc_sw_index_t sw_index;
+};
+
enum sfc_repr_proxy_mbox_op {
SFC_REPR_PROXY_MBOX_ADD_PORT,
SFC_REPR_PROXY_MBOX_DEL_PORT,
struct sfc_repr_proxy_ports ports;
bool started;
struct sfc_repr_proxy_dp_rxq dp_rxq[SFC_REPR_PROXY_NB_RXQ_MAX];
+ struct sfc_repr_proxy_dp_txq dp_txq[SFC_REPR_PROXY_NB_TXQ_MAX];
struct sfc_repr_proxy_mbox mbox;
};
int sfc_repr_proxy_attach(struct sfc_adapter *sa);
void sfc_repr_proxy_pre_detach(struct sfc_adapter *sa);
void sfc_repr_proxy_detach(struct sfc_adapter *sa);
+int sfc_repr_proxy_txq_init(struct sfc_adapter *sa);
+void sfc_repr_proxy_txq_fini(struct sfc_adapter *sa);
int sfc_repr_proxy_start(struct sfc_adapter *sa);
void sfc_repr_proxy_stop(struct sfc_adapter *sa);
txq->evq = NULL;
}
-static int
+int
sfc_tx_qinit_info(struct sfc_adapter *sa, sfc_sw_index_t sw_index)
{
struct sfc_adapter_shared * const sas = sfc_sa2shared(sa);
const unsigned int nb_tx_queues = sa->eth_dev->data->nb_tx_queues;
const unsigned int nb_rsvd_tx_queues = sfc_nb_txq_reserved(sas);
const unsigned int nb_txq_total = nb_tx_queues + nb_rsvd_tx_queues;
+ bool reconfigure;
int rc = 0;
sfc_log_init(sa, "nb_tx_queues=%u (old %u)",
goto done;
if (sas->txq_info == NULL) {
+ reconfigure = false;
sas->txq_info = rte_calloc_socket("sfc-txqs", nb_txq_total,
sizeof(sas->txq_info[0]), 0,
sa->socket_id);
struct sfc_txq_info *new_txq_info;
struct sfc_txq *new_txq_ctrl;
+ reconfigure = true;
+
if (nb_tx_queues < sas->ethdev_txq_count)
sfc_tx_fini_queues(sa, nb_tx_queues);
sas->ethdev_txq_count++;
}
- /* TODO: initialize reserved queues when supported. */
sas->txq_count = sas->ethdev_txq_count + nb_rsvd_tx_queues;
+ if (!reconfigure) {
+ rc = sfc_repr_proxy_txq_init(sa);
+ if (rc != 0)
+ goto fail_repr_proxy_txq_init;
+ }
+
done:
return 0;
+fail_repr_proxy_txq_init:
fail_tx_qinit_info:
fail_txqs_ctrl_realloc:
fail_txqs_realloc:
sfc_tx_close(struct sfc_adapter *sa)
{
sfc_tx_fini_queues(sa, 0);
+ sfc_repr_proxy_txq_fini(sa);
free(sa->txq_ctrl);
sa->txq_ctrl = NULL;