linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
To: linux-wireless@vger.kernel.org
Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 14/43] iwlwifi: mvm: send large SKBs to the transport
Date: Wed,  2 Mar 2016 09:56:15 +0200	[thread overview]
Message-ID: <1456905404-14435-14-git-send-email-emmanuel.grumbach@intel.com> (raw)
In-Reply-To: <0BA3FCBA62E2DC44AF3030971E174FB32EA50146@hasmsx107.ger.corp.intel.com>

Now that PCIe knows how to create A-MSDUs, use this
capability and prepare SKBs that are large enough to
build an A-MSDU.
Advertise TSO support towards the network stack and
segment the packet with gso_size set to be the maximal
A-MSDU length (after having taken the headers to be added
into account) to make sure that the skb that is passed
down to the transport are not longer than the maximal
A-MSDU allowed.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 148 ++++++++++++++++++++++++++--
 1 file changed, 140 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index 4fbaadd..6f67de5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -65,6 +65,7 @@
 #include <linux/ieee80211.h>
 #include <linux/etherdevice.h>
 #include <linux/tcp.h>
+#include <net/ip.h>
 
 #include "iwl-trans.h"
 #include "iwl-eeprom-parse.h"
@@ -182,7 +183,8 @@ void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
 
 	tx_cmd->tx_flags = cpu_to_le32(tx_flags);
 	/* Total # bytes to be transmitted */
-	tx_cmd->len = cpu_to_le16((u16)skb->len);
+	tx_cmd->len = cpu_to_le16((u16)skb->len +
+		(uintptr_t)info->driver_data[0]);
 	tx_cmd->next_frame_len = 0;
 	tx_cmd->life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE);
 	tx_cmd->sta_id = sta_id;
@@ -372,6 +374,9 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
 			  info->hw_queue != info->control.vif->cab_queue)))
 		return -1;
 
+	/* This holds the amsdu headers length */
+	info->driver_data[0] = (void *)(uintptr_t)0;
+
 	/*
 	 * IWL_MVM_OFFCHANNEL_QUEUE is used for ROC packets that can be used
 	 * in 2 different types of vifs, P2P & STATION. P2P uses the offchannel
@@ -428,33 +433,156 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
 	return 0;
 }
 
-static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb_gso,
+#ifdef CONFIG_INET
+static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
 			  struct ieee80211_sta *sta,
 			  struct sk_buff_head *mpdus_skb)
 {
+	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+	struct ieee80211_hdr *hdr = (void *)skb->data;
+	unsigned int mss = skb_shinfo(skb)->gso_size;
 	struct sk_buff *tmp, *next;
-	char cb[sizeof(skb_gso->cb)];
+	char cb[sizeof(skb->cb)];
+	unsigned int num_subframes, tcp_payload_len, subf_len;
+	bool ipv4 = (skb->protocol == htons(ETH_P_IP));
+	u16 ip_base_id = ipv4 ? ntohs(ip_hdr(skb)->id) : 0;
+	u16 amsdu_add, snap_ip_tcp, pad, i = 0;
+
+	snap_ip_tcp = 8 + skb_transport_header(skb) - skb_network_header(skb) +
+		tcp_hdrlen(skb);
+
+	if (!sta->max_amsdu_len ||
+	    !ieee80211_is_data_qos(hdr->frame_control)) {
+		num_subframes = 1;
+		pad = 0;
+		goto segment;
+	}
+
+	/* TODO: for now, disable A-MSDU inside AMPDU */
+	if (info->flags & IEEE80211_TX_CTL_AMPDU) {
+		num_subframes = 1;
+		pad = 0;
+		goto segment;
+	}
+
+	/* Sub frame header + SNAP + IP header + TCP header + MSS */
+	subf_len = sizeof(struct ethhdr) + snap_ip_tcp + mss;
+	pad = (4 - subf_len) & 0x3;
+
+	/*
+	 * If we have N subframes in the A-MSDU, then the A-MSDU's size is
+	 * N * subf_len + (N - 1) * pad.
+	 */
+	num_subframes = (sta->max_amsdu_len + pad) / (subf_len + pad);
+	if (num_subframes > 1) {
+		u8 *qc = ieee80211_get_qos_ctl((void *)skb->data);
+
+		*qc |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;
+	}
+
+	tcp_payload_len = skb_tail_pointer(skb) - skb_transport_header(skb) -
+		tcp_hdrlen(skb) + skb->data_len;
+
+	/*
+	 * Make sure we have enough TBs for the A-MSDU:
+	 *	2 for each subframe
+	 *	1 more for each fragment
+	 *	1 more for the potential data in the header
+	 */
+	num_subframes =
+		min_t(unsigned int, num_subframes,
+		      (mvm->trans->max_skb_frags - 1 -
+		       skb_shinfo(skb)->nr_frags) / 2);
+
+	/* This skb fits in one single A-MSDU */
+	if (num_subframes * mss >= tcp_payload_len) {
+		/*
+		 * Compute the length of all the data added for the A-MSDU.
+		 * This will be used to compute the length to write in the TX
+		 * command. We have: SNAP + IP + TCP for n -1 subframes and
+		 * ETH header for n subframes. Note that the original skb
+		 * already had one set of SNAP / IP / TCP headers.
+		 */
+		num_subframes = DIV_ROUND_UP(tcp_payload_len, mss);
+		info = IEEE80211_SKB_CB(skb);
+		amsdu_add = num_subframes * sizeof(struct ethhdr) +
+			(num_subframes - 1) * (snap_ip_tcp + pad);
+		/* This holds the amsdu headers length */
+		info->driver_data[0] = (void *)(uintptr_t)amsdu_add;
+
+		__skb_queue_tail(mpdus_skb, skb);
+		return 0;
+	}
 
