From patchwork Thu Mar 3 18:44:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivo van Doorn X-Patchwork-Id: 606991 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p23Imj2p021009 for ; Thu, 3 Mar 2011 18:49:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758697Ab1CCSs6 (ORCPT ); Thu, 3 Mar 2011 13:48:58 -0500 Received: from mail-wy0-f174.google.com ([74.125.82.174]:35605 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754069Ab1CCSs5 (ORCPT ); Thu, 3 Mar 2011 13:48:57 -0500 Received: by mail-wy0-f174.google.com with SMTP id 36so1356532wyg.19 for ; Thu, 03 Mar 2011 10:48:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:date:user-agent:cc:references :in-reply-to:mime-version:content-type:content-transfer-encoding :message-id; bh=U/vGv5NRdEfPuuGGtKAMDUvognohrK0/GOdeLrsDwFM=; b=bW1E1AzsP1L96pb6KW9JIwCduD7zJUKZnmAERqeDYWzKOl1pQyqoUGkvU50npmQGWd ADmng7Ja8tNdY6rVXnCNt8xKn4ZK0pJJ0crwVYMZcW/YDWQRuOVs0Q65RZoRPXEv8p8E V5G3Z5g4gomcAHs3/7Vuu3VYxMKCYozbM0av8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; b=T2QKqFOx9qfWdA+Ky/eHGcCakrVeN99NFkFIn4tHDscAuuk0w/U8KDnQQ/zFXSYNdr Ep9/QeirazoxoP41E/TdYqrhMKV5ZhJ1QsX3x5N6SCAZCZSadTIoqJvTJgrbVTo6IMzA 81oURRLx46h5yVVok1JdYzicchRHPQxFTlK60= Received: by 10.216.187.82 with SMTP id x60mr1051914wem.9.1299178136635; Thu, 03 Mar 2011 10:48:56 -0800 (PST) Received: from localhost.localdomain (g121037.upc-g.chello.nl [80.57.121.37]) by mx.google.com with ESMTPS id j49sm738659wer.14.2011.03.03.10.48.53 (version=SSLv3 cipher=OTHER); Thu, 03 Mar 2011 10:48:54 -0800 (PST) From: Ivo van Doorn To: "John W. Linville" Subject: [PATCH 12/19] rt2x00: Fix rt2800 key assignment in multi bssid setups Date: Thu, 3 Mar 2011 19:44:33 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.32.26-175.fc12.x86_64; KDE/4.4.5; x86_64; ; ) Cc: linux-wireless@vger.kernel.org, users@rt2x00.serialmonkey.com References: <201103031938.56423.IvDoorn@gmail.com> <201103031943.50656.IvDoorn@gmail.com> <201103031944.11965.IvDoorn@gmail.com> In-Reply-To: <201103031944.11965.IvDoorn@gmail.com> MIME-Version: 1.0 Message-Id: <201103031944.33950.IvDoorn@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 03 Mar 2011 18:49:20 +0000 (UTC) diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index d789d5b..ba87662 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1093,27 +1093,44 @@ int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev, } EXPORT_SYMBOL_GPL(rt2800_config_shared_key); +static inline int rt2800_find_pairwise_keyslot(struct rt2x00_dev *rt2x00dev) +{ + int idx; + u32 offset, reg; + + /* + * Search for the first free pairwise key entry and return the + * corresponding index. + * + * Make sure the WCID starts _after_ the last possible shared key + * entry (>32). + * + * Since parts of the pairwise key table might be shared with + * the beacon frame buffers 6 & 7 we should only write into the + * first 222 entries. + */ + for (idx = 33; idx <= 222; idx++) { + offset = MAC_WCID_ATTR_ENTRY(idx); + rt2800_register_read(rt2x00dev, offset, ®); + if (!reg) + return idx; + } + return -1; +} + int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_crypto *crypto, struct ieee80211_key_conf *key) { struct hw_key_entry key_entry; u32 offset; + int idx; if (crypto->cmd == SET_KEY) { - /* - * 1 pairwise key is possible per AID, this means that the AID - * equals our hw_key_idx. Make sure the WCID starts _after_ the - * last possible shared key entry. - * - * Since parts of the pairwise key table might be shared with - * the beacon frame buffers 6 & 7 we should only write into the - * first 222 entries. - */ - if (crypto->aid > (222 - 32)) + idx = rt2800_find_pairwise_keyslot(rt2x00dev); + if (idx < 0) return -ENOSPC; - - key->hw_key_idx = 32 + crypto->aid; + key->hw_key_idx = idx; memcpy(key_entry.key, crypto->key, sizeof(key_entry.key)); @@ -2443,7 +2460,7 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i), wcid, sizeof(wcid)); - rt2800_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 1); + rt2800_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 0); rt2800_register_write(rt2x00dev, MAC_IVEIV_ENTRY(i), 0); }