37#include <sys/stdint.h>
38#include <sys/stddef.h>
43#include <sys/kernel.h>
45#include <sys/module.h>
48#include <sys/condvar.h>
49#include <sys/socket.h>
50#include <sys/sysctl.h>
52#include <sys/unistd.h>
53#include <sys/callout.h>
54#include <sys/malloc.h>
58#include <net/if_var.h>
65#define USB_DEBUG_VAR ipheth_debug
88static int ipheth_debug = 0;
90static SYSCTL_NODE(_hw_usb, OID_AUTO, ipheth, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
91 "USB iPhone ethernet");
92SYSCTL_INT(_hw_usb_ipheth, OID_AUTO,
debug, CTLFLAG_RWTUN, &ipheth_debug, 0,
"Debug level");
138 {
IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE,
141 {
IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_3G,
144 {
IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_3GS,
147 {
IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_4,
150 {
IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_4S,
153 {
IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_5,
182#define IPHETH_ID(v,p,c,sc,pt) \
183 USB_VENDOR(v), USB_PRODUCT(p), \
184 USB_IFACE_CLASS(c), USB_IFACE_SUBCLASS(sc), \
185 USB_IFACE_PROTOCOL(pt)
199 req.wLength[0] = ETHER_ADDR_LEN;
235 mtx_init(&sc->
sc_mtx, device_get_nameunit(
dev), NULL, MTX_DEF);
240 device_printf(
dev,
"Cannot set alternate setting\n");
246 device_printf(
dev,
"Cannot setup USB transfers\n");
257 device_printf(
dev,
"Cannot get MAC address\n");
263 device_printf(
dev,
"could not attach interface\n");
352 ifp->if_drv_flags |= IFF_DRV_RUNNING;
378 for (x = 0; x !=
n; x++) {
379 if (ppm[x] != NULL) {
403 DPRINTFN(11,
"transfer complete: %u bytes in %u frames\n",
406 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
415 IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
453 DPRINTFN(11,
"transfer error, %s\n",
460 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
486 DPRINTF(
"received %u bytes in %u frames\n", actlen, aframes);
488 for (x = 0; x != aframes; x++) {
493 if (
len < (
int)(
sizeof(
struct ether_header) +
515 m_adj(m, ETHER_ALIGN);
static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB DWC OTG")
SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, phy_type, CTLFLAG_RDTUN, &dwc_otg_phy_type, 0, "DWC OTG PHY TYPE - 0/1/2/3 - ULPI/HSIC/INTERNAL/UTMI+")
static device_probe_t ipheth_probe
static int ipheth_get_mac_addr(struct ipheth_softc *sc)
MODULE_VERSION(ipheth, 1)
static const struct usb_ether_methods ipheth_ue_methods
static device_method_t ipheth_methods[]
static uether_fn_t ipheth_init
static uether_fn_t ipheth_start
static const STRUCT_USB_HOST_ID ipheth_devs[]
static device_attach_t ipheth_attach
static usb_callback_t ipheth_bulk_write_callback
USB_PNP_HOST_INFO(ipheth_devs)
static device_detach_t ipheth_detach
static driver_t ipheth_driver
static uether_fn_t ipheth_attach_post
static uether_fn_t ipheth_tick
static uether_fn_t ipheth_setmulti
static const struct usb_config ipheth_config[IPHETH_N_TRANSFER]
MODULE_DEPEND(ipheth, uether, 1, 1, 1)
DRIVER_MODULE(ipheth, uhub, ipheth_driver, ipheth_devclass, NULL, 0)
static uether_fn_t ipheth_setpromisc
static usb_callback_t ipheth_bulk_read_callback
static uether_fn_t ipheth_stop
#define IPHETH_ID(v, p, c, sc, pt)
static void ipheth_free_queue(struct mbuf **ppm, uint8_t n)
static devclass_t ipheth_devclass
#define IPHETH_TX_FRAMES_MAX
#define IPHETH_CMD_GET_MACADDR
#define IPHETH_USBINTF_CLASS
#define IPHETH_TX_TIMEOUT
#define IPHETH_ALT_INTFNUM
#define IPHETH_CMD_CARRIER_CHECK
#define IPHETH_CTRL_BUF_SIZE
#define IPHETH_LOCK_ASSERT(_sc, t)
#define IPHETH_USBINTF_PROTO
#define IPHETH_CTRL_TIMEOUT
#define IPHETH_CARRIER_ON
#define IPHETH_USBINTF_SUBCLASS
#define IPHETH_RX_FRAMES_MAX
struct usb_xfer * sc_xfer[IPHETH_N_TRANSFER]
struct mbuf * sc_rx_buf[IPHETH_RX_FRAMES_MAX]
struct mbuf * sc_tx_buf[IPHETH_TX_FRAMES_MAX]
uint8_t sc_data[IPHETH_CTRL_BUF_SIZE]
enum usb_hc_mode usb_mode
struct usbd_lookup_info info
struct usb_device * device
struct usb_xfer_flags flags
uether_fn_t * ue_attach_post
const struct usb_ether_methods * ue_methods
struct usb_device * ue_udev
uint8_t ue_eaddr[ETHER_ADDR_LEN]
#define UT_READ_VENDOR_DEVICE
void usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset, usb_frlength_t len)
usb_error_t usbd_set_alt_interface_index(struct usb_device *udev, uint8_t iface_index, uint8_t alt_index)
const char * usbd_errstr(usb_error_t err)
void uether_rxflush(struct usb_ether *ue)
struct mbuf * uether_newbuf(void)
void uether_ifdetach(struct usb_ether *ue)
void * uether_getsc(struct usb_ether *ue)
struct ifnet * uether_getifp(struct usb_ether *ue)
int uether_rxmbuf(struct usb_ether *ue, struct mbuf *m, unsigned int len)
int uether_ifattach(struct usb_ether *ue)
#define uether_do_request(ue, req, data, timo)
void() uether_fn_t(struct usb_ether *)
int usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, struct usb_attach_arg *uaa)
void usbd_transfer_submit(struct usb_xfer *xfer)
void usbd_xfer_set_frames(struct usb_xfer *xfer, usb_frcount_t n)
void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex, void *ptr, usb_frlength_t len)
void usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex, usb_frlength_t len)
usb_frlength_t usbd_xfer_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex)
struct usb_page_cache * usbd_xfer_get_frame(struct usb_xfer *xfer, usb_frcount_t frindex)
usb_error_t usbd_transfer_setup(struct usb_device *udev, const uint8_t *ifaces, struct usb_xfer **ppxfer, const struct usb_config *setup_start, uint16_t n_setup, void *priv_sc, struct mtx *xfer_mtx)
void usbd_transfer_start(struct usb_xfer *xfer)
void usbd_xfer_set_frame_offset(struct usb_xfer *xfer, usb_frlength_t offset, usb_frcount_t frindex)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_transfer_stop(struct usb_xfer *xfer)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
void device_set_usb_desc(device_t dev)
#define USB_IFACE_SUBCLASS(isc)
#define USB_IFACE_CLASS(ic)
#define USB_ST_TRANSFERRED
void usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset, struct mbuf *m, usb_size_t src_offset, usb_frlength_t src_len)
#define USB_IFACE_PROTOCOL(ip)
void() usb_callback_t(struct usb_xfer *, usb_error_t)
#define STRUCT_USB_HOST_ID
#define USB_GET_STATE(xfer)
#define usbd_do_request(u, m, r, d)