Thread (5 messages) 5 messages, 2 authors, 10d ago

Re: [PATCH net] octeontx2-pf: check DMAC extraction support before filtering

From: Harshitha Ramamurthy <hramamurthy@google.com>
Date: 2026-06-25 21:29:00
Also in: lkml

On Thu, Jun 25, 2026 at 10:30 AM [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Suman Ghosh <redacted>

Currently, configuring a VF MAC address via the PF (e.g., 'ip link
set <pf> vf 0 mac <mac>') blindly attempts to install a DMAC-based
hardware filter. However, the hardware parser profile might not
support DMAC extraction.

Check if the hardware parsing profile supports DMAC extraction
before adding the filter. Additionally, emit a warning message
to inform the operator if the MAC filter installation fails due
to missing DMAC extraction support.

Fixes: f0c2982aaf98 ("octeontx2-pf: Add support for SR-IOV management functions")
Signed-off-by: Suman Ghosh <redacted>
Signed-off-by: Nitin Shetty J <redacted>
---
 .../ethernet/marvell/octeontx2/nic/otx2_pf.c  | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index b63df5737ff2..8e4435d9e520 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -2546,6 +2546,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;
@@ -2559,6 +2561,38 @@ static int otx2_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
        if (!is_valid_ether_addr(mac))
                return -EINVAL;

+       /* Skip installing the DMAC filter if the hardware parser profile
+        * does not support DMAC extraction.
+        */
+       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;
+       if (otx2_sync_mbox_msg(&pf->mbox)) {
+               mutex_unlock(&pf->mbox.lock);
+               return -EINVAL;
+       }
+
+       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);
+       }
+
+       if (!rsp->enable) {
+               mutex_unlock(&pf->mbox.lock);
+               netdev_warn(netdev, "VF %d MAC filter not installed: DMAC extraction not supported by parser profile\n",
+                           vf);
+               return 0;
Is the intent to return success here even though the MAC address was
not programmed?
+       }
+
+       mutex_unlock(&pf->mbox.lock);
+
Why not move all these checks into the otx2_do_set_vf_mac() since that
anyway acquires the pf->mbox.lock? That way you could also fold all
the mutex_unlock() calls introduced in the error paths in this patch
into the existing goto-out in that function.
        config = &pf->vf_configs[vf];
        ether_addr_copy(config->mac, mac);

--
2.48.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help