cvmx-wqe.h revision 215990
1210284Sjmallett/***********************license start***************
2215990Sjmallett * Copyright (c) 2003-2010  Cavium Networks (support@cavium.com). All rights
3215990Sjmallett * reserved.
4210284Sjmallett *
5210284Sjmallett *
6215990Sjmallett * Redistribution and use in source and binary forms, with or without
7215990Sjmallett * modification, are permitted provided that the following conditions are
8215990Sjmallett * met:
9210284Sjmallett *
10215990Sjmallett *   * Redistributions of source code must retain the above copyright
11215990Sjmallett *     notice, this list of conditions and the following disclaimer.
12210284Sjmallett *
13215990Sjmallett *   * Redistributions in binary form must reproduce the above
14215990Sjmallett *     copyright notice, this list of conditions and the following
15215990Sjmallett *     disclaimer in the documentation and/or other materials provided
16215990Sjmallett *     with the distribution.
17210284Sjmallett
18215990Sjmallett *   * Neither the name of Cavium Networks nor the names of
19215990Sjmallett *     its contributors may be used to endorse or promote products
20215990Sjmallett *     derived from this software without specific prior written
21215990Sjmallett *     permission.
22210284Sjmallett
23215990Sjmallett * This Software, including technical data, may be subject to U.S. export  control
24215990Sjmallett * laws, including the U.S. Export Administration Act and its  associated
25215990Sjmallett * regulations, and may be subject to export or import  regulations in other
26215990Sjmallett * countries.
27210284Sjmallett
28215990Sjmallett * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29215990Sjmallett * AND WITH ALL FAULTS AND CAVIUM  NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR
30215990Sjmallett * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31215990Sjmallett * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32215990Sjmallett * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33215990Sjmallett * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34215990Sjmallett * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35215990Sjmallett * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36215990Sjmallett * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37215990Sjmallett * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38215990Sjmallett ***********************license end**************************************/
39210284Sjmallett
40210284Sjmallett
41210284Sjmallett/**
42210284Sjmallett * @file
43210284Sjmallett *
44210284Sjmallett * This header file defines the work queue entry (wqe) data structure.
45210284Sjmallett * Since this is a commonly used structure that depends on structures
46210284Sjmallett * from several hardware blocks, those definitions have been placed
47210284Sjmallett * in this file to create a single point of definition of the wqe
48210284Sjmallett * format.
49210284Sjmallett * Data structures are still named according to the block that they
50210284Sjmallett * relate to.
51210284Sjmallett *
52210284Sjmallett * This file must not depend on any other header files, except for cvmx.h!!!
53210284Sjmallett *
54210284Sjmallett *
55215990Sjmallett * <hr>$Revision: 49448 $<hr>
56210284Sjmallett *
57210284Sjmallett *
58210284Sjmallett */
59210284Sjmallett
60210284Sjmallett#ifndef __CVMX_WQE_H__
61210284Sjmallett#define __CVMX_WQE_H__
62210284Sjmallett
63210284Sjmallett#ifdef	__cplusplus
64210284Sjmallettextern "C" {
65210284Sjmallett#endif
66210284Sjmallett
67210284Sjmallett#define OCT_TAG_TYPE_STRING(x) (((x) == CVMX_POW_TAG_TYPE_ORDERED) ?  "ORDERED" : \
68210284Sjmallett                                (((x) == CVMX_POW_TAG_TYPE_ATOMIC) ?  "ATOMIC" : \
69210284Sjmallett                                (((x) == CVMX_POW_TAG_TYPE_NULL) ?  "NULL" : \
70210284Sjmallett                                "NULL_NULL")))
71210284Sjmallett
72210284Sjmallett
73210284Sjmallett/**
74210284Sjmallett * HW decode / err_code in work queue entry
75210284Sjmallett */
76210284Sjmalletttypedef union
77210284Sjmallett{
78210284Sjmallett    uint64_t                 u64;
79210284Sjmallett
80210284Sjmallett    /** Use this struct if the hardware determines that the packet is IP */
81210284Sjmallett    struct
82210284Sjmallett    {
83210284Sjmallett        uint64_t               bufs          : 8; /**< HW sets this to the number of buffers used by this packet */
84210284Sjmallett        uint64_t               ip_offset     : 8; /**< HW sets to the number of L2 bytes prior to the IP */
85210284Sjmallett        uint64_t               vlan_valid    : 1; /**< set to 1 if we found DSA/VLAN in the L2 */
86210284Sjmallett        uint64_t               vlan_stacked  : 1; /**< Set to 1 if the DSA/VLAN tag is stacked */
87210284Sjmallett        uint64_t               unassigned    : 1;
88210284Sjmallett        uint64_t               vlan_cfi      : 1; /**< HW sets to the DSA/VLAN CFI flag (valid when vlan_valid) */
89210284Sjmallett        uint64_t               vlan_id       :12; /**< HW sets to the DSA/VLAN_ID field (valid when vlan_valid) */
90210284Sjmallett        uint64_t               pr            : 4; /**< Ring Identifier (if PCIe). Requires PIP_GBL_CTL[RING_EN]=1 */
91210284Sjmallett        uint64_t               unassigned2   : 8;
92210284Sjmallett        uint64_t               dec_ipcomp    : 1; /**< the packet needs to be decompressed */
93210284Sjmallett        uint64_t               tcp_or_udp    : 1; /**< the packet is either TCP or UDP */
94210284Sjmallett        uint64_t               dec_ipsec     : 1; /**< the packet needs to be decrypted (ESP or AH) */
95210284Sjmallett        uint64_t               is_v6         : 1; /**< the packet is IPv6 */
96210284Sjmallett
97215990Sjmallett      /* (rcv_error, not_IP, IP_exc, is_frag, L4_error, software, etc.) */
98210284Sjmallett
99210284Sjmallett        uint64_t               software      : 1; /**< reserved for software use, hardware will clear on packet creation */
100215990Sjmallett      /* exceptional conditions below */
101210284Sjmallett        uint64_t               L4_error      : 1; /**< the receive interface hardware detected an L4 error (only applies if !is_frag)
102210284Sjmallett                                                    (only applies if !rcv_error && !not_IP && !IP_exc && !is_frag)
103210284Sjmallett                                                    failure indicated in err_code below, decode:
104210284Sjmallett                                                    - 1 = Malformed L4
105210284Sjmallett                                                    - 2 = L4 Checksum Error: the L4 checksum value is
106210284Sjmallett                                                    - 3 = UDP Length Error: The UDP length field would make the UDP data longer than what
107210284Sjmallett                                                        remains in the IP packet (as defined by the IP header length field).
108210284Sjmallett                                                    - 4 = Bad L4 Port: either the source or destination TCP/UDP port is 0.
109210284Sjmallett                                                    - 8 = TCP FIN Only: the packet is TCP and only the FIN flag set.
110210284Sjmallett                                                    - 9 = TCP No Flags: the packet is TCP and no flags are set.
111210284Sjmallett                                                    - 10 = TCP FIN RST: the packet is TCP and both FIN and RST are set.
112210284Sjmallett                                                    - 11 = TCP SYN URG: the packet is TCP and both SYN and URG are set.
113210284Sjmallett                                                    - 12 = TCP SYN RST: the packet is TCP and both SYN and RST are set.
114210284Sjmallett                                                    - 13 = TCP SYN FIN: the packet is TCP and both SYN and FIN are set. */
115210284Sjmallett
116210284Sjmallett
117210284Sjmallett
118210284Sjmallett        uint64_t               is_frag       : 1; /**< set if the packet is a fragment */
119210284Sjmallett        uint64_t               IP_exc        : 1; /**< the receive interface hardware detected an IP error / exception
120210284Sjmallett                                                    (only applies if !rcv_error && !not_IP) failure indicated in err_code below, decode:
121210284Sjmallett                                                    - 1 = Not IP: the IP version field is neither 4 nor 6.
122210284Sjmallett                                                    - 2 = IPv4 Header Checksum Error: the IPv4 header has a checksum violation.
123210284Sjmallett                                                    - 3 = IP Malformed Header: the packet is not long enough to contain the IP header.
124210284Sjmallett                                                    - 4 = IP Malformed: the packet is not long enough to contain the bytes indicated by the IP
125210284Sjmallett                                                        header. Pad is allowed.
126210284Sjmallett                                                    - 5 = IP TTL Hop: the IPv4 TTL field or the IPv6 Hop Count field are zero.
127210284Sjmallett                                                    - 6 = IP Options */
128210284Sjmallett
129210284Sjmallett        uint64_t               is_bcast      : 1; /**< set if the hardware determined that the packet is a broadcast */
130210284Sjmallett        uint64_t               is_mcast      : 1; /**< set if the hardware determined that the packet is a multi-cast */
131210284Sjmallett        uint64_t               not_IP        : 1; /**< set if the packet may not be IP (must be zero in this case) */
132210284Sjmallett        uint64_t               rcv_error     : 1; /**< the receive interface hardware detected a receive error (must be zero in this case) */
133210284Sjmallett        /* lower err_code = first-level descriptor of the work */
134210284Sjmallett        /* zero for packet submitted by hardware that isn't on the slow path */
135210284Sjmallett
136210284Sjmallett        uint64_t               err_code      : 8; /**< type is cvmx_pip_err_t */
137210284Sjmallett    } s;
138210284Sjmallett
139210284Sjmallett    /**< use this to get at the 16 vlan bits */
140210284Sjmallett    struct
141210284Sjmallett    {
142210284Sjmallett        uint64_t               unused1       :16;
143210284Sjmallett        uint64_t               vlan          :16;
144210284Sjmallett        uint64_t               unused2       :32;
145210284Sjmallett    } svlan;
146210284Sjmallett
147210284Sjmallett    /**< use this struct if the hardware could not determine that the packet is ip */
148210284Sjmallett    struct
149210284Sjmallett    {
150210284Sjmallett        uint64_t               bufs          : 8; /**< HW sets this to the number of buffers used by this packet */
151210284Sjmallett        uint64_t               unused        : 8;
152210284Sjmallett        uint64_t               vlan_valid    : 1; /**< set to 1 if we found DSA/VLAN in the L2 */
153210284Sjmallett        uint64_t               vlan_stacked  : 1; /**< Set to 1 if the DSA/VLAN tag is stacked */
154210284Sjmallett        uint64_t               unassigned    : 1;
155210284Sjmallett        uint64_t               vlan_cfi      : 1; /**< HW sets to the DSA/VLAN CFI flag (valid when vlan_valid) */
156210284Sjmallett        uint64_t               vlan_id       :12; /**< HW sets to the DSA/VLAN_ID field (valid when vlan_valid) */
157210284Sjmallett        uint64_t               pr            : 4; /**< Ring Identifier (if PCIe). Requires PIP_GBL_CTL[RING_EN]=1 */
158210284Sjmallett        uint64_t               unassigned2   :12;
159210284Sjmallett        uint64_t               software      : 1; /**< reserved for software use, hardware will clear on packet creation */
160210284Sjmallett        uint64_t               unassigned3   : 1;
161210284Sjmallett        uint64_t               is_rarp       : 1; /**< set if the hardware determined that the packet is rarp */
162210284Sjmallett        uint64_t               is_arp        : 1; /**< set if the hardware determined that the packet is arp */
163210284Sjmallett        uint64_t               is_bcast      : 1; /**< set if the hardware determined that the packet is a broadcast */
164210284Sjmallett        uint64_t               is_mcast      : 1; /**< set if the hardware determined that the packet is a multi-cast */
165210284Sjmallett        uint64_t               not_IP        : 1; /**< set if the packet may not be IP (must be one in this case) */
166210284Sjmallett        uint64_t               rcv_error     : 1; /**< the receive interface hardware detected a receive error.
167210284Sjmallett                                                    Failure indicated in err_code below, decode:
168210284Sjmallett                                                    - 1 = partial error: a packet was partially received, but internal
169210284Sjmallett                                                        buffering / bandwidth was not adequate to receive the entire packet.
170210284Sjmallett                                                    - 2 = jabber error: the RGMII packet was too large and is truncated.
171210284Sjmallett                                                    - 3 = overrun error: the RGMII packet is longer than allowed and had
172210284Sjmallett                                                        an FCS error.
173210284Sjmallett                                                    - 4 = oversize error: the RGMII packet is longer than allowed.
174210284Sjmallett                                                    - 5 = alignment error: the RGMII packet is not an integer number of bytes
175210284Sjmallett                                                        and had an FCS error (100M and 10M only).
176210284Sjmallett                                                    - 6 = fragment error: the RGMII packet is shorter than allowed and had an
177210284Sjmallett                                                        FCS error.
178210284Sjmallett                                                    - 7 = GMX FCS error: the RGMII packet had an FCS error.
179210284Sjmallett                                                    - 8 = undersize error: the RGMII packet is shorter than allowed.
180210284Sjmallett                                                    - 9 = extend error: the RGMII packet had an extend error.
181210284Sjmallett                                                    - 10 = length mismatch error: the RGMII packet had a length that did not
182210284Sjmallett                                                        match the length field in the L2 HDR.
183210284Sjmallett                                                    - 11 = RGMII RX error/SPI4 DIP4 Error: the RGMII packet had one or more
184210284Sjmallett                                                        data reception errors (RXERR) or the SPI4 packet had one or more DIP4
185210284Sjmallett                                                        errors.
186210284Sjmallett                                                    - 12 = RGMII skip error/SPI4 Abort Error: the RGMII packet was not large
187210284Sjmallett                                                        enough to cover the skipped bytes or the SPI4 packet was terminated
188210284Sjmallett                                                        with an About EOPS.
189210284Sjmallett                                                    - 13 = RGMII nibble error/SPI4 Port NXA Error: the RGMII packet had a
190210284Sjmallett                                                        studder error (data not repeated - 10/100M only) or the SPI4 packet
191210284Sjmallett                                                        was sent to an NXA.
192210284Sjmallett                                                    - 16 = FCS error: a SPI4.2 packet had an FCS error.
193210284Sjmallett                                                    - 17 = Skip error: a packet was not large enough to cover the skipped bytes.
194210284Sjmallett                                                    - 18 = L2 header malformed: the packet is not long enough to contain the L2 */
195210284Sjmallett
196210284Sjmallett
197210284Sjmallett        /* lower err_code = first-level descriptor of the work */
198210284Sjmallett        /* zero for packet submitted by hardware that isn't on the slow path */
199215990Sjmallett      uint64_t               err_code       : 8; /* type is cvmx_pip_err_t (union, so can't use directly */
200210284Sjmallett    } snoip;
201210284Sjmallett
202210284Sjmallett} cvmx_pip_wqe_word2;
203210284Sjmallett
204210284Sjmallett/**
205210284Sjmallett * Work queue entry format
206210284Sjmallett *
207210284Sjmallett * must be 8-byte aligned
208210284Sjmallett */
209210284Sjmalletttypedef struct
210210284Sjmallett{
211210284Sjmallett
212210284Sjmallett    /*****************************************************************
213210284Sjmallett     * WORD 0
214210284Sjmallett     *  HW WRITE: the following 64 bits are filled by HW when a packet arrives
215210284Sjmallett     */
216210284Sjmallett
217210284Sjmallett    /**
218210284Sjmallett     * raw chksum result generated by the HW
219210284Sjmallett     */
220210284Sjmallett    uint16_t                   hw_chksum;
221210284Sjmallett    /**
222210284Sjmallett     * Field unused by hardware - available for software
223210284Sjmallett     */
224210284Sjmallett    uint8_t                    unused;
225210284Sjmallett    /**
226210284Sjmallett     * Next pointer used by hardware for list maintenance.
227210284Sjmallett     * May be written/read by HW before the work queue
228210284Sjmallett     *           entry is scheduled to a PP
229210284Sjmallett     * (Only 36 bits used in Octeon 1)
230210284Sjmallett     */
231210284Sjmallett    uint64_t                   next_ptr      : 40;
232210284Sjmallett
233210284Sjmallett
234210284Sjmallett    /*****************************************************************
235210284Sjmallett     * WORD 1
236210284Sjmallett     *  HW WRITE: the following 64 bits are filled by HW when a packet arrives
237210284Sjmallett     */
238210284Sjmallett
239210284Sjmallett    /**
240210284Sjmallett     * HW sets to the total number of bytes in the packet
241210284Sjmallett     */
242210284Sjmallett    uint64_t                   len           :16;
243210284Sjmallett    /**
244210284Sjmallett     * HW sets this to input physical port
245210284Sjmallett     */
246210284Sjmallett    uint64_t                   ipprt         : 6;
247210284Sjmallett
248210284Sjmallett    /**
249210284Sjmallett     * HW sets this to what it thought the priority of the input packet was
250210284Sjmallett     */
251210284Sjmallett    uint64_t                   qos           : 3;
252210284Sjmallett
253210284Sjmallett    /**
254210284Sjmallett     * the group that the work queue entry will be scheduled to
255210284Sjmallett     */
256210284Sjmallett    uint64_t                   grp           : 4;
257210284Sjmallett    /**
258210284Sjmallett     * the type of the tag (ORDERED, ATOMIC, NULL)
259210284Sjmallett     */
260210284Sjmallett    cvmx_pow_tag_type_t        tag_type      : 3;
261210284Sjmallett    /**
262210284Sjmallett     * the synchronization/ordering tag
263210284Sjmallett     */
264210284Sjmallett    uint64_t                   tag           :32;
265210284Sjmallett
266210284Sjmallett    /**
267210284Sjmallett     * WORD 2
268210284Sjmallett     *   HW WRITE: the following 64-bits are filled in by hardware when a packet arrives
269210284Sjmallett     *   This indicates a variety of status and error conditions.
270210284Sjmallett     */
271210284Sjmallett    cvmx_pip_wqe_word2       word2;
272210284Sjmallett
273210284Sjmallett    /**
274210284Sjmallett     * Pointer to the first segment of the packet.
275210284Sjmallett     */
276210284Sjmallett    cvmx_buf_ptr_t             packet_ptr;
277210284Sjmallett
278210284Sjmallett    /**
279210284Sjmallett     *   HW WRITE: octeon will fill in a programmable amount from the
280210284Sjmallett     *             packet, up to (at most, but perhaps less) the amount
281210284Sjmallett     *             needed to fill the work queue entry to 128 bytes
282210284Sjmallett     *   If the packet is recognized to be IP, the hardware starts (except that
283210284Sjmallett     *   the IPv4 header is padded for appropriate alignment) writing here where
284210284Sjmallett     *   the IP header starts.
285210284Sjmallett     *   If the packet is not recognized to be IP, the hardware starts writing
286210284Sjmallett     *   the beginning of the packet here.
287210284Sjmallett     */
288210284Sjmallett    uint8_t packet_data[96];
289210284Sjmallett
290210284Sjmallett
291210284Sjmallett    /**
292210284Sjmallett     * If desired, SW can make the work Q entry any length. For the
293210284Sjmallett     * purposes of discussion here, Assume 128B always, as this is all that
294210284Sjmallett     * the hardware deals with.
295210284Sjmallett     *
296210284Sjmallett     */
297210284Sjmallett
298210284Sjmallett}  CVMX_CACHE_LINE_ALIGNED cvmx_wqe_t;
299210284Sjmallett
300210284Sjmallett#ifdef	__cplusplus
301210284Sjmallett}
302210284Sjmallett#endif
303210284Sjmallett
304210284Sjmallett#endif /* __CVMX_WQE_H__ */
305