xref: /titanic_41/usr/src/uts/common/sys/pattr.h (revision 0dc2366f7b9f9f36e10909b1e95edbf2a261c2ac)
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  */
25 
26 #ifndef _SYS_PATTR_H
27 #define	_SYS_PATTR_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Attribute types and structures.
35  */
36 #define	PATTR_DSTADDRSAP	0x1	/* destination physical address+SAP */
37 #define	PATTR_SRCADDRSAP	0x2	/* source physical address+SAP */
38 #define	PATTR_HCKSUM		0x3	/* hardware checksum attribute */
39 #define	PATTR_ZCOPY		0x4	/* zerocopy attribute */
40 
41 /*
42  * Structure shared by {source,destination} physical address+SAP attributes.
43  */
44 typedef struct pattr_addr_s {
45 	uint8_t	addr_is_group;	/* address is broadcast or multicast */
46 	uint8_t	addr_len;	/* length of address */
47 	uint8_t	addr[1];	/* address */
48 } pattr_addr_t;
49 
50 /*
51  * Structure used for Hardware Checksum attribute.
52  */
53 
54 typedef struct pattr_hcksum_s {
55 	uint32_t	hcksum_start_offset;
56 	uint32_t	hcksum_stuff_offset;
57 	uint32_t	hcksum_end_offset;
58 	union {
59 		uint64_t value;
60 		uint16_t inet_cksum; /* to store H/W computed cksum value */
61 	} hcksum_cksum_val;
62 	uint32_t	hcksum_flags;
63 } pattr_hcksum_t;
64 
65 /*
66  * Values for hcksum_flags
67  */
68 #define	HCK_IPV4_HDRCKSUM	0x01	/* On Transmit: Compute IP header */
69 					/* checksum in hardware. */
70 
71 #define	HCK_IPV4_HDRCKSUM_OK	0x01	/* On Receive: IP header checksum */
72 					/* was verified by h/w and is */
73 					/* correct. */
74 
75 #define	HCK_PARTIALCKSUM	0x02	/* On Transmit: Compute partial 1's */
76 					/* complement checksum based on */
77 					/* start, stuff and end offsets. */
78 					/* On Receive : Partial checksum */
79 					/* computed and attached. */
80 
81 #define	HCK_FULLCKSUM		0x04	/* On Transmit: Compute full(in case */
82 					/* of TCP/UDP, full is pseudo-header */
83 					/* + header + payload) checksum for */
84 					/* this packet. */
85 					/* On Receive : Full checksum  */
86 					/* computed in h/w and is attached */
87 
88 #define	HCK_FULLCKSUM_OK	0x08	/* On Transmit: N/A */
89 					/* On Receive: Full checksum status */
90 					/* If set, implies full checksum */
91 					/* computation was successful */
92 					/* i.e. checksum was correct. */
93 					/* If it is not set, IP will also */
94 					/* check the attached h/w computed */
95 					/* checksum value to determine if */
96 					/* checksum was bad */
97 
98 #define	HCK_FLAGS		(HCK_IPV4_HDRCKSUM | HCK_PARTIALCKSUM |	\
99 				HCK_FULLCKSUM | HCK_FULLCKSUM_OK)
100 /*
101  * Extended hardware offloading flags that also use hcksum_flags
102  */
103 #define	HW_LSO			0x10	/* On Transmit: hardware does LSO */
104 					/* On Receive: N/A */
105 
106 #define	HW_LSO_FLAGS		HW_LSO	/* All LSO flags, currently only one */
107 
108 /*
109  * Structure used for zerocopy attribute.
110  */
111 typedef struct pattr_zcopy_s {
112 	uint_t zcopy_flags;
113 } pattr_zcopy_t;
114 
115 #ifdef	__cplusplus
116 }
117 #endif
118 
119 #endif	/* _SYS_PATTR_H */
120