All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: ath9k-devel@lists.ath9k.org
Subject: [ath9k-devel] [PATCH 1/3] ath9k: Decrease skb size to fit into one page.
Date: Fri, 07 Jan 2011 14:46:42 -0800	[thread overview]
Message-ID: <4D2797D2.6000002@candelatech.com> (raw)
In-Reply-To: <1294439171.2709.6.camel@edumazet-laptop>

On 01/07/2011 02:26 PM, Eric Dumazet wrote:
> Le vendredi 07 janvier 2011 ? 14:20 -0800, Ben Greear a ?crit :
>> On 0
>>> Using skb_copy() is wrong then, since it makes a copy (order-1
>>> allocations)
>>>
>>> It should use :
>>>    skb_alloc( actual_size_of_frame  not the 3840 thing ...)
>>>    copy(data)
>>
>> We need the extra stuff copied too I think (like skb->cb).
>>
>> If you could provide a bit more complete example code, I'll be happy
>> to test it...
>
> take a random drivers/net using copybreak ... say ... tg3.c
>
> lines 4785
>
> len = length_of_the_current_frame
> copy_skb = netdev_alloc_skb(...,  len);
> // allocates exact required size not a byte more....
> ...
> skb_copy_from_linear_data(skb, copy_skb->data, len);
> ...
> skb_put(skb, len);
> ...

That seems fine for drivers, but I'm guessing something different
would be needed in the mac80211/rx.c code:

I figure doing the fix here might be a nice quick fix,
and would help with all funky drivers.  Later, can fix the
ath9k to do the skb copying as soon as DMA is done?

/*
  * This function returns whether or not the SKB
  * was destined for RX processing or not, which,
  * if consume is true, is equivalent to whether
  * or not the skb was consumed.
  */
static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
					    struct sk_buff *skb, bool consume)
{
	struct ieee80211_local *local = rx->local;
	struct ieee80211_sub_if_data *sdata = rx->sdata;
	struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
	struct ieee80211_hdr *hdr = (void *)skb->data;
	int prepares;

	rx->skb = skb;
	status->rx_flags |= IEEE80211_RX_RA_MATCH;
	prepares = prepare_for_handlers(rx, hdr);

	if (!prepares)
		return false;

	if (status->flag & RX_FLAG_MMIC_ERROR) {
		if (status->rx_flags & IEEE80211_RX_RA_MATCH)
			ieee80211_rx_michael_mic_report(hdr, rx);
		return false;
	}

	if (!consume) {
		skb = skb_copy(skb, GFP_ATOMIC);
		if (!skb) {
			if (net_ratelimit()) {
				printk("failed skb_copy, skb->len: %i\n", skb->len);
				wiphy_debug(local->hw.wiphy,
					"failed to copy skb for %s\n",
					sdata->name);
			}
			return true;
		}

		rx->skb = skb;
	}

	ieee80211_invoke_rx_handlers(rx);
	return true;
}


Thanks,
Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

WARNING: multiple messages have this Message-ID (diff)
From: Ben Greear <greearb@candelatech.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "Luis R. Rodriguez" <lrodriguez@atheros.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	"ath9k-devel@venema.h4ckr.net" <ath9k-devel@venema.h4ckr.net>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: Re: [ath9k-devel] [PATCH 1/3] ath9k: Decrease skb size to fit into one page.
Date: Fri, 07 Jan 2011 14:46:42 -0800	[thread overview]
Message-ID: <4D2797D2.6000002@candelatech.com> (raw)
In-Reply-To: <1294439171.2709.6.camel@edumazet-laptop>

On 01/07/2011 02:26 PM, Eric Dumazet wrote:
> Le vendredi 07 janvier 2011 à 14:20 -0800, Ben Greear a écrit :
>> On 0
>>> Using skb_copy() is wrong then, since it makes a copy (order-1
>>> allocations)
>>>
>>> It should use :
>>>    skb_alloc( actual_size_of_frame  not the 3840 thing ...)
>>>    copy(data)
>>
>> We need the extra stuff copied too I think (like skb->cb).
>>
>> If you could provide a bit more complete example code, I'll be happy
>> to test it...
>
> take a random drivers/net using copybreak ... say ... tg3.c
>
> lines 4785
>
> len = length_of_the_current_frame
> copy_skb = netdev_alloc_skb(...,  len);
> // allocates exact required size not a byte more....
> ...
> skb_copy_from_linear_data(skb, copy_skb->data, len);
> ...
> skb_put(skb, len);
> ...

That seems fine for drivers, but I'm guessing something different
would be needed in the mac80211/rx.c code:

I figure doing the fix here might be a nice quick fix,
and would help with all funky drivers.  Later, can fix the
ath9k to do the skb copying as soon as DMA is done?

/*
  * This function returns whether or not the SKB
  * was destined for RX processing or not, which,
  * if consume is true, is equivalent to whether
  * or not the skb was consumed.
  */
static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
					    struct sk_buff *skb, bool consume)
{
	struct ieee80211_local *local = rx->local;
	struct ieee80211_sub_if_data *sdata = rx->sdata;
	struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
	struct ieee80211_hdr *hdr = (void *)skb->data;
	int prepares;

	rx->skb = skb;
	status->rx_flags |= IEEE80211_RX_RA_MATCH;
	prepares = prepare_for_handlers(rx, hdr);

	if (!prepares)
		return false;

	if (status->flag & RX_FLAG_MMIC_ERROR) {
		if (status->rx_flags & IEEE80211_RX_RA_MATCH)
			ieee80211_rx_michael_mic_report(hdr, rx);
		return false;
	}

