ecore_tcp_ip.h revision 337519
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 * $FreeBSD: stable/10/sys/dev/qlnx/qlnxe/ecore_tcp_ip.h 337519 2018-08-09 01:39:47Z davidcs $ 28 */ 29 30#ifndef __ECORE_TCP_IP_H 31#define __ECORE_TCP_IP_H 32 33#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */ 34#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ 35#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */ 36#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ 37#define ETH_P_IP 0x0800 /* Internet Protocol packet */ 38#define ETH_HLEN 14 /* Total octets in header. */ 39#define VLAN_HLEN 4 /* additional bytes required by VLAN */ 40#define MAX_VLAN_PRIO 7 /* Max vlan priority value in 801.1Q tag */ 41 42#define MAX_DSCP 63 /* Max DSCP value in IP header */ 43#define IPPROTO_TCP 6 44 45#ifndef htonl 46#define htonl(val) OSAL_CPU_TO_BE32(val) 47#endif 48 49#ifndef ntohl 50#define ntohl(val) OSAL_BE32_TO_CPU(val) 51#endif 52 53#ifndef htons 54#define htons(val) OSAL_CPU_TO_BE16(val) 55#endif 56 57#ifndef ntohs 58#define ntohs(val) OSAL_BE16_TO_CPU(val) 59#endif 60 61 62struct ecore_ethhdr { 63 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ 64 unsigned char h_source[ETH_ALEN]; /* source ether addr */ 65 u16 h_proto; /* packet type ID field */ 66}; 67 68struct ecore_iphdr { 69 u8 ihl:4, 70 version:4; 71 u8 tos; 72 u16 tot_len; 73 u16 id; 74 u16 frag_off; 75 u8 ttl; 76 u8 protocol; 77 u16 check; 78 u32 saddr; 79 u32 daddr; 80 /*The options start here. */ 81}; 82 83struct ecore_vlan_ethhdr { 84 unsigned char h_dest[ETH_ALEN]; 85 unsigned char h_source[ETH_ALEN]; 86 u16 h_vlan_proto; 87 u16 h_vlan_TCI; 88 u16 h_vlan_encapsulated_proto; 89}; 90 91struct ecore_in6_addr { 92 union { 93 u8 u6_addr8[16]; 94 u16 u6_addr16[8]; 95 u32 u6_addr32[4]; 96 } in6_u; 97}; 98 99struct ecore_ipv6hdr { 100 u8 priority:4, 101 version:4; 102 u8 flow_lbl[3]; 103 104 u16 payload_len; 105 u8 nexthdr; 106 u8 hop_limit; 107 108 struct ecore_in6_addr saddr; 109 struct ecore_in6_addr daddr; 110}; 111 112struct ecore_tcphdr { 113 u16 source; 114 u16 dest; 115 u32 seq; 116 u32 ack_seq; 117 u16 res1:4, 118 doff:4, 119 fin:1, 120 syn:1, 121 rst:1, 122 psh:1, 123 ack:1, 124 urg:1, 125 ece:1, 126 cwr:1; 127 u16 window; 128 u16 check; 129 u16 urg_ptr; 130}; 131 132enum { 133 INET_ECN_NOT_ECT = 0, 134 INET_ECN_ECT_1 = 1, 135 INET_ECN_ECT_0 = 2, 136 INET_ECN_CE = 3, 137 INET_ECN_MASK = 3, 138}; 139 140#endif 141