FreeBSD kernel usb device Code
if_ipheth.c File Reference
#include <sys/cdefs.h>
#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/socket.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 "usbdevs.h"
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_iphethvar.h>
Include dependency graph for if_ipheth.c:

Go to the source code of this file.

Macros

#define USB_DEBUG_VAR   ipheth_debug
 
#define IPHETH_ID(v, p, c, sc, pt)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 DRIVER_MODULE (ipheth, uhub, ipheth_driver, ipheth_devclass, NULL, 0)
 
 MODULE_VERSION (ipheth, 1)
 
 MODULE_DEPEND (ipheth, uether, 1, 1, 1)
 
 MODULE_DEPEND (ipheth, usb, 1, 1, 1)
 
 MODULE_DEPEND (ipheth, ether, 1, 1, 1)
 
 USB_PNP_HOST_INFO (ipheth_devs)
 
static int ipheth_get_mac_addr (struct ipheth_softc *sc)
 
static int ipheth_probe (device_t dev)
 
static int ipheth_attach (device_t dev)
 
static int ipheth_detach (device_t dev)
 
static void ipheth_start (struct usb_ether *ue)
 
static void ipheth_stop (struct usb_ether *ue)
 
static void ipheth_tick (struct usb_ether *ue)
 
static void ipheth_attach_post (struct usb_ether *ue)
 
static void ipheth_init (struct usb_ether *ue)
 
static void ipheth_setmulti (struct usb_ether *ue)
 
static void ipheth_setpromisc (struct usb_ether *ue)
 
static void ipheth_free_queue (struct mbuf **ppm, uint8_t n)
 
static void ipheth_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void ipheth_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error)
 

Variables

static device_probe_t ipheth_probe
 
static device_attach_t ipheth_attach
 
static device_detach_t ipheth_detach
 
static usb_callback_t ipheth_bulk_write_callback
 
static usb_callback_t ipheth_bulk_read_callback
 
static uether_fn_t ipheth_attach_post
 
static uether_fn_t ipheth_tick
 
static uether_fn_t ipheth_init
 
static uether_fn_t ipheth_stop
 
static uether_fn_t ipheth_start
 
static uether_fn_t ipheth_setmulti
 
static uether_fn_t ipheth_setpromisc
 
static const struct usb_config ipheth_config [IPHETH_N_TRANSFER]
 
static device_method_t ipheth_methods []
 
static driver_t ipheth_driver
 
static devclass_t ipheth_devclass
 
static const STRUCT_USB_HOST_ID ipheth_devs []
 
static const struct usb_ether_methods ipheth_ue_methods
 

Macro Definition Documentation

◆ IPHETH_ID

#define IPHETH_ID (   v,
  p,
  c,
  sc,
  pt 
)
Value:
USB_IFACE_CLASS(c), USB_IFACE_SUBCLASS(sc), \
USB_IFACE_PROTOCOL(pt)
#define USB_IFACE_SUBCLASS(isc)
Definition: usbdi.h:388
#define USB_PRODUCT(prod)
Definition: usbdi.h:361
#define USB_VENDOR(vend)
Definition: usbdi.h:358

Definition at line 182 of file if_ipheth.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   ipheth_debug

Definition at line 65 of file if_ipheth.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( ipheth  ,
uhub  ,
ipheth_driver  ,
ipheth_devclass  ,
NULL  ,
 
)

◆ ipheth_attach()

◆ ipheth_attach_post()

static void ipheth_attach_post ( struct usb_ether ue)
static

Definition at line 339 of file if_ipheth.c.

◆ ipheth_bulk_read_callback()

◆ ipheth_bulk_write_callback()

◆ ipheth_detach()

static int ipheth_detach ( device_t  dev)
static

Definition at line 274 of file if_ipheth.c.

References dev, IPHETH_N_TRANSFER, ipheth_softc::sc_mtx, ipheth_softc::sc_ue, ipheth_softc::sc_xfer, uether_ifdetach(), and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ ipheth_free_queue()

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

Definition at line 374 of file if_ipheth.c.

References n.

