[ovs-dev] [PATCH 3/4] ofpbuf: Add ofpbuf_rss()

Pravin Shelar pshelar at nicira.com
Wed Aug 13 00:42:24 UTC 2014


On Tue, Jul 22, 2014 at 5:06 PM, Daniele Di Proietto
<ddiproietto at vmware.com> wrote:
> ofpbuf_rss() is introduced to get the RSS hash from the NIC. It works only for
> packets received by DPDK (otherwise it returns 0, which tells the caller to
> compute the hash in another way)
>
> This commit also configure DPDK devices to compute RSS hash for UDP packets
>
> Signed-off-by: Daniele Di Proietto <ddiproietto at vmware.com>
> ---
>  lib/netdev-dpdk.c |  3 ++-
>  lib/ofpbuf.h      | 13 +++++++++++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index 62c9a0c..44d2dc0 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -96,7 +96,8 @@ static const struct rte_eth_conf port_conf = {
>      .rx_adv_conf = {
>          .rss_conf = {
>              .rss_key = NULL,
> -            .rss_hf = ETH_RSS_IPV4_TCP | ETH_RSS_IPV4 | ETH_RSS_IPV6,
> +            .rss_hf = ETH_RSS_IPV4_TCP | ETH_RSS_IPV4 | ETH_RSS_IPV6
> +                      | ETH_RSS_IPV4_UDP,
>          },
>      },
>      .txmode = {
> diff --git a/lib/ofpbuf.h b/lib/ofpbuf.h
> index adaf526..9254c98 100644
> --- a/lib/ofpbuf.h
> +++ b/lib/ofpbuf.h
> @@ -159,6 +159,7 @@ char *ofpbuf_to_string(const struct ofpbuf *, size_t maxbytes);
>  static inline struct ofpbuf *ofpbuf_from_list(const struct list *);
>  void ofpbuf_list_delete(struct list *);
>  static inline bool ofpbuf_equal(const struct ofpbuf *, const struct ofpbuf *);
> +static inline uint32_t ofpbuf_rss(const struct ofpbuf *);
>
>
>  /* Returns a pointer that may be passed to free() to accomplish the same thing
> @@ -389,6 +390,13 @@ static inline void ofpbuf_set_size(struct ofpbuf *b, uint32_t v)
>      b->mbuf.pkt.pkt_len = v;     /* Total length of all segments linked to
>                                    * this segment. */
>  }
> +static inline uint32_t ofpbuf_rss(const struct ofpbuf * b)
> +{
> +    if (OVS_LIKELY(b->source == OFPBUF_DPDK)) {
> +        return (b)->mbuf.pkt.hash.rss;
> +    }
> +    return 0;
> +}
We need to handle case if buffer is not from dpdk.
>
>  #else
>  static inline void * ofpbuf_data(const struct ofpbuf *b)
> @@ -420,6 +428,11 @@ static inline void ofpbuf_set_size(struct ofpbuf *b, uint32_t v)
>  {
>      b->size_ = v;
>  }
> +
> +static inline uint32_t ofpbuf_rss(const struct ofpbuf *b OVS_UNUSED)
> +{
> +    return 0;
> +}
>  #endif
>
>  #ifdef  __cplusplus
> --
> 2.0.0
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list