X-Account-Key: account11
X-UIDL: GmailId12de6373b4e61446
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:                                                                                 
Delivered-To: larry.finger@gmail.com
Received: by 10.103.169.7 with SMTP id w7cs7277muo;
        Wed, 2 Feb 2011 03:52:17 -0800 (PST)
Received: by 10.229.189.199 with SMTP id df7mr8062848qcb.227.1296647536620;
        Wed, 02 Feb 2011 03:52:16 -0800 (PST)
Return-Path: <zajec5@gmail.com>
Received: from mail.networksolutionsemail.com (mail.networksolutionsemail.com [205.178.146.50])
        by mx.google.com with SMTP id p13si48933014qcu.189.2011.02.02.03.52.15;
        Wed, 02 Feb 2011 03:52:15 -0800 (PST)
Received-SPF: neutral (google.com: 205.178.146.50 is neither permitted nor denied by domain of zajec5@gmail.com) client-ip=205.178.146.50;
Authentication-Results: mx.google.com; spf=neutral (google.com: 205.178.146.50 is neither permitted nor denied by domain of zajec5@gmail.com) smtp.mail=zajec5@gmail.com; dkim=pass (test mode) header.i=@gmail.com
Received: (qmail 17498 invoked by uid 78); 2 Feb 2011 11:52:15 -0000
Delivered-To: lwfinger.net-Larry.Finger@lwfinger.net
Received: (qmail 17495 invoked by uid 78); 2 Feb 2011 11:52:15 -0000
Received: from unknown (HELO cloudmark1) (10.49.16.94)
  by 0 with SMTP; 2 Feb 2011 11:52:15 -0000
Return-Path: <zajec5@gmail.com>
Received: from [209.85.215.48] ([209.85.215.48:61703] helo=mail-ew0-f48.google.com)
	by cm-mr19 (envelope-from <zajec5@gmail.com>)
	(ecelerity 2.2.2.41 r(31179/31189)) with ESMTP
	id 64/DE-25842-E65494D4; Wed, 02 Feb 2011 06:52:15 -0500
Received: by ewy20 with SMTP id 20so3616518ewy.35
        for <Larry.Finger@lwfinger.net>; Wed, 02 Feb 2011 03:52:14 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer
         :mime-version:content-type:content-transfer-encoding;
        bh=WlGuxCBb9Cb6cChjST/7DK0GTALNFMsbgia7QmPFnRg=;
        b=F/HaFVwtYxuXcmNvhuNSOZrwoUHtdC+KPuFLlIcBilJoQfzdCFo/E9T+EjXl6Tgl2Y
         FO5+/DKW0vukOiGpcvuAuBIpJnDFHjEmTskvd/1uvNQ2qlOAYFJEeVlj7GHbTVMd3Tod
         t10WDVFF1vEjKoHyq5K/ACukKnnsPXinqorSU=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer:mime-version
         :content-type:content-transfer-encoding;
        b=cp5ylm5rL0YLz5yAPWu31HBzsDGAmlkZyp+h809nY8qSAfGfIe3ECkie3O9W7ivxVU
         j+SN6RCi9AfSZPtwJv6Zr2QSNwkZP6uBv7On6WEsV7eKVOQra8e4Bs71iqKQYzp0cAYW
         LtAP8DPDWJSewnmocGR3VS7dxEU9srwGeMNz8=
Received: by 10.213.27.203 with SMTP id j11mr7009304ebc.51.1296647533879;
        Wed, 02 Feb 2011 03:52:13 -0800 (PST)
Received: from localhost.localdomain (c10-97.icpnet.pl [62.21.10.97])
        by mx.google.com with ESMTPS id x54sm18138902eeh.11.2011.02.02.03.52.12
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Wed, 02 Feb 2011 03:52:13 -0800 (PST)
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
Subject: [PRIV][RFT][PATCH] b43: tx: set control words 1 for N-PHY
Date: Wed,  2 Feb 2011 12:56:43 +0100
Message-Id: <1296647804-2272-1-git-send-email-zajec5@gmail.com>
X-Mailer: git-send-email 1.7.3.4
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes transmission on OFDM rates for N-PHY.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/net/wireless/b43/xmit.c |   73 +++++++++++++++++++++++++++++++++++++++
 drivers/net/wireless/b43/xmit.h |    6 +++
 2 files changed, 79 insertions(+), 0 deletions(-)

Index: wireless-testing/drivers/net/wireless/b43/xmit.c
===================================================================
--- wireless-testing.orig/drivers/net/wireless/b43/xmit.c
+++ wireless-testing/drivers/net/wireless/b43/xmit.c
@@ -32,6 +32,36 @@
 #include "dma.h"
 #include "pio.h"
 
