Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 328026
b: refs/heads/master
c: 3118678
h: refs/heads/master
v: v3
  • Loading branch information
Alexander Duyck authored and Jeff Kirsher committed Sep 20, 2012
1 parent 58cc694 commit c8f5e6b
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 3 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: e5461112d993b5038954554b5c871d14e45ecc5c
refs/heads/master: 31186785186415eaf2b66025969d2364a07c9e83
1 change: 1 addition & 0 deletions trunk/drivers/net/ethernet/intel/ixgbevf/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,6 @@ struct ixgbe_adv_tx_context_desc {
/* Error Codes */
#define IXGBE_ERR_INVALID_MAC_ADDR -1
#define IXGBE_ERR_RESET_FAILED -2
#define IXGBE_ERR_INVALID_ARGUMENT -3

#endif /* _IXGBEVF_DEFINES_H_ */
23 changes: 23 additions & 0 deletions trunk/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,25 @@ static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
adapter->stats.base_vfmprc = adapter->stats.last_vfmprc;
}

static void ixgbevf_negotiate_api(struct ixgbevf_adapter *adapter)
{
struct ixgbe_hw *hw = &adapter->hw;
int api[] = { ixgbe_mbox_api_10,
ixgbe_mbox_api_unknown };
int err = 0, idx = 0;

spin_lock(&adapter->mbx_lock);

while (api[idx] != ixgbe_mbox_api_unknown) {
err = ixgbevf_negotiate_api_version(hw, api[idx]);
if (!err)
break;
idx++;
}

spin_unlock(&adapter->mbx_lock);
}

static void ixgbevf_up_complete(struct ixgbevf_adapter *adapter)
{
struct net_device *netdev = adapter->netdev;
Expand Down Expand Up @@ -1399,6 +1418,8 @@ void ixgbevf_up(struct ixgbevf_adapter *adapter)
{
struct ixgbe_hw *hw = &adapter->hw;

ixgbevf_negotiate_api(adapter);

ixgbevf_configure(adapter);

ixgbevf_up_complete(adapter);
Expand Down Expand Up @@ -2388,6 +2409,8 @@ static int ixgbevf_open(struct net_device *netdev)
}
}

ixgbevf_negotiate_api(adapter);

/* allocate transmit descriptors */
err = ixgbevf_setup_all_tx_resources(adapter);
if (err)
Expand Down
21 changes: 19 additions & 2 deletions trunk/drivers/net/ethernet/intel/ixgbevf/mbx.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,29 @@
/* bits 23:16 are used for exra info for certain messages */
#define IXGBE_VT_MSGINFO_MASK (0xFF << IXGBE_VT_MSGINFO_SHIFT)

/* definitions to support mailbox API version negotiation */

/*
* each element denotes a version of the API; existing numbers may not
* change; any additions must go at the end
*/
enum ixgbe_pfvf_api_rev {
ixgbe_mbox_api_10, /* API version 1.0, linux/freebsd VF driver */
ixgbe_mbox_api_20, /* API version 2.0, solaris Phase1 VF driver */
/* This value should always be last */
ixgbe_mbox_api_unknown, /* indicates that API version is not known */
};

/* mailbox API, legacy requests */
#define IXGBE_VF_RESET 0x01 /* VF requests reset */
#define IXGBE_VF_SET_MAC_ADDR 0x02 /* VF requests PF to set MAC addr */
#define IXGBE_VF_SET_MULTICAST 0x03 /* VF requests PF to set MC addr */
#define IXGBE_VF_SET_VLAN 0x04 /* VF requests PF to set VLAN */
#define IXGBE_VF_SET_LPE 0x05 /* VF requests PF to set VMOLR.LPE */
#define IXGBE_VF_SET_MACVLAN 0x06 /* VF requests PF for unicast filter */

/* mailbox API, version 1.0 VF requests */
#define IXGBE_VF_SET_LPE 0x05 /* VF requests PF to set VMOLR.LPE */
#define IXGBE_VF_SET_MACVLAN 0x06 /* VF requests PF for unicast filter */
#define IXGBE_VF_API_NEGOTIATE 0x08 /* negotiate API version */

/* length of permanent address message returned from PF */
#define IXGBE_VF_PERMADDR_MSG_LEN 4
Expand Down
37 changes: 37 additions & 0 deletions trunk/drivers/net/ethernet/intel/ixgbevf/vf.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw)
/* Call adapter stop to disable tx/rx and clear interrupts */
hw->mac.ops.stop_adapter(hw);

/* reset the api version */
hw->api_version = ixgbe_mbox_api_10;

IXGBE_WRITE_REG(hw, IXGBE_VFCTRL, IXGBE_CTRL_RST);
IXGBE_WRITE_FLUSH(hw);

Expand Down Expand Up @@ -433,6 +436,40 @@ void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size)
ixgbevf_write_msg_read_ack(hw, msgbuf, 2);
}

/**
* ixgbevf_negotiate_api_version - Negotiate supported API version
* @hw: pointer to the HW structure
* @api: integer containing requested API version
**/
int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api)
{
int err;
u32 msg[3];

/* Negotiate the mailbox API version */
msg[0] = IXGBE_VF_API_NEGOTIATE;
msg[1] = api;
msg[2] = 0;
err = hw->mbx.ops.write_posted(hw, msg, 3);

if (!err)
err = hw->mbx.ops.read_posted(hw, msg, 3);

if (!err) {
msg[0] &= ~IXGBE_VT_MSGTYPE_CTS;

/* Store value and return 0 on success */
if (msg[0] == (IXGBE_VF_API_NEGOTIATE | IXGBE_VT_MSGTYPE_ACK)) {
hw->api_version = api;
return 0;
}

err = IXGBE_ERR_INVALID_ARGUMENT;
}

return err;
}

static const struct ixgbe_mac_operations ixgbevf_mac_ops = {
.init_hw = ixgbevf_init_hw_vf,
.reset_hw = ixgbevf_reset_hw_vf,
Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/net/ethernet/intel/ixgbevf/vf.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ struct ixgbe_hw {

u8 revision_id;
bool adapter_stopped;

int api_version;
};

struct ixgbevf_hw_stats {
Expand Down Expand Up @@ -171,5 +173,6 @@ struct ixgbevf_info {
};

void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api);
#endif /* __IXGBE_VF_H__ */

0 comments on commit c8f5e6b

Please sign in to comment.