blob: e9137ca7d7e6b93ca4dcb8dfc039a1fc0bb164c7 [file] [log] [blame]
Ben Menchaca84f36632014-02-28 20:57:38 +00001/*
2 **************************************************************************
Kyle Swensona0ac1592021-05-21 08:08:08 -06003 * Copyright (c) 2014-2015, 2018-2021 The Linux Foundation. All rights reserved.
Ben Menchaca84f36632014-02-28 20:57:38 +00004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -060017extern int ecm_classifier_accel_delay_pkts; /* Default slow path packets allowed before the acceleration */
18
Ben Menchaca84f36632014-02-28 20:57:38 +000019struct ecm_classifier_instance;
20
21/*
22 * Classifier types.
23 * MUST BE RECORDED IN ASCENDING ORDER OF PRIORITY
24 */
25enum ecm_classifier_types {
26 ECM_CLASSIFIER_TYPE_DEFAULT = 0, /* MUST BE FIRST, Default classifier */
Murat Sezginf4f7ab42018-10-12 17:01:46 -070027#ifdef ECM_CLASSIFIER_MARK_ENABLE
28 ECM_CLASSIFIER_TYPE_MARK, /* Mark classifier */
29#endif
Hai Shalom81f4e202014-06-04 09:30:27 -070030#ifdef ECM_CLASSIFIER_HYFI_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +000031 ECM_CLASSIFIER_TYPE_HYFI, /* HyFi classifier */
Hai Shalom81f4e202014-06-04 09:30:27 -070032#endif
Murat Sezginb3731e82014-11-26 12:20:59 -080033#ifdef ECM_CLASSIFIER_DSCP_ENABLE
Gareth Williams8932a912014-06-11 18:06:25 -070034 ECM_CLASSIFIER_TYPE_DSCP, /* Provides DSCP and DSCP remarking support */
Murat Sezginb3731e82014-11-26 12:20:59 -080035#endif
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -060036#ifdef ECM_CLASSIFIER_MSCS_ENABLE
37 ECM_CLASSIFIER_TYPE_MSCS, /* Mirrored Stream Classification Signalling(MSCS) classifier */
38#endif
39#ifdef ECM_CLASSIFIER_EMESH_ENABLE
40 ECM_CLASSIFIER_TYPE_EMESH, /* E-Mesh classifier */
41#endif
Murat Sezginb3731e82014-11-26 12:20:59 -080042#ifdef ECM_CLASSIFIER_NL_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +000043 ECM_CLASSIFIER_TYPE_NL, /* Provides netlink interface */
Murat Sezginb3731e82014-11-26 12:20:59 -080044#endif
Murat Sezgina05befb2019-10-08 17:00:37 -070045#ifdef ECM_CLASSIFIER_OVS_ENABLE
46 ECM_CLASSIFIER_TYPE_OVS, /* OVS classifier */
47#endif
Gareth Williamsdcda9b92015-05-13 10:08:15 +010048#ifdef ECM_CLASSIFIER_PCC_ENABLE
49 ECM_CLASSIFIER_TYPE_PCC, /* Parental control subsystem support classifier */
50#endif
Ben Menchaca84f36632014-02-28 20:57:38 +000051 ECM_CLASSIFIER_TYPES, /* MUST BE LAST */
52};
53typedef enum ecm_classifier_types ecm_classifier_type_t;
54
55/*
56 * enum ecm_classifier_relevances
57 * Whether a classifier is relevant to a connection
58 */
59enum ecm_classifier_relevances {
60 ECM_CLASSIFIER_RELEVANCE_MAYBE = 0, /* Classifier has not yet determined relevance */
61 ECM_CLASSIFIER_RELEVANCE_NO, /* Classifier is not relevant to a connection (classifier will be unassigned from the connection after returning this from a process() call) */
62 ECM_CLASSIFIER_RELEVANCE_YES, /* Classifier is relevant to the connection, process actions will be inspected by the front end when returning this from a process() call */
63};
64typedef enum ecm_classifier_relevances ecm_classifier_relevence_t;
65
66/*
67 * enum ecm_classifier_acceleration_modes
68 * Modes in which a connection may be accelerated
Murat Sezgind701ac52014-08-20 14:02:30 -070069 *
70 * These are used by a classifier to indicate its desire to accelerate.
Ben Menchaca84f36632014-02-28 20:57:38 +000071 */
72enum ecm_classifier_acceleration_modes {
73 ECM_CLASSIFIER_ACCELERATION_MODE_DONT_CARE = 0, /* Classifier does not care if the connection is accelerated */
74 ECM_CLASSIFIER_ACCELERATION_MODE_NO, /* Connection must not be accelerated */
75 ECM_CLASSIFIER_ACCELERATION_MODE_ACCEL, /* Connection can be accelerated whenever */
76};
77typedef enum ecm_classifier_acceleration_modes ecm_classifier_acceleration_mode_t;
78
79/*
80 * Process actions
81 * A process result, that is relevant, may contain zero or more actions for the front end.
82 * Due to the parallel processing nature of classifiers, *usually* the action(s) of the highest priority
83 * classifier will override any lower priority actions. This is up to front end discretion, of course.
84 */
Gareth Williams27c3db12014-06-11 17:37:56 -070085#define ECM_CLASSIFIER_PROCESS_ACTION_DROP 0x00000001 /* Drop */
86#define ECM_CLASSIFIER_PROCESS_ACTION_QOS_TAG 0x00000002 /* Contains flow & return qos tags */
Ben Menchaca84f36632014-02-28 20:57:38 +000087#define ECM_CLASSIFIER_PROCESS_ACTION_ACCEL_MODE 0x00000004 /* Contains an accel mode */
88#define ECM_CLASSIFIER_PROCESS_ACTION_TIMER_GROUP 0x00000008 /* Contains a timer group change */
Murat Sezgin62c92832015-03-06 16:08:31 -080089
90#ifdef ECM_CLASSIFIER_DSCP_ENABLE
Gareth Williamsbd03e232014-06-11 17:55:28 -070091#define ECM_CLASSIFIER_PROCESS_ACTION_DSCP 0x00000010 /* Contains DSCP marking information */
92#define ECM_CLASSIFIER_PROCESS_ACTION_DSCP_DENY 0x00000020 /* Denies any DSCP changes */
Manish Vermaed493782019-05-27 12:56:02 +053093
94#define ECM_CLASSIFIER_PROCESS_ACTION_IGS_QOS_TAG 0x00000040 /* Contains flow & return ingress qos tags */
Murat Sezgin62c92832015-03-06 16:08:31 -080095#endif
Ben Menchaca84f36632014-02-28 20:57:38 +000096
Murat Sezgin964bfd82019-11-18 14:28:37 -080097#ifdef ECM_CLASSIFIER_OVS_ENABLE
98#define ECM_CLASSIFIER_PROCESS_ACTION_OVS_VLAN_TAG 0x00000080 /* Contains OVS VLAN tags */
Suman Ghoshe1c939c2019-11-12 20:43:04 +053099#define ECM_CLASSIFIER_PROCESS_ACTION_OVS_VLAN_QINQ_TAG 0x00000100 /* Contains OVS QinQ VLAN tags */
100#define ECM_CLASSIFIER_PROCESS_ACTION_OVS_MCAST_DENY_ACCEL 0x00000200 /* Multicast OVS flow */
Murat Sezgin964bfd82019-11-18 14:28:37 -0800101#endif
102
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600103#ifdef ECM_CLASSIFIER_EMESH_ENABLE
104#define ECM_CLASSIFIER_PROCESS_ACTION_EMESH_SP_FLOW 0x00000400 /* Mark the E-MESH Service Prioritization flow */
105#endif
106
107#define ECM_CLASSIFIER_PROCESS_ACTION_TIMER_GROUP_NO_TOUCH 0x00000400 /* Do not update CI time */
108
Kyle Swensona0ac1592021-05-21 08:08:08 -0600109#ifdef ECM_CLASSIFIER_PCC_ENABLE
110#define ECM_CLASSIFIER_PROCESS_ACTION_MIRROR_ENABLED 0x00000800 /* Contains mirror dynamic interface number */
111#endif
112
Ben Menchaca84f36632014-02-28 20:57:38 +0000113/*
114 * struct ecm_classifier_process_response
115 * Response structure returned by a process call
116 */
117struct ecm_classifier_process_response {
118 ecm_classifier_relevence_t relevance; /* Is this classifier relevant to the connection? */
119 uint32_t became_relevant; /* DB time the classifier became relevant or not relevant, if relevance is maybe this field is not relevant! */
120
121 uint32_t process_actions; /* Actions this process response contains */
122
123 /*
124 * The following fields are only to be inspected if this response is relevant AND the process_actions indicates so
125 */
126 bool drop; /* Drop packet at hand */
Gareth Williams27c3db12014-06-11 17:37:56 -0700127 uint32_t flow_qos_tag; /* QoS tag to use for the packet */
128 uint32_t return_qos_tag; /* QoS tag to use for the packet */
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600129#ifdef ECM_CLASSIFIER_DSCP_ENABLE
130#ifdef ECM_CLASSIFIER_DSCP_IGS
Manish Vermaed493782019-05-27 12:56:02 +0530131 uint16_t igs_flow_qos_tag; /* Ingress QoS tag to use for the packet */
132 uint16_t igs_return_qos_tag; /* Ingress QoS tag to use for the return packet */
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600133#endif
Gareth Williamsbd03e232014-06-11 17:55:28 -0700134 uint8_t flow_dscp; /* DSCP mark for flow */
135 uint8_t return_dscp; /* DSCP mark for return */
Murat Sezgin62c92832015-03-06 16:08:31 -0800136#endif
Murat Sezgin964bfd82019-11-18 14:28:37 -0800137#ifdef ECM_CLASSIFIER_OVS_ENABLE
138 uint32_t ingress_vlan_tag[2]; /* Ingress VLAN tags */
139 uint32_t egress_vlan_tag[2]; /* Egress VLAN tags */
Suman Ghosha11fc922020-01-08 14:34:03 +0530140#ifdef ECM_MULTICAST_ENABLE
141 int32_t egress_netdev_index[ECM_DB_MULTICAST_IF_MAX]; /* Multicast egress net device interface index */
142 uint32_t egress_mc_vlan_tag[ECM_DB_MULTICAST_IF_MAX][2]; /* Multicast egress VLAN tags */
143#endif
Murat Sezgin964bfd82019-11-18 14:28:37 -0800144#endif
Kyle Swensona0ac1592021-05-21 08:08:08 -0600145#ifdef ECM_CLASSIFIER_PCC_ENABLE
146 int flow_mirror_ifindex; /* Flow mirror device index value */
147 int return_mirror_ifindex; /* Return mirror device index value */
148#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000149 ecm_classifier_acceleration_mode_t accel_mode; /* Acceleration needed for this connection */
150 ecm_db_timer_group_t timer_group; /* Timer group the connection should be in */
151};
152
153/*
Murat Sezginb2676062015-06-12 17:05:31 -0700154 * Sync rule structure.
155 * Acceleration engine's sync parameters will be stored
156 * in this data structure to update the classifiers.
157 */
158struct ecm_classifier_rule_sync {
Murat Sezgine53be912020-01-07 16:04:57 -0800159 uint32_t tx_packet_count[ECM_CONN_DIR_MAX];
160 uint32_t tx_byte_count[ECM_CONN_DIR_MAX];
161 uint32_t rx_packet_count[ECM_CONN_DIR_MAX];
162 uint32_t rx_byte_count[ECM_CONN_DIR_MAX];
Murat Sezginb2676062015-06-12 17:05:31 -0700163 uint32_t reason;
164};
165
166/*
167 * Create rule structure.
168 * Additional create rule parameters from the classifiers
169 * will be copied to this data structure before pushing them to
170 * the underlying accelaration engine.
171 */
172struct ecm_classifier_rule_create {
Kyle Swensona0ac1592021-05-21 08:08:08 -0600173#ifdef ECM_CLASSIFIER_EMESH_ENABLE
174 struct sk_buff *skb;
175#endif
Murat Sezginb2676062015-06-12 17:05:31 -0700176};
177
178/*
Ben Menchaca84f36632014-02-28 20:57:38 +0000179 * To be implemented by all classifiers
180 */
181typedef void (*ecm_classifier_ref_method_t)(struct ecm_classifier_instance *ci);
182typedef int (*ecm_classifier_deref_callback_t)(struct ecm_classifier_instance *ci);
183typedef void (*ecm_classifier_process_callback_t)(struct ecm_classifier_instance *ci, ecm_tracker_sender_type_t sender, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, struct ecm_classifier_process_response *process_response);
184 /* Process new data for connection, process_response is populated with the response of processing */
Murat Sezginb2676062015-06-12 17:05:31 -0700185typedef void (*ecm_classifier_sync_from_v4_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_create *ecrc);
186 /* Sync the accel engine state with state from the classifier */
187typedef void (*ecm_classifier_sync_to_v4_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_sync *sync);
188 /* Sync the classifier state with current accel engine state */
189typedef void (*ecm_classifier_sync_from_v6_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_create *ecrc);
190 /* Sync the accel engine state with state from the classifier */
191typedef void (*ecm_classifier_sync_to_v6_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_sync *sync);
192 /* Sync the classifier state with current accel engine state */
Ben Menchaca84f36632014-02-28 20:57:38 +0000193typedef ecm_classifier_type_t (*ecm_classifier_type_get_callback_t)(struct ecm_classifier_instance *ci);
194 /* Get type of classifier this is */
195typedef bool (*ecm_classifier_reclassify_allowed_get_callback_t)(struct ecm_classifier_instance *ci);
196 /* Get whether reclassification is allowed */
197typedef void (*ecm_classifier_reclassify_callback_t)(struct ecm_classifier_instance *ci);
198 /* Reclassify */
199typedef void (*ecm_classifier_last_process_response_get_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_process_response *process_response);
200 /* Get last process response */
Gareth Williamsf98d4192015-03-11 16:55:41 +0000201#ifdef ECM_STATE_OUTPUT_ENABLE
Gareth Williamsd5618a82015-05-20 11:13:32 +0100202typedef int (*ecm_classifier_state_get_callback_t)(struct ecm_classifier_instance *ci, struct ecm_state_file_instance *sfi);
203 /* Get state output. Returns 0 upon success. */
Gareth Williamsf98d4192015-03-11 16:55:41 +0000204#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000205
206/*
Murat Sezgine34b0172015-11-05 21:58:14 -0800207 * Determines if a connection should be kept.
208 */
209typedef bool (*ecm_classifier_should_keep_connection_t)
210 (struct ecm_classifier_instance *ci, uint8_t *mac);
211
212/*
Ben Menchaca84f36632014-02-28 20:57:38 +0000213 * Base class for all types of classifiers
214 */
215struct ecm_classifier_instance {
216 struct ecm_classifier_instance *ca_next; /* DB use only: Connection assignment next pointer */
217 struct ecm_classifier_instance *ca_prev; /* DB use only: Connection assignment prev pointer */
218
219 ecm_classifier_process_callback_t process; /* Process new skb */
220 ecm_classifier_sync_from_v4_callback_t sync_from_v4;
Murat Sezginb2676062015-06-12 17:05:31 -0700221 /* Sync the accel engine with state from the classifier */
222 ecm_classifier_sync_to_v4_callback_t sync_to_v4;/* Sync the classifier with state from the accel engine */
Ben Menchaca84f36632014-02-28 20:57:38 +0000223 ecm_classifier_sync_from_v6_callback_t sync_from_v6;
Murat Sezginb2676062015-06-12 17:05:31 -0700224 /* Sync the accel engine with state from the classifier */
225 ecm_classifier_sync_to_v6_callback_t sync_to_v6;/* Sync the classifier with state from the accel engine */
Ben Menchaca84f36632014-02-28 20:57:38 +0000226 ecm_classifier_type_get_callback_t type_get; /* Get type of classifier */
227 ecm_classifier_reclassify_allowed_get_callback_t reclassify_allowed;
228 /* Get whether reclassification is allowed */
229 ecm_classifier_reclassify_callback_t reclassify;
230 /* Reclassify */
231 ecm_classifier_last_process_response_get_callback_t last_process_response_get;
232 /* Return last process response */
Murat Sezgine34b0172015-11-05 21:58:14 -0800233 ecm_classifier_should_keep_connection_t should_keep_connection;
234 /* Check if connection should be kept when FDB updates */
Gareth Williamsf98d4192015-03-11 16:55:41 +0000235#ifdef ECM_STATE_OUTPUT_ENABLE
Gareth Williamsd5618a82015-05-20 11:13:32 +0100236 ecm_classifier_state_get_callback_t state_get;
237 /* Return its state */
Gareth Williamsf98d4192015-03-11 16:55:41 +0000238#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000239 ecm_classifier_ref_method_t ref;
240 ecm_classifier_deref_callback_t deref;
241};
242
Gareth Williamsf98d4192015-03-11 16:55:41 +0000243#ifdef ECM_STATE_OUTPUT_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000244/*
Gareth Williamsd5618a82015-05-20 11:13:32 +0100245 * ecm_classifier_process_response_state_get()
246 * Output detail for the process response
Ben Menchaca84f36632014-02-28 20:57:38 +0000247 *
Gareth Williamsd5618a82015-05-20 11:13:32 +0100248 * Returns 0 on success.
Ben Menchaca84f36632014-02-28 20:57:38 +0000249 */
Gareth Williamsd5618a82015-05-20 11:13:32 +0100250static inline int ecm_classifier_process_response_state_get(struct ecm_state_file_instance *sfi, struct ecm_classifier_process_response *pr)
Ben Menchaca84f36632014-02-28 20:57:38 +0000251{
Gareth Williamsd5618a82015-05-20 11:13:32 +0100252 int result;
253
254 if ((result = ecm_state_prefix_add(sfi, "pr"))) {
255 return result;
256 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000257
258 if (pr->relevance == ECM_CLASSIFIER_RELEVANCE_NO) {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100259 return ecm_state_write(sfi, "relevant", "%s", "no");
Ben Menchaca84f36632014-02-28 20:57:38 +0000260 }
261
262 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_DROP) {
263 if (pr->drop) {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100264 if ((result = ecm_state_write(sfi, "drop", "yes"))) {
265 return result;
266 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000267 } else {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100268 if ((result = ecm_state_write(sfi, "drop", "no"))) {
269 return result;
270 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000271 }
272 }
273
Ben Menchaca84f36632014-02-28 20:57:38 +0000274 if (pr->relevance == ECM_CLASSIFIER_RELEVANCE_MAYBE) {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100275 if ((result = ecm_state_write(sfi, "accel", "denied"))) {
276 return result;
277 }
278 if ((result = ecm_state_write(sfi, "relevant", "maybe"))) {
279 return result;
280 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000281 } else {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100282 if ((result = ecm_state_write(sfi, "relevant", "yes"))) {
283 return result;
284 }
285 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_ACCEL_MODE) {
286 if (pr->accel_mode == ECM_CLASSIFIER_ACCELERATION_MODE_ACCEL) {
287 if ((result = ecm_state_write(sfi, "accel", "wanted"))) {
288 return result;
289 }
290 }
291 else if (pr->accel_mode == ECM_CLASSIFIER_ACCELERATION_MODE_NO) {
292 if ((result = ecm_state_write(sfi, "accel", "denied"))) {
293 return result;
294 }
295 }
296 /* Else don't care */
297 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000298 }
299
Murat Sezgin964bfd82019-11-18 14:28:37 -0800300#ifdef ECM_CLASSIFIER_OVS_ENABLE
301 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_OVS_VLAN_TAG) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530302#ifdef ECM_MULTICAST_ENABLE
303 int i;
304#endif
Suman Ghosha11fc922020-01-08 14:34:03 +0530305 /*
306 * TODO: Clean up the function later to print classifier
307 * specific data in each classifier’s state_get function.
308 */
Suman Ghosha33d7df2020-01-31 21:45:20 +0530309 if (pr->ingress_vlan_tag[0] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530310 if ((result = ecm_state_write(sfi, "ingress_vlan_tag[0]", "0x%x", pr->ingress_vlan_tag[0]))) {
311 return result;
312 }
Murat Sezgin964bfd82019-11-18 14:28:37 -0800313 }
Suman Ghosha11fc922020-01-08 14:34:03 +0530314
Suman Ghosha33d7df2020-01-31 21:45:20 +0530315 if (pr->ingress_vlan_tag[1] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530316 if ((result = ecm_state_write(sfi, "ingress_vlan_tag[1]", "0x%x", pr->ingress_vlan_tag[1]))) {
317 return result;
318 }
Murat Sezgin964bfd82019-11-18 14:28:37 -0800319 }
Suman Ghosha11fc922020-01-08 14:34:03 +0530320
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600321 if (pr->egress_vlan_tag[0] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
322 if ((result = ecm_state_write(sfi, "egress_vlan_tag[0]", "0x%x", pr->egress_vlan_tag[0]))) {
323 return result;
324 }
325 }
326
Suman Ghosha33d7df2020-01-31 21:45:20 +0530327 if (pr->egress_vlan_tag[1] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530328 if ((result = ecm_state_write(sfi, "egress_vlan_tag[1]", "0x%x", pr->egress_vlan_tag[1]))) {
329 return result;
330 }
Murat Sezgin964bfd82019-11-18 14:28:37 -0800331 }
Suman Ghosha11fc922020-01-08 14:34:03 +0530332
333#ifdef ECM_MULTICAST_ENABLE
334 for (i = 0; i < ECM_DB_MULTICAST_IF_MAX; i++) {
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600335 struct net_device *dev;
Suman Ghosha11fc922020-01-08 14:34:03 +0530336
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600337 if (pr->egress_mc_vlan_tag[i][0] == ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530338 continue;
339 }
340
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600341 dev = dev_get_by_index(&init_net, pr->egress_netdev_index[i]);
342 if (dev) {
343 if ((result = ecm_state_write(sfi, "port_egress", "%s", dev->name))) {
344 dev_put(dev);
345 return result;
346 }
347 dev_put(dev);
348 }
349
350 if ((result = ecm_state_write(sfi, "port_egress_vlan_tag[0]", "0x%x", pr->egress_mc_vlan_tag[i][0]))) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530351 return result;
352 }
353
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600354 if (pr->egress_mc_vlan_tag[i][1] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
355 if ((result = ecm_state_write(sfi, "port_egress_vlan_tag[1]", "0x%x", pr->egress_mc_vlan_tag[i][1]))) {
356 return result;
357 }
Suman Ghosha11fc922020-01-08 14:34:03 +0530358 }
359 }
360#endif
Murat Sezgin964bfd82019-11-18 14:28:37 -0800361 }
362#endif
363
Gareth Williamsd5618a82015-05-20 11:13:32 +0100364 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_QOS_TAG) {
365 if ((result = ecm_state_write(sfi, "flow_qos_tag", "%u", pr->flow_qos_tag))) {
366 return result;
367 }
368 if ((result = ecm_state_write(sfi, "return_qos_tag", "%u", pr->return_qos_tag))) {
369 return result;
370 }
371 }
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600372#ifdef ECM_CLASSIFIER_DSCP_ENABLE
373#ifdef ECM_CLASSIFIER_DSCP_IGS
Manish Vermaed493782019-05-27 12:56:02 +0530374 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_IGS_QOS_TAG) {
375 if ((result = ecm_state_write(sfi, "igs_flow_qos_tag", "%u", pr->igs_flow_qos_tag))) {
376 return result;
377 }
378 if ((result = ecm_state_write(sfi, "igs_return_qos_tag", "%u", pr->igs_return_qos_tag))) {
379 return result;
380 }
381 }
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600382#endif
Gareth Williamsd5618a82015-05-20 11:13:32 +0100383 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_DSCP) {
384 if ((result = ecm_state_write(sfi, "flow_dscp", "%u", pr->flow_dscp))) {
385 return result;
386 }
387 if ((result = ecm_state_write(sfi, "return_dscp", "%u", pr->return_dscp))) {
388 return result;
389 }
390 }
391#endif
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600392
Gareth Williamsd5618a82015-05-20 11:13:32 +0100393 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_TIMER_GROUP) {
394 if ((result = ecm_state_write(sfi, "timer_group", "%d", pr->timer_group))) {
395 return result;
396 }
397 }
398
399 return ecm_state_prefix_remove(sfi);
Ben Menchaca84f36632014-02-28 20:57:38 +0000400}
Gareth Williamsf98d4192015-03-11 16:55:41 +0000401#endif
402
Murat Sezginc725ad82016-04-13 17:12:50 -0700403extern struct ecm_classifier_instance *ecm_classifier_assign_classifier(struct ecm_db_connection_instance *ci, ecm_classifier_type_t type);
404extern bool ecm_classifier_reclassify(struct ecm_db_connection_instance *ci, int assignment_count, struct ecm_classifier_instance *assignments[]);