diff options
author | Octavian Purdila <opurdila@ixiacom.com> | 2009-12-26 06:51:05 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-26 23:45:32 -0500 |
commit | 52d58aef5ee460fedd7f250f05e79081019f2c79 (patch) | |
tree | 9c8d2bf8374570038820a47325a2305bcb83111d /include | |
parent | 6d2e3ea284463d5ab34e9cf2a41d0b8627b95d02 (diff) |
llc: replace the socket list with a local address based hash
For the cases where a lot of interfaces are used in conjunction with a
lot of LLC sockets bound to the same SAP, the iteration of the socket
list becomes prohibitively expensive.
Replacing the list with a a local address based hash significantly
improves the bind and listener lookup operations as well as the
datagram delivery.
Connected sockets delivery is also improved, but this patch does not
address the case where we have lots of sockets with the same local
address connected to different remote addresses.
In order to keep the socket sanity checks alive and fast a socket
counter was added to the SAP structure.
Signed-off-by: Octavian Purdila <opurdila@ixiacom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/llc.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/include/net/llc.h b/include/net/llc.h index dbef5917905b..709a9b37e239 100644 --- a/include/net/llc.h +++ b/include/net/llc.h | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
19 | #include <linux/rculist_nulls.h> | 19 | #include <linux/rculist_nulls.h> |
20 | #include <linux/hash.h> | ||
21 | #include <linux/jhash.h> | ||
20 | 22 | ||
21 | #include <asm/atomic.h> | 23 | #include <asm/atomic.h> |
22 | 24 | ||
@@ -35,6 +37,9 @@ struct llc_addr { | |||
35 | #define LLC_SK_DEV_HASH_BITS 6 | 37 | #define LLC_SK_DEV_HASH_BITS 6 |
36 | #define LLC_SK_DEV_HASH_ENTRIES (1<<LLC_SK_DEV_HASH_BITS) | 38 | #define LLC_SK_DEV_HASH_ENTRIES (1<<LLC_SK_DEV_HASH_BITS) |
37 | 39 | ||
40 | #define LLC_SK_LADDR_HASH_BITS 6 | ||
41 | #define LLC_SK_LADDR_HASH_ENTRIES (1<<LLC_SK_LADDR_HASH_BITS) | ||
42 | |||
38 | /** | 43 | /** |
39 | * struct llc_sap - Defines the SAP component | 44 | * struct llc_sap - Defines the SAP component |
40 | * | 45 | * |
@@ -58,7 +63,8 @@ struct llc_sap { | |||
58 | struct llc_addr laddr; | 63 | struct llc_addr laddr; |
59 | struct list_head node; | 64 | struct list_head node; |
60 | spinlock_t sk_lock; | 65 | spinlock_t sk_lock; |
61 | struct hlist_nulls_head sk_list; | 66 | int sk_count; |
67 | struct hlist_nulls_head sk_laddr_hash[LLC_SK_LADDR_HASH_ENTRIES]; | ||
62 | struct hlist_head sk_dev_hash[LLC_SK_DEV_HASH_ENTRIES]; | 68 | struct hlist_head sk_dev_hash[LLC_SK_DEV_HASH_ENTRIES]; |
63 | }; | 69 | }; |
64 | 70 | ||
@@ -68,6 +74,19 @@ struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex) | |||
68 | return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES]; | 74 | return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES]; |
69 | } | 75 | } |
70 | 76 | ||
77 | static inline | ||
78 | u32 llc_sk_laddr_hashfn(struct llc_sap *sap, const struct llc_addr *laddr) | ||
79 | { | ||
80 | return hash_32(jhash(laddr->mac, sizeof(laddr->mac), 0), | ||
81 | LLC_SK_LADDR_HASH_BITS); | ||
82 | } | ||
83 | |||
84 | static inline | ||
85 | struct hlist_nulls_head *llc_sk_laddr_hash(struct llc_sap *sap, | ||
86 | const struct llc_addr *laddr) | ||
87 | { | ||
88 | return &sap->sk_laddr_hash[llc_sk_laddr_hashfn(sap, laddr)]; | ||
89 | } | ||
71 | 90 | ||
72 | #define LLC_DEST_INVALID 0 /* Invalid LLC PDU type */ | 91 | #define LLC_DEST_INVALID 0 /* Invalid LLC PDU type */ |
73 | #define LLC_DEST_SAP 1 /* Type 1 goes here */ | 92 | #define LLC_DEST_SAP 1 /* Type 1 goes here */ |