1 #ifndef __IP_IN_H_
2 #define __IP_IN_H_
3 
4 #include "mtcp.h"
5 #include "mos_api.h"
6 
7 int
8 ProcessInIPv4Packet(mtcp_manager_t mtcp, struct pkt_ctx *pctx);
9 
ip_fast_csum(const void * iph,unsigned int ihl)10 static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
11 {
12 	unsigned int sum;
13 
14 	asm("  movl (%1), %0\n"
15 	    "  subl $4, %2\n"
16 	    "  jbe 2f\n"
17 	    "  addl 4(%1), %0\n"
18 	    "  adcl 8(%1), %0\n"
19 	    "  adcl 12(%1), %0\n"
20 	    "1: adcl 16(%1), %0\n"
21 	    "  lea 4(%1), %1\n"
22 	    "  decl %2\n"
23 	    "  jne      1b\n"
24 	    "  adcl $0, %0\n"
25 	    "  movl %0, %2\n"
26 	    "  shrl $16, %0\n"
27 	    "  addw %w2, %w0\n"
28 	    "  adcl $0, %0\n"
29 	    "  notl %0\n"
30 	    "2:"
31 	    /* Since the input registers which are loaded with iph and ih
32 	       are modified, we must also specify them as outputs, or gcc
33 	       will assume they contain their original values. */
34 	    : "=r" (sum), "=r" (iph), "=r" (ihl)
35 	    : "1" (iph), "2" (ihl)
36 	       : "memory");
37 	return (__sum16)sum;
38 }
39 
40 #endif /* __IP_IN_H_ */
41