1/* 2 * Copyright (c) 2018-2019 Cavium, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#ifndef __ECORE_TCP_IP_H 29#define __ECORE_TCP_IP_H 30 31#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */ 32#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ 33#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */ 34#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ 35#define ETH_P_IP 0x0800 /* Internet Protocol packet */ 36#define ETH_HLEN 14 /* Total octets in header. */ 37#define VLAN_HLEN 4 /* additional bytes required by VLAN */ 38#define MAX_VLAN_PRIO 7 /* Max vlan priority value in 801.1Q tag */ 39 40#define MAX_DSCP 63 /* Max DSCP value in IP header */ 41#define IPPROTO_TCP 6 42 43#ifndef htonl 44#define htonl(val) OSAL_CPU_TO_BE32(val) 45#endif 46 47#ifndef ntohl 48#define ntohl(val) OSAL_BE32_TO_CPU(val) 49#endif 50 51#ifndef htons 52#define htons(val) OSAL_CPU_TO_BE16(val) 53#endif 54 55#ifndef ntohs 56#define ntohs(val) OSAL_BE16_TO_CPU(val) 57#endif 58 59struct ecore_ethhdr { 60 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ 61 unsigned char h_source[ETH_ALEN]; /* source ether addr */ 62 u16 h_proto; /* packet type ID field */ 63}; 64 65struct ecore_iphdr { 66 u8 ihl:4, 67 version:4; 68 u8 tos; 69 u16 tot_len; 70 u16 id; 71 u16 frag_off; 72 u8 ttl; 73 u8 protocol; 74 u16 check; 75 u32 saddr; 76 u32 daddr; 77 /*The options start here. */ 78}; 79 80struct ecore_vlan_ethhdr { 81 unsigned char h_dest[ETH_ALEN]; 82 unsigned char h_source[ETH_ALEN]; 83 u16 h_vlan_proto; 84 u16 h_vlan_TCI; 85 u16 h_vlan_encapsulated_proto; 86}; 87 88struct ecore_in6_addr { 89 union { 90 u8 u6_addr8[16]; 91 u16 u6_addr16[8]; 92 u32 u6_addr32[4]; 93 } in6_u; 94}; 95 96struct ecore_ipv6hdr { 97 u8 priority:4, 98 version:4; 99 u8 flow_lbl[3]; 100 101 u16 payload_len; 102 u8 nexthdr; 103 u8 hop_limit; 104 105 struct ecore_in6_addr saddr; 106 struct ecore_in6_addr daddr; 107}; 108 109struct ecore_tcphdr { 110 u16 source; 111 u16 dest; 112 u32 seq; 113 u32 ack_seq; 114 u16 res1:4, 115 doff:4, 116 fin:1, 117 syn:1, 118 rst:1, 119 psh:1, 120 ack:1, 121 urg:1, 122 ece:1, 123 cwr:1; 124 u16 window; 125 u16 check; 126 u16 urg_ptr; 127}; 128 129enum { 130 INET_ECN_NOT_ECT = 0, 131 INET_ECN_ECT_1 = 1, 132 INET_ECN_ECT_0 = 2, 133 INET_ECN_CE = 3, 134 INET_ECN_MASK = 3, 135}; 136 137#endif 138