diff options
author | Tom Herbert <therbert@google.com> | 2013-12-16 01:16:19 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-17 16:36:22 -0500 |
commit | 09323cc479316e046931a2c679932204b36fea6c (patch) | |
tree | 80a3b4f3674c469a68dc65ef4446a652b68a9e2f | |
parent | 7539fadcb8146a5f0db51e80d99c9e724efec7b0 (diff) |
net: Add function to set the rxhash
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/skbuff.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 7deb7ad65914..99846956dff9 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -703,6 +703,46 @@ unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, | |||
703 | unsigned int to, struct ts_config *config, | 703 | unsigned int to, struct ts_config *config, |
704 | struct ts_state *state); | 704 | struct ts_state *state); |
705 | 705 | ||
706 | /* | ||
707 | * Packet hash types specify the type of hash in skb_set_hash. | ||
708 | * | ||
709 | * Hash types refer to the protocol layer addresses which are used to | ||
710 | * construct a packet's hash. The hashes are used to differentiate or identify | ||
711 | * flows of the protocol layer for the hash type. Hash types are either | ||
712 | * layer-2 (L2), layer-3 (L3), or layer-4 (L4). | ||
713 | * | ||
714 | * Properties of hashes: | ||
715 | * | ||
716 | * 1) Two packets in different flows have different hash values | ||
717 | * 2) Two packets in the same flow should have the same hash value | ||
718 | * | ||
719 | * A hash at a higher layer is considered to be more specific. A driver should | ||
720 | * set the most specific hash possible. | ||
721 | * | ||
722 | * A driver cannot indicate a more specific hash than the layer at which a hash | ||
723 | * was computed. For instance an L3 hash cannot be set as an L4 hash. | ||
724 | * | ||
725 | * A driver may indicate a hash level which is less specific than the | ||
726 | * actual layer the hash was computed on. For instance, a hash computed | ||
727 | * at L4 may be considered an L3 hash. This should only be done if the | ||
728 | * driver can't unambiguously determine that the HW computed the hash at | ||
729 | * the higher layer. Note that the "should" in the second property above | ||
730 | * permits this. | ||
731 | */ | ||
732 | enum pkt_hash_types { | ||
733 | PKT_HASH_TYPE_NONE, /* Undefined type */ | ||
734 | PKT_HASH_TYPE_L2, /* Input: src_MAC, dest_MAC */ | ||
735 | PKT_HASH_TYPE_L3, /* Input: src_IP, dst_IP */ | ||
736 | PKT_HASH_TYPE_L4, /* Input: src_IP, dst_IP, src_port, dst_port */ | ||
737 | }; | ||
738 | |||
739 | static inline void | ||
740 | skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type) | ||
741 | { | ||
742 | skb->l4_rxhash = (type == PKT_HASH_TYPE_L4); | ||
743 | skb->rxhash = hash; | ||
744 | } | ||
745 | |||
706 | void __skb_get_hash(struct sk_buff *skb); | 746 | void __skb_get_hash(struct sk_buff *skb); |
707 | static inline __u32 skb_get_hash(struct sk_buff *skb) | 747 | static inline __u32 skb_get_hash(struct sk_buff *skb) |
708 | { | 748 | { |