1
2
3
4
5
6
7#include "rxe.h"
8#include "rxe_loc.h"
9
10
11u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb)
12{
13 unsigned int bth_offset = 0;
14 struct iphdr *ip4h = NULL;
15 struct ipv6hdr *ip6h = NULL;
16 struct udphdr *udph;
17 struct rxe_bth *bth;
18 int crc;
19 int length;
20 int hdr_size = sizeof(struct udphdr) +
21 (skb->protocol == htons(ETH_P_IP) ?
22 sizeof(struct iphdr) : sizeof(struct ipv6hdr));
23
24
25
26 u8 pshdr[sizeof(struct udphdr) +
27 sizeof(struct ipv6hdr) +
28 RXE_BTH_BYTES];
29
30
31
32
33 crc = 0xdebb20e3;
34
35 if (skb->protocol == htons(ETH_P_IP)) {
36 memcpy(pshdr, ip_hdr(skb), hdr_size);
37 ip4h = (struct iphdr *)pshdr;
38 udph = (struct udphdr *)(ip4h + 1);
39
40 ip4h->ttl = 0xff;
41 ip4h->check = CSUM_MANGLED_0;
42 ip4h->tos = 0xff;
43 } else {
44 memcpy(pshdr, ipv6_hdr(skb), hdr_size);
45 ip6h = (struct ipv6hdr *)pshdr;
46 udph = (struct udphdr *)(ip6h + 1);
47
48 memset(ip6h->flow_lbl, 0xff, sizeof(ip6h->flow_lbl));
49 ip6h->priority = 0xf;
50 ip6h->hop_limit = 0xff;
51 }
52 udph->check = CSUM_MANGLED_0;
53
54 bth_offset += hdr_size;
55
56 memcpy(&pshdr[bth_offset], pkt->hdr, RXE_BTH_BYTES);
57 bth = (struct rxe_bth *)&pshdr[bth_offset];
58
59
60 bth->qpn |= cpu_to_be32(~BTH_QPN_MASK);
61
62 length = hdr_size + RXE_BTH_BYTES;
63 crc = rxe_crc32(pkt->rxe, crc, pshdr, length);
64
65
66 crc = rxe_crc32(pkt->rxe, crc, pkt->hdr + RXE_BTH_BYTES,
67 rxe_opcode[pkt->opcode].length - RXE_BTH_BYTES);
68 return crc;
69}
70