drivers/net/ethernet/intel/ixgbevf/mbx.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ixgbevf/mbx.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/intel/ixgbevf/mbx.c
Extension
.c
Size
12688 bytes
Lines
508
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (ixgbevf_read_mailbox_vf(hw) & IXGBE_VFMAILBOX_VFU) {
			ret_val = 0;
			break;
		}

		/* Wait a bit before trying again */
		udelay(mbx->udelay);
	}

	if (ret_val)
		ret_val = IXGBE_ERR_TIMEOUT;

	return ret_val;
}

/**
 * ixgbevf_release_mbx_lock_vf - release mailbox lock
 * @hw: pointer to the HW structure
 **/
static void ixgbevf_release_mbx_lock_vf(struct ixgbe_hw *hw)
{
	u32 vf_mailbox;

	/* Return ownership of the buffer */
	vf_mailbox = ixgbevf_read_mailbox_vf(hw);
	vf_mailbox &= ~IXGBE_VFMAILBOX_VFU;
	IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, vf_mailbox);
}

/**
 * ixgbevf_release_mbx_lock_vf_legacy - release mailbox lock
 * @hw: pointer to the HW structure
 **/
static void ixgbevf_release_mbx_lock_vf_legacy(struct ixgbe_hw *__always_unused hw)
{
}

/**
 *  ixgbevf_write_mbx_vf - Write a message to the mailbox
 *  @hw: pointer to the HW structure
 *  @msg: The message buffer
 *  @size: Length of buffer
 *
 *  returns 0 if it successfully copied message into the buffer
 **/
static s32 ixgbevf_write_mbx_vf(struct ixgbe_hw *hw, u32 *msg, u16 size)
{
	u32 vf_mailbox;
	s32 ret_val;
	u16 i;

	/* lock the mailbox to prevent PF/VF race condition */
	ret_val = ixgbevf_obtain_mbx_lock_vf(hw);
	if (ret_val)
		goto out_no_write;

	/* flush msg and acks as we are overwriting the message buffer */
	ixgbevf_clear_msg_vf(hw);
	ixgbevf_clear_ack_vf(hw);

	/* copy the caller specified message to the mailbox memory buffer */
	for (i = 0; i < size; i++)
		IXGBE_WRITE_REG_ARRAY(hw, IXGBE_VFMBMEM, i, msg[i]);

	/* update stats */
	hw->mbx.stats.msgs_tx++;

	/* interrupt the PF to tell it a message has been sent */
	vf_mailbox = ixgbevf_read_mailbox_vf(hw);
	vf_mailbox |= IXGBE_VFMAILBOX_REQ;
	IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, vf_mailbox);

	/* if msg sent wait until we receive an ack */
	ret_val = ixgbevf_poll_for_ack(hw);

out_no_write:
	hw->mbx.ops.release(hw);

	return ret_val;
}

/**
 *  ixgbevf_write_mbx_vf_legacy - Write a message to the mailbox
 *  @hw: pointer to the HW structure
 *  @msg: The message buffer
 *  @size: Length of buffer
 *
 *  returns 0 if it successfully copied message into the buffer
 **/
static s32 ixgbevf_write_mbx_vf_legacy(struct ixgbe_hw *hw, u32 *msg, u16 size)

Annotation

Implementation Notes