dpif-netdev queue packet to upcall handler thread to process flow misses. This adds latency for initial flow setup. Using ofproto flow lookup method for netdev flow-table miss can be handled in same thread.
Signed-off-by: Pravin B Shelar <pshe...@nicira.com> --- lib/dpif-netdev.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 7b921b1..5057833 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -350,10 +350,6 @@ static void dp_netdev_destroy_all_queues(struct dp_netdev *dp) OVS_REQ_WRLOCK(dp->queue_rwlock); static int dpif_netdev_open(const struct dpif_class *, const char *name, bool create, void *handle_miss_data, struct dpif **); -static int dp_netdev_output_userspace(struct dp_netdev *dp, struct ofpbuf *, - int queue_no, int type, - const struct flow *, - const struct nlattr *userdata); static void dp_netdev_execute_actions(struct dp_netdev *dp, const struct flow *, struct ofpbuf *, bool may_steal, struct pkt_metadata *, @@ -1980,6 +1976,44 @@ dp_netdev_count_packet(struct dp_netdev *dp, enum dp_stat_type type) } static void +dp_handle_miss(struct dp_netdev *dp, struct pkt_metadata *md, + struct ofpbuf *packet, struct flow *key) +{ + struct dp_netdev_flow *netdev_flow; + struct flow_wildcards wc; + struct ofpbuf actions; + uint64_t buf[4096 / 8]; + int err; + + dp_netdev_count_packet(dp, DP_STAT_MISS); + ofpbuf_use_stack(&actions, buf, 4096); + + err = -EINVAL; + if (dp->handle_miss_data) { + struct flow pkt_key = *key; + + err = fn_ofproto_flow_lookup(dp->handle_miss_data, packet, + &pkt_key, &wc, &actions); + } + if (err) { + ofpbuf_delete(packet); + return; + } + + ovs_mutex_lock(&dp->flow_mutex); + netdev_flow = dp_netdev_lookup_flow(dp, key); + if (!netdev_flow) { + if (hmap_count(&dp->flow_table) < MAX_FLOWS) { + dp_netdev_flow_add(dp, key, &wc, actions.data, actions.size); + } + } + ovs_mutex_unlock(&dp->flow_mutex); + + dp_netdev_execute_actions(dp, key, packet, true, md, + actions.data, actions.size); +} + +static void dp_netdev_port_input(struct dp_netdev *dp, struct ofpbuf *packet, struct pkt_metadata *md) { @@ -2001,12 +2035,8 @@ dp_netdev_port_input(struct dp_netdev *dp, struct ofpbuf *packet, dp_netdev_execute_actions(dp, &key, packet, true, md, actions->actions, actions->size); dp_netdev_count_packet(dp, DP_STAT_HIT); - } else if (dp->handler_queues) { - dp_netdev_count_packet(dp, DP_STAT_MISS); - dp_netdev_output_userspace(dp, packet, - flow_hash_5tuple(&key, 0) % dp->n_handlers, - DPIF_UC_MISS, &key, NULL); - ofpbuf_delete(packet); + } else { + dp_handle_miss(dp, md, packet, &key); } } -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev