Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Sep 2019 17:54:52 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r351942 - in stable/12: share/man/man4 sys/conf sys/dev/usb sys/dev/usb/net sys/dev/usb/template sys/modules/usb sys/modules/usb/cdceem sys/modules/usb/template
Message-ID:  <201909061754.x86HsqAA006158@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Fri Sep  6 17:54:51 2019
New Revision: 351942
URL: https://svnweb.freebsd.org/changeset/base/351942

Log:
  MFC r350685:
  
  Add cdceem(4) driver, for virtual ethernet devices compliant
  with Communication Device Class Ethernet Emulation Model (CDC EEM).
  The driver supports both the device, and host side operation; there
  is a new USB template (#11) for the former.
  
  This enables communication with virtual USB NIC provided by iLO 5,
  as found in new HPE Proliant servers.
  
  Reviewed by:	hselasky
  Relnotes:	yes
  Sponsored by:	Hewlett Packard Enterprise

Added:
  stable/12/share/man/man4/cdceem.4
     - copied unchanged from r350685, head/share/man/man4/cdceem.4
  stable/12/sys/dev/usb/net/if_cdceem.c
     - copied, changed from r350685, head/sys/dev/usb/net/if_cdceem.c
  stable/12/sys/dev/usb/template/usb_template_cdceem.c
     - copied unchanged from r350685, head/sys/dev/usb/template/usb_template_cdceem.c
  stable/12/sys/modules/usb/cdceem/
     - copied from r350685, head/sys/modules/usb/cdceem/
Modified:
  stable/12/share/man/man4/Makefile
  stable/12/share/man/man4/cdce.4
  stable/12/share/man/man4/ipheth.4
  stable/12/share/man/man4/urndis.4
  stable/12/share/man/man4/usb_template.4
  stable/12/sys/conf/files
  stable/12/sys/dev/usb/template/usb_template.c
  stable/12/sys/dev/usb/template/usb_template.h
  stable/12/sys/dev/usb/usb.h
  stable/12/sys/dev/usb/usb_ioctl.h
  stable/12/sys/modules/usb/Makefile
  stable/12/sys/modules/usb/template/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/Makefile
==============================================================================
--- stable/12/share/man/man4/Makefile	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/share/man/man4/Makefile	Fri Sep  6 17:54:51 2019	(r351942)
@@ -109,6 +109,7 @@ MAN=	aac.4 \
 	ccr.4 \
 	cd.4 \
 	cdce.4 \
+	cdceem.4 \
 	cfi.4 \
 	cfumass.4 \
 	ch.4 \

Modified: stable/12/share/man/man4/cdce.4
==============================================================================
--- stable/12/share/man/man4/cdce.4	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/share/man/man4/cdce.4	Fri Sep  6 17:54:51 2019	(r351942)
@@ -117,6 +117,7 @@ is running low on mbufs.
 .El
 .Sh SEE ALSO
 .Xr arp 4 ,
+.Xr cdceem 4 ,
 .Xr intro 4 ,
 .Xr ipheth 4 ,
 .Xr netintro 4 ,

Copied: stable/12/share/man/man4/cdceem.4 (from r350685, head/share/man/man4/cdceem.4)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/12/share/man/man4/cdceem.4	Fri Sep  6 17:54:51 2019	(r351942, copy of r350685, head/share/man/man4/cdceem.4)
@@ -0,0 +1,119 @@
+.\" Copyright (c) 2019 Edward Tomasz Napierala <trasz@FreeBSD.org>
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.Dd August 7, 2019
+.Dt CDCEEM 4
+.Os
+.Sh NAME
+.Nm cdceem
+.Nd "USB Communication Device Class Ethernet Emulation Model (CDC EEM) driver"
+.Sh SYNOPSIS
+To compile this driver into the kernel,
+place the following lines in your
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device uhci"
+.Cd "device ohci"
+.Cd "device usb"
+.Cd "device miibus"
+.Cd "device uether"
+.Cd "device cdceem"
+.Ed
+.Pp
+Alternatively, to load the driver as a
+module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+if_cdceem_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for USB devices based on the USB Communication
+Device Class Ethernet Emulation Model (CDC EEM) specification.
+.Pp
+The driver works on both host, and device-side; see
+.Xr usb_template 4
+for details.
+.Pp
+The USB device appears as a regular network interface on both sides,
+transporting Ethernet frames.
+.Pp
+For more information on configuring this device, see
+.Xr ifconfig 8 .
+.Pp
+The
+.Nm
+driver does not support different media types or options.
+.Sh SYSCTL VARIABLES
+The following variables are available as both
+.Xr sysctl 8
+variables and
+.Xr loader 8
+tunables:
+.Bl -tag -width indent
+.It Va hw.usb.cdceem.debug
+Verbosity level for log messages from the
+.Nm
+driver.
+Set to 0 to disable logging or 1 to warn about potential problems.
+Larger values enable debugging output.
+Defaults to 1.
+.It Va hw.usb.cdceem.send_echoes
+If set to 1, the driver will send an Echo EEM packet when the
+interface is brought up.
+While responding to Echo is mandatory, some devices cannot handle it.
+Only use for debugging.
+Defaults to 0.
+.It Va hw.usb.cdceem.send_fake_crc
+If set to 1, the driver will use 0xdeadbeef as the CRC value
+for outgoing Data EEM packets.
+Only use for debugging.
+Defaults to 0.
+.El
+.Sh SEE ALSO
+.Xr arp 4 ,
+.Xr cdce 4 ,
+.Xr intro 4 ,
+.Xr ipheth 4 ,
+.Xr netintro 4 ,
+.Xr urndis 4 ,
+.Xr usb 4 ,
+.Xr usb_template 4 ,
+.Xr ifconfig 8
+.Rs
+.%T "Universal Serial Bus Communications Class Subclass Specification for Ethernet Emulation Model Devices"
+.%U https://usb.org/sites/default/files/CDC_EEM10.pdf
+.Re
+.Sh HISTORY
+The
+.Nm
+device driver first appeared in
+.Fx 13.0 .
+.Sh AUTHORS
+The
+.Nm
+driver was written by
+.An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org
+under sponsorship from Hewlett Packard Enterprise.

Modified: stable/12/share/man/man4/ipheth.4
==============================================================================
--- stable/12/share/man/man4/ipheth.4	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/share/man/man4/ipheth.4	Fri Sep  6 17:54:51 2019	(r351942)
@@ -78,6 +78,7 @@ Apple iPad tethering (all models)
 .Sh SEE ALSO
 .Xr arp 4 ,
 .Xr cdce 4 ,
+.Xr cdceem 4 ,
 .Xr intro 4 ,
 .Xr netintro 4 ,
 .Xr urndis 4 ,

Modified: stable/12/share/man/man4/urndis.4
==============================================================================
--- stable/12/share/man/man4/urndis.4	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/share/man/man4/urndis.4	Fri Sep  6 17:54:51 2019	(r351942)
@@ -79,6 +79,7 @@ functionality of many Android devices.
 .Sh SEE ALSO
 .Xr arp 4 ,
 .Xr cdce 4 ,
+.Xr cdceem 4 ,
 .Xr ipheth 4 ,
 .Xr netintro 4 ,
 .Xr usb 4 ,

Modified: stable/12/share/man/man4/usb_template.4
==============================================================================
--- stable/12/share/man/man4/usb_template.4	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/share/man/man4/usb_template.4	Fri Sep  6 17:54:51 2019	(r351942)
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 24, 2018
+.Dd August 7, 2019
 .Dt USB_TEMPLATE 4
 .Os
 .
@@ -88,6 +88,8 @@ Available templates are:
 .It Dv 8 Ta CDC Ethernet and serial port
 .It Dv 9 Ta USB MIDI
 .It Dv 10 Ta CDC Ethernet, serial port, and storage
+.It Dv 11 Ta CDC Ethernet Emulation Model, see
+.Xr cdceem 4
 .El
 .
 .Sh SYSCTL VARIABLES

Modified: stable/12/sys/conf/files
==============================================================================
--- stable/12/sys/conf/files	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/sys/conf/files	Fri Sep  6 17:54:51 2019	(r351942)
@@ -3338,6 +3338,7 @@ dev/usb/net/if_aue.c		optional aue
 dev/usb/net/if_axe.c		optional axe
 dev/usb/net/if_axge.c		optional axge
 dev/usb/net/if_cdce.c		optional cdce
+dev/usb/net/if_cdceem.c		optional cdceem
 dev/usb/net/if_cue.c		optional cue
 dev/usb/net/if_ipheth.c		optional ipheth
 dev/usb/net/if_kue.c		optional kue
@@ -3351,8 +3352,8 @@ dev/usb/net/if_usie.c		optional usie
 dev/usb/net/if_urndis.c		optional urndis
 dev/usb/net/ruephy.c		optional rue
 dev/usb/net/usb_ethernet.c	optional uether | aue | axe | axge | cdce | \
-					 cue | ipheth | kue | mos | rue | \
-					 smsc | udav | ure | urndis
+					 cdceem | cue | ipheth | kue | mos | \
+					 rue | smsc | udav | ure | urndis
 dev/usb/net/uhso.c		optional uhso
 #
 # USB WLAN drivers
@@ -3457,6 +3458,7 @@ dev/usb/template/usb_template_phone.c	optional usb_tem
 dev/usb/template/usb_template_serialnet.c	optional usb_template
 dev/usb/template/usb_template_midi.c	optional usb_template
 dev/usb/template/usb_template_multi.c	optional usb_template
+dev/usb/template/usb_template_cdceem.c	optional usb_template
 #
 # USB video drivers
 #

Copied and modified: stable/12/sys/dev/usb/net/if_cdceem.c (from r350685, head/sys/dev/usb/net/if_cdceem.c)
==============================================================================
--- head/sys/dev/usb/net/if_cdceem.c	Wed Aug  7 18:14:45 2019	(r350685, copy source)
+++ stable/12/sys/dev/usb/net/if_cdceem.c	Fri Sep  6 17:54:51 2019	(r351942)
@@ -40,7 +40,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <sys/gsb_crc32.h>
+#include <sys/param.h>
 #include <sys/eventhandler.h>
 #include <sys/stdint.h>
 #include <sys/stddef.h>

Modified: stable/12/sys/dev/usb/template/usb_template.c
==============================================================================
--- stable/12/sys/dev/usb/template/usb_template.c	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/sys/dev/usb/template/usb_template.c	Fri Sep  6 17:54:51 2019	(r351942)
@@ -1464,6 +1464,9 @@ usb_temp_setup_by_index(struct usb_device *udev, uint1
 	case USB_TEMP_MULTI:
 		err = usb_temp_setup(udev, &usb_template_multi);
 		break;
+	case USB_TEMP_CDCEEM:
+		err = usb_temp_setup(udev, &usb_template_cdceem);
+		break;
 	default:
 		return (USB_ERR_INVAL);
 	}

Modified: stable/12/sys/dev/usb/template/usb_template.h
==============================================================================
--- stable/12/sys/dev/usb/template/usb_template.h	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/sys/dev/usb/template/usb_template.h	Fri Sep  6 17:54:51 2019	(r351942)
@@ -116,7 +116,7 @@ extern struct usb_temp_device_desc usb_template_phone;
 extern struct usb_temp_device_desc usb_template_serialnet;
 extern struct usb_temp_device_desc usb_template_midi;
 extern struct usb_temp_device_desc usb_template_multi;
-
+extern struct usb_temp_device_desc usb_template_cdceem;
 
 void		usb_decode_str_desc(struct usb_string_descriptor *sd,
 		    char *buf, size_t buflen);

Copied: stable/12/sys/dev/usb/template/usb_template_cdceem.c (from r350685, head/sys/dev/usb/template/usb_template_cdceem.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/12/sys/dev/usb/template/usb_template_cdceem.c	Fri Sep  6 17:54:51 2019	(r351942, copy of r350685, head/sys/dev/usb/template/usb_template_cdceem.c)
@@ -0,0 +1,263 @@
+/* $FreeBSD$ */
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2008 Hans Petter Selasky <hselasky@FreeBSD.org>
+ * Copyright (c) 2018 The FreeBSD Foundation
+ * Copyright (c) 2019 Edward Tomasz Napierala <trasz@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Edward Tomasz Napierala
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * This file contains the USB templates for an USB Mass Storage Device.
+ */
+
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usb_core.h>
+#include <dev/usb/usb_ioctl.h>
+#include <dev/usb/usb_util.h>
+
+#include <dev/usb/template/usb_template.h>
+#endif			/* USB_GLOBAL_INCLUDE_FILE */
+
+enum {
+	CDCEEM_LANG_INDEX,
+	CDCEEM_INTERFACE_INDEX,
+	CDCEEM_CONFIGURATION_INDEX,
+	CDCEEM_MANUFACTURER_INDEX,
+	CDCEEM_PRODUCT_INDEX,
+	CDCEEM_SERIAL_NUMBER_INDEX,
+	CDCEEM_MAX_INDEX,
+};
+
+#define	CDCEEM_DEFAULT_VENDOR_ID	USB_TEMPLATE_VENDOR
+#define	CDCEEM_DEFAULT_PRODUCT_ID	0x27df
+#define	CDCEEM_DEFAULT_INTERFACE	"USB CDC EEM Interface"
+#define	CDCEEM_DEFAULT_CONFIGURATION	"Default Config"
+#define	CDCEEM_DEFAULT_MANUFACTURER	USB_TEMPLATE_MANUFACTURER
+#define	CDCEEM_DEFAULT_PRODUCT		"CDC EEM"
+#define	CDCEEM_DEFAULT_SERIAL_NUMBER	"March 2008"
+
+static struct usb_string_descriptor	cdceem_interface;
+static struct usb_string_descriptor	cdceem_configuration;
+static struct usb_string_descriptor	cdceem_manufacturer;
+static struct usb_string_descriptor	cdceem_product;
+static struct usb_string_descriptor	cdceem_serial_number;
+
+static struct sysctl_ctx_list		cdceem_ctx_list;
+
+/* prototypes */
+
+static usb_temp_get_string_desc_t cdceem_get_string_desc;
+
+static const struct usb_temp_packet_size bulk_mps = {
+	.mps[USB_SPEED_FULL] = 64,
+	.mps[USB_SPEED_HIGH] = 512,
+};
+
+static const struct usb_temp_endpoint_desc bulk_in_ep = {
+	.pPacketSize = &bulk_mps,
+#ifdef USB_HIP_IN_EP_0
+	.bEndpointAddress = USB_HIP_IN_EP_0,
+#else
+	.bEndpointAddress = UE_DIR_IN,
+#endif
+	.bmAttributes = UE_BULK,
+};
+
+static const struct usb_temp_endpoint_desc bulk_out_ep = {
+	.pPacketSize = &bulk_mps,
+#ifdef USB_HIP_OUT_EP_0
+	.bEndpointAddress = USB_HIP_OUT_EP_0,
+#else
+	.bEndpointAddress = UE_DIR_OUT,
+#endif
+	.bmAttributes = UE_BULK,
+};
+
+static const struct usb_temp_endpoint_desc *cdceem_data_endpoints[] = {
+	&bulk_in_ep,
+	&bulk_out_ep,
+	NULL,
+};
+
+static const struct usb_temp_interface_desc cdceem_data_interface = {
+	.ppEndpoints = cdceem_data_endpoints,
+	.bInterfaceClass = UICLASS_CDC,
+	.bInterfaceSubClass = UISUBCLASS_ETHERNET_EMULATION_MODEL,
+	.bInterfaceProtocol = UIPROTO_CDC_EEM,
+	.iInterface = CDCEEM_INTERFACE_INDEX,
+};
+
+static const struct usb_temp_interface_desc *cdceem_interfaces[] = {
+	&cdceem_data_interface,
+	NULL,
+};
+
+static const struct usb_temp_config_desc cdceem_config_desc = {
+	.ppIfaceDesc = cdceem_interfaces,
+	.bmAttributes = 0,
+	.bMaxPower = 0,
+	.iConfiguration = CDCEEM_CONFIGURATION_INDEX,
+};
+
+static const struct usb_temp_config_desc *cdceem_configs[] = {
+	&cdceem_config_desc,
+	NULL,
+};
+
+struct usb_temp_device_desc usb_template_cdceem = {
+	.getStringDesc = &cdceem_get_string_desc,
+	.ppConfigDesc = cdceem_configs,
+	.idVendor = CDCEEM_DEFAULT_VENDOR_ID,
+	.idProduct = CDCEEM_DEFAULT_PRODUCT_ID,
+	.bcdDevice = 0x0100,
+	.bDeviceClass = UDCLASS_COMM,
+	.bDeviceSubClass = 0,
+	.bDeviceProtocol = 0,
+	.iManufacturer = CDCEEM_MANUFACTURER_INDEX,
+	.iProduct = CDCEEM_PRODUCT_INDEX,
+	.iSerialNumber = CDCEEM_SERIAL_NUMBER_INDEX,
+};
+
+/*------------------------------------------------------------------------*
+ *	cdceem_get_string_desc
+ *
+ * Return values:
+ * NULL: Failure. No such string.
+ * Else: Success. Pointer to string descriptor is returned.
+ *------------------------------------------------------------------------*/
+static const void *
+cdceem_get_string_desc(uint16_t lang_id, uint8_t string_index)
+{
+	static const void *ptr[CDCEEM_MAX_INDEX] = {
+		[CDCEEM_LANG_INDEX] = &usb_string_lang_en,
+		[CDCEEM_INTERFACE_INDEX] = &cdceem_interface,
+		[CDCEEM_CONFIGURATION_INDEX] = &cdceem_configuration,
+		[CDCEEM_MANUFACTURER_INDEX] = &cdceem_manufacturer,
+		[CDCEEM_PRODUCT_INDEX] = &cdceem_product,
+		[CDCEEM_SERIAL_NUMBER_INDEX] = &cdceem_serial_number,
+	};
+
+	if (string_index == 0) {
+		return (&usb_string_lang_en);
+	}
+	if (lang_id != 0x0409) {
+		return (NULL);
+	}
+	if (string_index < CDCEEM_MAX_INDEX) {
+		return (ptr[string_index]);
+	}
+	return (NULL);
+}
+
+static void
+cdceem_init(void *arg __unused)
+{
+	struct sysctl_oid *parent;
+	char parent_name[3];
+
+	usb_make_str_desc(&cdceem_interface, sizeof(cdceem_interface),
+	    CDCEEM_DEFAULT_INTERFACE);
+	usb_make_str_desc(&cdceem_configuration, sizeof(cdceem_configuration),
+	    CDCEEM_DEFAULT_CONFIGURATION);
+	usb_make_str_desc(&cdceem_manufacturer, sizeof(cdceem_manufacturer),
+	    CDCEEM_DEFAULT_MANUFACTURER);
+	usb_make_str_desc(&cdceem_product, sizeof(cdceem_product),
+	    CDCEEM_DEFAULT_PRODUCT);
+	usb_make_str_desc(&cdceem_serial_number, sizeof(cdceem_serial_number),
+	    CDCEEM_DEFAULT_SERIAL_NUMBER);
+
+	snprintf(parent_name, sizeof(parent_name), "%d", USB_TEMP_CDCEEM);
+	sysctl_ctx_init(&cdceem_ctx_list);
+
+	parent = SYSCTL_ADD_NODE(&cdceem_ctx_list,
+	    SYSCTL_STATIC_CHILDREN(_hw_usb_templates), OID_AUTO,
+	    parent_name, CTLFLAG_RW,
+	    0, "USB CDC EEM device side template");
+	SYSCTL_ADD_U16(&cdceem_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
+	    "vendor_id", CTLFLAG_RWTUN,
+	    &usb_template_cdceem.idVendor, 1, "Vendor identifier");
+	SYSCTL_ADD_U16(&cdceem_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
+	    "product_id", CTLFLAG_RWTUN,
+	    &usb_template_cdceem.idProduct, 1, "Product identifier");
+#if 0
+	SYSCTL_ADD_PROC(&cdceem_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
+	    "interface", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+	    &cdceem_interface, sizeof(cdceem_interface), usb_temp_sysctl,
+	    "A", "Interface string");
+	SYSCTL_ADD_PROC(&cdceem_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
+	    "configuration", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+	    &cdceem_configuration, sizeof(cdceem_configuration), usb_temp_sysctl,
+	    "A", "Configuration string");
+#endif
+	SYSCTL_ADD_PROC(&cdceem_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
+	    "manufacturer", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+	    &cdceem_manufacturer, sizeof(cdceem_manufacturer), usb_temp_sysctl,
+	    "A", "Manufacturer string");
+	SYSCTL_ADD_PROC(&cdceem_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
+	    "product", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+	    &cdceem_product, sizeof(cdceem_product), usb_temp_sysctl,
+	    "A", "Product string");
+	SYSCTL_ADD_PROC(&cdceem_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
+	    "serial_number", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+	    &cdceem_serial_number, sizeof(cdceem_serial_number), usb_temp_sysctl,
+	    "A", "Serial number string");
+}
+
+static void
+cdceem_uninit(void *arg __unused)
+{
+
+	sysctl_ctx_free(&cdceem_ctx_list);
+}
+
+SYSINIT(cdceem_init, SI_SUB_LOCK, SI_ORDER_FIRST, cdceem_init, NULL);
+SYSUNINIT(cdceem_uninit, SI_SUB_LOCK, SI_ORDER_FIRST, cdceem_uninit, NULL);

Modified: stable/12/sys/dev/usb/usb.h
==============================================================================
--- stable/12/sys/dev/usb/usb.h	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/sys/dev/usb/usb.h	Fri Sep  6 17:54:51 2019	(r351942)
@@ -444,6 +444,7 @@ typedef struct usb_interface_assoc_descriptor usb_inte
 
 #define	UIPROTO_CDC_NONE		0
 #define	UIPROTO_CDC_AT			1
+#define	UIPROTO_CDC_EEM			7
 
 #define	UICLASS_HID		0x03
 #define	UISUBCLASS_BOOT		1

Modified: stable/12/sys/dev/usb/usb_ioctl.h
==============================================================================
--- stable/12/sys/dev/usb/usb_ioctl.h	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/sys/dev/usb/usb_ioctl.h	Fri Sep  6 17:54:51 2019	(r351942)
@@ -70,6 +70,7 @@ enum {
 	USB_TEMP_SERIALNET,	/* USB CDC Ethernet and Modem */
 	USB_TEMP_MIDI,		/* USB MIDI */
 	USB_TEMP_MULTI,		/* USB Ethernet, serial, and storage */
+	USB_TEMP_CDCEEM,	/* USB Ethernet Emulation Model */
 	USB_TEMP_MAX,
 };
 

Modified: stable/12/sys/modules/usb/Makefile
==============================================================================
--- stable/12/sys/modules/usb/Makefile	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/sys/modules/usb/Makefile	Fri Sep  6 17:54:51 2019	(r351942)
@@ -51,7 +51,8 @@ SUBDIR += atp cfumass uhid uhid_snes ukbd ums udbp ufm
 SUBDIR += ucom u3g uark ubsa ubser uchcom ucycom ufoma uftdi ugensa uipaq ulpt \
 	  umct umcs umodem umoscom uplcom uslcom uvisor uvscom
 SUBDIR += udl
-SUBDIR += uether aue axe axge cdce cue ${_kue} mos rue smsc udav uhso ipheth
+SUBDIR += uether aue axe axge cdce cdceem cue ${_kue} mos rue smsc udav uhso \
+	  ipheth
 SUBDIR += muge
 SUBDIR += ure urndis
 SUBDIR += usfs umass urio

Modified: stable/12/sys/modules/usb/template/Makefile
==============================================================================
--- stable/12/sys/modules/usb/template/Makefile	Fri Sep  6 17:43:00 2019	(r351941)
+++ stable/12/sys/modules/usb/template/Makefile	Fri Sep  6 17:54:51 2019	(r351942)
@@ -42,6 +42,7 @@ SRCS=	opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.
 	usb_template_phone.c \
 	usb_template_serialnet.c \
 	usb_template_midi.c \
-	usb_template_multi.c
+	usb_template_multi.c \
+	usb_template_cdceem.c
 
 .include <bsd.kmod.mk>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909061754.x86HsqAA006158>