Referenced by ipheth_bulk_read_callback(), and ipheth_bulk_write_callback().

Here is the caller graph for this function:

◆ ipheth_get_mac_addr()

static int ipheth_get_mac_addr ( struct ipheth_softc sc)
static

◆ ipheth_init()

static void ipheth_init ( struct usb_ether ue)
static

Definition at line 345 of file if_ipheth.c.

References IPHETH_BULK_TX, IPHETH_LOCK_ASSERT, ipheth_start, ipheth_softc::sc_xfer, uether_getifp(), uether_getsc(), and usbd_xfer_set_stall().

Here is the call graph for this function:

◆ ipheth_probe()

static int ipheth_probe ( device_t  dev)
static

Definition at line 213 of file if_ipheth.c.

References dev, ipheth_devs, usb_attach_arg::usb_mode, USB_MODE_HOST, and usbd_lookup_id_by_uaa().

Here is the call graph for this function:

◆ ipheth_setmulti()

static void ipheth_setmulti ( struct usb_ether ue)
static

Definition at line 362 of file if_ipheth.c.

◆ ipheth_setpromisc()

static void ipheth_setpromisc ( struct usb_ether ue)
static

Definition at line 368 of file if_ipheth.c.

◆ ipheth_start()

static void ipheth_start ( struct usb_ether ue)
static

Definition at line 290 of file if_ipheth.c.

References IPHETH_BULK_RX, IPHETH_BULK_TX, ipheth_softc::sc_xfer, uether_getsc(), and usbd_transfer_start().

Here is the call graph for this function:

◆ ipheth_stop()

static void ipheth_stop ( struct usb_ether ue)
static

Definition at line 302 of file if_ipheth.c.

References IPHETH_BULK_RX, IPHETH_BULK_TX, ipheth_softc::sc_xfer, uether_getsc(), and usbd_transfer_stop().

Here is the call graph for this function:

◆ ipheth_tick()

static void ipheth_tick ( struct usb_ether ue)
static

◆ MODULE_DEPEND() [1/3]

MODULE_DEPEND ( ipheth  ,
ether  ,
,
,
 
)

◆ MODULE_DEPEND() [2/3]

MODULE_DEPEND ( ipheth  ,
uether  ,
,
,
 
)

◆ MODULE_DEPEND() [3/3]

MODULE_DEPEND ( ipheth  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( ipheth  ,
 
)

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( ipheth_devs  )

Variable Documentation

◆ ipheth_attach

device_attach_t ipheth_attach
static

Definition at line 73 of file if_ipheth.c.

◆ ipheth_attach_post

uether_fn_t ipheth_attach_post
static

Definition at line 79 of file if_ipheth.c.

◆ ipheth_bulk_read_callback

usb_callback_t ipheth_bulk_read_callback
static

Definition at line 77 of file if_ipheth.c.

◆ ipheth_bulk_write_callback

usb_callback_t ipheth_bulk_write_callback
static

Definition at line 76 of file if_ipheth.c.

◆ ipheth_config

const struct usb_config ipheth_config[IPHETH_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_RX,
.bufsize = (IPHETH_RX_FRAMES_MAX * MCLBYTES),
.flags = {.short_frames_ok = 1,.short_xfer_ok = 1,.ext_buffer = 1,},
.timeout = 0,
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_TX,
.flags = {.force_short_xfer = 1,},
.timeout = IPHETH_TX_TIMEOUT,
},
}
static usb_callback_t ipheth_bulk_write_callback
Definition: if_ipheth.c:76
static usb_callback_t ipheth_bulk_read_callback
Definition: if_ipheth.c:77
#define IPHETH_TX_FRAMES_MAX
Definition: if_iphethvar.h:46
#define IPHETH_TX_TIMEOUT
Definition: if_iphethvar.h:43
@ IPHETH_BULK_RX
Definition: if_iphethvar.h:65
@ IPHETH_BULK_TX
Definition: if_iphethvar.h:64
#define IPHETH_BUF_SIZE
Definition: if_iphethvar.h:42
#define IPHETH_RX_FRAMES_MAX
Definition: if_iphethvar.h:45
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_BULK
Definition: usb.h:543
#define UE_DIR_RX
Definition: usb.h:533
#define UE_DIR_TX
Definition: usb.h:534

