From patchwork Mon Oct 6 18:23:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 5039021 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6B06B9F2F1 for ; Mon, 6 Oct 2014 18:24:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 85B0B2014A for ; Mon, 6 Oct 2014 18:24:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 936C52013A for ; Mon, 6 Oct 2014 18:24:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753014AbaJFSYe (ORCPT ); Mon, 6 Oct 2014 14:24:34 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:54789 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080AbaJFSYe (ORCPT ); Mon, 6 Oct 2014 14:24:34 -0400 Received: by mail-wg0-f52.google.com with SMTP id a1so7276172wgh.35 for ; Mon, 06 Oct 2014 11:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=9pLKGt0W9xVfPC16PuR949jfuwZpTOjdJBOe5ICTmbs=; b=LvRrjGbgRS/oHOGQ7uTRkQhbSgWx6bQZ9hmXoc/0Th2Q8cGEQ7W6CpvGncBMqy68EI beJqizalCIpHSQcgWXNHvKILCh9Ynk7D0vvEDdHhyNv1VMRfNj2ZxpILPcn1x7iThrYT ZjydmVPXC0lUrd7GxvU7Wcvojz9GfSpBFlYboUSC63Tdl2Rn6ySotwHhFjVxjDhNF5G+ f+W46HtSCjw09Oo4gMXs+Usu0fSIxztmX0ethGegqb9yJWIBph7n+RouLUNSNrJAOL2y 5qFYvgMcCEwJnRYQYUz5Mp16xhSGr0U0vErLgIJPc3W9rhvds9Bnw+z7MMHaFi4XmNj+ DmrA== X-Received: by 10.180.198.203 with SMTP id je11mr21321358wic.69.1412619873103; Mon, 06 Oct 2014 11:24:33 -0700 (PDT) Received: from localhost.localdomain ([95.236.121.96]) by mx.google.com with ESMTPSA id pm6sm18078153wjb.36.2014.10.06.11.24.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Oct 2014 11:24:32 -0700 (PDT) From: Andrea Merello To: linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, Larry.Finger@lwfinger.net, bernhard@schiffner-limbach.de, dan.carpenter@oracle.com, xose.vazquez@gmail.com, ralf@czekalla.com, Andrea Merello Subject: [PATCH] rtl818x_pci: fix response rate may be incorrect. Date: Mon, 6 Oct 2014 20:23:55 +0200 Message-Id: <1412619835-12038-1-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the allowed "respose rate" set (rates for HW generated frames like ACKs) is the same as the basic rate set. The HW will use the higher allowed response rate that is lower than the rate of the received frame. This is more or less what IEEE80211 mandates, but I missed the fact that IEEE80211 also says that whenever it happens that for a modulation class there is no any rate in the basic rates set, then the response rate set shall include also all the mandatory rates for that modulation class. This patch adds mandatory OFDM rates to the allowed response rate set if no OFDM rate is included in the basic rate set. Depending by the AP, I faced cases in which this patch seems to cause a noticeable perfomance improvement. - With my usual test AP there is no particular perfomance difference. - With a prism54/hostapd AP this patch causes RX thoughput increase from about 5Mbps to about 20Mbps. Hopefully this patch may help people that faced performance regression wrt the old staging driver. Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl8180/dev.c | 36 +++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index ded967a..706b844 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -742,35 +742,49 @@ static void rtl8180_int_disable(struct ieee80211_hw *dev) } static void rtl8180_conf_basic_rates(struct ieee80211_hw *dev, - u32 rates_mask) + u32 basic_mask) { struct rtl8180_priv *priv = dev->priv; - - u8 max, min; u16 reg; - - max = fls(rates_mask) - 1; - min = ffs(rates_mask) - 1; + u32 resp_mask; + u8 basic_max; + u8 resp_max, resp_min; + + resp_mask = basic_mask; + /* IEEE80211 says the response rate should be equal to the highest basic + * rate that is not faster than received frame. But it says also that if + * the basic rate set does not contains any rate for the current + * modulation class then mandatory rate set must be used for that + * modulation class. Eventually add OFDM mandatory rates.. + */ + if ((resp_mask & 0xf) == resp_mask) + resp_mask |= 0x150; /* 6, 12, 24Mbps */ switch (priv->chip_family) { case RTL818X_CHIP_FAMILY_RTL8180: /* in 8180 this is NOT a BITMAP */ + basic_max = fls(basic_mask) - 1; reg = rtl818x_ioread16(priv, &priv->map->BRSR); reg &= ~3; - reg |= max; + reg |= basic_max; rtl818x_iowrite16(priv, &priv->map->BRSR, reg); break; case RTL818X_CHIP_FAMILY_RTL8185: + resp_max = fls(resp_mask) - 1; + resp_min = ffs(resp_mask) - 1; /* in 8185 this is a BITMAP */ - rtl818x_iowrite16(priv, &priv->map->BRSR, rates_mask); - rtl818x_iowrite8(priv, &priv->map->RESP_RATE, (max << 4) | min); + rtl818x_iowrite16(priv, &priv->map->BRSR, basic_mask); + rtl818x_iowrite8(priv, &priv->map->RESP_RATE, (resp_max << 4) | + resp_min); break; case RTL818X_CHIP_FAMILY_RTL8187SE: - /* in 8187se this is a BITMAP */ - rtl818x_iowrite16(priv, &priv->map->BRSR_8187SE, rates_mask); + /* in 8187se this is a BITMAP. BRSR reg actually sets + * response rates. + */ + rtl818x_iowrite16(priv, &priv->map->BRSR_8187SE, resp_mask); break; } }