Skip to content

Commit 3118678

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
ixgbevf: Add support for VF API negotiation
This change makes it so that the VF can support the PF/VF API negotiation protocol. Specifically in this case we are adding support for API 1.0 which will mean that the VF is capable of cleaning up buffers that span multiple descriptors without triggering an error. Signed-off-by: Alexander Duyck <[email protected]> Tested-by: Sibai Li <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent e546111 commit 3118678

File tree

5 files changed

+83
-2
lines changed

5 files changed

+83
-2
lines changed

drivers/net/ethernet/intel/ixgbevf/defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,5 +272,6 @@ struct ixgbe_adv_tx_context_desc {
272272
/* Error Codes */
273273
#define IXGBE_ERR_INVALID_MAC_ADDR -1
274274
#define IXGBE_ERR_RESET_FAILED -2
275+
#define IXGBE_ERR_INVALID_ARGUMENT -3
275276

276277
#endif /* _IXGBEVF_DEFINES_H_ */

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,25 @@ static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
13341334
adapter->stats.base_vfmprc = adapter->stats.last_vfmprc;
13351335
}
13361336

1337+
static void ixgbevf_negotiate_api(struct ixgbevf_adapter *adapter)
1338+
{
1339+
struct ixgbe_hw *hw = &adapter->hw;
1340+
int api[] = { ixgbe_mbox_api_10,
1341+
ixgbe_mbox_api_unknown };
1342+
int err = 0, idx = 0;
1343+
1344+
spin_lock(&adapter->mbx_lock);
1345+
1346+
while (api[idx] != ixgbe_mbox_api_unknown) {
1347+
err = ixgbevf_negotiate_api_version(hw, api[idx]);
1348+
if (!err)
1349+
break;
1350+
idx++;
1351+
}
1352+
1353+
spin_unlock(&adapter->mbx_lock);
1354+
}
1355+
13371356
static void ixgbevf_up_complete(struct ixgbevf_adapter *adapter)
13381357
{
13391358
struct net_device *netdev = adapter->netdev;
@@ -1399,6 +1418,8 @@ void ixgbevf_up(struct ixgbevf_adapter *adapter)
13991418
{
14001419
struct ixgbe_hw *hw = &adapter->hw;
14011420

1421+
ixgbevf_negotiate_api(adapter);
1422+
14021423
ixgbevf_configure(adapter);
14031424

14041425
ixgbevf_up_complete(adapter);
@@ -2388,6 +2409,8 @@ static int ixgbevf_open(struct net_device *netdev)
23882409
}
23892410
}
23902411

2412+
ixgbevf_negotiate_api(adapter);
2413+
23912414
/* allocate transmit descriptors */
23922415
err = ixgbevf_setup_all_tx_resources(adapter);
23932416
if (err)

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,29 @@
7676
/* bits 23:16 are used for exra info for certain messages */
7777
#define IXGBE_VT_MSGINFO_MASK (0xFF << IXGBE_VT_MSGINFO_SHIFT)
7878

79+
/* definitions to support mailbox API version negotiation */
80+
81+
/*
82+
* each element denotes a version of the API; existing numbers may not
83+
* change; any additions must go at the end
84+
*/
85+
enum ixgbe_pfvf_api_rev {
86+
ixgbe_mbox_api_10, /* API version 1.0, linux/freebsd VF driver */
87+
ixgbe_mbox_api_20, /* API version 2.0, solaris Phase1 VF driver */
88+
/* This value should always be last */
89+
ixgbe_mbox_api_unknown, /* indicates that API version is not known */
90+
};
91+
92+
/* mailbox API, legacy requests */
7993
#define IXGBE_VF_RESET 0x01 /* VF requests reset */
8094
#define IXGBE_VF_SET_MAC_ADDR 0x02 /* VF requests PF to set MAC addr */
8195
#define IXGBE_VF_SET_MULTICAST 0x03 /* VF requests PF to set MC addr */
8296
#define IXGBE_VF_SET_VLAN 0x04 /* VF requests PF to set VLAN */
83-
#define IXGBE_VF_SET_LPE 0x05 /* VF requests PF to set VMOLR.LPE */
84-
#define IXGBE_VF_SET_MACVLAN 0x06 /* VF requests PF for unicast filter */
97+
98+
/* mailbox API, version 1.0 VF requests */
99+
#define IXGBE_VF_SET_LPE 0x05 /* VF requests PF to set VMOLR.LPE */
100+
#define IXGBE_VF_SET_MACVLAN 0x06 /* VF requests PF for unicast filter */
101+
#define IXGBE_VF_API_NEGOTIATE 0x08 /* negotiate API version */
85102

86103
/* length of permanent address message returned from PF */
87104
#define IXGBE_VF_PERMADDR_MSG_LEN 4

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw)
7979
/* Call adapter stop to disable tx/rx and clear interrupts */
8080
hw->mac.ops.stop_adapter(hw);
8181

82+
/* reset the api version */
83+
hw->api_version = ixgbe_mbox_api_10;
84+
8285
IXGBE_WRITE_REG(hw, IXGBE_VFCTRL, IXGBE_CTRL_RST);
8386
IXGBE_WRITE_FLUSH(hw);
8487

@@ -433,6 +436,40 @@ void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size)
433436
ixgbevf_write_msg_read_ack(hw, msgbuf, 2);
434437
}
435438

439+
/**
440+
* ixgbevf_negotiate_api_version - Negotiate supported API version
441+
* @hw: pointer to the HW structure
442+
* @api: integer containing requested API version
443+
**/
444+
int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api)
445+
{
446+
int err;
447+
u32 msg[3];
448+
449+
/* Negotiate the mailbox API version */
450+
msg[0] = IXGBE_VF_API_NEGOTIATE;
451+
msg[1] = api;
452+
msg[2] = 0;
453+
err = hw->mbx.ops.write_posted(hw, msg, 3);
454+
455+
if (!err)
456+
err = hw->mbx.ops.read_posted(hw, msg, 3);
457+
458+
if (!err) {
459+
msg[0] &= ~IXGBE_VT_MSGTYPE_CTS;
460+
461+
/* Store value and return 0 on success */
462+
if (msg[0] == (IXGBE_VF_API_NEGOTIATE | IXGBE_VT_MSGTYPE_ACK)) {
463+
hw->api_version = api;
464+
return 0;
465+
}
466+
467+
err = IXGBE_ERR_INVALID_ARGUMENT;
468+
}
469+
470+
return err;
471+
}
472+
436473
static const struct ixgbe_mac_operations ixgbevf_mac_ops = {
437474
.init_hw = ixgbevf_init_hw_vf,
438475
.reset_hw = ixgbevf_reset_hw_vf,

drivers/net/ethernet/intel/ixgbevf/vf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ struct ixgbe_hw {
137137

138138
u8 revision_id;
139139
bool adapter_stopped;
140+
141+
int api_version;
140142
};
141143

142144
struct ixgbevf_hw_stats {
@@ -171,5 +173,6 @@ struct ixgbevf_info {
171173
};
172174

173175
void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
176+
int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api);
174177
#endif /* __IXGBE_VF_H__ */
175178

0 commit comments

Comments
 (0)