1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_malloc.h>
9 #include <rte_cycles.h>
10 #include <rte_table_array.h>
11 #include <rte_byteorder.h>
14 #include "pipeline_actions_common.h"
15 #include "pipeline_flow_actions_be.h"
17 #include "hash_func.h"
20 pipeline_fa_flow_params_set_default(struct pipeline_fa_flow_params *params)
27 for (i = 0; i < PIPELINE_FA_N_TC_MAX; i++) {
28 struct rte_meter_trtcm_params *m = ¶ms->m[i];
36 for (i = 0; i < PIPELINE_FA_N_TC_MAX; i++) {
37 struct pipeline_fa_policer_params *p = ¶ms->p[i];
40 for (j = 0; j < e_RTE_METER_COLORS; j++) {
41 struct pipeline_fa_policer_action *a = &p->action[j];
44 a->color = (enum rte_meter_color) j;
54 uint32_t traffic_class;
55 enum rte_meter_color color;
58 struct pipeline_flow_actions {
60 struct pipeline_fa_params params;
61 pipeline_msg_req_handler custom_handlers[PIPELINE_FA_MSG_REQS];
63 struct dscp_entry dscp[PIPELINE_FA_N_DSCP];
64 } __rte_cache_aligned;
67 pipeline_fa_msg_req_custom_handler(struct pipeline *p, void *msg);
69 static pipeline_msg_req_handler handlers[] = {
70 [PIPELINE_MSG_REQ_PING] =
71 pipeline_msg_req_ping_handler,
72 [PIPELINE_MSG_REQ_STATS_PORT_IN] =
73 pipeline_msg_req_stats_port_in_handler,
74 [PIPELINE_MSG_REQ_STATS_PORT_OUT] =
75 pipeline_msg_req_stats_port_out_handler,
76 [PIPELINE_MSG_REQ_STATS_TABLE] =
77 pipeline_msg_req_stats_table_handler,
78 [PIPELINE_MSG_REQ_PORT_IN_ENABLE] =
79 pipeline_msg_req_port_in_enable_handler,
80 [PIPELINE_MSG_REQ_PORT_IN_DISABLE] =
81 pipeline_msg_req_port_in_disable_handler,
82 [PIPELINE_MSG_REQ_CUSTOM] =
83 pipeline_fa_msg_req_custom_handler,
87 pipeline_fa_msg_req_flow_config_handler(struct pipeline *p, void *msg);
90 pipeline_fa_msg_req_flow_config_bulk_handler(struct pipeline *p, void *msg);
93 pipeline_fa_msg_req_dscp_config_handler(struct pipeline *p, void *msg);
96 pipeline_fa_msg_req_policer_stats_read_handler(struct pipeline *p, void *msg);
98 static pipeline_msg_req_handler custom_handlers[] = {
99 [PIPELINE_FA_MSG_REQ_FLOW_CONFIG] =
100 pipeline_fa_msg_req_flow_config_handler,
101 [PIPELINE_FA_MSG_REQ_FLOW_CONFIG_BULK] =
102 pipeline_fa_msg_req_flow_config_bulk_handler,
103 [PIPELINE_FA_MSG_REQ_DSCP_CONFIG] =
104 pipeline_fa_msg_req_dscp_config_handler,
105 [PIPELINE_FA_MSG_REQ_POLICER_STATS_READ] =
106 pipeline_fa_msg_req_policer_stats_read_handler,
112 struct meter_policer {
113 struct rte_meter_trtcm meter;
114 struct rte_meter_trtcm_profile meter_profile;
115 struct pipeline_fa_policer_params policer;
116 struct pipeline_fa_policer_stats stats;
119 struct flow_table_entry {
120 struct rte_pipeline_table_entry head;
121 struct meter_policer mp[PIPELINE_FA_N_TC_MAX];
125 flow_table_entry_set_meter(struct flow_table_entry *entry,
127 struct pipeline_fa_flow_params *params)
129 struct rte_meter_trtcm *meter = &entry->mp[meter_id].meter;
130 struct rte_meter_trtcm_params *meter_params = ¶ms->m[meter_id];
131 struct rte_meter_trtcm_profile *meter_profile =
132 &entry->mp[meter_id].meter_profile;
135 status = rte_meter_trtcm_profile_config(meter_profile, meter_params);
139 return rte_meter_trtcm_config(meter, meter_profile);
143 flow_table_entry_set_policer(struct flow_table_entry *entry,
145 struct pipeline_fa_flow_params *params)
147 struct pipeline_fa_policer_params *p0 = &entry->mp[policer_id].policer;
148 struct pipeline_fa_policer_params *p1 = ¶ms->p[policer_id];
150 memcpy(p0, p1, sizeof(*p0));
154 flow_table_entry_set_port_id(struct pipeline_flow_actions *p,
155 struct flow_table_entry *entry,
156 struct pipeline_fa_flow_params *params)
158 entry->head.action = RTE_PIPELINE_ACTION_PORT;
159 entry->head.port_id = p->p.port_out_id[params->port_id];
163 flow_table_entry_set_default(struct pipeline_flow_actions *p,
164 struct flow_table_entry *entry)
166 struct pipeline_fa_flow_params params;
169 pipeline_fa_flow_params_set_default(¶ms);
171 memset(entry, 0, sizeof(*entry));
173 flow_table_entry_set_port_id(p, entry, ¶ms);
175 for (i = 0; i < PIPELINE_FA_N_TC_MAX; i++) {
178 status = flow_table_entry_set_meter(entry, i, ¶ms);
183 for (i = 0; i < PIPELINE_FA_N_TC_MAX; i++)
184 flow_table_entry_set_policer(entry, i, ¶ms);
189 static inline uint64_t
191 struct rte_mbuf *pkt,
192 struct rte_pipeline_table_entry *table_entry,
196 struct pipeline_flow_actions *p = arg;
197 struct flow_table_entry *entry =
198 (struct flow_table_entry *) table_entry;
200 struct ipv4_hdr *pkt_ip = (struct ipv4_hdr *)
201 RTE_MBUF_METADATA_UINT32_PTR(pkt, p->params.ip_hdr_offset);
202 enum rte_meter_color *pkt_color = (enum rte_meter_color *)
203 RTE_MBUF_METADATA_UINT32_PTR(pkt, p->params.color_offset);
205 /* Read (IP header) */
206 uint32_t total_length = rte_bswap16(pkt_ip->total_length);
207 uint32_t dscp = pkt_ip->type_of_service >> 2;
209 uint32_t tc = p->dscp[dscp].traffic_class;
210 enum rte_meter_color color = p->dscp[dscp].color;
212 struct rte_meter_trtcm *meter = &entry->mp[tc].meter;
213 struct rte_meter_trtcm_profile *meter_profile =
214 &entry->mp[tc].meter_profile;
215 struct pipeline_fa_policer_params *policer = &entry->mp[tc].policer;
216 struct pipeline_fa_policer_stats *stats = &entry->mp[tc].stats;
218 /* Read (entry), compute */
219 enum rte_meter_color color2 = rte_meter_trtcm_color_aware_check(meter,
225 enum rte_meter_color color3 = policer->action[color2].color;
226 uint64_t drop = policer->action[color2].drop;
228 /* Read (entry), write (entry, color) */
229 stats->n_pkts[color3] += drop ^ 1LLU;
230 stats->n_pkts_drop += drop;
236 static inline uint64_t
238 struct rte_mbuf **pkts,
239 struct rte_pipeline_table_entry **table_entries,
243 struct pipeline_flow_actions *p = arg;
245 struct flow_table_entry *entry0 =
246 (struct flow_table_entry *) table_entries[0];
247 struct flow_table_entry *entry1 =
248 (struct flow_table_entry *) table_entries[1];
249 struct flow_table_entry *entry2 =
250 (struct flow_table_entry *) table_entries[2];
251 struct flow_table_entry *entry3 =
252 (struct flow_table_entry *) table_entries[3];
254 struct ipv4_hdr *pkt0_ip = (struct ipv4_hdr *)
255 RTE_MBUF_METADATA_UINT32_PTR(pkts[0], p->params.ip_hdr_offset);
256 struct ipv4_hdr *pkt1_ip = (struct ipv4_hdr *)
257 RTE_MBUF_METADATA_UINT32_PTR(pkts[1], p->params.ip_hdr_offset);
258 struct ipv4_hdr *pkt2_ip = (struct ipv4_hdr *)
259 RTE_MBUF_METADATA_UINT32_PTR(pkts[2], p->params.ip_hdr_offset);
260 struct ipv4_hdr *pkt3_ip = (struct ipv4_hdr *)
261 RTE_MBUF_METADATA_UINT32_PTR(pkts[3], p->params.ip_hdr_offset);
263 enum rte_meter_color *pkt0_color = (enum rte_meter_color *)
264 RTE_MBUF_METADATA_UINT32_PTR(pkts[0], p->params.color_offset);
265 enum rte_meter_color *pkt1_color = (enum rte_meter_color *)
266 RTE_MBUF_METADATA_UINT32_PTR(pkts[1], p->params.color_offset);
267 enum rte_meter_color *pkt2_color = (enum rte_meter_color *)
268 RTE_MBUF_METADATA_UINT32_PTR(pkts[2], p->params.color_offset);
269 enum rte_meter_color *pkt3_color = (enum rte_meter_color *)
270 RTE_MBUF_METADATA_UINT32_PTR(pkts[3], p->params.color_offset);
272 /* Read (IP header) */
273 uint32_t total_length0 = rte_bswap16(pkt0_ip->total_length);
274 uint32_t dscp0 = pkt0_ip->type_of_service >> 2;
276 uint32_t total_length1 = rte_bswap16(pkt1_ip->total_length);
277 uint32_t dscp1 = pkt1_ip->type_of_service >> 2;
279 uint32_t total_length2 = rte_bswap16(pkt2_ip->total_length);
280 uint32_t dscp2 = pkt2_ip->type_of_service >> 2;
282 uint32_t total_length3 = rte_bswap16(pkt3_ip->total_length);
283 uint32_t dscp3 = pkt3_ip->type_of_service >> 2;
285 uint32_t tc0 = p->dscp[dscp0].traffic_class;
286 enum rte_meter_color color0 = p->dscp[dscp0].color;
288 uint32_t tc1 = p->dscp[dscp1].traffic_class;
289 enum rte_meter_color color1 = p->dscp[dscp1].color;
291 uint32_t tc2 = p->dscp[dscp2].traffic_class;
292 enum rte_meter_color color2 = p->dscp[dscp2].color;
294 uint32_t tc3 = p->dscp[dscp3].traffic_class;
295 enum rte_meter_color color3 = p->dscp[dscp3].color;
297 struct rte_meter_trtcm *meter0 = &entry0->mp[tc0].meter;
298 struct rte_meter_trtcm_profile *meter0_profile =
299 &entry0->mp[tc0].meter_profile;
300 struct pipeline_fa_policer_params *policer0 = &entry0->mp[tc0].policer;
301 struct pipeline_fa_policer_stats *stats0 = &entry0->mp[tc0].stats;
303 struct rte_meter_trtcm *meter1 = &entry1->mp[tc1].meter;
304 struct rte_meter_trtcm_profile *meter1_profile =
305 &entry1->mp[tc1].meter_profile;
306 struct pipeline_fa_policer_params *policer1 = &entry1->mp[tc1].policer;
307 struct pipeline_fa_policer_stats *stats1 = &entry1->mp[tc1].stats;
309 struct rte_meter_trtcm *meter2 = &entry2->mp[tc2].meter;
310 struct rte_meter_trtcm_profile *meter2_profile =
311 &entry2->mp[tc2].meter_profile;
312 struct pipeline_fa_policer_params *policer2 = &entry2->mp[tc2].policer;
313 struct pipeline_fa_policer_stats *stats2 = &entry2->mp[tc2].stats;
315 struct rte_meter_trtcm *meter3 = &entry3->mp[tc3].meter;
316 struct rte_meter_trtcm_profile *meter3_profile =
317 &entry3->mp[tc3].meter_profile;
318 struct pipeline_fa_policer_params *policer3 = &entry3->mp[tc3].policer;
319 struct pipeline_fa_policer_stats *stats3 = &entry3->mp[tc3].stats;
321 /* Read (entry), compute, write (entry) */
322 enum rte_meter_color color2_0 = rte_meter_trtcm_color_aware_check(
329 enum rte_meter_color color2_1 = rte_meter_trtcm_color_aware_check(
336 enum rte_meter_color color2_2 = rte_meter_trtcm_color_aware_check(
343 enum rte_meter_color color2_3 = rte_meter_trtcm_color_aware_check(
350 enum rte_meter_color color3_0 = policer0->action[color2_0].color;
351 enum rte_meter_color color3_1 = policer1->action[color2_1].color;
352 enum rte_meter_color color3_2 = policer2->action[color2_2].color;
353 enum rte_meter_color color3_3 = policer3->action[color2_3].color;
355 uint64_t drop0 = policer0->action[color2_0].drop;
356 uint64_t drop1 = policer1->action[color2_1].drop;
357 uint64_t drop2 = policer2->action[color2_2].drop;
358 uint64_t drop3 = policer3->action[color2_3].drop;
360 /* Read (entry), write (entry, color) */
361 stats0->n_pkts[color3_0] += drop0 ^ 1LLU;
362 stats0->n_pkts_drop += drop0;
364 stats1->n_pkts[color3_1] += drop1 ^ 1LLU;
365 stats1->n_pkts_drop += drop1;
367 stats2->n_pkts[color3_2] += drop2 ^ 1LLU;
368 stats2->n_pkts_drop += drop2;
370 stats3->n_pkts[color3_3] += drop3 ^ 1LLU;
371 stats3->n_pkts_drop += drop3;
373 *pkt0_color = color3_0;
374 *pkt1_color = color3_1;
375 *pkt2_color = color3_2;
376 *pkt3_color = color3_3;
378 return drop0 | (drop1 << 1) | (drop2 << 2) | (drop3 << 3);
381 PIPELINE_TABLE_AH_HIT_DROP_TIME(fa_table_ah_hit, pkt_work, pkt4_work);
383 static rte_pipeline_table_action_handler_hit
384 get_fa_table_ah_hit(__rte_unused struct pipeline_flow_actions *p)
386 return fa_table_ah_hit;
393 pipeline_fa_parse_args(struct pipeline_fa_params *p,
394 struct pipeline_params *params)
396 uint32_t n_flows_present = 0;
397 uint32_t n_meters_per_flow_present = 0;
398 uint32_t flow_id_offset_present = 0;
399 uint32_t ip_hdr_offset_present = 0;
400 uint32_t color_offset_present = 0;
404 p->n_meters_per_flow = 1;
407 for (i = 0; i < params->n_args; i++) {
408 char *arg_name = params->args_name[i];
409 char *arg_value = params->args_value[i];
412 if (strcmp(arg_name, "n_flows") == 0) {
415 PIPELINE_PARSE_ERR_DUPLICATE(
416 n_flows_present == 0, params->name,
420 status = parser_read_uint32(&p->n_flows,
422 PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
423 (p->n_flows != 0)), params->name,
424 arg_name, arg_value);
425 PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
426 params->name, arg_name, arg_value);
431 /* n_meters_per_flow */
432 if (strcmp(arg_name, "n_meters_per_flow") == 0) {
435 PIPELINE_PARSE_ERR_DUPLICATE(
436 n_meters_per_flow_present == 0,
437 params->name, arg_name);
438 n_meters_per_flow_present = 1;
440 status = parser_read_uint32(&p->n_meters_per_flow,
442 PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
443 (p->n_meters_per_flow != 0)),
444 params->name, arg_name, arg_value);
445 PIPELINE_PARSE_ERR_OUT_RNG(((status != -ERANGE) &&
446 (p->n_meters_per_flow <=
447 PIPELINE_FA_N_TC_MAX)), params->name,
448 arg_name, arg_value);
454 if (strcmp(arg_name, "flow_id_offset") == 0) {
457 PIPELINE_PARSE_ERR_DUPLICATE(
458 flow_id_offset_present == 0,
459 params->name, arg_name);
460 flow_id_offset_present = 1;
462 status = parser_read_uint32(&p->flow_id_offset,
464 PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
465 params->name, arg_name, arg_value);
466 PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
467 params->name, arg_name, arg_value);
473 if (strcmp(arg_name, "ip_hdr_offset") == 0) {
476 PIPELINE_PARSE_ERR_DUPLICATE(
477 ip_hdr_offset_present == 0,
478 params->name, arg_name);
479 ip_hdr_offset_present = 1;
481 status = parser_read_uint32(&p->ip_hdr_offset,
483 PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
484 params->name, arg_name, arg_value);
485 PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
486 params->name, arg_name, arg_value);
492 if (strcmp(arg_name, "color_offset") == 0) {
495 PIPELINE_PARSE_ERR_DUPLICATE(
496 color_offset_present == 0, params->name,
498 color_offset_present = 1;
500 status = parser_read_uint32(&p->color_offset,
502 PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
503 params->name, arg_name, arg_value);
504 PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
505 params->name, arg_name, arg_value);
512 /* Unknown argument */
513 PIPELINE_PARSE_ERR_INV_ENT(0, params->name, arg_name);
516 /* Check that mandatory arguments are present */
517 PIPELINE_PARSE_ERR_MANDATORY((n_flows_present), params->name,
519 PIPELINE_PARSE_ERR_MANDATORY((flow_id_offset_present),
520 params->name, "flow_id_offset");
521 PIPELINE_PARSE_ERR_MANDATORY((ip_hdr_offset_present),
522 params->name, "ip_hdr_offset");
523 PIPELINE_PARSE_ERR_MANDATORY((color_offset_present), params->name,
530 dscp_init(struct pipeline_flow_actions *p)
534 for (i = 0; i < PIPELINE_FA_N_DSCP; i++) {
535 p->dscp[i].traffic_class = 0;
536 p->dscp[i].color = e_RTE_METER_GREEN;
540 static void *pipeline_fa_init(struct pipeline_params *params,
541 __rte_unused void *arg)
544 struct pipeline_flow_actions *p_fa;
547 /* Check input arguments */
551 if (params->n_ports_in != params->n_ports_out)
554 /* Memory allocation */
555 size = RTE_CACHE_LINE_ROUNDUP(
556 sizeof(struct pipeline_flow_actions));
557 p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
560 p_fa = (struct pipeline_flow_actions *) p;
562 strcpy(p->name, params->name);
563 p->log_level = params->log_level;
565 PLOG(p, HIGH, "Flow actions");
567 /* Parse arguments */
568 if (pipeline_fa_parse_args(&p_fa->params, params))
575 struct rte_pipeline_params pipeline_params = {
576 .name = params->name,
577 .socket_id = params->socket_id,
581 p->p = rte_pipeline_create(&pipeline_params);
589 p->n_ports_in = params->n_ports_in;
590 for (i = 0; i < p->n_ports_in; i++) {
591 struct rte_pipeline_port_in_params port_params = {
592 .ops = pipeline_port_in_params_get_ops(
593 ¶ms->port_in[i]),
594 .arg_create = pipeline_port_in_params_convert(
595 ¶ms->port_in[i]),
598 .burst_size = params->port_in[i].burst_size,
601 int status = rte_pipeline_port_in_create(p->p,
606 rte_pipeline_free(p->p);
613 p->n_ports_out = params->n_ports_out;
614 for (i = 0; i < p->n_ports_out; i++) {
615 struct rte_pipeline_port_out_params port_params = {
616 .ops = pipeline_port_out_params_get_ops(
617 ¶ms->port_out[i]),
618 .arg_create = pipeline_port_out_params_convert(
619 ¶ms->port_out[i]),
624 int status = rte_pipeline_port_out_create(p->p,
629 rte_pipeline_free(p->p);
638 struct rte_table_array_params table_array_params = {
639 .n_entries = p_fa->params.n_flows,
640 .offset = p_fa->params.flow_id_offset,
643 struct rte_pipeline_table_params table_params = {
644 .ops = &rte_table_array_ops,
645 .arg_create = &table_array_params,
646 .f_action_hit = get_fa_table_ah_hit(p_fa),
647 .f_action_miss = NULL,
650 sizeof(struct flow_table_entry) -
651 sizeof(struct rte_pipeline_table_entry),
656 status = rte_pipeline_table_create(p->p,
661 rte_pipeline_free(p->p);
667 /* Connecting input ports to tables */
668 for (i = 0; i < p->n_ports_in; i++) {
669 int status = rte_pipeline_port_in_connect_to_table(p->p,
674 rte_pipeline_free(p->p);
680 /* Enable input ports */
681 for (i = 0; i < p->n_ports_in; i++) {
682 int status = rte_pipeline_port_in_enable(p->p,
686 rte_pipeline_free(p->p);
692 /* Initialize table entries */
693 for (i = 0; i < p_fa->params.n_flows; i++) {
694 struct rte_table_array_key key = {
698 struct flow_table_entry entry;
699 struct rte_pipeline_table_entry *entry_ptr;
700 int key_found, status;
702 flow_table_entry_set_default(p_fa, &entry);
704 status = rte_pipeline_table_entry_add(p->p,
707 (struct rte_pipeline_table_entry *) &entry,
712 rte_pipeline_free(p->p);
718 /* Check pipeline consistency */
719 if (rte_pipeline_check(p->p) < 0) {
720 rte_pipeline_free(p->p);
726 p->n_msgq = params->n_msgq;
727 for (i = 0; i < p->n_msgq; i++)
728 p->msgq_in[i] = params->msgq_in[i];
729 for (i = 0; i < p->n_msgq; i++)
730 p->msgq_out[i] = params->msgq_out[i];
732 /* Message handlers */
733 memcpy(p->handlers, handlers, sizeof(p->handlers));
734 memcpy(p_fa->custom_handlers,
736 sizeof(p_fa->custom_handlers));
742 pipeline_fa_free(void *pipeline)
744 struct pipeline *p = (struct pipeline *) pipeline;
746 /* Check input arguments */
751 rte_pipeline_free(p->p);
757 pipeline_fa_timer(void *pipeline)
759 struct pipeline *p = (struct pipeline *) pipeline;
761 pipeline_msg_req_handle(p);
762 rte_pipeline_flush(p->p);
768 pipeline_fa_msg_req_custom_handler(struct pipeline *p, void *msg)
770 struct pipeline_flow_actions *p_fa =
771 (struct pipeline_flow_actions *) p;
772 struct pipeline_custom_msg_req *req = msg;
773 pipeline_msg_req_handler f_handle;
775 f_handle = (req->subtype < PIPELINE_FA_MSG_REQS) ?
776 p_fa->custom_handlers[req->subtype] :
777 pipeline_msg_req_invalid_handler;
779 if (f_handle == NULL)
780 f_handle = pipeline_msg_req_invalid_handler;
782 return f_handle(p, req);
786 pipeline_fa_msg_req_flow_config_handler(struct pipeline *p, void *msg)
788 struct pipeline_flow_actions *p_fa = (struct pipeline_flow_actions *) p;
789 struct pipeline_fa_flow_config_msg_req *req = msg;
790 struct pipeline_fa_flow_config_msg_rsp *rsp = msg;
791 struct flow_table_entry *entry;
794 /* Set flow table entry to default if not configured before */
795 if (req->entry_ptr == NULL) {
796 struct rte_table_array_key key = {
797 .pos = req->flow_id % p_fa->params.n_flows,
800 struct flow_table_entry default_entry;
802 int key_found, status;
804 flow_table_entry_set_default(p_fa, &default_entry);
806 status = rte_pipeline_table_entry_add(p->p,
809 (struct rte_pipeline_table_entry *) &default_entry,
811 (struct rte_pipeline_table_entry **) &entry);
817 entry = (struct flow_table_entry *) req->entry_ptr;
820 for (i = 0, mask = 1; i < PIPELINE_FA_N_TC_MAX; i++, mask <<= 1) {
823 if ((mask & req->meter_update_mask) == 0)
826 status = flow_table_entry_set_meter(entry, i, &req->params);
834 for (i = 0, mask = 1; i < PIPELINE_FA_N_TC_MAX; i++, mask <<= 1) {
835 if ((mask & req->policer_update_mask) == 0)
838 flow_table_entry_set_policer(entry, i, &req->params);
842 if (req->port_update)
843 flow_table_entry_set_port_id(p_fa, entry, &req->params);
847 rsp->entry_ptr = (void *) entry;
852 pipeline_fa_msg_req_flow_config_bulk_handler(struct pipeline *p, void *msg)
854 struct pipeline_flow_actions *p_fa = (struct pipeline_flow_actions *) p;
855 struct pipeline_fa_flow_config_bulk_msg_req *req = msg;
856 struct pipeline_fa_flow_config_bulk_msg_rsp *rsp = msg;
859 for (i = 0; i < req->n_flows; i++) {
860 struct flow_table_entry *entry;
863 /* Set flow table entry to default if not configured before */
864 if (req->entry_ptr[i] == NULL) {
865 struct rte_table_array_key key = {
866 .pos = req->flow_id[i] % p_fa->params.n_flows,
869 struct flow_table_entry entry_to_add;
871 int key_found, status;
873 flow_table_entry_set_default(p_fa, &entry_to_add);
875 status = rte_pipeline_table_entry_add(p->p,
878 (struct rte_pipeline_table_entry *) &entry_to_add,
880 (struct rte_pipeline_table_entry **) &entry);
886 req->entry_ptr[i] = (void *) entry;
888 entry = (struct flow_table_entry *) req->entry_ptr[i];
891 for (j = 0, mask = 1;
892 j < PIPELINE_FA_N_TC_MAX;
896 if ((mask & req->meter_update_mask) == 0)
899 status = flow_table_entry_set_meter(entry,
908 for (j = 0, mask = 1;
909 j < PIPELINE_FA_N_TC_MAX;
911 if ((mask & req->policer_update_mask) == 0)
914 flow_table_entry_set_policer(entry,
919 if (req->port_update)
920 flow_table_entry_set_port_id(p_fa,
921 entry, &req->params[i]);
930 pipeline_fa_msg_req_dscp_config_handler(struct pipeline *p, void *msg)
932 struct pipeline_flow_actions *p_fa = (struct pipeline_flow_actions *) p;
933 struct pipeline_fa_dscp_config_msg_req *req = msg;
934 struct pipeline_fa_dscp_config_msg_rsp *rsp = msg;
937 if ((req->dscp >= PIPELINE_FA_N_DSCP) ||
938 (req->traffic_class >= PIPELINE_FA_N_TC_MAX) ||
939 (req->color >= e_RTE_METER_COLORS)) {
944 p_fa->dscp[req->dscp].traffic_class = req->traffic_class;
945 p_fa->dscp[req->dscp].color = req->color;
951 pipeline_fa_msg_req_policer_stats_read_handler(__rte_unused struct pipeline *p,
954 struct pipeline_fa_policer_stats_msg_req *req = msg;
955 struct pipeline_fa_policer_stats_msg_rsp *rsp = msg;
957 struct flow_table_entry *entry = req->entry_ptr;
958 uint32_t policer_id = req->policer_id;
959 int clear = req->clear;
962 if ((req->entry_ptr == NULL) ||
963 (req->policer_id >= PIPELINE_FA_N_TC_MAX)) {
969 &entry->mp[policer_id].stats,
972 memset(&entry->mp[policer_id].stats,
973 0, sizeof(entry->mp[policer_id].stats));
978 struct pipeline_be_ops pipeline_flow_actions_be_ops = {
979 .f_init = pipeline_fa_init,
980 .f_free = pipeline_fa_free,
982 .f_timer = pipeline_fa_timer,