[ovs-dev] [PATCH 3/5] dp-packet: Rename 'dp_hash' in 'rss_hash'.

Ethan Jackson ethan at nicira.com
Mon Apr 20 19:48:49 UTC 2015


Acked-by: Ethan Jackson <ethan at nicira.com>


On Wed, Apr 15, 2015 at 11:11 AM, Daniele Di Proietto
<diproiettod at vmware.com> wrote:
> 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 at vmware.com>
> ---
>  lib/dp-packet.h    | 10 +++++-----
>  lib/dpif-netdev.c  |  7 ++-----
>  lib/netdev-bsd.c   |  2 +-
>  lib/netdev-dummy.c |  2 +-
>  lib/netdev-linux.c |  2 +-
>  lib/netdev-vport.c |  2 +-
>  lib/odp-execute.c  |  7 ++-----
>  7 files changed, 13 insertions(+), 19 deletions(-)
>
> diff --git a/lib/dp-packet.h b/lib/dp-packet.h
> index 5d0fee7..fd23d11 100644
> --- a/lib/dp-packet.h
> +++ b/lib/dp-packet.h
> @@ -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
>  }
>
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index 8aa70c8..5b44d51 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -3009,10 +3009,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;
>  }
> @@ -3492,9 +3492,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)--;
> diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c
> index 541e5ec..e77aba5 100644
> --- a/lib/netdev-bsd.c
> +++ b/lib/netdev-bsd.c
> @@ -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;
>      }
> diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
> index 24c91c2..db03f59 100644
> --- a/lib/netdev-dummy.c
> +++ b/lib/netdev-dummy.c
> @@ -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;
> diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
> index 23f9856..36e27e0 100644
> --- a/lib/netdev-linux.c
> +++ b/lib/netdev-linux.c
> @@ -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;
>      }
> diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
> index f228ac2..297320c 100644
> --- a/lib/netdev-vport.c
> +++ b/lib/netdev-vport.c
> @@ -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);
> diff --git a/lib/odp-execute.c b/lib/odp-execute.c
> index ccd29d7..f83fe60 100644
> --- a/lib/odp-execute.c
> +++ b/lib/odp-execute.c
> @@ -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.  */
> --
> 2.1.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list