From patchwork Wed Mar 26 20:00:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 3895041 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 2D5049F2E8 for ; Wed, 26 Mar 2014 19:59:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1ECF920221 for ; Wed, 26 Mar 2014 19:59:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 15D382021F for ; Wed, 26 Mar 2014 19:59:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756250AbaCZT7t (ORCPT ); Wed, 26 Mar 2014 15:59:49 -0400 Received: from mail-ee0-f49.google.com ([74.125.83.49]:36208 "EHLO mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756143AbaCZT7s (ORCPT ); Wed, 26 Mar 2014 15:59:48 -0400 Received: by mail-ee0-f49.google.com with SMTP id c41so2070560eek.8 for ; Wed, 26 Mar 2014 12:59:47 -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=MsbYZzqYDDi0zcFKVMRoGZi1jls4nq5UN04XsK176V8=; b=JKE66lHEVylmGgGFE9AX0wF8N6qLOt13VtpKKk69fHP24U9Sl6xKyrQQp6alnW9fqS BLG9ByDq25jEkjtyiQm1v3k54DOl4/Nv+R4Gm3oL2WmRGDfM3VJpMnjssLeswFliC+Y2 rtRoNHrDrJI9OBjTGtINh3402aHGlJc5myEJyw033sdwEEzaVJBUMMTocQ3BKd4KHxUB 1Vejl90ACX+MejPmbBgUzcQDVqXmpjnRWOcZJmYLaLjy326fY0aIAwy3T3ca9L9mlEYI Tg+hAgV5vKMoLF1nSHyki6o+SsaUs/NhVuai7v7fPmmHWvdeEuwiQrPMcEk0J7RUhgcU YRig== X-Received: by 10.14.216.2 with SMTP id f2mr4865935eep.83.1395863987093; Wed, 26 Mar 2014 12:59:47 -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 p8sm49258286eef.26.2014.03.26.12.59.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Mar 2014 12:59:46 -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 09/20] rtl8180: add TX queue mapping and support for rtl8187se Date: Wed, 26 Mar 2014 21:00:57 +0100 Message-Id: <1395864057-4702-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 This patch adds tx queue mapping for rtl8187se and a long comment block about their usages. It adapts the TX function to use that map and it sets properly the TX descriptor rtl8187se-only fields Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl8180/dev.c | 84 ++++++++++++++++++++++++-- drivers/net/wireless/rtl818x/rtl8180/rtl8180.h | 10 ++- 2 files changed, 88 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index cce972d..eb86ede 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -85,6 +85,52 @@ static const struct ieee80211_channel rtl818x_channels[] = { { .center_freq = 2484 }, }; +/* Queues for rtl8187se card + * + * name | reg | queue + * BC | 7 | 6 + * MG | 1 | 0 + * HI | 6 | 1 + * VO | 5 | 2 + * VI | 4 | 3 + * BE | 3 | 4 + * BK | 2 | 5 + * + * The complete map for DMA kick reg using use all queue is: + * static const int rtl8187se_queues_map[RTL8187SE_NR_TX_QUEUES] = + * {1, 6, 5, 4, 3, 2, 7}; + * + * .. but.. Because for mac80211 4 queues are enough for QoS we use this + * + * name | reg | queue + * BC | 7 | 4 <- currently not used yet + * MG | 1 | x <- Not used + * HI | 6 | x <- Not used + * VO | 5 | 0 <- used + * VI | 4 | 1 <- used + * BE | 3 | 2 <- used + * BK | 2 | 3 <- used + * + * Beacon queue could be used, but this is not finished yet. + * + * I thougth about using the other two queues but I decided not to do this: + * + * - I'm unsure whether the mac80211 will ever try to use more than 4 queues + * by itself. + * + * - I could route MGMT frames (currently sent over VO queue) to the MGMT + * queue but since mac80211 will do not know about it, I will probably gain + * some HW priority whenever the VO queue is not empty, but this gain is + * limited by the fact that I had to stop the mac80211 queue whenever one of + * the VO or MGMT queues is full, stopping also submitting of MGMT frame + * to the driver. + * + * - I don't know how to set in the HW the contention window params for MGMT + * and HI-prio queues. + */ + +static const int rtl8187se_queues_map[RTL8187SE_NR_TX_QUEUES] = {5, 4, 3, 2, 7}; + /* Queues for rtl8180/rtl8185 cards * * name | reg | prio @@ -358,6 +404,8 @@ static void rtl8180_tx(struct ieee80211_hw *dev, u8 rc_flags; u16 plcp_len = 0; __le16 rts_duration = 0; + /* do arithmetic and then convert to le16 */ + u16 frame_duration = 0; prio = skb_get_queue_mapping(skb); ring = &priv->tx_ring[prio]; @@ -369,7 +417,6 @@ static void rtl8180_tx(struct ieee80211_hw *dev, kfree_skb(skb); dev_err(&priv->pdev->dev, "TX DMA mapping error\n"); return; - } tx_flags = RTL818X_TX_DESC_FLAG_OWN | RTL818X_TX_DESC_FLAG_FS | @@ -405,6 +452,18 @@ static void rtl8180_tx(struct ieee80211_hw *dev, plcp_len |= 1 << 15; } + if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { + __le16 duration; + /* SIFS time (required by HW) is already included by + * ieee80211_generic_frame_duration + */ + duration = ieee80211_generic_frame_duration(dev, priv->vif, + IEEE80211_BAND_2GHZ, skb->len, + ieee80211_get_tx_rate(dev, info)); + + frame_duration = priv->ack_time + le16_to_cpu(duration); + } + spin_lock_irqsave(&priv->lock, flags); if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { @@ -417,10 +476,19 @@ static void rtl8180_tx(struct ieee80211_hw *dev, idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; entry = &ring->desc[idx]; + if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { + entry->frame_duration = cpu_to_le16(frame_duration); + entry->frame_len_se = cpu_to_le16(skb->len); + + /* tpc polarity */ + entry->flags3 = cpu_to_le16(1<<4); + } else + entry->frame_len = cpu_to_le32(skb->len); + entry->rts_duration = rts_duration; entry->plcp_len = cpu_to_le16(plcp_len); entry->tx_buf = cpu_to_le32(mapping); - entry->frame_len = cpu_to_le32(skb->len); + entry->flags2 = info->control.rates[1].idx >= 0 ? ieee80211_get_alt_retry_rate(dev, info, 0)->bitrate << 4 : 0; entry->retry_limit = info->control.rates[0].count; @@ -442,11 +510,17 @@ static void rtl8180_tx(struct ieee80211_hw *dev, spin_unlock_irqrestore(&priv->lock, flags); - hw_prio = rtl8180_queues_map[prio]; - - rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, + if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { + /* just poll: rings are stopped with TPPollStop reg */ + hw_prio = rtl8187se_queues_map[prio]; + rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, + (1 << hw_prio)); + } else { + hw_prio = rtl8180_queues_map[prio]; + rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, (1 << hw_prio) | /* ring to poll */ (1<<1) | (1<<2));/* stopped rings */ + } } void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam) diff --git a/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h b/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h index d866cc6..d64e75d 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h +++ b/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h @@ -29,6 +29,14 @@ */ #define RTL8180_NR_TX_QUEUES 2 +/* rtl8187SE have 6 queues + beacon queues + * mac80211 can use 4 QoS data queue, + beacon = 5 tot + */ +#define RTL8187SE_NR_TX_QUEUES 5 + +/* for array static allocation, it is the max of above */ +#define RTL818X_NR_TX_QUEUES 5 + struct rtl8180_tx_desc { __le32 flags; __le16 rts_duration; @@ -105,7 +113,7 @@ struct rtl8180_priv { dma_addr_t rx_ring_dma; unsigned int rx_idx; struct sk_buff *rx_buf[32]; - struct rtl8180_tx_ring tx_ring[RTL8180_NR_TX_QUEUES]; + struct rtl8180_tx_ring tx_ring[RTL818X_NR_TX_QUEUES]; struct ieee80211_channel channels[14]; struct ieee80211_rate rates[12]; struct ieee80211_supported_band band;