From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <liang-min.wang@intel.com>
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id 54E1FC34E
 for <dev@dpdk.org>; Thu, 16 Jul 2015 15:25:45 +0200 (CEST)
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by fmsmga102.fm.intel.com with ESMTP; 16 Jul 2015 06:25:45 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.15,488,1432623600"; d="scan'208";a="748561701"
Received: from lwang14-mobl6.amr.corp.intel.com ([10.127.188.51])
 by fmsmga001.fm.intel.com with ESMTP; 16 Jul 2015 06:25:44 -0700
From: Liang-Min Larry Wang <liang-min.wang@intel.com>
To: dev@dpdk.org
Date: Thu, 16 Jul 2015 09:25:33 -0400
Message-Id: <1437053137-10460-2-git-send-email-liang-min.wang@intel.com>
X-Mailer: git-send-email 2.1.4
In-Reply-To: <1437053137-10460-1-git-send-email-liang-min.wang@intel.com>
References: <1432946276-9424-1-git-send-email-liang-min.wang@intel.com>
 <1437053137-10460-1-git-send-email-liang-min.wang@intel.com>
Cc: Liang-Min Larry Wang <liang-min.wang@intel.com>
Subject: [dpdk-dev] [PATCH v17 1/5] ethdev: add api to support setting
	default mac addr
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 16 Jul 2015 13:25:45 -0000

add new api:
- rte_eth_dev_default_mac_addr_set

the new api, rte_eth_dev_default_mac_addr_set, uses the
existing dev_op, mac_addr_set, to enable setting mac
addr from ethdev level.

Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
---
 lib/librte_ether/rte_ethdev.c          | 21 +++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h          | 16 ++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 3 files changed, 38 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ddf3658..a809718 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2542,6 +2542,27 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
 }
 
 int
+rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
+{
+	struct rte_eth_dev *dev;
+
+	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+	if (!is_valid_assigned_ether_addr(addr))
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port_id];
+	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
+
+	/* Update default address in NIC data structure */
+	ether_addr_copy(addr, &dev->data->mac_addrs[0]);
+
+	(*dev->dev_ops->mac_addr_set)(dev, addr);
+
+	return 0;
+}
+
+int
 rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
 				uint16_t rx_mode, uint8_t on)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d76bbb3..57ad653 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3021,6 +3021,22 @@ int rte_eth_dev_mac_addr_add(uint8_t port, struct ether_addr *mac_addr,
 int rte_eth_dev_mac_addr_remove(uint8_t port, struct ether_addr *mac_addr);
 
 /**
+ * Set the default MAC address.
+ *
+ * @param port
+ *   The port identifier of the Ethernet device.
+ * @param mac_addr
+ *   New default MAC address.
+ * @return
+ *   - (0) if successful, or *mac_addr* didn't exist.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if MAC address is invalid.
+ */
+int rte_eth_dev_default_mac_addr_set(uint8_t port, struct ether_addr *mac_addr);
+
+
+/**
  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
  *
  * @param port
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 39baf11..3c6cca8 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -109,6 +109,7 @@ DPDK_2.0 {
 DPDK_2.1 {
 	global:
 
+	rte_eth_dev_default_mac_addr_set;
 	rte_eth_dev_set_mc_addr_list;
 	rte_eth_timesync_disable;
 	rte_eth_timesync_enable;
-- 
2.1.4