Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6072BC282DD for ; Thu, 18 Apr 2019 14:07:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FCE22083D for ; Thu, 18 Apr 2019 14:07:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="E8WX2OrH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389300AbfDROGU (ORCPT ); Thu, 18 Apr 2019 10:06:20 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38964 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389260AbfDROGS (ORCPT ); Thu, 18 Apr 2019 10:06:18 -0400 Received: by mail-wr1-f66.google.com with SMTP id j9so3145108wrn.6 for ; Thu, 18 Apr 2019 07:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=mwe0aAYuAZCBQp/ZJ9KdYrGkZhRI1vgCjEHpIzqcWdg=; b=E8WX2OrHPnwguyEvBvJxHT6saE5Xhdti+diJnowA1IQUSuoH9IlTIFpqmcbq1CAqMv 8Pu/Rlr0X6hXwWpbN8IcKTHwyFoAAc20Be1gVOZMqvpwudg5AkHSeqMRUGQSMbFI5SHf T1OpSfELnb50jVRmg6zk7WelL4yNTb+pzm5RIdQxCFSG5a8cWxrq+GLLgrrxuN4MB46V nmplP3CGSAuLfkrw+zbHs+RfrZrQUCAu7ObV6yLs8FbrnpqvgRu79x2mwCYAsWyTFgt5 HuKLac0pAJI9CxUS39rzttV4OGK5RaBftz4BwjZFfn8EvuvHdNDfCghsaHN6Up8a96bH yGnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mwe0aAYuAZCBQp/ZJ9KdYrGkZhRI1vgCjEHpIzqcWdg=; b=k2HCvOI8WZoG7RbmvNQSX+VgdaIawk7ZCqhYg79KzJjMLffVDtKv2NsDrlSrh+VjSz fJ0ilLnpT7IXHkp7YBPSdYzAuDeftaf3162elgvvOtmHQRyllFTcnirkT4bqayBRuPZF jEjQ4rh6XWkFo/JDy6u1IN+bkHxLWGPFuYeJiaOyL2sBt5wz5g36eeXRM49Prs69ICWU 7+SL7dInWiBjiUa1fH6Ls3k9lz5cWM18nLu2gSR78EXzXR/tRBWd8dU65EkgrcSDJoIN 0T/jri6mpnLHgau/Pya+tsGQBnSC6nLQDUAcWHSD+lGQH0G2Al+eKNMPxn0a1tPzIZ+m HfCQ== X-Gm-Message-State: APjAAAX+wlu7Npi3CE/8ck5mao8X8GiJvIujPZ7SX81uBU59dMYCBhX2 +fNDhAalHMgQvwQoCdlEBx3UUsK9A40= X-Google-Smtp-Source: APXvYqxttlcJZreHluUJGCyjOY6hMMynkGMT+FA0H1bITQdZ6TqS93l6vT/lpIUQwfssOMDwMtUOYA== X-Received: by 2002:adf:ec11:: with SMTP id x17mr25289524wrn.120.1555596376490; Thu, 18 Apr 2019 07:06:16 -0700 (PDT) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id t76sm3322530wmt.8.2019.04.18.07.06.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2019 07:06:15 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, mlxsw@mellanox.com, jakub.kicinski@netronome.com, dsahern@gmail.com Subject: [patch net-next 00/15] netdevsim: impement proper device model Date: Thu, 18 Apr 2019 16:05:59 +0200 Message-Id: <20190418140614.3973-1-jiri@resnulli.us> X-Mailer: git-send-email 2.17.2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Currently the model of netdevsim is a bit odd in multiple ways. 1) devlink instance is not in any way related with actual netdevsim netdevices. Instead, it is created per-namespace. 2) multi-port netdevsim device is done using "link" attribute. 3) netdevsim bus is there only to have something to bind the netdev to, it really does not act as a bus. 4) netdevsim instances are created by "ip link add" which is great for soft devices with no hw backend. The rtnl core allocates netdev and calls into driver holding rtnl mutex. For hw-backed devices, this flow is wrong as it breaks order in which things are done. This patchset adjust netdevsim to fix all above. In order to support proper devlink and devlink port instances and to be able to emulate real devices, there is need to implement bus probe and instantiate everything from there. User can specify device id and port count to be instantianted. For example: echo "10 4" > /sys/bus/netdevsim/new_device Then devlink shows this: $ devlink dev netdevsim/netdevsim10 $ devlink port netdevsim/netdevsim10/0: type eth netdev netdevsim10p1 flavour physical netdevsim/netdevsim10/1: type eth netdev netdevsim10p2 flavour physical netdevsim/netdevsim10/2: type eth netdev netdevsim10p3 flavour physical netdevsim/netdevsim10/3: type eth netdev netdevsim10p4 flavour physical Debugfs topology is also adjusted a bit. The rest stays the same as before. Udev bits are pushed in following pull request: https://github.com/systemd/systemd/pull/12340 Note that future extensions to allow add and delete ports during netdevsim life are quite easy to do. There is just needed to pick a correct interface. Jiri Pirko (15): netdevsim: move device registration on bus to be done earlier in init netdevsim: create devlink instance per netdevsim instance netdevsim: rename devlink.c to dev.c to contain per-dev(asic) items netdevsim: put netdevsim bus code into separate file netdevsim: move device registration and related code to bus.c netdevsim: add stub netdevsim driver implementation netdevsim: use ida for bus device ids netdevsim: add bus attributes to add new and delete devices netdevsim: rename dev_init/exit() functions and make them independent on ns netdevsim: merge sdev into dev netdevsim: generate random switch id instead of using dev id netdevsim: change debugfs tree topology netdevsim: implement dev probe/remove skeleton with port initialization netdevsim: move netdev creation/destruction to dev probe netdevsim: implement ndo_get_devlink_port drivers/net/netdevsim/Makefile | 2 +- drivers/net/netdevsim/bpf.c | 92 ++--- drivers/net/netdevsim/bus.c | 305 +++++++++++++++ drivers/net/netdevsim/dev.c | 385 +++++++++++++++++++ drivers/net/netdevsim/devlink.c | 295 --------------- drivers/net/netdevsim/fib.c | 103 +++-- drivers/net/netdevsim/ipsec.c | 3 +- drivers/net/netdevsim/netdev.c | 396 +++++--------------- drivers/net/netdevsim/netdevsim.h | 124 +++--- tools/testing/selftests/bpf/test_offload.py | 204 +++++----- tools/testing/selftests/net/rtnetlink.sh | 8 +- 11 files changed, 1071 insertions(+), 846 deletions(-) create mode 100644 drivers/net/netdevsim/bus.c create mode 100644 drivers/net/netdevsim/dev.c delete mode 100644 drivers/net/netdevsim/devlink.c -- 2.17.2