Linux wireless drivers development
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless <linux-wireless@vger.kernel.org>
Subject: [RFC 2/2] get rid of tx handler function pointers
Date: Thu, 19 Jun 2008 14:21:00 +0200	[thread overview]
Message-ID: <1213878060.8967.4.camel@johannes.berg> (raw)

Just call the functions directly.

Together with the previous patch yields this:

add/remove: 1/11 grow/shrink: 0/2 up/down: 3392/-4108 (-716)
function                                     old     new   delta
invoke_tx_handlers                             -    3392   +3392
ieee80211_tx_handlers                         48       -     -48
ieee80211_tx_h_sequence                      116       -    -116
ieee80211_get_buffered_bc                    620     484    -136
ieee80211_master_start_xmit                 1152    1008    -144
ieee80211_tx_h_stats                         168       -    -168
ieee80211_tx_h_encrypt                       168       -    -168
ieee80211_tx_h_select_key                    256       -    -256
ieee80211_tx_h_calculate_duration            276       -    -276
ieee80211_tx_h_rate_ctrl                     344       -    -344
ieee80211_tx_h_check_assoc                   344       -    -344
ieee80211_tx_h_fragment                      640       -    -640
ieee80211_tx_h_misc                          724       -    -724
ieee80211_tx_h_ps_buf                        744       -    -744

Yeah, I need to clean up things, but hey, I think this is a pretty neat
optimisation. Makes compiling noticably slower though!
---
 net/mac80211/tx.c |   47 +++++++++++++++++------------------------------
 1 file changed, 17 insertions(+), 30 deletions(-)

--- everything.orig/net/mac80211/tx.c	2008-06-19 14:14:48.000000000 +0200
+++ everything/net/mac80211/tx.c	2008-06-19 14:15:06.000000000 +0200
@@ -796,24 +796,6 @@ ieee80211_tx_h_stats(struct ieee80211_tx
 }
 
 
-typedef ieee80211_tx_result (*ieee80211_tx_handler)(struct ieee80211_tx_data *);
-static ieee80211_tx_handler ieee80211_tx_handlers[] =
-{
-	ieee80211_tx_h_check_assoc,
-	ieee80211_tx_h_sequence,
-	ieee80211_tx_h_ps_buf,
-	ieee80211_tx_h_select_key,
-	ieee80211_tx_h_michael_mic_add,
-	ieee80211_tx_h_rate_ctrl,
-	ieee80211_tx_h_misc,
-	ieee80211_tx_h_fragment,
-	/* handlers after fragment must be aware of tx info fragmentation! */
-	ieee80211_tx_h_encrypt,
-	ieee80211_tx_h_calculate_duration,
-	ieee80211_tx_h_stats,
-	NULL
-};
-
 /* actual transmit path */
 
 /*
@@ -1113,29 +1095,34 @@ static int invoke_tx_handlers(struct iee
 {
 	struct ieee80211_local *local = tx->local;
 	struct sk_buff *skb = tx->skb;
-	ieee80211_tx_handler *handler;
 	ieee80211_tx_result res = TX_DROP;
 	int i;
 
-	for (handler = ieee80211_tx_handlers; *handler != NULL; handler++) {
-		res = (*handler)(tx);
-		if (res != TX_CONTINUE)
-			break;
-	}
-
-	if (WARN_ON(tx->skb != skb))
-		res = TX_DROP;
+#define CALL_TXH(txh) if ((res = txh(tx)) != TX_CONTINUE) goto txh_done;
+	CALL_TXH(ieee80211_tx_h_check_assoc)
+	CALL_TXH(ieee80211_tx_h_sequence);
+	CALL_TXH(ieee80211_tx_h_ps_buf);
+	CALL_TXH(ieee80211_tx_h_select_key);
+	CALL_TXH(ieee80211_tx_h_michael_mic_add);
+	CALL_TXH(ieee80211_tx_h_rate_ctrl);
+	CALL_TXH(ieee80211_tx_h_misc);
+	CALL_TXH(ieee80211_tx_h_fragment);
+	/* handlers after fragment must be aware of tx info fragmentation! */
+	CALL_TXH(ieee80211_tx_h_encrypt);
+	CALL_TXH(ieee80211_tx_h_calculate_duration);
+	CALL_TXH(ieee80211_tx_h_stats);
+#undef CALL_TXH
 
+ txh_done:
 	if (unlikely(res == TX_DROP)) {
 		I802_DEBUG_INC(local->tx_handlers_drop);
-		if (skb)
-			dev_kfree_skb(skb);
+		dev_kfree_skb(skb);
 		for (i = 0; i < tx->num_extra_frag; i++)
 			if (tx->extra_frag[i])
 				dev_kfree_skb(tx->extra_frag[i]);
 		kfree(tx->extra_frag);
 		return -1;
-	} else if (unlikely(res == TX_QUEUED)) {
+	} else if (res == TX_QUEUED) {
 		I802_DEBUG_INC(local->tx_handlers_queued);
 		return -1;
 	}



                 reply	other threads:[~2008-06-19 12:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1213878060.8967.4.camel@johannes.berg \
    --to=johannes@sipsolutions.net \
    --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