FreeBSD kernel usb device Code
if_cdce.c File Reference
#include <sys/cdefs.h>
#include <sys/gsb_crc32.h>
#include <sys/eventhandler.h>
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/queue.h>
#include <sys/systm.h>
#include <sys/socket.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 <net/if.h>
#include <net/if_var.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_cdc.h>
#include "usbdevs.h"
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_msctest.h>
#include "usb_if.h"
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_cdcereg.h>
Include dependency graph for if_cdce.c:

Go to the source code of this file.

Macros

#define USB_DEBUG_VAR   cdce_debug
 
#define cdce_debug   0
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int cdce_attach_post_sub (struct usb_ether *)
 
static int cdce_ioctl (struct ifnet *, u_long, caddr_t)
 
static int cdce_media_change_cb (struct ifnet *)
 
static void cdce_media_status_cb (struct ifnet *, struct ifmediareq *)
 
static uint32_t cdce_m_crc32 (struct mbuf *, uint32_t, uint32_t)
 
static void cdce_set_filter (struct usb_ether *)
 
static int cdce_driver_loaded (struct module *, int, void *)
 
 DRIVER_MODULE (cdce, uhub, cdce_driver, cdce_devclass, cdce_driver_loaded, 0)
 
 MODULE_VERSION (cdce, 1)
 
 MODULE_DEPEND (cdce, uether, 1, 1, 1)
 
 MODULE_DEPEND (cdce, usb, 1, 1, 1)
 
 MODULE_DEPEND (cdce, ether, 1, 1, 1)
 
 USB_PNP_DEVICE_INFO (cdce_switch_devs)
 
 USB_PNP_HOST_INFO (cdce_host_devs)
 
 USB_PNP_DUAL_INFO (cdce_dual_devs)
 
static void cdce_test_autoinst (void *arg, struct usb_device *udev, struct usb_attach_arg *uaa)
 
static int cdce_probe (device_t dev)
 
static void cdce_attach_post (struct usb_ether *ue)
 
static int cdce_attach (device_t dev)
 
static int cdce_detach (device_t dev)
 
static void cdce_start (struct usb_ether *ue)
 
static void cdce_free_queue (struct mbuf **ppm, uint8_t n)
 
static void cdce_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static int32_t cdce_m_crc32_cb (void *arg, void *src, uint32_t count)
 
static void cdce_init (struct usb_ether *ue)
 
static void cdce_stop (struct usb_ether *ue)
 
static void cdce_setmulti (struct usb_ether *ue)
 
static void cdce_setpromisc (struct usb_ether *ue)
 
static int cdce_suspend (device_t dev)
 
static int cdce_resume (device_t dev)
 
static void cdce_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void cdce_intr_read_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void cdce_intr_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static int cdce_handle_request (device_t dev, const void *preq, void **pptr, uint16_t *plen, uint16_t offset, uint8_t *pstate)
 

Variables

static device_probe_t cdce_probe
 
static device_attach_t cdce_attach
 
static device_detach_t cdce_detach
 
static device_suspend_t cdce_suspend
 
static device_resume_t cdce_resume
 
static usb_handle_request_t cdce_handle_request
 
static usb_callback_t cdce_bulk_write_callback
 
static usb_callback_t cdce_bulk_read_callback
 
static usb_callback_t cdce_intr_read_callback
 
static usb_callback_t cdce_intr_write_callback
 
static uether_fn_t cdce_attach_post
 
static uether_fn_t cdce_init
 
static uether_fn_t cdce_stop
 
static uether_fn_t cdce_start
 
static uether_fn_t cdce_setmulti
 
static uether_fn_t cdce_setpromisc
 
static const struct usb_config cdce_config [CDCE_N_TRANSFER]
 
static device_method_t cdce_methods []
 
static driver_t cdce_driver
 
static devclass_t cdce_devclass
 
static eventhandler_tag cdce_etag
 
static const STRUCT_USB_HOST_ID cdce_switch_devs []
 
static const STRUCT_USB_HOST_ID cdce_host_devs []
 
static const STRUCT_USB_DUAL_ID cdce_dual_devs []
 
static const struct usb_ether_methods cdce_ue_methods
 

Macro Definition Documentation

◆ cdce_debug

#define cdce_debug   0

Definition at line 133 of file if_cdce.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   cdce_debug

Definition at line 82 of file if_cdce.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ cdce_attach()

◆ cdce_attach_post()

static void cdce_attach_post ( struct usb_ether ue)
static

Definition at line 565 of file if_cdce.c.

◆ cdce_attach_post_sub()

static int cdce_attach_post_sub ( struct usb_ether ue)
static

◆ cdce_bulk_read_callback()

◆ cdce_bulk_write_callback()

◆ cdce_detach()

static int cdce_detach ( device_t  dev)
static

Definition at line 784 of file if_cdce.c.

References CDCE_N_TRANSFER, dev, cdce_softc::sc_media, cdce_softc::sc_mtx, cdce_softc::sc_ue, cdce_softc::sc_xfer, uether_ifdetach(), and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ cdce_driver_loaded()

static int cdce_driver_loaded ( struct module *  mod,
int  what,
void *  arg 
)
static

Definition at line 536 of file if_cdce.c.

References cdce_etag, and cdce_test_autoinst().

Here is the call graph for this function:

◆ cdce_free_queue()

static void cdce_free_queue ( struct mbuf **  ppm,
uint8_t  n 
)
static

Definition at line 835 of file if_cdce.c.

References n.

Referenced by cdce_bulk_read_callback(), and cdce_bulk_write_callback().

Here is the caller graph for this function:

◆ cdce_handle_request()

static int cdce_handle_request ( device_t  dev,
const void *  preq,
void **  pptr,
uint16_t *  plen,
uint16_t  offset,
uint8_t *  pstate 
)
static

◆ cdce_init()

static void cdce_init ( struct usb_ether ue)
static

◆ cdce_intr_read_callback()

◆ cdce_intr_write_callback()

◆ cdce_ioctl()

static int cdce_ioctl ( struct ifnet *  ifp,
u_long  command,
caddr_t  data 
)
static

Definition at line 812 of file if_cdce.c.

References data, error, cdce_softc::sc_media, uether_getsc(), and uether_ioctl().

Referenced by cdce_attach_post_sub().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cdce_m_crc32()

static uint32_t cdce_m_crc32 ( struct mbuf *  m,
uint32_t  src_offset,
uint32_t  src_len 
)
static

Definition at line 974 of file if_cdce.c.

References cdce_m_crc32_cb().

Referenced by cdce_bulk_write_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cdce_m_crc32_cb()

static int32_t cdce_m_crc32_cb ( void *  arg,
void *  src,
uint32_t  count 
)
static

Definition at line 965 of file if_cdce.c.

References count.

Referenced by cdce_m_crc32().

Here is the caller graph for this function:

◆ cdce_media_change_cb()

static int cdce_media_change_cb ( struct ifnet *  ifp)
static

Definition at line 847 of file if_cdce.c.

Referenced by cdce_attach_post_sub().

Here is the caller graph for this function:

◆ cdce_media_status_cb()

static void cdce_media_status_cb ( struct ifnet *  ifp,
struct ifmediareq *  ifmr 
)
static

Definition at line 854 of file if_cdce.c.

Referenced by cdce_attach_post_sub().

Here is the caller graph for this function:

◆ cdce_probe()

static int cdce_probe ( device_t  dev)
static

Definition at line 553 of file if_cdce.c.

References cdce_dual_devs, cdce_host_devs, dev, error, and usbd_lookup_id_by_uaa().

Here is the call graph for this function:

◆ cdce_resume()

static int cdce_resume ( device_t  dev)
static

Definition at line 1079 of file if_cdce.c.

References dev.

◆ cdce_set_filter()

static void cdce_set_filter ( struct usb_ether ue)
static

◆ cdce_setmulti()

static void cdce_setmulti ( struct usb_ether ue)
static

Definition at line 1029 of file if_cdce.c.

References cdce_set_filter().

Here is the call graph for this function:

◆ cdce_setpromisc()

static void cdce_setpromisc ( struct usb_ether ue)
static

Definition at line 1036 of file if_cdce.c.

References cdce_set_filter().

Here is the call graph for this function:

◆ cdce_start()

static void cdce_start ( struct usb_ether ue)
static

Definition at line 800 of file if_cdce.c.

References CDCE_BULK_RX, CDCE_BULK_TX, cdce_softc::sc_xfer, uether_getsc(), and usbd_transfer_start().

Here is the call graph for this function:

◆ cdce_stop()

static void cdce_stop ( struct usb_ether ue)
static

Definition at line 1010 of file if_cdce.c.

References CDCE_BULK_RX, CDCE_BULK_TX, CDCE_INTR_RX, CDCE_INTR_TX, CDCE_LOCK_ASSERT, cdce_softc::sc_xfer, uether_getifp(), uether_getsc(), and usbd_transfer_stop().

