All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: Re: [PATCH v2 2/3] rrm: add radio resource management module
Date: Wed, 06 Nov 2019 13:51:38 -0800	[thread overview]
Message-ID: <62ca199a1e05bc90e09f7469282ecafce8a3ca4a.camel@gmail.com> (raw)
In-Reply-To: <fefac4d3-28be-6a56-a8c2-887e68765bd7@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3098 bytes --]

Hi Denis,

<snip>
> > +
> > +static void rrm_new_state(struct netdev *netdev)
> > +{
> > +	struct rrm_state *rrm;
> > +	uint16_t frame_type = 0x00d0;
> > +	uint8_t prefix[] = { 0x05, 0x00 };
> > +	struct station *station;
> > +
> > +	rrm = l_new(struct rrm_state, 1);
> > +
> > +	rrm->last_request = l_time_now();
> > +	rrm->ifindex = netdev_get_ifindex(netdev);
> > +	rrm->wdev_id = netdev_get_wdev_id(netdev);
> > +
> > +	netdev_frame_watch_add(netdev, frame_type, prefix,
> > sizeof(prefix),
> > +					rrm_frame_watch_cb, rrm);
> > +
> > +	station = station_find(rrm->ifindex);
> > +	station_add_state_watch(station, rrm_station_watch_cb, rrm,
> > NULL);
> 
> Shouldn't you be checking that station exists first?  Also, you have
> a 
> bit of a chicken/egg problem since station is watching the same 
> netdev_watch.  So by luck of the draw it may be getting notified
> (and 
> thus created) after the rrm module.
> 
> How we get around this is unclear.  One way would be to check the
> iftype 
> to be station and just assume that the station object comes around 
> eventually.  Perhaps by lazy-instantiating the station watch only
> once 
> an actual request arrives.

What about adding a module depends on station? This would make RRM get
initialized after station which should make the netdev watch call into
station before RRM.

> > +
> > +	l_queue_push_head(states, rrm);
> > +}
> > +
> > +static bool match_ifindex(const void *a, const void *b)
> > +{
> > +	const struct rrm_state *rrm = a;
> > +	uint32_t ifindex = L_PTR_TO_UINT(b);
> > +
> > +	return rrm->ifindex == ifindex;
> > +}
> > +
> > +static void rrm_netdev_watch(struct netdev *netdev,
> > +				enum netdev_watch_event event, void
> > *user_data)
> > +{
> > +	struct rrm_state *rrm;
> > +	uint32_t ifindex = netdev_get_ifindex(netdev);
> > +
> > +	switch (event) {
> > +	case NETDEV_WATCH_EVENT_NEW:
> > +		rrm_new_state(netdev);
> > +		return;
> > +	case NETDEV_WATCH_EVENT_DEL:
> > +		rrm = l_queue_find(states, match_ifindex,
> > +					L_UINT_TO_PTR(ifindex));
> > +		if (!rrm)
> > +			return;
> > +
> > +		rrm_cancel_pending(rrm);
> 
> Shouldn't you be freeing the rrm state?
> 
> > +		return;
> > +	default:
> > +		break;
> > +	}
> > +}
> > +
> > +static int rrm_init(void)
> > +{
> > +	struct l_genl *genl = iwd_get_genl();
> > +
> > +	states = l_queue_new();
> > +
> > +	nl80211 = l_genl_family_new(genl, NL80211_GENL_NAME);
> > +
> > +	netdev_watch = netdev_watch_add(rrm_netdev_watch, NULL, NULL);
> > +
> > +	return 0;
> > +}
> > +
> > +static void rrm_exit(void)
> > +{
> > +	l_genl_family_free(nl80211);
> > +	nl80211 = NULL;
> > +
> > +	netdev_watch_remove(netdev_watch);
> > +
> > +	l_queue_destroy(states, rrm_state_destroy);
> > +}
> > +
> > +IWD_MODULE(rrm, rrm_init, rrm_exit);
> > +IWD_MODULE_DEPENDS(rrm, netdev);
> > 
> 
> Regards,
> -Denis
> _______________________________________________
> iwd mailing list -- iwd(a)lists.01.org
> To unsubscribe send an email to iwd-leave(a)lists.01.org

  reply	other threads:[~2019-11-06 21:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 17:57 [PATCH v2 1/3] wiphy: add beacon bits to RM Enabled Capabilities James Prestwood
2019-11-06 17:57 ` [PATCH v2 2/3] rrm: add radio resource management module James Prestwood
2019-11-06 21:34   ` Denis Kenzior
2019-11-06 21:51     ` James Prestwood [this message]
2019-11-06 21:59       ` Denis Kenzior
2019-11-06 17:57 ` [PATCH v2 3/3] auto-t: add RRM autotest James Prestwood

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=62ca199a1e05bc90e09f7469282ecafce8a3ca4a.camel@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.01.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.