net/ice: track DCF state of PF
[dpdk.git] / drivers / net / sfc / sfc_mae.h
index 15fe5eb..3431aaa 100644 (file)
@@ -29,6 +29,7 @@ struct sfc_mae_fw_rsrc {
        union {
                efx_mae_aset_id_t       aset_id;
                efx_mae_rule_id_t       rule_id;
+               efx_mae_mac_id_t        mac_id;
                efx_mae_eh_id_t         eh_id;
        };
 };
@@ -44,6 +45,16 @@ struct sfc_mae_outer_rule {
 
 TAILQ_HEAD(sfc_mae_outer_rules, sfc_mae_outer_rule);
 
+/** MAC address registry entry */
+struct sfc_mae_mac_addr {
+       TAILQ_ENTRY(sfc_mae_mac_addr)   entries;
+       unsigned int                    refcnt;
+       uint8_t                         addr_bytes[EFX_MAC_ADDR_LEN];
+       struct sfc_mae_fw_rsrc          fw_rsrc;
+};
+
+TAILQ_HEAD(sfc_mae_mac_addrs, sfc_mae_mac_addr);
+
 /** Encap. header registry entry */
 struct sfc_mae_encap_header {
        TAILQ_ENTRY(sfc_mae_encap_header)       entries;
@@ -62,6 +73,13 @@ struct sfc_mae_counter_id {
        efx_counter_t                   mae_id;
        /* ID of a counter in RTE */
        uint32_t                        rte_id;
+       /* RTE counter ID validity status */
+       bool                            rte_id_valid;
+
+       /* Flow Tunnel (FT) GROUP hit counter (or NULL) */
+       uint64_t                        *ft_group_hit_counter;
+       /* Flow Tunnel (FT) context (for JUMP rules; otherwise, NULL) */
+       struct sfc_flow_tunnel          *ft;
 };
 
 /** Action set registry entry */
@@ -72,6 +90,8 @@ struct sfc_mae_action_set {
        uint32_t                        n_counters;
        efx_mae_actions_t               *spec;
        struct sfc_mae_encap_header     *encap_header;
+       struct sfc_mae_mac_addr         *dst_mac_addr;
+       struct sfc_mae_mac_addr         *src_mac_addr;
        struct sfc_mae_fw_rsrc          fw_rsrc;
 };
 
@@ -81,7 +101,8 @@ TAILQ_HEAD(sfc_mae_action_sets, sfc_mae_action_set);
 enum sfc_mae_status {
        SFC_MAE_STATUS_UNKNOWN = 0,
        SFC_MAE_STATUS_UNSUPPORTED,
-       SFC_MAE_STATUS_SUPPORTED
+       SFC_MAE_STATUS_SUPPORTED,
+       SFC_MAE_STATUS_ADMIN,
 };
 
 /*
@@ -101,6 +122,8 @@ struct sfc_mae_counter {
        uint32_t                        generation_count;
        union sfc_pkts_bytes            value;
        union sfc_pkts_bytes            reset;
+
+       uint64_t                        *ft_group_hit_counter;
 };
 
 struct sfc_mae_counters_xstats {
@@ -117,6 +140,13 @@ struct sfc_mae_counters {
        unsigned int                    n_mae_counters;
 };
 
+/** Options for MAE counter polling mode */
+enum sfc_mae_counter_polling_mode {
+       SFC_MAE_COUNTER_POLLING_OFF = 0,
+       SFC_MAE_COUNTER_POLLING_SERVICE,
+       SFC_MAE_COUNTER_POLLING_THREAD,
+};
+
 struct sfc_mae_counter_registry {
        /* Common counter information */
        /** Counters collection */
@@ -133,10 +163,48 @@ struct sfc_mae_counter_registry {
        bool                            use_credits;
 
        /* Information used by configuration routines */
-       /** Counter service core ID */
-       uint32_t                        service_core_id;
-       /** Counter service ID */
-       uint32_t                        service_id;
+       enum sfc_mae_counter_polling_mode polling_mode;
+       union {
+               struct {
+                       /** Counter service core ID */
+                       uint32_t                        core_id;
+                       /** Counter service ID */
+                       uint32_t                        id;
+               } service;
+               struct {
+                       /** Counter thread ID */
+                       pthread_t                       id;
+                       /** The thread should keep running */
+                       bool                            run;
+               } thread;
+       } polling;
+};
+
+/**
+ * MAE rules used to capture traffic generated by VFs and direct it to
+ * representors (one for each VF).
+ */
+#define SFC_MAE_NB_REPR_RULES_MAX      (64)
+
+/** Rules to forward traffic from PHY port to PF and from PF to PHY port */
+#define SFC_MAE_NB_SWITCHDEV_RULES     (2)
+/** Maximum required internal MAE rules */
+#define SFC_MAE_NB_RULES_MAX           (SFC_MAE_NB_SWITCHDEV_RULES + \
+                                        SFC_MAE_NB_REPR_RULES_MAX)
+
+struct sfc_mae_rule {
+       efx_mae_match_spec_t            *spec;
+       efx_mae_actions_t               *actions;
+       efx_mae_aset_id_t               action_set;
+       efx_mae_rule_id_t               rule_id;
+};
+
+struct sfc_mae_internal_rules {
+       /*
+        * Rules required to sustain switchdev mode or to provide
+        * port representor functionality.
+        */
+       struct sfc_mae_rule             rules[SFC_MAE_NB_RULES_MAX];
 };
 
 struct sfc_mae {
@@ -156,6 +224,8 @@ struct sfc_mae {
        struct sfc_mae_outer_rules      outer_rules;
        /** Encap. header registry */
        struct sfc_mae_encap_headers    encap_headers;
+       /** MAC address registry */
+       struct sfc_mae_mac_addrs        mac_addrs;
        /** Action set registry */
        struct sfc_mae_action_sets      action_sets;
        /** Encap. header bounce buffer */
@@ -164,6 +234,14 @@ struct sfc_mae {
        bool                            counter_rxq_running;
        /** Counter registry */
        struct sfc_mae_counter_registry counter_registry;
+       /** Driver-internal flow rules */
+       struct sfc_mae_internal_rules   internal_rules;
+       /**
+        * Switchdev default rules. They forward traffic from PHY port
+        * to PF and vice versa.
+        */
+       struct sfc_mae_rule             *switchdev_rule_pf_to_ext;
+       struct sfc_mae_rule             *switchdev_rule_ext_to_pf;
 };
 
 struct sfc_adapter;
@@ -285,9 +363,12 @@ struct sfc_mae_parse_ctx {
        size_t                          tunnel_def_mask_size;
        const void                      *tunnel_def_mask;
        bool                            match_mport_set;
+       enum sfc_flow_tunnel_rule_type  ft_rule_type;
        struct sfc_mae_pattern_data     pattern_data;
        efx_tunnel_protocol_t           encap_type;
+       const struct rte_flow_item      *pattern;
        unsigned int                    priority;
+       struct sfc_flow_tunnel          *ft;
 };
 
 int sfc_mae_attach(struct sfc_adapter *sa);
@@ -304,6 +385,28 @@ int sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
 sfc_flow_verify_cb_t sfc_mae_flow_verify;
 sfc_flow_insert_cb_t sfc_mae_flow_insert;
 sfc_flow_remove_cb_t sfc_mae_flow_remove;
+sfc_flow_query_cb_t sfc_mae_flow_query;
+
+/**
+ * The value used to represent the lowest priority.
+ * Used in MAE rule API.
+ */
+#define SFC_MAE_RULE_PRIO_LOWEST       (-1)
+
+/**
+ * Insert a driver-internal flow rule that matches traffic originating from
+ * some m-port selector and redirects it to another one
+ * (eg. PF --> PHY, PHY --> PF).
+ *
+ * If requested priority is negative, use the lowest priority.
+ */
+int sfc_mae_rule_add_mport_match_deliver(struct sfc_adapter *sa,
+                                        const efx_mport_sel_t *mport_match,
+                                        const efx_mport_sel_t *mport_deliver,
+                                        int prio, struct sfc_mae_rule **rulep);
+void sfc_mae_rule_del(struct sfc_adapter *sa, struct sfc_mae_rule *rule);
+int sfc_mae_switchdev_init(struct sfc_adapter *sa);
+void sfc_mae_switchdev_fini(struct sfc_adapter *sa);
 
 #ifdef __cplusplus
 }