1221420Sdes/* 2162852Sdes * Copyright (c) 2018-2019 Cavium, Inc. 3162852Sdes * All rights reserved. 4162852Sdes * 5162852Sdes * Redistribution and use in source and binary forms, with or without 6162852Sdes * modification, are permitted provided that the following conditions 7162852Sdes * are met: 8162852Sdes * 9162852Sdes * 1. Redistributions of source code must retain the above copyright 10162852Sdes * notice, this list of conditions and the following disclaimer. 11162852Sdes * 2. Redistributions in binary form must reproduce the above copyright 12162852Sdes * notice, this list of conditions and the following disclaimer in the 13162852Sdes * documentation and/or other materials provided with the distribution. 14162852Sdes * 15162852Sdes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16162852Sdes * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17162852Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18162852Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19162852Sdes * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20162852Sdes * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21162852Sdes * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22162852Sdes * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23162852Sdes * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24162852Sdes * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25162852Sdes * POSSIBILITY OF SUCH DAMAGE. 26162852Sdes * 27162852Sdes * $FreeBSD: stable/10/sys/dev/qlnx/qlnxe/ecore_tcp_ip.h 337519 2018-08-09 01:39:47Z davidcs $ 28162852Sdes */ 29162852Sdes 30162852Sdes#ifndef __ECORE_TCP_IP_H 31162852Sdes#define __ECORE_TCP_IP_H 32162852Sdes 33162852Sdes#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */ 34162852Sdes#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ 35162852Sdes#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */ 36162852Sdes#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ 37162852Sdes#define ETH_P_IP 0x0800 /* Internet Protocol packet */ 38162852Sdes#define ETH_HLEN 14 /* Total octets in header. */ 39162852Sdes#define VLAN_HLEN 4 /* additional bytes required by VLAN */ 40162852Sdes#define MAX_VLAN_PRIO 7 /* Max vlan priority value in 801.1Q tag */ 41162852Sdes 42162852Sdes#define MAX_DSCP 63 /* Max DSCP value in IP header */ 43162852Sdes#define IPPROTO_TCP 6 44162852Sdes 45162852Sdes#ifndef htonl 46162852Sdes#define htonl(val) OSAL_CPU_TO_BE32(val) 47162852Sdes#endif 48162852Sdes 49162852Sdes#ifndef ntohl 50162852Sdes#define ntohl(val) OSAL_BE32_TO_CPU(val) 51162852Sdes#endif 52162852Sdes 53162852Sdes#ifndef htons 54162852Sdes#define htons(val) OSAL_CPU_TO_BE16(val) 55162852Sdes#endif 56162852Sdes 57162852Sdes#ifndef ntohs 58162852Sdes#define ntohs(val) OSAL_BE16_TO_CPU(val) 59162852Sdes#endif 60162852Sdes 61162852Sdes 62162852Sdesstruct ecore_ethhdr { 63162852Sdes unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ 64162852Sdes unsigned char h_source[ETH_ALEN]; /* source ether addr */ 65162852Sdes u16 h_proto; /* packet type ID field */ 66162852Sdes}; 67162852Sdes 68162852Sdesstruct ecore_iphdr { 69162852Sdes u8 ihl:4, 70162852Sdes version:4; 71162852Sdes u8 tos; 72162852Sdes u16 tot_len; 73162852Sdes u16 id; 74162852Sdes u16 frag_off; 75162852Sdes u8 ttl; 76162852Sdes u8 protocol; 77162852Sdes u16 check; 78162852Sdes u32 saddr; 79162852Sdes u32 daddr; 80162852Sdes /*The options start here. */ 81162852Sdes}; 82162852Sdes 83162852Sdesstruct ecore_vlan_ethhdr { 84162852Sdes unsigned char h_dest[ETH_ALEN]; 85162852Sdes unsigned char h_source[ETH_ALEN]; 86162852Sdes u16 h_vlan_proto; 87162852Sdes u16 h_vlan_TCI; 88162852Sdes u16 h_vlan_encapsulated_proto; 89164146Sdes}; 90164146Sdes 91164146Sdesstruct ecore_in6_addr { 92164146Sdes union { 93164146Sdes u8 u6_addr8[16]; 94164146Sdes u16 u6_addr16[8]; 95164146Sdes u32 u6_addr32[4]; 96162852Sdes } in6_u; 97162852Sdes}; 98162852Sdes 99162852Sdesstruct ecore_ipv6hdr { 100164146Sdes u8 priority:4, 101162852Sdes version:4; 102162852Sdes u8 flow_lbl[3]; 103162852Sdes 104162852Sdes u16 payload_len; 105164146Sdes u8 nexthdr; 106164146Sdes u8 hop_limit; 107164146Sdes 108164146Sdes struct ecore_in6_addr saddr; 109164146Sdes struct ecore_in6_addr daddr; 110162852Sdes}; 111162852Sdes 112162852Sdesstruct ecore_tcphdr { 113162852Sdes u16 source; 114162852Sdes u16 dest; 115162852Sdes u32 seq; 116162852Sdes u32 ack_seq; 117162852Sdes u16 res1:4, 118162852Sdes doff:4, 119162852Sdes fin:1, 120162852Sdes syn:1, 121162852Sdes rst:1, 122162852Sdes psh:1, 123162852Sdes ack:1, 124162852Sdes urg:1, 125162852Sdes ece:1, 126162852Sdes cwr:1; 127162852Sdes u16 window; 128162852Sdes u16 check; 129162852Sdes u16 urg_ptr; 130162852Sdes}; 131162852Sdes 132162852Sdesenum { 133162852Sdes INET_ECN_NOT_ECT = 0, 134162852Sdes INET_ECN_ECT_1 = 1, 135162852Sdes INET_ECN_ECT_0 = 2, 136162852Sdes INET_ECN_CE = 3, 137162852Sdes INET_ECN_MASK = 3, 138162852Sdes}; 139162852Sdes 140162852Sdes#endif 141162852Sdes