	if (!consume) {
		skb = skb_copy(skb, GFP_ATOMIC);
		if (!skb) {
			if (net_ratelimit()) {
				printk("failed skb_copy, skb->len: %i\n", skb->len);
				wiphy_debug(local->hw.wiphy,
					"failed to copy skb for %s\n",
					sdata->name);
			}
			return true;
		}

		rx->skb = skb;
	}

	ieee80211_invoke_rx_handlers(rx);
	return true;
}


Thanks,
Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


  reply	other threads:[~2011-01-07 22:46 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-07  0:46 [ath9k-devel] [PATCH 1/3] ath9k: Decrease skb size to fit into one page greearb at candelatech.com
2011-01-07  0:46 ` greearb
2011-01-07  0:46 ` [ath9k-devel] [PATCH 2/3] ath9k: Re-start xmit logic in xmit watchdog timer greearb at candelatech.com
2011-01-07  0:46   ` greearb
2011-01-07  6:51   ` [ath9k-devel] " Vasanthakumar Thiagarajan
2011-01-07  6:51     ` Vasanthakumar Thiagarajan
2011-01-07  7:16     ` [ath9k-devel] " Ben Greear
2011-01-07  7:16       ` Ben Greear
2011-01-07 15:11     ` [ath9k-devel] " Peter Stuge
2011-01-07 15:11       ` Peter Stuge
2011-01-07 15:19       ` Ben Greear
2011-01-07 15:19         ` Ben Greear
2011-01-07 15:20       ` Vasanthakumar Thiagarajan
2011-01-07 15:20         ` Vasanthakumar Thiagarajan
2011-01-07  0:46 ` [ath9k-devel] [PATCH 3/3] ath9k: Keep track of stations for debugfs greearb at candelatech.com
2011-01-07  0:46   ` greearb
2011-01-07  2:30   ` [ath9k-devel] " Luis R. Rodriguez
2011-01-07  2:30     ` Luis R. Rodriguez
2011-01-07  2:45     ` Ben Greear
2011-01-07  2:45       ` Ben Greear
2011-01-07  2:49       ` Luis R. Rodriguez
2011-01-07  2:49         ` Luis R. Rodriguez
2011-01-07  3:17         ` Ben Greear
2011-01-07  3:17           ` Ben Greear
2011-01-07 15:36           ` Peter Stuge
2011-01-07 15:36             ` Peter Stuge
2011-01-07 15:52             ` Ben Greear
2011-01-07 15:52               ` Ben Greear
2011-01-07 20:01             ` Luis R. Rodriguez
2011-01-07 20:01               ` Luis R. Rodriguez
2011-01-07 20:25               ` Luis R. Rodriguez
2011-01-07 20:25                 ` Luis R. Rodriguez
2011-01-07 20:30                 ` Luis R. Rodriguez
2011-01-07 20:30                   ` Luis R. Rodriguez
2011-01-07 20:59               ` [ath9k-devel] ath9k debugging Peter Stuge
2011-01-07 19:46           ` [ath9k-devel] [PATCH 3/3] ath9k: Keep track of stations for debugfs Luis R. Rodriguez
2011-01-07 19:46             ` Luis R. Rodriguez
2011-01-07  2:45   ` Felix Fietkau
2011-01-07  2:45     ` Felix Fietkau
2011-01-07  2:48     ` Ben Greear
2011-01-07  2:48       ` Ben Greear
2011-01-07  0:57 ` [ath9k-devel] [PATCH 1/3] ath9k: Decrease skb size to fit into one page Luis R. Rodriguez
2011-01-07  0:57   ` Luis R. Rodriguez
2011-01-07  1:03   ` Ben Greear
2011-01-07  1:03     ` Ben Greear
2011-01-07  1:04 ` Christian Lamparter
2011-01-07  1:04   ` Christian Lamparter
2011-01-07  1:23   ` [ath9k-devel] " Eric Dumazet
2011-01-07  1:23     ` Eric Dumazet
2011-01-07  1:57     ` [ath9k-devel] " Luis R. Rodriguez
2011-01-07  1:57       ` Luis R. Rodriguez
2011-01-07  2:07       ` [ath9k-devel] " Eric Dumazet
2011-01-07  2:07         ` Eric Dumazet
2011-01-07  2:13         ` Luis R. Rodriguez
2011-01-07  2:24           ` [ath9k-devel] " Eric Dumazet
2011-01-07  2:24             ` Eric Dumazet
2011-01-07  2:33             ` [ath9k-devel] " Eric Dumazet
2011-01-07  2:33               ` Eric Dumazet
2011-01-07 10:58 ` [ath9k-devel] " Johannes Berg
2011-01-07 10:58   ` Johannes Berg
2011-01-07 18:34   ` [ath9k-devel] " Ben Greear
2011-01-07 18:34     ` Ben Greear
2011-01-07 20:09     ` [ath9k-devel] " Luis R. Rodriguez
2011-01-07 20:09       ` Luis R. Rodriguez
2011-01-07 20:26       ` Eric Dumazet
2011-01-07 20:26         ` Eric Dumazet
2011-01-07 22:20         ` Ben Greear
2011-01-07 22:20           ` Ben Greear
2011-01-07 22:26           ` Eric Dumazet
2011-01-07 22:26             ` Eric Dumazet
2011-01-07 22:46             ` Ben Greear [this message]
2011-01-07 22:46               ` Ben Greear
2011-01-09  9:34               ` Johannes Berg
2011-01-09  9:34                 ` Johannes Berg

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=4D2797D2.6000002@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=ath9k-devel@lists.ath9k.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.