From mboxrd@z Thu Jan 1 00:00:00 1970 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,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 BB826C282DD for ; Sat, 20 Apr 2019 10:29:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EF9921479 for ; Sat, 20 Apr 2019 10:29:27 +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="hnszB4Uq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726304AbfDTK30 (ORCPT ); Sat, 20 Apr 2019 06:29:26 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36954 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbfDTK30 (ORCPT ); Sat, 20 Apr 2019 06:29:26 -0400 Received: by mail-wm1-f67.google.com with SMTP id v14so8870793wmf.2 for ; Sat, 20 Apr 2019 03:29:24 -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=m/kr7JM0uPveUq9ipcchuxwFideAr1adEAzPdlR6C+U=; b=hnszB4UqTagLZONga4uAGDKVRFrQlu1kpHD3GfEynKmh1utoTO13taw6wMfX1qAWj5 powSqvYIYUTTyyLNXA7wxqOtQ6GTiq1Pwlv1+dS6vNKFMJzZUefas3HAXve/fXDjNvGx XM+22NoDunj1gHD98xqDeKeMfM3vZ4eTADbvT4WUgMGtXKL0A0gb7gLO0seeeTTwXWcy 1nmDPeUcsiSfgkfxFVwAOS3kKB+Suk0dqUnrXvPZ6s58ZlU8ufKycMf1AE51BWkT9vAq LEDOkjFU/ZX/dv+QzWsQNdq5fi7J9dXYP2E5vGRMVbZcSJW4hZbsmbT9TxmUmjY79yW8 tplg== 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=m/kr7JM0uPveUq9ipcchuxwFideAr1adEAzPdlR6C+U=; b=Dfr1ooBFXBGrJEpVPFfu+QmcJo04lOQMT8l4gWbNj6AhpVY12OqouawBofsJ/LXnqQ M3pze8ADu8C+8+Q40mffxir77DgLn1ghDiyxcmHe4KctaJvoSQ4/aQm9687+St+cT84c k+jQr71HSNzqsR4PIrHnse7Vhzm5ysA1G3UwwI89m8lPebC6AqM0dY62ExhPHRZEtji7 62JuBOQ+PU++H+WT2bri6NOgSEd/nxM7N6w+SZxl6RgPTvJZDaCevCUEfcaArzdxvGj3 8WMfbjxiSrrdZzd34tY6XD7+jtn3eo4DSvsJy3W4QOOOPTs/09cxy6/wcLgQtkGKodjM rDJA== X-Gm-Message-State: APjAAAXpKMWglBPSnWHJmUDqeDoRu4Yuil/LiU3RUCe/Lj0IP46zqy8d GMBz5e2NxpDgm+40CWXfCgjTkvRp6EY= X-Google-Smtp-Source: APXvYqzvVA0pdSSozQYG/Ep7L7OsDSeNms2EJvHR4QEgdUrr6y14NRF7ExeXHjzycrrm63NefJAuOQ== X-Received: by 2002:a1c:804c:: with SMTP id b73mr5423545wmd.116.1555756164012; Sat, 20 Apr 2019 03:29:24 -0700 (PDT) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id f128sm9936004wme.28.2019.04.20.03.29.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Apr 2019 03:29:23 -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 v2 00/16] netdevsim: impement proper device model Date: Sat, 20 Apr 2019 12:29:06 +0200 Message-Id: <20190420102922.6001-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 eni0np1 flavour physical netdevsim/netdevsim10/1: type eth netdev eni0np2 flavour physical netdevsim/netdevsim10/2: type eth netdev eni0np3 flavour physical netdevsim/netdevsim10/3: type eth netdev eni0np4 flavour physical There is possible to add and delete ports using their indexes during netdevsim device lifetime like this: # echo "43" > /sys/bus/netdevsim/devices/netdevsim10/new_port # echo "0" > /sys/bus/netdevsim/devices/netdevsim10/del_port Then devlink shows this: $ devlink port netdevsim/netdevsim10/1: type eth netdev eni10np2 flavour physical netdevsim/netdevsim10/2: type eth netdev eni10np3 flavour physical netdevsim/netdevsim10/3: type eth netdev eni10np4 flavour physical netdevsim/netdevsim10/43: type eth netdev eni10np44 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 v1->v2: See individual patches for changelog. The difference is in adding patch "extend device attrs to support port addition and deletion" and adjusting selftests. Jiri Pirko (16): 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: extend device attrs to support port addition and deletion 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 | 339 +++++++++++++++ drivers/net/netdevsim/dev.c | 447 ++++++++++++++++++++ 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 | 130 +++--- tools/testing/selftests/bpf/test_offload.py | 199 +++++---- tools/testing/selftests/net/rtnetlink.sh | 8 +- 11 files changed, 1181 insertions(+), 833 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