From patchwork Wed Mar 26 20:03:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 3895121 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A7CD6BF540 for ; Wed, 26 Mar 2014 20:02:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C39E720222 for ; Wed, 26 Mar 2014 20:02:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E05DB2021F for ; Wed, 26 Mar 2014 20:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932092AbaCZUCb (ORCPT ); Wed, 26 Mar 2014 16:02:31 -0400 Received: from mail-ee0-f54.google.com ([74.125.83.54]:55363 "EHLO mail-ee0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756170AbaCZUCb (ORCPT ); Wed, 26 Mar 2014 16:02:31 -0400 Received: by mail-ee0-f54.google.com with SMTP id d49so2058143eek.41 for ; Wed, 26 Mar 2014 13:02:30 -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=7T6C36k9GdGQtVk7LaIZGSc2Bzxm1vhz8mXAKW295Zw=; b=l02NABtpN8rmRb/ezC5OK9Uv2ku9ODJCWrGKfi5Pku4eiYWusM1MYidq90jxSVfRB6 rV19dhdjOXIZM4dc1h7InstT+6uexRcIa181P9GhxVWLQQ7tT2DCg0CKadIa5vwGYtLz bBt+v/NMJY+7Cr9/wKntRj0d1GtALzqvg+D7CGbIADgLLx6xcPy3hjbzONwCdzhOOom0 o8E4hthjhfz+N3L09RxNkeCaVVOrgJD1SW5nMg0B0veATPErvdxV11iGlBS8nQDq+dCt L4MX6US2O5A1w6oH45GoAxliwYT/t/pYUmXRwiyKEXv+bdkhQmozLqkSlK/Q1xyOviTN +Oug== X-Received: by 10.15.60.199 with SMTP id g47mr77378222eex.37.1395864150041; Wed, 26 Mar 2014 13:02:30 -0700 (PDT) Received: from localhost.localdomain (host179-124-dynamic.6-79-r.retail.telecomitalia.it. [79.6.124.179]) by mx.google.com with ESMTPSA id h47sm41347105eey.13.2014.03.26.13.02.28 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Mar 2014 13:02:29 -0700 (PDT) From: Andrea Merello To: linville@tuxdriver.com Cc: andrea.merello@gmail.com, linux-wireless@vger.kernel.org, Larry.Finger@lwfinger.net, bernhard@schiffner-limbach.de, dan.carpenter@oracle.com Subject: [PATCH 17/20] rtl8180: add WMM parameters configuration for rtl8187se Date: Wed, 26 Mar 2014 21:03:40 +0100 Message-Id: <1395864220-5082-1-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Introduce a new function to configure AC parameters for TX queues on rtl8187se cards, and hook it onto mac80211 in order to enable WMM support. Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl8180/dev.c | 62 +++++++++++++++++++++++++- drivers/net/wireless/rtl818x/rtl8180/rtl8180.h | 1 + 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index eb678da..a14dfd9 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -1090,6 +1090,7 @@ static int rtl8180_start(struct ieee80211_hw *dev) /* CW is not on per-packet basis. * in rtl8185 the CW_VALUE reg is used. + * in rtl8187se the AC param regs are used. */ reg &= ~RTL818X_CW_CONF_PERPACKET_CW; /* retry limit IS on per-packet basis. @@ -1279,6 +1280,49 @@ static int rtl8180_config(struct ieee80211_hw *dev, u32 changed) return 0; } +static void rtl8187se_conf_ac_parm(struct ieee80211_hw *dev, u8 queue) +{ + const struct ieee80211_tx_queue_params *params; + struct rtl8180_priv *priv = dev->priv; + + /* hw value */ + u32 ac_param; + + u8 aifs; + u8 txop; + u8 cw_min, cw_max; + + params = &priv->queue_param[queue]; + + cw_min = fls(params->cw_min); + cw_max = fls(params->cw_max); + + aifs = 10 + params->aifs * priv->slot_time; + + /* TODO: check if txop HW is in us (mult by 32) */ + txop = params->txop; + + ac_param = txop << AC_PARAM_TXOP_LIMIT_SHIFT | + cw_max << AC_PARAM_ECW_MAX_SHIFT | + cw_min << AC_PARAM_ECW_MIN_SHIFT | + aifs << AC_PARAM_AIFS_SHIFT; + + switch (queue) { + case IEEE80211_AC_BK: + rtl818x_iowrite32(priv, &priv->map->AC_BK_PARAM, ac_param); + break; + case IEEE80211_AC_BE: + rtl818x_iowrite32(priv, &priv->map->AC_BE_PARAM, ac_param); + break; + case IEEE80211_AC_VI: + rtl818x_iowrite32(priv, &priv->map->AC_VI_PARAM, ac_param); + break; + case IEEE80211_AC_VO: + rtl818x_iowrite32(priv, &priv->map->AC_VO_PARAM, ac_param); + break; + } +} + static int rtl8180_conf_tx(struct ieee80211_hw *dev, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params) @@ -1293,8 +1337,12 @@ static int rtl8180_conf_tx(struct ieee80211_hw *dev, cw_min = fls(params->cw_min); cw_max = fls(params->cw_max); - rtl818x_iowrite8(priv, &priv->map->CW_VAL, (cw_max << 4) | cw_min); - + if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { + priv->queue_param[queue] = *params; + rtl8187se_conf_ac_parm(dev, queue); + } else + rtl818x_iowrite8(priv, &priv->map->CW_VAL, + (cw_max << 4) | cw_min); return 0; } @@ -1396,6 +1444,16 @@ static void rtl8180_bss_info_changed(struct ieee80211_hw *dev, &priv->rates[0])) - 10; rtl8180_conf_erp(dev, info); + + /* mac80211 supplies aifs_n to driver and calls + * conf_tx callback whether aifs_n changes, NOT + * when aifs changes. + * Aifs should be recalculated if slot changes. + */ + if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { + for (i = 0; i < 4; i++) + rtl8187se_conf_ac_parm(dev, i); + } } if (changed & BSS_CHANGED_BEACON_ENABLED) diff --git a/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h b/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h index 0ef3fc7..291a559 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h +++ b/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h @@ -117,6 +117,7 @@ struct rtl8180_priv { struct ieee80211_channel channels[14]; struct ieee80211_rate rates[12]; struct ieee80211_supported_band band; + struct ieee80211_tx_queue_params queue_param[4]; struct pci_dev *pdev; u32 rx_conf; u8 slot_time;