netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Cc: m.chetan.kumar@intel.com, Loic Poulain <loic.poulain@linaro.org>,
	Johannes Berg <johannes@sipsolutions.net>,
	Johannes Berg <johannes.berg@intel.com>
Subject: Re: [RFC v2 3/5] rtnetlink: add IFLA_PARENT_DEV_NAME
Date: Wed, 2 Jun 2021 18:26:55 +0300	[thread overview]
Message-ID: <CAHNKnsTKfFF9EckwSnLrwaPdH_tkjvdB3PVraMD-OLqFdLmp_Q@mail.gmail.com> (raw)
In-Reply-To: <20210602102653.9d5c4789824f.Ia98e333bba58bc6a0b1c8fa28ad0964fb9c918d6@changeid>

On Wed, Jun 2, 2021 at 11:28 AM Johannes Berg <johannes@sipsolutions.net> wrote:
> In some cases, for example in the upcoming WWAN framework
> changes, there's no natural "parent netdev", so sometimes
> dummy netdevs are created or similar. IFLA_PARENT_DEV_NAME
> is a new attribute intended to contain a device (sysfs,
> struct device) name that can be used instead when creating
> a new netdev, if the rtnetlink family implements it.
>
> Suggested-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
> v2:
>  * new patch
> ---
>  include/uapi/linux/if_link.h | 6 ++++++
>  net/core/rtnetlink.c         | 1 +
>  2 files changed, 7 insertions(+)
>
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> index f7c3beebb074..3455780193a4 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -341,6 +341,12 @@ enum {
>         IFLA_ALT_IFNAME, /* Alternative ifname */
>         IFLA_PERM_ADDRESS,
>         IFLA_PROTO_DOWN_REASON,
> +
> +       /* device (sysfs) name as parent, used instead
> +        * of IFLA_LINK where there's no parent netdev
> +        */
> +       IFLA_PARENT_DEV_NAME,
> +
>         __IFLA_MAX
>  };
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 4975dd91407d..49a27bf6e4a7 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -1878,6 +1878,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
>         [IFLA_PERM_ADDRESS]     = { .type = NLA_REJECT },
>         [IFLA_PROTO_DOWN_REASON] = { .type = NLA_NESTED },
>         [IFLA_NEW_IFINDEX]      = NLA_POLICY_MIN(NLA_S32, 1),
> +       [IFLA_PARENT_DEV_NAME]  = { .type = NLA_NUL_STRING },
>  };
>
>  static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {

I would like to clarify this proposal more broadly. There are some
devices that implement multiple data channels and require several
netdev for traffic separation. The most notable class of such devices
is WWAN modems.

At the moment, a common way to manage these multiple interfaces is to
create a master netdev per each HW instance and reuse IFLA_LINK
attribute to create all subsequent data channel netdevs as
subinterfaces of the master (see MBIM and RMNET drivers). But in fact
all these netdev do not have the master-subinterface relationship.
They are equal. The only reason to implement such a complex scheme is
the absenсe of an attribute that can indicate a parent device. So, in
some sense, driver developers were forced to abuse IFLA_LINK to avoid
a complete per-driver private API creation.

It was Johannes finding that we can greatly simplify the management
API for the WWAN subsystem by specifying a sysfs device name as a
parent for the data channel netdev creation procedure. The first RFC
introduces a private attribute to indicate a parent device. My
suggestion was only to make this attribute generic as it seems to be
generic. The parent device indication attribute should help us avoid
further IFLA_LINK abuse and perhaps even make it easier to rework
existing drivers. Moreover, we have the parent device pointer directly
in the netdev structure, so after applying this patch, we will be able
to export the parent device name using the netdev dump operation and
even filter its results.

ip-link(8) support for the generic parent device attribute will help
us avoid code duplication, so no other link type will require a custom
code to handle the parent name attribute. E.g. the WWAN interface
creation command will looks like this:

# ip link add wwan0-1 parent-dev wwan0 type wwan channel-id 1

So, some future subsystem (or driver) FOO will have an interface
creation command that looks like this:

# ip link add foo1-3 parent-dev foo1 type foo bar-id 3 baz-type Y

As suggested by Johannes, I will soon send a small series with
examples of using the suggested parent device name attribute.

-- 
Sergey

  reply	other threads:[~2021-06-02 15:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  8:28 [RFC v2 0/5] generic WWAN framework interface creation Johannes Berg
2021-06-02  8:28 ` [RFC v2 1/5] iosm: fix stats and RCU bugs in RX Johannes Berg
2021-06-02  8:28 ` [RFC v2 2/5] rtnetlink: add alloc() method to rtnl_link_ops Johannes Berg
2021-06-02  8:28 ` [RFC v2 3/5] rtnetlink: add IFLA_PARENT_DEV_NAME Johannes Berg
2021-06-02 15:26   ` Sergey Ryazanov [this message]
2021-06-02  8:28 ` [RFC v2 4/5] wwan: add interface creation support Johannes Berg
2021-06-02  8:28 ` [RFC v2 5/5] iosm: convert to generic wwan ops 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=CAHNKnsTKfFF9EckwSnLrwaPdH_tkjvdB3PVraMD-OLqFdLmp_Q@mail.gmail.com \
    --to=ryazanov.s.a@gmail.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=m.chetan.kumar@intel.com \
    --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).