// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
*/
#include <linux/crc32.h>
#include"rxe.h" #include"rxe_loc.h"
/** * rxe_crc32() - Compute cumulative crc32 for a contiguous segment * @rxe: rdma_rxe device object * @crc: starting crc32 value from previous segments * @next: starting address of current segment * @len: length of current segment * * Return: the cumulative crc32 checksum
*/ static __be32 rxe_crc32(struct rxe_dev *rxe, __be32 crc, void *next, size_t len)
{ return (__force __be32)crc32_le((__force u32)crc, next, len);
}
/** * rxe_icrc_hdr() - Compute the partial ICRC for the network and transport * headers of a packet. * @skb: packet buffer * @pkt: packet information * * Return: the partial ICRC
*/ static __be32 rxe_icrc_hdr(struct sk_buff *skb, struct rxe_pkt_info *pkt)
{ unsignedint bth_offset = 0; struct iphdr *ip4h = NULL; struct ipv6hdr *ip6h = NULL; struct udphdr *udph; struct rxe_bth *bth;
__be32 crc; int length; int hdr_size = sizeof(struct udphdr) +
(skb->protocol == htons(ETH_P_IP) ? sizeof(struct iphdr) : sizeof(struct ipv6hdr)); /* pseudo header buffer size is calculate using ipv6 header size since * it is bigger than ipv4
*/
u8 pshdr[sizeof(struct udphdr) + sizeof(struct ipv6hdr) +
RXE_BTH_BYTES];
/* This seed is the result of computing a CRC with a seed of * 0xfffffff and 8 bytes of 0xff representing a masked LRH.
*/
crc = (__force __be32)0xdebb20e3;
/* And finish to compute the CRC on the remainder of the headers. */
crc = rxe_crc32(pkt->rxe, crc, pkt->hdr + RXE_BTH_BYTES,
rxe_opcode[pkt->opcode].length - RXE_BTH_BYTES); return crc;
}
/** * rxe_icrc_check() - Compute ICRC for a packet and compare to the ICRC * delivered in the packet. * @skb: packet buffer * @pkt: packet information * * Return: 0 if the values match else an error
*/ int rxe_icrc_check(struct sk_buff *skb, struct rxe_pkt_info *pkt)
{
__be32 *icrcp;
__be32 pkt_icrc;
__be32 icrc;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.