xref: /freebsd/sys/dev/usb/template/usb_template_multi.c (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
5  * Copyright (c) 2018 The FreeBSD Foundation
6  * All rights reserved.
7  *
8  * This software was developed by SRI International and the University of
9  * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
10  * ("CTSRD"), as part of the DARPA CRASH research programme.
11  *
12  * Portions of this software were developed by Edward Tomasz Napierala
13  * under sponsorship from the FreeBSD Foundation.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must reproduce the above copyright
21  *    notice, this list of conditions and the following disclaimer in the
22  *    documentation and/or other materials provided with the distribution.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  */
36 /*
37  * USB template for CDC ACM (serial), CDC ECM (network), and CDC MSC (storage).
38  */
39 
40 #include <sys/cdefs.h>
41 #ifdef USB_GLOBAL_INCLUDE_FILE
42 #include USB_GLOBAL_INCLUDE_FILE
43 #else
44 #include <sys/stdint.h>
45 #include <sys/stddef.h>
46 #include <sys/param.h>
47 #include <sys/queue.h>
48 #include <sys/types.h>
49 #include <sys/systm.h>
50 #include <sys/kernel.h>
51 #include <sys/bus.h>
52 #include <sys/module.h>
53 #include <sys/lock.h>
54 #include <sys/mutex.h>
55 #include <sys/condvar.h>
56 #include <sys/sysctl.h>
57 #include <sys/sx.h>
58 #include <sys/unistd.h>
59 #include <sys/callout.h>
60 #include <sys/malloc.h>
61 #include <sys/priv.h>
62 
63 #include <dev/usb/usb.h>
64 #include <dev/usb/usbdi.h>
65 #include <dev/usb/usb_core.h>
66 #include <dev/usb/usb_cdc.h>
67 #include <dev/usb/usb_ioctl.h>
68 #include <dev/usb/usb_util.h>
69 
70 #include <dev/usb/template/usb_template.h>
71 #endif		/* USB_GLOBAL_INCLUDE_FILE */
72 
73 #define	MODEM_IFACE_0 0
74 #define	MODEM_IFACE_1 1
75 
76 enum {
77 	MULTI_LANG_INDEX,
78 	MULTI_MODEM_INDEX,
79 	MULTI_ETH_MAC_INDEX,
80 	MULTI_ETH_CONTROL_INDEX,
81 	MULTI_ETH_DATA_INDEX,
82 	MULTI_STORAGE_INDEX,
83 	MULTI_CONFIGURATION_INDEX,
84 	MULTI_MANUFACTURER_INDEX,
85 	MULTI_PRODUCT_INDEX,
86 	MULTI_SERIAL_NUMBER_INDEX,
87 	MULTI_MAX_INDEX,
88 };
89 
90 #define	MULTI_DEFAULT_VENDOR_ID		USB_TEMPLATE_VENDOR
91 #define	MULTI_DEFAULT_PRODUCT_ID	0x05dc
92 #define	MULTI_DEFAULT_MODEM		"Virtual serial port"
93 #define	MULTI_DEFAULT_ETH_MAC		"2A02030405060789AB"
94 #define	MULTI_DEFAULT_ETH_CONTROL	"Ethernet Comm Interface"
95 #define	MULTI_DEFAULT_ETH_DATA		"Ethernet Data Interface"
96 #define	MULTI_DEFAULT_STORAGE		"Mass Storage Interface"
97 #define	MULTI_DEFAULT_CONFIGURATION	"Default configuration"
98 #define	MULTI_DEFAULT_MANUFACTURER	USB_TEMPLATE_MANUFACTURER
99 #define	MULTI_DEFAULT_PRODUCT		"Multifunction Device"
100 /*
101  * The reason for this being called like this is that OSX
102  * derives the device node name from it, resulting in a somewhat
103  * user-friendly "/dev/cu.usbmodemFreeBSD1".  And yes, the "1"
104  * needs to be there, otherwise OSX will mangle it.
105  */
106 #define MULTI_DEFAULT_SERIAL_NUMBER	"FreeBSD1"
107 
108 static struct usb_string_descriptor	multi_modem;
109 static struct usb_string_descriptor	multi_eth_mac;
110 static struct usb_string_descriptor	multi_eth_control;
111 static struct usb_string_descriptor	multi_eth_data;
112 static struct usb_string_descriptor	multi_storage;
113 static struct usb_string_descriptor	multi_configuration;
114 static struct usb_string_descriptor	multi_manufacturer;
115 static struct usb_string_descriptor	multi_product;
116 static struct usb_string_descriptor	multi_serial_number;
117 
118 static struct sysctl_ctx_list		multi_ctx_list;
119 
120 /* prototypes */
121 
122 static usb_temp_get_string_desc_t multi_get_string_desc;
123 
124 static const struct usb_cdc_union_descriptor eth_union_desc = {
125 	.bLength = sizeof(eth_union_desc),
126 	.bDescriptorType = UDESC_CS_INTERFACE,
127 	.bDescriptorSubtype = UDESCSUB_CDC_UNION,
128 	.bMasterInterface = 0,		/* this is automatically updated */
129 	.bSlaveInterface[0] = 1,	/* this is automatically updated */
130 };
131 
132 static const struct usb_cdc_header_descriptor eth_header_desc = {
133 	.bLength = sizeof(eth_header_desc),
134 	.bDescriptorType = UDESC_CS_INTERFACE,
135 	.bDescriptorSubtype = UDESCSUB_CDC_HEADER,
136 	.bcdCDC[0] = 0x10,
137 	.bcdCDC[1] = 0x01,
138 };
139 
140 static const struct usb_cdc_ethernet_descriptor eth_enf_desc = {
141 	.bLength = sizeof(eth_enf_desc),
142 	.bDescriptorType = UDESC_CS_INTERFACE,
143 	.bDescriptorSubtype = UDESCSUB_CDC_ENF,
144 	.iMacAddress = MULTI_ETH_MAC_INDEX,
145 	.bmEthernetStatistics = {0, 0, 0, 0},
146 	.wMaxSegmentSize = {0xEA, 0x05},/* 1514 bytes */
147 	.wNumberMCFilters = {0, 0},
148 	.bNumberPowerFilters = 0,
149 };
150 
151 static const void *eth_control_if_desc[] = {
152 	&eth_union_desc,
153 	&eth_header_desc,
154 	&eth_enf_desc,
155 	NULL,
156 };
157 
158 static const struct usb_temp_packet_size bulk_mps = {
159 	.mps[USB_SPEED_FULL] = 64,
160 	.mps[USB_SPEED_HIGH] = 512,
161 };
162 
163 static const struct usb_temp_packet_size intr_mps = {
164 	.mps[USB_SPEED_FULL] = 8,
165 	.mps[USB_SPEED_HIGH] = 8,
166 };
167 
168 static const struct usb_temp_endpoint_desc bulk_in_ep = {
169 	.pPacketSize = &bulk_mps,
170 #ifdef USB_HIP_IN_EP_0
171 	.bEndpointAddress = USB_HIP_IN_EP_0,
172 #else
173 	.bEndpointAddress = UE_DIR_IN,
174 #endif
175 	.bmAttributes = UE_BULK,
176 };
177 
178 static const struct usb_temp_endpoint_desc bulk_out_ep = {
179 	.pPacketSize = &bulk_mps,
180 #ifdef USB_HIP_OUT_EP_0
181 	.bEndpointAddress = USB_HIP_OUT_EP_0,
182 #else
183 	.bEndpointAddress = UE_DIR_OUT,
184 #endif
185 	.bmAttributes = UE_BULK,
186 };
187 
188 static const struct usb_temp_endpoint_desc intr_in_ep = {
189 	.pPacketSize = &intr_mps,
190 	.bEndpointAddress = UE_DIR_IN,
191 	.bmAttributes = UE_INTERRUPT,
192 };
193 
194 static const struct usb_temp_endpoint_desc *eth_intr_endpoints[] = {
195 	&intr_in_ep,
196 	NULL,
197 };
198 
199 static const struct usb_temp_interface_desc eth_control_interface = {
200 	.ppEndpoints = eth_intr_endpoints,
201 	.ppRawDesc = eth_control_if_desc,
202 	.bInterfaceClass = UICLASS_CDC,
203 	.bInterfaceSubClass = UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL,
204 	.bInterfaceProtocol = UIPROTO_CDC_NONE,
205 	.iInterface = MULTI_ETH_CONTROL_INDEX,
206 };
207 
208 static const struct usb_temp_endpoint_desc *eth_data_endpoints[] = {
209 	&bulk_in_ep,
210 	&bulk_out_ep,
211 	NULL,
212 };
213 
214 static const struct usb_temp_interface_desc eth_data_null_interface = {
215 	.ppEndpoints = NULL,		/* no endpoints */
216 	.bInterfaceClass = UICLASS_CDC_DATA,
217 	.bInterfaceSubClass = UISUBCLASS_DATA,
218 	.bInterfaceProtocol = 0,
219 	.iInterface = MULTI_ETH_DATA_INDEX,
220 };
221 
222 static const struct usb_temp_interface_desc eth_data_interface = {
223 	.ppEndpoints = eth_data_endpoints,
224 	.bInterfaceClass = UICLASS_CDC_DATA,
225 	.bInterfaceSubClass = UISUBCLASS_DATA,
226 	.bInterfaceProtocol = 0,
227 	.iInterface = MULTI_ETH_DATA_INDEX,
228 	.isAltInterface = 1,		/* this is an alternate setting */
229 };
230 
231 static const struct usb_temp_packet_size modem_bulk_mps = {
232 	.mps[USB_SPEED_LOW] = 8,
233 	.mps[USB_SPEED_FULL] = 64,
234 	.mps[USB_SPEED_HIGH] = 512,
235 };
236 
237 static const struct usb_temp_packet_size modem_intr_mps = {
238 	.mps[USB_SPEED_LOW] = 8,
239 	.mps[USB_SPEED_FULL] = 8,
240 	.mps[USB_SPEED_HIGH] = 8,
241 };
242 
243 static const struct usb_temp_interval modem_intr_interval = {
244 	.bInterval[USB_SPEED_LOW] = 8,	/* 8ms */
245 	.bInterval[USB_SPEED_FULL] = 8,	/* 8ms */
246 	.bInterval[USB_SPEED_HIGH] = 7,	/* 8ms */
247 };
248 
249 static const struct usb_temp_endpoint_desc modem_ep_0 = {
250 	.pPacketSize = &modem_intr_mps,
251 	.pIntervals = &modem_intr_interval,
252 	.bEndpointAddress = UE_DIR_IN,
253 	.bmAttributes = UE_INTERRUPT,
254 };
255 
256 static const struct usb_temp_endpoint_desc modem_ep_1 = {
257 	.pPacketSize = &modem_bulk_mps,
258 	.bEndpointAddress = UE_DIR_OUT,
259 	.bmAttributes = UE_BULK,
260 };
261 
262 static const struct usb_temp_endpoint_desc modem_ep_2 = {
263 	.pPacketSize = &modem_bulk_mps,
264 	.bEndpointAddress = UE_DIR_IN,
265 	.bmAttributes = UE_BULK,
266 };
267 
268 static const struct usb_temp_endpoint_desc *modem_iface_0_ep[] = {
269 	&modem_ep_0,
270 	NULL,
271 };
272 
273 static const struct usb_temp_endpoint_desc *modem_iface_1_ep[] = {
274 	&modem_ep_1,
275 	&modem_ep_2,
276 	NULL,
277 };
278 
279 static const uint8_t modem_raw_desc_0[] = {
280 	0x05, 0x24, 0x00, 0x10, 0x01
281 };
282 
283 static const uint8_t modem_raw_desc_1[] = {
284 	0x05, 0x24, 0x06, MODEM_IFACE_0, MODEM_IFACE_1
285 };
286 
287 static const uint8_t modem_raw_desc_2[] = {
288 	0x05, 0x24, 0x01, 0x03, MODEM_IFACE_1
289 };
290 
291 static const uint8_t modem_raw_desc_3[] = {
292 	0x04, 0x24, 0x02, 0x07
293 };
294 
295 static const void *modem_iface_0_desc[] = {
296 	&modem_raw_desc_0,
297 	&modem_raw_desc_1,
298 	&modem_raw_desc_2,
299 	&modem_raw_desc_3,
300 	NULL,
301 };
302 
303 static const struct usb_temp_interface_desc modem_iface_0 = {
304 	.ppRawDesc = modem_iface_0_desc,
305 	.ppEndpoints = modem_iface_0_ep,
306 	.bInterfaceClass = UICLASS_CDC,
307 	.bInterfaceSubClass = UISUBCLASS_ABSTRACT_CONTROL_MODEL,
308 	.bInterfaceProtocol = UIPROTO_CDC_NONE,
309 	.iInterface = MULTI_MODEM_INDEX,
310 };
311 
312 static const struct usb_temp_interface_desc modem_iface_1 = {
313 	.ppEndpoints = modem_iface_1_ep,
314 	.bInterfaceClass = UICLASS_CDC_DATA,
315 	.bInterfaceSubClass = UISUBCLASS_DATA,
316 	.bInterfaceProtocol = 0,
317 	.iInterface = MULTI_MODEM_INDEX,
318 };
319 
320 static const struct usb_temp_packet_size msc_bulk_mps = {
321 	.mps[USB_SPEED_FULL] = 64,
322 	.mps[USB_SPEED_HIGH] = 512,
323 };
324 
325 static const struct usb_temp_endpoint_desc msc_bulk_in_ep = {
326 	.pPacketSize = &msc_bulk_mps,
327 #ifdef USB_HIP_IN_EP_0
328 	.bEndpointAddress = USB_HIP_IN_EP_0,
329 #else
330 	.bEndpointAddress = UE_DIR_IN,
331 #endif
332 	.bmAttributes = UE_BULK,
333 };
334 
335 static const struct usb_temp_endpoint_desc msc_bulk_out_ep = {
336 	.pPacketSize = &msc_bulk_mps,
337 #ifdef USB_HIP_OUT_EP_0
338 	.bEndpointAddress = USB_HIP_OUT_EP_0,
339 #else
340 	.bEndpointAddress = UE_DIR_OUT,
341 #endif
342 	.bmAttributes = UE_BULK,
343 };
344 
345 static const struct usb_temp_endpoint_desc *msc_data_endpoints[] = {
346 	&msc_bulk_in_ep,
347 	&msc_bulk_out_ep,
348 	NULL,
349 };
350 
351 static const struct usb_temp_interface_desc msc_data_interface = {
352 	.ppEndpoints = msc_data_endpoints,
353 	.bInterfaceClass = UICLASS_MASS,
354 	.bInterfaceSubClass = UISUBCLASS_SCSI,
355 	.bInterfaceProtocol = UIPROTO_MASS_BBB,
356 	.iInterface = MULTI_STORAGE_INDEX,
357 };
358 
359 static const struct usb_temp_interface_desc *multi_interfaces[] = {
360 	&modem_iface_0,
361 	&modem_iface_1,
362 	&eth_control_interface,
363 	&eth_data_null_interface,
364 	&eth_data_interface,
365 	&msc_data_interface,
366 	NULL,
367 };
368 
369 static const struct usb_temp_config_desc multi_config_desc = {
370 	.ppIfaceDesc = multi_interfaces,
371 	.bmAttributes = 0,
372 	.bMaxPower = 0,
373 	.iConfiguration = MULTI_CONFIGURATION_INDEX,
374 };
375 static const struct usb_temp_config_desc *multi_configs[] = {
376 	&multi_config_desc,
377 	NULL,
378 };
379 
380 struct usb_temp_device_desc usb_template_multi = {
381 	.getStringDesc = &multi_get_string_desc,
382 	.ppConfigDesc = multi_configs,
383 	.idVendor = MULTI_DEFAULT_VENDOR_ID,
384 	.idProduct = MULTI_DEFAULT_PRODUCT_ID,
385 	.bcdDevice = 0x0100,
386 	.bDeviceClass = UDCLASS_IN_INTERFACE,
387 	.bDeviceSubClass = 0,
388 	.bDeviceProtocol = 0,
389 	.iManufacturer = MULTI_MANUFACTURER_INDEX,
390 	.iProduct = MULTI_PRODUCT_INDEX,
391 	.iSerialNumber = MULTI_SERIAL_NUMBER_INDEX,
392 };
393 
394 /*------------------------------------------------------------------------*
395  *	multi_get_string_desc
396  *
397  * Return values:
398  * NULL: Failure. No such string.
399  * Else: Success. Pointer to string descriptor is returned.
400  *------------------------------------------------------------------------*/
401 static const void *
402 multi_get_string_desc(uint16_t lang_id, uint8_t string_index)
403 {
404 	static const void *ptr[MULTI_MAX_INDEX] = {
405 		[MULTI_LANG_INDEX] = &usb_string_lang_en,
406 		[MULTI_MODEM_INDEX] = &multi_modem,
407 		[MULTI_ETH_MAC_INDEX] = &multi_eth_mac,
408 		[MULTI_ETH_CONTROL_INDEX] = &multi_eth_control,
409 		[MULTI_ETH_DATA_INDEX] = &multi_eth_data,
410 		[MULTI_STORAGE_INDEX] = &multi_storage,
411 		[MULTI_CONFIGURATION_INDEX] = &multi_configuration,
412 		[MULTI_MANUFACTURER_INDEX] = &multi_manufacturer,
413 		[MULTI_PRODUCT_INDEX] = &multi_product,
414 		[MULTI_SERIAL_NUMBER_INDEX] = &multi_serial_number,
415 	};
416 
417 	if (string_index == 0) {
418 		return (&usb_string_lang_en);
419 	}
420 	if (lang_id != 0x0409) {
421 		return (NULL);
422 	}
423 	if (string_index < MULTI_MAX_INDEX) {
424 		return (ptr[string_index]);
425 	}
426 	return (NULL);
427 }
428 
429 static void
430 multi_init(void *arg __unused)
431 {
432 	struct sysctl_oid *parent;
433 	char parent_name[3];
434 
435 	usb_make_str_desc(&multi_modem, sizeof(multi_modem),
436 	    MULTI_DEFAULT_MODEM);
437 	usb_make_str_desc(&multi_eth_mac, sizeof(multi_eth_mac),
438 	    MULTI_DEFAULT_ETH_MAC);
439 	usb_make_str_desc(&multi_eth_control, sizeof(multi_eth_control),
440 	    MULTI_DEFAULT_ETH_CONTROL);
441 	usb_make_str_desc(&multi_eth_data, sizeof(multi_eth_data),
442 	    MULTI_DEFAULT_ETH_DATA);
443 	usb_make_str_desc(&multi_storage, sizeof(multi_storage),
444 	    MULTI_DEFAULT_STORAGE);
445 	usb_make_str_desc(&multi_configuration, sizeof(multi_configuration),
446 	    MULTI_DEFAULT_CONFIGURATION);
447 	usb_make_str_desc(&multi_manufacturer, sizeof(multi_manufacturer),
448 	    MULTI_DEFAULT_MANUFACTURER);
449 	usb_make_str_desc(&multi_product, sizeof(multi_product),
450 	    MULTI_DEFAULT_PRODUCT);
451 	usb_make_str_desc(&multi_serial_number, sizeof(multi_serial_number),
452 	    MULTI_DEFAULT_SERIAL_NUMBER);
453 
454 	snprintf(parent_name, sizeof(parent_name), "%d", USB_TEMP_MULTI);
455 	sysctl_ctx_init(&multi_ctx_list);
456 
457 	parent = SYSCTL_ADD_NODE(&multi_ctx_list,
458 	    SYSCTL_STATIC_CHILDREN(_hw_usb_templates), OID_AUTO,
459 	    parent_name, CTLFLAG_RW | CTLFLAG_MPSAFE,
460 	    0, "USB Multifunction device side template");
461 	SYSCTL_ADD_U16(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
462 	    "vendor_id", CTLFLAG_RWTUN,
463 	    &usb_template_multi.idVendor, 1, "Vendor identifier");
464 	SYSCTL_ADD_U16(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
465 	    "product_id", CTLFLAG_RWTUN,
466 	    &usb_template_multi.idProduct, 1, "Product identifier");
467 	SYSCTL_ADD_PROC(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
468 	    "eth_mac", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
469 	    &multi_eth_mac, sizeof(multi_eth_mac), usb_temp_sysctl,
470 	    "A", "Ethernet MAC address string");
471 #if 0
472 	SYSCTL_ADD_PROC(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
473 	    "modem", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
474 	    &multi_modem, sizeof(multi_modem), usb_temp_sysctl,
475 	    "A", "Modem interface string");
476 	SYSCTL_ADD_PROC(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
477 	    "eth_control", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
478 	    &multi_eth_control, sizeof(multi_eth_data), usb_temp_sysctl,
479 	    "A", "Ethernet control interface string");
480 	SYSCTL_ADD_PROC(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
481 	    "eth_data", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
482 	    &multi_eth_data, sizeof(multi_eth_data), usb_temp_sysctl,
483 	    "A", "Ethernet data interface string");
484 	SYSCTL_ADD_PROC(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
485 	    "interface", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
486 	    &multi_storage, sizeof(multi_storage), usb_temp_sysctl,
487 	    "A", "Storage interface string");
488 	SYSCTL_ADD_PROC(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
489 	    "configuration", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
490 	    &multi_configuration, sizeof(multi_configuration), usb_temp_sysctl,
491 	    "A", "Configuration string");
492 #endif
493 	SYSCTL_ADD_PROC(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
494 	    "manufacturer", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
495 	    &multi_manufacturer, sizeof(multi_manufacturer), usb_temp_sysctl,
496 	    "A", "Manufacturer string");
497 	SYSCTL_ADD_PROC(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
498 	    "product", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
499 	    &multi_product, sizeof(multi_product), usb_temp_sysctl,
500 	    "A", "Product string");
501 	SYSCTL_ADD_PROC(&multi_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
502 	    "serial_number", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
503 	    &multi_serial_number, sizeof(multi_serial_number), usb_temp_sysctl,
504 	    "A", "Serial number string");
505 }
506 
507 static void
508 multi_uninit(void *arg __unused)
509 {
510 
511 	sysctl_ctx_free(&multi_ctx_list);
512 }
513 
514 SYSINIT(multi_init, SI_SUB_LOCK, SI_ORDER_FIRST, multi_init, NULL);
515 SYSUNINIT(multi_uninit, SI_SUB_LOCK, SI_ORDER_FIRST, multi_uninit, NULL);
516