struct flow key;
/* Statistics. */
- struct timespec used; /* Last used time. */
+ long long int used; /* Last used time, in monotonic msecs. */
long long int packet_count; /* Number of packets matched. */
long long int byte_count; /* Number of bytes matched. */
uint16_t tcp_ctl; /* Bitwise-OR of seen tcp_ctl values. */
}
static void
-get_odp_flow_stats(struct dp_netdev_flow *flow, struct odp_flow_stats *stats)
+get_dpif_flow_stats(struct dp_netdev_flow *flow, struct dpif_flow_stats *stats)
{
stats->n_packets = flow->packet_count;
stats->n_bytes = flow->byte_count;
- stats->used_sec = flow->used.tv_sec;
- stats->used_nsec = flow->used.tv_nsec;
+ stats->used = flow->used;
stats->tcp_flags = TCP_FLAGS(flow->tcp_ctl);
- stats->reserved = 0;
}
static int
}
static int
-dpif_netdev_flow_get(const struct dpif *dpif, int flags,
+dpif_netdev_flow_get(const struct dpif *dpif,
const struct nlattr *nl_key, size_t nl_key_len,
- struct ofpbuf **actionsp, struct odp_flow_stats *stats)
+ struct ofpbuf **actionsp, struct dpif_flow_stats *stats)
{
struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *flow;
}
if (stats) {
- get_odp_flow_stats(flow, stats);
+ get_dpif_flow_stats(flow, stats);
}
if (actionsp) {
*actionsp = ofpbuf_clone_data(flow->actions, flow->actions_len);
}
- if (flags & ODPFF_ZERO_TCP_FLAGS) {
- flow->tcp_ctl = 0;
- }
return 0;
}
static void
clear_stats(struct dp_netdev_flow *flow)
{
- flow->used.tv_sec = 0;
- flow->used.tv_nsec = 0;
+ flow->used = 0;
flow->packet_count = 0;
flow->byte_count = 0;
flow->tcp_ctl = 0;
}
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 odp_flow_stats *stats)
+ struct dpif_flow_stats *stats)
{
struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *flow;
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_odp_flow_stats(flow, stats);
+ get_dpif_flow_stats(flow, stats);
}
- if (flags & ODPPF_ZERO_STATS) {
+ if (flags & DPIF_FP_ZERO_STATS) {
clear_stats(flow);
}
}
static int
dpif_netdev_flow_del(struct dpif *dpif,
const struct nlattr *nl_key, size_t nl_key_len,
- struct odp_flow_stats *stats)
+ struct dpif_flow_stats *stats)
{
struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *flow;
flow = dp_netdev_lookup_flow(dp, &key);
if (flow) {
if (stats) {
- get_odp_flow_stats(flow, stats);
+ get_dpif_flow_stats(flow, stats);
}
dp_netdev_free_flow(dp, flow);
return 0;
uint32_t offset;
struct nlattr *actions;
uint32_t keybuf[ODPUTIL_FLOW_KEY_U32S];
- struct odp_flow_stats stats;
+ struct dpif_flow_stats stats;
};
static int
dpif_netdev_flow_dump_next(const struct dpif *dpif, void *state_,
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)
{
struct dp_netdev_flow_state *state = state_;
struct dp_netdev *dp = get_dp_netdev(dpif);
}
if (stats) {
- get_odp_flow_stats(flow, &state->stats);
+ get_dpif_flow_stats(flow, &state->stats);
*stats = &state->stats;
}
dpif_netdev_recv_set_mask(struct dpif *dpif, int listen_mask)
{
struct dpif_netdev *dpif_netdev = dpif_netdev_cast(dpif);
- if (!(listen_mask & ~ODPL_ALL)) {
- dpif_netdev->listen_mask = listen_mask;
- return 0;
- } else {
- return EINVAL;
- }
+ dpif_netdev->listen_mask = listen_mask;
+ return 0;
}
static struct dp_netdev_queue *
dp_netdev_flow_used(struct dp_netdev_flow *flow, struct flow *key,
const struct ofpbuf *packet)
{
- time_timespec(&flow->used);
+ flow->used = time_msec();
flow->packet_count++;
flow->byte_count += packet->size;
if (key->dl_type == htons(ETH_TYPE_IP) && key->nw_proto == IPPROTO_TCP) {
dp->n_hit++;
} else {
dp->n_missed++;
- dp_netdev_output_control(dp, packet, _ODPL_MISS_NR, &key, 0);
+ dp_netdev_output_control(dp, packet, DPIF_UC_MISS, &key, 0);
}
}
break;
case ODPAT_CONTROLLER:
- dp_netdev_output_control(dp, packet, _ODPL_ACTION_NR,
+ dp_netdev_output_control(dp, packet, DPIF_UC_ACTION,
key, nl_attr_get_u64(a));
break;