1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2020 Xilinx, Inc.
4 * Copyright(c) 2019 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
12 #include <rte_common.h>
20 sfc_mae_attach(struct sfc_adapter *sa)
22 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
23 struct sfc_mae *mae = &sa->mae;
24 efx_mae_limits_t limits;
27 sfc_log_init(sa, "entry");
29 if (!encp->enc_mae_supported) {
30 mae->status = SFC_MAE_STATUS_UNSUPPORTED;
34 sfc_log_init(sa, "init MAE");
35 rc = efx_mae_init(sa->nic);
39 sfc_log_init(sa, "get MAE limits");
40 rc = efx_mae_get_limits(sa->nic, &limits);
42 goto fail_mae_get_limits;
44 mae->status = SFC_MAE_STATUS_SUPPORTED;
45 mae->nb_action_rule_prios_max = limits.eml_max_n_action_prios;
47 sfc_log_init(sa, "done");
52 efx_mae_fini(sa->nic);
55 sfc_log_init(sa, "failed %d", rc);
61 sfc_mae_detach(struct sfc_adapter *sa)
63 struct sfc_mae *mae = &sa->mae;
64 enum sfc_mae_status status_prev = mae->status;
66 sfc_log_init(sa, "entry");
68 mae->nb_action_rule_prios_max = 0;
69 mae->status = SFC_MAE_STATUS_UNKNOWN;
71 if (status_prev != SFC_MAE_STATUS_SUPPORTED)
74 efx_mae_fini(sa->nic);
76 sfc_log_init(sa, "done");
80 sfc_mae_flow_cleanup(struct sfc_adapter *sa,
81 struct rte_flow *flow)
83 struct sfc_flow_spec *spec;
84 struct sfc_flow_spec_mae *spec_mae;
94 spec_mae = &spec->mae;
96 if (spec_mae->match_spec != NULL)
97 efx_mae_match_spec_fini(sa->nic, spec_mae->match_spec);
100 static const struct sfc_flow_item sfc_flow_items[] = {
104 sfc_mae_rule_parse_pattern(struct sfc_adapter *sa,
105 const struct rte_flow_item pattern[],
106 struct sfc_flow_spec_mae *spec,
107 struct rte_flow_error *error)
109 struct sfc_mae_parse_ctx ctx_mae;
110 struct sfc_flow_parse_ctx ctx;
113 memset(&ctx_mae, 0, sizeof(ctx_mae));
115 rc = efx_mae_match_spec_init(sa->nic, EFX_MAE_RULE_ACTION,
117 &ctx_mae.match_spec_action);
119 rc = rte_flow_error_set(error, rc,
120 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
121 "Failed to initialise action rule match specification");
122 goto fail_init_match_spec_action;
125 ctx.type = SFC_FLOW_PARSE_CTX_MAE;
128 rc = sfc_flow_parse_pattern(sfc_flow_items, RTE_DIM(sfc_flow_items),
129 pattern, &ctx, error);
131 goto fail_parse_pattern;
133 spec->match_spec = ctx_mae.match_spec_action;
138 efx_mae_match_spec_fini(sa->nic, ctx_mae.match_spec_action);
140 fail_init_match_spec_action: