Skip to content

Commit 1e1429d

Browse files
fengyuleidian0615Jeff Kirsher
authored andcommitted
ixgbevf: Set Rx hash type for ingress packets
Set hash type for ingress packets according to NIC advanced receive descriptors RSS type part. Signed-off-by: Fan Du <[email protected]> Tested-by: Phil Schmitt <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 7edda4b commit 1e1429d

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ typedef u32 ixgbe_link_speed;
161161
#define IXGBE_RXDADV_SPLITHEADER_EN 0x00001000
162162
#define IXGBE_RXDADV_SPH 0x8000
163163

164+
/* RSS Hash results */
165+
#define IXGBE_RXDADV_RSSTYPE_NONE 0x00000000
166+
#define IXGBE_RXDADV_RSSTYPE_IPV4_TCP 0x00000001
167+
#define IXGBE_RXDADV_RSSTYPE_IPV4 0x00000002
168+
#define IXGBE_RXDADV_RSSTYPE_IPV6_TCP 0x00000003
169+
#define IXGBE_RXDADV_RSSTYPE_IPV6_EX 0x00000004
170+
#define IXGBE_RXDADV_RSSTYPE_IPV6 0x00000005
171+
#define IXGBE_RXDADV_RSSTYPE_IPV6_TCP_EX 0x00000006
172+
#define IXGBE_RXDADV_RSSTYPE_IPV4_UDP 0x00000007
173+
#define IXGBE_RXDADV_RSSTYPE_IPV6_UDP 0x00000008
174+
#define IXGBE_RXDADV_RSSTYPE_IPV6_UDP_EX 0x00000009
175+
164176
#define IXGBE_RXD_ERR_FRAME_ERR_MASK ( \
165177
IXGBE_RXD_ERR_CE | \
166178
IXGBE_RXD_ERR_LE | \

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,32 @@ static void ixgbevf_rx_skb(struct ixgbevf_q_vector *q_vector,
457457
napi_gro_receive(&q_vector->napi, skb);
458458
}
459459

460+
#define IXGBE_RSS_L4_TYPES_MASK \
461+
((1ul << IXGBE_RXDADV_RSSTYPE_IPV4_TCP) | \
462+
(1ul << IXGBE_RXDADV_RSSTYPE_IPV4_UDP) | \
463+
(1ul << IXGBE_RXDADV_RSSTYPE_IPV6_TCP) | \
464+
(1ul << IXGBE_RXDADV_RSSTYPE_IPV6_UDP))
465+
466+
static inline void ixgbevf_rx_hash(struct ixgbevf_ring *ring,
467+
union ixgbe_adv_rx_desc *rx_desc,
468+
struct sk_buff *skb)
469+
{
470+
u16 rss_type;
471+
472+
if (!(ring->netdev->features & NETIF_F_RXHASH))
473+
return;
474+
475+
rss_type = le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.pkt_info) &
476+
IXGBE_RXDADV_RSSTYPE_MASK;
477+
478+
if (!rss_type)
479+
return;
480+
481+
skb_set_hash(skb, le32_to_cpu(rx_desc->wb.lower.hi_dword.rss),
482+
(IXGBE_RSS_L4_TYPES_MASK & (1ul << rss_type)) ?
483+
PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3);
484+
}
485+
460486
/**
461487
* ixgbevf_rx_checksum - indicate in skb if hw indicated a good cksum
462488
* @ring: structure containig ring specific data
@@ -506,6 +532,7 @@ static void ixgbevf_process_skb_fields(struct ixgbevf_ring *rx_ring,
506532
union ixgbe_adv_rx_desc *rx_desc,
507533
struct sk_buff *skb)
508534
{
535+
ixgbevf_rx_hash(rx_ring, rx_desc, skb);
509536
ixgbevf_rx_checksum(rx_ring, rx_desc, skb);
510537

511538
if (ixgbevf_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) {

0 commit comments

Comments
 (0)