18c2ecf20Sopenharmony_ci/***********************license start*************** 28c2ecf20Sopenharmony_ci * Author: Cavium Networks 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Contact: support@caviumnetworks.com 58c2ecf20Sopenharmony_ci * This file is part of the OCTEON SDK 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (c) 2003-2008 Cavium Networks 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This file is free software; you can redistribute it and/or modify 108c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License, Version 2, as 118c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * This file is distributed in the hope that it will be useful, but 148c2ecf20Sopenharmony_ci * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty 158c2ecf20Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or 168c2ecf20Sopenharmony_ci * NONINFRINGEMENT. See the GNU General Public License for more 178c2ecf20Sopenharmony_ci * details. 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License 208c2ecf20Sopenharmony_ci * along with this file; if not, write to the Free Software 218c2ecf20Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 228c2ecf20Sopenharmony_ci * or visit http://www.gnu.org/licenses/. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * This file may also be available under a different license from Cavium. 258c2ecf20Sopenharmony_ci * Contact Cavium Networks for more information 268c2ecf20Sopenharmony_ci ***********************license end**************************************/ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/** 298c2ecf20Sopenharmony_ci * 308c2ecf20Sopenharmony_ci * This header file defines the work queue entry (wqe) data structure. 318c2ecf20Sopenharmony_ci * Since this is a commonly used structure that depends on structures 328c2ecf20Sopenharmony_ci * from several hardware blocks, those definitions have been placed 338c2ecf20Sopenharmony_ci * in this file to create a single point of definition of the wqe 348c2ecf20Sopenharmony_ci * format. 358c2ecf20Sopenharmony_ci * Data structures are still named according to the block that they 368c2ecf20Sopenharmony_ci * relate to. 378c2ecf20Sopenharmony_ci * 388c2ecf20Sopenharmony_ci */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#ifndef __CVMX_WQE_H__ 418c2ecf20Sopenharmony_ci#define __CVMX_WQE_H__ 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#include <asm/octeon/cvmx-packet.h> 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define OCT_TAG_TYPE_STRING(x) \ 478c2ecf20Sopenharmony_ci (((x) == CVMX_POW_TAG_TYPE_ORDERED) ? "ORDERED" : \ 488c2ecf20Sopenharmony_ci (((x) == CVMX_POW_TAG_TYPE_ATOMIC) ? "ATOMIC" : \ 498c2ecf20Sopenharmony_ci (((x) == CVMX_POW_TAG_TYPE_NULL) ? "NULL" : \ 508c2ecf20Sopenharmony_ci "NULL_NULL"))) 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/** 538c2ecf20Sopenharmony_ci * HW decode / err_code in work queue entry 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_citypedef union { 568c2ecf20Sopenharmony_ci uint64_t u64; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci /* Use this struct if the hardware determines that the packet is IP */ 598c2ecf20Sopenharmony_ci struct { 608c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD 618c2ecf20Sopenharmony_ci /* HW sets this to the number of buffers used by this packet */ 628c2ecf20Sopenharmony_ci uint64_t bufs:8; 638c2ecf20Sopenharmony_ci /* HW sets to the number of L2 bytes prior to the IP */ 648c2ecf20Sopenharmony_ci uint64_t ip_offset:8; 658c2ecf20Sopenharmony_ci /* set to 1 if we found DSA/VLAN in the L2 */ 668c2ecf20Sopenharmony_ci uint64_t vlan_valid:1; 678c2ecf20Sopenharmony_ci /* Set to 1 if the DSA/VLAN tag is stacked */ 688c2ecf20Sopenharmony_ci uint64_t vlan_stacked:1; 698c2ecf20Sopenharmony_ci uint64_t unassigned:1; 708c2ecf20Sopenharmony_ci /* HW sets to the DSA/VLAN CFI flag (valid when vlan_valid) */ 718c2ecf20Sopenharmony_ci uint64_t vlan_cfi:1; 728c2ecf20Sopenharmony_ci /* HW sets to the DSA/VLAN_ID field (valid when vlan_valid) */ 738c2ecf20Sopenharmony_ci uint64_t vlan_id:12; 748c2ecf20Sopenharmony_ci /* Ring Identifier (if PCIe). Requires PIP_GBL_CTL[RING_EN]=1 */ 758c2ecf20Sopenharmony_ci uint64_t pr:4; 768c2ecf20Sopenharmony_ci uint64_t unassigned2:8; 778c2ecf20Sopenharmony_ci /* the packet needs to be decompressed */ 788c2ecf20Sopenharmony_ci uint64_t dec_ipcomp:1; 798c2ecf20Sopenharmony_ci /* the packet is either TCP or UDP */ 808c2ecf20Sopenharmony_ci uint64_t tcp_or_udp:1; 818c2ecf20Sopenharmony_ci /* the packet needs to be decrypted (ESP or AH) */ 828c2ecf20Sopenharmony_ci uint64_t dec_ipsec:1; 838c2ecf20Sopenharmony_ci /* the packet is IPv6 */ 848c2ecf20Sopenharmony_ci uint64_t is_v6:1; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci /* 878c2ecf20Sopenharmony_ci * (rcv_error, not_IP, IP_exc, is_frag, L4_error, 888c2ecf20Sopenharmony_ci * software, etc.). 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci /* 928c2ecf20Sopenharmony_ci * reserved for software use, hardware will clear on 938c2ecf20Sopenharmony_ci * packet creation. 948c2ecf20Sopenharmony_ci */ 958c2ecf20Sopenharmony_ci uint64_t software:1; 968c2ecf20Sopenharmony_ci /* exceptional conditions below */ 978c2ecf20Sopenharmony_ci /* the receive interface hardware detected an L4 error 988c2ecf20Sopenharmony_ci * (only applies if !is_frag) (only applies if 998c2ecf20Sopenharmony_ci * !rcv_error && !not_IP && !IP_exc && !is_frag) 1008c2ecf20Sopenharmony_ci * failure indicated in err_code below, decode: 1018c2ecf20Sopenharmony_ci * 1028c2ecf20Sopenharmony_ci * - 1 = Malformed L4 1038c2ecf20Sopenharmony_ci * - 2 = L4 Checksum Error: the L4 checksum value is 1048c2ecf20Sopenharmony_ci * - 3 = UDP Length Error: The UDP length field would 1058c2ecf20Sopenharmony_ci * make the UDP data longer than what remains in 1068c2ecf20Sopenharmony_ci * the IP packet (as defined by the IP header 1078c2ecf20Sopenharmony_ci * length field). 1088c2ecf20Sopenharmony_ci * - 4 = Bad L4 Port: either the source or destination 1098c2ecf20Sopenharmony_ci * TCP/UDP port is 0. 1108c2ecf20Sopenharmony_ci * - 8 = TCP FIN Only: the packet is TCP and only the 1118c2ecf20Sopenharmony_ci * FIN flag set. 1128c2ecf20Sopenharmony_ci * - 9 = TCP No Flags: the packet is TCP and no flags 1138c2ecf20Sopenharmony_ci * are set. 1148c2ecf20Sopenharmony_ci * - 10 = TCP FIN RST: the packet is TCP and both FIN 1158c2ecf20Sopenharmony_ci * and RST are set. 1168c2ecf20Sopenharmony_ci * - 11 = TCP SYN URG: the packet is TCP and both SYN 1178c2ecf20Sopenharmony_ci * and URG are set. 1188c2ecf20Sopenharmony_ci * - 12 = TCP SYN RST: the packet is TCP and both SYN 1198c2ecf20Sopenharmony_ci * and RST are set. 1208c2ecf20Sopenharmony_ci * - 13 = TCP SYN FIN: the packet is TCP and both SYN 1218c2ecf20Sopenharmony_ci * and FIN are set. 1228c2ecf20Sopenharmony_ci */ 1238c2ecf20Sopenharmony_ci uint64_t L4_error:1; 1248c2ecf20Sopenharmony_ci /* set if the packet is a fragment */ 1258c2ecf20Sopenharmony_ci uint64_t is_frag:1; 1268c2ecf20Sopenharmony_ci /* the receive interface hardware detected an IP error 1278c2ecf20Sopenharmony_ci * / exception (only applies if !rcv_error && !not_IP) 1288c2ecf20Sopenharmony_ci * failure indicated in err_code below, decode: 1298c2ecf20Sopenharmony_ci * 1308c2ecf20Sopenharmony_ci * - 1 = Not IP: the IP version field is neither 4 nor 1318c2ecf20Sopenharmony_ci * 6. 1328c2ecf20Sopenharmony_ci * - 2 = IPv4 Header Checksum Error: the IPv4 header 1338c2ecf20Sopenharmony_ci * has a checksum violation. 1348c2ecf20Sopenharmony_ci * - 3 = IP Malformed Header: the packet is not long 1358c2ecf20Sopenharmony_ci * enough to contain the IP header. 1368c2ecf20Sopenharmony_ci * - 4 = IP Malformed: the packet is not long enough 1378c2ecf20Sopenharmony_ci * to contain the bytes indicated by the IP 1388c2ecf20Sopenharmony_ci * header. Pad is allowed. 1398c2ecf20Sopenharmony_ci * - 5 = IP TTL Hop: the IPv4 TTL field or the IPv6 1408c2ecf20Sopenharmony_ci * Hop Count field are zero. 1418c2ecf20Sopenharmony_ci * - 6 = IP Options 1428c2ecf20Sopenharmony_ci */ 1438c2ecf20Sopenharmony_ci uint64_t IP_exc:1; 1448c2ecf20Sopenharmony_ci /* 1458c2ecf20Sopenharmony_ci * Set if the hardware determined that the packet is a 1468c2ecf20Sopenharmony_ci * broadcast. 1478c2ecf20Sopenharmony_ci */ 1488c2ecf20Sopenharmony_ci uint64_t is_bcast:1; 1498c2ecf20Sopenharmony_ci /* 1508c2ecf20Sopenharmony_ci * St if the hardware determined that the packet is a 1518c2ecf20Sopenharmony_ci * multi-cast. 1528c2ecf20Sopenharmony_ci */ 1538c2ecf20Sopenharmony_ci uint64_t is_mcast:1; 1548c2ecf20Sopenharmony_ci /* 1558c2ecf20Sopenharmony_ci * Set if the packet may not be IP (must be zero in 1568c2ecf20Sopenharmony_ci * this case). 1578c2ecf20Sopenharmony_ci */ 1588c2ecf20Sopenharmony_ci uint64_t not_IP:1; 1598c2ecf20Sopenharmony_ci /* 1608c2ecf20Sopenharmony_ci * The receive interface hardware detected a receive 1618c2ecf20Sopenharmony_ci * error (must be zero in this case). 1628c2ecf20Sopenharmony_ci */ 1638c2ecf20Sopenharmony_ci uint64_t rcv_error:1; 1648c2ecf20Sopenharmony_ci /* lower err_code = first-level descriptor of the 1658c2ecf20Sopenharmony_ci * work */ 1668c2ecf20Sopenharmony_ci /* zero for packet submitted by hardware that isn't on 1678c2ecf20Sopenharmony_ci * the slow path */ 1688c2ecf20Sopenharmony_ci /* type is cvmx_pip_err_t */ 1698c2ecf20Sopenharmony_ci uint64_t err_code:8; 1708c2ecf20Sopenharmony_ci#else 1718c2ecf20Sopenharmony_ci uint64_t err_code:8; 1728c2ecf20Sopenharmony_ci uint64_t rcv_error:1; 1738c2ecf20Sopenharmony_ci uint64_t not_IP:1; 1748c2ecf20Sopenharmony_ci uint64_t is_mcast:1; 1758c2ecf20Sopenharmony_ci uint64_t is_bcast:1; 1768c2ecf20Sopenharmony_ci uint64_t IP_exc:1; 1778c2ecf20Sopenharmony_ci uint64_t is_frag:1; 1788c2ecf20Sopenharmony_ci uint64_t L4_error:1; 1798c2ecf20Sopenharmony_ci uint64_t software:1; 1808c2ecf20Sopenharmony_ci uint64_t is_v6:1; 1818c2ecf20Sopenharmony_ci uint64_t dec_ipsec:1; 1828c2ecf20Sopenharmony_ci uint64_t tcp_or_udp:1; 1838c2ecf20Sopenharmony_ci uint64_t dec_ipcomp:1; 1848c2ecf20Sopenharmony_ci uint64_t unassigned2:4; 1858c2ecf20Sopenharmony_ci uint64_t unassigned2a:4; 1868c2ecf20Sopenharmony_ci uint64_t pr:4; 1878c2ecf20Sopenharmony_ci uint64_t vlan_id:12; 1888c2ecf20Sopenharmony_ci uint64_t vlan_cfi:1; 1898c2ecf20Sopenharmony_ci uint64_t unassigned:1; 1908c2ecf20Sopenharmony_ci uint64_t vlan_stacked:1; 1918c2ecf20Sopenharmony_ci uint64_t vlan_valid:1; 1928c2ecf20Sopenharmony_ci uint64_t ip_offset:8; 1938c2ecf20Sopenharmony_ci uint64_t bufs:8; 1948c2ecf20Sopenharmony_ci#endif 1958c2ecf20Sopenharmony_ci } s; 1968c2ecf20Sopenharmony_ci struct { 1978c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD 1988c2ecf20Sopenharmony_ci uint64_t bufs:8; 1998c2ecf20Sopenharmony_ci uint64_t ip_offset:8; 2008c2ecf20Sopenharmony_ci uint64_t vlan_valid:1; 2018c2ecf20Sopenharmony_ci uint64_t vlan_stacked:1; 2028c2ecf20Sopenharmony_ci uint64_t unassigned:1; 2038c2ecf20Sopenharmony_ci uint64_t vlan_cfi:1; 2048c2ecf20Sopenharmony_ci uint64_t vlan_id:12; 2058c2ecf20Sopenharmony_ci uint64_t port:12; /* MAC/PIP port number. */ 2068c2ecf20Sopenharmony_ci uint64_t dec_ipcomp:1; 2078c2ecf20Sopenharmony_ci uint64_t tcp_or_udp:1; 2088c2ecf20Sopenharmony_ci uint64_t dec_ipsec:1; 2098c2ecf20Sopenharmony_ci uint64_t is_v6:1; 2108c2ecf20Sopenharmony_ci uint64_t software:1; 2118c2ecf20Sopenharmony_ci uint64_t L4_error:1; 2128c2ecf20Sopenharmony_ci uint64_t is_frag:1; 2138c2ecf20Sopenharmony_ci uint64_t IP_exc:1; 2148c2ecf20Sopenharmony_ci uint64_t is_bcast:1; 2158c2ecf20Sopenharmony_ci uint64_t is_mcast:1; 2168c2ecf20Sopenharmony_ci uint64_t not_IP:1; 2178c2ecf20Sopenharmony_ci uint64_t rcv_error:1; 2188c2ecf20Sopenharmony_ci uint64_t err_code:8; 2198c2ecf20Sopenharmony_ci#else 2208c2ecf20Sopenharmony_ci uint64_t err_code:8; 2218c2ecf20Sopenharmony_ci uint64_t rcv_error:1; 2228c2ecf20Sopenharmony_ci uint64_t not_IP:1; 2238c2ecf20Sopenharmony_ci uint64_t is_mcast:1; 2248c2ecf20Sopenharmony_ci uint64_t is_bcast:1; 2258c2ecf20Sopenharmony_ci uint64_t IP_exc:1; 2268c2ecf20Sopenharmony_ci uint64_t is_frag:1; 2278c2ecf20Sopenharmony_ci uint64_t L4_error:1; 2288c2ecf20Sopenharmony_ci uint64_t software:1; 2298c2ecf20Sopenharmony_ci uint64_t is_v6:1; 2308c2ecf20Sopenharmony_ci uint64_t dec_ipsec:1; 2318c2ecf20Sopenharmony_ci uint64_t tcp_or_udp:1; 2328c2ecf20Sopenharmony_ci uint64_t dec_ipcomp:1; 2338c2ecf20Sopenharmony_ci uint64_t port:12; 2348c2ecf20Sopenharmony_ci uint64_t vlan_id:12; 2358c2ecf20Sopenharmony_ci uint64_t vlan_cfi:1; 2368c2ecf20Sopenharmony_ci uint64_t unassigned:1; 2378c2ecf20Sopenharmony_ci uint64_t vlan_stacked:1; 2388c2ecf20Sopenharmony_ci uint64_t vlan_valid:1; 2398c2ecf20Sopenharmony_ci uint64_t ip_offset:8; 2408c2ecf20Sopenharmony_ci uint64_t bufs:8; 2418c2ecf20Sopenharmony_ci#endif 2428c2ecf20Sopenharmony_ci } s_cn68xx; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci /* use this to get at the 16 vlan bits */ 2458c2ecf20Sopenharmony_ci struct { 2468c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD 2478c2ecf20Sopenharmony_ci uint64_t unused1:16; 2488c2ecf20Sopenharmony_ci uint64_t vlan:16; 2498c2ecf20Sopenharmony_ci uint64_t unused2:32; 2508c2ecf20Sopenharmony_ci#else 2518c2ecf20Sopenharmony_ci uint64_t unused2:32; 2528c2ecf20Sopenharmony_ci uint64_t vlan:16; 2538c2ecf20Sopenharmony_ci uint64_t unused1:16; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci#endif 2568c2ecf20Sopenharmony_ci } svlan; 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci /* 2598c2ecf20Sopenharmony_ci * use this struct if the hardware could not determine that 2608c2ecf20Sopenharmony_ci * the packet is ip. 2618c2ecf20Sopenharmony_ci */ 2628c2ecf20Sopenharmony_ci struct { 2638c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD 2648c2ecf20Sopenharmony_ci /* 2658c2ecf20Sopenharmony_ci * HW sets this to the number of buffers used by this 2668c2ecf20Sopenharmony_ci * packet. 2678c2ecf20Sopenharmony_ci */ 2688c2ecf20Sopenharmony_ci uint64_t bufs:8; 2698c2ecf20Sopenharmony_ci uint64_t unused:8; 2708c2ecf20Sopenharmony_ci /* set to 1 if we found DSA/VLAN in the L2 */ 2718c2ecf20Sopenharmony_ci uint64_t vlan_valid:1; 2728c2ecf20Sopenharmony_ci /* Set to 1 if the DSA/VLAN tag is stacked */ 2738c2ecf20Sopenharmony_ci uint64_t vlan_stacked:1; 2748c2ecf20Sopenharmony_ci uint64_t unassigned:1; 2758c2ecf20Sopenharmony_ci /* 2768c2ecf20Sopenharmony_ci * HW sets to the DSA/VLAN CFI flag (valid when 2778c2ecf20Sopenharmony_ci * vlan_valid) 2788c2ecf20Sopenharmony_ci */ 2798c2ecf20Sopenharmony_ci uint64_t vlan_cfi:1; 2808c2ecf20Sopenharmony_ci /* 2818c2ecf20Sopenharmony_ci * HW sets to the DSA/VLAN_ID field (valid when 2828c2ecf20Sopenharmony_ci * vlan_valid). 2838c2ecf20Sopenharmony_ci */ 2848c2ecf20Sopenharmony_ci uint64_t vlan_id:12; 2858c2ecf20Sopenharmony_ci /* 2868c2ecf20Sopenharmony_ci * Ring Identifier (if PCIe). Requires 2878c2ecf20Sopenharmony_ci * PIP_GBL_CTL[RING_EN]=1 2888c2ecf20Sopenharmony_ci */ 2898c2ecf20Sopenharmony_ci uint64_t pr:4; 2908c2ecf20Sopenharmony_ci uint64_t unassigned2:12; 2918c2ecf20Sopenharmony_ci /* 2928c2ecf20Sopenharmony_ci * reserved for software use, hardware will clear on 2938c2ecf20Sopenharmony_ci * packet creation. 2948c2ecf20Sopenharmony_ci */ 2958c2ecf20Sopenharmony_ci uint64_t software:1; 2968c2ecf20Sopenharmony_ci uint64_t unassigned3:1; 2978c2ecf20Sopenharmony_ci /* 2988c2ecf20Sopenharmony_ci * set if the hardware determined that the packet is 2998c2ecf20Sopenharmony_ci * rarp. 3008c2ecf20Sopenharmony_ci */ 3018c2ecf20Sopenharmony_ci uint64_t is_rarp:1; 3028c2ecf20Sopenharmony_ci /* 3038c2ecf20Sopenharmony_ci * set if the hardware determined that the packet is 3048c2ecf20Sopenharmony_ci * arp 3058c2ecf20Sopenharmony_ci */ 3068c2ecf20Sopenharmony_ci uint64_t is_arp:1; 3078c2ecf20Sopenharmony_ci /* 3088c2ecf20Sopenharmony_ci * set if the hardware determined that the packet is a 3098c2ecf20Sopenharmony_ci * broadcast. 3108c2ecf20Sopenharmony_ci */ 3118c2ecf20Sopenharmony_ci uint64_t is_bcast:1; 3128c2ecf20Sopenharmony_ci /* 3138c2ecf20Sopenharmony_ci * set if the hardware determined that the packet is a 3148c2ecf20Sopenharmony_ci * multi-cast 3158c2ecf20Sopenharmony_ci */ 3168c2ecf20Sopenharmony_ci uint64_t is_mcast:1; 3178c2ecf20Sopenharmony_ci /* 3188c2ecf20Sopenharmony_ci * set if the packet may not be IP (must be one in 3198c2ecf20Sopenharmony_ci * this case) 3208c2ecf20Sopenharmony_ci */ 3218c2ecf20Sopenharmony_ci uint64_t not_IP:1; 3228c2ecf20Sopenharmony_ci /* The receive interface hardware detected a receive 3238c2ecf20Sopenharmony_ci * error. Failure indicated in err_code below, 3248c2ecf20Sopenharmony_ci * decode: 3258c2ecf20Sopenharmony_ci * 3268c2ecf20Sopenharmony_ci * - 1 = partial error: a packet was partially 3278c2ecf20Sopenharmony_ci * received, but internal buffering / bandwidth 3288c2ecf20Sopenharmony_ci * was not adequate to receive the entire 3298c2ecf20Sopenharmony_ci * packet. 3308c2ecf20Sopenharmony_ci * - 2 = jabber error: the RGMII packet was too large 3318c2ecf20Sopenharmony_ci * and is truncated. 3328c2ecf20Sopenharmony_ci * - 3 = overrun error: the RGMII packet is longer 3338c2ecf20Sopenharmony_ci * than allowed and had an FCS error. 3348c2ecf20Sopenharmony_ci * - 4 = oversize error: the RGMII packet is longer 3358c2ecf20Sopenharmony_ci * than allowed. 3368c2ecf20Sopenharmony_ci * - 5 = alignment error: the RGMII packet is not an 3378c2ecf20Sopenharmony_ci * integer number of bytes 3388c2ecf20Sopenharmony_ci * and had an FCS error (100M and 10M only). 3398c2ecf20Sopenharmony_ci * - 6 = fragment error: the RGMII packet is shorter 3408c2ecf20Sopenharmony_ci * than allowed and had an FCS error. 3418c2ecf20Sopenharmony_ci * - 7 = GMX FCS error: the RGMII packet had an FCS 3428c2ecf20Sopenharmony_ci * error. 3438c2ecf20Sopenharmony_ci * - 8 = undersize error: the RGMII packet is shorter 3448c2ecf20Sopenharmony_ci * than allowed. 3458c2ecf20Sopenharmony_ci * - 9 = extend error: the RGMII packet had an extend 3468c2ecf20Sopenharmony_ci * error. 3478c2ecf20Sopenharmony_ci * - 10 = length mismatch error: the RGMII packet had 3488c2ecf20Sopenharmony_ci * a length that did not match the length field 3498c2ecf20Sopenharmony_ci * in the L2 HDR. 3508c2ecf20Sopenharmony_ci * - 11 = RGMII RX error/SPI4 DIP4 Error: the RGMII 3518c2ecf20Sopenharmony_ci * packet had one or more data reception errors 3528c2ecf20Sopenharmony_ci * (RXERR) or the SPI4 packet had one or more 3538c2ecf20Sopenharmony_ci * DIP4 errors. 3548c2ecf20Sopenharmony_ci * - 12 = RGMII skip error/SPI4 Abort Error: the RGMII 3558c2ecf20Sopenharmony_ci * packet was not large enough to cover the 3568c2ecf20Sopenharmony_ci * skipped bytes or the SPI4 packet was 3578c2ecf20Sopenharmony_ci * terminated with an About EOPS. 3588c2ecf20Sopenharmony_ci * - 13 = RGMII nibble error/SPI4 Port NXA Error: the 3598c2ecf20Sopenharmony_ci * RGMII packet had a studder error (data not 3608c2ecf20Sopenharmony_ci * repeated - 10/100M only) or the SPI4 packet 3618c2ecf20Sopenharmony_ci * was sent to an NXA. 3628c2ecf20Sopenharmony_ci * - 16 = FCS error: a SPI4.2 packet had an FCS error. 3638c2ecf20Sopenharmony_ci * - 17 = Skip error: a packet was not large enough to 3648c2ecf20Sopenharmony_ci * cover the skipped bytes. 3658c2ecf20Sopenharmony_ci * - 18 = L2 header malformed: the packet is not long 3668c2ecf20Sopenharmony_ci * enough to contain the L2. 3678c2ecf20Sopenharmony_ci */ 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci uint64_t rcv_error:1; 3708c2ecf20Sopenharmony_ci /* 3718c2ecf20Sopenharmony_ci * lower err_code = first-level descriptor of the 3728c2ecf20Sopenharmony_ci * work 3738c2ecf20Sopenharmony_ci */ 3748c2ecf20Sopenharmony_ci /* 3758c2ecf20Sopenharmony_ci * zero for packet submitted by hardware that isn't on 3768c2ecf20Sopenharmony_ci * the slow path 3778c2ecf20Sopenharmony_ci */ 3788c2ecf20Sopenharmony_ci /* type is cvmx_pip_err_t (union, so can't use directly */ 3798c2ecf20Sopenharmony_ci uint64_t err_code:8; 3808c2ecf20Sopenharmony_ci#else 3818c2ecf20Sopenharmony_ci uint64_t err_code:8; 3828c2ecf20Sopenharmony_ci uint64_t rcv_error:1; 3838c2ecf20Sopenharmony_ci uint64_t not_IP:1; 3848c2ecf20Sopenharmony_ci uint64_t is_mcast:1; 3858c2ecf20Sopenharmony_ci uint64_t is_bcast:1; 3868c2ecf20Sopenharmony_ci uint64_t is_arp:1; 3878c2ecf20Sopenharmony_ci uint64_t is_rarp:1; 3888c2ecf20Sopenharmony_ci uint64_t unassigned3:1; 3898c2ecf20Sopenharmony_ci uint64_t software:1; 3908c2ecf20Sopenharmony_ci uint64_t unassigned2:4; 3918c2ecf20Sopenharmony_ci uint64_t unassigned2a:8; 3928c2ecf20Sopenharmony_ci uint64_t pr:4; 3938c2ecf20Sopenharmony_ci uint64_t vlan_id:12; 3948c2ecf20Sopenharmony_ci uint64_t vlan_cfi:1; 3958c2ecf20Sopenharmony_ci uint64_t unassigned:1; 3968c2ecf20Sopenharmony_ci uint64_t vlan_stacked:1; 3978c2ecf20Sopenharmony_ci uint64_t vlan_valid:1; 3988c2ecf20Sopenharmony_ci uint64_t unused:8; 3998c2ecf20Sopenharmony_ci uint64_t bufs:8; 4008c2ecf20Sopenharmony_ci#endif 4018c2ecf20Sopenharmony_ci } snoip; 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci} cvmx_pip_wqe_word2; 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ciunion cvmx_pip_wqe_word0 { 4068c2ecf20Sopenharmony_ci struct { 4078c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD 4088c2ecf20Sopenharmony_ci /** 4098c2ecf20Sopenharmony_ci * raw chksum result generated by the HW 4108c2ecf20Sopenharmony_ci */ 4118c2ecf20Sopenharmony_ci uint16_t hw_chksum; 4128c2ecf20Sopenharmony_ci /** 4138c2ecf20Sopenharmony_ci * Field unused by hardware - available for software 4148c2ecf20Sopenharmony_ci */ 4158c2ecf20Sopenharmony_ci uint8_t unused; 4168c2ecf20Sopenharmony_ci /** 4178c2ecf20Sopenharmony_ci * Next pointer used by hardware for list maintenance. 4188c2ecf20Sopenharmony_ci * May be written/read by HW before the work queue 4198c2ecf20Sopenharmony_ci * entry is scheduled to a PP (Only 36 bits used in 4208c2ecf20Sopenharmony_ci * Octeon 1) 4218c2ecf20Sopenharmony_ci */ 4228c2ecf20Sopenharmony_ci uint64_t next_ptr:40; 4238c2ecf20Sopenharmony_ci#else 4248c2ecf20Sopenharmony_ci uint64_t next_ptr:40; 4258c2ecf20Sopenharmony_ci uint8_t unused; 4268c2ecf20Sopenharmony_ci uint16_t hw_chksum; 4278c2ecf20Sopenharmony_ci#endif 4288c2ecf20Sopenharmony_ci } cn38xx; 4298c2ecf20Sopenharmony_ci struct { 4308c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD 4318c2ecf20Sopenharmony_ci uint64_t l4ptr:8; /* 56..63 */ 4328c2ecf20Sopenharmony_ci uint64_t unused0:8; /* 48..55 */ 4338c2ecf20Sopenharmony_ci uint64_t l3ptr:8; /* 40..47 */ 4348c2ecf20Sopenharmony_ci uint64_t l2ptr:8; /* 32..39 */ 4358c2ecf20Sopenharmony_ci uint64_t unused1:18; /* 14..31 */ 4368c2ecf20Sopenharmony_ci uint64_t bpid:6; /* 8..13 */ 4378c2ecf20Sopenharmony_ci uint64_t unused2:2; /* 6..7 */ 4388c2ecf20Sopenharmony_ci uint64_t pknd:6; /* 0..5 */ 4398c2ecf20Sopenharmony_ci#else 4408c2ecf20Sopenharmony_ci uint64_t pknd:6; /* 0..5 */ 4418c2ecf20Sopenharmony_ci uint64_t unused2:2; /* 6..7 */ 4428c2ecf20Sopenharmony_ci uint64_t bpid:6; /* 8..13 */ 4438c2ecf20Sopenharmony_ci uint64_t unused1:18; /* 14..31 */ 4448c2ecf20Sopenharmony_ci uint64_t l2ptr:8; /* 32..39 */ 4458c2ecf20Sopenharmony_ci uint64_t l3ptr:8; /* 40..47 */ 4468c2ecf20Sopenharmony_ci uint64_t unused0:8; /* 48..55 */ 4478c2ecf20Sopenharmony_ci uint64_t l4ptr:8; /* 56..63 */ 4488c2ecf20Sopenharmony_ci#endif 4498c2ecf20Sopenharmony_ci } cn68xx; 4508c2ecf20Sopenharmony_ci}; 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ciunion cvmx_wqe_word0 { 4538c2ecf20Sopenharmony_ci uint64_t u64; 4548c2ecf20Sopenharmony_ci union cvmx_pip_wqe_word0 pip; 4558c2ecf20Sopenharmony_ci}; 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ciunion cvmx_wqe_word1 { 4588c2ecf20Sopenharmony_ci uint64_t u64; 4598c2ecf20Sopenharmony_ci struct { 4608c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD 4618c2ecf20Sopenharmony_ci uint64_t len:16; 4628c2ecf20Sopenharmony_ci uint64_t varies:14; 4638c2ecf20Sopenharmony_ci /** 4648c2ecf20Sopenharmony_ci * the type of the tag (ORDERED, ATOMIC, NULL) 4658c2ecf20Sopenharmony_ci */ 4668c2ecf20Sopenharmony_ci uint64_t tag_type:2; 4678c2ecf20Sopenharmony_ci uint64_t tag:32; 4688c2ecf20Sopenharmony_ci#else 4698c2ecf20Sopenharmony_ci uint64_t tag:32; 4708c2ecf20Sopenharmony_ci uint64_t tag_type:2; 4718c2ecf20Sopenharmony_ci uint64_t varies:14; 4728c2ecf20Sopenharmony_ci uint64_t len:16; 4738c2ecf20Sopenharmony_ci#endif 4748c2ecf20Sopenharmony_ci }; 4758c2ecf20Sopenharmony_ci struct { 4768c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD 4778c2ecf20Sopenharmony_ci uint64_t len:16; 4788c2ecf20Sopenharmony_ci uint64_t zero_0:1; 4798c2ecf20Sopenharmony_ci /** 4808c2ecf20Sopenharmony_ci * HW sets this to what it thought the priority of 4818c2ecf20Sopenharmony_ci * the input packet was 4828c2ecf20Sopenharmony_ci */ 4838c2ecf20Sopenharmony_ci uint64_t qos:3; 4848c2ecf20Sopenharmony_ci 4858c2ecf20Sopenharmony_ci uint64_t zero_1:1; 4868c2ecf20Sopenharmony_ci /** 4878c2ecf20Sopenharmony_ci * the group that the work queue entry will be scheduled to 4888c2ecf20Sopenharmony_ci */ 4898c2ecf20Sopenharmony_ci uint64_t grp:6; 4908c2ecf20Sopenharmony_ci uint64_t zero_2:3; 4918c2ecf20Sopenharmony_ci uint64_t tag_type:2; 4928c2ecf20Sopenharmony_ci uint64_t tag:32; 4938c2ecf20Sopenharmony_ci#else 4948c2ecf20Sopenharmony_ci uint64_t tag:32; 4958c2ecf20Sopenharmony_ci uint64_t tag_type:2; 4968c2ecf20Sopenharmony_ci uint64_t zero_2:3; 4978c2ecf20Sopenharmony_ci uint64_t grp:6; 4988c2ecf20Sopenharmony_ci uint64_t zero_1:1; 4998c2ecf20Sopenharmony_ci uint64_t qos:3; 5008c2ecf20Sopenharmony_ci uint64_t zero_0:1; 5018c2ecf20Sopenharmony_ci uint64_t len:16; 5028c2ecf20Sopenharmony_ci#endif 5038c2ecf20Sopenharmony_ci } cn68xx; 5048c2ecf20Sopenharmony_ci struct { 5058c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD 5068c2ecf20Sopenharmony_ci /** 5078c2ecf20Sopenharmony_ci * HW sets to the total number of bytes in the packet 5088c2ecf20Sopenharmony_ci */ 5098c2ecf20Sopenharmony_ci uint64_t len:16; 5108c2ecf20Sopenharmony_ci /** 5118c2ecf20Sopenharmony_ci * HW sets this to input physical port 5128c2ecf20Sopenharmony_ci */ 5138c2ecf20Sopenharmony_ci uint64_t ipprt:6; 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci /** 5168c2ecf20Sopenharmony_ci * HW sets this to what it thought the priority of 5178c2ecf20Sopenharmony_ci * the input packet was 5188c2ecf20Sopenharmony_ci */ 5198c2ecf20Sopenharmony_ci uint64_t qos:3; 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci /** 5228c2ecf20Sopenharmony_ci * the group that the work queue entry will be scheduled to 5238c2ecf20Sopenharmony_ci */ 5248c2ecf20Sopenharmony_ci uint64_t grp:4; 5258c2ecf20Sopenharmony_ci /** 5268c2ecf20Sopenharmony_ci * the type of the tag (ORDERED, ATOMIC, NULL) 5278c2ecf20Sopenharmony_ci */ 5288c2ecf20Sopenharmony_ci uint64_t tag_type:3; 5298c2ecf20Sopenharmony_ci /** 5308c2ecf20Sopenharmony_ci * the synchronization/ordering tag 5318c2ecf20Sopenharmony_ci */ 5328c2ecf20Sopenharmony_ci uint64_t tag:32; 5338c2ecf20Sopenharmony_ci#else 5348c2ecf20Sopenharmony_ci uint64_t tag:32; 5358c2ecf20Sopenharmony_ci uint64_t tag_type:2; 5368c2ecf20Sopenharmony_ci uint64_t zero_2:1; 5378c2ecf20Sopenharmony_ci uint64_t grp:4; 5388c2ecf20Sopenharmony_ci uint64_t qos:3; 5398c2ecf20Sopenharmony_ci uint64_t ipprt:6; 5408c2ecf20Sopenharmony_ci uint64_t len:16; 5418c2ecf20Sopenharmony_ci#endif 5428c2ecf20Sopenharmony_ci } cn38xx; 5438c2ecf20Sopenharmony_ci}; 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci/** 5468c2ecf20Sopenharmony_ci * Work queue entry format 5478c2ecf20Sopenharmony_ci * 5488c2ecf20Sopenharmony_ci * must be 8-byte aligned 5498c2ecf20Sopenharmony_ci */ 5508c2ecf20Sopenharmony_cistruct cvmx_wqe { 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci /***************************************************************** 5538c2ecf20Sopenharmony_ci * WORD 0 5548c2ecf20Sopenharmony_ci * HW WRITE: the following 64 bits are filled by HW when a packet arrives 5558c2ecf20Sopenharmony_ci */ 5568c2ecf20Sopenharmony_ci union cvmx_wqe_word0 word0; 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci /***************************************************************** 5598c2ecf20Sopenharmony_ci * WORD 1 5608c2ecf20Sopenharmony_ci * HW WRITE: the following 64 bits are filled by HW when a packet arrives 5618c2ecf20Sopenharmony_ci */ 5628c2ecf20Sopenharmony_ci union cvmx_wqe_word1 word1; 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci /** 5658c2ecf20Sopenharmony_ci * WORD 2 HW WRITE: the following 64-bits are filled in by 5668c2ecf20Sopenharmony_ci * hardware when a packet arrives This indicates a variety of 5678c2ecf20Sopenharmony_ci * status and error conditions. 5688c2ecf20Sopenharmony_ci */ 5698c2ecf20Sopenharmony_ci cvmx_pip_wqe_word2 word2; 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci /** 5728c2ecf20Sopenharmony_ci * Pointer to the first segment of the packet. 5738c2ecf20Sopenharmony_ci */ 5748c2ecf20Sopenharmony_ci union cvmx_buf_ptr packet_ptr; 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ci /** 5778c2ecf20Sopenharmony_ci * HW WRITE: octeon will fill in a programmable amount from the 5788c2ecf20Sopenharmony_ci * packet, up to (at most, but perhaps less) the amount 5798c2ecf20Sopenharmony_ci * needed to fill the work queue entry to 128 bytes 5808c2ecf20Sopenharmony_ci * 5818c2ecf20Sopenharmony_ci * If the packet is recognized to be IP, the hardware starts 5828c2ecf20Sopenharmony_ci * (except that the IPv4 header is padded for appropriate 5838c2ecf20Sopenharmony_ci * alignment) writing here where the IP header starts. If the 5848c2ecf20Sopenharmony_ci * packet is not recognized to be IP, the hardware starts 5858c2ecf20Sopenharmony_ci * writing the beginning of the packet here. 5868c2ecf20Sopenharmony_ci */ 5878c2ecf20Sopenharmony_ci uint8_t packet_data[96]; 5888c2ecf20Sopenharmony_ci 5898c2ecf20Sopenharmony_ci /** 5908c2ecf20Sopenharmony_ci * If desired, SW can make the work Q entry any length. For the 5918c2ecf20Sopenharmony_ci * purposes of discussion here, Assume 128B always, as this is all that 5928c2ecf20Sopenharmony_ci * the hardware deals with. 5938c2ecf20Sopenharmony_ci * 5948c2ecf20Sopenharmony_ci */ 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci} CVMX_CACHE_LINE_ALIGNED; 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_cistatic inline int cvmx_wqe_get_port(struct cvmx_wqe *work) 5998c2ecf20Sopenharmony_ci{ 6008c2ecf20Sopenharmony_ci int port; 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 6038c2ecf20Sopenharmony_ci port = work->word2.s_cn68xx.port; 6048c2ecf20Sopenharmony_ci else 6058c2ecf20Sopenharmony_ci port = work->word1.cn38xx.ipprt; 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_ci return port; 6088c2ecf20Sopenharmony_ci} 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_cistatic inline void cvmx_wqe_set_port(struct cvmx_wqe *work, int port) 6118c2ecf20Sopenharmony_ci{ 6128c2ecf20Sopenharmony_ci if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 6138c2ecf20Sopenharmony_ci work->word2.s_cn68xx.port = port; 6148c2ecf20Sopenharmony_ci else 6158c2ecf20Sopenharmony_ci work->word1.cn38xx.ipprt = port; 6168c2ecf20Sopenharmony_ci} 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_cistatic inline int cvmx_wqe_get_grp(struct cvmx_wqe *work) 6198c2ecf20Sopenharmony_ci{ 6208c2ecf20Sopenharmony_ci int grp; 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_ci if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 6238c2ecf20Sopenharmony_ci grp = work->word1.cn68xx.grp; 6248c2ecf20Sopenharmony_ci else 6258c2ecf20Sopenharmony_ci grp = work->word1.cn38xx.grp; 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci return grp; 6288c2ecf20Sopenharmony_ci} 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_cistatic inline void cvmx_wqe_set_grp(struct cvmx_wqe *work, int grp) 6318c2ecf20Sopenharmony_ci{ 6328c2ecf20Sopenharmony_ci if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 6338c2ecf20Sopenharmony_ci work->word1.cn68xx.grp = grp; 6348c2ecf20Sopenharmony_ci else 6358c2ecf20Sopenharmony_ci work->word1.cn38xx.grp = grp; 6368c2ecf20Sopenharmony_ci} 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_cistatic inline int cvmx_wqe_get_qos(struct cvmx_wqe *work) 6398c2ecf20Sopenharmony_ci{ 6408c2ecf20Sopenharmony_ci int qos; 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ci if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 6438c2ecf20Sopenharmony_ci qos = work->word1.cn68xx.qos; 6448c2ecf20Sopenharmony_ci else 6458c2ecf20Sopenharmony_ci qos = work->word1.cn38xx.qos; 6468c2ecf20Sopenharmony_ci 6478c2ecf20Sopenharmony_ci return qos; 6488c2ecf20Sopenharmony_ci} 6498c2ecf20Sopenharmony_ci 6508c2ecf20Sopenharmony_cistatic inline void cvmx_wqe_set_qos(struct cvmx_wqe *work, int qos) 6518c2ecf20Sopenharmony_ci{ 6528c2ecf20Sopenharmony_ci if (octeon_has_feature(OCTEON_FEATURE_CN68XX_WQE)) 6538c2ecf20Sopenharmony_ci work->word1.cn68xx.qos = qos; 6548c2ecf20Sopenharmony_ci else 6558c2ecf20Sopenharmony_ci work->word1.cn38xx.qos = qos; 6568c2ecf20Sopenharmony_ci} 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ci#endif /* __CVMX_WQE_H__ */ 659