Definition at line 95 of file if_ipheth.c.

Referenced by ipheth_attach().

◆ ipheth_detach

device_detach_t ipheth_detach
static

Definition at line 74 of file if_ipheth.c.

Referenced by ipheth_attach().

◆ ipheth_devclass

devclass_t ipheth_devclass
static

Definition at line 134 of file if_ipheth.c.

◆ ipheth_devs

const STRUCT_USB_HOST_ID ipheth_devs[]
static
Initial value:
= {
{USB_VENDOR(USB_VENDOR_APPLE),
}
#define IPHETH_USBINTF_CLASS
Definition: if_iphethvar.h:38
#define IPHETH_USBINTF_PROTO
Definition: if_iphethvar.h:40
#define IPHETH_USBINTF_SUBCLASS
Definition: if_iphethvar.h:39
#define USB_IFACE_CLASS(ic)
Definition: usbdi.h:385
#define USB_IFACE_PROTOCOL(ip)
Definition: usbdi.h:391

Definition at line 136 of file if_ipheth.c.

Referenced by ipheth_probe().

◆ ipheth_driver

driver_t ipheth_driver
static
Initial value:
= {
.name = "ipheth",
.methods = ipheth_methods,
.size = sizeof(struct ipheth_softc),
}
static device_method_t ipheth_methods[]
Definition: if_ipheth.c:119

Definition at line 128 of file if_ipheth.c.

◆ ipheth_init

uether_fn_t ipheth_init
static

Definition at line 81 of file if_ipheth.c.

◆ ipheth_methods

device_method_t ipheth_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ipheth_probe),
DEVMETHOD(device_attach, ipheth_attach),
DEVMETHOD(device_detach, ipheth_detach),
DEVMETHOD_END
}
static device_probe_t ipheth_probe
Definition: if_ipheth.c:72
static device_attach_t ipheth_attach
Definition: if_ipheth.c:73
static device_detach_t ipheth_detach
Definition: if_ipheth.c:74

Definition at line 119 of file if_ipheth.c.

◆ ipheth_probe

device_probe_t ipheth_probe
static

Definition at line 72 of file if_ipheth.c.

◆ ipheth_setmulti

uether_fn_t ipheth_setmulti
static

Definition at line 84 of file if_ipheth.c.

◆ ipheth_setpromisc

uether_fn_t ipheth_setpromisc
static

Definition at line 85 of file if_ipheth.c.

◆ ipheth_start

uether_fn_t ipheth_start
static

Definition at line 83 of file if_ipheth.c.

Referenced by ipheth_init().

◆ ipheth_stop

uether_fn_t ipheth_stop
static

Definition at line 82 of file if_ipheth.c.

◆ ipheth_tick

uether_fn_t ipheth_tick
static

Definition at line 80 of file if_ipheth.c.

◆ ipheth_ue_methods

const struct usb_ether_methods ipheth_ue_methods
static
Initial value:
= {
.ue_attach_post = ipheth_attach_post,
.ue_start = ipheth_start,
.ue_init = ipheth_init,
.ue_tick = ipheth_tick,
.ue_stop = ipheth_stop,
.ue_setmulti = ipheth_setmulti,
.ue_setpromisc = ipheth_setpromisc,
}
static uether_fn_t ipheth_init
Definition: if_ipheth.c:81
static uether_fn_t ipheth_start
Definition: if_ipheth.c:83
static uether_fn_t ipheth_attach_post
Definition: if_ipheth.c:79
static uether_fn_t ipheth_tick
Definition: if_ipheth.c:80
static uether_fn_t ipheth_setmulti
Definition: if_ipheth.c:84
static uether_fn_t ipheth_setpromisc
Definition: if_ipheth.c:85
static uether_fn_t ipheth_stop
Definition: if_ipheth.c:82

Definition at line 172 of file if_ipheth.c.

Referenced by ipheth_attach().