Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E55035E958 for ; Wed, 4 Mar 2026 16:00:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772640053; cv=none; b=FQqZWBbPsEYe9l/Odpy58y0mDG0TjciwaX9dRIVYR+qkXjSLQRRkfby0MojzRDKWKia3AbscHPabq4boWnXGnmhFanJ3XtiTjAguNMT5LcA07sg7In0mOTwdDBdywEc/233JIav08rW6nhimLYQsz+Bo4JZhX/6tAcwCxfr9NVs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772640053; c=relaxed/simple; bh=suAlp0+6vIiTYE/DszDuVSfJ/B/GhkXRhq5R0j4plyk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ew0/62GLzXQIgEOsTYAo7vMPn1UokBHWl142pew/b+nSM6on7tTIz2BXR9hjb61aTkr17mT5ZjXMJd6ciarHK0U67MetNVlDzKhhsEsNVL1FKfKrz8f9VVKT1rSVJbluAEeXd7ZJyBNDkN7l2Xz5K2ErZCtUCkmT3SC3H8xWXng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=3dJzgiFT; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="3dJzgiFT" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4836f4cbe0bso59326245e9.3 for ; Wed, 04 Mar 2026 08:00:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1772640049; x=1773244849; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T3g0UTN2sEfKe2VfEgfWZcWamkZLOLTyGyEUUMk8B8w=; b=3dJzgiFToOxO+iz1yiW9nfsncciLnIlxgjjvboNOdkglu8CyhtZ9MO7v4Bh4FIgsfU MrzNoTeAvvm3WypyqQDUxai1rBbx5zEgAyYSAUWqdfM+vqy/Ek5qrOnT5ZXumpikCGuc hiR+rjO8FsnIliBbBDujSAidq9HJlaSIxUWZQPYkImNoxHusJaSMOp/cwAPWkq7+J5oO hQPyphCOlAwKP3qLXwp5rdAiTr+iKzXSR1JeHBCZggOf4XejQt1rITdMSiKgw7OQggM0 duVGj/3Nvtae+W/DyqmouReOq8M+baixXfq6Fd0yxMVabI2h4iXe0f3BVx/6KIyB0aAa pxSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772640049; x=1773244849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=T3g0UTN2sEfKe2VfEgfWZcWamkZLOLTyGyEUUMk8B8w=; b=mg33tczBcikKhOGtd6zg2hqV8jvEoRZdKRYgfT1VRRrNPtZqoPXGoU6qAxEjE3XKfh VawZrI+weiME7xEP9oGPvjTZ+X71I3vmpmw/aBBVneNWVZhe4NOAasBH87YZtazz3zXZ 4q8rxwkN/BOWDgPpb71JNvk1UBSin9n3cBluPbaEBxCtFcLPIcFbUGRQf2Zn+ey7h14c cY5ikuZ1vSfj2gSVtLubK89EBWMGv/IfXUCIzD9OCbO+3uHf02XoUCMf/+ke0OYLYulc zqJvOZXD8it7ApXlIDTwwZBSIG9YsL48Nzixtc6foAtEa9TAwA8KE0J6dHv1ZMZNr+8b 1cTg== X-Forwarded-Encrypted: i=1; AJvYcCXHm92K/HuJe+rSG9V7Obe0v2l49wMBlsIjjSWUW/YakZDIIEx5ug5d8zzX4+0ZSomlAjEPUAbRRqk=@vger.kernel.org X-Gm-Message-State: AOJu0YzmnbNacHGvvup6K5EiobPL3oVS1hiE7K3j2EoXnjMaQoGn0KHR OJ5NXktdmyssRnOyBchkpCol1N3OdnxrObqZ8pHzw70f1QXzIqLpLMrRpruDtFo8aCw= X-Gm-Gg: ATEYQzz+A+omnZgFmUnaWzAAOYNZ4TbS3K1kEQUiqUQmOAzvHRbNIwupPcCHE3ML0B4 Av83afu9/PSIa27qb9+gb5P9iLG01oRXHja9qrjbKlyXwQNjFiwOK/9NthojMA4/bVUcPpms4yD Zj2YbE8zbHUSnKo0wbWqF77aHtUZ0Oy3GPlv0o4THAM3KM4iNXCj5aUgYleyk61E5nxsC154a93 teM1WEi6EMo2yWHTKdhoOMKzRrsVTYxBUUOVH1wY8FKPHHXmu+yIlvPGwPe1C2uAe2ZiDWV/CN5 6i09wNfGN6nVxOA3uPzpomxHs/IV5d4Rldw6qA6OEi4QtY0tzFHDF1BpFQCUkjcwiyTpGuoKNRl PxALeI8L3ZVL4cLfhDXL1D4mgStGimvAfI4bxUEWKByVly9vDmZi9kpMnp9vepo5jEd/tEN0unj OP9FYmslUiqNFKoSBLY2Aa/RS8K429VylE+4PIjPW0oBI0AadymzxAYFl3 X-Received: by 2002:a05:600c:529b:b0:47a:7fdd:2906 with SMTP id 5b1f17b1804b1-485198668eemr42237935e9.12.1772640049317; Wed, 04 Mar 2026 08:00:49 -0800 (PST) Received: from localhost (46-13-72-179.customers.tmcz.cz. [46.13.72.179]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485188914ddsm74604335e9.12.2026.03.04.08.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:00:48 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, donald.hunter@gmail.com, corbet@lwn.net, skhan@linuxfoundation.org, saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, mbloch@nvidia.com, przemyslaw.kitszel@intel.com, mschmidt@redhat.com, andrew+netdev@lunn.ch, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, chuck.lever@oracle.com, matttbe@kernel.org, cjubran@nvidia.com, daniel.zahka@gmail.com, linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH net-next v3 12/13] documentation: networking: add shared devlink documentation Date: Wed, 4 Mar 2026 17:00:21 +0100 Message-ID: <20260304160022.6114-13-jiri@resnulli.us> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260304160022.6114-1-jiri@resnulli.us> References: <20260304160022.6114-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jiri Pirko Document shared devlink instances for multiple PFs on the same chip. Signed-off-by: Jiri Pirko --- v2->v3: - describing 2 models of use os shared device, with and without per-PF instances v1->v2: - fixed number of "="'s --- .../networking/devlink/devlink-shared.rst | 97 +++++++++++++++++++ Documentation/networking/devlink/index.rst | 1 + 2 files changed, 98 insertions(+) create mode 100644 Documentation/networking/devlink/devlink-shared.rst diff --git a/Documentation/networking/devlink/devlink-shared.rst b/Documentation/networking/devlink/devlink-shared.rst new file mode 100644 index 000000000000..16bf6a7d25d9 --- /dev/null +++ b/Documentation/networking/devlink/devlink-shared.rst @@ -0,0 +1,97 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======================== +Devlink Shared Instances +======================== + +Overview +======== + +Shared devlink instances allow multiple physical functions (PFs) on the same +chip to share a devlink instance for chip-wide operations. + +Multiple PFs may reside on the same physical chip, running a single firmware. +Some of the resources and configurations may be shared among these PFs. The +shared devlink instance provides an object to pin configuration knobs on. + +There are two possible usage models: + +1. The shared devlink instance is used alongside individual PF devlink + instances, providing chip-wide configuration in addition to per-PF + configuration. +2. The shared devlink instance is the only devlink instance, without + per-PF instances. + +It is up to the driver to decide which usage model to use. + +The shared devlink instance is not backed by any struct *device*. + +Implementation +============== + +Architecture +------------ + +The implementation uses: + +* **Chip identification**: PFs are grouped by chip using a driver-specific identifier +* **Shared instance management**: Global list of shared instances with reference counting + +API Functions +------------- + +The following functions are provided for managing shared devlink instances: + +* ``devlink_shd_get()``: Get or create a shared devlink instance identified by a string ID +* ``devlink_shd_put()``: Release a reference on a shared devlink instance +* ``devlink_shd_get_priv()``: Get private data from shared devlink instance + +Initialization Flow +------------------- + +1. **PF calls shared devlink init** during driver probe +2. **Chip identification** using driver-specific method to determine device identity +3. **Get or create shared instance** using ``devlink_shd_get()``: + + * The function looks up existing instance by identifier + * If none exists, creates new instance: + - Allocates and registers devlink instance + - Adds to global shared instances list + - Increments reference count + +4. **Set nested devlink instance** for the PF devlink instance using + ``devl_nested_devlink_set()`` before registering the PF devlink instance + +Cleanup Flow +------------ + +1. **Cleanup** when PF is removed +2. **Call** ``devlink_shd_put()`` to release reference (decrements reference count) +3. **Shared instance is automatically destroyed** when the last PF removes (reference count reaches zero) + +Chip Identification +------------------- + +PFs belonging to the same chip are identified using a driver-specific method. +The driver is free to choose any identifier that is suitable for determining +whether two PFs are part of the same device. Examples include: + +* **PCI VPD serial numbers**: Extract from PCI VPD +* **Device tree properties**: Read chip identifier from device tree +* **Other hardware-specific identifiers**: Any unique identifier that groups PFs by chip + +Locking +------- + +A global mutex (``shd_mutex``) protects the shared instances list during registration/deregistration. + +Similarly to other nested devlink instance relationships, devlink lock of +the shared instance should be always taken after the devlink lock of PF. + +Reference Counting +------------------ + +Each shared devlink instance maintains a reference count (``refcount_t refcount``). +The reference count is incremented when ``devlink_shd_get()`` is called and decremented +when ``devlink_shd_put()`` is called. When the reference count reaches zero, the shared +instance is automatically destroyed. diff --git a/Documentation/networking/devlink/index.rst b/Documentation/networking/devlink/index.rst index 35b12a2bfeba..f7ba7dcf477d 100644 --- a/Documentation/networking/devlink/index.rst +++ b/Documentation/networking/devlink/index.rst @@ -68,6 +68,7 @@ general. devlink-resource devlink-selftests devlink-trap + devlink-shared Driver-specific documentation ----------------------------- -- 2.51.1