-	memcpy(cb, skb_gso->cb, sizeof(cb));
-	next = skb_gso_segment(skb_gso, 0);
-	if (IS_ERR(next))
+	/*
+	 * Trick the segmentation function to make it
+	 * create SKBs that can fit into one A-MSDU.
+	 */
+segment:
+	skb_shinfo(skb)->gso_size = num_subframes * mss;
+	memcpy(cb, skb->cb, sizeof(cb));
+
+	next = skb_gso_segment(skb, NETIF_F_CSUM_MASK | NETIF_F_SG);
+	skb_shinfo(skb)->gso_size = mss;
+	if (WARN_ON_ONCE(IS_ERR(next)))
 		return -EINVAL;
 	else if (next)
-		consume_skb(skb_gso);
+		consume_skb(skb);
 
 	while (next) {
 		tmp = next;
 		next = tmp->next;
+
 		memcpy(tmp->cb, cb, sizeof(tmp->cb));
+		/*
+		 * Compute the length of all the data added for the A-MSDU.
+		 * This will be used to compute the length to write in the TX
+		 * command. We have: SNAP + IP + TCP for n -1 subframes and
+		 * ETH header for n subframes.
+		 */
+		tcp_payload_len = skb_tail_pointer(tmp) -
+			skb_transport_header(tmp) -
+			tcp_hdrlen(tmp) + tmp->data_len;
+
+		if (ipv4)
+			ip_hdr(tmp)->id = htons(ip_base_id + i * num_subframes);
+
+		if (tcp_payload_len > mss) {
+			num_subframes = DIV_ROUND_UP(tcp_payload_len, mss);
+			info = IEEE80211_SKB_CB(tmp);
+			amsdu_add = num_subframes * sizeof(struct ethhdr) +
+				(num_subframes - 1) * (snap_ip_tcp + pad);
+			info->driver_data[0] = (void *)(uintptr_t)amsdu_add;
+			skb_shinfo(tmp)->gso_size = mss;
+		} else {
+			u8 *qc = ieee80211_get_qos_ctl((void *)tmp->data);
+
+			if (ipv4)
+				ip_send_check(ip_hdr(tmp));
+			*qc &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT;
+			skb_shinfo(tmp)->gso_size = 0;
+		}
 
 		tmp->prev = NULL;
 		tmp->next = NULL;
 
 		__skb_queue_tail(mpdus_skb, tmp);
+		i++;
 	}
 
 	return 0;
 }
+#else /* CONFIG_INET */
+static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
+			  struct ieee80211_sta *sta,
+			  struct sk_buff_head *mpdus_skb)
+{
+	/* Impossible to get TSO with CONFIG_INET */
+	WARN_ON(1);
+
+	return -1;
+}
+#endif
 
 /*
  * Sets the fields in the Tx cmd that are crypto related
@@ -560,6 +688,7 @@ int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
 		   struct ieee80211_sta *sta)
 {
 	struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
+	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	struct sk_buff_head mpdus_skbs;
 	unsigned int payload_len;
 	int ret;
@@ -570,6 +699,9 @@ int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
 	if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_STATION_COUNT))
 		return -1;
 
+	/* This holds the amsdu headers length */
+	info->driver_data[0] = (void *)(uintptr_t)0;
+
 	if (!skb_is_gso(skb))
 		return iwl_mvm_tx_mpdu(mvm, skb, sta);
 
