2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright 2016 Joyent, Inc.
19 .Nd get device capabilities
21 .In sys/mac_provider.h
25 .Fa "mac_capab_t capab"
33 A pointer to the driver's private data that was passed in via the
41 A value which indicates the capability being asked about.
42 For a full list of capabilities, see the
47 Capability specific data that may need to be filled in.
48 The type of data used is listed in the
56 entry point is called to determine whether or not a device supports a
58 The capability in question is specified in
60 and the list of possible capabilities is listed in the
65 Capabilities are generally only queried once for a given device.
66 An instance of a device cannot change whether or not it supports a given
67 capability after it has been queried by the system.
69 Each capability has its own specific kind of data that a device driver
70 needs to fill in as part of declaring that it supports a given capability.
71 That data is present in
73 The device driver should cast
75 to the appropriate structure and fill it in.
76 The structures to use for a given capability are all listed in the
81 The return value is used to indicate whether or not a device driver
82 supports the given capability.
83 If it does, then the device driver should return
87 Otherwise, whenever it encounters an unsupported or unknown capability,
90 Many device drivers employ
94 from their default case statement.
95 The system will present unknown capabilities to device drivers and they must
99 The driver has access to its soft state by casting the
101 argument to the specific structure.
102 The device driver is responsible for any necessary locking.
104 Many capabilities are related to features of hardware.
105 However, all hardware and firmware has the possibility of having bugs.
106 It is recommended that any capability that is supported have some form of
107 tunable, whether in the form of a
109 driver-specific property and/or a
111 property to disable it.
112 This way when problems are discovered in the field, they can be worked around
113 without requiring initial changes to the device driver.
115 This function is generally only called from
119 If the device driver supports the specified capability
121 then it should return
123 Otherwise, it should return
126 The following example shows how a driver might structure its
130 #include <sys/types.h>
131 #include <sys/mac_provider.h>
134 * Note, this example merely shows the structure of the function. For
135 * the purpose of this example, we assume that we have a device which
136 * has members that indicate whether the various capabilities have been
137 * enabled and that they are read-only after the driver has had its
138 * mc_start(9F) entry point called.
141 #define EXAMPLE_LSO_MAX 65535
144 example_m_getcapab(void *arg, mac_capab_t cap, void *cap_data)
149 case MAC_CAPAB_HCKSUM: {
150 uint32_t *txflags = cap_data;
153 * The actual flags used here should be replaced with
154 * what the device actually supports. If the device
155 * doesn't support checksums, then this case statement
159 if (ep->ep_tx_hcksum_enable == B_TRUE)
160 *txflags = HCKSUM_IPHDRCKSUM;
164 case MAC_CAPAB_LSO: {
165 mac_capab_lso_t *lso = cap_data;
167 if (ep->ep_lso_enable == B_TRUE) {
168 lso->lso_flags = LSO_TX_BASIC_TCP_IPV4;
169 lso->lso_basic_tcp_ipv4.lso_max = EXAMPLE_LSO_MAX;
185 .Xr mac_register 9F ,