Here is the call graph for this function:

◆ cdce_suspend()

static int cdce_suspend ( device_t  dev)
static

Definition at line 1072 of file if_cdce.c.

References dev.

◆ cdce_test_autoinst()

static void cdce_test_autoinst ( void *  arg,
struct usb_device udev,
struct usb_attach_arg uaa 
)
static

Definition at line 511 of file if_cdce.c.

References cdce_switch_devs, usb_attach_arg::dev_state, id, usb_interface::idesc, UAA_DEV_EJECTING, UAA_DEV_READY, UICLASS_MASS, USB_GET_DRIVER_INFO, usb_msc_eject(), usbd_get_iface(), and usbd_lookup_id_by_uaa().

Referenced by cdce_driver_loaded().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DRIVER_MODULE()

DRIVER_MODULE ( cdce  ,
uhub  ,
cdce_driver  ,
cdce_devclass  ,
cdce_driver_loaded  ,
 
)

◆ MODULE_DEPEND() [1/3]

MODULE_DEPEND ( cdce  ,
ether  ,
,
,
 
)

◆ MODULE_DEPEND() [2/3]

MODULE_DEPEND ( cdce  ,
uether  ,
,
,
 
)

◆ MODULE_DEPEND() [3/3]

MODULE_DEPEND ( cdce  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( cdce  ,
 
)

◆ USB_PNP_DEVICE_INFO()

USB_PNP_DEVICE_INFO ( cdce_switch_devs  )

◆ USB_PNP_DUAL_INFO()

USB_PNP_DUAL_INFO ( cdce_dual_devs  )

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( cdce_host_devs  )

Variable Documentation

◆ cdce_attach

device_attach_t cdce_attach
static

Definition at line 92 of file if_cdce.c.

◆ cdce_attach_post

uether_fn_t cdce_attach_post
static

Definition at line 108 of file if_cdce.c.

◆ cdce_bulk_read_callback

usb_callback_t cdce_bulk_read_callback
static

Definition at line 99 of file if_cdce.c.

◆ cdce_bulk_write_callback

usb_callback_t cdce_bulk_write_callback
static

Definition at line 98 of file if_cdce.c.

◆ cdce_config

const struct usb_config cdce_config[CDCE_N_TRANSFER]
static

Definition at line 136 of file if_cdce.c.

Referenced by cdce_attach().

◆ cdce_detach

device_detach_t cdce_detach
static

Definition at line 93 of file if_cdce.c.

Referenced by cdce_attach().

◆ cdce_devclass

devclass_t cdce_devclass
static

Definition at line 262 of file if_cdce.c.

◆ cdce_driver

driver_t cdce_driver
static
Initial value:
= {
.name = "cdce",
.methods = cdce_methods,
.size = sizeof(struct cdce_softc),
}
static device_method_t cdce_methods[]
Definition: if_cdce.c:242

Definition at line 256 of file if_cdce.c.

◆ cdce_dual_devs

const STRUCT_USB_DUAL_ID cdce_dual_devs[]
static
Initial value:
= {
}
#define UISUBCLASS_NETWORK_CONTROL_MODEL
Definition: usb.h:447
#define UICLASS_CDC
Definition: usb.h:434
#define UISUBCLASS_MOBILE_DIRECT_LINE_MODEL
Definition: usb.h:444
#define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL
Definition: usb.h:440
#define USB_IF_CSI(class, subclass, info)
Definition: usbdi.h:394

Definition at line 300 of file if_cdce.c.

Referenced by cdce_probe().

◆ cdce_etag

eventhandler_tag cdce_etag
static

Definition at line 263 of file if_cdce.c.

Referenced by cdce_driver_loaded().

◆ cdce_handle_request

usb_handle_request_t cdce_handle_request
static

Definition at line 96 of file if_cdce.c.

◆ cdce_host_devs

const STRUCT_USB_HOST_ID cdce_host_devs[]
static
Initial value:
= {
{USB_VPI(USB_VENDOR_ACERLABS, USB_PRODUCT_ACERLABS_M5632, CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_AMBIT, USB_PRODUCT_AMBIT_NTL_250, CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_COMPAQ, USB_PRODUCT_COMPAQ_IPAQLINUX, CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_GMATE, USB_PRODUCT_GMATE_YP3X00, CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_MOTOROLA2, USB_PRODUCT_MOTOROLA2_USBLAN, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_MOTOROLA2, USB_PRODUCT_MOTOROLA2_USBLAN2, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2501, CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SL5500, CDCE_FLAG_ZAURUS)},
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SL5600, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLA300, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC700, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC750, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8156, 0)},
{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
}
#define CDCE_FLAG_ZAURUS
Definition: if_cdcereg.h:96
#define CDCE_FLAG_NO_UNION
Definition: if_cdcereg.h:97
#define UICLASS_VENDOR
Definition: usb.h:520
#define USB_IFACE_SUBCLASS(isc)
Definition: usbdi.h:388
#define USB_IFACE_CLASS(ic)
Definition: usbdi.h:385
#define USB_IFACE_PROTOCOL(ip)
Definition: usbdi.h:391
#define USB_VENDOR(vend)
Definition: usbdi.h:358
#define USB_VPI(vend, prod, info)
Definition: usbdi.h:367
#define USB_DRIVER_INFO(n)
Definition: usbdi.h:397

