Skip to content

Commit ad1431e

Browse files
Vlad ZolotarovJeff Kirsher
authored andcommitted
ixgbevf: Add RSS Key query code
Add the ixgbevf_get_rss_key() function that queries the PF for an RSS Random Key using a new VF-PF channel IXGBE_VF_GET_RSS_KEY command. This patch adds the support for 82599 and x540 devices only. Support for other devices will be added later. Signed-off-by: Vlad Zolotarov <[email protected]> Tested-by: Phil Schmitt <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 3c0841a commit ad1431e

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ struct ixgbevf_ring {
146146
#define MAX_TX_QUEUES IXGBE_VF_MAX_TX_QUEUES
147147
#define IXGBEVF_MAX_RSS_QUEUES 2
148148
#define IXGBEVF_82599_RETA_SIZE 128
149+
#define IXGBEVF_RSS_HASH_KEY_SIZE 40
149150

150151
#define IXGBEVF_DEFAULT_TXD 1024
151152
#define IXGBEVF_DEFAULT_RXD 512

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ enum ixgbe_pfvf_api_rev {
110110

111111
/* mailbox API, version 1.2 VF requests */
112112
#define IXGBE_VF_GET_RETA 0x0a /* VF request for RETA */
113+
#define IXGBE_VF_GET_RSS_KEY 0x0b /* get RSS hash key */
113114

114115
/* length of permanent address message returned from PF */
115116
#define IXGBE_VF_PERMADDR_MSG_LEN 4

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,60 @@ int ixgbevf_get_reta_locked(struct ixgbe_hw *hw, u32 *reta, int num_rx_queues)
325325
return 0;
326326
}
327327

328+
/**
329+
* ixgbevf_get_rss_key_locked - get the RSS Random Key
330+
* @hw: pointer to the HW structure
331+
* @rss_key: buffer to fill with RSS Hash Key contents.
332+
*
333+
* The "rss_key" buffer should be big enough to contain 10 registers.
334+
*
335+
* Returns: 0 on success.
336+
* if API doesn't support this operation - (-EOPNOTSUPP).
337+
*/
338+
int ixgbevf_get_rss_key_locked(struct ixgbe_hw *hw, u8 *rss_key)
339+
{
340+
int err;
341+
u32 msgbuf[IXGBE_VFMAILBOX_SIZE];
342+
343+
/* We currently support the RSS Random Key retrieval for 82599 and x540
344+
* devices only.
345+
*
346+
* Thus return an error if API doesn't support RSS Random Key retrieval
347+
* or if the operation is not supported for this device type.
348+
*/
349+
if (hw->api_version != ixgbe_mbox_api_12 ||
350+
hw->mac.type >= ixgbe_mac_X550_vf)
351+
return -EOPNOTSUPP;
352+
353+
msgbuf[0] = IXGBE_VF_GET_RSS_KEY;
354+
err = hw->mbx.ops.write_posted(hw, msgbuf, 1);
355+
356+
if (err)
357+
return err;
358+
359+
err = hw->mbx.ops.read_posted(hw, msgbuf, 11);
360+
361+
if (err)
362+
return err;
363+
364+
msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;
365+
366+
/* If the operation has been refused by a PF return -EPERM */
367+
if (msgbuf[0] == (IXGBE_VF_GET_RETA | IXGBE_VT_MSGTYPE_NACK))
368+
return -EPERM;
369+
370+
/* If we didn't get an ACK there must have been
371+
* some sort of mailbox error so we should treat it
372+
* as such.
373+
*/
374+
if (msgbuf[0] != (IXGBE_VF_GET_RSS_KEY | IXGBE_VT_MSGTYPE_ACK))
375+
return IXGBE_ERR_MBX;
376+
377+
memcpy(rss_key, msgbuf + 1, IXGBEVF_RSS_HASH_KEY_SIZE);
378+
379+
return 0;
380+
}
381+
328382
/**
329383
* ixgbevf_set_rar_vf - set device MAC address
330384
* @hw: pointer to hardware structure

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,5 @@ int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api);
211211
int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
212212
unsigned int *default_tc);
213213
int ixgbevf_get_reta_locked(struct ixgbe_hw *hw, u32 *reta, int num_rx_queues);
214+
int ixgbevf_get_rss_key_locked(struct ixgbe_hw *hw, u8 *rss_key);
214215
#endif /* __IXGBE_VF_H__ */

0 commit comments

Comments
 (0)