Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp878737pxf; Wed, 7 Apr 2021 13:59:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYLcKmlrdnz5/fMi6S/CZK+nwjXf9BvqfkFT9ZrpNw+CKa/EOsxLViNt8b8dvo/uOsdCcN X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr4680196plh.47.1617829176854; Wed, 07 Apr 2021 13:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617829176; cv=none; d=google.com; s=arc-20160816; b=IqMYsmGVT2FTS35tqIL0uAWrgNCe7P0R8jH9FFcFblSScJkJ9pETroCdE0mAhjuDu+ q6Sw+SEK1V2tJUbL2XE7ahEmF9MABcxhl7HFixs5AKfJkpM1mgI9vq2F4y0JvHWdUA1w 5luyPLYnJrtRwXqtptOxsKYF8XksBktjnQxb89tyTkr97rkeeIzM/nX26Aosrkeuxs5I Ni4gLes0dOw76zQeoHPWhbwZjM/eEsaVkaXOTu58Hk2g01IqXLPsYipS7+iCb2c6X3Gg G7p9Oc3K6Kp+3BbAtkKKytqO0h4IGQU1QWBRDFlvTG4s1a64cPih83mLzJp+W5tBfaEe 4FrA== 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=+tZKbBZsHzHT7ez7IToWavjnk0q1E1myLKj48pmKHUQ=; b=YD0UPyjNhL07a/hgyo9j6w3hI0oKfmMGmv2UkE2gFXu8AighzBEPcFXZTLGPNUS7nj amh1syhT0hVb6gHCKxEF9gEheHPUC0lgfYVVw4ZTpf7sMzW/5iPpCwJx1bWr7o0LE2rF HcujWJnGMb7/FN8KcTkZQNnq60vBcVf5Z4YMOznoKKlq7ZbGclG7BSDafvETkmsLBVb3 vRYHhfU46car8aUtTPElliwExGUzQte3W9SA8rVpXu5+aiLY5n2hDbgmkJL3bCf8BpjQ KnEmS7Z2n51UgWCttz5MHF8KFRf/nPqSQU1pRDY32dW3vQXX8RZlXoss9EBeSTPqupJE kfVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Eg/cjZgl"; 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 d6si6736874pjr.146.2021.04.07.13.59.24; Wed, 07 Apr 2021 13:59: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="Eg/cjZgl"; 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 S1352447AbhDGMvd (ORCPT + 99 others); Wed, 7 Apr 2021 08:51:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:53324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbhDGMvb (ORCPT ); Wed, 7 Apr 2021 08:51:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB93461279; Wed, 7 Apr 2021 12:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617799882; bh=m4r6X7ZfydL60kYXm+rHrFPGoJaR2k9l7+B9drZZwHU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Eg/cjZglmOs+0VhFkHOsbQYekE4Y92vEuJBZOVSLDNZVQfAEP1v6sKbxxj2OdpXJF 0pZVBfLKcL6GDGHkWX+FLJ+Xr/nMDvmCJ2MUqjdOlIuDdSxbiX9+9H5gpBW0wWqc/8 okJfq9ghElwMauqW9owTQlMBIIG2C4oi+Fq/N26+ZHh4y2EZy7aAFTc3MOcAMTHDoV SWwqaCpcAk2IxZojl2RWYV2abb6pcohUL4MVAzo8zpLvQnT7k9KYt9mZgzZtz58nuU BSyTJA/Khnnm0eJmluiWbJil/6fkvj8wVQWGhM6hw21/fvp66BrKBamkWETivurx/0 nJY+4P1lqwslQ== Date: Wed, 7 Apr 2021 15:51:18 +0300 From: Leon Romanovsky 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) 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 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. Thanks > > Thanks, > -- Dexuan