f92e62dcbef64137a38d63ec336227b15e9c1641
[dpdk.git] / drivers / net / sfc / sfc_mae.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2019-2020 Xilinx, Inc.
4  * Copyright(c) 2019 Solarflare Communications Inc.
5  *
6  * This software was jointly developed between OKTET Labs (under contract
7  * for Solarflare) and Solarflare Communications, Inc.
8  */
9
10 #ifndef _SFC_MAE_H
11 #define _SFC_MAE_H
12
13 #include <stdbool.h>
14
15 #include <rte_spinlock.h>
16
17 #include "efx.h"
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /** FW-allocatable resource context */
24 struct sfc_mae_fw_rsrc {
25         unsigned int                    refcnt;
26         RTE_STD_C11
27         union {
28                 efx_mae_aset_id_t       aset_id;
29         };
30 };
31
32 /** Action set registry entry */
33 struct sfc_mae_action_set {
34         TAILQ_ENTRY(sfc_mae_action_set) entries;
35         unsigned int                    refcnt;
36         efx_mae_actions_t               *spec;
37         struct sfc_mae_fw_rsrc          fw_rsrc;
38 };
39
40 TAILQ_HEAD(sfc_mae_action_sets, sfc_mae_action_set);
41
42 /** Options for MAE support status */
43 enum sfc_mae_status {
44         SFC_MAE_STATUS_UNKNOWN = 0,
45         SFC_MAE_STATUS_UNSUPPORTED,
46         SFC_MAE_STATUS_SUPPORTED
47 };
48
49 struct sfc_mae {
50         /** Assigned switch domain identifier */
51         uint16_t                        switch_domain_id;
52         /** Assigned switch port identifier */
53         uint16_t                        switch_port_id;
54         /** NIC support for MAE status */
55         enum sfc_mae_status             status;
56         /** Priority level limit for MAE action rules */
57         unsigned int                    nb_action_rule_prios_max;
58         /** Action set registry */
59         struct sfc_mae_action_sets      action_sets;
60 };
61
62 struct sfc_adapter;
63 struct sfc_flow_spec;
64
65 struct sfc_mae_parse_ctx {
66         struct sfc_adapter              *sa;
67         efx_mae_match_spec_t            *match_spec_action;
68         bool                            match_mport_set;
69 };
70
71 int sfc_mae_attach(struct sfc_adapter *sa);
72 void sfc_mae_detach(struct sfc_adapter *sa);
73 sfc_flow_cleanup_cb_t sfc_mae_flow_cleanup;
74 int sfc_mae_rule_parse_pattern(struct sfc_adapter *sa,
75                                const struct rte_flow_item pattern[],
76                                struct sfc_flow_spec_mae *spec,
77                                struct rte_flow_error *error);
78 int sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
79                                const struct rte_flow_action actions[],
80                                struct sfc_mae_action_set **action_setp,
81                                struct rte_flow_error *error);
82 sfc_flow_verify_cb_t sfc_mae_flow_verify;
83 sfc_flow_insert_cb_t sfc_mae_flow_insert;
84 sfc_flow_remove_cb_t sfc_mae_flow_remove;
85
86 #ifdef __cplusplus
87 }
88 #endif
89 #endif /* _SFC_MAE_H */