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