linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Ivan Bezyazychnyy <ivan.bezyazychnyy@gmail.com>
Cc: linux-wireless@vger.kernel.org,
	Mike Krinkin <krinkin.m.u@gmail.com>,
	Max Filippov <jcmvbkbc@gmail.com>,
	Marco Porsch <marco.porsch@etit.tu-chemnitz.de>
Subject: Re: [RFC v2 2/8] mac80211: mesh power mode indication in QoS frames
Date: Thu, 24 Nov 2011 19:23:17 +0100	[thread overview]
Message-ID: <1322158997.5366.29.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <1321886416-12597-3-git-send-email-ivan.bezyazychnyy@gmail.com> (sfid-20111121_154146_911104_5CCCA53C)

On Mon, 2011-11-21 at 18:40 +0400, Ivan Bezyazychnyy wrote:

> +static enum nl80211_mesh_power_mode
> +ieee80211s_get_ps_mode(struct ieee80211_sub_if_data *sdata,
> +			struct ieee80211_hdr *hdr)
> +{
> +	enum nl80211_mesh_power_mode pm = NL80211_MESH_POWER_ACTIVE;
> +	struct mesh_path *mpath;
> +
> +	if (is_multicast_ether_addr(hdr->addr1)) {
> +		pm = (enum nl80211_mesh_power_mode)
> +				sdata->u.mesh.mshcfg.power_mode;

I mean here.

> +	} else {
> +		rcu_read_lock();
> +		mpath = mesh_path_lookup(hdr->addr3, sdata);
> +		if (mpath) {
> +			pm = mpath->next_hop->local_ps_mode;
> +		}

No need for braces.

> +static void ieee80211_set_mesh_ps_fields(struct ieee80211_sub_if_data *sdata,
> +					struct ieee80211_hdr *hdr)
> +{
> +	if (ieee80211_vif_is_mesh(&sdata->vif) &&
> +	    (ieee80211_is_data_qos(hdr->frame_control)
> +	     || ieee80211_is_qos_nullfunc(hdr->frame_control))) {
> +		enum nl80211_mesh_power_mode
> +				pm = ieee80211s_get_ps_mode(sdata, hdr);
> +		if (pm != NL80211_MESH_POWER_ACTIVE) {
> +			__le16 *qc = (__le16 *) ieee80211_get_qos_ctl(hdr);
> +			hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
> +			if (pm == NL80211_MESH_POWER_DEEP_SLEEP) {
> +				*qc |= cpu_to_le16(
> +					IEEE80211_QOS_CTL_MESH_PS_LEVEL);
> +			}
> +		}
> +	}
> +}

I'm sure you can write this in a more readable way, e.g. by returning
from the function if the conditions aren't met etc.

johannes


  reply	other threads:[~2011-11-24 18:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-21 14:40 [RFC v2 0/8] mesh power saving implementation: indication Ivan Bezyazychnyy
2011-11-21 14:40 ` [RFC v2 1/8] cfg80211 and nl80211: mesh power mode config parameter Ivan Bezyazychnyy
2011-11-24 18:21   ` Johannes Berg
2011-11-21 14:40 ` [RFC v2 2/8] mac80211: mesh power mode indication in QoS frames Ivan Bezyazychnyy
2011-11-24 18:23   ` Johannes Berg [this message]
2011-11-21 14:40 ` [RFC v2 3/8] mac80211: tracking mesh peer link-specific power mode Ivan Bezyazychnyy
2011-11-24 18:26   ` Johannes Berg
2011-11-21 14:40 ` [RFC v2 4/8] mac80211: mesh non-peer power mode indication in beacons Ivan Bezyazychnyy
2011-11-21 14:40 ` [RFC v2 5/8] mac80211: setting link-specific mesh power modes when plink opens Ivan Bezyazychnyy
2011-11-24 18:29   ` Johannes Berg
2011-11-21 14:40 ` [RFC v2 6/8] cfg80211 and nl80211: Setting local link-specific power mode Ivan Bezyazychnyy
2011-11-21 14:40 ` [RFC v2 7/8] cfg80211 and nl80211: getting local and peer mesh power modes Ivan Bezyazychnyy
2011-11-24 18:31   ` Johannes Berg
2011-11-21 14:40 ` [RFC v2 8/8] cfg80211 and nl80211: setting and getting mesh non-peer power mode Ivan Bezyazychnyy
2011-11-24 18:33 ` [RFC v2 0/8] mesh power saving implementation: indication Johannes Berg
2011-11-25 18:35   ` Ivan Bezyazychnyy
2011-11-25  1:40 ` Javier Cardona
2011-11-25 18:40   ` Ivan Bezyazychnyy
  -- strict thread matches above, loose matches on Subject: below --
2011-11-21 13:16 [RFC v2 2/8] mac80211: mesh power mode indication in QoS frames Ivan Bezyazychnyy

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=1322158997.5366.29.camel@jlt3.sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=ivan.bezyazychnyy@gmail.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=krinkin.m.u@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=marco.porsch@etit.tu-chemnitz.de \
    /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).