From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id B3467A00BE;
	Tue, 29 Oct 2019 19:51:21 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id D708D1BFAC;
	Tue, 29 Oct 2019 19:51:11 +0100 (CET)
Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com
 [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 06BA01BFAA
 for <dev@dpdk.org>; Tue, 29 Oct 2019 19:51:10 +0100 (CET)
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.nyi.internal (Postfix) with ESMTP id 790AA20D2B;
 Tue, 29 Oct 2019 14:51:09 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
 by compute1.internal (MEProxy); Tue, 29 Oct 2019 14:51:09 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=
 from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding; s=mesmtp; bh=flzSd38kca
 61I2uCe+eACpu9XGpzqS6lnjyWN31WCNY=; b=YTqREDVPYD67nOHvFHc7Kr6P8T
 R2SitxwyYs1o+8IEz+BJE58/JzBlaNasrwaonDw8O/kyb/AbwWIRKqYJxvXxvw0a
 ZA0kgje0f9ZQqH/X7sPNpOJYW1bhRkMbb8bdyfP5TBYLfj1YW28J3ipQw3HqaHnf
 mwBzgFYFamLVWggfk=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:date:from
 :in-reply-to:message-id:mime-version:references:subject:to
 :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
 fm1; bh=flzSd38kca61I2uCe+eACpu9XGpzqS6lnjyWN31WCNY=; b=tChL9qhI
 kCiPje+RZQ027Sg2jutpBP88ariuBsWOMSn9UZPMXbkH/wyz7i+d2g3aANj0uP/B
 PgXRpgmSxGmkTL5y28j/CjqJGUPBHu4Y2t8rRWMfNzgc7mZpSAo5JubmI7geFdxG
 YCkESn0rBvvrm7Q74zGXvLEl6thbnQ0LhZmF5At9vhPzwhTrpYprU8c2VVh7askb
 lfsW7vUyV3ve7JqFQisAplfLoatt7eYOVqvV7GG6axBar9aSuXtRUS/gKInkuezB
 P0TjyqTfyDuUETTBHi3ddVB8fHC3dPSOmjA0cmH472y9vWRVPOh9kEXjXBmASFT8
 sSF9oH1b2uAEGA==
X-ME-Sender: <xms:HYq4XcCu7LejfzJrhO17DpY8el8FYXaqyWc5PtbZA2R6-uBf6Fn8JA>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedruddtuddgudduiecutefuodetggdotefrod
 ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh
 necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd
 enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm
 rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc
 fkphepjeejrddufeegrddvtdefrddukeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpeht
 hhhomhgrshesmhhonhhjrghlohhnrdhnvghtnecuvehluhhsthgvrhfuihiivgepvd
X-ME-Proxy: <xmx:HYq4Xajlfm7VNWS1novjCjcCPNQoYhki_JG1yr7e4KCpKqqechBFdA>
 <xmx:HYq4XRwJAPiKhZ_QItRNmi-ROEUvPXNlM_Q3nM2G764RoZTl0rc4bw>
 <xmx:HYq4XT3ptoD5Y_Zn71L8geGdQSn-VQOamuSHW70foUu9Qd1gjgNd2Q>
 <xmx:HYq4XTn3iWS-y8unEppUulzBXvlApjz-6aqQ-WKLLf5PXNefXKv3kQ>
Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id BD6DED60065;
 Tue, 29 Oct 2019 14:51:08 -0400 (EDT)
From: Thomas Monjalon <thomas@monjalon.net>
To: Ferruh Yigit <ferruh.yigit@intel.com>,
 Andrew Rybchenko <arybchenko@solarflare.com>
Cc: dev@dpdk.org
Date: Tue, 29 Oct 2019 19:50:50 +0100
Message-Id: <20191029185051.32203-3-thomas@monjalon.net>
X-Mailer: git-send-email 2.23.0
In-Reply-To: <20191029185051.32203-1-thomas@monjalon.net>
References: <4165509.5enYigmRGf@xps>
 <20191029185051.32203-1-thomas@monjalon.net>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v2 2/3] ethdev: set VF MAC address from host
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

The API to set a default MAC address is extended
to support a VF ID as port ID.
In order to be supported by a driver,
the related vf_ops must be implemented.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ethdev/rte_ethdev.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index fb3da4dcc3..9cf82ff10b 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3386,20 +3386,23 @@ int
 rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr)
 {
 	struct rte_eth_dev *dev;
+	bool vf; /* true if port_id targets a connected VF */
 	int ret;
 
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_ID_OR_ERR_RET(port_id, -ENODEV);
 
 	if (!rte_is_valid_assigned_ether_addr(addr))
 		return -EINVAL;
 
+	port_id = port_id_parse(port_id, &vf);
 	dev = &rte_eth_devices[port_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
-
-	ret = (*dev->dev_ops->mac_addr_set)(dev, addr);
+	ret = ETH_DEV_OP_CALL(dev, vf, mac_addr_set, addr);
 	if (ret < 0)
 		return ret;
 
+	if (vf)
+		return 0;
+
 	/* Update default address in NIC data structure */
 	rte_ether_addr_copy(addr, &dev->data->mac_addrs[0]);
 
-- 
2.23.0