Outreachy Linux Kernel Community
 help / color / mirror / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Jaehee Park <jhpark1013@gmail.com>
Cc: outreachy@lists.linux.dev
Subject: Re: patch idea for wfx
Date: Fri, 1 Apr 2022 00:12:16 +0200	[thread overview]
Message-ID: <20220401001216.727c2ef1@elisabeth> (raw)
In-Reply-To: <20220331214733.GA1508153@jaehee-ThinkPad-X1-Extreme>

On Thu, 31 Mar 2022 17:47:33 -0400
Jaehee Park <jhpark1013@gmail.com> wrote:

> [...]
>
> Ok so my understanding is: vif is an instance of the struct
> ieee80211_vif which is from the /net/mac80211.h in the linux kernel
> code and so the compiler knows the offset of drv_priv because it's
> defined within this generic struct.

Correct! Well, it's not an instance, it's just a reference to an
instance -- note that it's a pointer. Usually by "instance" one refers
to something more concrete (such as the storage for a given struct).

	struct ieee80211_vif vif <- instance!

	struct ieee80211_vif *vif -> hmm, you could call it an
				     instance, but might cause confusion

> This makes is so much clearer in my head; Thank you so much!! I
> didn't know about pahole. Such a neat tool!

You're welcome, I'm glad it's clear now!

> [...]
>
> Thank you Stefano for explanining contain_of() so clearly! To
> implement it, I think I need to implement work_struct from
> linux/workqueue.h because I see it's being used in container_of()
> defined in functions: wfx_cooling_timeout_work, wfx_beacon_loss_work,
> wfx_update_tim_work.

Hah, no, forget about that! It's just the very same construct but it
has little to do with what you want to change.

Take wfx_update_tim_work(): struct wfx_vif here is like struct
ieee80211_vif because it carries a struct work_struct, here, which is
like your struct wfx_wif:

	struct wfx_vif *wvif = container_of(work, struct wfx_vif, update_tim_work);

meaning:

- struct wfx_vif contains a struct work_struct, and you have a pointer
  to the inner struct ("work")

- "update_tim_work" is the name of the instance of struct work_struct
  inside struct wfx_vif

- from "work", take a pointer to the struct wfx_vif which contains it

> I'm not totally sure of my questions / what to ask here - maybe how
> does the kernel know that there is work and what work to queue?

http://www.makelinux.net/ldd3/chp-7-sect-6.shtml

...but it's unrelated with the issue at hand. :)

-- 
Stefano


  reply	other threads:[~2022-03-31 22:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31 14:14 patch idea for wfx Jaehee Park
2022-03-31 17:40 ` Fabio M. De Francesco
2022-03-31 17:52 ` Stefano Brivio
2022-03-31 21:47   ` Jaehee Park
2022-03-31 22:12     ` Stefano Brivio [this message]
2022-04-06  4:28       ` Jaehee Park
2022-04-06 13:54         ` Fabio M. De Francesco
2022-04-06 14:24           ` Jaehee Park
2022-04-06 16:04             ` Fabio M. De Francesco
2022-04-07  1:57               ` Jaehee Park
2022-04-06 15:41         ` Stefano Brivio

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=20220401001216.727c2ef1@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=jhpark1013@gmail.com \
    --cc=outreachy@lists.linux.dev \
    /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