netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: dborkman@redhat.com
Cc: mathias.kretschmer@fokus.fraunhofer.de, netdev@vger.kernel.org,
	brouer@redhat.com
Subject: Re: [PATCH net] packet: check for ndo_select_queue during queue selection
Date: Fri, 14 Feb 2014 13:48:43 -0500 (EST)	[thread overview]
Message-ID: <20140214.134843.1912150240271947468.davem@davemloft.net> (raw)
In-Reply-To: <52FDEE22.9010503@redhat.com>

From: Daniel Borkmann <dborkman@redhat.com>
Date: Fri, 14 Feb 2014 11:21:22 +0100

> The other two possibilities I see is 1) to check for
> dev->ieee80211_ptr on setsockopt(2) and bind(2) (which could happen
> _after_ the option was set) and just disallow that option for those
> cases (doesn't make sense to use it for ieee80211 devs anyway, and
> they seem to be the only special-cased users), or, preferably 2) to
> just leave the code as it currently is, that is, similar to pktgen.

Don't sell yourself so short, think out of the box:

typedef u16 (*select_queue_fallback_t)(struct net_device *dev, struct sk_buff *skb);
 ...
	u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb,
				void *accel_priv, select_queue_fallback_t fallback);

And your packet code would do something like:

static u16 __packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb)
{
	return (u16) raw_smp_processor_id() % dev->real_num_tx_queues;
}

static u16 packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb)
{
	u16 queue_index;

	if (ops->ndo_select_queue)
		queue_index = ops->ndo_select_queue(dev, skb, NULL, __packet_pick_tx_queue);
	else
		queue_index = __packet_pick_tx_queue(dev, skb);
	skb_set_queue_mapping(skb, queue_index);
}

Then you go through the existing ndo_select_queue implementations, you'll notice
a lot of them are of the form:

	if (special_stuff)
		queue_index = whatever;
	else
		queue_index = __netdev_pick_tx(...);

replace that __netdev_pick_tx call with one to "fallback".

  reply	other threads:[~2014-02-14 18:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13 17:18 [PATCH net] packet: check for ndo_select_queue during queue selection Daniel Borkmann
2014-02-14  5:40 ` David Miller
2014-02-14 10:21   ` Daniel Borkmann
2014-02-14 18:48     ` David Miller [this message]
2014-02-14 21:03       ` Daniel Borkmann

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=20140214.134843.1912150240271947468.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=brouer@redhat.com \
    --cc=dborkman@redhat.com \
    --cc=mathias.kretschmer@fokus.fraunhofer.de \
    --cc=netdev@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).