@@ -589,7 +721,7 @@ int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
 		return ret;
 
 	while (!skb_queue_empty(&mpdus_skbs)) {
-		struct sk_buff *skb = __skb_dequeue(&mpdus_skbs);
+		skb = __skb_dequeue(&mpdus_skbs);
 
 		ret = iwl_mvm_tx_mpdu(mvm, skb, sta);
 		if (ret) {
-- 
2.5.0


  parent reply	other threads:[~2016-03-02  7:57 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02  7:51 pull request: iwlwifi-next 2016-03-02 Grumbach, Emmanuel
2016-03-02  7:56 ` [PATCH 01/43] iwlwifi: mvm: add CT-KILL notification Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 02/43] iwlwifi: mvm: add registration to thermal zone Emmanuel Grumbach
2016-03-04 18:39   ` Bjørn Mork
2016-03-04 18:53     ` Bjørn Mork
2016-03-04 19:57       ` Coelho, Luciano
2016-03-04 20:22         ` Bjørn Mork
2016-03-04 20:30           ` Coelho, Luciano
2016-03-04 19:52     ` Coelho, Luciano
2016-03-02  7:56 ` [PATCH 03/43] iwlwifi: mvm: add registration to cooling device Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 04/43] iwlwifi: mvm: set the correct descriptor size for tracing Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 05/43] iwlwifi: mvm: fix RSS key sizing Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 06/43] iwlwifi: mvm: handle pass all scan reporting Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 07/43] iwlwifi: mvm: rs: fix a theoretical access to uninitialized array elements Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 08/43] iwlwifi: mvm: bump firmware API to 21 Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 09/43] iwlwifi: pcie: aggregate Flow Handler configuration writes Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 10/43] iwlwifi: pcie: Add new configuration to enable MSIX Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 11/43] iwlwifi: pcie: fix identation in trans.c Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 12/43] iwlwifi: mvm: enable VHT MU-MIMO for supported hardware Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 13/43] iwlwifi: mvm: update firmware of VHT MU-MIMO groups status on restart Emmanuel Grumbach
2016-03-02  7:56 ` Emmanuel Grumbach [this message]
2016-03-02  7:56 ` [PATCH 15/43] iwlwifi: mvm: add Tx A-MSDU inside A-MPDU Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 16/43] iwlwifi: mvm: allow to limit the A-MSDU from debugfs Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 17/43] iwlwifi: mvm: don't enable A-MSDU when the rates are too low Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 18/43] iwlwifi: mvm: don't send an A-MSDU that is larger than the TXF Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 19/43] iwlwifi: support tracing wide commands Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 20/43] iwlwifi: mvm: update rx_status with mactime flag Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 21/43] iwlwifi: mvm: support filtered frames notification Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 22/43] iwlwifi: pcie: configure more RFH settings Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 23/43] iwlwifi: pcie: add pm_prepare and pm_complete ops Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 24/43] iwlwifi: pcie: prevent skbs shadowing in iwl_trans_pcie_reclaim Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 25/43] iwlwifi: mvm: add duplicate packet detection per rx queue Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 26/43] iwlwifi: mvm: add RSS queues notification infrastructure Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 27/43] iwlwifi: mvm: remove unused field in iwl_mvm_tid_data Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 28/43] iwlwifi: mvm: support VHT MU-MIMO notification Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 29/43] iwlwifi: mvm: various trivial cleanups Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 30/43] iwlwifi: mvm: Set global RRM capability Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 31/43] iwlwifi: mvm: forbid U-APSD for P2P Client if the firmware doesn't support it Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 32/43] iwlwifi: mvm: Send power command on BSS_CHANGED_BEACON_INFO if needed Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 33/43] iwlwifi: mvm: take care of padded packets Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 34/43] iwlwifi: mvm: kill iwl_mvm_enable_agg_txq Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 35/43] iwlwifi: mvm: Disable beacon storing in D3 when WOWLAN configured Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 36/43] iwlwifi: support ucode with d0 unified image - regular and usniffer Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 37/43] iwlwifi: mvm: update ucode status before stopping device Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 38/43] iwlwifi: pcie: detect and workaround invalid write ptr behavior Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 39/43] iwlwifi: mvm: disable DQA support Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 40/43] iwlwifi: mvm: only release the trans ref if d0i3 is supported in fw Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 41/43] iwlwifi: add disable_11ac module param Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 42/43] iwlwifi: mvm: take the transport ref back when leaving Emmanuel Grumbach
2016-03-02  7:56 ` [PATCH 43/43] iwlwifi: mvm: support sw queue start/stop from mvm Emmanuel Grumbach
2016-03-07 13:50 ` pull request: iwlwifi-next 2016-03-02 Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456905404-14435-14-git-send-email-emmanuel.grumbach@intel.com \
    --to=emmanuel.grumbach@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).