TAILQ_FOREACH(rule, &mae->outer_rules, entries) {
if (efx_mae_match_specs_equal(rule->match_spec, match_spec) &&
rule->encap_type == encap_type) {
+ sfc_dbg(sa, "attaching to outer_rule=%p", rule);
++(rule->refcnt);
return rule;
}
*rulep = rule;
+ sfc_dbg(sa, "added outer_rule=%p", rule);
+
return 0;
}
if (rule->refcnt != 0)
return;
- SFC_ASSERT(rule->fw_rsrc.rule_id.id == EFX_MAE_RSRC_ID_INVALID);
- SFC_ASSERT(rule->fw_rsrc.refcnt == 0);
+ if (rule->fw_rsrc.rule_id.id != EFX_MAE_RSRC_ID_INVALID ||
+ rule->fw_rsrc.refcnt != 0) {
+ sfc_err(sa, "deleting outer_rule=%p abandons its FW resource: OR_ID=0x%08x, refcnt=%u",
+ rule, rule->fw_rsrc.rule_id.id, rule->fw_rsrc.refcnt);
+ }
efx_mae_match_spec_fini(sa->nic, rule->match_spec);
TAILQ_REMOVE(&mae->outer_rules, rule, entries);
rte_free(rule);
+
+ sfc_dbg(sa, "deleted outer_rule=%p", rule);
}
static int
rc = efx_mae_outer_rule_insert(sa->nic, rule->match_spec,
rule->encap_type,
&fw_rsrc->rule_id);
- if (rc != 0)
+ if (rc != 0) {
+ sfc_err(sa, "failed to enable outer_rule=%p: %s",
+ rule, strerror(rc));
return rc;
+ }
}
rc = efx_mae_match_spec_outer_rule_id_set(match_spec_action,
if (fw_rsrc->refcnt == 0) {
(void)efx_mae_outer_rule_remove(sa->nic,
&fw_rsrc->rule_id);
+ fw_rsrc->rule_id.id = EFX_MAE_RSRC_ID_INVALID;
}
+
+ sfc_err(sa, "can't match on outer rule ID: %s", strerror(rc));
+
return rc;
}
+ if (fw_rsrc->refcnt == 0) {
+ sfc_dbg(sa, "enabled outer_rule=%p: OR_ID=0x%08x",
+ rule, fw_rsrc->rule_id.id);
+ }
+
++(fw_rsrc->refcnt);
return 0;
}
-static int
+static void
sfc_mae_outer_rule_disable(struct sfc_adapter *sa,
struct sfc_mae_outer_rule *rule)
{
int rc;
SFC_ASSERT(sfc_adapter_is_locked(sa));
- SFC_ASSERT(fw_rsrc->rule_id.id != EFX_MAE_RSRC_ID_INVALID);
- SFC_ASSERT(fw_rsrc->refcnt != 0);
+
+ if (fw_rsrc->rule_id.id == EFX_MAE_RSRC_ID_INVALID ||
+ fw_rsrc->refcnt == 0) {
+ sfc_err(sa, "failed to disable outer_rule=%p: already disabled; OR_ID=0x%08x, refcnt=%u",
+ rule, fw_rsrc->rule_id.id, fw_rsrc->refcnt);
+ return;
+ }
if (fw_rsrc->refcnt == 1) {
rc = efx_mae_outer_rule_remove(sa->nic, &fw_rsrc->rule_id);
- if (rc != 0)
- return rc;
-
+ if (rc == 0) {
+ sfc_dbg(sa, "disabled outer_rule=%p with OR_ID=0x%08x",
+ rule, fw_rsrc->rule_id.id);
+ } else {
+ sfc_err(sa, "failed to disable outer_rule=%p with OR_ID=0x%08x: %s",
+ rule, fw_rsrc->rule_id.id, strerror(rc));
+ }
fw_rsrc->rule_id.id = EFX_MAE_RSRC_ID_INVALID;
}
--(fw_rsrc->refcnt);
-
- return 0;
}
static struct sfc_mae_encap_header *
if (encap_header->size == bounce_eh->size &&
memcmp(encap_header->buf, bounce_eh->buf,
bounce_eh->size) == 0) {
+ sfc_dbg(sa, "attaching to encap_header=%p",
+ encap_header);
++(encap_header->refcnt);
return encap_header;
}
*encap_headerp = encap_header;
+ sfc_dbg(sa, "added encap_header=%p", encap_header);
+
return 0;
}
if (encap_header->refcnt != 0)
return;
- SFC_ASSERT(encap_header->fw_rsrc.eh_id.id == EFX_MAE_RSRC_ID_INVALID);
- SFC_ASSERT(encap_header->fw_rsrc.refcnt == 0);
+ if (encap_header->fw_rsrc.eh_id.id != EFX_MAE_RSRC_ID_INVALID ||
+ encap_header->fw_rsrc.refcnt != 0) {
+ sfc_err(sa, "deleting encap_header=%p abandons its FW resource: EH_ID=0x%08x, refcnt=%u",
+ encap_header, encap_header->fw_rsrc.eh_id.id,
+ encap_header->fw_rsrc.refcnt);
+ }
TAILQ_REMOVE(&mae->encap_headers, encap_header, entries);
rte_free(encap_header->buf);
rte_free(encap_header);
+
+ sfc_dbg(sa, "deleted encap_header=%p", encap_header);
}
static int
encap_header->buf,
encap_header->size,
&fw_rsrc->eh_id);
- if (rc != 0)
+ if (rc != 0) {
+ sfc_err(sa, "failed to enable encap_header=%p: %s",
+ encap_header, strerror(rc));
return rc;
+ }
}
rc = efx_mae_action_set_fill_in_eh_id(action_set_spec,
if (fw_rsrc->refcnt == 0) {
(void)efx_mae_encap_header_free(sa->nic,
&fw_rsrc->eh_id);
+ fw_rsrc->eh_id.id = EFX_MAE_RSRC_ID_INVALID;
}
+
+ sfc_err(sa, "can't fill in encap. header ID: %s", strerror(rc));
+
return rc;
}
+ if (fw_rsrc->refcnt == 0) {
+ sfc_dbg(sa, "enabled encap_header=%p: EH_ID=0x%08x",
+ encap_header, fw_rsrc->eh_id.id);
+ }
+
++(fw_rsrc->refcnt);
return 0;
}
-static int
+static void
sfc_mae_encap_header_disable(struct sfc_adapter *sa,
struct sfc_mae_encap_header *encap_header)
{
int rc;
if (encap_header == NULL)
- return 0;
+ return;
SFC_ASSERT(sfc_adapter_is_locked(sa));
fw_rsrc = &encap_header->fw_rsrc;
- SFC_ASSERT(fw_rsrc->eh_id.id != EFX_MAE_RSRC_ID_INVALID);
- SFC_ASSERT(fw_rsrc->refcnt != 0);
+ if (fw_rsrc->eh_id.id == EFX_MAE_RSRC_ID_INVALID ||
+ fw_rsrc->refcnt == 0) {
+ sfc_err(sa, "failed to disable encap_header=%p: already disabled; EH_ID=0x%08x, refcnt=%u",
+ encap_header, fw_rsrc->eh_id.id, fw_rsrc->refcnt);
+ return;
+ }
if (fw_rsrc->refcnt == 1) {
rc = efx_mae_encap_header_free(sa->nic, &fw_rsrc->eh_id);
- if (rc != 0)
- return rc;
-
+ if (rc == 0) {
+ sfc_dbg(sa, "disabled encap_header=%p with EH_ID=0x%08x",
+ encap_header, fw_rsrc->eh_id.id);
+ } else {
+ sfc_err(sa, "failed to disable encap_header=%p with EH_ID=0x%08x: %s",
+ encap_header, fw_rsrc->eh_id.id, strerror(rc));
+ }
fw_rsrc->eh_id.id = EFX_MAE_RSRC_ID_INVALID;
}
--(fw_rsrc->refcnt);
-
- return 0;
}
static struct sfc_mae_action_set *
TAILQ_FOREACH(action_set, &mae->action_sets, entries) {
if (action_set->encap_header == encap_header &&
efx_mae_action_set_specs_equal(action_set->spec, spec)) {
+ sfc_dbg(sa, "attaching to action_set=%p", action_set);
++(action_set->refcnt);
return action_set;
}
*action_setp = action_set;
+ sfc_dbg(sa, "added action_set=%p", action_set);
+
return 0;
}
if (action_set->refcnt != 0)
return;
- SFC_ASSERT(action_set->fw_rsrc.aset_id.id == EFX_MAE_RSRC_ID_INVALID);
- SFC_ASSERT(action_set->fw_rsrc.refcnt == 0);
+ if (action_set->fw_rsrc.aset_id.id != EFX_MAE_RSRC_ID_INVALID ||
+ action_set->fw_rsrc.refcnt != 0) {
+ sfc_err(sa, "deleting action_set=%p abandons its FW resource: AS_ID=0x%08x, refcnt=%u",
+ action_set, action_set->fw_rsrc.aset_id.id,
+ action_set->fw_rsrc.refcnt);
+ }
efx_mae_action_set_spec_fini(sa->nic, action_set->spec);
sfc_mae_encap_header_del(sa, action_set->encap_header);
TAILQ_REMOVE(&mae->action_sets, action_set, entries);
rte_free(action_set);
+
+ sfc_dbg(sa, "deleted action_set=%p", action_set);
}
static int
rc = efx_mae_action_set_alloc(sa->nic, action_set->spec,
&fw_rsrc->aset_id);
if (rc != 0) {
- (void)sfc_mae_encap_header_disable(sa, encap_header);
+ sfc_mae_encap_header_disable(sa, encap_header);
+
+ sfc_err(sa, "failed to enable action_set=%p: %s",
+ action_set, strerror(rc));
return rc;
}
+
+ sfc_dbg(sa, "enabled action_set=%p: AS_ID=0x%08x",
+ action_set, fw_rsrc->aset_id.id);
}
++(fw_rsrc->refcnt);
return 0;
}
-static int
+static void
sfc_mae_action_set_disable(struct sfc_adapter *sa,
struct sfc_mae_action_set *action_set)
{
int rc;
SFC_ASSERT(sfc_adapter_is_locked(sa));
- SFC_ASSERT(fw_rsrc->aset_id.id != EFX_MAE_RSRC_ID_INVALID);
- SFC_ASSERT(fw_rsrc->refcnt != 0);
+
+ if (fw_rsrc->aset_id.id == EFX_MAE_RSRC_ID_INVALID ||
+ fw_rsrc->refcnt == 0) {
+ sfc_err(sa, "failed to disable action_set=%p: already disabled; AS_ID=0x%08x, refcnt=%u",
+ action_set, fw_rsrc->aset_id.id, fw_rsrc->refcnt);
+ return;
+ }
if (fw_rsrc->refcnt == 1) {
rc = efx_mae_action_set_free(sa->nic, &fw_rsrc->aset_id);
- if (rc != 0)
- return rc;
-
+ if (rc == 0) {
+ sfc_dbg(sa, "disabled action_set=%p with AS_ID=0x%08x",
+ action_set, fw_rsrc->aset_id.id);
+ } else {
+ sfc_err(sa, "failed to disable action_set=%p with AS_ID=0x%08x: %s",
+ action_set, fw_rsrc->aset_id.id, strerror(rc));
+ }
fw_rsrc->aset_id.id = EFX_MAE_RSRC_ID_INVALID;
- rc = sfc_mae_encap_header_disable(sa, action_set->encap_header);
- if (rc != 0)
- return rc;
+ sfc_mae_encap_header_disable(sa, action_set->encap_header);
}
--(fw_rsrc->refcnt);
-
- return 0;
}
void
if (rc != 0)
goto fail_action_rule_insert;
+ sfc_dbg(sa, "enabled flow=%p: AR_ID=0x%08x",
+ flow, spec_mae->rule_id.id);
+
return 0;
fail_action_rule_insert:
- (void)sfc_mae_action_set_disable(sa, action_set);
+ sfc_mae_action_set_disable(sa, action_set);
fail_action_set_enable:
if (outer_rule != NULL)
- (void)sfc_mae_outer_rule_disable(sa, outer_rule);
+ sfc_mae_outer_rule_disable(sa, outer_rule);
fail_outer_rule_enable:
return rc;
SFC_ASSERT(action_set != NULL);
rc = efx_mae_action_rule_remove(sa->nic, &spec_mae->rule_id);
- if (rc != 0)
- return rc;
-
- spec_mae->rule_id.id = EFX_MAE_RSRC_ID_INVALID;
-
- rc = sfc_mae_action_set_disable(sa, action_set);
if (rc != 0) {
- sfc_err(sa, "failed to disable the action set (rc = %d)", rc);
- /* Despite the error, proceed with outer rule removal. */
+ sfc_err(sa, "failed to disable flow=%p with AR_ID=0x%08x: %s",
+ flow, spec_mae->rule_id.id, strerror(rc));
}
+ sfc_dbg(sa, "disabled flow=%p with AR_ID=0x%08x",
+ flow, spec_mae->rule_id.id);
+ spec_mae->rule_id.id = EFX_MAE_RSRC_ID_INVALID;
+
+ sfc_mae_action_set_disable(sa, action_set);
if (outer_rule != NULL)
- return sfc_mae_outer_rule_disable(sa, outer_rule);
+ sfc_mae_outer_rule_disable(sa, outer_rule);
return 0;
}