}
static int
-dpif_linux_flow_put(struct dpif *dpif_, int flags,
+dpif_linux_flow_put(struct dpif *dpif_, enum dpif_flow_put_flags flags,
const struct nlattr *key, size_t key_len,
const struct nlattr *actions, size_t actions_len,
struct dpif_flow_stats *stats)
put.flow.actions = (struct nlattr *) actions;
put.flow.actions_len = actions_len;
put.flow.flags = 0;
- put.flags = flags;
+ put.flags = 0;
+ if (flags & DPIF_FP_CREATE) {
+ put.flags |= ODPPF_CREATE;
+ }
+ if (flags & DPIF_FP_MODIFY) {
+ put.flags |= ODPPF_MODIFY;
+ }
+ if (flags & DPIF_FP_ZERO_STATS) {
+ put.flags |= ODPPF_ZERO_STATS;
+ }
error = do_ioctl(dpif_, ODP_FLOW_PUT, &put);
if (!error && stats) {
odp_flow_stats_to_dpif_flow_stats(&put.flow.stats, stats);
}
static int
-dpif_netdev_flow_put(struct dpif *dpif, int flags,
+dpif_netdev_flow_put(struct dpif *dpif, enum dpif_flow_put_flags flags,
const struct nlattr *nl_key, size_t nl_key_len,
const struct nlattr *actions, size_t actions_len,
struct dpif_flow_stats *stats)
flow = dp_netdev_lookup_flow(dp, &key);
if (!flow) {
- if (flags & ODPPF_CREATE) {
+ if (flags & DPIF_FP_CREATE) {
if (hmap_count(&dp->flow_table) < MAX_FLOWS) {
if (stats) {
memset(stats, 0, sizeof *stats);
return ENOENT;
}
} else {
- if (flags & ODPPF_MODIFY) {
+ if (flags & DPIF_FP_MODIFY) {
int error = set_flow_actions(flow, actions, actions_len);
if (!error) {
if (stats) {
get_dpif_flow_stats(flow, stats);
}
- if (flags & ODPPF_ZERO_STATS) {
+ if (flags & DPIF_FP_ZERO_STATS) {
clear_stats(flow);
}
}
* with types ODPAT_* in the 'actions_len' bytes starting at 'actions'.
*
* - If the flow's key does not exist in 'dpif', then the flow will be
- * added if 'flags' includes ODPPF_CREATE. Otherwise the operation will
- * fail with ENOENT.
+ * added if 'flags' includes DPIF_FP_CREATE. Otherwise the operation
+ * will fail with ENOENT.
*
* If the operation succeeds, then 'stats', if nonnull, must be zeroed.
*
* - If the flow's key does exist in 'dpif', then the flow's actions will
- * be updated if 'flags' includes ODPPF_MODIFY. Otherwise the operation
- * will fail with EEXIST. If the flow's actions are updated, then its
- * statistics will be zeroed if 'flags' includes ODPPF_ZERO_STATS, and
- * left as-is otherwise.
+ * be updated if 'flags' includes DPIF_FP_MODIFY. Otherwise the
+ * operation will fail with EEXIST. If the flow's actions are updated,
+ * then its statistics will be zeroed if 'flags' includes
+ * DPIF_FP_ZERO_STATS, and left as-is otherwise.
*
* If the operation succeeds, then 'stats', if nonnull, must be set to
* the flow's statistics before the update.
*/
- int (*flow_put)(struct dpif *dpif, int flags,
+ int (*flow_put)(struct dpif *dpif, enum dpif_flow_put_flags flags,
const struct nlattr *key, size_t key_len,
const struct nlattr *actions, size_t actions_len,
struct dpif_flow_stats *stats);
* types ODPAT_* in the 'actions_len' bytes starting at 'actions'.
*
* - If the flow's key does not exist in 'dpif', then the flow will be added if
- * 'flags' includes ODPPF_CREATE. Otherwise the operation will fail with
+ * 'flags' includes DPIF_FP_CREATE. Otherwise the operation will fail with
* ENOENT.
*
* If the operation succeeds, then 'stats', if nonnull, will be zeroed.
*
* - If the flow's key does exist in 'dpif', then the flow's actions will be
- * updated if 'flags' includes ODPPF_MODIFY. Otherwise the operation will
+ * updated if 'flags' includes DPIF_FP_MODIFY. Otherwise the operation will
* fail with EEXIST. If the flow's actions are updated, then its statistics
- * will be zeroed if 'flags' includes ODPPF_ZERO_STATS, and left as-is
+ * will be zeroed if 'flags' includes DPIF_FP_ZERO_STATS, and left as-is
* otherwise.
*
* If the operation succeeds, then 'stats', if nonnull, will be set to the
* flow's statistics before the update.
*/
int
-dpif_flow_put(struct dpif *dpif, int flags,
+dpif_flow_put(struct dpif *dpif, enum dpif_flow_put_flags flags,
const struct nlattr *key, size_t key_len,
const struct nlattr *actions, size_t actions_len,
struct dpif_flow_stats *stats)
int error;
COVERAGE_INC(dpif_flow_put);
+ assert(!(flags & ~(DPIF_FP_CREATE | DPIF_FP_MODIFY | DPIF_FP_ZERO_STATS)));
error = dpif->dpif_class->flow_put(dpif, flags, key, key_len,
actions, actions_len, stats);
memset(stats, 0, sizeof *stats);
}
if (should_log_flow_message(error)) {
- enum { ODPPF_ALL = ODPPF_CREATE | ODPPF_MODIFY | ODPPF_ZERO_STATS };
struct ds s;
ds_init(&s);
ds_put_cstr(&s, "put");
- if (flags & ODPPF_CREATE) {
+ if (flags & DPIF_FP_CREATE) {
ds_put_cstr(&s, "[create]");
}
- if (flags & ODPPF_MODIFY) {
+ if (flags & DPIF_FP_MODIFY) {
ds_put_cstr(&s, "[modify]");
}
- if (flags & ODPPF_ZERO_STATS) {
+ if (flags & DPIF_FP_ZERO_STATS) {
ds_put_cstr(&s, "[zero]");
}
- if (flags & ~ODPPF_ALL) {
- ds_put_format(&s, "[%x]", flags & ~ODPPF_ALL);
- }
log_flow_message(dpif, error, ds_cstr(&s), key, key_len, stats,
actions, actions_len);
ds_destroy(&s);
void dpif_flow_stats_format(const struct dpif_flow_stats *, struct ds *);
+enum dpif_flow_put_flags {
+ DPIF_FP_CREATE = 1 << 0, /* Allow creating a new flow. */
+ DPIF_FP_MODIFY = 1 << 1, /* Allow modifying an existing flow. */
+ DPIF_FP_ZERO_STATS = 1 << 2 /* Zero the stats of an existing flow. */
+};
+
int dpif_flow_flush(struct dpif *);
-int dpif_flow_put(struct dpif *, int flags,
+int dpif_flow_put(struct dpif *, enum dpif_flow_put_flags,
const struct nlattr *key, size_t key_len,
const struct nlattr *actions, size_t actions_len,
struct dpif_flow_stats *);
*
* - Do include packets and bytes that were obtained from the datapath
* when a flow was deleted (e.g. dpif_flow_del()) or when its
- * statistics were reset (e.g. dpif_flow_put() with ODPPF_ZERO_STATS).
+ * statistics were reset (e.g. dpif_flow_put() with
+ * DPIF_FP_ZERO_STATS).
*
* - Do not include any packets or bytes that can currently be obtained
* from the datapath by, e.g., dpif_flow_get().
}
static int
-facet_put__(struct ofproto *ofproto, struct facet *facet, int flags)
+facet_put__(struct ofproto *ofproto, struct facet *facet,
+ enum dpif_flow_put_flags flags)
{
uint32_t keybuf[ODPUTIL_FLOW_KEY_U32S];
struct ofpbuf key;
facet_install(struct ofproto *p, struct facet *facet, bool zero_stats)
{
if (facet->may_install) {
- int flags = ODPPF_CREATE | ODPPF_MODIFY;
+ enum dpif_flow_put_flags flags = DPIF_FP_CREATE | DPIF_FP_MODIFY;
if (zero_stats) {
- flags |= ODPPF_ZERO_STATS;
+ flags |= DPIF_FP_ZERO_STATS;
}
if (!facet_put__(p, facet, flags)) {
facet->installed = true;
odp_flow_key_from_flow(&key, &facet->flow);
dpif_flow_put(ofproto->dpif,
- ODPPF_CREATE | ODPPF_MODIFY | ODPPF_ZERO_STATS,
+ DPIF_FP_CREATE | DPIF_FP_MODIFY | DPIF_FP_ZERO_STATS,
key.data, key.size,
odp_actions->data, odp_actions->size, &stats);