]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/contrib/octeon-sdk/cvmip.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / contrib / octeon-sdk / cvmip.h
1 /***********************license start***************
2  * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights
3  * reserved.
4  *
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  *   * Redistributions of source code must retain the above copyright
11  *     notice, this list of conditions and the following disclaimer.
12  *
13  *   * Redistributions in binary form must reproduce the above
14  *     copyright notice, this list of conditions and the following
15  *     disclaimer in the documentation and/or other materials provided
16  *     with the distribution.
17
18  *   * Neither the name of Cavium Inc. nor the names of
19  *     its contributors may be used to endorse or promote products
20  *     derived from this software without specific prior written
21  *     permission.
22
23  * This Software, including technical data, may be subject to U.S. export  control
24  * laws, including the U.S. Export Administration Act and its  associated
25  * regulations, and may be subject to export or import  regulations in other
26  * countries.
27
28  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29  * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30  * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31  * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32  * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33  * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34  * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35  * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36  * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37  * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38  ***********************license end**************************************/
39
40
41
42
43
44
45
46 /**
47  * @file
48  *
49  * Cavium Inc. Internet Protocol (IP)
50  *
51  * Definitions for the Internet Protocol (IP) support.
52  *
53  * <hr>$Revision: 70030 $<hr>
54  *
55  */
56
57 #ifndef __CVMIP_H__
58 #define __CVMIP_H__
59
60
61 /*
62  * IP protocol values (1 byte)
63  *
64  */
65 #define  CVMIP_PROTO_ICMP  1    /* Internet Control Message Protocol */
66 #define  CVMIP_PROTO_TCP   6    /* Transmission Control Protocol */
67 #define  CVMIP_PROTO_UDP  17    /* User Datagram Protocol */
68 #define  CVMIP_PROTO_ESP  50    /* Encapsulated Security Payload */
69 #define  CVMIP_PROTO_AH   51    /* Authentication Header */
70
71
72 /**
73  * network packet header definitions
74  * (originally from octane_hw.h)
75  *
76  */
77
78 /**
79  * UDP Packet header
80  */
81 typedef struct {
82    union {
83       int32_t           s32     ;
84       uint32_t          u32     ;
85       struct {
86          uint16_t        src_prt ;
87          uint16_t        dst_prt ;
88       } s;
89    } prts;
90    uint16_t            len     ;
91    uint16_t            chksum  ;
92 } cvmip_udp_hdr_t;
93
94 /**
95  * TCP Packet header
96  */
97 typedef struct {
98    uint16_t            src_prt ;
99    uint16_t            dst_prt ;
100    uint32_t            seq     ;
101    uint32_t            ack_seq ;
102    uint32_t            hlen    :4;
103    uint32_t            rsvd    :6;
104    uint32_t            urg     :1;
105    uint32_t            ack     :1;
106    uint32_t            psh     :1;
107    uint32_t            rst     :1;
108    uint32_t            syn     :1;
109    uint32_t            fin     :1;
110    uint16_t            win_sz  ;
111    uint16_t            chksum  ;
112    uint16_t            urg_ptr ;
113    uint32_t            junk    ;
114 } cvmip_tcp_hdr_t;
115
116 /**
117  * L4 Packet header
118  */
119 typedef union {
120    cvmip_udp_hdr_t udphdr;
121    cvmip_tcp_hdr_t tcphdr;
122    struct {
123       union {
124          int32_t           s32    ;
125          uint32_t          u32    ;
126          struct {
127             uint16_t        src_prt;
128             uint16_t        dst_prt;
129          } s;
130       } prts;
131       uint16_t            len     ;
132       uint16_t            chksum  ;
133       char              dat[48] ; // 48 for IPv6 with no extension hdrs, 64 for IPv4 without options
134    } udp;
135    struct {
136       uint16_t            src_prt ;
137       uint16_t            dst_prt ;
138       uint32_t            seq     ;
139       uint32_t            ack_seq ;
140       uint32_t            hlen    :4;
141       uint32_t            rsvd    :6;
142       uint32_t            urg     :1;
143       uint32_t            ack     :1;
144       uint32_t            psh     :1;
145       uint32_t            rst     :1;
146       uint32_t            syn     :1;
147       uint32_t            fin     :1;
148       uint16_t            win_sz  ;
149       uint16_t            chksum  ;
150       uint16_t            urg_ptr ;
151       char              dat[36] ; // 36 for IPv6 with no extension hdrs, 52 for IPv6 without options
152    } tcp;
153 } cvmip_l4_info_t;
154
155 /**
156  * Special struct to add a pad to IPv4 header
157  */
158 typedef struct {
159    uint32_t            pad;
160
161    uint32_t            version : 4;
162    uint32_t            hl      : 4;
163    uint8_t             tos     ;
164    uint16_t            len     ;
165
166    uint16_t            id      ;
167    uint32_t            mbz     : 1;
168    uint32_t            df      : 1;
169    uint32_t            mf      : 1;
170    uint32_t            off     :13;
171
172    uint8_t             ttl     ;
173    uint8_t             protocol;
174    uint16_t            chksum  ;
175
176    union {
177       uint64_t          u64;
178       struct {
179          uint32_t        src;
180          uint32_t        dst;
181       } s;
182    } src_dst;
183 } cvmip_ipv4_hdr_t;
184
185 /**
186  * IPv6 Packet header
187  */
188 typedef struct {
189
190    uint32_t            version : 4;
191    uint32_t            v6class : 8;
192    uint32_t            flow    :20;
193
194    uint16_t            len     ;    // includes extension headers plus payload (add 40 to be equiv to v4 len field)
195    uint8_t             next_hdr;    // equivalent to the v4 protocol field
196    uint8_t             hop_lim ;    // equivalent to the v4 TTL field
197
198    union {
199       uint64_t          u64[4];
200       struct {
201          uint64_t        src[2];
202          uint64_t        dst[2];
203       } s;
204    } src_dst;
205
206 } cvmip_ipv6_hdr_t;
207
208
209 #endif /* __CVMIP_H__ */