Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 170435
b: refs/heads/master
c: 0acb6fd
h: refs/heads/master
i:
  170433: 1d5c682
  170431: fea1266
v: v3
  • Loading branch information
Alexander Duyck authored and David S. Miller committed Oct 6, 2009
1 parent 6f57389 commit f027253
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 747d49baaf4e3f4ad5ae77477830da026eeef69d
refs/heads/master: 0acb6fde5fc84009be1c7efc0aaa8e69e394a2e2
63 changes: 34 additions & 29 deletions trunk/drivers/net/igb/e1000_mbx.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,30 @@ static s32 igb_check_for_rst_pf(struct e1000_hw *hw, u16 vf_number)
return ret_val;
}

/**
* igb_obtain_mbx_lock_pf - obtain mailbox lock
* @hw: pointer to the HW structure
* @vf_number: the VF index
*
* return SUCCESS if we obtained the mailbox lock
**/
static s32 igb_obtain_mbx_lock_pf(struct e1000_hw *hw, u16 vf_number)
{
s32 ret_val = -E1000_ERR_MBX;
u32 p2v_mailbox;


/* Take ownership of the buffer */
wr32(E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_PFU);

/* reserve mailbox for vf use */
p2v_mailbox = rd32(E1000_P2VMAILBOX(vf_number));
if (p2v_mailbox & E1000_P2VMAILBOX_PFU)
ret_val = 0;

return ret_val;
}

/**
* igb_write_mbx_pf - Places a message in the mailbox
* @hw: pointer to the HW structure
Expand All @@ -316,27 +340,17 @@ static s32 igb_check_for_rst_pf(struct e1000_hw *hw, u16 vf_number)
static s32 igb_write_mbx_pf(struct e1000_hw *hw, u32 *msg, u16 size,
u16 vf_number)
{
u32 p2v_mailbox;
s32 ret_val = 0;
s32 ret_val;
u16 i;

/* Take ownership of the buffer */
wr32(E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_PFU);

/* Make sure we have ownership now... */
p2v_mailbox = rd32(E1000_P2VMAILBOX(vf_number));
if (!(p2v_mailbox & E1000_P2VMAILBOX_PFU)) {
/* failed to grab ownership */
ret_val = -E1000_ERR_MBX;
/* lock the mailbox to prevent pf/vf race condition */
ret_val = igb_obtain_mbx_lock_pf(hw, vf_number);
if (ret_val)
goto out_no_write;
}

/*
* flush any ack or msg which may already be in the queue
* as they are likely the result of an error
*/
igb_check_for_ack_pf(hw, vf_number);
/* flush msg and acks as we are overwriting the message buffer */
igb_check_for_msg_pf(hw, vf_number);
igb_check_for_ack_pf(hw, vf_number);

/* copy the caller specified message to the mailbox memory buffer */
for (i = 0; i < size; i++)
Expand Down Expand Up @@ -367,20 +381,13 @@ static s32 igb_write_mbx_pf(struct e1000_hw *hw, u32 *msg, u16 size,
static s32 igb_read_mbx_pf(struct e1000_hw *hw, u32 *msg, u16 size,
u16 vf_number)
{
u32 p2v_mailbox;
s32 ret_val = 0;
s32 ret_val;
u16 i;

/* Take ownership of the buffer */
wr32(E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_PFU);

/* Make sure we have ownership now... */
p2v_mailbox = rd32(E1000_P2VMAILBOX(vf_number));
if (!(p2v_mailbox & E1000_P2VMAILBOX_PFU)) {
/* failed to grab ownership */
ret_val = -E1000_ERR_MBX;
/* lock the mailbox to prevent pf/vf race condition */
ret_val = igb_obtain_mbx_lock_pf(hw, vf_number);
if (ret_val)
goto out_no_read;
}

/* copy the message to the mailbox memory buffer */
for (i = 0; i < size; i++)
Expand All @@ -392,8 +399,6 @@ static s32 igb_read_mbx_pf(struct e1000_hw *hw, u32 *msg, u16 size,
/* update stats */
hw->mbx.stats.msgs_rx++;

ret_val = 0;

out_no_read:
return ret_val;
}
Expand Down

0 comments on commit f027253

Please sign in to comment.