This new function uses ofpbuf_rss(), or hashes the packet 5-tuple, to get the hash of a packet. Used by OVS_ACTION_ATTR_HASH and future commits.
Signed-off-by: Daniele Di Proietto <ddiproie...@vmware.com> --- lib/dpif-netdev.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index a458f24..c77fbce 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1850,6 +1850,26 @@ dp_netdev_stats_new_cb(void) return bucket; } +static inline uint32_t +dp_netdev_packet_rss(struct dpif_packet *packet, const struct miniflow *mf) +{ + uint32_t hash; + + hash = ofpbuf_rss(&packet->ofpbuf); + if (OVS_UNLIKELY(!hash)) { + struct netdev_flow_key key; + if (!mf) { + miniflow_initialize(&key.flow, key.buf); + miniflow_extract(&packet->ofpbuf, NULL, &key.flow); + mf = &key.flow; + } + + hash = miniflow_hash_5tuple(mf, 0); + } + + return hash; +} + static void dp_netdev_count_packet(struct dp_netdev *dp, enum dp_stat_type type, int cnt) { @@ -2168,22 +2188,17 @@ dp_execute_cb(void *aux_, struct dpif_packet **packets, int cnt, case OVS_ACTION_ATTR_HASH: { const struct ovs_action_hash *hash_act; - struct netdev_flow_key key; uint32_t hash; hash_act = nl_attr_get(a); - miniflow_initialize(&key.flow, key.buf); - for (i = 0; i < cnt; i++) { - /* XXX: this is slow. Use RSS hash in the future */ - miniflow_extract(&packets[i]->ofpbuf, md, &key.flow); - if (hash_act->hash_alg == OVS_HASH_ALG_L4) { /* Hash need not be symmetric, nor does it need to include * L2 fields. */ - hash = miniflow_hash_5tuple(&key.flow, hash_act->hash_basis); + hash = hash_2words(dp_netdev_packet_rss(packets[i], NULL), + hash_act->hash_basis); } else { VLOG_WARN("Unknown hash algorithm specified " "for the hash action."); -- 2.0.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev