Skip to content

Commit de28c99

Browse files
Prasad Kannegantidavem330
authored andcommitted
liquidio: store the L4 hash of rx packets in skb
Store the L4 hash of received packets in the skb; the hash is computed in the NIC firmware. Signed-off-by: Prasad Kanneganti <[email protected]> Signed-off-by: Felix Manlunas <[email protected]> Signed-off-by: Derek Chickles <[email protected]> Signed-off-by: Satanand Burla <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5bd36a6 commit de28c99

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

drivers/net/ethernet/cavium/liquidio/lio_main.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,7 @@ liquidio_push_packet(u32 octeon_id __attribute__((unused)),
22632263
struct skb_shared_hwtstamps *shhwtstamps;
22642264
u64 ns;
22652265
u16 vtag = 0;
2266+
u32 r_dh_off;
22662267
struct net_device *netdev = (struct net_device *)arg;
22672268
struct octeon_droq *droq = container_of(param, struct octeon_droq,
22682269
napi);
@@ -2308,6 +2309,8 @@ liquidio_push_packet(u32 octeon_id __attribute__((unused)),
23082309
put_page(pg_info->page);
23092310
}
23102311

2312+
r_dh_off = (rh->r_dh.len - 1) * BYTES_PER_DHLEN_UNIT;
2313+
23112314
if (((oct->chip_id == OCTEON_CN66XX) ||
23122315
(oct->chip_id == OCTEON_CN68XX)) &&
23132316
ptp_enable) {
@@ -2320,16 +2323,27 @@ liquidio_push_packet(u32 octeon_id __attribute__((unused)),
23202323
/* Nanoseconds are in the first 64-bits
23212324
* of the packet.
23222325
*/
2323-
memcpy(&ns, (skb->data), sizeof(ns));
2326+
memcpy(&ns, (skb->data + r_dh_off),
2327+
sizeof(ns));
2328+
r_dh_off -= BYTES_PER_DHLEN_UNIT;
23242329
shhwtstamps = skb_hwtstamps(skb);
23252330
shhwtstamps->hwtstamp =
23262331
ns_to_ktime(ns +
23272332
lio->ptp_adjust);
23282333
}
2329-
skb_pull(skb, sizeof(ns));
23302334
}
23312335
}
23322336

2337+
if (rh->r_dh.has_hash) {
2338+
__be32 *hash_be = (__be32 *)(skb->data + r_dh_off);
2339+
u32 hash = be32_to_cpu(*hash_be);
2340+
2341+
skb_set_hash(skb, hash, PKT_HASH_TYPE_L4);
2342+
r_dh_off -= BYTES_PER_DHLEN_UNIT;
2343+
}
2344+
2345+
skb_pull(skb, rh->r_dh.len * BYTES_PER_DHLEN_UNIT);
2346+
23332347
skb->protocol = eth_type_trans(skb, skb->dev);
23342348
if ((netdev->features & NETIF_F_RXCSUM) &&
23352349
(((rh->r_dh.encap_on) &&

drivers/net/ethernet/cavium/liquidio/lio_vf_main.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,7 @@ liquidio_push_packet(u32 octeon_id __attribute__((unused)),
14971497
struct net_device *netdev = (struct net_device *)arg;
14981498
struct sk_buff *skb = (struct sk_buff *)skbuff;
14991499
u16 vtag = 0;
1500+
u32 r_dh_off;
15001501

15011502
if (netdev) {
15021503
struct lio *lio = GET_LIO(netdev);
@@ -1540,7 +1541,20 @@ liquidio_push_packet(u32 octeon_id __attribute__((unused)),
15401541
put_page(pg_info->page);
15411542
}
15421543

1543-
skb_pull(skb, rh->r_dh.len * 8);
1544+
r_dh_off = (rh->r_dh.len - 1) * BYTES_PER_DHLEN_UNIT;
1545+
1546+
if (rh->r_dh.has_hwtstamp)
1547+
r_dh_off -= BYTES_PER_DHLEN_UNIT;
1548+
1549+
if (rh->r_dh.has_hash) {
1550+
__be32 *hash_be = (__be32 *)(skb->data + r_dh_off);
1551+
u32 hash = be32_to_cpu(*hash_be);
1552+
1553+
skb_set_hash(skb, hash, PKT_HASH_TYPE_L4);
1554+
r_dh_off -= BYTES_PER_DHLEN_UNIT;
1555+
}
1556+
1557+
skb_pull(skb, rh->r_dh.len * BYTES_PER_DHLEN_UNIT);
15441558
skb->protocol = eth_type_trans(skb, skb->dev);
15451559

15461560
if ((netdev->features & NETIF_F_RXCSUM) &&

drivers/net/ethernet/cavium/liquidio/liquidio_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ enum octeon_tag_type {
9898
#define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2)
9999
#define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1)
100100

101+
#define BYTES_PER_DHLEN_UNIT 8
102+
101103
static inline u32 incr_index(u32 index, u32 count, u32 max)
102104
{
103105
if ((index + count) >= max)

0 commit comments

Comments
 (0)