#include "sfc_tweak.h"
#include "sfc_sw_stats.h"
-
bool
sfc_repr_supported(const struct sfc_adapter *sa)
{
sfc_log_init(sa, "entry");
SFC_ASSERT(sfc_adapter_is_locked(sa));
- SFC_ASSERT(sa->state == SFC_ADAPTER_STARTING);
+ SFC_ASSERT(sa->state == SFC_ETHDEV_STARTING);
sfc_log_init(sa, "set FW subvariant");
rc = sfc_set_fw_subvariant(sa);
SFC_ASSERT(sfc_adapter_is_locked(sa));
switch (sa->state) {
- case SFC_ADAPTER_CONFIGURED:
+ case SFC_ETHDEV_CONFIGURED:
break;
- case SFC_ADAPTER_STARTED:
+ case SFC_ETHDEV_STARTED:
sfc_notice(sa, "already started");
return 0;
default:
goto fail_bad_state;
}
- sa->state = SFC_ADAPTER_STARTING;
+ sa->state = SFC_ETHDEV_STARTING;
rc = 0;
do {
if (rc != 0)
goto fail_try_start;
- sa->state = SFC_ADAPTER_STARTED;
+ sa->state = SFC_ETHDEV_STARTED;
sfc_log_init(sa, "done");
return 0;
fail_try_start:
fail_sriov_vswitch_create:
- sa->state = SFC_ADAPTER_CONFIGURED;
+ sa->state = SFC_ETHDEV_CONFIGURED;
fail_bad_state:
sfc_log_init(sa, "failed %d", rc);
return rc;
SFC_ASSERT(sfc_adapter_is_locked(sa));
switch (sa->state) {
- case SFC_ADAPTER_STARTED:
+ case SFC_ETHDEV_STARTED:
break;
- case SFC_ADAPTER_CONFIGURED:
+ case SFC_ETHDEV_CONFIGURED:
sfc_notice(sa, "already stopped");
return;
default:
return;
}
- sa->state = SFC_ADAPTER_STOPPING;
+ sa->state = SFC_ETHDEV_STOPPING;
sfc_repr_proxy_stop(sa);
sfc_flow_stop(sa);
sfc_intr_stop(sa);
efx_nic_fini(sa->nic);
- sa->state = SFC_ADAPTER_CONFIGURED;
+ sa->state = SFC_ETHDEV_CONFIGURED;
sfc_log_init(sa, "done");
}
SFC_ASSERT(sfc_adapter_is_locked(sa));
- if (sa->state != SFC_ADAPTER_STARTED)
+ if (sa->state != SFC_ETHDEV_STARTED)
return EINVAL;
sfc_stop(sa);
if (rte_atomic32_cmpset((volatile uint32_t *)&sa->restart_required,
1, 0)) {
sfc_adapter_lock(sa);
- if (sa->state == SFC_ADAPTER_STARTED)
+ if (sa->state == SFC_ETHDEV_STARTED)
(void)sfc_restart(sa);
sfc_adapter_unlock(sa);
}
SFC_ASSERT(sfc_adapter_is_locked(sa));
- SFC_ASSERT(sa->state == SFC_ADAPTER_INITIALIZED ||
- sa->state == SFC_ADAPTER_CONFIGURED);
- sa->state = SFC_ADAPTER_CONFIGURING;
+ SFC_ASSERT(sa->state == SFC_ETHDEV_INITIALIZED ||
+ sa->state == SFC_ETHDEV_CONFIGURED);
+ sa->state = SFC_ETHDEV_CONFIGURING;
rc = sfc_check_conf(sa);
if (rc != 0)
if (rc != 0)
goto fail_sw_xstats_configure;
- sa->state = SFC_ADAPTER_CONFIGURED;
+ sa->state = SFC_ETHDEV_CONFIGURED;
sfc_log_init(sa, "done");
return 0;
fail_intr_configure:
fail_check_conf:
- sa->state = SFC_ADAPTER_INITIALIZED;
+ sa->state = SFC_ETHDEV_INITIALIZED;
sfc_log_init(sa, "failed %d", rc);
return rc;
}
SFC_ASSERT(sfc_adapter_is_locked(sa));
- SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED);
- sa->state = SFC_ADAPTER_CLOSING;
+ SFC_ASSERT(sa->state == SFC_ETHDEV_CONFIGURED);
+ sa->state = SFC_ETHDEV_CLOSING;
sfc_sw_xstats_close(sa);
sfc_tx_close(sa);
sfc_port_close(sa);
sfc_intr_close(sa);
- sa->state = SFC_ADAPTER_INITIALIZED;
+ sa->state = SFC_ETHDEV_INITIALIZED;
sfc_log_init(sa, "done");
}
if (rc != 0)
goto fail_sriov_vswitch_create;
- sa->state = SFC_ADAPTER_INITIALIZED;
+ sa->state = SFC_ETHDEV_INITIALIZED;
sfc_log_init(sa, "done");
return 0;
efx_tunnel_fini(sa->nic);
sfc_sriov_detach(sa);
- sa->state = SFC_ADAPTER_UNINITIALIZED;
+ sa->state = SFC_ETHDEV_UNINITIALIZED;
}
static int
sfc_mem_bar_fini(sa);
sfc_flow_fini(sa);
- sa->state = SFC_ADAPTER_UNINITIALIZED;
+ sa->state = SFC_ETHDEV_UNINITIALIZED;
}
uint32_t
#include "sfc_sw_stats.h"
#include "sfc_repr_proxy.h"
#include "sfc_service.h"
+#include "sfc_ethdev_state.h"
#ifdef __cplusplus
extern "C" {
#endif
-/*
- * +---------------+
- * | UNINITIALIZED |<-----------+
- * +---------------+ |
- * |.eth_dev_init |.eth_dev_uninit
- * V |
- * +---------------+------------+
- * | INITIALIZED |
- * +---------------+<-----------<---------------+
- * |.dev_configure | |
- * V |failed |
- * +---------------+------------+ |
- * | CONFIGURING | |
- * +---------------+----+ |
- * |success | |
- * | | +---------------+
- * | | | CLOSING |
- * | | +---------------+
- * | | ^
- * V |.dev_configure |
- * +---------------+----+ |.dev_close
- * | CONFIGURED |----------------------------+
- * +---------------+<-----------+
- * |.dev_start |
- * V |
- * +---------------+ |
- * | STARTING |------------^
- * +---------------+ failed |
- * |success |
- * | +---------------+
- * | | STOPPING |
- * | +---------------+
- * | ^
- * V |.dev_stop
- * +---------------+------------+
- * | STARTED |
- * +---------------+
- */
-enum sfc_adapter_state {
- SFC_ADAPTER_UNINITIALIZED = 0,
- SFC_ADAPTER_INITIALIZED,
- SFC_ADAPTER_CONFIGURING,
- SFC_ADAPTER_CONFIGURED,
- SFC_ADAPTER_CLOSING,
- SFC_ADAPTER_STARTING,
- SFC_ADAPTER_STARTED,
- SFC_ADAPTER_STOPPING,
-
- SFC_ADAPTER_NSTATES
-};
-
enum sfc_dev_filter_mode {
SFC_DEV_FILTER_MODE_PROMISC = 0,
SFC_DEV_FILTER_MODE_ALLMULTI,
* change its state should acquire the lock.
*/
rte_spinlock_t lock;
- enum sfc_adapter_state state;
+ enum sfc_ethdev_state state;
struct rte_eth_dev *eth_dev;
struct rte_kvargs *kvargs;
int socket_id;
sfc_adapter_lock(sa);
switch (sa->state) {
- case SFC_ADAPTER_CONFIGURED:
+ case SFC_ETHDEV_CONFIGURED:
/* FALLTHROUGH */
- case SFC_ADAPTER_INITIALIZED:
+ case SFC_ETHDEV_INITIALIZED:
rc = sfc_configure(sa);
break;
default:
sfc_log_init(sa, "entry");
- if (sa->state != SFC_ADAPTER_STARTED) {
+ if (sa->state != SFC_ETHDEV_STARTED) {
sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, ¤t_link);
} else if (wait_to_complete) {
efx_link_mode_t link_mode;
sfc_adapter_lock(sa);
switch (sa->state) {
- case SFC_ADAPTER_STARTED:
+ case SFC_ETHDEV_STARTED:
sfc_stop(sa);
- SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED);
+ SFC_ASSERT(sa->state == SFC_ETHDEV_CONFIGURED);
/* FALLTHROUGH */
- case SFC_ADAPTER_CONFIGURED:
+ case SFC_ETHDEV_CONFIGURED:
sfc_close(sa);
- SFC_ASSERT(sa->state == SFC_ADAPTER_INITIALIZED);
+ SFC_ASSERT(sa->state == SFC_ETHDEV_INITIALIZED);
/* FALLTHROUGH */
- case SFC_ADAPTER_INITIALIZED:
+ case SFC_ETHDEV_INITIALIZED:
break;
default:
sfc_err(sa, "unexpected adapter state %u on close", sa->state);
sfc_warn(sa, "the change is to be applied on the next "
"start provided that isolated mode is "
"disabled prior the next start");
- } else if ((sa->state == SFC_ADAPTER_STARTED) &&
+ } else if ((sa->state == SFC_ETHDEV_STARTED) &&
((rc = sfc_set_rx_mode(sa)) != 0)) {
*toggle = !(enabled);
sfc_warn(sa, "Failed to %s %s mode, rc = %d",
sfc_adapter_lock(sa);
- if (sa->state != SFC_ADAPTER_STARTED) {
+ if (sa->state != SFC_ETHDEV_STARTED) {
/*
* The operation cannot be done if port is not started; it
* will be scheduled to be done during the next port start
sfc_adapter_lock(sa);
- if (sa->state == SFC_ADAPTER_STARTED)
+ if (sa->state == SFC_ETHDEV_STARTED)
efx_mac_fcntl_get(sa->nic, &wanted_fc, &link_fc);
else
link_fc = sa->port.flow_ctrl;
sfc_adapter_lock(sa);
- if (sa->state == SFC_ADAPTER_STARTED) {
+ if (sa->state == SFC_ETHDEV_STARTED) {
rc = efx_mac_fcntl_set(sa->nic, fcntl, fc_conf->autoneg);
if (rc != 0)
goto fail_mac_fcntl_set;
goto fail_check_scatter;
if (pdu != sa->port.pdu) {
- if (sa->state == SFC_ADAPTER_STARTED) {
+ if (sa->state == SFC_ETHDEV_STARTED) {
sfc_stop(sa);
old_pdu = sa->port.pdu;
goto unlock;
}
- if (sa->state != SFC_ADAPTER_STARTED) {
+ if (sa->state != SFC_ETHDEV_STARTED) {
sfc_notice(sa, "the port is not started");
sfc_notice(sa, "the new MAC address will be set on port start");
port->nb_mcast_addrs = nb_mc_addr;
- if (sa->state != SFC_ADAPTER_STARTED)
+ if (sa->state != SFC_ETHDEV_STARTED)
return 0;
rc = efx_mac_multicast_list_set(sa->nic, port->mcast_addrs,
sfc_adapter_lock(sa);
rc = EINVAL;
- if (sa->state != SFC_ADAPTER_STARTED)
+ if (sa->state != SFC_ETHDEV_STARTED)
goto fail_not_started;
rxq_info = sfc_rxq_info_by_ethdev_qid(sas, sfc_ethdev_qid);
sfc_adapter_lock(sa);
rc = EINVAL;
- if (sa->state != SFC_ADAPTER_STARTED)
+ if (sa->state != SFC_ETHDEV_STARTED)
goto fail_not_started;
txq_info = sfc_txq_info_by_ethdev_qid(sas, ethdev_qid);
if (rc != 0)
goto fail_op;
- if (sa->state == SFC_ADAPTER_STARTED) {
+ if (sa->state == SFC_ETHDEV_STARTED) {
rc = efx_tunnel_reconfigure(sa->nic);
if (rc == EAGAIN) {
/*
}
if (rss_conf->rss_key != NULL) {
- if (sa->state == SFC_ADAPTER_STARTED) {
+ if (sa->state == SFC_ETHDEV_STARTED) {
for (key_i = 0; key_i < n_contexts; key_i++) {
rc = efx_rx_scale_key_set(sa->nic,
contexts[key_i],
}
}
- if (sa->state == SFC_ADAPTER_STARTED) {
+ if (sa->state == SFC_ETHDEV_STARTED) {
rc = efx_rx_scale_tbl_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
rss_tbl_new, EFX_RSS_TBL_SIZE);
if (rc != 0)
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2021 Xilinx, Inc.
+ * Copyright(c) 2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#ifndef _SFC_ETHDEV_STATE_H
+#define _SFC_ETHDEV_STATE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * +---------------+
+ * | UNINITIALIZED |<-----------+
+ * +---------------+ |
+ * |.eth_dev_init |.eth_dev_uninit
+ * V |
+ * +---------------+------------+
+ * | INITIALIZED |
+ * +---------------+<-----------<---------------+
+ * |.dev_configure | |
+ * V |failed |
+ * +---------------+------------+ |
+ * | CONFIGURING | |
+ * +---------------+----+ |
+ * |success | |
+ * | | +---------------+
+ * | | | CLOSING |
+ * | | +---------------+
+ * | | ^
+ * V |.dev_configure |
+ * +---------------+----+ |.dev_close
+ * | CONFIGURED |----------------------------+
+ * +---------------+<-----------+
+ * |.dev_start |
+ * V |
+ * +---------------+ |
+ * | STARTING |------------^
+ * +---------------+ failed |
+ * |success |
+ * | +---------------+
+ * | | STOPPING |
+ * | +---------------+
+ * | ^
+ * V |.dev_stop
+ * +---------------+------------+
+ * | STARTED |
+ * +---------------+
+ */
+enum sfc_ethdev_state {
+ SFC_ETHDEV_UNINITIALIZED = 0,
+ SFC_ETHDEV_INITIALIZED,
+ SFC_ETHDEV_CONFIGURING,
+ SFC_ETHDEV_CONFIGURED,
+ SFC_ETHDEV_CLOSING,
+ SFC_ETHDEV_STARTING,
+ SFC_ETHDEV_STARTED,
+ SFC_ETHDEV_STOPPING,
+
+ SFC_ETHDEV_NSTATES
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SFC_ETHDEV_STATE_H */
TAILQ_INSERT_TAIL(&sa->flow_list, flow, entries);
- if (sa->state == SFC_ADAPTER_STARTED) {
+ if (sa->state == SFC_ETHDEV_STARTED) {
rc = sfc_flow_insert(sa, flow, error);
if (rc != 0)
goto fail_flow_insert;
goto fail_bad_value;
}
- if (sa->state == SFC_ADAPTER_STARTED)
+ if (sa->state == SFC_ETHDEV_STARTED)
rc = sfc_flow_remove(sa, flow, error);
TAILQ_REMOVE(&sa->flow_list, flow, entries);
sfc_adapter_lock(sa);
while ((flow = TAILQ_FIRST(&sa->flow_list)) != NULL) {
- if (sa->state == SFC_ADAPTER_STARTED) {
+ if (sa->state == SFC_ETHDEV_STARTED) {
int rc;
rc = sfc_flow_remove(sa, flow, error);
goto fail_no_backend;
}
- if (sa->state != SFC_ADAPTER_STARTED) {
+ if (sa->state != SFC_ETHDEV_STARTED) {
ret = rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
"Can't query the flow: the adapter is not started");
int ret = 0;
sfc_adapter_lock(sa);
- if (sa->state != SFC_ADAPTER_INITIALIZED) {
+ if (sa->state != SFC_ETHDEV_INITIALIZED) {
rte_flow_error_set(error, EBUSY,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
NULL, "please close the port first");
sfc_log_init(sa, "entry");
- if (sa->state != SFC_ADAPTER_STARTED &&
- sa->state != SFC_ADAPTER_STARTING &&
- sa->state != SFC_ADAPTER_STOPPING) {
+ if (sa->state != SFC_ETHDEV_STARTED &&
+ sa->state != SFC_ETHDEV_STARTING &&
+ sa->state != SFC_ETHDEV_STOPPING) {
sfc_log_init(sa,
"interrupt on stopped adapter, don't reenable");
goto exit;
sfc_log_init(sa, "entry");
- if (sa->state != SFC_ADAPTER_STARTED &&
- sa->state != SFC_ADAPTER_STARTING &&
- sa->state != SFC_ADAPTER_STOPPING) {
+ if (sa->state != SFC_ETHDEV_STARTED &&
+ sa->state != SFC_ETHDEV_STARTING &&
+ sa->state != SFC_ETHDEV_STOPPING) {
sfc_log_init(sa, "adapter not-started, don't reenable");
goto exit;
}
SFC_ASSERT(sfc_adapter_is_locked(sa));
- if (sa->state != SFC_ADAPTER_STARTED)
+ if (sa->state != SFC_ETHDEV_STARTED)
return EAGAIN;
if (outer_rule != NULL) {
SFC_ASSERT(sfc_adapter_is_locked(sa));
- if (sa->state != SFC_ADAPTER_STARTED)
+ if (sa->state != SFC_ETHDEV_STARTED)
return 0;
/*