Definition at line 271 of file if_cdce.c.

Referenced by cdce_probe().

◆ cdce_init

uether_fn_t cdce_init
static

Definition at line 109 of file if_cdce.c.

◆ cdce_intr_read_callback

usb_callback_t cdce_intr_read_callback
static

Definition at line 100 of file if_cdce.c.

◆ cdce_intr_write_callback

usb_callback_t cdce_intr_write_callback
static

Definition at line 101 of file if_cdce.c.

◆ cdce_methods

device_method_t cdce_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, cdce_probe),
DEVMETHOD(device_attach, cdce_attach),
DEVMETHOD(device_detach, cdce_detach),
DEVMETHOD(device_suspend, cdce_suspend),
DEVMETHOD(device_resume, cdce_resume),
DEVMETHOD_END
}
static device_suspend_t cdce_suspend
Definition: if_cdce.c:94
static device_probe_t cdce_probe
Definition: if_cdce.c:91
static device_resume_t cdce_resume
Definition: if_cdce.c:95
static usb_handle_request_t cdce_handle_request
Definition: if_cdce.c:96
static device_attach_t cdce_attach
Definition: if_cdce.c:92
static device_detach_t cdce_detach
Definition: if_cdce.c:93
static usb_error_t usb_handle_request(struct usb_xfer *)

Definition at line 242 of file if_cdce.c.

◆ cdce_probe

device_probe_t cdce_probe
static

Definition at line 91 of file if_cdce.c.

◆ cdce_resume

device_resume_t cdce_resume
static

Definition at line 95 of file if_cdce.c.

◆ cdce_setmulti

uether_fn_t cdce_setmulti
static

Definition at line 112 of file if_cdce.c.

◆ cdce_setpromisc

uether_fn_t cdce_setpromisc
static

Definition at line 113 of file if_cdce.c.

◆ cdce_start

uether_fn_t cdce_start
static

Definition at line 111 of file if_cdce.c.

Referenced by cdce_init().

◆ cdce_stop

uether_fn_t cdce_stop
static

Definition at line 110 of file if_cdce.c.

◆ cdce_suspend

device_suspend_t cdce_suspend
static

Definition at line 94 of file if_cdce.c.

◆ cdce_switch_devs

const STRUCT_USB_HOST_ID cdce_switch_devs[]
static
Initial value:
= {
{USB_VPI(USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E3272_INIT, MSC_EJECT_HUAWEI2)},
}
@ MSC_EJECT_HUAWEI2
Definition: usb_msctest.h:38

Definition at line 267 of file if_cdce.c.

Referenced by cdce_test_autoinst().

◆ cdce_ue_methods

const struct usb_ether_methods cdce_ue_methods
static
Initial value:
= {
.ue_attach_post = cdce_attach_post,
.ue_attach_post_sub = cdce_attach_post_sub,
.ue_start = cdce_start,
.ue_init = cdce_init,
.ue_stop = cdce_stop,
.ue_setmulti = cdce_setmulti,
.ue_setpromisc = cdce_setpromisc,
}
static uether_fn_t cdce_setmulti
Definition: if_cdce.c:112
static uether_fn_t cdce_setpromisc
Definition: if_cdce.c:113
static uether_fn_t cdce_start
Definition: if_cdce.c:111
static uether_fn_t cdce_stop
Definition: if_cdce.c:110
static uether_fn_t cdce_attach_post
Definition: if_cdce.c:108
static int cdce_attach_post_sub(struct usb_ether *)
Definition: if_cdce.c:572
static uether_fn_t cdce_init
Definition: if_cdce.c:109

Definition at line 315 of file if_cdce.c.

Referenced by cdce_attach().