net/sched: add police action to the hardware intermediate representation
authorPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Sat, 4 May 2019 11:46:22 +0000 (04:46 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 May 2019 04:49:24 +0000 (21:49 -0700)
Add police action to the hardware intermediate representation which
would subsequently allow it to be used by drivers for offload.

Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/flow_offload.h
net/sched/cls_api.c

index 3bf67dd64be5f6f58ac59c1d77b41c184293be6e..6200900434e17cc01b1768496a7341a0a4dacf65 100644 (file)
@@ -119,6 +119,7 @@ enum flow_action_id {
        FLOW_ACTION_WAKE,
        FLOW_ACTION_QUEUE,
        FLOW_ACTION_SAMPLE,
+       FLOW_ACTION_POLICE,
 };
 
 /* This is mirroring enum pedit_header_type definition for easy mapping between
@@ -164,6 +165,10 @@ struct flow_action_entry {
                        u32                     trunc_size;
                        bool                    truncate;
                } sample;
+               struct {                                /* FLOW_ACTION_POLICE */
+                       s64                     burst;
+                       u64                     rate_bytes_ps;
+               } police;
        };
 };
 
index f8ee2d78654a61f829c80d7793642cdc6744069f..d4699156974a6811a60e327f37b9d7a80aef7fde 100644 (file)
@@ -37,6 +37,7 @@
 #include <net/tc_act/tc_tunnel_key.h>
 #include <net/tc_act/tc_csum.h>
 #include <net/tc_act/tc_gact.h>
+#include <net/tc_act/tc_police.h>
 #include <net/tc_act/tc_sample.h>
 #include <net/tc_act/tc_skbedit.h>
 
@@ -3265,6 +3266,11 @@ int tc_setup_flow_action(struct flow_action *flow_action,
                        entry->sample.trunc_size = tcf_sample_trunc_size(act);
                        entry->sample.truncate = tcf_sample_truncate(act);
                        entry->sample.rate = tcf_sample_rate(act);
+               } else if (is_tcf_police(act)) {
+                       entry->id = FLOW_ACTION_POLICE;
+                       entry->police.burst = tcf_police_tcfp_burst(act);
+                       entry->police.rate_bytes_ps =
+                               tcf_police_rate_bytes_ps(act);
                } else {
                        goto err_out;
                }