xref: /illumos-gate/usr/src/uts/common/sys/pattr.h (revision daa7e8a345b2e0424e612017e8ead2e97b0f7f37)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  * Copyright 2019 Joyent, Inc.
25  */
26 
27 #ifndef _SYS_PATTR_H
28 #define	_SYS_PATTR_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Attribute types and structures.
36  */
37 #define	PATTR_DSTADDRSAP	0x1	/* destination physical address+SAP */
38 #define	PATTR_SRCADDRSAP	0x2	/* source physical address+SAP */
39 #define	PATTR_HCKSUM		0x3	/* hardware checksum attribute */
40 #define	PATTR_ZCOPY		0x4	/* zerocopy attribute */
41 
42 /*
43  * Structure shared by {source,destination} physical address+SAP attributes.
44  */
45 typedef struct pattr_addr_s {
46 	uint8_t	addr_is_group;	/* address is broadcast or multicast */
47 	uint8_t	addr_len;	/* length of address */
48 	uint8_t	addr[1];	/* address */
49 } pattr_addr_t;
50 
51 /*
52  * Structure used for Hardware Checksum attribute.
53  */
54 
55 typedef struct pattr_hcksum_s {
56 	uint32_t	hcksum_start_offset;
57 	uint32_t	hcksum_stuff_offset;
58 	uint32_t	hcksum_end_offset;
59 	union {
60 		uint64_t value;
61 		uint16_t inet_cksum; /* to store H/W computed cksum value */
62 	} hcksum_cksum_val;
63 	uint32_t	hcksum_flags;
64 } pattr_hcksum_t;
65 
66 /*
67  * Values for hcksum_flags
68  */
69 #define	HCK_IPV4_HDRCKSUM	0x01	/* On Transmit: Compute IP header */
70 					/* checksum in hardware. */
71 
72 #define	HCK_IPV4_HDRCKSUM_OK	0x01	/* On Receive: IP header checksum */
73 					/* was verified by h/w and is */
74 					/* correct. */
75 
76 #define	HCK_PARTIALCKSUM	0x02	/* On Transmit: Compute partial 1's */
77 					/* complement checksum based on */
78 					/* start, stuff and end offsets. */
79 					/* On Receive : Partial checksum */
80 					/* computed and attached. */
81 
82 #define	HCK_FULLCKSUM		0x04	/* On Transmit: Compute full(in case */
83 					/* of TCP/UDP, full is pseudo-header */
84 					/* + header + payload) checksum for */
85 					/* this packet. */
86 					/* On Receive : Full checksum  */
87 					/* computed in h/w and is attached */
88 
89 #define	HCK_FULLCKSUM_OK	0x08	/* On Transmit: N/A */
90 					/* On Receive: Full checksum status */
91 					/* If set, implies full checksum */
92 					/* computation was successful */
93 					/* i.e. checksum was correct. */
94 					/* If it is not set, IP will also */
95 					/* check the attached h/w computed */
96 					/* checksum value to determine if */
97 					/* checksum was bad */
98 
99 #define	HCK_FLAGS		(HCK_IPV4_HDRCKSUM | HCK_PARTIALCKSUM |	\
100 				HCK_FULLCKSUM | HCK_FULLCKSUM_OK)
101 #define	HCK_TX_FLAGS		(HCK_IPV4_HDRCKSUM | HCK_PARTIALCKSUM | \
102 				HCK_FULLCKSUM)
103 /*
104  * Extended hardware offloading flags that also use hcksum_flags
105  */
106 #define	HW_LSO			0x10	/* On Transmit: hardware does LSO */
107 					/* On Receive: N/A */
108 
109 #define	HW_LSO_FLAGS		HW_LSO	/* All LSO flags, currently only one */
110 
111 /*
112  * Structure used for zerocopy attribute.
113  */
114 typedef struct pattr_zcopy_s {
115 	uint_t zcopy_flags;
116 } pattr_zcopy_t;
117 
118 #ifdef	__cplusplus
119 }
120 #endif
121 
122 #endif	/* _SYS_PATTR_H */
123