1210284Sjmallett/***********************license start*************** 2232812Sjmallett * Copyright (c) 2003-2010 Cavium Inc. (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 18232812Sjmallett * * Neither the name of Cavium Inc. 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" 29232812Sjmallett * AND WITH ALL FAULTS AND CAVIUM INC. 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 * 55232812Sjmallett * <hr>$Revision: 70030 $<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) */ 90232812Sjmallett uint64_t varies:12; /**< 38xx and 68xx have different definitions. */ 91210284Sjmallett uint64_t dec_ipcomp : 1; /**< the packet needs to be decompressed */ 92210284Sjmallett uint64_t tcp_or_udp : 1; /**< the packet is either TCP or UDP */ 93210284Sjmallett uint64_t dec_ipsec : 1; /**< the packet needs to be decrypted (ESP or AH) */ 94210284Sjmallett uint64_t is_v6 : 1; /**< the packet is IPv6 */ 95210284Sjmallett 96215990Sjmallett /* (rcv_error, not_IP, IP_exc, is_frag, L4_error, software, etc.) */ 97210284Sjmallett 98210284Sjmallett uint64_t software : 1; /**< reserved for software use, hardware will clear on packet creation */ 99215990Sjmallett /* exceptional conditions below */ 100210284Sjmallett uint64_t L4_error : 1; /**< the receive interface hardware detected an L4 error (only applies if !is_frag) 101210284Sjmallett (only applies if !rcv_error && !not_IP && !IP_exc && !is_frag) 102210284Sjmallett failure indicated in err_code below, decode: 103210284Sjmallett - 1 = Malformed L4 104210284Sjmallett - 2 = L4 Checksum Error: the L4 checksum value is 105210284Sjmallett - 3 = UDP Length Error: The UDP length field would make the UDP data longer than what 106210284Sjmallett remains in the IP packet (as defined by the IP header length field). 107210284Sjmallett - 4 = Bad L4 Port: either the source or destination TCP/UDP port is 0. 108210284Sjmallett - 8 = TCP FIN Only: the packet is TCP and only the FIN flag set. 109210284Sjmallett - 9 = TCP No Flags: the packet is TCP and no flags are set. 110210284Sjmallett - 10 = TCP FIN RST: the packet is TCP and both FIN and RST are set. 111210284Sjmallett - 11 = TCP SYN URG: the packet is TCP and both SYN and URG are set. 112210284Sjmallett - 12 = TCP SYN RST: the packet is TCP and both SYN and RST are set. 113210284Sjmallett - 13 = TCP SYN FIN: the packet is TCP and both SYN and FIN are set. */ 114210284Sjmallett 115210284Sjmallett 116210284Sjmallett 117210284Sjmallett uint64_t is_frag : 1; /**< set if the packet is a fragment */ 118210284Sjmallett uint64_t IP_exc : 1; /**< the receive interface hardware detected an IP error / exception 119210284Sjmallett (only applies if !rcv_error && !not_IP) failure indicated in err_code below, decode: 120210284Sjmallett - 1 = Not IP: the IP version field is neither 4 nor 6. 121210284Sjmallett - 2 = IPv4 Header Checksum Error: the IPv4 header has a checksum violation. 122210284Sjmallett - 3 = IP Malformed Header: the packet is not long enough to contain the IP header. 123210284Sjmallett - 4 = IP Malformed: the packet is not long enough to contain the bytes indicated by the IP 124210284Sjmallett header. Pad is allowed. 125210284Sjmallett - 5 = IP TTL Hop: the IPv4 TTL field or the IPv6 Hop Count field are zero. 126210284Sjmallett - 6 = IP Options */ 127210284Sjmallett 128210284Sjmallett uint64_t is_bcast : 1; /**< set if the hardware determined that the packet is a broadcast */ 129210284Sjmallett uint64_t is_mcast : 1; /**< set if the hardware determined that the packet is a multi-cast */ 130210284Sjmallett uint64_t not_IP : 1; /**< set if the packet may not be IP (must be zero in this case) */ 131210284Sjmallett uint64_t rcv_error : 1; /**< the receive interface hardware detected a receive error (must be zero in this case) */ 132210284Sjmallett /* lower err_code = first-level descriptor of the work */ 133210284Sjmallett /* zero for packet submitted by hardware that isn't on the slow path */ 134210284Sjmallett 135210284Sjmallett uint64_t err_code : 8; /**< type is cvmx_pip_err_t */ 136210284Sjmallett } s; 137232812Sjmallett struct 138232812Sjmallett { 139232812Sjmallett uint64_t bufs : 8; /**< HW sets this to the number of buffers used by this packet */ 140232812Sjmallett uint64_t ip_offset : 8; /**< HW sets to the number of L2 bytes prior to the IP */ 141232812Sjmallett uint64_t vlan_valid : 1; /**< set to 1 if we found DSA/VLAN in the L2 */ 142232812Sjmallett uint64_t vlan_stacked : 1; /**< Set to 1 if the DSA/VLAN tag is stacked */ 143232812Sjmallett uint64_t unassigned : 1; 144232812Sjmallett uint64_t vlan_cfi : 1; /**< HW sets to the DSA/VLAN CFI flag (valid when vlan_valid) */ 145232812Sjmallett uint64_t vlan_id :12; /**< HW sets to the DSA/VLAN_ID field (valid when vlan_valid) */ 146210284Sjmallett 147232812Sjmallett uint64_t port:12; /**< MAC/PIP port number. */ 148232812Sjmallett 149232812Sjmallett uint64_t dec_ipcomp : 1; /**< the packet needs to be decompressed */ 150232812Sjmallett uint64_t tcp_or_udp : 1; /**< the packet is either TCP or UDP */ 151232812Sjmallett uint64_t dec_ipsec : 1; /**< the packet needs to be decrypted (ESP or AH) */ 152232812Sjmallett uint64_t is_v6 : 1; /**< the packet is IPv6 */ 153232812Sjmallett 154232812Sjmallett /* (rcv_error, not_IP, IP_exc, is_frag, L4_error, software, etc.) */ 155232812Sjmallett 156232812Sjmallett uint64_t software : 1; /**< reserved for software use, hardware will clear on packet creation */ 157232812Sjmallett /* exceptional conditions below */ 158232812Sjmallett uint64_t L4_error : 1; /**< the receive interface hardware detected an L4 error (only applies if !is_frag) 159232812Sjmallett (only applies if !rcv_error && !not_IP && !IP_exc && !is_frag) 160232812Sjmallett failure indicated in err_code below, decode: 161232812Sjmallett - 1 = Malformed L4 162232812Sjmallett - 2 = L4 Checksum Error: the L4 checksum value is 163232812Sjmallett - 3 = UDP Length Error: The UDP length field would make the UDP data longer than what 164232812Sjmallett remains in the IP packet (as defined by the IP header length field). 165232812Sjmallett - 4 = Bad L4 Port: either the source or destination TCP/UDP port is 0. 166232812Sjmallett - 8 = TCP FIN Only: the packet is TCP and only the FIN flag set. 167232812Sjmallett - 9 = TCP No Flags: the packet is TCP and no flags are set. 168232812Sjmallett - 10 = TCP FIN RST: the packet is TCP and both FIN and RST are set. 169232812Sjmallett - 11 = TCP SYN URG: the packet is TCP and both SYN and URG are set. 170232812Sjmallett - 12 = TCP SYN RST: the packet is TCP and both SYN and RST are set. 171232812Sjmallett - 13 = TCP SYN FIN: the packet is TCP and both SYN and FIN are set. */ 172232812Sjmallett 173232812Sjmallett 174232812Sjmallett 175232812Sjmallett uint64_t is_frag : 1; /**< set if the packet is a fragment */ 176232812Sjmallett uint64_t IP_exc : 1; /**< the receive interface hardware detected an IP error / exception 177232812Sjmallett (only applies if !rcv_error && !not_IP) failure indicated in err_code below, decode: 178232812Sjmallett - 1 = Not IP: the IP version field is neither 4 nor 6. 179232812Sjmallett - 2 = IPv4 Header Checksum Error: the IPv4 header has a checksum violation. 180232812Sjmallett - 3 = IP Malformed Header: the packet is not long enough to contain the IP header. 181232812Sjmallett - 4 = IP Malformed: the packet is not long enough to contain the bytes indicated by the IP 182232812Sjmallett header. Pad is allowed. 183232812Sjmallett - 5 = IP TTL Hop: the IPv4 TTL field or the IPv6 Hop Count field are zero. 184232812Sjmallett - 6 = IP Options */ 185232812Sjmallett 186232812Sjmallett uint64_t is_bcast : 1; /**< set if the hardware determined that the packet is a broadcast */ 187232812Sjmallett uint64_t is_mcast : 1; /**< set if the hardware determined that the packet is a multi-cast */ 188232812Sjmallett uint64_t not_IP : 1; /**< set if the packet may not be IP (must be zero in this case) */ 189232812Sjmallett uint64_t rcv_error : 1; /**< the receive interface hardware detected a receive error (must be zero in this case) */ 190232812Sjmallett /* lower err_code = first-level descriptor of the work */ 191232812Sjmallett /* zero for packet submitted by hardware that isn't on the slow path */ 192232812Sjmallett 193232812Sjmallett uint64_t err_code : 8; /**< type is cvmx_pip_err_t */ 194232812Sjmallett } s_cn68xx; 195232812Sjmallett struct 196232812Sjmallett { 197232812Sjmallett uint64_t bufs : 8; /**< HW sets this to the number of buffers used by this packet */ 198232812Sjmallett uint64_t ip_offset : 8; /**< HW sets to the number of L2 bytes prior to the IP */ 199232812Sjmallett uint64_t vlan_valid : 1; /**< set to 1 if we found DSA/VLAN in the L2 */ 200232812Sjmallett uint64_t vlan_stacked : 1; /**< Set to 1 if the DSA/VLAN tag is stacked */ 201232812Sjmallett uint64_t unassigned : 1; 202232812Sjmallett uint64_t vlan_cfi : 1; /**< HW sets to the DSA/VLAN CFI flag (valid when vlan_valid) */ 203232812Sjmallett uint64_t vlan_id :12; /**< HW sets to the DSA/VLAN_ID field (valid when vlan_valid) */ 204232812Sjmallett uint64_t pr : 4; /**< Ring Identifier (if PCIe). Requires PIP_GBL_CTL[RING_EN]=1 */ 205232812Sjmallett uint64_t unassigned2a :4; 206232812Sjmallett uint64_t unassigned2 :4; 207232812Sjmallett 208232812Sjmallett uint64_t dec_ipcomp : 1; /**< the packet needs to be decompressed */ 209232812Sjmallett uint64_t tcp_or_udp : 1; /**< the packet is either TCP or UDP */ 210232812Sjmallett uint64_t dec_ipsec : 1; /**< the packet needs to be decrypted (ESP or AH) */ 211232812Sjmallett uint64_t is_v6 : 1; /**< the packet is IPv6 */ 212232812Sjmallett 213232812Sjmallett /* (rcv_error, not_IP, IP_exc, is_frag, L4_error, software, etc.) */ 214232812Sjmallett 215232812Sjmallett uint64_t software : 1; /**< reserved for software use, hardware will clear on packet creation */ 216232812Sjmallett /* exceptional conditions below */ 217232812Sjmallett uint64_t L4_error : 1; /**< the receive interface hardware detected an L4 error (only applies if !is_frag) 218232812Sjmallett (only applies if !rcv_error && !not_IP && !IP_exc && !is_frag) 219232812Sjmallett failure indicated in err_code below, decode: 220232812Sjmallett - 1 = Malformed L4 221232812Sjmallett - 2 = L4 Checksum Error: the L4 checksum value is 222232812Sjmallett - 3 = UDP Length Error: The UDP length field would make the UDP data longer than what 223232812Sjmallett remains in the IP packet (as defined by the IP header length field). 224232812Sjmallett - 4 = Bad L4 Port: either the source or destination TCP/UDP port is 0. 225232812Sjmallett - 8 = TCP FIN Only: the packet is TCP and only the FIN flag set. 226232812Sjmallett - 9 = TCP No Flags: the packet is TCP and no flags are set. 227232812Sjmallett - 10 = TCP FIN RST: the packet is TCP and both FIN and RST are set. 228232812Sjmallett - 11 = TCP SYN URG: the packet is TCP and both SYN and URG are set. 229232812Sjmallett - 12 = TCP SYN RST: the packet is TCP and both SYN and RST are set. 230232812Sjmallett - 13 = TCP SYN FIN: the packet is TCP and both SYN and FIN are set. */ 231232812Sjmallett 232232812Sjmallett 233232812Sjmallett 234232812Sjmallett uint64_t is_frag : 1; /**< set if the packet is a fragment */ 235232812Sjmallett uint64_t IP_exc : 1; /**< the receive interface hardware detected an IP error / exception 236232812Sjmallett (only applies if !rcv_error && !not_IP) failure indicated in err_code below, decode: 237232812Sjmallett - 1 = Not IP: the IP version field is neither 4 nor 6. 238232812Sjmallett - 2 = IPv4 Header Checksum Error: the IPv4 header has a checksum violation. 239232812Sjmallett - 3 = IP Malformed Header: the packet is not long enough to contain the IP header. 240232812Sjmallett - 4 = IP Malformed: the packet is not long enough to contain the bytes indicated by the IP 241232812Sjmallett header. Pad is allowed. 242232812Sjmallett - 5 = IP TTL Hop: the IPv4 TTL field or the IPv6 Hop Count field are zero. 243232812Sjmallett - 6 = IP Options */ 244232812Sjmallett 245232812Sjmallett uint64_t is_bcast : 1; /**< set if the hardware determined that the packet is a broadcast */ 246232812Sjmallett uint64_t is_mcast : 1; /**< set if the hardware determined that the packet is a multi-cast */ 247232812Sjmallett uint64_t not_IP : 1; /**< set if the packet may not be IP (must be zero in this case) */ 248232812Sjmallett uint64_t rcv_error : 1; /**< the receive interface hardware detected a receive error (must be zero in this case) */ 249232812Sjmallett /* lower err_code = first-level descriptor of the work */ 250232812Sjmallett /* zero for packet submitted by hardware that isn't on the slow path */ 251232812Sjmallett 252232812Sjmallett uint64_t err_code : 8; /**< type is cvmx_pip_err_t */ 253232812Sjmallett } s_cn38xx; 254232812Sjmallett 255210284Sjmallett /**< use this to get at the 16 vlan bits */ 256210284Sjmallett struct 257210284Sjmallett { 258210284Sjmallett uint64_t unused1 :16; 259210284Sjmallett uint64_t vlan :16; 260210284Sjmallett uint64_t unused2 :32; 261210284Sjmallett } svlan; 262210284Sjmallett 263210284Sjmallett /**< use this struct if the hardware could not determine that the packet is ip */ 264210284Sjmallett struct 265210284Sjmallett { 266210284Sjmallett uint64_t bufs : 8; /**< HW sets this to the number of buffers used by this packet */ 267210284Sjmallett uint64_t unused : 8; 268210284Sjmallett uint64_t vlan_valid : 1; /**< set to 1 if we found DSA/VLAN in the L2 */ 269210284Sjmallett uint64_t vlan_stacked : 1; /**< Set to 1 if the DSA/VLAN tag is stacked */ 270210284Sjmallett uint64_t unassigned : 1; 271210284Sjmallett uint64_t vlan_cfi : 1; /**< HW sets to the DSA/VLAN CFI flag (valid when vlan_valid) */ 272210284Sjmallett uint64_t vlan_id :12; /**< HW sets to the DSA/VLAN_ID field (valid when vlan_valid) */ 273232812Sjmallett 274232812Sjmallett uint64_t varies:12; /**< 38xx and 68xx have different definitions. */ 275232812Sjmallett uint64_t unassigned2:4; 276232812Sjmallett 277210284Sjmallett uint64_t software : 1; /**< reserved for software use, hardware will clear on packet creation */ 278210284Sjmallett uint64_t unassigned3 : 1; 279210284Sjmallett uint64_t is_rarp : 1; /**< set if the hardware determined that the packet is rarp */ 280210284Sjmallett uint64_t is_arp : 1; /**< set if the hardware determined that the packet is arp */ 281210284Sjmallett uint64_t is_bcast : 1; /**< set if the hardware determined that the packet is a broadcast */ 282210284Sjmallett uint64_t is_mcast : 1; /**< set if the hardware determined that the packet is a multi-cast */ 283210284Sjmallett uint64_t not_IP : 1; /**< set if the packet may not be IP (must be one in this case) */ 284210284Sjmallett uint64_t rcv_error : 1; /**< the receive interface hardware detected a receive error. 285210284Sjmallett Failure indicated in err_code below, decode: 286210284Sjmallett - 1 = partial error: a packet was partially received, but internal 287210284Sjmallett buffering / bandwidth was not adequate to receive the entire packet. 288210284Sjmallett - 2 = jabber error: the RGMII packet was too large and is truncated. 289210284Sjmallett - 3 = overrun error: the RGMII packet is longer than allowed and had 290210284Sjmallett an FCS error. 291210284Sjmallett - 4 = oversize error: the RGMII packet is longer than allowed. 292210284Sjmallett - 5 = alignment error: the RGMII packet is not an integer number of bytes 293210284Sjmallett and had an FCS error (100M and 10M only). 294210284Sjmallett - 6 = fragment error: the RGMII packet is shorter than allowed and had an 295210284Sjmallett FCS error. 296210284Sjmallett - 7 = GMX FCS error: the RGMII packet had an FCS error. 297210284Sjmallett - 8 = undersize error: the RGMII packet is shorter than allowed. 298210284Sjmallett - 9 = extend error: the RGMII packet had an extend error. 299210284Sjmallett - 10 = length mismatch error: the RGMII packet had a length that did not 300210284Sjmallett match the length field in the L2 HDR. 301210284Sjmallett - 11 = RGMII RX error/SPI4 DIP4 Error: the RGMII packet had one or more 302210284Sjmallett data reception errors (RXERR) or the SPI4 packet had one or more DIP4 303210284Sjmallett errors. 304210284Sjmallett - 12 = RGMII skip error/SPI4 Abort Error: the RGMII packet was not large 305210284Sjmallett enough to cover the skipped bytes or the SPI4 packet was terminated 306210284Sjmallett with an About EOPS. 307210284Sjmallett - 13 = RGMII nibble error/SPI4 Port NXA Error: the RGMII packet had a 308210284Sjmallett studder error (data not repeated - 10/100M only) or the SPI4 packet 309210284Sjmallett was sent to an NXA. 310210284Sjmallett - 16 = FCS error: a SPI4.2 packet had an FCS error. 311210284Sjmallett - 17 = Skip error: a packet was not large enough to cover the skipped bytes. 312210284Sjmallett - 18 = L2 header malformed: the packet is not long enough to contain the L2 */ 313210284Sjmallett 314210284Sjmallett 315210284Sjmallett /* lower err_code = first-level descriptor of the work */ 316210284Sjmallett /* zero for packet submitted by hardware that isn't on the slow path */ 317215990Sjmallett uint64_t err_code : 8; /* type is cvmx_pip_err_t (union, so can't use directly */ 318210284Sjmallett } snoip; 319232812Sjmallett struct 320232812Sjmallett { 321232812Sjmallett uint64_t bufs : 8; /**< HW sets this to the number of buffers used by this packet */ 322232812Sjmallett uint64_t unused : 8; 323232812Sjmallett uint64_t vlan_valid : 1; /**< set to 1 if we found DSA/VLAN in the L2 */ 324232812Sjmallett uint64_t vlan_stacked : 1; /**< Set to 1 if the DSA/VLAN tag is stacked */ 325232812Sjmallett uint64_t unassigned : 1; 326232812Sjmallett uint64_t vlan_cfi : 1; /**< HW sets to the DSA/VLAN CFI flag (valid when vlan_valid) */ 327232812Sjmallett uint64_t vlan_id :12; /**< HW sets to the DSA/VLAN_ID field (valid when vlan_valid) */ 328210284Sjmallett 329232812Sjmallett uint64_t port:12; /**< MAC/PIP port number. */ 330232812Sjmallett uint64_t unassigned2:4; 331210284Sjmallett 332232812Sjmallett uint64_t software : 1; /**< reserved for software use, hardware will clear on packet creation */ 333232812Sjmallett uint64_t unassigned3 : 1; 334232812Sjmallett uint64_t is_rarp : 1; /**< set if the hardware determined that the packet is rarp */ 335232812Sjmallett uint64_t is_arp : 1; /**< set if the hardware determined that the packet is arp */ 336232812Sjmallett uint64_t is_bcast : 1; /**< set if the hardware determined that the packet is a broadcast */ 337232812Sjmallett uint64_t is_mcast : 1; /**< set if the hardware determined that the packet is a multi-cast */ 338232812Sjmallett uint64_t not_IP : 1; /**< set if the packet may not be IP (must be one in this case) */ 339232812Sjmallett uint64_t rcv_error : 1; /**< the receive interface hardware detected a receive error. 340232812Sjmallett Failure indicated in err_code below, decode: 341232812Sjmallett - 1 = partial error: a packet was partially received, but internal 342232812Sjmallett buffering / bandwidth was not adequate to receive the entire packet. 343232812Sjmallett - 2 = jabber error: the RGMII packet was too large and is truncated. 344232812Sjmallett - 3 = overrun error: the RGMII packet is longer than allowed and had 345232812Sjmallett an FCS error. 346232812Sjmallett - 4 = oversize error: the RGMII packet is longer than allowed. 347232812Sjmallett - 5 = alignment error: the RGMII packet is not an integer number of bytes 348232812Sjmallett and had an FCS error (100M and 10M only). 349232812Sjmallett - 6 = fragment error: the RGMII packet is shorter than allowed and had an 350232812Sjmallett FCS error. 351232812Sjmallett - 7 = GMX FCS error: the RGMII packet had an FCS error. 352232812Sjmallett - 8 = undersize error: the RGMII packet is shorter than allowed. 353232812Sjmallett - 9 = extend error: the RGMII packet had an extend error. 354232812Sjmallett - 10 = length mismatch error: the RGMII packet had a length that did not 355232812Sjmallett match the length field in the L2 HDR. 356232812Sjmallett - 11 = RGMII RX error/SPI4 DIP4 Error: the RGMII packet had one or more 357232812Sjmallett data reception errors (RXERR) or the SPI4 packet had one or more DIP4 358232812Sjmallett errors. 359232812Sjmallett - 12 = RGMII skip error/SPI4 Abort Error: the RGMII packet was not large 360232812Sjmallett enough to cover the skipped bytes or the SPI4 packet was terminated 361232812Sjmallett with an About EOPS. 362232812Sjmallett - 13 = RGMII nibble error/SPI4 Port NXA Error: the RGMII packet had a 363232812Sjmallett studder error (data not repeated - 10/100M only) or the SPI4 packet 364232812Sjmallett was sent to an NXA. 365232812Sjmallett - 16 = FCS error: a SPI4.2 packet had an FCS error. 366232812Sjmallett - 17 = Skip error: a packet was not large enough to cover the skipped bytes. 367232812Sjmallett - 18 = L2 header malformed: the packet is not long enough to contain the L2 */ 368232812Sjmallett 369232812Sjmallett 370232812Sjmallett /* lower err_code = first-level descriptor of the work */ 371232812Sjmallett /* zero for packet submitted by hardware that isn't on the slow path */ 372232812Sjmallett uint64_t err_code : 8; /* type is cvmx_pip_err_t (union, so can't use directly */ 373232812Sjmallett } snoip_cn68xx; 374232812Sjmallett struct 375232812Sjmallett { 376232812Sjmallett uint64_t bufs : 8; /**< HW sets this to the number of buffers used by this packet */ 377232812Sjmallett uint64_t unused : 8; 378232812Sjmallett uint64_t vlan_valid : 1; /**< set to 1 if we found DSA/VLAN in the L2 */ 379232812Sjmallett uint64_t vlan_stacked : 1; /**< Set to 1 if the DSA/VLAN tag is stacked */ 380232812Sjmallett uint64_t unassigned : 1; 381232812Sjmallett uint64_t vlan_cfi : 1; /**< HW sets to the DSA/VLAN CFI flag (valid when vlan_valid) */ 382232812Sjmallett uint64_t vlan_id :12; /**< HW sets to the DSA/VLAN_ID field (valid when vlan_valid) */ 383232812Sjmallett uint64_t pr : 4; /**< Ring Identifier (if PCIe). Requires PIP_GBL_CTL[RING_EN]=1 */ 384232812Sjmallett uint64_t unassigned2a :8; 385232812Sjmallett uint64_t unassigned2 :4; 386232812Sjmallett 387232812Sjmallett uint64_t software : 1; /**< reserved for software use, hardware will clear on packet creation */ 388232812Sjmallett uint64_t unassigned3 : 1; 389232812Sjmallett uint64_t is_rarp : 1; /**< set if the hardware determined that the packet is rarp */ 390232812Sjmallett uint64_t is_arp : 1; /**< set if the hardware determined that the packet is arp */ 391232812Sjmallett uint64_t is_bcast : 1; /**< set if the hardware determined that the packet is a broadcast */ 392232812Sjmallett uint64_t is_mcast : 1; /**< set if the hardware determined that the packet is a multi-cast */ 393232812Sjmallett uint64_t not_IP : 1; /**< set if the packet may not be IP (must be one in this case) */ 394232812Sjmallett uint64_t rcv_error : 1; /**< the receive interface hardware detected a receive error. 395232812Sjmallett Failure indicated in err_code below, decode: 396232812Sjmallett - 1 = partial error: a packet was partially received, but internal 397232812Sjmallett buffering / bandwidth was not adequate to receive the entire packet. 398232812Sjmallett - 2 = jabber error: the RGMII packet was too large and is truncated. 399232812Sjmallett - 3 = overrun error: the RGMII packet is longer than allowed and had 400232812Sjmallett an FCS error. 401232812Sjmallett - 4 = oversize error: the RGMII packet is longer than allowed. 402232812Sjmallett - 5 = alignment error: the RGMII packet is not an integer number of bytes 403232812Sjmallett and had an FCS error (100M and 10M only). 404232812Sjmallett - 6 = fragment error: the RGMII packet is shorter than allowed and had an 405232812Sjmallett FCS error. 406232812Sjmallett - 7 = GMX FCS error: the RGMII packet had an FCS error. 407232812Sjmallett - 8 = undersize error: the RGMII packet is shorter than allowed. 408232812Sjmallett - 9 = extend error: the RGMII packet had an extend error. 409232812Sjmallett - 10 = length mismatch error: the RGMII packet had a length that did not 410232812Sjmallett match the length field in the L2 HDR. 411232812Sjmallett - 11 = RGMII RX error/SPI4 DIP4 Error: the RGMII packet had one or more 412232812Sjmallett data reception errors (RXERR) or the SPI4 packet had one or more DIP4 413232812Sjmallett errors. 414232812Sjmallett - 12 = RGMII skip error/SPI4 Abort Error: the RGMII packet was not large 415232812Sjmallett enough to cover the skipped bytes or the SPI4 packet was terminated 416232812Sjmallett with an About EOPS. 417232812Sjmallett - 13 = RGMII nibble error/SPI4 Port NXA Error: the RGMII packet had a 418232812Sjmallett studder error (data not repeated - 10/100M only) or the SPI4 packet 419232812Sjmallett was sent to an NXA. 420232812Sjmallett - 16 = FCS error: a SPI4.2 packet had an FCS error. 421232812Sjmallett - 17 = Skip error: a packet was not large enough to cover the skipped bytes. 422232812Sjmallett - 18 = L2 header malformed: the packet is not long enough to contain the L2 */ 423232812Sjmallett 424232812Sjmallett 425232812Sjmallett /* lower err_code = first-level descriptor of the work */ 426232812Sjmallett /* zero for packet submitted by hardware that isn't on the slow path */ 427232812Sjmallett uint64_t err_code : 8; /* type is cvmx_pip_err_t (union, so can't use directly */ 428232812Sjmallett } snoip_cn38xx; 429232812Sjmallett 430232812Sjmallett} cvmx_pip_wqe_word2_t; 431232812Sjmallett 432232812Sjmalletttypedef union { 433232812Sjmallett struct { 434232812Sjmallett /** 435232812Sjmallett * raw chksum result generated by the HW 436232812Sjmallett */ 437232812Sjmallett uint16_t hw_chksum; 438232812Sjmallett /** 439232812Sjmallett * Field unused by hardware - available for software 440232812Sjmallett */ 441232812Sjmallett uint8_t unused; 442232812Sjmallett /** 443232812Sjmallett * Next pointer used by hardware for list maintenance. 444232812Sjmallett * May be written/read by HW before the work queue 445232812Sjmallett * entry is scheduled to a PP (Only 36 bits used in 446232812Sjmallett * Octeon 1) 447232812Sjmallett */ 448232812Sjmallett uint64_t next_ptr : 40; 449232812Sjmallett 450232812Sjmallett } cn38xx; 451232812Sjmallett struct { 452232812Sjmallett uint64_t l4ptr:8; /* 56..63 */ 453232812Sjmallett uint64_t unused0:8; /* 48..55 */ 454232812Sjmallett uint64_t l3ptr:8; /* 40..47 */ 455232812Sjmallett uint64_t l2ptr:8; /* 32..39 */ 456232812Sjmallett uint64_t unused1:18; /* 14..31 */ 457232812Sjmallett uint64_t bpid:6; /* 8..13 */ 458232812Sjmallett uint64_t unused2:2; /* 6..7 */ 459232812Sjmallett uint64_t pknd:6; /* 0..5 */ 460232812Sjmallett } cn68xx; 461232812Sjmallett} cvmx_pip_wqe_word0_t; 462232812Sjmallett 463232812Sjmalletttypedef union { 464232812Sjmallett uint64_t u64; 465232812Sjmallett cvmx_pip_wqe_word0_t pip; 466232812Sjmallett struct { 467232812Sjmallett uint64_t unused:24; 468232812Sjmallett uint64_t next_ptr:40; /* on cn68xx this is unused as well */ 469232812Sjmallett 470232812Sjmallett } raw; 471232812Sjmallett} cvmx_wqe_word0_t; 472232812Sjmallett 473232812Sjmalletttypedef union { 474232812Sjmallett uint64_t u64; 475232812Sjmallett struct { 476232812Sjmallett uint64_t len:16; 477232812Sjmallett uint64_t varies:14; 478232812Sjmallett /** 479232812Sjmallett * the type of the tag (ORDERED, ATOMIC, NULL) 480232812Sjmallett */ 481232812Sjmallett cvmx_pow_tag_type_t tag_type:2; 482232812Sjmallett uint64_t tag:32; 483232812Sjmallett } s; 484232812Sjmallett struct { 485232812Sjmallett uint64_t len:16; 486232812Sjmallett uint64_t zero_0:1; 487232812Sjmallett /** 488232812Sjmallett * HW sets this to what it thought the priority of the input packet was 489232812Sjmallett */ 490232812Sjmallett uint64_t qos:3; 491232812Sjmallett 492232812Sjmallett uint64_t zero_1:1; 493232812Sjmallett /** 494232812Sjmallett * the group that the work queue entry will be scheduled to 495232812Sjmallett */ 496232812Sjmallett uint64_t grp:6; 497232812Sjmallett uint64_t zero_2:3; 498232812Sjmallett cvmx_pow_tag_type_t tag_type:2; 499232812Sjmallett uint64_t tag:32; 500232812Sjmallett } cn68xx; 501232812Sjmallett struct { 502232812Sjmallett uint64_t len:16; 503232812Sjmallett /** 504232812Sjmallett * HW sets this to input physical port 505232812Sjmallett */ 506232812Sjmallett uint64_t ipprt:6; 507232812Sjmallett 508232812Sjmallett /** 509232812Sjmallett * HW sets this to what it thought the priority of the input packet was 510232812Sjmallett */ 511232812Sjmallett uint64_t qos:3; 512232812Sjmallett 513232812Sjmallett /** 514232812Sjmallett * the group that the work queue entry will be scheduled to 515232812Sjmallett */ 516232812Sjmallett uint64_t grp:4; 517232812Sjmallett uint64_t zero_2:1; 518232812Sjmallett cvmx_pow_tag_type_t tag_type:2; 519232812Sjmallett uint64_t tag:32; 520232812Sjmallett } cn38xx; 521232812Sjmallett} cvmx_wqe_word1_t; 522232812Sjmallett 523210284Sjmallett/** 524210284Sjmallett * Work queue entry format 525210284Sjmallett * 526210284Sjmallett * must be 8-byte aligned 527210284Sjmallett */ 528210284Sjmalletttypedef struct 529210284Sjmallett{ 530210284Sjmallett 531210284Sjmallett /***************************************************************** 532210284Sjmallett * WORD 0 533210284Sjmallett * HW WRITE: the following 64 bits are filled by HW when a packet arrives 534210284Sjmallett */ 535210284Sjmallett 536232812Sjmallett cvmx_wqe_word0_t word0; 537210284Sjmallett 538210284Sjmallett /***************************************************************** 539210284Sjmallett * WORD 1 540210284Sjmallett * HW WRITE: the following 64 bits are filled by HW when a packet arrives 541210284Sjmallett */ 542210284Sjmallett 543232812Sjmallett cvmx_wqe_word1_t word1; 544210284Sjmallett /** 545210284Sjmallett * WORD 2 546210284Sjmallett * HW WRITE: the following 64-bits are filled in by hardware when a packet arrives 547210284Sjmallett * This indicates a variety of status and error conditions. 548210284Sjmallett */ 549232812Sjmallett cvmx_pip_wqe_word2_t word2; 550210284Sjmallett 551210284Sjmallett /** 552210284Sjmallett * Pointer to the first segment of the packet. 553210284Sjmallett */ 554210284Sjmallett cvmx_buf_ptr_t packet_ptr; 555210284Sjmallett 556210284Sjmallett /** 557210284Sjmallett * HW WRITE: octeon will fill in a programmable amount from the 558210284Sjmallett * packet, up to (at most, but perhaps less) the amount 559210284Sjmallett * needed to fill the work queue entry to 128 bytes 560210284Sjmallett * If the packet is recognized to be IP, the hardware starts (except that 561210284Sjmallett * the IPv4 header is padded for appropriate alignment) writing here where 562210284Sjmallett * the IP header starts. 563210284Sjmallett * If the packet is not recognized to be IP, the hardware starts writing 564210284Sjmallett * the beginning of the packet here. 565210284Sjmallett */ 566210284Sjmallett uint8_t packet_data[96]; 567210284Sjmallett 568210284Sjmallett 569210284Sjmallett /** 570210284Sjmallett * If desired, SW can make the work Q entry any length. For the 571210284Sjmallett * purposes of discussion here, Assume 128B always, as this is all that 572210284Sjmallett * the hardware deals with. 573210284Sjmallett * 574210284Sjmallett */ 575210284Sjmallett 576210284Sjmallett} CVMX_CACHE_LINE_ALIGNED cvmx_wqe_t; 577210284Sjmallett 578232812Sjmallettstatic inline int cvmx_wqe_get_port(cvmx_wqe_t *work) 579232812Sjmallett{ 580232812Sjmallett int port; 581232812Sjmallett 582232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 583232812Sjmallett port = work->word2.s_cn68xx.port; 584232812Sjmallett else 585232812Sjmallett port = work->word1.cn38xx.ipprt; 586232812Sjmallett 587232812Sjmallett return port; 588232812Sjmallett} 589232812Sjmallett 590232812Sjmallettstatic inline void cvmx_wqe_set_port(cvmx_wqe_t *work, int port) 591232812Sjmallett{ 592232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 593232812Sjmallett port = work->word2.s_cn68xx.port = port; 594232812Sjmallett else 595232812Sjmallett port = work->word1.cn38xx.ipprt = port; 596232812Sjmallett} 597232812Sjmallett 598232812Sjmallettstatic inline int cvmx_wqe_get_grp(cvmx_wqe_t *work) 599232812Sjmallett{ 600232812Sjmallett int grp; 601232812Sjmallett 602232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 603232812Sjmallett grp = work->word1.cn68xx.grp; 604232812Sjmallett else 605232812Sjmallett grp = work->word1.cn38xx.grp; 606232812Sjmallett 607232812Sjmallett return grp; 608232812Sjmallett} 609232812Sjmallett 610232812Sjmallettstatic inline void cvmx_wqe_set_grp(cvmx_wqe_t *work, int grp) 611232812Sjmallett{ 612232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 613232812Sjmallett work->word1.cn68xx.grp = grp; 614232812Sjmallett else 615232812Sjmallett work->word1.cn38xx.grp = grp; 616232812Sjmallett} 617232812Sjmallett 618232812Sjmallettstatic inline int cvmx_wqe_get_qos(cvmx_wqe_t *work) 619232812Sjmallett{ 620232812Sjmallett int qos; 621232812Sjmallett 622232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 623232812Sjmallett qos = work->word1.cn68xx.qos; 624232812Sjmallett else 625232812Sjmallett qos = work->word1.cn38xx.qos; 626232812Sjmallett 627232812Sjmallett return qos; 628232812Sjmallett} 629232812Sjmallett 630232812Sjmallettstatic inline void cvmx_wqe_set_qos(cvmx_wqe_t *work, int qos) 631232812Sjmallett{ 632232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 633232812Sjmallett work->word1.cn68xx.qos = qos; 634232812Sjmallett else 635232812Sjmallett work->word1.cn38xx.qos = qos; 636232812Sjmallett} 637232812Sjmallett 638232812Sjmallettstatic inline int cvmx_wqe_get_len(cvmx_wqe_t *work) 639232812Sjmallett{ 640232812Sjmallett int len; 641232812Sjmallett 642232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 643232812Sjmallett len = work->word1.cn68xx.len; 644232812Sjmallett else 645232812Sjmallett len = work->word1.cn38xx.len; 646232812Sjmallett 647232812Sjmallett return len; 648232812Sjmallett} 649232812Sjmallett 650232812Sjmallettstatic inline void cvmx_wqe_set_len(cvmx_wqe_t *work, int len) 651232812Sjmallett{ 652232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 653232812Sjmallett work->word1.cn68xx.len = len; 654232812Sjmallett else 655232812Sjmallett work->word1.cn38xx.len = len; 656232812Sjmallett} 657232812Sjmallett 658232812Sjmallettstatic inline uint32_t cvmx_wqe_get_tag(cvmx_wqe_t *work) 659232812Sjmallett{ 660232812Sjmallett return work->word1.s.tag; 661232812Sjmallett} 662232812Sjmallett 663232812Sjmallettstatic inline void cvmx_wqe_set_tag(cvmx_wqe_t *work, uint32_t tag) 664232812Sjmallett{ 665232812Sjmallett work->word1.s.tag = tag; 666232812Sjmallett} 667232812Sjmallett 668232812Sjmallettstatic inline int cvmx_wqe_get_tt(cvmx_wqe_t *work) 669232812Sjmallett{ 670232812Sjmallett return work->word1.s.tag_type; 671232812Sjmallett} 672232812Sjmallett 673232812Sjmallettstatic inline void cvmx_wqe_set_tt(cvmx_wqe_t *work, int tt) 674232812Sjmallett{ 675232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 676232812Sjmallett { 677232812Sjmallett work->word1.cn68xx.tag_type = (cvmx_pow_tag_type_t)tt; 678232812Sjmallett work->word1.cn68xx.zero_2 = 0; 679232812Sjmallett } 680232812Sjmallett else 681232812Sjmallett { 682232812Sjmallett work->word1.cn38xx.tag_type = (cvmx_pow_tag_type_t)tt; 683232812Sjmallett work->word1.cn38xx.zero_2 = 0; 684232812Sjmallett } 685232812Sjmallett} 686232812Sjmallett 687232812Sjmallettstatic inline int cvmx_wqe_get_unused8(cvmx_wqe_t *work) 688232812Sjmallett{ 689232812Sjmallett int len; 690232812Sjmallett 691232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 692232812Sjmallett len = work->word0.pip.cn68xx.unused1; 693232812Sjmallett else 694232812Sjmallett len = work->word0.pip.cn38xx.unused; 695232812Sjmallett 696232812Sjmallett return len; 697232812Sjmallett} 698232812Sjmallett 699232812Sjmallettstatic inline void cvmx_wqe_set_unused8(cvmx_wqe_t *work, int v) 700232812Sjmallett{ 701232812Sjmallett if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 702232812Sjmallett work->word0.pip.cn68xx.unused1 = v; 703232812Sjmallett else 704232812Sjmallett work->word0.pip.cn38xx.unused = v; 705232812Sjmallett} 706232812Sjmallett 707210284Sjmallett#ifdef __cplusplus 708210284Sjmallett} 709210284Sjmallett#endif 710210284Sjmallett 711210284Sjmallett#endif /* __CVMX_WQE_H__ */ 712