Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp905437pxf; Wed, 7 Apr 2021 14:41:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKnltRUFq1sMENqpALL1S3NbuLBx7fwJNnrGumeZYyoCjrLC0q0zNUNNioOJDrAwhRO9hQ X-Received: by 2002:a05:6402:34d5:: with SMTP id w21mr7039451edc.14.1617831696092; Wed, 07 Apr 2021 14:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617831696; cv=none; d=google.com; s=arc-20160816; b=Dg2OhUjb4cFRfgKkiX096fQUmPJjbPqEiW6JdeheiiG0YSodD2MMtSzBwvpUNOx8E3 BRigsZdSx9TVwDKcw7ZOa9ZW0PQSKmmwSnB1srGK28LJznK1T/HI7f3fzLFn3U06pO8h 9qdrJCGZdy6s5QndHuKiiNhWWPzC3ZBNC+l9EJcBzm948Vk7oR7EwxXBTp1VbSm9WkEu /8JfNbEOWDSdDHCSrhSvmknB1N4wrxx5fo86HMGkZYuZejFDfQTAsf/kwUhppjUHBi4C BTOKK/plZMLguFhx/fbxVbkSrFNCf3xWWa9gOzcWB4DV6Qm5x9RZZGdq8A0VzCuGb/jB rtcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yNLTsZDf1wsruz9uZD3oF8piv1cq4DMToDmp+NwDlCc=; b=TCGAsFx3macUn3Q99hMfLRhP3s7e0mWbthqOlN+zVL3hs+zj0MchiKy0rEm+gmvfJc ZmuSHuEVOECe25/MRuMqqJAiMSlxhbXFnDhrql6iE2I3f8QQNGiHXlArUzD68322PANd t7EEh8792HzDptZiLSClvE/IZJJ9sJjJBB+BCGfEFokbFvzSPaqed23P5jhsCO4peHfK moia9U3ZiB/yMmWUXKx8+qb6c/6ZTtjynM2rcao4Cp2nKSXb7BBhUR0W1vXEG4i0UD6C m6aVFhL3AO8yXbti8fG3W19lx5cIUHm5t4P7Gf6Nua/HkUzEuXcNjYhkmTTv0td48bjA fZ4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DZvZEW5a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si7399256edd.369.2021.04.07.14.41.13; Wed, 07 Apr 2021 14:41:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DZvZEW5a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348209AbhDGRHd (ORCPT + 99 others); Wed, 7 Apr 2021 13:07:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:36460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbhDGRHa (ORCPT ); Wed, 7 Apr 2021 13:07:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B5805610CC; Wed, 7 Apr 2021 17:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617815240; bh=apYFtuNjrmejYcSJrizl3qdNjlJnPQG0oaFz9y6REwE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DZvZEW5aRVVrnzHzcQ0FiqmiAjJNRU5VlbA7YGgK3DD7GrjiSCMd45gWJtejdjvcj eaYHtTjLo0jUi3BJF7ffPfzR9pQohHiNHACh+ZVAqtzwWNPzEA6IOJpceF8ZFV7t/e AT3IyBn8iEZd/YQv7UQB9ZjtkoDpVE3YdzX9fSqQ6CXJoRHaVliv3aoXXDGUuGGoCd 5XfZ7itX/C/uz+Xx9m836XOPgiu2nDeyFl0mbnutaqcRTtKyt+Wffr3ZIUdsGLFQUs h98B/QaGqotwO50wgB9cMRCsMQD7opmzCsp1wbd8BYRVp5hY87q1h+VPrfAQXZLyAf yWJCTSVuSUOsA== Date: Wed, 7 Apr 2021 20:07:16 +0300 From: Leon Romanovsky To: Haiyang Zhang Cc: Dexuan Cui , "davem@davemloft.net" , "kuba@kernel.org" , KY Srinivasan , Stephen Hemminger , "wei.liu@kernel.org" , Wei Liu , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" Subject: Re: [PATCH net-next] net: mana: Add a driver for Microsoft Azure Network Adapter (MANA) Message-ID: References: <20210406232321.12104-1-decui@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 07, 2021 at 03:05:26PM +0000, Haiyang Zhang wrote: > > > > -----Original Message----- > > From: Leon Romanovsky > > Sent: Wednesday, April 7, 2021 10:55 AM > > To: Haiyang Zhang > > Cc: Dexuan Cui ; davem@davemloft.net; > > kuba@kernel.org; KY Srinivasan ; Stephen Hemminger > > ; wei.liu@kernel.org; Wei Liu > > ; netdev@vger.kernel.org; linux- > > kernel@vger.kernel.org; linux-hyperv@vger.kernel.org > > Subject: Re: [PATCH net-next] net: mana: Add a driver for Microsoft Azure > > Network Adapter (MANA) > > > > On Wed, Apr 07, 2021 at 02:41:45PM +0000, Haiyang Zhang wrote: > > > > > > > > > > -----Original Message----- > > > > From: Leon Romanovsky > > > > Sent: Wednesday, April 7, 2021 8:51 AM > > > > To: Dexuan Cui > > > > Cc: davem@davemloft.net; kuba@kernel.org; KY Srinivasan > > > > ; Haiyang Zhang ; > > Stephen > > > > Hemminger ; wei.liu@kernel.org; Wei Liu > > > > ; netdev@vger.kernel.org; linux- > > > > kernel@vger.kernel.org; linux-hyperv@vger.kernel.org > > > > Subject: Re: [PATCH net-next] net: mana: Add a driver for Microsoft > > > > Azure Network Adapter (MANA) > > > > > > > > On Wed, Apr 07, 2021 at 08:40:13AM +0000, Dexuan Cui wrote: > > > > > > From: Leon Romanovsky > > > > > > Sent: Wednesday, April 7, 2021 1:10 AM > > > > > > > > > > > > <...> > > > > > > > > > > > > > +int gdma_verify_vf_version(struct pci_dev *pdev) { > > > > > > > + struct gdma_context *gc = pci_get_drvdata(pdev); > > > > > > > + struct gdma_verify_ver_req req = { 0 }; > > > > > > > + struct gdma_verify_ver_resp resp = { 0 }; > > > > > > > + int err; > > > > > > > + > > > > > > > + gdma_init_req_hdr(&req.hdr, > > GDMA_VERIFY_VF_DRIVER_VERSION, > > > > > > > + sizeof(req), sizeof(resp)); > > > > > > > + > > > > > > > + req.protocol_ver_min = GDMA_PROTOCOL_FIRST; > > > > > > > + req.protocol_ver_max = GDMA_PROTOCOL_LAST; > > > > > > > + > > > > > > > + err = gdma_send_request(gc, sizeof(req), &req, sizeof(resp), > > &resp); > > > > > > > + if (err || resp.hdr.status) { > > > > > > > + pr_err("VfVerifyVersionOutput: %d, status=0x%x\n", > > err, > > > > > > > + resp.hdr.status); > > > > > > > + return -EPROTO; > > > > > > > + } > > > > > > > + > > > > > > > + return 0; > > > > > > > +} > > > > > > > > > > > > <...> > > > > > > > + err = gdma_verify_vf_version(pdev); > > > > > > > + if (err) > > > > > > > + goto remove_irq; > > > > > > > > > > > > Will this VF driver be used in the guest VM? What will prevent > > > > > > from users > > > > to > > > > > > change it? > > > > > > I think that such version negotiation scheme is not allowed. > > > > > > > > > > Yes, the VF driver is expected to run in a Linux VM that runs on Azure. > > > > > > > > > > Currently gdma_verify_vf_version() just tells the PF driver that > > > > > the VF > > > > driver > > > > > is only able to support GDMA_PROTOCOL_V1, and want to use > > > > > GDMA_PROTOCOL_V1's message formats to talk to the PF driver later. > > > > > > > > > > enum { > > > > > GDMA_PROTOCOL_UNDEFINED = 0, > > > > > GDMA_PROTOCOL_V1 = 1, > > > > > GDMA_PROTOCOL_FIRST = GDMA_PROTOCOL_V1, > > > > > GDMA_PROTOCOL_LAST = GDMA_PROTOCOL_V1, > > > > > GDMA_PROTOCOL_VALUE_MAX > > > > > }; > > > > > > > > > > The PF driver is supposed to always support GDMA_PROTOCOL_V1, so I > > > > expect > > > > > here gdma_verify_vf_version() should succeed. If a user changes > > > > > the Linux > > > > VF > > > > > driver and try to use a protocol version not supported by the PF > > > > > driver, > > > > then > > > > > gdma_verify_vf_version() will fail; later, if the VF driver tries > > > > > to talk to the > > > > PF > > > > > driver using an unsupported message format, the PF driver will > > > > > return a > > > > failure. > > > > > > > > The worry is not for the current code, but for the future one when > > > > you will support v2, v3 e.t.c. First, your code will look like a > > > > spaghetti and second, users will try and mix vX with "unsupported" > > > > commands just for the fun. > > > > > > In the future, if the protocol version updated on the host side, > > > guests need to support different host versions because not all hosts > > > are updated (simultaneously). So this negotiation is necessary to know > > > the supported version, and decide the proper command version to use. > > > > And how do other paravirtual drivers solve this negotiation scheme? > > I saw some other drivers used version negotiation too, for example: I see, thanks. > > /** > * ixgbevf_negotiate_api_version_vf - Negotiate supported API version > * @hw: pointer to the HW structure > * @api: integer containing requested API version > **/ > static int ixgbevf_negotiate_api_version_vf(struct ixgbe_hw *hw, int api) > { > > Thanks, > - Haiyang