+static void xlate_actions(struct action_xlate_ctx *,
+ const struct ofpact *ofpacts, size_t ofpacts_len,
+ struct ofpbuf *odp_actions);
+static void xlate_actions_for_side_effects(struct action_xlate_ctx *,
+ const struct ofpact *ofpacts,
+ size_t ofpacts_len);
+
+static size_t put_userspace_action(const struct ofproto_dpif *,
+ struct ofpbuf *odp_actions,
+ const struct flow *,
+ const union user_action_cookie *);
+
+static void compose_slow_path(const struct ofproto_dpif *, const struct flow *,
+ enum slow_path_reason,
+ uint64_t *stub, size_t stub_size,
+ const struct nlattr **actionsp,
+ size_t *actions_lenp);
+
+/* A subfacet (see "struct subfacet" below) has three possible installation
+ * states:
+ *
+ * - SF_NOT_INSTALLED: Not installed in the datapath. This will only be the
+ * case just after the subfacet is created, just before the subfacet is
+ * destroyed, or if the datapath returns an error when we try to install a
+ * subfacet.
+ *
+ * - SF_FAST_PATH: The subfacet's actions are installed in the datapath.
+ *
+ * - SF_SLOW_PATH: An action that sends every packet for the subfacet through
+ * ofproto_dpif is installed in the datapath.
+ */
+enum subfacet_path {
+ SF_NOT_INSTALLED, /* No datapath flow for this subfacet. */
+ SF_FAST_PATH, /* Full actions are installed. */
+ SF_SLOW_PATH, /* Send-to-userspace action is installed. */
+};
+
+static const char *subfacet_path_to_string(enum subfacet_path);
+
+/* A dpif flow and actions associated with a facet.
+ *
+ * See also the large comment on struct facet. */
+struct subfacet {
+ /* Owners. */
+ struct hmap_node hmap_node; /* In struct ofproto_dpif 'subfacets' list. */
+ struct list list_node; /* In struct facet's 'facets' list. */
+ struct facet *facet; /* Owning facet. */
+
+ /* Key.
+ *
+ * To save memory in the common case, 'key' is NULL if 'key_fitness' is
+ * ODP_FIT_PERFECT, that is, odp_flow_key_from_flow() can accurately
+ * regenerate the ODP flow key from ->facet->flow. */
+ enum odp_key_fitness key_fitness;
+ struct nlattr *key;
+ int key_len;
+
+ long long int used; /* Time last used; time created if not used. */
+
+ uint64_t dp_packet_count; /* Last known packet count in the datapath. */
+ uint64_t dp_byte_count; /* Last known byte count in the datapath. */
+
+ /* Datapath actions.
+ *
+ * These should be essentially identical for every subfacet in a facet, but
+ * may differ in trivial ways due to VLAN splinters. */
+ size_t actions_len; /* Number of bytes in actions[]. */
+ struct nlattr *actions; /* Datapath actions. */
+
+ enum slow_path_reason slow; /* 0 if fast path may be used. */
+ enum subfacet_path path; /* Installed in datapath? */
+
+ /* This value is normally the same as ->facet->flow.vlan_tci. Only VLAN
+ * splinters can cause it to differ. This value should be removed when
+ * the VLAN splinters feature is no longer needed. */
+ ovs_be16 initial_tci; /* Initial VLAN TCI value. */
+};
+
+static struct subfacet *subfacet_create(struct facet *, enum odp_key_fitness,
+ const struct nlattr *key,
+ size_t key_len, ovs_be16 initial_tci);
+static struct subfacet *subfacet_find(struct ofproto_dpif *,
+ const struct nlattr *key, size_t key_len);
+static void subfacet_destroy(struct subfacet *);
+static void subfacet_destroy__(struct subfacet *);
+static void subfacet_get_key(struct subfacet *, struct odputil_keybuf *,
+ struct ofpbuf *key);
+static void subfacet_reset_dp_stats(struct subfacet *,
+ struct dpif_flow_stats *);
+static void subfacet_update_time(struct subfacet *, long long int used);
+static void subfacet_update_stats(struct subfacet *,
+ const struct dpif_flow_stats *);
+static void subfacet_make_actions(struct subfacet *,
+ const struct ofpbuf *packet,
+ struct ofpbuf *odp_actions);
+static int subfacet_install(struct subfacet *,
+ const struct nlattr *actions, size_t actions_len,
+ struct dpif_flow_stats *, enum slow_path_reason);
+static void subfacet_uninstall(struct subfacet *);
+
+static enum subfacet_path subfacet_want_path(enum slow_path_reason);