diff --git a/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
index 979e3b150..8da471f02 100644
--- a/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
+++ b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
@@ -613,6 +613,10 @@ void xsc_core_frag_buf_free(struct xsc_core_device *xdev, struct xsc_frag_buf *b
 int xsc_register_interface(struct xsc_interface *intf);
 void xsc_unregister_interface(struct xsc_interface *intf);
 
+u8 xsc_core_query_vport_state(struct xsc_core_device *dev, u16 vport);
+int xsc_core_modify_nic_vport_mac_address(struct xsc_core_device *dev,
+					  u16 vport, u8 *addr, bool perm_mac);
+
 static inline void *xsc_buf_offset(struct xsc_buf *buf, int offset)
 {
 	if (likely(BITS_PER_LONG == 64 || buf->nbufs == 1))
diff --git a/drivers/net/ethernet/yunsilicon/xsc/net/main.c b/drivers/net/ethernet/yunsilicon/xsc/net/main.c
index a3b557cc5..1861b10a8 100644
--- a/drivers/net/ethernet/yunsilicon/xsc/net/main.c
+++ b/drivers/net/ethernet/yunsilicon/xsc/net/main.c
@@ -1349,37 +1349,13 @@ static void xsc_eth_sw_deinit(struct xsc_adapter *adapter)
 	return xsc_eth_close_channels(adapter);
 }
 
-static int _xsc_query_vport_state(struct xsc_core_device *dev, u16 opmod,
-				  u16 vport, void *out, int outlen)
-{
-	struct xsc_query_vport_state_in in;
-
-	memset(&in, 0, sizeof(in));
-	in.hdr.opcode = cpu_to_be16(XSC_CMD_OP_QUERY_VPORT_STATE);
-	in.vport_number = cpu_to_be16(vport);
-	if (vport)
-		in.other_vport = 1;
-
-	return xsc_cmd_exec(dev, &in, sizeof(in), out, outlen);
-}
-
-static u8 xsc_query_vport_state(struct xsc_core_device *dev, u16 opmod, u16 vport)
-{
-	struct xsc_query_vport_state_out out;
-
-	memset(&out, 0, sizeof(out));
-	_xsc_query_vport_state(dev, opmod, vport, &out, sizeof(out));
-
-	return out.state;
-}
-
 static bool xsc_eth_get_link_status(struct xsc_adapter *adapter)
 {
 	bool link_up;
 	struct xsc_core_device *xdev = adapter->xdev;
 	u16 vport = 0;
 
-	link_up = xsc_query_vport_state(xdev, XSC_CMD_OP_QUERY_VPORT_STATE, vport);
+	link_up = xsc_core_query_vport_state(xdev, vport);
 
 	xsc_core_dbg(adapter->xdev, "link_status=%d\n", link_up);
 
@@ -1668,11 +1644,33 @@ static void xsc_eth_get_stats(struct net_device *netdev, struct rtnl_link_stats6
 	xsc_eth_fold_sw_stats64(adapter, stats);
 }
 
+static int xsc_eth_set_mac(struct net_device *netdev, void *addr)
+{
+	struct xsc_adapter *adapter = netdev_priv(netdev);
+	struct sockaddr *saddr = addr;
+	struct xsc_core_device *xdev = adapter->xdev;
+	int ret;
+
+	if (!is_valid_ether_addr(saddr->sa_data))
+		return -EADDRNOTAVAIL;
+
+	ret = xsc_core_modify_nic_vport_mac_address(xdev, 0, saddr->sa_data, false);
+	if (ret)
+		xsc_core_err(adapter->xdev, "%s: xsc set mac addr failed\n", __func__);
+
+	netif_addr_lock_bh(netdev);
+	eth_hw_addr_set(netdev, saddr->sa_data);
+	netif_addr_unlock_bh(netdev);
+
+	return 0;
+}
+
 static const struct net_device_ops xsc_netdev_ops = {
 	.ndo_open		= xsc_eth_open,
 	.ndo_stop		= xsc_eth_close,
 	.ndo_start_xmit		= xsc_eth_xmit_start,
 	.ndo_get_stats64	= xsc_eth_get_stats,
+	.ndo_set_mac_address	= xsc_eth_set_mac,
 };
 
 static void xsc_eth_build_nic_netdev(struct xsc_adapter *adapter)
diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile b/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
index 7c185e164..5c3d5624e 100644
--- a/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
+++ b/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
@@ -6,5 +6,5 @@ ccflags-y += -I$(srctree)/drivers/net/ethernet/yunsilicon/xsc
 
 obj-$(CONFIG_YUNSILICON_XSC_PCI) += xsc_pci.o
 
-xsc_pci-y := main.o cmdq.o hw.o qp.o cq.o alloc.o eq.o pci_irq.o intf.o
+xsc_pci-y := main.o cmdq.o hw.o qp.o cq.o alloc.o eq.o pci_irq.o intf.o vport.o
 
diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/vport.c b/drivers/net/ethernet/yunsilicon/xsc/pci/vport.c
new file mode 100644
index 000000000..82db21eb8
--- /dev/null
+++ b/drivers/net/ethernet/yunsilicon/xsc/pci/vport.c
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2021 - 2023, Shanghai Yunsilicon Technology Co., Ltd.
+ * All rights reserved.
+ */
+
+#include "common/xsc_core.h"
+#include "common/xsc_driver.h"
+
+#define LAG_ID_INVALID		U16_MAX
+
+u8 xsc_core_query_vport_state(struct xsc_core_device *xdev, u16 vport)
+{
+	struct xsc_query_vport_state_in in;
+	struct xsc_query_vport_state_out out;
+	int err;
+
+	memset(&in, 0, sizeof(in));
+	memset(&out, 0, sizeof(out));
+
+	in.hdr.opcode = cpu_to_be16(XSC_CMD_OP_QUERY_VPORT_STATE);
+	in.vport_number = cpu_to_be16(vport);
+	if (vport)
+		in.other_vport = 1;
+
+	err = xsc_cmd_exec(xdev, &in, sizeof(in), &out, sizeof(out));
+	if (err || out.hdr.status)
+		xsc_core_err(xdev, "failed to query vport state, err=%d, status=%d\n",
+			     err, out.hdr.status);
+
+	return out.state;
+}
+EXPORT_SYMBOL(xsc_core_query_vport_state);
+
+static int xsc_modify_nic_vport_context(struct xsc_core_device *dev, void *in,
+					int inlen)
+{
+	struct xsc_modify_nic_vport_context_out out;
+	struct xsc_modify_nic_vport_context_in *tmp;
+	int err;
+
+	memset(&out, 0, sizeof(out));
+	tmp = (struct xsc_modify_nic_vport_context_in *)in;
+	tmp->hdr.opcode = cpu_to_be16(XSC_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
+
+	err = xsc_cmd_exec(dev, in, inlen, &out, sizeof(out));
+	if (err || out.hdr.status) {
+		xsc_core_err(dev, "fail to modify nic vport err=%d status=%d\n",
+			     err, out.hdr.status);
+	}
+	return err;
+}
+
+static int __xsc_modify_nic_vport_mac_address(struct xsc_core_device *dev,
+					      u16 vport, u8 *addr, int force_other, bool perm_mac)
+{
+	struct xsc_modify_nic_vport_context_in *in;
+	int err;
+	int in_sz;
+	u8 *mac_addr;
+	u16 caps = 0;
+	u16 caps_mask = 0;
+	u16 lag_id = LAG_ID_INVALID;
+
+	in_sz = sizeof(struct xsc_modify_nic_vport_context_in) + 2;
+
+	in = kzalloc(in_sz, GFP_KERNEL);
+	if (!in)
+		return -ENOMEM;
+
+	in->lag_id = cpu_to_be16(lag_id);
+
+	if (perm_mac) {
+		in->field_select.permanent_address = 1;
+		mac_addr = in->nic_vport_ctx.permanent_address;
+	} else {
+		in->field_select.current_address = 1;
+		mac_addr = in->nic_vport_ctx.current_address;
+	}
+
+	caps_mask |= BIT(XSC_TBM_CAP_PP_BYPASS);
+	in->caps = cpu_to_be16(caps);
+	in->caps_mask = cpu_to_be16(caps_mask);
+
+	ether_addr_copy(mac_addr, addr);
+
+	in->field_select.addresses_list = 1;
+	in->nic_vport_ctx.vlan_allowed = 0;
+
+	err = xsc_modify_nic_vport_context(dev, in, in_sz);
+	if (err)
+		xsc_core_err(dev, "modify nic vport context failed\n");
+
+	kfree(in);
+	return err;
+}
+
+int xsc_core_modify_nic_vport_mac_address(struct xsc_core_device *dev,
+					  u16 vport, u8 *addr, bool perm_mac)
+{
+	return __xsc_modify_nic_vport_mac_address(dev, vport, addr, 0, perm_mac);
+}
+EXPORT_SYMBOL(xsc_core_modify_nic_vport_mac_address);
