FreeBSD kernel usb device Code
|
#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>
Go to the source code of this file.
Data Structures | |
struct | cdceem_softc |
Macros | |
#define | USB_DEBUG_VAR cdceem_debug |
#define | CDCEEM_FRAMES_MAX 1 |
#define | CDCEEM_ECHO_MAX 1024 |
#define | CDCEEM_ECHO_PAYLOAD "ICH DALEKOPIS FALSZUJE GDY PROBY XQV NIE WYTRZYMUJE 1234567890" |
#define | CDCEEM_SC_FLAGS_ECHO_RESPONSE_PENDING 0x1 |
#define | CDCEEM_SC_FLAGS_ECHO_PENDING 0x2 |
#define | CDCEEM_DEBUG(S, X, ...) |
#define | CDCEEM_WARN(S, X, ...) |
#define | CDCEEM_LOCK(X) mtx_lock(&(X)->sc_mtx) |
#define | CDCEEM_UNLOCK(X) mtx_unlock(&(X)->sc_mtx) |
#define | CDCEEM_TYPE_CMD (0x1 << 15) |
#define | CDCEEM_CMD_MASK (0x7 << 11) |
#define | CDCEEM_CMD_ECHO (0x0 << 11) |
#define | CDCEEM_CMD_ECHO_RESPONSE (0x1 << 11) |
#define | CDCEEM_CMD_SUSPEND_HINT (0x2 << 11) |
#define | CDCEEM_CMD_RESPONSE_HINT (0x3 << 11) |
#define | CDCEEM_CMD_RESPONSE_COMPLETE_HINT (0x4 << 11) |
#define | CDCEEM_CMD_TICKLE (0x5 << 11) |
#define | CDCEEM_CMD_RESERVED (0x1 << 14) |
#define | CDCEEM_ECHO_LEN_MASK 0x3ff |
#define | CDCEEM_DATA_CRC (0x1 << 14) |
#define | CDCEEM_DATA_LEN_MASK 0x3fff |
Enumerations | |
enum | { CDCEEM_BULK_RX , CDCEEM_BULK_TX , CDCEEM_N_TRANSFER } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | SYSCTL_NODE (_hw_usb, OID_AUTO, cdceem, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB CDC EEM") |
SYSCTL_INT (_hw_usb_cdceem, OID_AUTO, debug, CTLFLAG_RWTUN, &cdceem_debug, 0, "Debug level") | |
SYSCTL_INT (_hw_usb_cdceem, OID_AUTO, send_echoes, CTLFLAG_RWTUN, &cdceem_send_echoes, 0, "Send an Echo command") | |
SYSCTL_INT (_hw_usb_cdceem, OID_AUTO, send_fake_crc, CTLFLAG_RWTUN, &cdceem_send_fake_crc, 0, "Use 0xdeadbeef instead of CRC") | |
static uint32_t | cdceem_m_crc32 (struct mbuf *, uint32_t, uint32_t) |
DRIVER_MODULE (cdceem, uhub, cdceem_driver, cdceem_devclass, NULL, NULL) | |
MODULE_VERSION (cdceem, 1) | |
MODULE_DEPEND (cdceem, uether, 1, 1, 1) | |
MODULE_DEPEND (cdceem, usb, 1, 1, 1) | |
MODULE_DEPEND (cdceem, ether, 1, 1, 1) | |
USB_PNP_DUAL_INFO (cdceem_dual_devs) | |
static int | cdceem_probe (device_t dev) |
static void | cdceem_attach_post (struct usb_ether *ue) |
static int | cdceem_attach (device_t dev) |
static int | cdceem_detach (device_t dev) |
static void | cdceem_handle_cmd (struct usb_xfer *xfer, uint16_t hdr, int *offp) |
static void | cdceem_handle_data (struct usb_xfer *xfer, uint16_t hdr, int *offp) |
static void | cdceem_bulk_read_callback (struct usb_xfer *xfer, usb_error_t usb_error) |
static void | cdceem_send_echo (struct usb_xfer *xfer, int *offp) |
static void | cdceem_send_echo_response (struct usb_xfer *xfer, int *offp) |
static void | cdceem_send_data (struct usb_xfer *xfer, int *offp) |
static void | cdceem_bulk_write_callback (struct usb_xfer *xfer, usb_error_t usb_error) |
static int32_t | cdceem_m_crc32_cb (void *arg, void *src, uint32_t count) |
static void | cdceem_start (struct usb_ether *ue) |
static void | cdceem_init (struct usb_ether *ue) |
static void | cdceem_stop (struct usb_ether *ue) |
static void | cdceem_setmulti (struct usb_ether *ue) |
static void | cdceem_setpromisc (struct usb_ether *ue) |
static int | cdceem_suspend (device_t dev) |
static int | cdceem_resume (device_t dev) |
Variables | |
static int | cdceem_debug = 1 |
static int | cdceem_send_echoes = 0 |
static int | cdceem_send_fake_crc = 0 |
static device_probe_t | cdceem_probe |
static device_attach_t | cdceem_attach |
static device_detach_t | cdceem_detach |
static device_suspend_t | cdceem_suspend |
static device_resume_t | cdceem_resume |
static usb_callback_t | cdceem_bulk_write_callback |
static usb_callback_t | cdceem_bulk_read_callback |
static uether_fn_t | cdceem_attach_post |
static uether_fn_t | cdceem_init |
static uether_fn_t | cdceem_stop |
static uether_fn_t | cdceem_start |
static uether_fn_t | cdceem_setmulti |
static uether_fn_t | cdceem_setpromisc |
static const struct usb_config | cdceem_config [CDCEEM_N_TRANSFER] |
static device_method_t | cdceem_methods [] |
static driver_t | cdceem_driver |
static devclass_t | cdceem_devclass |
static const STRUCT_USB_DUAL_ID | cdceem_dual_devs [] |
static const struct usb_ether_methods | cdceem_ue_methods |
#define CDCEEM_CMD_ECHO (0x0 << 11) |
Definition at line 140 of file if_cdceem.c.
#define CDCEEM_CMD_ECHO_RESPONSE (0x1 << 11) |
Definition at line 141 of file if_cdceem.c.
#define CDCEEM_CMD_MASK (0x7 << 11) |
Definition at line 138 of file if_cdceem.c.
#define CDCEEM_CMD_RESERVED (0x1 << 14) |
Definition at line 147 of file if_cdceem.c.
#define CDCEEM_CMD_RESPONSE_COMPLETE_HINT (0x4 << 11) |
Definition at line 144 of file if_cdceem.c.
#define CDCEEM_CMD_RESPONSE_HINT (0x3 << 11) |
Definition at line 143 of file if_cdceem.c.
#define CDCEEM_CMD_SUSPEND_HINT (0x2 << 11) |
Definition at line 142 of file if_cdceem.c.
#define CDCEEM_CMD_TICKLE (0x5 << 11) |
Definition at line 145 of file if_cdceem.c.
#define CDCEEM_DATA_CRC (0x1 << 14) |
Definition at line 151 of file if_cdceem.c.
#define CDCEEM_DATA_LEN_MASK 0x3fff |
Definition at line 152 of file if_cdceem.c.
#define CDCEEM_DEBUG | ( | S, | |
X, | |||
... | |||
) |
Definition at line 116 of file if_cdceem.c.
#define CDCEEM_ECHO_LEN_MASK 0x3ff |
Definition at line 149 of file if_cdceem.c.
#define CDCEEM_ECHO_MAX 1024 |
Definition at line 81 of file if_cdceem.c.
#define CDCEEM_ECHO_PAYLOAD "ICH DALEKOPIS FALSZUJE GDY PROBY XQV NIE WYTRZYMUJE 1234567890" |
Definition at line 83 of file if_cdceem.c.
#define CDCEEM_FRAMES_MAX 1 |
Definition at line 80 of file if_cdceem.c.
Definition at line 133 of file if_cdceem.c.
#define CDCEEM_SC_FLAGS_ECHO_PENDING 0x2 |
Definition at line 102 of file if_cdceem.c.
#define CDCEEM_SC_FLAGS_ECHO_RESPONSE_PENDING 0x1 |
Definition at line 101 of file if_cdceem.c.
#define CDCEEM_TYPE_CMD (0x1 << 15) |
Definition at line 136 of file if_cdceem.c.
Definition at line 134 of file if_cdceem.c.
#define CDCEEM_WARN | ( | S, | |
X, | |||
... | |||
) |
Definition at line 124 of file if_cdceem.c.
#define USB_DEBUG_VAR cdceem_debug |
Definition at line 72 of file if_cdceem.c.
anonymous enum |
Enumerator | |
---|---|
CDCEEM_BULK_RX | |
CDCEEM_BULK_TX | |
CDCEEM_N_TRANSFER |
Definition at line 86 of file if_cdceem.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 258 of file if_cdceem.c.
References cdceem_config, CDCEEM_N_TRANSFER, cdceem_ue_methods, CDCEEM_WARN, dev, usb_attach_arg::device, device_set_usb_desc(), error, cdceem_softc::sc_mtx, cdceem_softc::sc_ue, cdceem_softc::sc_xfer, usb_ether::ue_dev, usb_ether::ue_eaddr, usb_ether::ue_methods, usb_ether::ue_mtx, usb_ether::ue_sc, usb_ether::ue_udev, uether_ifattach(), usbd_transfer_setup(), and usbd_transfer_unsetup().
|
static |
Definition at line 251 of file if_cdceem.c.
|
static |
Definition at line 507 of file if_cdceem.c.
References CDCEEM_DEBUG, cdceem_handle_cmd(), cdceem_handle_data(), CDCEEM_TYPE_CMD, CDCEEM_WARN, cdceem_softc::sc_ue, uether_rxflush(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_out(), usbd_errstr(), usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_max_len(), usbd_xfer_set_frame_len(), usbd_xfer_set_stall(), usbd_xfer_softc(), and usbd_xfer_status().
|
static |
Definition at line 713 of file if_cdceem.c.
References CDCEEM_DEBUG, CDCEEM_SC_FLAGS_ECHO_PENDING, CDCEEM_SC_FLAGS_ECHO_RESPONSE_PENDING, cdceem_send_data(), cdceem_send_echo(), cdceem_send_echo_response(), CDCEEM_WARN, cdceem_softc::sc_flags, cdceem_softc::sc_ue, uether_getifp(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_errstr(), usbd_transfer_submit(), usbd_xfer_max_len(), usbd_xfer_set_frame_len(), usbd_xfer_set_frame_offset(), usbd_xfer_set_stall(), usbd_xfer_softc(), and usbd_xfer_status().
|
static |
Definition at line 308 of file if_cdceem.c.
References CDCEEM_N_TRANSFER, dev, cdceem_softc::sc_mtx, cdceem_softc::sc_ue, cdceem_softc::sc_xfer, uether_ifdetach(), and usbd_transfer_unsetup().
|
static |
Definition at line 322 of file if_cdceem.c.
References CDCEEM_CMD_ECHO, CDCEEM_CMD_ECHO_RESPONSE, CDCEEM_CMD_MASK, CDCEEM_CMD_RESERVED, CDCEEM_CMD_RESPONSE_COMPLETE_HINT, CDCEEM_CMD_RESPONSE_HINT, CDCEEM_CMD_SUSPEND_HINT, CDCEEM_CMD_TICKLE, CDCEEM_DEBUG, CDCEEM_ECHO_LEN_MASK, CDCEEM_ECHO_PAYLOAD, CDCEEM_SC_FLAGS_ECHO_RESPONSE_PENDING, CDCEEM_WARN, cdceem_softc::sc_echo_buffer, cdceem_softc::sc_echo_len, cdceem_softc::sc_flags, usbd_copy_out(), usbd_xfer_get_frame(), usbd_xfer_softc(), and usbd_xfer_status().
Referenced by cdceem_bulk_read_callback().
|
static |
Definition at line 423 of file if_cdceem.c.
References CDCEEM_DATA_CRC, CDCEEM_DATA_LEN_MASK, CDCEEM_DEBUG, cdceem_m_crc32(), CDCEEM_WARN, cdceem_softc::sc_ue, uether_getifp(), uether_newbuf(), uether_rxmbuf(), usbd_copy_out(), usbd_xfer_get_frame(), usbd_xfer_softc(), and usbd_xfer_status().
Referenced by cdceem_bulk_read_callback().
|
static |
Definition at line 806 of file if_cdceem.c.
References CDCEEM_BULK_TX, CDCEEM_SC_FLAGS_ECHO_PENDING, cdceem_send_echoes, cdceem_start, cdceem_softc::sc_flags, cdceem_softc::sc_ue, cdceem_softc::sc_xfer, usb_ether::ue_udev, uether_getifp(), uether_getsc(), USB_MODE_HOST, usbd_get_mode(), and usbd_xfer_set_stall().
|
static |
Definition at line 783 of file if_cdceem.c.
References cdceem_m_crc32_cb().
Referenced by cdceem_handle_data(), and cdceem_send_data().
|
static |
Definition at line 774 of file if_cdceem.c.
References count.
Referenced by cdceem_m_crc32().
|
static |
Definition at line 238 of file if_cdceem.c.
References cdceem_dual_devs, dev, error, and usbd_lookup_id_by_uaa().
|
static |
Definition at line 872 of file if_cdceem.c.
References CDCEEM_DEBUG, and dev.
|
static |
Definition at line 647 of file if_cdceem.c.
References CDCEEM_DATA_CRC, CDCEEM_DATA_LEN_MASK, CDCEEM_DEBUG, cdceem_m_crc32(), cdceem_send_fake_crc, cdceem_softc::sc_ue, uether_getifp(), usbd_copy_in(), usbd_m_copy_in(), usbd_xfer_get_frame(), usbd_xfer_max_len(), and usbd_xfer_softc().
Referenced by cdceem_bulk_write_callback().
|
static |
Definition at line 570 of file if_cdceem.c.
References CDCEEM_CMD_ECHO, CDCEEM_DEBUG, CDCEEM_ECHO_PAYLOAD, CDCEEM_TYPE_CMD, cdceem_softc::sc_flags, usbd_copy_in(), usbd_xfer_get_frame(), usbd_xfer_max_len(), and usbd_xfer_softc().
Referenced by cdceem_bulk_write_callback().
|
static |
Definition at line 609 of file if_cdceem.c.
References CDCEEM_CMD_ECHO_RESPONSE, CDCEEM_DEBUG, CDCEEM_TYPE_CMD, cdceem_softc::sc_echo_buffer, cdceem_softc::sc_echo_len, cdceem_softc::sc_flags, usbd_copy_in(), usbd_xfer_get_frame(), usbd_xfer_max_len(), and usbd_xfer_softc().
Referenced by cdceem_bulk_write_callback().
|
static |
Definition at line 849 of file if_cdceem.c.
|
static |
Definition at line 856 of file if_cdceem.c.
|
static |
Definition at line 792 of file if_cdceem.c.
References CDCEEM_BULK_RX, CDCEEM_BULK_TX, cdceem_softc::sc_xfer, uether_getsc(), and usbd_transfer_start().
|
static |
Definition at line 834 of file if_cdceem.c.
References CDCEEM_BULK_RX, CDCEEM_BULK_TX, cdceem_softc::sc_xfer, uether_getifp(), uether_getsc(), and usbd_transfer_stop().
|
static |
Definition at line 863 of file if_cdceem.c.
References CDCEEM_DEBUG, and dev.
DRIVER_MODULE | ( | cdceem | , |
uhub | , | ||
cdceem_driver | , | ||
cdceem_devclass | , | ||
NULL | , | ||
NULL | |||
) |
MODULE_DEPEND | ( | cdceem | , |
ether | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | cdceem | , |
uether | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | cdceem | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_VERSION | ( | cdceem | , |
1 | |||
) |
SYSCTL_INT | ( | _hw_usb_cdceem | , |
OID_AUTO | , | ||
debug | , | ||
CTLFLAG_RWTUN | , | ||
& | cdceem_debug, | ||
0 | , | ||
"Debug level" | |||
) |
SYSCTL_INT | ( | _hw_usb_cdceem | , |
OID_AUTO | , | ||
send_echoes | , | ||
CTLFLAG_RWTUN | , | ||
& | cdceem_send_echoes, | ||
0 | , | ||
"Send an Echo command" | |||
) |
SYSCTL_INT | ( | _hw_usb_cdceem | , |
OID_AUTO | , | ||
send_fake_crc | , | ||
CTLFLAG_RWTUN | , | ||
& | cdceem_send_fake_crc, | ||
0 | , | ||
"Use 0xdeadbeef instead of CRC" | |||
) |
|
static |
USB_PNP_DUAL_INFO | ( | cdceem_dual_devs | ) |
|
static |
Definition at line 155 of file if_cdceem.c.
|
static |
Definition at line 163 of file if_cdceem.c.
|
static |
Definition at line 161 of file if_cdceem.c.
|
static |
Definition at line 160 of file if_cdceem.c.
|
static |
Definition at line 172 of file if_cdceem.c.
Referenced by cdceem_attach().
|
static |
Definition at line 106 of file if_cdceem.c.
|
static |
Definition at line 156 of file if_cdceem.c.
|
static |
Definition at line 213 of file if_cdceem.c.
|
static |
Definition at line 207 of file if_cdceem.c.
|
static |
|
static |
Definition at line 164 of file if_cdceem.c.
|
static |
Definition at line 196 of file if_cdceem.c.
|
static |
Definition at line 154 of file if_cdceem.c.
|
static |
Definition at line 158 of file if_cdceem.c.
|
static |
Definition at line 109 of file if_cdceem.c.
Referenced by cdceem_init().
|
static |
Definition at line 112 of file if_cdceem.c.
Referenced by cdceem_send_data().
|
static |
Definition at line 167 of file if_cdceem.c.
|
static |
Definition at line 168 of file if_cdceem.c.
|
static |
Definition at line 166 of file if_cdceem.c.
Referenced by cdceem_init().
|
static |
Definition at line 165 of file if_cdceem.c.
|
static |
Definition at line 157 of file if_cdceem.c.
|
static |
Definition at line 228 of file if_cdceem.c.
Referenced by cdceem_attach().