On Wed, Aug 13, 2014 at 4:42 PM, Daniele Di Proietto
<ddiproie...@vmware.com> wrote:
> On 8/13/14, 3:28 PM, "Pravin Shelar" <pshe...@nicira.com> wrote:
>
>>On Wed, Aug 13, 2014 at 8:49 AM, Daniele Di Proietto
>><ddiproie...@vmware.com> wrote:
>>>
>>>
>>> On 8/12/14, 5:42 PM, "Pravin Shelar" <pshe...@nicira.com> wrote:
>>>
>>>>On Tue, Jul 22, 2014 at 5:06 PM, Daniele Di Proietto
>>>><ddiproie...@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 <ddiproie...@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.
>>>
>>> If the buffer is not from DPDK we just return 0 (which is considered an
>>> invalid hash value). Is there anything better we could do?
>>>
>>
>>You can use miniflow_hash_5tuple() to calculate the hash. We also need
>>this API for hash action code in dpif-netdev to use DPDK rss rather
>>than extracting flow key for every packet.
>
> I am using ofpbuf_rss() like this (in the next commit):
>
> uint32_t hash = ofpbuf_rss(&packets[i]->ofpbuf);
> if (OVS_UNLIKELY(!hash)) {
>     hash = miniflow_hash_5tuple(&key.flow, 0);
>         }
>
> If you think it¹s better we can pass a miniflow pointer and move
> miniflow_hash_5tuple() into ofpbuf_rss(), but we¹ll need to include flow.h
> into ofpbuf.h or move ofpbuf_rss() to ofpbuf.c
>

I think we should extract flow and calculate hash inside ofpbuf_rss().
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to