+const struct b43_tx_legacy_rate_phy_ctl_entry b43_tx_legacy_rate_phy_ctl[] = {
+	{ B43_CCK_RATE_1MB,	0x0,			0x0 },
+	{ B43_CCK_RATE_2MB,	0x0,			0x1 },
+	{ B43_CCK_RATE_5MB,	0x0,			0x2 },
+	{ B43_CCK_RATE_11MB,	0x0,			0x3 },
+	{ B43_OFDM_RATE_6MB,	B43_TXH_PHY1_CRATE_1_2,	B43_TXH_PHY1_MODUL_BPSK },
+	{ B43_OFDM_RATE_9MB,	B43_TXH_PHY1_CRATE_3_4,	B43_TXH_PHY1_MODUL_BPSK },
+	{ B43_OFDM_RATE_12MB,	B43_TXH_PHY1_CRATE_1_2,	B43_TXH_PHY1_MODUL_QPSK },
+	{ B43_OFDM_RATE_18MB,	B43_TXH_PHY1_CRATE_3_4,	B43_TXH_PHY1_MODUL_QPSK },
+	{ B43_OFDM_RATE_24MB,	B43_TXH_PHY1_CRATE_1_2,	B43_TXH_PHY1_MODUL_QAM16 },
+	{ B43_OFDM_RATE_36MB,	B43_TXH_PHY1_CRATE_3_4,	B43_TXH_PHY1_MODUL_QAM16 },
+	{ B43_OFDM_RATE_48MB,	B43_TXH_PHY1_CRATE_2_3,	B43_TXH_PHY1_MODUL_QAM64 },
+	{ B43_OFDM_RATE_54MB,	B43_TXH_PHY1_CRATE_3_4,	B43_TXH_PHY1_MODUL_QAM64 },
+};
+
+const struct b43_tx_legacy_rate_phy_ctl_entry *
+b43_tx_legacy_rate_phy_ctl_ent(u8 bitrate)
+{
+	const struct b43_tx_legacy_rate_phy_ctl_entry *e;
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(b43_tx_legacy_rate_phy_ctl); i++) {
+		e = &(b43_tx_legacy_rate_phy_ctl[i]);
+		if (e->bitrate == bitrate)
+			return e;
+	}
+
+	B43_WARN_ON(1);
+	return NULL;
+}
 
 /* Extract the bitrate index out of a CCK PLCP header. */
 static int b43_plcp_get_bitrate_idx_cck(struct b43_plcp_hdr6 *plcp)
@@ -145,6 +175,34 @@ void b43_generate_plcp_hdr(struct b43_pl
 	}
 }
 
+static u16 b43_generate_tx_phy_ctl1(struct b43_wldev *dev, u8 bitrate)
+{
+	const struct b43_phy *phy = &dev->phy;
+	const struct b43_tx_legacy_rate_phy_ctl_entry *e;
+	u16 control = 0;
+	u16 bw;
+
+	if (phy->type == B43_PHYTYPE_LP)
+		bw = B43_TXH_PHY1_BW_20;
+	else /* FIXME */
+		bw = B43_TXH_PHY1_BW_20;
+
+	if (0) { /* FIXME: MIMO */
+	} else if (b43_is_cck_rate(bitrate) && phy->type != B43_PHYTYPE_LP) {
+		control = bw;
+	} else {
+		control = bw;
+		e = b43_tx_legacy_rate_phy_ctl_ent(bitrate);
+		if (e) {
+			control |= e->coding_rate;
+			control |= e->modulation;
+		}
+		control |= B43_TXH_PHY1_MODE_SISO;
+	}
+
+	return control;
+}
+
 static u8 b43_calc_fallback_rate(u8 bitrate)
 {
 	switch (bitrate) {
@@ -437,6 +495,14 @@ int b43_generate_txhdr(struct b43_wldev
 			extra_ft |= B43_TXH_EFT_RTSFB_OFDM;
 		else
 			extra_ft |= B43_TXH_EFT_RTSFB_CCK;
+
+		if (rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS &&
+		    phy->type == B43_PHYTYPE_N) {
+			txhdr->phy_ctl1_rts = cpu_to_le16(
+				b43_generate_tx_phy_ctl1(dev, rts_rate));
+			txhdr->phy_ctl1_rts_fb = cpu_to_le16(
+				b43_generate_tx_phy_ctl1(dev, rts_rate_fb));
+		}
 	}
 
 	/* Magic cookie */
@@ -445,6 +511,13 @@ int b43_generate_txhdr(struct b43_wldev
 	else
 		txhdr->new_format.cookie = cpu_to_le16(cookie);
 
+	if (phy->type == B43_PHYTYPE_N) {
+		txhdr->phy_ctl1 =
+			cpu_to_le16(b43_generate_tx_phy_ctl1(dev, rate));
+		txhdr->phy_ctl1_fb =
+			cpu_to_le16(b43_generate_tx_phy_ctl1(dev, rate_fb));
+	}
+
 	/* Apply the bitfields */
 	txhdr->mac_ctl = cpu_to_le32(mac_ctl);
 	txhdr->phy_ctl = cpu_to_le16(phy_ctl);
Index: wireless-testing/drivers/net/wireless/b43/xmit.h
===================================================================
--- wireless-testing.orig/drivers/net/wireless/b43/xmit.h
+++ wireless-testing/drivers/net/wireless/b43/xmit.h
@@ -73,6 +73,12 @@ struct b43_txhdr {
 	} __packed;
 } __packed;
 
+struct b43_tx_legacy_rate_phy_ctl_entry {
+	u8 bitrate;
+	u16 coding_rate;
+	u16 modulation;
+};
+
 /* MAC TX control */
 #define B43_TXH_MAC_USEFBR		0x10000000 /* Use fallback rate for this AMPDU */
 #define B43_TXH_MAC_KEYIDX		0x0FF00000 /* Security key index */