staging: fsl-dpaa2/eth: Add APIs for DPNI objects

Add the command build/parse APIs for operating on DPNI objects through
the DPAA2 Management Complex.

Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Ioana Radulescu
2017-04-28 04:50:28 -05:00
committed by Greg Kroah-Hartman
parent 9425f00e62
commit 0352d1d852
10 changed files with 3656 additions and 0 deletions

View File

@@ -94,6 +94,8 @@ source "drivers/staging/fbtft/Kconfig"
source "drivers/staging/fsl-mc/Kconfig"
source "drivers/staging/fsl-dpaa2/Kconfig"
source "drivers/staging/wilc1000/Kconfig"
source "drivers/staging/most/Kconfig"

View File

@@ -36,6 +36,7 @@ obj-$(CONFIG_UNISYSSPAR) += unisys/
obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/
obj-$(CONFIG_FB_TFT) += fbtft/
obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/
obj-$(CONFIG_FSL_DPAA2) += fsl-dpaa2/
obj-$(CONFIG_WILC1000) += wilc1000/
obj-$(CONFIG_MOST) += most/
obj-$(CONFIG_KS7010) += ks7010/

View File

@@ -0,0 +1,17 @@
#
# Freescale DataPath Acceleration Architecture Gen2 (DPAA2) drivers
#
config FSL_DPAA2
bool "Freescale DPAA2 devices"
depends on FSL_MC_BUS
---help---
Build drivers for Freescale DataPath Acceleration
Architecture (DPAA2) family of SoCs.
config FSL_DPAA2_ETH
tristate "Freescale DPAA2 Ethernet"
depends on FSL_DPAA2 && FSL_MC_DPIO
---help---
Ethernet driver for Freescale DPAA2 SoCs, using the
Freescale MC bus driver

View File

@@ -0,0 +1,5 @@
#
# Freescale DataPath Acceleration Architecture Gen2 (DPAA2) drivers
#
obj-$(CONFIG_FSL_DPAA2_ETH) += ethernet/

View File

@@ -0,0 +1,7 @@
#
# Makefile for the Freescale DPAA2 Ethernet controller
#
obj-$(CONFIG_FSL_DPAA2_ETH) += fsl-dpaa2-eth.o
fsl-dpaa2-eth-objs := dpni.o

View File

