netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next PATCH] octeontx2-pf: Check for DMAC extraction before setting VF DMAC
@ 2025-06-25 11:30 Subbaraya Sundeep
  2025-06-25 19:02 ` Simon Horman
  2025-06-27 23:59 ` Jakub Kicinski
  0 siblings, 2 replies; 5+ messages in thread
From: Subbaraya Sundeep @ 2025-06-25 11:30 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, sgoutham, gakula,
	hkelam, bbhushan2
  Cc: netdev, Suman Ghosh, Subbaraya Sundeep

From: Suman Ghosh <sumang@marvell.com>

Currently while setting a MAC address of a PF's VF (e.g. ip link set
<pf-netdev> vf 0 mac <mac-address>), it simply tries to install a DMAC
based hardware filter. But it is possible that the loaded hardware parser
profile does not support DMAC extraction. Hence check for DMAC extraction
before installing the filter.

Signed-off-by: Suman Ghosh <sumang@marvell.com>
Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
---
 .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c   | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index 4e2d120..c8c9cf6 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -2559,6 +2559,8 @@ static int otx2_do_set_vf_mac(struct otx2_nic *pf, int vf, const u8 *mac)
 static int otx2_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
 {
 	struct otx2_nic *pf = netdev_priv(netdev);
+	struct npc_get_field_status_req *req;
+	struct npc_get_field_status_rsp *rsp;
 	struct pci_dev *pdev = pf->pdev;
 	struct otx2_vf_config *config;
 	int ret;
@@ -2572,6 +2574,35 @@ static int otx2_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
 	if (!is_valid_ether_addr(mac))
 		return -EINVAL;
 
+	/* Check if NPC_DMAC feature is set in NPC. If not set then
+	 * return from the function.
+	 */
+	mutex_lock(&pf->mbox.lock);
+	req = otx2_mbox_alloc_msg_npc_get_field_status(&pf->mbox);
+	if (!req) {
+		mutex_unlock(&pf->mbox.lock);
+		return -ENOMEM;
+	}
+
+	req->field = NPC_DMAC;
+	ret = otx2_sync_mbox_msg(&pf->mbox);
+	if (ret) {
+		mutex_unlock(&pf->mbox.lock);
+		return ret;
+	}
+
+	rsp = (struct npc_get_field_status_rsp *)otx2_mbox_get_rsp
+	       (&pf->mbox.mbox, 0, &req->hdr);
+	if (IS_ERR(rsp)) {
+		mutex_unlock(&pf->mbox.lock);
+		return PTR_ERR(rsp);
+	}
+
+	mutex_unlock(&pf->mbox.lock);
+
+	if (!rsp->enable)
+		return 0;
+
 	config = &pf->vf_configs[vf];
 	ether_addr_copy(config->mac, mac);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-27 23:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 11:30 [net-next PATCH] octeontx2-pf: Check for DMAC extraction before setting VF DMAC Subbaraya Sundeep
2025-06-25 19:02 ` Simon Horman
2025-06-26  6:23   ` Subbaraya Sundeep
2025-06-26  7:25     ` Simon Horman
2025-06-27 23:59 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).