#include "poll-loop.h"
#include "shash.h"
#include "svec.h"
+#include "timeval.h"
#include "util.h"
#include "valgrind.h"
#include "vlog.h"
static void log_flow_message(const struct dpif *dpif, int error,
const char *operation,
const struct nlattr *key, size_t key_len,
- const struct odp_flow_stats *stats,
+ const struct dpif_flow_stats *stats,
const struct nlattr *actions, size_t actions_len);
static void log_operation(const struct dpif *, const char *operation,
int error);
dpif->dpif_class->port_poll_wait(dpif);
}
+/* Appends a human-readable representation of 'stats' to 's'. */
+void
+dpif_flow_stats_format(const struct dpif_flow_stats *stats, struct ds *s)
+{
+ ds_put_format(s, "packets:%"PRIu64", bytes:%"PRIu64", used:",
+ stats->n_packets, stats->n_bytes);
+ if (stats->used) {
+ ds_put_format(s, "%.3fs", (time_msec() - stats->used) / 1000.0);
+ } else {
+ ds_put_format(s, "never");
+ }
+ /* XXX tcp_flags? */
+}
+
/* Deletes all flows from 'dpif'. Returns 0 if successful, otherwise a
* positive errno value. */
int
* If 'stats' is nonnull, then on success it will be updated with the flow's
* statistics. */
int
-dpif_flow_get(const struct dpif *dpif, int flags,
+dpif_flow_get(const struct dpif *dpif,
const struct nlattr *key, size_t key_len,
- struct ofpbuf **actionsp, struct odp_flow_stats *stats)
+ struct ofpbuf **actionsp, struct dpif_flow_stats *stats)
{
int error;
COVERAGE_INC(dpif_flow_get);
- error = dpif->dpif_class->flow_get(dpif, flags, key, key_len, actionsp,
- stats);
+ error = dpif->dpif_class->flow_get(dpif, key, key_len, actionsp, stats);
if (error) {
if (actionsp) {
*actionsp = NULL;
* 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 odp_flow_stats *stats)
+ 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);
int
dpif_flow_del(struct dpif *dpif,
const struct nlattr *key, size_t key_len,
- struct odp_flow_stats *stats)
+ struct dpif_flow_stats *stats)
{
int error;
dpif_flow_dump_next(struct dpif_flow_dump *dump,
const struct nlattr **key, size_t *key_len,
const struct nlattr **actions, size_t *actions_len,
- const struct odp_flow_stats **stats)
+ const struct dpif_flow_stats **stats)
{
const struct dpif *dpif = dump->dpif;
int error = dump->error;
static void
log_flow_message(const struct dpif *dpif, int error, const char *operation,
const struct nlattr *key, size_t key_len,
- const struct odp_flow_stats *stats,
+ const struct dpif_flow_stats *stats,
const struct nlattr *actions, size_t actions_len)
{
struct ds ds = DS_EMPTY_INITIALIZER;
odp_flow_key_format(key, key_len, &ds);
if (stats) {
ds_put_cstr(&ds, ", ");
- format_odp_flow_stats(&ds, stats);
+ dpif_flow_stats_format(stats, &ds);
}
if (actions || actions_len) {
ds_put_cstr(&ds, ", actions:");