dp-packet: Rename 'dp_hash' in 'rss_hash'.
authorDaniele Di Proietto <diproiettod@vmware.com>
Wed, 15 Apr 2015 18:11:48 +0000 (19:11 +0100)
committerEthan Jackson <ethan@nicira.com>
Mon, 20 Apr 2015 19:49:41 +0000 (12:49 -0700)
We already have the 'dp_hash' embedded in the metadata.  This caused
confusion in the code.  With this commit it should be clear that
'rss_hash' is the packet hash used for internal purposes, while
'md.dp_hash' is part of the flow, computed during the execution of
certain actions.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
lib/dp-packet.h
lib/dpif-netdev.c
lib/netdev-bsd.c
lib/netdev-dummy.c
lib/netdev-linux.c
lib/netdev-vport.c
lib/odp-execute.c

index 5d0fee7..fd23d11 100644 (file)
@@ -63,7 +63,7 @@ struct dp_packet {
     void *base_;                /* First byte of allocated space. */
     uint16_t data_ofs;          /* First byte actually in use. */
     uint32_t size_;             /* Number of bytes in use. */
-    uint32_t dp_hash;           /* Packet hash. */
+    uint32_t rss_hash;          /* Packet hash. */
 #endif
     uint32_t allocated;         /* Number of bytes allocated. */
 
@@ -484,22 +484,22 @@ static inline void dp_packet_reset_packet(struct dp_packet *b, int off)
     b->l2_5_ofs = b->l3_ofs = b->l4_ofs = UINT16_MAX;
 }
 
-static inline uint32_t dp_packet_get_dp_hash(struct dp_packet *p)
+static inline uint32_t dp_packet_get_rss_hash(struct dp_packet *p)
 {
 #ifdef DPDK_NETDEV
     return p->mbuf.hash.rss;
 #else
-    return p->dp_hash;
+    return p->rss_hash;
 #endif
 }
 
-static inline void dp_packet_set_dp_hash(struct dp_packet *p,
+static inline void dp_packet_set_rss_hash(struct dp_packet *p,
                                            uint32_t hash)
 {
 #ifdef DPDK_NETDEV
     p->mbuf.hash.rss = hash;
 #else
-    p->dp_hash = hash;
+    p->rss_hash = hash;
 #endif
 }
 
index 892a024..78ed486 100644 (file)
@@ -3012,10 +3012,10 @@ dpif_netdev_packet_get_dp_hash(struct dp_packet *packet,
 {
     uint32_t hash;
 
-    hash = dp_packet_get_dp_hash(packet);
+    hash = dp_packet_get_rss_hash(packet);
     if (OVS_UNLIKELY(!hash)) {
         hash = miniflow_hash_5tuple(mf, 0);
-        dp_packet_set_dp_hash(packet, hash);
+        dp_packet_set_rss_hash(packet, hash);
     }
     return hash;
 }
@@ -3495,9 +3495,6 @@ dp_execute_cb(void *aux_, struct dp_packet **packets, int cnt,
 
                 recirc_pkt->md.recirc_id = nl_attr_get_u32(a);
 
-                /* Hash is private to each packet */
-                recirc_pkt->md.dp_hash = dp_packet_get_dp_hash(packets[i]);
-
                 dp_netdev_input(pmd, &recirc_pkt, 1);
             }
             (*depth)--;
index cc01470..b3075dc 100644 (file)
@@ -642,7 +642,7 @@ netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **packets,
         dp_packet_delete(packet);
     } else {
         dp_packet_pad(packet);
-        dp_packet_set_dp_hash(packet, 0);
+        dp_packet_set_rss_hash(packet, 0);
         packets[0] = packet;
         *c = 1;
     }
index 24c91c2..db03f59 100644 (file)
@@ -834,7 +834,7 @@ netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **arr,
     ovs_mutex_unlock(&netdev->mutex);
 
     dp_packet_pad(packet);
-    dp_packet_set_dp_hash(packet, 0);
+    dp_packet_set_rss_hash(packet, 0);
 
     arr[0] = packet;
     *c = 1;
index 23f9856..36e27e0 100644 (file)
@@ -1058,7 +1058,7 @@ netdev_linux_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **packets,
         dp_packet_delete(buffer);
     } else {
         dp_packet_pad(buffer);
-        dp_packet_set_dp_hash(buffer, 0);
+        dp_packet_set_rss_hash(buffer, 0);
         packets[0] = buffer;
         *c = 1;
     }
index f228ac2..297320c 100644 (file)
@@ -914,7 +914,7 @@ get_src_port(struct dp_packet *packet)
 {
     uint32_t hash;
 
-    hash = dp_packet_get_dp_hash(packet);
+    hash = dp_packet_get_rss_hash(packet);
 
     return htons((((uint64_t) hash * (tnl_udp_port_max - tnl_udp_port_min)) >> 32) +
                  tnl_udp_port_min);
index ccd29d7..f83fe60 100644 (file)
@@ -312,7 +312,6 @@ odp_execute_set_action(struct dp_packet *packet, const struct nlattr *a)
 
     case OVS_KEY_ATTR_DP_HASH:
         md->dp_hash = nl_attr_get_u32(a);
-        dp_packet_set_dp_hash(packet, md->dp_hash);
         break;
 
     case OVS_KEY_ATTR_RECIRC_ID:
@@ -405,8 +404,7 @@ odp_execute_masked_set_action(struct dp_packet *packet,
 
     case OVS_KEY_ATTR_DP_HASH:
         md->dp_hash = nl_attr_get_u32(a)
-            | (dp_packet_get_dp_hash(packet) & ~*get_mask(a, uint32_t));
-        dp_packet_set_dp_hash(packet, md->dp_hash);
+            | (md->dp_hash & ~*get_mask(a, uint32_t));
         break;
 
     case OVS_KEY_ATTR_RECIRC_ID:
@@ -516,8 +514,7 @@ odp_execute_actions(void *dp, struct dp_packet **packets, int cnt, bool steal,
                     flow_extract(packets[i], &flow);
                     hash = flow_hash_5tuple(&flow, hash_act->hash_basis);
 
-                    /* We also store the hash value with each packet */
-                    dp_packet_set_dp_hash(packets[i], hash ? hash : 1);
+                    packets[i]->md.dp_hash = hash;
                 }
             } else {
                 /* Assert on unknown hash algorithm.  */