octeontx2-af: add new mailbox to configure VF trust mode
[platform/kernel/linux-starfive.git] / drivers / net / ethernet / marvell / octeontx2 / af / rvu_npc_fs.c
index bc37858..6ba6a83 100644 (file)
@@ -1103,9 +1103,11 @@ find_rule:
        if (pf_set_vfs_mac) {
                ether_addr_copy(pfvf->default_mac, req->packet.dmac);
                ether_addr_copy(pfvf->mac_addr, req->packet.dmac);
+               set_bit(PF_SET_VF_MAC, &pfvf->flags);
        }
 
-       if (pfvf->pf_set_vf_cfg && req->vtag0_type == NIX_AF_LFX_RX_VTAG_TYPE7)
+       if (test_bit(PF_SET_VF_CFG, &pfvf->flags) &&
+           req->vtag0_type == NIX_AF_LFX_RX_VTAG_TYPE7)
                rule->vfvlan_cfg = true;
 
        return 0;
@@ -1167,7 +1169,7 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
 
        /* PF installing for its VF */
        if (req->hdr.pcifunc && !from_vf && req->vf)
-               pfvf->pf_set_vf_cfg = 1;
+               set_bit(PF_SET_VF_CFG, &pfvf->flags);
 
        /* update req destination mac addr */
        if ((req->features & BIT_ULL(NPC_DMAC)) && is_npc_intf_rx(req->intf) &&
@@ -1177,7 +1179,7 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
        }
 
        err = nix_get_nixlf(rvu, target, &nixlf, NULL);
-       if (err)
+       if (err && is_npc_intf_rx(req->intf) && !pf_set_vfs_mac)
                return -EINVAL;
 
        /* don't enable rule when nixlf not attached or initialized */
@@ -1196,6 +1198,14 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
        if (from_vf && !enable)
                return -EINVAL;
 
+       /* PF sets VF mac & VF NIXLF is not attached, update the mac addr */
+       if (pf_set_vfs_mac && !enable) {
+               ether_addr_copy(pfvf->default_mac, req->packet.dmac);
+               ether_addr_copy(pfvf->mac_addr, req->packet.dmac);
+               set_bit(PF_SET_VF_MAC, &pfvf->flags);
+               return 0;
+       }
+
        /* If message is from VF then its flow should not overlap with
         * reserved unicast flow.
         */