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.
15 #include <rte_spinlock.h>
23 /** FW-allocatable resource context */
24 struct sfc_mae_fw_rsrc {
28 efx_mae_aset_id_t aset_id;
32 /** Action set registry entry */
33 struct sfc_mae_action_set {
34 TAILQ_ENTRY(sfc_mae_action_set) entries;
36 efx_mae_actions_t *spec;
37 struct sfc_mae_fw_rsrc fw_rsrc;
40 TAILQ_HEAD(sfc_mae_action_sets, sfc_mae_action_set);
42 /** Options for MAE support status */
44 SFC_MAE_STATUS_UNKNOWN = 0,
45 SFC_MAE_STATUS_UNSUPPORTED,
46 SFC_MAE_STATUS_SUPPORTED
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;
65 /** This implementation supports double-tagging */
66 #define SFC_MAE_MATCH_VLAN_MAX_NTAGS (2)
68 /** It is possible to keep track of one item ETH and two items VLAN */
69 #define SFC_MAE_L2_MAX_NITEMS (SFC_MAE_MATCH_VLAN_MAX_NTAGS + 1)
71 /** Auxiliary entry format to keep track of L2 "type" ("inner_type") */
72 struct sfc_mae_ethertype {
77 struct sfc_mae_pattern_data {
79 * Keeps track of "type" ("inner_type") mask and value for each
80 * parsed L2 item in a pattern. These values/masks get filled
81 * in MAE match specification at the end of parsing. Also, this
82 * information is used to conduct consistency checks:
84 * - If an item ETH is followed by a single item VLAN,
85 * the former must have "type" set to one of supported
86 * TPID values (0x8100, 0x88a8, 0x9100, 0x9200, 0x9300).
88 * - If an item ETH is followed by two items VLAN, the
89 * item ETH must have "type" set to one of supported TPID
90 * values (0x88a8, 0x9100, 0x9200, 0x9300), and the outermost
91 * VLAN item must have "inner_type" set to TPID value 0x8100.
93 * In turn, mapping between RTE convention (above requirements) and
94 * MAE fields is non-trivial. The following scheme indicates
95 * which item EtherTypes go to which MAE fields in the case
98 * ETH (0x8100) --> VLAN0_PROTO_BE
99 * VLAN (L3 EtherType) --> ETHER_TYPE_BE
101 * Similarly, in the case of double tagging:
103 * ETH (0x88a8) --> VLAN0_PROTO_BE
104 * VLAN (0x8100) --> VLAN1_PROTO_BE
105 * VLAN (L3 EtherType) --> ETHER_TYPE_BE
107 struct sfc_mae_ethertype ethertypes[SFC_MAE_L2_MAX_NITEMS];
108 unsigned int nb_vlan_tags;
111 struct sfc_mae_parse_ctx {
112 struct sfc_adapter *sa;
113 efx_mae_match_spec_t *match_spec_action;
114 bool match_mport_set;
115 struct sfc_mae_pattern_data pattern_data;
118 int sfc_mae_attach(struct sfc_adapter *sa);
119 void sfc_mae_detach(struct sfc_adapter *sa);
120 sfc_flow_cleanup_cb_t sfc_mae_flow_cleanup;
121 int sfc_mae_rule_parse_pattern(struct sfc_adapter *sa,
122 const struct rte_flow_item pattern[],
123 struct sfc_flow_spec_mae *spec,
124 struct rte_flow_error *error);
125 int sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
126 const struct rte_flow_action actions[],
127 struct sfc_mae_action_set **action_setp,
128 struct rte_flow_error *error);
129 sfc_flow_verify_cb_t sfc_mae_flow_verify;
130 sfc_flow_insert_cb_t sfc_mae_flow_insert;
131 sfc_flow_remove_cb_t sfc_mae_flow_remove;
136 #endif /* _SFC_MAE_H */