blob: a4ffcf74f8f6852c327150e59faa2fa0f6dc3293 [file] [log] [blame]
Ben Menchaca84f36632014-02-28 20:57:38 +00001/*
2 **************************************************************************
Murat Sezgina05befb2019-10-08 17:00:37 -07003 * Copyright (c) 2014-2015, 2018-2020 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
Ben Menchaca84f36632014-02-28 20:57:38 +0000109/*
110 * struct ecm_classifier_process_response
111 * Response structure returned by a process call
112 */
113struct ecm_classifier_process_response {
114 ecm_classifier_relevence_t relevance; /* Is this classifier relevant to the connection? */
115 uint32_t became_relevant; /* DB time the classifier became relevant or not relevant, if relevance is maybe this field is not relevant! */
116
117 uint32_t process_actions; /* Actions this process response contains */
118
119 /*
120 * The following fields are only to be inspected if this response is relevant AND the process_actions indicates so
121 */
122 bool drop; /* Drop packet at hand */
Gareth Williams27c3db12014-06-11 17:37:56 -0700123 uint32_t flow_qos_tag; /* QoS tag to use for the packet */
124 uint32_t return_qos_tag; /* QoS tag to use for the packet */
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600125#ifdef ECM_CLASSIFIER_DSCP_ENABLE
126#ifdef ECM_CLASSIFIER_DSCP_IGS
Manish Vermaed493782019-05-27 12:56:02 +0530127 uint16_t igs_flow_qos_tag; /* Ingress QoS tag to use for the packet */
128 uint16_t igs_return_qos_tag; /* Ingress QoS tag to use for the return packet */
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600129#endif
Gareth Williamsbd03e232014-06-11 17:55:28 -0700130 uint8_t flow_dscp; /* DSCP mark for flow */
131 uint8_t return_dscp; /* DSCP mark for return */
Murat Sezgin62c92832015-03-06 16:08:31 -0800132#endif
Murat Sezgin964bfd82019-11-18 14:28:37 -0800133#ifdef ECM_CLASSIFIER_OVS_ENABLE
134 uint32_t ingress_vlan_tag[2]; /* Ingress VLAN tags */
135 uint32_t egress_vlan_tag[2]; /* Egress VLAN tags */
Suman Ghosha11fc922020-01-08 14:34:03 +0530136#ifdef ECM_MULTICAST_ENABLE
137 int32_t egress_netdev_index[ECM_DB_MULTICAST_IF_MAX]; /* Multicast egress net device interface index */
138 uint32_t egress_mc_vlan_tag[ECM_DB_MULTICAST_IF_MAX][2]; /* Multicast egress VLAN tags */
139#endif
Murat Sezgin964bfd82019-11-18 14:28:37 -0800140#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000141 ecm_classifier_acceleration_mode_t accel_mode; /* Acceleration needed for this connection */
142 ecm_db_timer_group_t timer_group; /* Timer group the connection should be in */
143};
144
145/*
Murat Sezginb2676062015-06-12 17:05:31 -0700146 * Sync rule structure.
147 * Acceleration engine's sync parameters will be stored
148 * in this data structure to update the classifiers.
149 */
150struct ecm_classifier_rule_sync {
Murat Sezgine53be912020-01-07 16:04:57 -0800151 uint32_t tx_packet_count[ECM_CONN_DIR_MAX];
152 uint32_t tx_byte_count[ECM_CONN_DIR_MAX];
153 uint32_t rx_packet_count[ECM_CONN_DIR_MAX];
154 uint32_t rx_byte_count[ECM_CONN_DIR_MAX];
Murat Sezginb2676062015-06-12 17:05:31 -0700155 uint32_t reason;
156};
157
158/*
159 * Create rule structure.
160 * Additional create rule parameters from the classifiers
161 * will be copied to this data structure before pushing them to
162 * the underlying accelaration engine.
163 */
164struct ecm_classifier_rule_create {
165
166};
167
168/*
Ben Menchaca84f36632014-02-28 20:57:38 +0000169 * To be implemented by all classifiers
170 */
171typedef void (*ecm_classifier_ref_method_t)(struct ecm_classifier_instance *ci);
172typedef int (*ecm_classifier_deref_callback_t)(struct ecm_classifier_instance *ci);
173typedef 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);
174 /* Process new data for connection, process_response is populated with the response of processing */
Murat Sezginb2676062015-06-12 17:05:31 -0700175typedef void (*ecm_classifier_sync_from_v4_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_create *ecrc);
176 /* Sync the accel engine state with state from the classifier */
177typedef void (*ecm_classifier_sync_to_v4_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_sync *sync);
178 /* Sync the classifier state with current accel engine state */
179typedef void (*ecm_classifier_sync_from_v6_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_create *ecrc);
180 /* Sync the accel engine state with state from the classifier */
181typedef void (*ecm_classifier_sync_to_v6_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_sync *sync);
182 /* Sync the classifier state with current accel engine state */
Ben Menchaca84f36632014-02-28 20:57:38 +0000183typedef ecm_classifier_type_t (*ecm_classifier_type_get_callback_t)(struct ecm_classifier_instance *ci);
184 /* Get type of classifier this is */
185typedef bool (*ecm_classifier_reclassify_allowed_get_callback_t)(struct ecm_classifier_instance *ci);
186 /* Get whether reclassification is allowed */
187typedef void (*ecm_classifier_reclassify_callback_t)(struct ecm_classifier_instance *ci);
188 /* Reclassify */
189typedef void (*ecm_classifier_last_process_response_get_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_process_response *process_response);
190 /* Get last process response */
Gareth Williamsf98d4192015-03-11 16:55:41 +0000191#ifdef ECM_STATE_OUTPUT_ENABLE
Gareth Williamsd5618a82015-05-20 11:13:32 +0100192typedef int (*ecm_classifier_state_get_callback_t)(struct ecm_classifier_instance *ci, struct ecm_state_file_instance *sfi);
193 /* Get state output. Returns 0 upon success. */
Gareth Williamsf98d4192015-03-11 16:55:41 +0000194#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000195
196/*
Murat Sezgine34b0172015-11-05 21:58:14 -0800197 * Determines if a connection should be kept.
198 */
199typedef bool (*ecm_classifier_should_keep_connection_t)
200 (struct ecm_classifier_instance *ci, uint8_t *mac);
201
202/*
Ben Menchaca84f36632014-02-28 20:57:38 +0000203 * Base class for all types of classifiers
204 */
205struct ecm_classifier_instance {
206 struct ecm_classifier_instance *ca_next; /* DB use only: Connection assignment next pointer */
207 struct ecm_classifier_instance *ca_prev; /* DB use only: Connection assignment prev pointer */
208
209 ecm_classifier_process_callback_t process; /* Process new skb */
210 ecm_classifier_sync_from_v4_callback_t sync_from_v4;
Murat Sezginb2676062015-06-12 17:05:31 -0700211 /* Sync the accel engine with state from the classifier */
212 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 +0000213 ecm_classifier_sync_from_v6_callback_t sync_from_v6;
Murat Sezginb2676062015-06-12 17:05:31 -0700214 /* Sync the accel engine with state from the classifier */
215 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 +0000216 ecm_classifier_type_get_callback_t type_get; /* Get type of classifier */
217 ecm_classifier_reclassify_allowed_get_callback_t reclassify_allowed;
218 /* Get whether reclassification is allowed */
219 ecm_classifier_reclassify_callback_t reclassify;
220 /* Reclassify */
221 ecm_classifier_last_process_response_get_callback_t last_process_response_get;
222 /* Return last process response */
Murat Sezgine34b0172015-11-05 21:58:14 -0800223 ecm_classifier_should_keep_connection_t should_keep_connection;
224 /* Check if connection should be kept when FDB updates */
Gareth Williamsf98d4192015-03-11 16:55:41 +0000225#ifdef ECM_STATE_OUTPUT_ENABLE
Gareth Williamsd5618a82015-05-20 11:13:32 +0100226 ecm_classifier_state_get_callback_t state_get;
227 /* Return its state */
Gareth Williamsf98d4192015-03-11 16:55:41 +0000228#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000229 ecm_classifier_ref_method_t ref;
230 ecm_classifier_deref_callback_t deref;
231};
232
Gareth Williamsf98d4192015-03-11 16:55:41 +0000233#ifdef ECM_STATE_OUTPUT_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000234/*
Gareth Williamsd5618a82015-05-20 11:13:32 +0100235 * ecm_classifier_process_response_state_get()
236 * Output detail for the process response
Ben Menchaca84f36632014-02-28 20:57:38 +0000237 *
Gareth Williamsd5618a82015-05-20 11:13:32 +0100238 * Returns 0 on success.
Ben Menchaca84f36632014-02-28 20:57:38 +0000239 */
Gareth Williamsd5618a82015-05-20 11:13:32 +0100240static 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 +0000241{
Gareth Williamsd5618a82015-05-20 11:13:32 +0100242 int result;
243
244 if ((result = ecm_state_prefix_add(sfi, "pr"))) {
245 return result;
246 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000247
248 if (pr->relevance == ECM_CLASSIFIER_RELEVANCE_NO) {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100249 return ecm_state_write(sfi, "relevant", "%s", "no");
Ben Menchaca84f36632014-02-28 20:57:38 +0000250 }
251
252 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_DROP) {
253 if (pr->drop) {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100254 if ((result = ecm_state_write(sfi, "drop", "yes"))) {
255 return result;
256 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000257 } else {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100258 if ((result = ecm_state_write(sfi, "drop", "no"))) {
259 return result;
260 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000261 }
262 }
263
Ben Menchaca84f36632014-02-28 20:57:38 +0000264 if (pr->relevance == ECM_CLASSIFIER_RELEVANCE_MAYBE) {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100265 if ((result = ecm_state_write(sfi, "accel", "denied"))) {
266 return result;
267 }
268 if ((result = ecm_state_write(sfi, "relevant", "maybe"))) {
269 return result;
270 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000271 } else {
Gareth Williamsd5618a82015-05-20 11:13:32 +0100272 if ((result = ecm_state_write(sfi, "relevant", "yes"))) {
273 return result;
274 }
275 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_ACCEL_MODE) {
276 if (pr->accel_mode == ECM_CLASSIFIER_ACCELERATION_MODE_ACCEL) {
277 if ((result = ecm_state_write(sfi, "accel", "wanted"))) {
278 return result;
279 }
280 }
281 else if (pr->accel_mode == ECM_CLASSIFIER_ACCELERATION_MODE_NO) {
282 if ((result = ecm_state_write(sfi, "accel", "denied"))) {
283 return result;
284 }
285 }
286 /* Else don't care */
287 }
Ben Menchaca84f36632014-02-28 20:57:38 +0000288 }
289
Murat Sezgin964bfd82019-11-18 14:28:37 -0800290#ifdef ECM_CLASSIFIER_OVS_ENABLE
291 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_OVS_VLAN_TAG) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530292#ifdef ECM_MULTICAST_ENABLE
293 int i;
294#endif
Suman Ghosha11fc922020-01-08 14:34:03 +0530295 /*
296 * TODO: Clean up the function later to print classifier
297 * specific data in each classifier’s state_get function.
298 */
Suman Ghosha33d7df2020-01-31 21:45:20 +0530299 if (pr->ingress_vlan_tag[0] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530300 if ((result = ecm_state_write(sfi, "ingress_vlan_tag[0]", "0x%x", pr->ingress_vlan_tag[0]))) {
301 return result;
302 }
Murat Sezgin964bfd82019-11-18 14:28:37 -0800303 }
Suman Ghosha11fc922020-01-08 14:34:03 +0530304
Suman Ghosha33d7df2020-01-31 21:45:20 +0530305 if (pr->ingress_vlan_tag[1] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530306 if ((result = ecm_state_write(sfi, "ingress_vlan_tag[1]", "0x%x", pr->ingress_vlan_tag[1]))) {
307 return result;
308 }
Murat Sezgin964bfd82019-11-18 14:28:37 -0800309 }
Suman Ghosha11fc922020-01-08 14:34:03 +0530310
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600311 if (pr->egress_vlan_tag[0] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
312 if ((result = ecm_state_write(sfi, "egress_vlan_tag[0]", "0x%x", pr->egress_vlan_tag[0]))) {
313 return result;
314 }
315 }
316
Suman Ghosha33d7df2020-01-31 21:45:20 +0530317 if (pr->egress_vlan_tag[1] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530318 if ((result = ecm_state_write(sfi, "egress_vlan_tag[1]", "0x%x", pr->egress_vlan_tag[1]))) {
319 return result;
320 }
Murat Sezgin964bfd82019-11-18 14:28:37 -0800321 }
Suman Ghosha11fc922020-01-08 14:34:03 +0530322
323#ifdef ECM_MULTICAST_ENABLE
324 for (i = 0; i < ECM_DB_MULTICAST_IF_MAX; i++) {
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600325 struct net_device *dev;
Suman Ghosha11fc922020-01-08 14:34:03 +0530326
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600327 if (pr->egress_mc_vlan_tag[i][0] == ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
Suman Ghosha11fc922020-01-08 14:34:03 +0530328 continue;
329 }
330
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600331 dev = dev_get_by_index(&init_net, pr->egress_netdev_index[i]);
332 if (dev) {
333 if ((result = ecm_state_write(sfi, "port_egress", "%s", dev->name))) {
334 dev_put(dev);
335 return result;
336 }
337 dev_put(dev);
338 }
339
340 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 +0530341 return result;
342 }
343
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600344 if (pr->egress_mc_vlan_tag[i][1] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) {
345 if ((result = ecm_state_write(sfi, "port_egress_vlan_tag[1]", "0x%x", pr->egress_mc_vlan_tag[i][1]))) {
346 return result;
347 }
Suman Ghosha11fc922020-01-08 14:34:03 +0530348 }
349 }
350#endif
Murat Sezgin964bfd82019-11-18 14:28:37 -0800351 }
352#endif
353
Gareth Williamsd5618a82015-05-20 11:13:32 +0100354 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_QOS_TAG) {
355 if ((result = ecm_state_write(sfi, "flow_qos_tag", "%u", pr->flow_qos_tag))) {
356 return result;
357 }
358 if ((result = ecm_state_write(sfi, "return_qos_tag", "%u", pr->return_qos_tag))) {
359 return result;
360 }
361 }
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600362#ifdef ECM_CLASSIFIER_DSCP_ENABLE
363#ifdef ECM_CLASSIFIER_DSCP_IGS
Manish Vermaed493782019-05-27 12:56:02 +0530364 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_IGS_QOS_TAG) {
365 if ((result = ecm_state_write(sfi, "igs_flow_qos_tag", "%u", pr->igs_flow_qos_tag))) {
366 return result;
367 }
368 if ((result = ecm_state_write(sfi, "igs_return_qos_tag", "%u", pr->igs_return_qos_tag))) {
369 return result;
370 }
371 }
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600372#endif
Gareth Williamsd5618a82015-05-20 11:13:32 +0100373 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_DSCP) {
374 if ((result = ecm_state_write(sfi, "flow_dscp", "%u", pr->flow_dscp))) {
375 return result;
376 }
377 if ((result = ecm_state_write(sfi, "return_dscp", "%u", pr->return_dscp))) {
378 return result;
379 }
380 }
381#endif
Kyle Swenson1aa0e0d2021-03-18 14:20:24 -0600382
Gareth Williamsd5618a82015-05-20 11:13:32 +0100383 if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_TIMER_GROUP) {
384 if ((result = ecm_state_write(sfi, "timer_group", "%d", pr->timer_group))) {
385 return result;
386 }
387 }
388
389 return ecm_state_prefix_remove(sfi);
Ben Menchaca84f36632014-02-28 20:57:38 +0000390}
Gareth Williamsf98d4192015-03-11 16:55:41 +0000391#endif
392
Murat Sezginc725ad82016-04-13 17:12:50 -0700393extern struct ecm_classifier_instance *ecm_classifier_assign_classifier(struct ecm_db_connection_instance *ci, ecm_classifier_type_t type);
394extern bool ecm_classifier_reclassify(struct ecm_db_connection_instance *ci, int assignment_count, struct ecm_classifier_instance *assignments[]);