162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Linux driver for VMware's vmxnet3 ethernet NIC.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (C) 2008-2022, VMware, Inc. All Rights Reserved.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify it
762306a36Sopenharmony_ci * under the terms of the GNU General Public License as published by the
862306a36Sopenharmony_ci * Free Software Foundation; version 2 of the License and no later version.
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * This program is distributed in the hope that it will be useful, but
1162306a36Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of
1262306a36Sopenharmony_ci * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
1362306a36Sopenharmony_ci * NON INFRINGEMENT.  See the GNU General Public License for more
1462306a36Sopenharmony_ci * details.
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License
1762306a36Sopenharmony_ci * along with this program; if not, write to the Free Software
1862306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci * The full GNU General Public License is included in this distribution in
2162306a36Sopenharmony_ci * the file called "COPYING".
2262306a36Sopenharmony_ci *
2362306a36Sopenharmony_ci * Maintained by: pv-drivers@vmware.com
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci */
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#ifndef _VMXNET3_DEFS_H_
2862306a36Sopenharmony_ci#define _VMXNET3_DEFS_H_
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#include "upt1_defs.h"
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci/* all registers are 32 bit wide */
3362306a36Sopenharmony_ci/* BAR 1 */
3462306a36Sopenharmony_cienum {
3562306a36Sopenharmony_ci	VMXNET3_REG_VRRS	= 0x0,	/* Vmxnet3 Revision Report Selection */
3662306a36Sopenharmony_ci	VMXNET3_REG_UVRS	= 0x8,	/* UPT Version Report Selection */
3762306a36Sopenharmony_ci	VMXNET3_REG_DSAL	= 0x10,	/* Driver Shared Address Low */
3862306a36Sopenharmony_ci	VMXNET3_REG_DSAH	= 0x18,	/* Driver Shared Address High */
3962306a36Sopenharmony_ci	VMXNET3_REG_CMD		= 0x20,	/* Command */
4062306a36Sopenharmony_ci	VMXNET3_REG_MACL	= 0x28,	/* MAC Address Low */
4162306a36Sopenharmony_ci	VMXNET3_REG_MACH	= 0x30,	/* MAC Address High */
4262306a36Sopenharmony_ci	VMXNET3_REG_ICR		= 0x38,	/* Interrupt Cause Register */
4362306a36Sopenharmony_ci	VMXNET3_REG_ECR		= 0x40, /* Event Cause Register */
4462306a36Sopenharmony_ci	VMXNET3_REG_DCR         = 0x48, /* Device capability register,
4562306a36Sopenharmony_ci					 * from 0x48 to 0x80
4662306a36Sopenharmony_ci					 */
4762306a36Sopenharmony_ci	VMXNET3_REG_PTCR        = 0x88, /* Passthru capbility register
4862306a36Sopenharmony_ci					 * from 0x88 to 0xb0
4962306a36Sopenharmony_ci					 */
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/* BAR 0 */
5362306a36Sopenharmony_cienum {
5462306a36Sopenharmony_ci	VMXNET3_REG_IMR		= 0x0,	 /* Interrupt Mask Register */
5562306a36Sopenharmony_ci	VMXNET3_REG_TXPROD	= 0x600, /* Tx Producer Index */
5662306a36Sopenharmony_ci	VMXNET3_REG_RXPROD	= 0x800, /* Rx Producer Index for ring 1 */
5762306a36Sopenharmony_ci	VMXNET3_REG_RXPROD2	= 0xA00	 /* Rx Producer Index for ring 2 */
5862306a36Sopenharmony_ci};
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci/* For Large PT BAR, the following offset to DB register */
6162306a36Sopenharmony_cienum {
6262306a36Sopenharmony_ci	VMXNET3_REG_LB_TXPROD   = 0x1000, /* Tx Producer Index */
6362306a36Sopenharmony_ci	VMXNET3_REG_LB_RXPROD   = 0x1400, /* Rx Producer Index for ring 1 */
6462306a36Sopenharmony_ci	VMXNET3_REG_LB_RXPROD2  = 0x1800, /* Rx Producer Index for ring 2 */
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define VMXNET3_PT_REG_SIZE         4096		/* BAR 0 */
6862306a36Sopenharmony_ci#define VMXNET3_LARGE_PT_REG_SIZE   8192		/* large PT pages */
6962306a36Sopenharmony_ci#define VMXNET3_VD_REG_SIZE         4096		/* BAR 1 */
7062306a36Sopenharmony_ci#define VMXNET3_LARGE_BAR0_REG_SIZE (4096 * 4096)	/* LARGE BAR 0 */
7162306a36Sopenharmony_ci#define VMXNET3_OOB_REG_SIZE        (4094 * 4096)	/* OOB pages */
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci#define VMXNET3_REG_ALIGN       8	/* All registers are 8-byte aligned. */
7462306a36Sopenharmony_ci#define VMXNET3_REG_ALIGN_MASK  0x7
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* I/O Mapped access to registers */
7762306a36Sopenharmony_ci#define VMXNET3_IO_TYPE_PT              0
7862306a36Sopenharmony_ci#define VMXNET3_IO_TYPE_VD              1
7962306a36Sopenharmony_ci#define VMXNET3_IO_ADDR(type, reg)      (((type) << 24) | ((reg) & 0xFFFFFF))
8062306a36Sopenharmony_ci#define VMXNET3_IO_TYPE(addr)           ((addr) >> 24)
8162306a36Sopenharmony_ci#define VMXNET3_IO_REG(addr)            ((addr) & 0xFFFFFF)
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_cienum {
8462306a36Sopenharmony_ci	VMXNET3_CMD_FIRST_SET = 0xCAFE0000,
8562306a36Sopenharmony_ci	VMXNET3_CMD_ACTIVATE_DEV = VMXNET3_CMD_FIRST_SET,
8662306a36Sopenharmony_ci	VMXNET3_CMD_QUIESCE_DEV,
8762306a36Sopenharmony_ci	VMXNET3_CMD_RESET_DEV,
8862306a36Sopenharmony_ci	VMXNET3_CMD_UPDATE_RX_MODE,
8962306a36Sopenharmony_ci	VMXNET3_CMD_UPDATE_MAC_FILTERS,
9062306a36Sopenharmony_ci	VMXNET3_CMD_UPDATE_VLAN_FILTERS,
9162306a36Sopenharmony_ci	VMXNET3_CMD_UPDATE_RSSIDT,
9262306a36Sopenharmony_ci	VMXNET3_CMD_UPDATE_IML,
9362306a36Sopenharmony_ci	VMXNET3_CMD_UPDATE_PMCFG,
9462306a36Sopenharmony_ci	VMXNET3_CMD_UPDATE_FEATURE,
9562306a36Sopenharmony_ci	VMXNET3_CMD_RESERVED1,
9662306a36Sopenharmony_ci	VMXNET3_CMD_LOAD_PLUGIN,
9762306a36Sopenharmony_ci	VMXNET3_CMD_RESERVED2,
9862306a36Sopenharmony_ci	VMXNET3_CMD_RESERVED3,
9962306a36Sopenharmony_ci	VMXNET3_CMD_SET_COALESCE,
10062306a36Sopenharmony_ci	VMXNET3_CMD_REGISTER_MEMREGS,
10162306a36Sopenharmony_ci	VMXNET3_CMD_SET_RSS_FIELDS,
10262306a36Sopenharmony_ci	VMXNET3_CMD_RESERVED4,
10362306a36Sopenharmony_ci	VMXNET3_CMD_RESERVED5,
10462306a36Sopenharmony_ci	VMXNET3_CMD_SET_RING_BUFFER_SIZE,
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci	VMXNET3_CMD_FIRST_GET = 0xF00D0000,
10762306a36Sopenharmony_ci	VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
10862306a36Sopenharmony_ci	VMXNET3_CMD_GET_STATS,
10962306a36Sopenharmony_ci	VMXNET3_CMD_GET_LINK,
11062306a36Sopenharmony_ci	VMXNET3_CMD_GET_PERM_MAC_LO,
11162306a36Sopenharmony_ci	VMXNET3_CMD_GET_PERM_MAC_HI,
11262306a36Sopenharmony_ci	VMXNET3_CMD_GET_DID_LO,
11362306a36Sopenharmony_ci	VMXNET3_CMD_GET_DID_HI,
11462306a36Sopenharmony_ci	VMXNET3_CMD_GET_DEV_EXTRA_INFO,
11562306a36Sopenharmony_ci	VMXNET3_CMD_GET_CONF_INTR,
11662306a36Sopenharmony_ci	VMXNET3_CMD_GET_RESERVED1,
11762306a36Sopenharmony_ci	VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
11862306a36Sopenharmony_ci	VMXNET3_CMD_GET_COALESCE,
11962306a36Sopenharmony_ci	VMXNET3_CMD_GET_RSS_FIELDS,
12062306a36Sopenharmony_ci	VMXNET3_CMD_GET_RESERVED2,
12162306a36Sopenharmony_ci	VMXNET3_CMD_GET_RESERVED3,
12262306a36Sopenharmony_ci	VMXNET3_CMD_GET_MAX_QUEUES_CONF,
12362306a36Sopenharmony_ci	VMXNET3_CMD_GET_RESERVED4,
12462306a36Sopenharmony_ci	VMXNET3_CMD_GET_MAX_CAPABILITIES,
12562306a36Sopenharmony_ci	VMXNET3_CMD_GET_DCR0_REG,
12662306a36Sopenharmony_ci};
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci/*
12962306a36Sopenharmony_ci *	Little Endian layout of bitfields -
13062306a36Sopenharmony_ci *	Byte 0 :	7.....len.....0
13162306a36Sopenharmony_ci *	Byte 1 :	oco gen 13.len.8
13262306a36Sopenharmony_ci *	Byte 2 : 	5.msscof.0 ext1  dtype
13362306a36Sopenharmony_ci *	Byte 3 : 	13...msscof...6
13462306a36Sopenharmony_ci *
13562306a36Sopenharmony_ci *	Big Endian layout of bitfields -
13662306a36Sopenharmony_ci *	Byte 0:		13...msscof...6
13762306a36Sopenharmony_ci *	Byte 1 : 	5.msscof.0 ext1  dtype
13862306a36Sopenharmony_ci *	Byte 2 :	oco gen 13.len.8
13962306a36Sopenharmony_ci *	Byte 3 :	7.....len.....0
14062306a36Sopenharmony_ci *
14162306a36Sopenharmony_ci *	Thus, le32_to_cpu on the dword will allow the big endian driver to read
14262306a36Sopenharmony_ci *	the bit fields correctly. And cpu_to_le32 will convert bitfields
14362306a36Sopenharmony_ci *	bit fields written by big endian driver to format required by device.
14462306a36Sopenharmony_ci */
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_cistruct Vmxnet3_TxDesc {
14762306a36Sopenharmony_ci	__le64 addr;
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD
15062306a36Sopenharmony_ci	u32 msscof:14;  /* MSS, checksum offset, flags */
15162306a36Sopenharmony_ci	u32 ext1:1;     /* set to 1 to indicate inner csum/tso, vmxnet3 v7 */
15262306a36Sopenharmony_ci	u32 dtype:1;    /* descriptor type */
15362306a36Sopenharmony_ci	u32 oco:1;      /* Outer csum offload */
15462306a36Sopenharmony_ci	u32 gen:1;      /* generation bit */
15562306a36Sopenharmony_ci	u32 len:14;
15662306a36Sopenharmony_ci#else
15762306a36Sopenharmony_ci	u32 len:14;
15862306a36Sopenharmony_ci	u32 gen:1;      /* generation bit */
15962306a36Sopenharmony_ci	u32 oco:1;      /* Outer csum offload */
16062306a36Sopenharmony_ci	u32 dtype:1;    /* descriptor type */
16162306a36Sopenharmony_ci	u32 ext1:1;     /* set to 1 to indicate inner csum/tso, vmxnet3 v7 */
16262306a36Sopenharmony_ci	u32 msscof:14;  /* MSS, checksum offset, flags */
16362306a36Sopenharmony_ci#endif  /* __BIG_ENDIAN_BITFIELD */
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD
16662306a36Sopenharmony_ci	u32 tci:16;     /* Tag to Insert */
16762306a36Sopenharmony_ci	u32 ti:1;       /* VLAN Tag Insertion */
16862306a36Sopenharmony_ci	u32 ext2:1;
16962306a36Sopenharmony_ci	u32 cq:1;       /* completion request */
17062306a36Sopenharmony_ci	u32 eop:1;      /* End Of Packet */
17162306a36Sopenharmony_ci	u32 om:2;       /* offload mode */
17262306a36Sopenharmony_ci	u32 hlen:10;    /* header len */
17362306a36Sopenharmony_ci#else
17462306a36Sopenharmony_ci	u32 hlen:10;    /* header len */
17562306a36Sopenharmony_ci	u32 om:2;       /* offload mode */
17662306a36Sopenharmony_ci	u32 eop:1;      /* End Of Packet */
17762306a36Sopenharmony_ci	u32 cq:1;       /* completion request */
17862306a36Sopenharmony_ci	u32 ext2:1;
17962306a36Sopenharmony_ci	u32 ti:1;       /* VLAN Tag Insertion */
18062306a36Sopenharmony_ci	u32 tci:16;     /* Tag to Insert */
18162306a36Sopenharmony_ci#endif  /* __BIG_ENDIAN_BITFIELD */
18262306a36Sopenharmony_ci};
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci/* TxDesc.OM values */
18562306a36Sopenharmony_ci#define VMXNET3_OM_NONE         0
18662306a36Sopenharmony_ci#define VMXNET3_OM_ENCAP        1
18762306a36Sopenharmony_ci#define VMXNET3_OM_CSUM         2
18862306a36Sopenharmony_ci#define VMXNET3_OM_TSO          3
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci/* fields in TxDesc we access w/o using bit fields */
19162306a36Sopenharmony_ci#define VMXNET3_TXD_EOP_SHIFT	12
19262306a36Sopenharmony_ci#define VMXNET3_TXD_CQ_SHIFT	13
19362306a36Sopenharmony_ci#define VMXNET3_TXD_GEN_SHIFT	14
19462306a36Sopenharmony_ci#define VMXNET3_TXD_EOP_DWORD_SHIFT 3
19562306a36Sopenharmony_ci#define VMXNET3_TXD_GEN_DWORD_SHIFT 2
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci#define VMXNET3_TXD_CQ		(1 << VMXNET3_TXD_CQ_SHIFT)
19862306a36Sopenharmony_ci#define VMXNET3_TXD_EOP		(1 << VMXNET3_TXD_EOP_SHIFT)
19962306a36Sopenharmony_ci#define VMXNET3_TXD_GEN		(1 << VMXNET3_TXD_GEN_SHIFT)
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci#define VMXNET3_HDR_COPY_SIZE   128
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_cistruct Vmxnet3_TxDataDesc {
20562306a36Sopenharmony_ci	u8		data[VMXNET3_HDR_COPY_SIZE];
20662306a36Sopenharmony_ci};
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_citypedef u8 Vmxnet3_RxDataDesc;
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci#define VMXNET3_TCD_GEN_SHIFT	31
21162306a36Sopenharmony_ci#define VMXNET3_TCD_GEN_SIZE	1
21262306a36Sopenharmony_ci#define VMXNET3_TCD_TXIDX_SHIFT	0
21362306a36Sopenharmony_ci#define VMXNET3_TCD_TXIDX_SIZE	12
21462306a36Sopenharmony_ci#define VMXNET3_TCD_GEN_DWORD_SHIFT	3
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_cistruct Vmxnet3_TxCompDesc {
21762306a36Sopenharmony_ci	u32		txdIdx:12;    /* Index of the EOP TxDesc */
21862306a36Sopenharmony_ci	u32		ext1:20;
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci	__le32		ext2;
22162306a36Sopenharmony_ci	__le32		ext3;
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci	u32		rsvd:24;
22462306a36Sopenharmony_ci	u32		type:7;       /* completion type */
22562306a36Sopenharmony_ci	u32		gen:1;        /* generation bit */
22662306a36Sopenharmony_ci};
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_cistruct Vmxnet3_RxDesc {
22962306a36Sopenharmony_ci	__le64		addr;
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD
23262306a36Sopenharmony_ci	u32		gen:1;        /* Generation bit */
23362306a36Sopenharmony_ci	u32		rsvd:15;
23462306a36Sopenharmony_ci	u32		dtype:1;      /* Descriptor type */
23562306a36Sopenharmony_ci	u32		btype:1;      /* Buffer Type */
23662306a36Sopenharmony_ci	u32		len:14;
23762306a36Sopenharmony_ci#else
23862306a36Sopenharmony_ci	u32		len:14;
23962306a36Sopenharmony_ci	u32		btype:1;      /* Buffer Type */
24062306a36Sopenharmony_ci	u32		dtype:1;      /* Descriptor type */
24162306a36Sopenharmony_ci	u32		rsvd:15;
24262306a36Sopenharmony_ci	u32		gen:1;        /* Generation bit */
24362306a36Sopenharmony_ci#endif
24462306a36Sopenharmony_ci	u32		ext1;
24562306a36Sopenharmony_ci};
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci/* values of RXD.BTYPE */
24862306a36Sopenharmony_ci#define VMXNET3_RXD_BTYPE_HEAD   0    /* head only */
24962306a36Sopenharmony_ci#define VMXNET3_RXD_BTYPE_BODY   1    /* body only */
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci/* fields in RxDesc we access w/o using bit fields */
25262306a36Sopenharmony_ci#define VMXNET3_RXD_BTYPE_SHIFT  14
25362306a36Sopenharmony_ci#define VMXNET3_RXD_GEN_SHIFT    31
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci#define VMXNET3_RCD_HDR_INNER_SHIFT  13
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_cistruct Vmxnet3_RxCompDesc {
25862306a36Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD
25962306a36Sopenharmony_ci	u32		ext2:1;
26062306a36Sopenharmony_ci	u32		cnc:1;        /* Checksum Not Calculated */
26162306a36Sopenharmony_ci	u32		rssType:4;    /* RSS hash type used */
26262306a36Sopenharmony_ci	u32		rqID:10;      /* rx queue/ring ID */
26362306a36Sopenharmony_ci	u32		sop:1;        /* Start of Packet */
26462306a36Sopenharmony_ci	u32		eop:1;        /* End of Packet */
26562306a36Sopenharmony_ci	u32		ext1:2;       /* bit 0: indicating v4/v6/.. is for inner header */
26662306a36Sopenharmony_ci				      /* bit 1: indicating rssType is based on inner header */
26762306a36Sopenharmony_ci	u32		rxdIdx:12;    /* Index of the RxDesc */
26862306a36Sopenharmony_ci#else
26962306a36Sopenharmony_ci	u32		rxdIdx:12;    /* Index of the RxDesc */
27062306a36Sopenharmony_ci	u32		ext1:2;       /* bit 0: indicating v4/v6/.. is for inner header */
27162306a36Sopenharmony_ci				      /* bit 1: indicating rssType is based on inner header */
27262306a36Sopenharmony_ci	u32		eop:1;        /* End of Packet */
27362306a36Sopenharmony_ci	u32		sop:1;        /* Start of Packet */
27462306a36Sopenharmony_ci	u32		rqID:10;      /* rx queue/ring ID */
27562306a36Sopenharmony_ci	u32		rssType:4;    /* RSS hash type used */
27662306a36Sopenharmony_ci	u32		cnc:1;        /* Checksum Not Calculated */
27762306a36Sopenharmony_ci	u32		ext2:1;
27862306a36Sopenharmony_ci#endif  /* __BIG_ENDIAN_BITFIELD */
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci	__le32		rssHash;      /* RSS hash value */
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD
28362306a36Sopenharmony_ci	u32		tci:16;       /* Tag stripped */
28462306a36Sopenharmony_ci	u32		ts:1;         /* Tag is stripped */
28562306a36Sopenharmony_ci	u32		err:1;        /* Error */
28662306a36Sopenharmony_ci	u32		len:14;       /* data length */
28762306a36Sopenharmony_ci#else
28862306a36Sopenharmony_ci	u32		len:14;       /* data length */
28962306a36Sopenharmony_ci	u32		err:1;        /* Error */
29062306a36Sopenharmony_ci	u32		ts:1;         /* Tag is stripped */
29162306a36Sopenharmony_ci	u32		tci:16;       /* Tag stripped */
29262306a36Sopenharmony_ci#endif  /* __BIG_ENDIAN_BITFIELD */
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD
29662306a36Sopenharmony_ci	u32		gen:1;        /* generation bit */
29762306a36Sopenharmony_ci	u32		type:7;       /* completion type */
29862306a36Sopenharmony_ci	u32		fcs:1;        /* Frame CRC correct */
29962306a36Sopenharmony_ci	u32		frg:1;        /* IP Fragment */
30062306a36Sopenharmony_ci	u32		v4:1;         /* IPv4 */
30162306a36Sopenharmony_ci	u32		v6:1;         /* IPv6 */
30262306a36Sopenharmony_ci	u32		ipc:1;        /* IP Checksum Correct */
30362306a36Sopenharmony_ci	u32		tcp:1;        /* TCP packet */
30462306a36Sopenharmony_ci	u32		udp:1;        /* UDP packet */
30562306a36Sopenharmony_ci	u32		tuc:1;        /* TCP/UDP Checksum Correct */
30662306a36Sopenharmony_ci	u32		csum:16;
30762306a36Sopenharmony_ci#else
30862306a36Sopenharmony_ci	u32		csum:16;
30962306a36Sopenharmony_ci	u32		tuc:1;        /* TCP/UDP Checksum Correct */
31062306a36Sopenharmony_ci	u32		udp:1;        /* UDP packet */
31162306a36Sopenharmony_ci	u32		tcp:1;        /* TCP packet */
31262306a36Sopenharmony_ci	u32		ipc:1;        /* IP Checksum Correct */
31362306a36Sopenharmony_ci	u32		v6:1;         /* IPv6 */
31462306a36Sopenharmony_ci	u32		v4:1;         /* IPv4 */
31562306a36Sopenharmony_ci	u32		frg:1;        /* IP Fragment */
31662306a36Sopenharmony_ci	u32		fcs:1;        /* Frame CRC correct */
31762306a36Sopenharmony_ci	u32		type:7;       /* completion type */
31862306a36Sopenharmony_ci	u32		gen:1;        /* generation bit */
31962306a36Sopenharmony_ci#endif  /* __BIG_ENDIAN_BITFIELD */
32062306a36Sopenharmony_ci};
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_cistruct Vmxnet3_RxCompDescExt {
32362306a36Sopenharmony_ci	__le32		dword1;
32462306a36Sopenharmony_ci	u8		segCnt;       /* Number of aggregated packets */
32562306a36Sopenharmony_ci	u8		dupAckCnt;    /* Number of duplicate Acks */
32662306a36Sopenharmony_ci	__le16		tsDelta;      /* TCP timestamp difference */
32762306a36Sopenharmony_ci	__le32		dword2;
32862306a36Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD
32962306a36Sopenharmony_ci	u32		gen:1;        /* generation bit */
33062306a36Sopenharmony_ci	u32		type:7;       /* completion type */
33162306a36Sopenharmony_ci	u32		fcs:1;        /* Frame CRC correct */
33262306a36Sopenharmony_ci	u32		frg:1;        /* IP Fragment */
33362306a36Sopenharmony_ci	u32		v4:1;         /* IPv4 */
33462306a36Sopenharmony_ci	u32		v6:1;         /* IPv6 */
33562306a36Sopenharmony_ci	u32		ipc:1;        /* IP Checksum Correct */
33662306a36Sopenharmony_ci	u32		tcp:1;        /* TCP packet */
33762306a36Sopenharmony_ci	u32		udp:1;        /* UDP packet */
33862306a36Sopenharmony_ci	u32		tuc:1;        /* TCP/UDP Checksum Correct */
33962306a36Sopenharmony_ci	u32		mss:16;
34062306a36Sopenharmony_ci#else
34162306a36Sopenharmony_ci	u32		mss:16;
34262306a36Sopenharmony_ci	u32		tuc:1;        /* TCP/UDP Checksum Correct */
34362306a36Sopenharmony_ci	u32		udp:1;        /* UDP packet */
34462306a36Sopenharmony_ci	u32		tcp:1;        /* TCP packet */
34562306a36Sopenharmony_ci	u32		ipc:1;        /* IP Checksum Correct */
34662306a36Sopenharmony_ci	u32		v6:1;         /* IPv6 */
34762306a36Sopenharmony_ci	u32		v4:1;         /* IPv4 */
34862306a36Sopenharmony_ci	u32		frg:1;        /* IP Fragment */
34962306a36Sopenharmony_ci	u32		fcs:1;        /* Frame CRC correct */
35062306a36Sopenharmony_ci	u32		type:7;       /* completion type */
35162306a36Sopenharmony_ci	u32		gen:1;        /* generation bit */
35262306a36Sopenharmony_ci#endif  /* __BIG_ENDIAN_BITFIELD */
35362306a36Sopenharmony_ci};
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ci/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */
35762306a36Sopenharmony_ci#define VMXNET3_RCD_TUC_SHIFT	16
35862306a36Sopenharmony_ci#define VMXNET3_RCD_IPC_SHIFT	19
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ci/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.qword[1] */
36162306a36Sopenharmony_ci#define VMXNET3_RCD_TYPE_SHIFT	56
36262306a36Sopenharmony_ci#define VMXNET3_RCD_GEN_SHIFT	63
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci/* csum OK for TCP/UDP pkts over IP */
36562306a36Sopenharmony_ci#define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \
36662306a36Sopenharmony_ci			     1 << VMXNET3_RCD_IPC_SHIFT)
36762306a36Sopenharmony_ci#define VMXNET3_TXD_GEN_SIZE 1
36862306a36Sopenharmony_ci#define VMXNET3_TXD_EOP_SIZE 1
36962306a36Sopenharmony_ci
37062306a36Sopenharmony_ci/* value of RxCompDesc.rssType */
37162306a36Sopenharmony_ci#define VMXNET3_RCD_RSS_TYPE_NONE     0
37262306a36Sopenharmony_ci#define VMXNET3_RCD_RSS_TYPE_IPV4     1
37362306a36Sopenharmony_ci#define VMXNET3_RCD_RSS_TYPE_TCPIPV4  2
37462306a36Sopenharmony_ci#define VMXNET3_RCD_RSS_TYPE_IPV6     3
37562306a36Sopenharmony_ci#define VMXNET3_RCD_RSS_TYPE_TCPIPV6  4
37662306a36Sopenharmony_ci#define VMXNET3_RCD_RSS_TYPE_UDPIPV4  5
37762306a36Sopenharmony_ci#define VMXNET3_RCD_RSS_TYPE_UDPIPV6  6
37862306a36Sopenharmony_ci#define VMXNET3_RCD_RSS_TYPE_ESPIPV4  7
37962306a36Sopenharmony_ci#define VMXNET3_RCD_RSS_TYPE_ESPIPV6  8
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_ci
38262306a36Sopenharmony_ci/* a union for accessing all cmd/completion descriptors */
38362306a36Sopenharmony_ciunion Vmxnet3_GenericDesc {
38462306a36Sopenharmony_ci	__le64				qword[2];
38562306a36Sopenharmony_ci	__le32				dword[4];
38662306a36Sopenharmony_ci	__le16				word[8];
38762306a36Sopenharmony_ci	struct Vmxnet3_TxDesc		txd;
38862306a36Sopenharmony_ci	struct Vmxnet3_RxDesc		rxd;
38962306a36Sopenharmony_ci	struct Vmxnet3_TxCompDesc	tcd;
39062306a36Sopenharmony_ci	struct Vmxnet3_RxCompDesc	rcd;
39162306a36Sopenharmony_ci	struct Vmxnet3_RxCompDescExt 	rcdExt;
39262306a36Sopenharmony_ci};
39362306a36Sopenharmony_ci
39462306a36Sopenharmony_ci#define VMXNET3_INIT_GEN       1
39562306a36Sopenharmony_ci
39662306a36Sopenharmony_ci/* Max size of a single tx buffer */
39762306a36Sopenharmony_ci#define VMXNET3_MAX_TX_BUF_SIZE  (1 << 14)
39862306a36Sopenharmony_ci
39962306a36Sopenharmony_ci/* # of tx desc needed for a tx buffer size */
40062306a36Sopenharmony_ci#define VMXNET3_TXD_NEEDED(size) (((size) + VMXNET3_MAX_TX_BUF_SIZE - 1) / \
40162306a36Sopenharmony_ci				  VMXNET3_MAX_TX_BUF_SIZE)
40262306a36Sopenharmony_ci
40362306a36Sopenharmony_ci/* max # of tx descs for a non-tso pkt */
40462306a36Sopenharmony_ci#define VMXNET3_MAX_TXD_PER_PKT 16
40562306a36Sopenharmony_ci/* max # of tx descs for a tso pkt */
40662306a36Sopenharmony_ci#define VMXNET3_MAX_TSO_TXD_PER_PKT 24
40762306a36Sopenharmony_ci
40862306a36Sopenharmony_ci/* Max size of a single rx buffer */
40962306a36Sopenharmony_ci#define VMXNET3_MAX_RX_BUF_SIZE  ((1 << 14) - 1)
41062306a36Sopenharmony_ci/* Minimum size of a type 0 buffer */
41162306a36Sopenharmony_ci#define VMXNET3_MIN_T0_BUF_SIZE  128
41262306a36Sopenharmony_ci#define VMXNET3_MAX_CSUM_OFFSET  1024
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_ci/* Ring base address alignment */
41562306a36Sopenharmony_ci#define VMXNET3_RING_BA_ALIGN   512
41662306a36Sopenharmony_ci#define VMXNET3_RING_BA_MASK    (VMXNET3_RING_BA_ALIGN - 1)
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ci/* Ring size must be a multiple of 32 */
41962306a36Sopenharmony_ci#define VMXNET3_RING_SIZE_ALIGN 32
42062306a36Sopenharmony_ci#define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
42162306a36Sopenharmony_ci
42262306a36Sopenharmony_ci/* Tx Data Ring buffer size must be a multiple of 64 */
42362306a36Sopenharmony_ci#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
42462306a36Sopenharmony_ci#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
42562306a36Sopenharmony_ci
42662306a36Sopenharmony_ci/* Rx Data Ring buffer size must be a multiple of 64 */
42762306a36Sopenharmony_ci#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
42862306a36Sopenharmony_ci#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
42962306a36Sopenharmony_ci
43062306a36Sopenharmony_ci/* Max ring size */
43162306a36Sopenharmony_ci#define VMXNET3_TX_RING_MAX_SIZE   4096
43262306a36Sopenharmony_ci#define VMXNET3_TC_RING_MAX_SIZE   4096
43362306a36Sopenharmony_ci#define VMXNET3_RX_RING_MAX_SIZE   4096
43462306a36Sopenharmony_ci#define VMXNET3_RX_RING2_MAX_SIZE  4096
43562306a36Sopenharmony_ci#define VMXNET3_RC_RING_MAX_SIZE   8192
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
43862306a36Sopenharmony_ci#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
43962306a36Sopenharmony_ci
44062306a36Sopenharmony_ci#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
44162306a36Sopenharmony_ci
44262306a36Sopenharmony_ci/* a list of reasons for queue stop */
44362306a36Sopenharmony_ci
44462306a36Sopenharmony_cienum {
44562306a36Sopenharmony_ci VMXNET3_ERR_NOEOP        = 0x80000000,  /* cannot find the EOP desc of a pkt */
44662306a36Sopenharmony_ci VMXNET3_ERR_TXD_REUSE    = 0x80000001,  /* reuse TxDesc before tx completion */
44762306a36Sopenharmony_ci VMXNET3_ERR_BIG_PKT      = 0x80000002,  /* too many TxDesc for a pkt */
44862306a36Sopenharmony_ci VMXNET3_ERR_DESC_NOT_SPT = 0x80000003,  /* descriptor type not supported */
44962306a36Sopenharmony_ci VMXNET3_ERR_SMALL_BUF    = 0x80000004,  /* type 0 buffer too small */
45062306a36Sopenharmony_ci VMXNET3_ERR_STRESS       = 0x80000005,  /* stress option firing in vmkernel */
45162306a36Sopenharmony_ci VMXNET3_ERR_SWITCH       = 0x80000006,  /* mode switch failure */
45262306a36Sopenharmony_ci VMXNET3_ERR_TXD_INVALID  = 0x80000007,  /* invalid TxDesc */
45362306a36Sopenharmony_ci};
45462306a36Sopenharmony_ci
45562306a36Sopenharmony_ci/* completion descriptor types */
45662306a36Sopenharmony_ci#define VMXNET3_CDTYPE_TXCOMP      0    /* Tx Completion Descriptor */
45762306a36Sopenharmony_ci#define VMXNET3_CDTYPE_RXCOMP      3    /* Rx Completion Descriptor */
45862306a36Sopenharmony_ci#define VMXNET3_CDTYPE_RXCOMP_LRO  4    /* Rx Completion Descriptor for LRO */
45962306a36Sopenharmony_ci
46062306a36Sopenharmony_cienum {
46162306a36Sopenharmony_ci	VMXNET3_GOS_BITS_UNK    = 0,   /* unknown */
46262306a36Sopenharmony_ci	VMXNET3_GOS_BITS_32     = 1,
46362306a36Sopenharmony_ci	VMXNET3_GOS_BITS_64     = 2,
46462306a36Sopenharmony_ci};
46562306a36Sopenharmony_ci
46662306a36Sopenharmony_ci#define VMXNET3_GOS_TYPE_LINUX	1
46762306a36Sopenharmony_ci
46862306a36Sopenharmony_ci
46962306a36Sopenharmony_cistruct Vmxnet3_GOSInfo {
47062306a36Sopenharmony_ci#ifdef __BIG_ENDIAN_BITFIELD
47162306a36Sopenharmony_ci	u32		gosMisc:10;    /* other info about gos */
47262306a36Sopenharmony_ci	u32		gosVer:16;     /* gos version */
47362306a36Sopenharmony_ci	u32		gosType:4;     /* which guest */
47462306a36Sopenharmony_ci	u32		gosBits:2;    /* 32-bit or 64-bit? */
47562306a36Sopenharmony_ci#else
47662306a36Sopenharmony_ci	u32		gosBits:2;     /* 32-bit or 64-bit? */
47762306a36Sopenharmony_ci	u32		gosType:4;     /* which guest */
47862306a36Sopenharmony_ci	u32		gosVer:16;     /* gos version */
47962306a36Sopenharmony_ci	u32		gosMisc:10;    /* other info about gos */
48062306a36Sopenharmony_ci#endif  /* __BIG_ENDIAN_BITFIELD */
48162306a36Sopenharmony_ci};
48262306a36Sopenharmony_ci
48362306a36Sopenharmony_cistruct Vmxnet3_DriverInfo {
48462306a36Sopenharmony_ci	__le32				version;
48562306a36Sopenharmony_ci	struct Vmxnet3_GOSInfo		gos;
48662306a36Sopenharmony_ci	__le32				vmxnet3RevSpt;
48762306a36Sopenharmony_ci	__le32				uptVerSpt;
48862306a36Sopenharmony_ci};
48962306a36Sopenharmony_ci
49062306a36Sopenharmony_ci
49162306a36Sopenharmony_ci#define VMXNET3_REV1_MAGIC  3133079265u
49262306a36Sopenharmony_ci
49362306a36Sopenharmony_ci/*
49462306a36Sopenharmony_ci * QueueDescPA must be 128 bytes aligned. It points to an array of
49562306a36Sopenharmony_ci * Vmxnet3_TxQueueDesc followed by an array of Vmxnet3_RxQueueDesc.
49662306a36Sopenharmony_ci * The number of Vmxnet3_TxQueueDesc/Vmxnet3_RxQueueDesc are specified by
49762306a36Sopenharmony_ci * Vmxnet3_MiscConf.numTxQueues/numRxQueues, respectively.
49862306a36Sopenharmony_ci */
49962306a36Sopenharmony_ci#define VMXNET3_QUEUE_DESC_ALIGN  128
50062306a36Sopenharmony_ci
50162306a36Sopenharmony_ci
50262306a36Sopenharmony_cistruct Vmxnet3_MiscConf {
50362306a36Sopenharmony_ci	struct Vmxnet3_DriverInfo driverInfo;
50462306a36Sopenharmony_ci	__le64		uptFeatures;
50562306a36Sopenharmony_ci	__le64		ddPA;         /* driver data PA */
50662306a36Sopenharmony_ci	__le64		queueDescPA;  /* queue descriptor table PA */
50762306a36Sopenharmony_ci	__le32		ddLen;        /* driver data len */
50862306a36Sopenharmony_ci	__le32		queueDescLen; /* queue desc. table len in bytes */
50962306a36Sopenharmony_ci	__le32		mtu;
51062306a36Sopenharmony_ci	__le16		maxNumRxSG;
51162306a36Sopenharmony_ci	u8		numTxQueues;
51262306a36Sopenharmony_ci	u8		numRxQueues;
51362306a36Sopenharmony_ci	__le32		reserved[4];
51462306a36Sopenharmony_ci};
51562306a36Sopenharmony_ci
51662306a36Sopenharmony_ci
51762306a36Sopenharmony_cistruct Vmxnet3_TxQueueConf {
51862306a36Sopenharmony_ci	__le64		txRingBasePA;
51962306a36Sopenharmony_ci	__le64		dataRingBasePA;
52062306a36Sopenharmony_ci	__le64		compRingBasePA;
52162306a36Sopenharmony_ci	__le64		ddPA;         /* driver data */
52262306a36Sopenharmony_ci	__le64		reserved;
52362306a36Sopenharmony_ci	__le32		txRingSize;   /* # of tx desc */
52462306a36Sopenharmony_ci	__le32		dataRingSize; /* # of data desc */
52562306a36Sopenharmony_ci	__le32		compRingSize; /* # of comp desc */
52662306a36Sopenharmony_ci	__le32		ddLen;        /* size of driver data */
52762306a36Sopenharmony_ci	u8		intrIdx;
52862306a36Sopenharmony_ci	u8		_pad1[1];
52962306a36Sopenharmony_ci	__le16		txDataRingDescSize;
53062306a36Sopenharmony_ci	u8		_pad2[4];
53162306a36Sopenharmony_ci};
53262306a36Sopenharmony_ci
53362306a36Sopenharmony_ci
53462306a36Sopenharmony_cistruct Vmxnet3_RxQueueConf {
53562306a36Sopenharmony_ci	__le64		rxRingBasePA[2];
53662306a36Sopenharmony_ci	__le64		compRingBasePA;
53762306a36Sopenharmony_ci	__le64		ddPA;            /* driver data */
53862306a36Sopenharmony_ci	__le64		rxDataRingBasePA;
53962306a36Sopenharmony_ci	__le32		rxRingSize[2];   /* # of rx desc */
54062306a36Sopenharmony_ci	__le32		compRingSize;    /* # of rx comp desc */
54162306a36Sopenharmony_ci	__le32		ddLen;           /* size of driver data */
54262306a36Sopenharmony_ci	u8		intrIdx;
54362306a36Sopenharmony_ci	u8		_pad1[1];
54462306a36Sopenharmony_ci	__le16		rxDataRingDescSize;  /* size of rx data ring buffer */
54562306a36Sopenharmony_ci	u8		_pad2[4];
54662306a36Sopenharmony_ci};
54762306a36Sopenharmony_ci
54862306a36Sopenharmony_ci
54962306a36Sopenharmony_cienum vmxnet3_intr_mask_mode {
55062306a36Sopenharmony_ci	VMXNET3_IMM_AUTO   = 0,
55162306a36Sopenharmony_ci	VMXNET3_IMM_ACTIVE = 1,
55262306a36Sopenharmony_ci	VMXNET3_IMM_LAZY   = 2
55362306a36Sopenharmony_ci};
55462306a36Sopenharmony_ci
55562306a36Sopenharmony_cienum vmxnet3_intr_type {
55662306a36Sopenharmony_ci	VMXNET3_IT_AUTO = 0,
55762306a36Sopenharmony_ci	VMXNET3_IT_INTX = 1,
55862306a36Sopenharmony_ci	VMXNET3_IT_MSI  = 2,
55962306a36Sopenharmony_ci	VMXNET3_IT_MSIX = 3
56062306a36Sopenharmony_ci};
56162306a36Sopenharmony_ci
56262306a36Sopenharmony_ci#define VMXNET3_MAX_TX_QUEUES  8
56362306a36Sopenharmony_ci#define VMXNET3_MAX_RX_QUEUES  16
56462306a36Sopenharmony_ci/* addition 1 for events */
56562306a36Sopenharmony_ci#define VMXNET3_MAX_INTRS      25
56662306a36Sopenharmony_ci
56762306a36Sopenharmony_ci/* Version 6 and later will use below macros */
56862306a36Sopenharmony_ci#define VMXNET3_EXT_MAX_TX_QUEUES  32
56962306a36Sopenharmony_ci#define VMXNET3_EXT_MAX_RX_QUEUES  32
57062306a36Sopenharmony_ci/* addition 1 for events */
57162306a36Sopenharmony_ci#define VMXNET3_EXT_MAX_INTRS      65
57262306a36Sopenharmony_ci#define VMXNET3_FIRST_SET_INTRS    64
57362306a36Sopenharmony_ci
57462306a36Sopenharmony_ci/* value of intrCtrl */
57562306a36Sopenharmony_ci#define VMXNET3_IC_DISABLE_ALL  0x1   /* bit 0 */
57662306a36Sopenharmony_ci
57762306a36Sopenharmony_ci
57862306a36Sopenharmony_cistruct Vmxnet3_IntrConf {
57962306a36Sopenharmony_ci	bool		autoMask;
58062306a36Sopenharmony_ci	u8		numIntrs;      /* # of interrupts */
58162306a36Sopenharmony_ci	u8		eventIntrIdx;
58262306a36Sopenharmony_ci	u8		modLevels[VMXNET3_MAX_INTRS];	/* moderation level for
58362306a36Sopenharmony_ci							 * each intr */
58462306a36Sopenharmony_ci	__le32		intrCtrl;
58562306a36Sopenharmony_ci	__le32		reserved[2];
58662306a36Sopenharmony_ci};
58762306a36Sopenharmony_ci
58862306a36Sopenharmony_cistruct Vmxnet3_IntrConfExt {
58962306a36Sopenharmony_ci	u8              autoMask;
59062306a36Sopenharmony_ci	u8              numIntrs;      /* # of interrupts */
59162306a36Sopenharmony_ci	u8              eventIntrIdx;
59262306a36Sopenharmony_ci	u8              reserved;
59362306a36Sopenharmony_ci	__le32          intrCtrl;
59462306a36Sopenharmony_ci	__le32          reserved1;
59562306a36Sopenharmony_ci	u8              modLevels[VMXNET3_EXT_MAX_INTRS]; /* moderation level for
59662306a36Sopenharmony_ci							   * each intr
59762306a36Sopenharmony_ci							   */
59862306a36Sopenharmony_ci	u8              reserved2[3];
59962306a36Sopenharmony_ci};
60062306a36Sopenharmony_ci
60162306a36Sopenharmony_ci/* one bit per VLAN ID, the size is in the units of u32	*/
60262306a36Sopenharmony_ci#define VMXNET3_VFT_SIZE  (4096 / (sizeof(u32) * 8))
60362306a36Sopenharmony_ci
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_cistruct Vmxnet3_QueueStatus {
60662306a36Sopenharmony_ci	bool		stopped;
60762306a36Sopenharmony_ci	u8		_pad[3];
60862306a36Sopenharmony_ci	__le32		error;
60962306a36Sopenharmony_ci};
61062306a36Sopenharmony_ci
61162306a36Sopenharmony_ci
61262306a36Sopenharmony_cistruct Vmxnet3_TxQueueCtrl {
61362306a36Sopenharmony_ci	__le32		txNumDeferred;
61462306a36Sopenharmony_ci	__le32		txThreshold;
61562306a36Sopenharmony_ci	__le64		reserved;
61662306a36Sopenharmony_ci};
61762306a36Sopenharmony_ci
61862306a36Sopenharmony_ci
61962306a36Sopenharmony_cistruct Vmxnet3_RxQueueCtrl {
62062306a36Sopenharmony_ci	bool		updateRxProd;
62162306a36Sopenharmony_ci	u8		_pad[7];
62262306a36Sopenharmony_ci	__le64		reserved;
62362306a36Sopenharmony_ci};
62462306a36Sopenharmony_ci
62562306a36Sopenharmony_cienum {
62662306a36Sopenharmony_ci	VMXNET3_RXM_UCAST     = 0x01,  /* unicast only */
62762306a36Sopenharmony_ci	VMXNET3_RXM_MCAST     = 0x02,  /* multicast passing the filters */
62862306a36Sopenharmony_ci	VMXNET3_RXM_BCAST     = 0x04,  /* broadcast only */
62962306a36Sopenharmony_ci	VMXNET3_RXM_ALL_MULTI = 0x08,  /* all multicast */
63062306a36Sopenharmony_ci	VMXNET3_RXM_PROMISC   = 0x10  /* promiscuous */
63162306a36Sopenharmony_ci};
63262306a36Sopenharmony_ci
63362306a36Sopenharmony_cistruct Vmxnet3_RxFilterConf {
63462306a36Sopenharmony_ci	__le32		rxMode;       /* VMXNET3_RXM_xxx */
63562306a36Sopenharmony_ci	__le16		mfTableLen;   /* size of the multicast filter table */
63662306a36Sopenharmony_ci	__le16		_pad1;
63762306a36Sopenharmony_ci	__le64		mfTablePA;    /* PA of the multicast filters table */
63862306a36Sopenharmony_ci	__le32		vfTable[VMXNET3_VFT_SIZE]; /* vlan filter */
63962306a36Sopenharmony_ci};
64062306a36Sopenharmony_ci
64162306a36Sopenharmony_ci
64262306a36Sopenharmony_ci#define VMXNET3_PM_MAX_FILTERS        6
64362306a36Sopenharmony_ci#define VMXNET3_PM_MAX_PATTERN_SIZE   128
64462306a36Sopenharmony_ci#define VMXNET3_PM_MAX_MASK_SIZE      (VMXNET3_PM_MAX_PATTERN_SIZE / 8)
64562306a36Sopenharmony_ci
64662306a36Sopenharmony_ci#define VMXNET3_PM_WAKEUP_MAGIC       cpu_to_le16(0x01)  /* wake up on magic pkts */
64762306a36Sopenharmony_ci#define VMXNET3_PM_WAKEUP_FILTER      cpu_to_le16(0x02)  /* wake up on pkts matching
64862306a36Sopenharmony_ci							  * filters */
64962306a36Sopenharmony_ci
65062306a36Sopenharmony_ci
65162306a36Sopenharmony_cistruct Vmxnet3_PM_PktFilter {
65262306a36Sopenharmony_ci	u8		maskSize;
65362306a36Sopenharmony_ci	u8		patternSize;
65462306a36Sopenharmony_ci	u8		mask[VMXNET3_PM_MAX_MASK_SIZE];
65562306a36Sopenharmony_ci	u8		pattern[VMXNET3_PM_MAX_PATTERN_SIZE];
65662306a36Sopenharmony_ci	u8		pad[6];
65762306a36Sopenharmony_ci};
65862306a36Sopenharmony_ci
65962306a36Sopenharmony_ci
66062306a36Sopenharmony_cistruct Vmxnet3_PMConf {
66162306a36Sopenharmony_ci	__le16		wakeUpEvents;  /* VMXNET3_PM_WAKEUP_xxx */
66262306a36Sopenharmony_ci	u8		numFilters;
66362306a36Sopenharmony_ci	u8		pad[5];
66462306a36Sopenharmony_ci	struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS];
66562306a36Sopenharmony_ci};
66662306a36Sopenharmony_ci
66762306a36Sopenharmony_ci
66862306a36Sopenharmony_cistruct Vmxnet3_VariableLenConfDesc {
66962306a36Sopenharmony_ci	__le32		confVer;
67062306a36Sopenharmony_ci	__le32		confLen;
67162306a36Sopenharmony_ci	__le64		confPA;
67262306a36Sopenharmony_ci};
67362306a36Sopenharmony_ci
67462306a36Sopenharmony_ci
67562306a36Sopenharmony_cistruct Vmxnet3_TxQueueDesc {
67662306a36Sopenharmony_ci	struct Vmxnet3_TxQueueCtrl		ctrl;
67762306a36Sopenharmony_ci	struct Vmxnet3_TxQueueConf		conf;
67862306a36Sopenharmony_ci
67962306a36Sopenharmony_ci	/* Driver read after a GET command */
68062306a36Sopenharmony_ci	struct Vmxnet3_QueueStatus		status;
68162306a36Sopenharmony_ci	struct UPT1_TxStats			stats;
68262306a36Sopenharmony_ci	u8					_pad[88]; /* 128 aligned */
68362306a36Sopenharmony_ci};
68462306a36Sopenharmony_ci
68562306a36Sopenharmony_ci
68662306a36Sopenharmony_cistruct Vmxnet3_RxQueueDesc {
68762306a36Sopenharmony_ci	struct Vmxnet3_RxQueueCtrl		ctrl;
68862306a36Sopenharmony_ci	struct Vmxnet3_RxQueueConf		conf;
68962306a36Sopenharmony_ci	/* Driver read after a GET commad */
69062306a36Sopenharmony_ci	struct Vmxnet3_QueueStatus		status;
69162306a36Sopenharmony_ci	struct UPT1_RxStats			stats;
69262306a36Sopenharmony_ci	u8				      __pad[88]; /* 128 aligned */
69362306a36Sopenharmony_ci};
69462306a36Sopenharmony_ci
69562306a36Sopenharmony_cistruct Vmxnet3_SetPolling {
69662306a36Sopenharmony_ci	u8					enablePolling;
69762306a36Sopenharmony_ci};
69862306a36Sopenharmony_ci
69962306a36Sopenharmony_ci#define VMXNET3_COAL_STATIC_MAX_DEPTH		128
70062306a36Sopenharmony_ci#define VMXNET3_COAL_RBC_MIN_RATE		100
70162306a36Sopenharmony_ci#define VMXNET3_COAL_RBC_MAX_RATE		100000
70262306a36Sopenharmony_ci
70362306a36Sopenharmony_cienum Vmxnet3_CoalesceMode {
70462306a36Sopenharmony_ci	VMXNET3_COALESCE_DISABLED   = 0,
70562306a36Sopenharmony_ci	VMXNET3_COALESCE_ADAPT      = 1,
70662306a36Sopenharmony_ci	VMXNET3_COALESCE_STATIC     = 2,
70762306a36Sopenharmony_ci	VMXNET3_COALESCE_RBC        = 3
70862306a36Sopenharmony_ci};
70962306a36Sopenharmony_ci
71062306a36Sopenharmony_cistruct Vmxnet3_CoalesceRbc {
71162306a36Sopenharmony_ci	u32					rbc_rate;
71262306a36Sopenharmony_ci};
71362306a36Sopenharmony_ci
71462306a36Sopenharmony_cistruct Vmxnet3_CoalesceStatic {
71562306a36Sopenharmony_ci	u32					tx_depth;
71662306a36Sopenharmony_ci	u32					tx_comp_depth;
71762306a36Sopenharmony_ci	u32					rx_depth;
71862306a36Sopenharmony_ci};
71962306a36Sopenharmony_ci
72062306a36Sopenharmony_cistruct Vmxnet3_CoalesceScheme {
72162306a36Sopenharmony_ci	enum Vmxnet3_CoalesceMode		coalMode;
72262306a36Sopenharmony_ci	union {
72362306a36Sopenharmony_ci		struct Vmxnet3_CoalesceRbc	coalRbc;
72462306a36Sopenharmony_ci		struct Vmxnet3_CoalesceStatic	coalStatic;
72562306a36Sopenharmony_ci	} coalPara;
72662306a36Sopenharmony_ci};
72762306a36Sopenharmony_ci
72862306a36Sopenharmony_cistruct Vmxnet3_MemoryRegion {
72962306a36Sopenharmony_ci	__le64					startPA;
73062306a36Sopenharmony_ci	__le32					length;
73162306a36Sopenharmony_ci	__le16					txQueueBits;
73262306a36Sopenharmony_ci	__le16					rxQueueBits;
73362306a36Sopenharmony_ci};
73462306a36Sopenharmony_ci
73562306a36Sopenharmony_ci#define MAX_MEMORY_REGION_PER_QUEUE 16
73662306a36Sopenharmony_ci#define MAX_MEMORY_REGION_PER_DEVICE 256
73762306a36Sopenharmony_ci
73862306a36Sopenharmony_cistruct Vmxnet3_MemRegs {
73962306a36Sopenharmony_ci	__le16					numRegs;
74062306a36Sopenharmony_ci	__le16					pad[3];
74162306a36Sopenharmony_ci	struct Vmxnet3_MemoryRegion		memRegs[1];
74262306a36Sopenharmony_ci};
74362306a36Sopenharmony_ci
74462306a36Sopenharmony_cienum Vmxnet3_RSSField {
74562306a36Sopenharmony_ci	VMXNET3_RSS_FIELDS_TCPIP4 = 0x0001,
74662306a36Sopenharmony_ci	VMXNET3_RSS_FIELDS_TCPIP6 = 0x0002,
74762306a36Sopenharmony_ci	VMXNET3_RSS_FIELDS_UDPIP4 = 0x0004,
74862306a36Sopenharmony_ci	VMXNET3_RSS_FIELDS_UDPIP6 = 0x0008,
74962306a36Sopenharmony_ci	VMXNET3_RSS_FIELDS_ESPIP4 = 0x0010,
75062306a36Sopenharmony_ci	VMXNET3_RSS_FIELDS_ESPIP6 = 0x0020,
75162306a36Sopenharmony_ci};
75262306a36Sopenharmony_ci
75362306a36Sopenharmony_cistruct Vmxnet3_RingBufferSize {
75462306a36Sopenharmony_ci	__le16             ring1BufSizeType0;
75562306a36Sopenharmony_ci	__le16             ring1BufSizeType1;
75662306a36Sopenharmony_ci	__le16             ring2BufSizeType1;
75762306a36Sopenharmony_ci	__le16             pad;
75862306a36Sopenharmony_ci};
75962306a36Sopenharmony_ci
76062306a36Sopenharmony_ci/* If the command data <= 16 bytes, use the shared memory directly.
76162306a36Sopenharmony_ci * otherwise, use variable length configuration descriptor.
76262306a36Sopenharmony_ci */
76362306a36Sopenharmony_ciunion Vmxnet3_CmdInfo {
76462306a36Sopenharmony_ci	struct Vmxnet3_VariableLenConfDesc	varConf;
76562306a36Sopenharmony_ci	struct Vmxnet3_SetPolling		setPolling;
76662306a36Sopenharmony_ci	enum   Vmxnet3_RSSField                 setRssFields;
76762306a36Sopenharmony_ci	struct Vmxnet3_RingBufferSize           ringBufSize;
76862306a36Sopenharmony_ci	__le64					data[2];
76962306a36Sopenharmony_ci};
77062306a36Sopenharmony_ci
77162306a36Sopenharmony_cistruct Vmxnet3_DSDevRead {
77262306a36Sopenharmony_ci	/* read-only region for device, read by dev in response to a SET cmd */
77362306a36Sopenharmony_ci	struct Vmxnet3_MiscConf			misc;
77462306a36Sopenharmony_ci	struct Vmxnet3_IntrConf			intrConf;
77562306a36Sopenharmony_ci	struct Vmxnet3_RxFilterConf		rxFilterConf;
77662306a36Sopenharmony_ci	struct Vmxnet3_VariableLenConfDesc	rssConfDesc;
77762306a36Sopenharmony_ci	struct Vmxnet3_VariableLenConfDesc	pmConfDesc;
77862306a36Sopenharmony_ci	struct Vmxnet3_VariableLenConfDesc	pluginConfDesc;
77962306a36Sopenharmony_ci};
78062306a36Sopenharmony_ci
78162306a36Sopenharmony_cistruct Vmxnet3_DSDevReadExt {
78262306a36Sopenharmony_ci	/* read-only region for device, read by dev in response to a SET cmd */
78362306a36Sopenharmony_ci	struct Vmxnet3_IntrConfExt              intrConfExt;
78462306a36Sopenharmony_ci};
78562306a36Sopenharmony_ci
78662306a36Sopenharmony_ci/* All structures in DriverShared are padded to multiples of 8 bytes */
78762306a36Sopenharmony_cistruct Vmxnet3_DriverShared {
78862306a36Sopenharmony_ci	__le32				magic;
78962306a36Sopenharmony_ci	/* make devRead start at 64bit boundaries */
79062306a36Sopenharmony_ci	__le32                          size; /* size of DriverShared */
79162306a36Sopenharmony_ci	struct Vmxnet3_DSDevRead	devRead;
79262306a36Sopenharmony_ci	__le32				ecr;
79362306a36Sopenharmony_ci	__le32				reserved;
79462306a36Sopenharmony_ci	union {
79562306a36Sopenharmony_ci		__le32			reserved1[4];
79662306a36Sopenharmony_ci		union Vmxnet3_CmdInfo	cmdInfo; /* only valid in the context of
79762306a36Sopenharmony_ci						  * executing the relevant
79862306a36Sopenharmony_ci						  * command
79962306a36Sopenharmony_ci						  */
80062306a36Sopenharmony_ci	} cu;
80162306a36Sopenharmony_ci	struct Vmxnet3_DSDevReadExt     devReadExt;
80262306a36Sopenharmony_ci};
80362306a36Sopenharmony_ci
80462306a36Sopenharmony_ci
80562306a36Sopenharmony_ci#define VMXNET3_ECR_RQERR       (1 << 0)
80662306a36Sopenharmony_ci#define VMXNET3_ECR_TQERR       (1 << 1)
80762306a36Sopenharmony_ci#define VMXNET3_ECR_LINK        (1 << 2)
80862306a36Sopenharmony_ci#define VMXNET3_ECR_DIC         (1 << 3)
80962306a36Sopenharmony_ci#define VMXNET3_ECR_DEBUG       (1 << 4)
81062306a36Sopenharmony_ci
81162306a36Sopenharmony_ci/* flip the gen bit of a ring */
81262306a36Sopenharmony_ci#define VMXNET3_FLIP_RING_GEN(gen) ((gen) = (gen) ^ 0x1)
81362306a36Sopenharmony_ci
81462306a36Sopenharmony_ci/* only use this if moving the idx won't affect the gen bit */
81562306a36Sopenharmony_ci#define VMXNET3_INC_RING_IDX_ONLY(idx, ring_size) \
81662306a36Sopenharmony_ci	do {\
81762306a36Sopenharmony_ci		(idx)++;\
81862306a36Sopenharmony_ci		if (unlikely((idx) == (ring_size))) {\
81962306a36Sopenharmony_ci			(idx) = 0;\
82062306a36Sopenharmony_ci		} \
82162306a36Sopenharmony_ci	} while (0)
82262306a36Sopenharmony_ci
82362306a36Sopenharmony_ci#define VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid) \
82462306a36Sopenharmony_ci	(vfTable[vid >> 5] |= (1 << (vid & 31)))
82562306a36Sopenharmony_ci#define VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid) \
82662306a36Sopenharmony_ci	(vfTable[vid >> 5] &= ~(1 << (vid & 31)))
82762306a36Sopenharmony_ci
82862306a36Sopenharmony_ci#define VMXNET3_VFTABLE_ENTRY_IS_SET(vfTable, vid) \
82962306a36Sopenharmony_ci	((vfTable[vid >> 5] & (1 << (vid & 31))) != 0)
83062306a36Sopenharmony_ci
83162306a36Sopenharmony_ci#define VMXNET3_MAX_MTU     9000
83262306a36Sopenharmony_ci#define VMXNET3_V6_MAX_MTU  9190
83362306a36Sopenharmony_ci#define VMXNET3_MIN_MTU     60
83462306a36Sopenharmony_ci
83562306a36Sopenharmony_ci#define VMXNET3_LINK_UP         (10000 << 16 | 1)    /* 10 Gbps, up */
83662306a36Sopenharmony_ci#define VMXNET3_LINK_DOWN       0
83762306a36Sopenharmony_ci
83862306a36Sopenharmony_ci#define VMXNET3_DCR_ERROR                          31   /* error when bit 31 of DCR is set */
83962306a36Sopenharmony_ci#define VMXNET3_CAP_UDP_RSS                        0    /* bit 0 of DCR 0 */
84062306a36Sopenharmony_ci#define VMXNET3_CAP_ESP_RSS_IPV4                   1    /* bit 1 of DCR 0 */
84162306a36Sopenharmony_ci#define VMXNET3_CAP_GENEVE_CHECKSUM_OFFLOAD        2    /* bit 2 of DCR 0 */
84262306a36Sopenharmony_ci#define VMXNET3_CAP_GENEVE_TSO                     3    /* bit 3 of DCR 0 */
84362306a36Sopenharmony_ci#define VMXNET3_CAP_VXLAN_CHECKSUM_OFFLOAD         4    /* bit 4 of DCR 0 */
84462306a36Sopenharmony_ci#define VMXNET3_CAP_VXLAN_TSO                      5    /* bit 5 of DCR 0 */
84562306a36Sopenharmony_ci#define VMXNET3_CAP_GENEVE_OUTER_CHECKSUM_OFFLOAD  6    /* bit 6 of DCR 0 */
84662306a36Sopenharmony_ci#define VMXNET3_CAP_VXLAN_OUTER_CHECKSUM_OFFLOAD   7    /* bit 7 of DCR 0 */
84762306a36Sopenharmony_ci#define VMXNET3_CAP_PKT_STEERING_IPV4              8    /* bit 8 of DCR 0 */
84862306a36Sopenharmony_ci#define VMXNET3_CAP_VERSION_4_MAX                  VMXNET3_CAP_PKT_STEERING_IPV4
84962306a36Sopenharmony_ci#define VMXNET3_CAP_ESP_RSS_IPV6                   9    /* bit 9 of DCR 0 */
85062306a36Sopenharmony_ci#define VMXNET3_CAP_VERSION_5_MAX                  VMXNET3_CAP_ESP_RSS_IPV6
85162306a36Sopenharmony_ci#define VMXNET3_CAP_ESP_OVER_UDP_RSS               10   /* bit 10 of DCR 0 */
85262306a36Sopenharmony_ci#define VMXNET3_CAP_INNER_RSS                      11   /* bit 11 of DCR 0 */
85362306a36Sopenharmony_ci#define VMXNET3_CAP_INNER_ESP_RSS                  12   /* bit 12 of DCR 0 */
85462306a36Sopenharmony_ci#define VMXNET3_CAP_CRC32_HASH_FUNC                13   /* bit 13 of DCR 0 */
85562306a36Sopenharmony_ci#define VMXNET3_CAP_VERSION_6_MAX                  VMXNET3_CAP_CRC32_HASH_FUNC
85662306a36Sopenharmony_ci#define VMXNET3_CAP_OAM_FILTER                     14   /* bit 14 of DCR 0 */
85762306a36Sopenharmony_ci#define VMXNET3_CAP_ESP_QS                         15   /* bit 15 of DCR 0 */
85862306a36Sopenharmony_ci#define VMXNET3_CAP_LARGE_BAR                      16   /* bit 16 of DCR 0 */
85962306a36Sopenharmony_ci#define VMXNET3_CAP_OOORX_COMP                     17   /* bit 17 of DCR 0 */
86062306a36Sopenharmony_ci#define VMXNET3_CAP_VERSION_7_MAX                  18
86162306a36Sopenharmony_ci/* when new capability is introduced, update VMXNET3_CAP_MAX */
86262306a36Sopenharmony_ci#define VMXNET3_CAP_MAX                            VMXNET3_CAP_VERSION_7_MAX
86362306a36Sopenharmony_ci
86462306a36Sopenharmony_ci#endif /* _VMXNET3_DEFS_H_ */
865