diff mbox

[v2,02/17] net: Add utility function to set the rxhash

Message ID alpine.DEB.2.02.1311260913480.21024@tomh.mtv.corp.google.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Tom Herbert Nov. 26, 2013, 5:22 p.m. UTC
The function skb_set_rxash was added for drivers to call to set
the rxhash in an skb. The type of hash is also specified as
a parameter (L2, L3, L4, or unknown type).

Signed-off-by: Tom Herbert <therbert@google.com>
---
 include/linux/skbuff.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

David Miller Nov. 29, 2013, 8:42 p.m. UTC | #1
From: Tom Herbert <therbert@google.com>
Date: Tue, 26 Nov 2013 09:22:34 -0800 (PST)

> @@ -703,6 +703,20 @@ unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
>  			   unsigned int to, struct ts_config *config,
>  			   struct ts_state *state);
>  
> +enum rxhash_types {
> +	RXHASH_TYPE_NONE,	/* Undefined type */
> +	RXHASH_TYPE_L2,		/* Uses L2 information (addresses) */
> +	RXHASH_TYPE_L3,		/* Uses L3 information */
> +	RXHASH_TYPE_L4,		/* Uses L4 information (ports) */
> +};
> +
> +static inline void
> +skb_set_rxhash(struct sk_buff *skb, __u32 hash, enum rxhash_types type)
> +{
> +	skb->l4_rxhash = (type == RXHASH_TYPE_L4);
> +	skb->rxhash = hash;
> +}

This looks fine but I want slightly more documentation in the
comments.

First of all, L2 is link layer "addresses" like ethernet, and L3 is
for protocol "addresses" such as for IPv4/IPv6.  Make this explicit
in the comments.

Next, answer the question "Does RXHASH_TYPE_LN imply
RXHASH_TYPE_L{N-1}?"

I suspect it's variable, so for example L4 implies L3, but not
necessarily L2.  Document this fully.

Finally, are there any serious negative consequences for not setting
the type correctly?  Or is it just a minor performance issue?  Either
way, document it.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 76d3aa9..25f190e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -703,6 +703,20 @@  unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
 			   unsigned int to, struct ts_config *config,
 			   struct ts_state *state);
 
+enum rxhash_types {
+	RXHASH_TYPE_NONE,	/* Undefined type */
+	RXHASH_TYPE_L2,		/* Uses L2 information (addresses) */
+	RXHASH_TYPE_L3,		/* Uses L3 information */
+	RXHASH_TYPE_L4,		/* Uses L4 information (ports) */
+};
+
+static inline void
+skb_set_rxhash(struct sk_buff *skb, __u32 hash, enum rxhash_types type)
+{
+	skb->l4_rxhash = (type == RXHASH_TYPE_L4);
+	skb->rxhash = hash;
+}
+
 void __skb_get_rxhash(struct sk_buff *skb);
 static inline __u32 skb_get_rxhash(struct sk_buff *skb)
 {