Skip to content

Commit 8c84c5e

Browse files
WeiFang-NXPkuba-moo
authored andcommitted
net: enetc: fix incorrect mailbox message status returned to VFs
There are two cases where VFs receive an incorrect success status from the PF mailbox message handler, misleading them into believing their requests have been fulfilled: In enetc_msg_handle_rxmsg(), *status is pre-initialized to ENETC_MSG_CMD_STATUS_OK. When an unsupported command type is received, the default case only logs an error without updating *status, so it remains as ENETC_MSG_CMD_STATUS_OK. In enetc_msg_pf_set_vf_primary_mac_addr(), when the PF has already assigned a MAC address for the VF (ENETC_VF_FLAG_PF_SET_MAC is set), the function rejects the request but returns ENETC_MSG_CMD_STATUS_OK instead of ENETC_MSG_CMD_STATUS_FAIL. Therefore, correct the status value for the two cases mentioned above. Fixes: beb74ac ("enetc: Add vf to pf messaging support") Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com> Link: https://patch.msgid.link/20260520064421.91569-2-wei.fang@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent bdd3957 commit 8c84c5e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/net/ethernet/freescale/enetc/enetc_pf.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,13 @@ static u16 enetc_msg_pf_set_vf_primary_mac_addr(struct enetc_pf *pf,
493493
return ENETC_MSG_CMD_STATUS_FAIL;
494494

495495
addr = cmd->mac.sa_data;
496-
if (vf_state->flags & ENETC_VF_FLAG_PF_SET_MAC)
496+
if (vf_state->flags & ENETC_VF_FLAG_PF_SET_MAC) {
497497
dev_warn(dev, "Attempt to override PF set mac addr for VF%d\n",
498498
vf_id);
499-
else
500-
enetc_pf_set_primary_mac_addr(&pf->si->hw, vf_id + 1, addr);
499+
return ENETC_MSG_CMD_STATUS_FAIL;
500+
}
501+
502+
enetc_pf_set_primary_mac_addr(&pf->si->hw, vf_id + 1, addr);
501503

502504
return ENETC_MSG_CMD_STATUS_OK;
503505
}
@@ -509,7 +511,6 @@ void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int vf_id, u16 *status)
509511
struct enetc_msg_cmd_header *cmd_hdr;
510512
u16 cmd_type;
511513

512-
*status = ENETC_MSG_CMD_STATUS_OK;
513514
cmd_hdr = (struct enetc_msg_cmd_header *)msg->vaddr;
514515
cmd_type = cmd_hdr->type;
515516

@@ -518,6 +519,7 @@ void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int vf_id, u16 *status)
518519
*status = enetc_msg_pf_set_vf_primary_mac_addr(pf, vf_id);
519520
break;
520521
default:
522+
*status = ENETC_MSG_CMD_STATUS_FAIL;
521523
dev_err(dev, "command not supported (cmd_type: 0x%x)\n",
522524
cmd_type);
523525
}

0 commit comments

Comments
 (0)