]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mac80211: duplicate station's MAC address for hash table
authorJohannes Berg <johannes.berg@intel.com>
Tue, 16 Jun 2015 14:22:12 +0000 (16:22 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 17 Jul 2015 13:38:03 +0000 (15:38 +0200)
Currently, the station hash table lookup (or iteration) must
access two cachelines for each station - the one with the hash
table node, and the one with the MAC address.

Duplicate the MAC address next to the hash node to get rid of
this. Since the MAC address is static there's no consistency
problem introduced by this.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/sta_info.c
net/mac80211/sta_info.h

index 666ddac3c87c67a63ed685efe83221cf7d52428d..d573a499750eb24cecc3570895b9294087d55439 100644 (file)
@@ -68,7 +68,7 @@ static const struct rhashtable_params sta_rht_params = {
        .nelem_hint = 3, /* start small */
        .automatic_shrinking = true,
        .head_offset = offsetof(struct sta_info, hash_node),
-       .key_offset = offsetof(struct sta_info, sta.addr),
+       .key_offset = offsetof(struct sta_info, addr),
        .key_len = ETH_ALEN,
        .hashfn = sta_addr_hash,
        .max_size = CONFIG_MAC80211_STA_HASH_MAX_SIZE,
@@ -320,6 +320,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
        sta->nonpeer_pm = NL80211_MESH_POWER_ACTIVE;
 #endif
 
+       memcpy(sta->addr, addr, ETH_ALEN);
        memcpy(sta->sta.addr, addr, ETH_ALEN);
        sta->local = local;
        sta->sdata = sdata;
index db76103b444556fa9c5f16b7f81cde6c06c4d8a9..4229849862638630ce271c126af61c999a24e214 100644 (file)
@@ -278,6 +278,8 @@ struct ieee80211_fast_tx {
  * @list: global linked list entry
  * @free_list: list entry for keeping track of stations to free
  * @hash_node: hash node for rhashtable
+ * @addr: station's MAC address - duplicated from public part to
+ *     let the hash table work with just a single cacheline
  * @local: pointer to the global information
  * @sdata: virtual interface this station belongs to
  * @ptk: peer keys negotiated with this station, if any
@@ -377,6 +379,7 @@ struct sta_info {
        struct list_head list, free_list;
        struct rcu_head rcu_head;
        struct rhash_head hash_node;
+       u8 addr[ETH_ALEN];
        struct ieee80211_local *local;
        struct ieee80211_sub_if_data *sdata;
        struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
@@ -607,7 +610,7 @@ u32 sta_addr_hash(const void *key, u32 length, u32 seed);
                               _sta_bucket_idx(tbl, _addr),             \
                               hash_node)                               \
        /* compare address and run code only if it matches */           \
-       if (ether_addr_equal(_sta->sta.addr, (_addr)))
+       if (ether_addr_equal(_sta->addr, (_addr)))
 
 /*
  * Get STA info by index, BROKEN!