@@ -0,0 +1,176 @@
/* Copyright 2013-2015 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the above-listed copyright holders nor the
* names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* ALTERNATIVELY, this software may be distributed under the terms of the
* GNU General Public License ("GPL") as published by the Free Software
* Foundation, either version 2 of that License or (at your option) any
* later version.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __FSL_DPKG_H_
#define __FSL_DPKG_H_
#include <linux/types.h>
#include "net.h"
/* Data Path Key Generator API
* Contains initialization APIs and runtime APIs for the Key Generator
*/
/** Key Generator properties */
/**
* Number of masks per key extraction
*/
#define DPKG_NUM_OF_MASKS 4
/**
* Number of extractions per key profile
*/
#define DPKG_MAX_NUM_OF_EXTRACTS 10
/**
* enum dpkg_extract_from_hdr_type - Selecting extraction by header types
* @DPKG_FROM_HDR: Extract selected bytes from header, by offset
* @DPKG_FROM_FIELD: Extract selected bytes from header, by offset from field
* @DPKG_FULL_FIELD: Extract a full field
*/
enum dpkg_extract_from_hdr_type {
DPKG_FROM_HDR = 0,
DPKG_FROM_FIELD = 1,
DPKG_FULL_FIELD = 2
};
/**
* enum dpkg_extract_type - Enumeration for selecting extraction type
* @DPKG_EXTRACT_FROM_HDR: Extract from the header
* @DPKG_EXTRACT_FROM_DATA: Extract from data not in specific header
* @DPKG_EXTRACT_FROM_PARSE: Extract from parser-result;
* e.g. can be used to extract header existence;
* please refer to 'Parse Result definition' section in the parser BG
*/
enum dpkg_extract_type {
DPKG_EXTRACT_FROM_HDR = 0,
DPKG_EXTRACT_FROM_DATA = 1,
DPKG_EXTRACT_FROM_PARSE = 3
};
/**
* struct dpkg_mask - A structure for defining a single extraction mask
* @mask: Byte mask for the extracted content
* @offset: Offset within the extracted content
*/
struct dpkg_mask {
u8 mask;
u8 offset;
};
/**
* struct dpkg_extract - A structure for defining a single extraction
* @type: Determines how the union below is interpreted:
* DPKG_EXTRACT_FROM_HDR: selects 'from_hdr';
* DPKG_EXTRACT_FROM_DATA: selects 'from_data';
* DPKG_EXTRACT_FROM_PARSE: selects 'from_parse'
* @extract: Selects extraction method
* @num_of_byte_masks: Defines the number of valid entries in the array below;
* This is also the number of bytes to be used as masks
* @masks: Masks parameters
*/
struct dpkg_extract {
enum dpkg_extract_type type;
/**
* union extract - Selects extraction method
* @from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR'
* @from_data - Used when 'type = DPKG_EXTRACT_FROM_DATA'
* @from_parse - Used when 'type = DPKG_EXTRACT_FROM_PARSE'
*/
union {
/**
* struct from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR'
* @prot: Any of the supported headers
* @type: Defines the type of header extraction:
* DPKG_FROM_HDR: use size & offset below;
* DPKG_FROM_FIELD: use field, size and offset below;
* DPKG_FULL_FIELD: use field below
* @field: One of the supported fields (NH_FLD_)
*
* @size: Size in bytes
* @offset: Byte offset
* @hdr_index: Clear for cases not listed below;
* Used for protocols that may have more than a single
* header, 0 indicates an outer header;
* Supported protocols (possible values):
* NET_PROT_VLAN (0, HDR_INDEX_LAST);
* NET_PROT_MPLS (0, 1, HDR_INDEX_LAST);
* NET_PROT_IP(0, HDR_INDEX_LAST);
* NET_PROT_IPv4(0, HDR_INDEX_LAST);
* NET_PROT_IPv6(0, HDR_INDEX_LAST);
*/
struct {
enum net_prot prot;
enum dpkg_extract_from_hdr_type type;
u32 field;
u8 size;
u8 offset;
u8 hdr_index;
} from_hdr;
/**
* struct from_data - Used when 'type = DPKG_EXTRACT_FROM_DATA'
* @size: Size in bytes
* @offset: Byte offset
*/
struct {
u8 size;
u8 offset;
} from_data;
/**
* struct from_parse - Used when
* 'type = DPKG_EXTRACT_FROM_PARSE'
* @size: Size in bytes
* @offset: Byte offset
*/
struct {
u8 size;
u8 offset;
} from_parse;
} extract;
u8 num_of_byte_masks;
struct dpkg_mask masks[DPKG_NUM_OF_MASKS];
};
/**
* struct dpkg_profile_cfg - A structure for defining a full Key Generation
* profile (rule)
* @num_extracts: Defines the number of valid entries in the array below
* @extracts: Array of required extractions
*/
struct dpkg_profile_cfg {
u8 num_extracts;
struct dpkg_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS];
};
#endif /* __FSL_DPKG_H_ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,480 @@
/* Copyright 2013-2015 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the above-listed copyright holders nor the
* names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* ALTERNATIVELY, this software may be distributed under the terms of the
* GNU General Public License ("GPL") as published by the Free Software
* Foundation, either version 2 of that License or (at your option) any
* later version.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __FSL_NET_H
#define __FSL_NET_H
#define LAST_HDR_INDEX 0xFFFFFFFF
/*****************************************************************************/
/* Protocol fields */
/*****************************************************************************/
/************************* Ethernet fields *********************************/
#define NH_FLD_ETH_DA (1)
#define NH_FLD_ETH_SA (NH_FLD_ETH_DA << 1)
#define NH_FLD_ETH_LENGTH (NH_FLD_ETH_DA << 2)
#define NH_FLD_ETH_TYPE (NH_FLD_ETH_DA << 3)
#define NH_FLD_ETH_FINAL_CKSUM (NH_FLD_ETH_DA << 4)
#define NH_FLD_ETH_PADDING (NH_FLD_ETH_DA << 5)
#define NH_FLD_ETH_ALL_FIELDS ((NH_FLD_ETH_DA << 6) - 1)
#define NH_FLD_ETH_ADDR_SIZE 6
/*************************** VLAN fields ***********************************/
#define NH_FLD_VLAN_VPRI (1)
#define NH_FLD_VLAN_CFI (NH_FLD_VLAN_VPRI << 1)
#define NH_FLD_VLAN_VID (NH_FLD_VLAN_VPRI << 2)
#define NH_FLD_VLAN_LENGTH (NH_FLD_VLAN_VPRI << 3)
#define NH_FLD_VLAN_TYPE (NH_FLD_VLAN_VPRI << 4)
#define NH_FLD_VLAN_ALL_FIELDS ((NH_FLD_VLAN_VPRI << 5) - 1)
#define NH_FLD_VLAN_TCI (NH_FLD_VLAN_VPRI | \
NH_FLD_VLAN_CFI | \
NH_FLD_VLAN_VID)
/************************ IP (generic) fields ******************************/
#define NH_FLD_IP_VER (1)
#define NH_FLD_IP_DSCP (NH_FLD_IP_VER << 2)
#define NH_FLD_IP_ECN (NH_FLD_IP_VER << 3)
#define NH_FLD_IP_PROTO (NH_FLD_IP_VER << 4)
#define NH_FLD_IP_SRC (NH_FLD_IP_VER << 5)
#define NH_FLD_IP_DST (NH_FLD_IP_VER << 6)
#define NH_FLD_IP_TOS_TC (NH_FLD_IP_VER << 7)
#define NH_FLD_IP_ID (NH_FLD_IP_VER << 8)
#define NH_FLD_IP_ALL_FIELDS ((NH_FLD_IP_VER << 9) - 1)
#define NH_FLD_IP_PROTO_SIZE 1
/***************************** IPV4 fields *********************************/
#define NH_FLD_IPV4_VER (1)
#define NH_FLD_IPV4_HDR_LEN (NH_FLD_IPV4_VER << 1)
#define NH_FLD_IPV4_TOS (NH_FLD_IPV4_VER << 2)
#define NH_FLD_IPV4_TOTAL_LEN (NH_FLD_IPV4_VER << 3)
#define NH_FLD_IPV4_ID (NH_FLD_IPV4_VER << 4)
#define NH_FLD_IPV4_FLAG_D (NH_FLD_IPV4_VER << 5)
#define NH_FLD_IPV4_FLAG_M (NH_FLD_IPV4_VER << 6)
#define NH_FLD_IPV4_OFFSET (NH_FLD_IPV4_VER << 7)
#define NH_FLD_IPV4_TTL (NH_FLD_IPV4_VER << 8)
#define NH_FLD_IPV4_PROTO (NH_FLD_IPV4_VER << 9)
#define NH_FLD_IPV4_CKSUM (NH_FLD_IPV4_VER << 10)
#define NH_FLD_IPV4_SRC_IP (NH_FLD_IPV4_VER << 11)
#define NH_FLD_IPV4_DST_IP (NH_FLD_IPV4_VER << 12)
#define NH_FLD_IPV4_OPTS (NH_FLD_IPV4_VER << 13)
#define NH_FLD_IPV4_OPTS_COUNT (NH_FLD_IPV4_VER << 14)
#define NH_FLD_IPV4_ALL_FIELDS ((NH_FLD_IPV4_VER << 15) - 1)
#define NH_FLD_IPV4_ADDR_SIZE 4
#define NH_FLD_IPV4_PROTO_SIZE 1
/***************************** IPV6 fields *********************************/
#define NH_FLD_IPV6_VER (1)
#define NH_FLD_IPV6_TC (NH_FLD_IPV6_VER << 1)
#define NH_FLD_IPV6_SRC_IP (NH_FLD_IPV6_VER << 2)
#define NH_FLD_IPV6_DST_IP (NH_FLD_IPV6_VER << 3)
#define NH_FLD_IPV6_NEXT_HDR (NH_FLD_IPV6_VER << 4)
#define NH_FLD_IPV6_FL (NH_FLD_IPV6_VER << 5)
#define NH_FLD_IPV6_HOP_LIMIT (NH_FLD_IPV6_VER << 6)
#define NH_FLD_IPV6_ID (NH_FLD_IPV6_VER << 7)
#define NH_FLD_IPV6_ALL_FIELDS ((NH_FLD_IPV6_VER << 8) - 1)
#define NH_FLD_IPV6_ADDR_SIZE 16
#define NH_FLD_IPV6_NEXT_HDR_SIZE 1
/***************************** ICMP fields *********************************/
#define NH_FLD_ICMP_TYPE (1)
#define NH_FLD_ICMP_CODE (NH_FLD_ICMP_TYPE << 1)
#define NH_FLD_ICMP_CKSUM (NH_FLD_ICMP_TYPE << 2)
#define NH_FLD_ICMP_ID (NH_FLD_ICMP_TYPE << 3)
#define NH_FLD_ICMP_SQ_NUM (NH_FLD_ICMP_TYPE << 4)
#define NH_FLD_ICMP_ALL_FIELDS ((NH_FLD_ICMP_TYPE << 5) - 1)
#define NH_FLD_ICMP_CODE_SIZE 1
#define NH_FLD_ICMP_TYPE_SIZE 1
/***************************** IGMP fields *********************************/
#define NH_FLD_IGMP_VERSION (1)
#define NH_FLD_IGMP_TYPE (NH_FLD_IGMP_VERSION << 1)
#define NH_FLD_IGMP_CKSUM (NH_FLD_IGMP_VERSION << 2)
#define NH_FLD_IGMP_DATA (NH_FLD_IGMP_VERSION << 3)
#define NH_FLD_IGMP_ALL_FIELDS ((NH_FLD_IGMP_VERSION << 4) - 1)
/***************************** TCP fields **********************************/
#define NH_FLD_TCP_PORT_SRC (1)
#define NH_FLD_TCP_PORT_DST (NH_FLD_TCP_PORT_SRC << 1)
#define NH_FLD_TCP_SEQ (NH_FLD_TCP_PORT_SRC << 2)
#define NH_FLD_TCP_ACK (NH_FLD_TCP_PORT_SRC << 3)
#define NH_FLD_TCP_OFFSET (NH_FLD_TCP_PORT_SRC << 4)
#define NH_FLD_TCP_FLAGS (NH_FLD_TCP_PORT_SRC << 5)
#define NH_FLD_TCP_WINDOW (NH_FLD_TCP_PORT_SRC << 6)
#define NH_FLD_TCP_CKSUM (NH_FLD_TCP_PORT_SRC << 7)
#define NH_FLD_TCP_URGPTR (NH_FLD_TCP_PORT_SRC << 8)
#define NH_FLD_TCP_OPTS (NH_FLD_TCP_PORT_SRC << 9)
#define NH_FLD_TCP_OPTS_COUNT (NH_FLD_TCP_PORT_SRC << 10)
#define NH_FLD_TCP_ALL_FIELDS ((NH_FLD_TCP_PORT_SRC << 11) - 1)
#define NH_FLD_TCP_PORT_SIZE 2
/***************************** UDP fields **********************************/
#define NH_FLD_UDP_PORT_SRC (1)
#define NH_FLD_UDP_PORT_DST (NH_FLD_UDP_PORT_SRC << 1)
#define NH_FLD_UDP_LEN (NH_FLD_UDP_PORT_SRC << 2)
#define NH_FLD_UDP_CKSUM (NH_FLD_UDP_PORT_SRC << 3)
#define NH_FLD_UDP_ALL_FIELDS ((NH_FLD_UDP_PORT_SRC << 4) - 1)
#define NH_FLD_UDP_PORT_SIZE 2
/*************************** UDP-lite fields *******************************/
#define NH_FLD_UDP_LITE_PORT_SRC (1)
#define NH_FLD_UDP_LITE_PORT_DST (NH_FLD_UDP_LITE_PORT_SRC << 1)
#define NH_FLD_UDP_LITE_ALL_FIELDS \
((NH_FLD_UDP_LITE_PORT_SRC << 2) - 1)
#define NH_FLD_UDP_LITE_PORT_SIZE 2
/*************************** UDP-encap-ESP fields **************************/
#define NH_FLD_UDP_ENC_ESP_PORT_SRC (1)
#define NH_FLD_UDP_ENC_ESP_PORT_DST (NH_FLD_UDP_ENC_ESP_PORT_SRC << 1)
#define NH_FLD_UDP_ENC_ESP_LEN (NH_FLD_UDP_ENC_ESP_PORT_SRC << 2)
#define NH_FLD_UDP_ENC_ESP_CKSUM (NH_FLD_UDP_ENC_ESP_PORT_SRC << 3)
#define NH_FLD_UDP_ENC_ESP_SPI (NH_FLD_UDP_ENC_ESP_PORT_SRC << 4)
#define NH_FLD_UDP_ENC_ESP_SEQUENCE_NUM (NH_FLD_UDP_ENC_ESP_PORT_SRC << 5)
#define NH_FLD_UDP_ENC_ESP_ALL_FIELDS \
((NH_FLD_UDP_ENC_ESP_PORT_SRC << 6) - 1)
#define NH_FLD_UDP_ENC_ESP_PORT_SIZE 2
#define NH_FLD_UDP_ENC_ESP_SPI_SIZE 4
/***************************** SCTP fields *********************************/
#define NH_FLD_SCTP_PORT_SRC (1)
#define NH_FLD_SCTP_PORT_DST (NH_FLD_SCTP_PORT_SRC << 1)
#define NH_FLD_SCTP_VER_TAG (NH_FLD_SCTP_PORT_SRC << 2)
#define NH_FLD_SCTP_CKSUM (NH_FLD_SCTP_PORT_SRC << 3)
#define NH_FLD_SCTP_ALL_FIELDS ((NH_FLD_SCTP_PORT_SRC << 4) - 1)
#define NH_FLD_SCTP_PORT_SIZE 2
/***************************** DCCP fields *********************************/
#define NH_FLD_DCCP_PORT_SRC (1)
#define NH_FLD_DCCP_PORT_DST (NH_FLD_DCCP_PORT_SRC << 1)
#define NH_FLD_DCCP_ALL_FIELDS ((NH_FLD_DCCP_PORT_SRC << 2) - 1)
#define NH_FLD_DCCP_PORT_SIZE 2
/***************************** IPHC fields *********************************/
#define NH_FLD_IPHC_CID (1)
#define NH_FLD_IPHC_CID_TYPE (NH_FLD_IPHC_CID << 1)
#define NH_FLD_IPHC_HCINDEX (NH_FLD_IPHC_CID << 2)
#define NH_FLD_IPHC_GEN (NH_FLD_IPHC_CID << 3)
#define NH_FLD_IPHC_D_BIT (NH_FLD_IPHC_CID << 4)
#define NH_FLD_IPHC_ALL_FIELDS ((NH_FLD_IPHC_CID << 5) - 1)
/***************************** SCTP fields *********************************/
#define NH_FLD_SCTP_CHUNK_DATA_TYPE (1)
#define NH_FLD_SCTP_CHUNK_DATA_FLAGS (NH_FLD_SCTP_CHUNK_DATA_TYPE << 1)
#define NH_FLD_SCTP_CHUNK_DATA_LENGTH (NH_FLD_SCTP_CHUNK_DATA_TYPE << 2)
#define NH_FLD_SCTP_CHUNK_DATA_TSN (NH_FLD_SCTP_CHUNK_DATA_TYPE << 3)
#define NH_FLD_SCTP_CHUNK_DATA_STREAM_ID (NH_FLD_SCTP_CHUNK_DATA_TYPE << 4)
#define NH_FLD_SCTP_CHUNK_DATA_STREAM_SQN (NH_FLD_SCTP_CHUNK_DATA_TYPE << 5)
#define NH_FLD_SCTP_CHUNK_DATA_PAYLOAD_PID (NH_FLD_SCTP_CHUNK_DATA_TYPE << 6)
#define NH_FLD_SCTP_CHUNK_DATA_UNORDERED (NH_FLD_SCTP_CHUNK_DATA_TYPE << 7)
#define NH_FLD_SCTP_CHUNK_DATA_BEGGINING (NH_FLD_SCTP_CHUNK_DATA_TYPE << 8)
#define NH_FLD_SCTP_CHUNK_DATA_END (NH_FLD_SCTP_CHUNK_DATA_TYPE << 9)
#define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS \
((NH_FLD_SCTP_CHUNK_DATA_TYPE << 10) - 1)
/*************************** L2TPV2 fields *********************************/
#define NH_FLD_L2TPV2_TYPE_BIT (1)
#define NH_FLD_L2TPV2_LENGTH_BIT (NH_FLD_L2TPV2_TYPE_BIT << 1)
#define NH_FLD_L2TPV2_SEQUENCE_BIT (NH_FLD_L2TPV2_TYPE_BIT << 2)
#define NH_FLD_L2TPV2_OFFSET_BIT (NH_FLD_L2TPV2_TYPE_BIT << 3)
#define NH_FLD_L2TPV2_PRIORITY_BIT (NH_FLD_L2TPV2_TYPE_BIT << 4)
#define NH_FLD_L2TPV2_VERSION (NH_FLD_L2TPV2_TYPE_BIT << 5)
#define NH_FLD_L2TPV2_LEN (NH_FLD_L2TPV2_TYPE_BIT << 6)
#define NH_FLD_L2TPV2_TUNNEL_ID (NH_FLD_L2TPV2_TYPE_BIT << 7)
#define NH_FLD_L2TPV2_SESSION_ID (NH_FLD_L2TPV2_TYPE_BIT << 8)
#define NH_FLD_L2TPV2_NS (NH_FLD_L2TPV2_TYPE_BIT << 9)
#define NH_FLD_L2TPV2_NR (NH_FLD_L2TPV2_TYPE_BIT << 10)
#define NH_FLD_L2TPV2_OFFSET_SIZE (NH_FLD_L2TPV2_TYPE_BIT << 11)
#define NH_FLD_L2TPV2_FIRST_BYTE (NH_FLD_L2TPV2_TYPE_BIT << 12)
#define NH_FLD_L2TPV2_ALL_FIELDS \
((NH_FLD_L2TPV2_TYPE_BIT << 13) - 1)
/*************************** L2TPV3 fields *********************************/
#define NH_FLD_L2TPV3_CTRL_TYPE_BIT (1)
#define NH_FLD_L2TPV3_CTRL_LENGTH_BIT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 1)
#define NH_FLD_L2TPV3_CTRL_SEQUENCE_BIT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 2)
#define NH_FLD_L2TPV3_CTRL_VERSION (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 3)
#define NH_FLD_L2TPV3_CTRL_LENGTH (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 4)
#define NH_FLD_L2TPV3_CTRL_CONTROL (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 5)
#define NH_FLD_L2TPV3_CTRL_SENT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 6)
#define NH_FLD_L2TPV3_CTRL_RECV (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 7)
#define NH_FLD_L2TPV3_CTRL_FIRST_BYTE (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 8)
#define NH_FLD_L2TPV3_CTRL_ALL_FIELDS \
((NH_FLD_L2TPV3_CTRL_TYPE_BIT << 9) - 1)
#define NH_FLD_L2TPV3_SESS_TYPE_BIT (1)
#define NH_FLD_L2TPV3_SESS_VERSION (NH_FLD_L2TPV3_SESS_TYPE_BIT << 1)
#define NH_FLD_L2TPV3_SESS_ID (NH_FLD_L2TPV3_SESS_TYPE_BIT << 2)
#define NH_FLD_L2TPV3_SESS_COOKIE (NH_FLD_L2TPV3_SESS_TYPE_BIT << 3)
#define NH_FLD_L2TPV3_SESS_ALL_FIELDS \
((NH_FLD_L2TPV3_SESS_TYPE_BIT << 4) - 1)
/**************************** PPP fields ***********************************/
#define NH_FLD_PPP_PID (1)
#define NH_FLD_PPP_COMPRESSED (NH_FLD_PPP_PID << 1)
#define NH_FLD_PPP_ALL_FIELDS ((NH_FLD_PPP_PID << 2) - 1)
/************************** PPPoE fields ***********************************/
#define NH_FLD_PPPOE_VER (1)
#define NH_FLD_PPPOE_TYPE (NH_FLD_PPPOE_VER << 1)
#define NH_FLD_PPPOE_CODE (NH_FLD_PPPOE_VER << 2)
#define NH_FLD_PPPOE_SID (NH_FLD_PPPOE_VER << 3)
#define NH_FLD_PPPOE_LEN (NH_FLD_PPPOE_VER << 4)
#define NH_FLD_PPPOE_SESSION (NH_FLD_PPPOE_VER << 5)
#define NH_FLD_PPPOE_PID (NH_FLD_PPPOE_VER << 6)
#define NH_FLD_PPPOE_ALL_FIELDS ((NH_FLD_PPPOE_VER << 7) - 1)
/************************* PPP-Mux fields **********************************/
#define NH_FLD_PPPMUX_PID (1)
#define NH_FLD_PPPMUX_CKSUM (NH_FLD_PPPMUX_PID << 1)
#define NH_FLD_PPPMUX_COMPRESSED (NH_FLD_PPPMUX_PID << 2)
#define NH_FLD_PPPMUX_ALL_FIELDS ((NH_FLD_PPPMUX_PID << 3) - 1)
/*********************** PPP-Mux sub-frame fields **************************/
#define NH_FLD_PPPMUX_SUBFRM_PFF (1)
#define NH_FLD_PPPMUX_SUBFRM_LXT (NH_FLD_PPPMUX_SUBFRM_PFF << 1)
#define NH_FLD_PPPMUX_SUBFRM_LEN (NH_FLD_PPPMUX_SUBFRM_PFF << 2)
#define NH_FLD_PPPMUX_SUBFRM_PID (NH_FLD_PPPMUX_SUBFRM_PFF << 3)
#define NH_FLD_PPPMUX_SUBFRM_USE_PID (NH_FLD_PPPMUX_SUBFRM_PFF << 4)
#define NH_FLD_PPPMUX_SUBFRM_ALL_FIELDS \
((NH_FLD_PPPMUX_SUBFRM_PFF << 5) - 1)
/*************************** LLC fields ************************************/
#define NH_FLD_LLC_DSAP (1)
#define NH_FLD_LLC_SSAP (NH_FLD_LLC_DSAP << 1)
#define NH_FLD_LLC_CTRL (NH_FLD_LLC_DSAP << 2)
#define NH_FLD_LLC_ALL_FIELDS ((NH_FLD_LLC_DSAP << 3) - 1)
/*************************** NLPID fields **********************************/
#define NH_FLD_NLPID_NLPID (1)
#define NH_FLD_NLPID_ALL_FIELDS ((NH_FLD_NLPID_NLPID << 1) - 1)
/*************************** SNAP fields ***********************************/
#define NH_FLD_SNAP_OUI (1)
#define NH_FLD_SNAP_PID (NH_FLD_SNAP_OUI << 1)
#define NH_FLD_SNAP_ALL_FIELDS ((NH_FLD_SNAP_OUI << 2) - 1)
/*************************** LLC SNAP fields *******************************/
#define NH_FLD_LLC_SNAP_TYPE (1)
#define NH_FLD_LLC_SNAP_ALL_FIELDS ((NH_FLD_LLC_SNAP_TYPE << 1) - 1)
#define NH_FLD_ARP_HTYPE (1)
#define NH_FLD_ARP_PTYPE (NH_FLD_ARP_HTYPE << 1)
#define NH_FLD_ARP_HLEN (NH_FLD_ARP_HTYPE << 2)
#define NH_FLD_ARP_PLEN (NH_FLD_ARP_HTYPE << 3)
#define NH_FLD_ARP_OPER (NH_FLD_ARP_HTYPE << 4)
#define NH_FLD_ARP_SHA (NH_FLD_ARP_HTYPE << 5)
#define NH_FLD_ARP_SPA (NH_FLD_ARP_HTYPE << 6)
#define NH_FLD_ARP_THA (NH_FLD_ARP_HTYPE << 7)
#define NH_FLD_ARP_TPA (NH_FLD_ARP_HTYPE << 8)
#define NH_FLD_ARP_ALL_FIELDS ((NH_FLD_ARP_HTYPE << 9) - 1)
/*************************** RFC2684 fields ********************************/
#define NH_FLD_RFC2684_LLC (1)
#define NH_FLD_RFC2684_NLPID (NH_FLD_RFC2684_LLC << 1)
#define NH_FLD_RFC2684_OUI (NH_FLD_RFC2684_LLC << 2)
#define NH_FLD_RFC2684_PID (NH_FLD_RFC2684_LLC << 3)
#define NH_FLD_RFC2684_VPN_OUI (NH_FLD_RFC2684_LLC << 4)
#define NH_FLD_RFC2684_VPN_IDX (NH_FLD_RFC2684_LLC << 5)
#define NH_FLD_RFC2684_ALL_FIELDS ((NH_FLD_RFC2684_LLC << 6) - 1)
/*************************** User defined fields ***************************/
#define NH_FLD_USER_DEFINED_SRCPORT (1)
#define NH_FLD_USER_DEFINED_PCDID (NH_FLD_USER_DEFINED_SRCPORT << 1)
#define NH_FLD_USER_DEFINED_ALL_FIELDS \
((NH_FLD_USER_DEFINED_SRCPORT << 2) - 1)
/*************************** Payload fields ********************************/
#define NH_FLD_PAYLOAD_BUFFER (1)
#define NH_FLD_PAYLOAD_SIZE (NH_FLD_PAYLOAD_BUFFER << 1)
#define NH_FLD_MAX_FRM_SIZE (NH_FLD_PAYLOAD_BUFFER << 2)
#define NH_FLD_MIN_FRM_SIZE (NH_FLD_PAYLOAD_BUFFER << 3)
#define NH_FLD_PAYLOAD_TYPE (NH_FLD_PAYLOAD_BUFFER << 4)
#define NH_FLD_FRAME_SIZE (NH_FLD_PAYLOAD_BUFFER << 5)
#define NH_FLD_PAYLOAD_ALL_FIELDS ((NH_FLD_PAYLOAD_BUFFER << 6) - 1)
/*************************** GRE fields ************************************/
#define NH_FLD_GRE_TYPE (1)
#define NH_FLD_GRE_ALL_FIELDS ((NH_FLD_GRE_TYPE << 1) - 1)
/*************************** MINENCAP fields *******************************/
#define NH_FLD_MINENCAP_SRC_IP (1)
#define NH_FLD_MINENCAP_DST_IP (NH_FLD_MINENCAP_SRC_IP << 1)
#define NH_FLD_MINENCAP_TYPE (NH_FLD_MINENCAP_SRC_IP << 2)
#define NH_FLD_MINENCAP_ALL_FIELDS \
((NH_FLD_MINENCAP_SRC_IP << 3) - 1)
/*************************** IPSEC AH fields *******************************/
#define NH_FLD_IPSEC_AH_SPI (1)
#define NH_FLD_IPSEC_AH_NH (NH_FLD_IPSEC_AH_SPI << 1)
#define NH_FLD_IPSEC_AH_ALL_FIELDS ((NH_FLD_IPSEC_AH_SPI << 2) - 1)
/*************************** IPSEC ESP fields ******************************/
#define NH_FLD_IPSEC_ESP_SPI (1)
#define NH_FLD_IPSEC_ESP_SEQUENCE_NUM (NH_FLD_IPSEC_ESP_SPI << 1)
#define NH_FLD_IPSEC_ESP_ALL_FIELDS ((NH_FLD_IPSEC_ESP_SPI << 2) - 1)
#define NH_FLD_IPSEC_ESP_SPI_SIZE 4
/*************************** MPLS fields ***********************************/
#define NH_FLD_MPLS_LABEL_STACK (1)
#define NH_FLD_MPLS_LABEL_STACK_ALL_FIELDS \
((NH_FLD_MPLS_LABEL_STACK << 1) - 1)
/*************************** MACSEC fields *********************************/
#define NH_FLD_MACSEC_SECTAG (1)
#define NH_FLD_MACSEC_ALL_FIELDS ((NH_FLD_MACSEC_SECTAG << 1) - 1)
/*************************** GTP fields ************************************/
#define NH_FLD_GTP_TEID (1)
/* Protocol options */
/* Ethernet options */
#define NH_OPT_ETH_BROADCAST 1
#define NH_OPT_ETH_MULTICAST 2
#define NH_OPT_ETH_UNICAST 3
#define NH_OPT_ETH_BPDU 4
#define NH_ETH_IS_MULTICAST_ADDR(addr) (addr[0] & 0x01)
/* also applicable for broadcast */
/* VLAN options */
#define NH_OPT_VLAN_CFI 1
/* IPV4 options */
#define NH_OPT_IPV4_UNICAST 1
#define NH_OPT_IPV4_MULTICAST 2
#define NH_OPT_IPV4_BROADCAST 3
#define NH_OPT_IPV4_OPTION 4
#define NH_OPT_IPV4_FRAG 5
#define NH_OPT_IPV4_INITIAL_FRAG 6
/* IPV6 options */
#define NH_OPT_IPV6_UNICAST 1
#define NH_OPT_IPV6_MULTICAST 2
#define NH_OPT_IPV6_OPTION 3
#define NH_OPT_IPV6_FRAG 4
#define NH_OPT_IPV6_INITIAL_FRAG 5
/* General IP options (may be used for any version) */
#define NH_OPT_IP_FRAG 1
#define NH_OPT_IP_INITIAL_FRAG 2
#define NH_OPT_IP_OPTION 3
/* Minenc. options */
#define NH_OPT_MINENCAP_SRC_ADDR_PRESENT 1
/* GRE. options */
#define NH_OPT_GRE_ROUTING_PRESENT 1
/* TCP options */
#define NH_OPT_TCP_OPTIONS 1
#define NH_OPT_TCP_CONTROL_HIGH_BITS 2
#define NH_OPT_TCP_CONTROL_LOW_BITS 3
/* CAPWAP options */
#define NH_OPT_CAPWAP_DTLS 1
enum net_prot {
NET_PROT_NONE = 0,
NET_PROT_PAYLOAD,
NET_PROT_ETH,
NET_PROT_VLAN,
NET_PROT_IPV4,
NET_PROT_IPV6,
NET_PROT_IP,
NET_PROT_TCP,
NET_PROT_UDP,
NET_PROT_UDP_LITE,
NET_PROT_IPHC,
NET_PROT_SCTP,
NET_PROT_SCTP_CHUNK_DATA,
NET_PROT_PPPOE,
NET_PROT_PPP,
NET_PROT_PPPMUX,
NET_PROT_PPPMUX_SUBFRM,
NET_PROT_L2TPV2,
NET_PROT_L2TPV3_CTRL,
NET_PROT_L2TPV3_SESS,
NET_PROT_LLC,
NET_PROT_LLC_SNAP,
NET_PROT_NLPID,
NET_PROT_SNAP,
NET_PROT_MPLS,
NET_PROT_IPSEC_AH,
NET_PROT_IPSEC_ESP,
NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
NET_PROT_MACSEC,
NET_PROT_GRE,
NET_PROT_MINENCAP,
NET_PROT_DCCP,
NET_PROT_ICMP,
NET_PROT_IGMP,
NET_PROT_ARP,
NET_PROT_CAPWAP_DATA,
NET_PROT_CAPWAP_CTRL,
NET_PROT_RFC2684,
NET_PROT_ICMPV6,
NET_PROT_FCOE,
NET_PROT_FIP,
NET_PROT_ISCSI,
NET_PROT_GTP,
NET_PROT_USER_DEFINED_L2,
NET_PROT_USER_DEFINED_L3,
NET_PROT_USER_DEFINED_L4,
NET_PROT_USER_DEFINED_L5,
NET_PROT_USER_DEFINED_SHIM1,
NET_PROT_USER_DEFINED_SHIM2,
NET_PROT_DUMMY_LAST
};
/*! IEEE8021.Q */
#define NH_IEEE8021Q_ETYPE 0x8100
#define NH_IEEE8021Q_HDR(etype, pcp, dei, vlan_id) \
((((u32)((etype) & 0xFFFF)) << 16) | \
(((u32)((pcp) & 0x07)) << 13) | \
(((u32)((dei) & 0x01)) << 12) | \
(((u32)((vlan_id) & 0xFFF))))
#endif /* __FSL_NET_H */