]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/contrib/octeon-sdk/cvmip.h
Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.
[FreeBSD/releng/8.2.git] / sys / contrib / octeon-sdk / cvmip.h
1 /***********************license start***************
2  *  Copyright (c) 2003-2008 Cavium Networks (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 Networks 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  *  TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24  *  AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25  *  OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26  *  RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27  *  REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28  *  DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29  *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30  *  PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31  *  POSSESSION OR CORRESPONDENCE TO DESCRIPTION.  THE ENTIRE RISK ARISING OUT
32  *  OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
33  *
34  *
35  *  For any questions regarding licensing please contact marketing@caviumnetworks.com
36  *
37  ***********************license end**************************************/
38
39
40
41
42
43
44 /**
45  * @file
46  *
47  * Cavium Networks Internet Protocol (IP)
48  *
49  * Definitions for the Internet Protocol (IP) support.
50  *
51  * <hr>$Revision: 41586 $<hr>
52  *
53  */
54
55 #ifndef __CVMIP_H__
56 #define __CVMIP_H__
57
58
59 /*
60  * IP protocol values (1 byte)
61  *
62  */
63 #define  CVMIP_PROTO_ICMP  1    /* Internet Control Message Protocol */
64 #define  CVMIP_PROTO_TCP   6    /* Transmission Control Protocol */
65 #define  CVMIP_PROTO_UDP  17    /* User Datagram Protocol */
66 #define  CVMIP_PROTO_ESP  50    /* Encapsulated Security Payload */
67 #define  CVMIP_PROTO_AH   51    /* Authentication Header */
68
69
70 /**
71  * network packet header definitions
72  * (originally from octane_hw.h)
73  *
74  */
75
76 /**
77  * UDP Packet header
78  */
79 typedef struct {
80    union {
81       int32_t           s32     ;
82       uint32_t          u32     ;
83       struct {
84          uint16_t        src_prt ;
85          uint16_t        dst_prt ;
86       } s;
87    } prts;
88    uint16_t            len     ;
89    uint16_t            chksum  ;
90 } cvmip_udp_hdr_t;
91
92 /**
93  * TCP Packet header
94  */
95 typedef struct {
96    uint16_t            src_prt ;
97    uint16_t            dst_prt ;
98    uint32_t            seq     ;
99    uint32_t            ack_seq ;
100    uint32_t            hlen    :4;
101    uint32_t            rsvd    :6;
102    uint32_t            urg     :1;
103    uint32_t            ack     :1;
104    uint32_t            psh     :1;
105    uint32_t            rst     :1;
106    uint32_t            syn     :1;
107    uint32_t            fin     :1;
108    uint16_t            win_sz  ;
109    uint16_t            chksum  ;
110    uint16_t            urg_ptr ;
111    uint32_t            junk    ;
112 } cvmip_tcp_hdr_t;
113
114 /**
115  * L4 Packet header
116  */
117 typedef union {
118    cvmip_udp_hdr_t udphdr;
119    cvmip_tcp_hdr_t tcphdr;
120    struct {
121       union {
122          int32_t           s32    ;
123          uint32_t          u32    ;
124          struct {
125             uint16_t        src_prt;
126             uint16_t        dst_prt;
127          } s;
128       } prts;
129       uint16_t            len     ;
130       uint16_t            chksum  ;
131       char              dat[48] ; // 48 for IPv6 with no extension hdrs, 64 for IPv4 without options
132    } udp;
133    struct {
134       uint16_t            src_prt ;
135       uint16_t            dst_prt ;
136       uint32_t            seq     ;
137       uint32_t            ack_seq ;
138       uint32_t            hlen    :4;
139       uint32_t            rsvd    :6;
140       uint32_t            urg     :1;
141       uint32_t            ack     :1;
142       uint32_t            psh     :1;
143       uint32_t            rst     :1;
144       uint32_t            syn     :1;
145       uint32_t            fin     :1;
146       uint16_t            win_sz  ;
147       uint16_t            chksum  ;
148       uint16_t            urg_ptr ;
149       char              dat[36] ; // 36 for IPv6 with no extension hdrs, 52 for IPv6 without options
150    } tcp;
151 } cvmip_l4_info_t;
152
153 /**
154  * Special struct to add a pad to IPv4 header
155  */
156 typedef struct {
157    uint32_t            pad;
158
159    uint32_t            version : 4;
160    uint32_t            hl      : 4;
161    uint8_t             tos     ;
162    uint16_t            len     ;
163
164    uint16_t            id      ;
165    uint32_t            mbz     : 1;
166    uint32_t            df      : 1;
167    uint32_t            mf      : 1;
168    uint32_t            off     :13;
169
170    uint8_t             ttl     ;
171    uint8_t             protocol;
172    uint16_t            chksum  ;
173
174    union {
175       uint64_t          u64;
176       struct {
177          uint32_t        src;
178          uint32_t        dst;
179       } s;
180    } src_dst;
181 } cvmip_ipv4_hdr_t;
182
183 /**
184  * IPv6 Packet header
185  */
186 typedef struct {
187
188    uint32_t            version : 4;
189    uint32_t            v6class : 8;
190    uint32_t            flow    :20;
191
192    uint16_t            len     ;    // includes extension headers plus payload (add 40 to be equiv to v4 len field)
193    uint8_t             next_hdr;    // equivalent to the v4 protocol field
194    uint8_t             hop_lim ;    // equivalent to the v4 TTL field
195
196    union {
197       uint64_t          u64[4];
198       struct {
199          uint64_t        src[2];
200          uint64_t        dst[2];
201       } s;
202    } src_dst;
203
204 } cvmip_ipv6_hdr_t;
205
206
207 #endif /* __CVMIP_H__ */