From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796418202; b=oV1B59eqBliznzDY8ITutrsE/L/Z18+cS0tY5JyfatEAtGL1Cj0AsILCkPtdMfXLNNNP NsT2wcK+swLpvjJBqZ2o+mdzhJBjworOU0ttBYTCo9JIHY4P0f4ntcmnexX5qcFs/XR8B FgcHaK6JBi/Re95UcXI6ntTYtvEZ1Q7KPtSD0pD5l+fbZVxgMVdTQEeUPsIKzB9W60SF5 cE9eS1EPsh5jcKe/myvS2sQur8e7nLpcVMCTCikUW8PGgHX+gyDEl7JPyV2c9H3uBzu7Q 2C/q+FSUznypeekshk+KoHSSM7q+K7/5m73vbuipm/QV5Is1MwDJkvHmRNMuMK5i1jg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796418202; h=Received:DKIM-Signature:Mime-Version:Content-Transfer-Encoding: Content-Type:Date:Message-Id:Subject:Cc:To:From:References: In-Reply-To; bh=sRO5/kQGEI0EKsLM+L+5ZUTcgqy0KntpWcvfLDzV39s=; b=SmgeyQ4pX7AcC9FGCRxswjmEPfnN/Ox8uWR/yH9/QCqED9qb9UkpZOUucs3HaSvfg2nT JUaO9NSvWWKpkrJCvxQRDz+UEPiOdXFpgBvWXXAOJvZuE+Sc1jSnqgW4thajBM6tH5Dz5 Dl9Eq6BEawR33cL1PnIh5774FQSFBcNX7RBZdClp56bynnYIKdXn56gpJf4Cq0a99+A5U vjkSO0w2wiB2jv4xsWl8yoCievJiRnBuLVWp+nSK7ASQeuX1KTTj2UrSqLRlY1pvA0bSw tRsExe7hRCD7lG4doUHmmsh4mBLhidyKLs82rHcv1f1Xu8cC6ofXtlmIpENsgZJtvjw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GIIktiEk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98262606A322; Fri, 4 Dec 2026 21:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GIIktiEk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 851A41F00936; Fri, 4 Dec 2026 21:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796418202; bh=sRO5/kQGEI0EKsLM+L+5ZUTcgqy0KntpWcvfLDzV39s=; h=Date:Subject:Cc:To:From:References:In-Reply-To; b=GIIktiEk/VJVtyqPjiH8s5Iv0yw08C8E/pL9u4o5k5v+uEwvmYPkbdlM2eXtN4mLC CcTyzxMCRfl3fhDwpa31+te2rZ/zqmans8B+C3FQJk77hh6Z9W7M7Rd6DlJJ/wtp0E 7y7UD6RXCay1/gz4hLl7qhSuqRToxKf+AIAm3Iw0R+SwCTXRzLmwqPQZBVF81N3Lhl N0ifHnoEIJsPTKUFKwB9crKBd4IjbTgnswUUvlLBbSJsZOrWIxaPF2m2waMcoWxM4/ VMitZmMkYDQCz4fglM7IjwW7uSCLsy749JvK8Bcrma3JdEfG1UdsWJf1OfXu56UN4Q NSaxONBVrif6g== X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 04 Dec 2026 22:03:11 +0100 Message-Id: Subject: Re: [PATCH v6 21/34] gpu: nova-core: vgpu: query VF assignments and properties Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , To: "Alok Kumar" From: "Danilo Krummrich" References: <3c007bb2a13cd7120a30a03e40007b1902b4e527.1796191007.git.alkumar@nvidia.com> In-Reply-To: <3c007bb2a13cd7120a30a03e40007b1902b4e527.1796191007.git.alkumar@nvidia.com> On Wed Dec 2, 2026 at 9:28 AM CET, Alok Kumar wrote: > +struct QueryAssignedVfVgpuType(Dbdf); > + > +impl CommandToGsp for QueryAssignedVfVgpuType { > + const COMMAND: GmcCommandId =3D GmcCommandId::QueryAssignedVfVgpuTyp= e; > + type Command =3D u64; > + type Reply =3D AssignedVfVgpuType; > + const MAX_REPLY_SIZE: u32 =3D cv!(size_of::()); > + type InitError =3D Infallible; > + > + fn init(&self) -> impl Init { > + u64::from(self.0.into_raw()).to_le() > + } > +} > + > +impl MessageFromGsp for AssignedVfVgpuType { > + type InitError =3D Error; > + > + fn read(payload: &mut MessagePayload<'_>) -> Result { > + payload.read() > + } > +} > + > +/// Query the vGPU type assigned to a VF by its DBDF. > +#[expect(dead_code)] > +pub(super) fn query_assigned_vf_type( > + _dev: &device::Device, > + cmdq: &Cmdq<'_>, > + dbdf: Dbdf, > +) -> Result { > + let reply =3D cmdq > + .send_gmc_command(QueryAssignedVfVgpuType(dbdf), |_| Ok(()))? > + .map_err(|_| EIO)?; > + > + Ok(reply.vgpu_type_id) > +} > + > +struct QueryVgpuProperties(u32); Please don't use freestanding functions for this, this should instead be struct QueryAssignedVfVgpuType(Dbdf); impl QueryAssignedVfVgpuType { pub(super) fn new(dbdf: Dbdf) -> Self { Self(dbdf) } pub(super) fn send(self, cmdq: &Cmdq<'_>) -> Result { let reply =3D cmdq .send_gmc_command(QueryAssignedVfVgpuType(dbdf), |_| Ok(()))? .map_err(|_| EIO)?; Ok(reply.vgpu_type_id) } } Such that this can be called as let type_id =3D QueryAssignedVfVgpuType::new(dbdf).send(cmdq)?; > +/// Query and decode the firmware properties of one vGPU type. > +#[expect(dead_code)] > +pub(super) fn query_vgpu_properties( > + _dev: &device::Device, > + cmdq: &Cmdq<'_>, > + type_id: u32, > +) -> Result> { > + let properties =3D cmdq > + .send_gmc_command(QueryVgpuProperties(type_id), |_| Ok(()))? > + .map_err(|_| EIO)?; > + > + if properties.type_id !=3D type_id || properties.max_instance =3D=3D= 0 { > + Err(EINVAL) > + } else { > + Ok(properties) > + } > +} Same here.