1184610Salfred/* $FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.h 334758 2018-06-07 07:33:46Z hselasky $ */ 2184610Salfred/*- 3184610Salfred * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4184610Salfred * 5184610Salfred * Redistribution and use in source and binary forms, with or without 6184610Salfred * modification, are permitted provided that the following conditions 7184610Salfred * are met: 8184610Salfred * 1. Redistributions of source code must retain the above copyright 9184610Salfred * notice, this list of conditions and the following disclaimer. 10184610Salfred * 2. Redistributions in binary form must reproduce the above copyright 11184610Salfred * notice, this list of conditions and the following disclaimer in the 12184610Salfred * documentation and/or other materials provided with the distribution. 13184610Salfred * 14184610Salfred * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15184610Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16184610Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17184610Salfred * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18184610Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19184610Salfred * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20184610Salfred * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21184610Salfred * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22184610Salfred * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23184610Salfred * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24184610Salfred * SUCH DAMAGE. 25184610Salfred * 26184610Salfred * $FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.h 334758 2018-06-07 07:33:46Z hselasky $ 27184610Salfred */ 28184610Salfred 29184610Salfred#ifndef _USB_ETHERNET_H_ 30184610Salfred#define _USB_ETHERNET_H_ 31184610Salfred 32184610Salfred#include "opt_inet.h" 33184610Salfred 34184610Salfred#include <sys/param.h> 35184610Salfred#include <sys/systm.h> 36184610Salfred#include <sys/mbuf.h> 37184610Salfred#include <sys/socket.h> 38184610Salfred#include <sys/sockio.h> 39184610Salfred#include <sys/limits.h> 40184610Salfred 41184610Salfred#include <net/if.h> 42184610Salfred#include <net/if_arp.h> 43184610Salfred#include <net/if_dl.h> 44184610Salfred#include <net/if_media.h> 45184610Salfred#include <net/if_types.h> 46184610Salfred#include <net/bpf.h> 47184610Salfred#include <net/ethernet.h> 48184610Salfred 49184610Salfred#include "miibus_if.h" 50184610Salfred 51184610Salfred#include <dev/mii/mii.h> 52184610Salfred#include <dev/mii/miivar.h> 53184610Salfred 54184610Salfredstruct usb_ether; 55184610Salfredstruct usb_device_request; 56184610Salfred 57184610Salfredtypedef void (uether_fn_t)(struct usb_ether *); 58184610Salfred 59184610Salfredstruct usb_ether_methods { 60184610Salfred uether_fn_t *ue_attach_post; 61184610Salfred uether_fn_t *ue_start; 62184610Salfred uether_fn_t *ue_init; 63184610Salfred uether_fn_t *ue_stop; 64184610Salfred uether_fn_t *ue_setmulti; 65184610Salfred uether_fn_t *ue_setpromisc; 66184610Salfred uether_fn_t *ue_tick; 67184610Salfred int (*ue_mii_upd)(struct ifnet *); 68184610Salfred void (*ue_mii_sts)(struct ifnet *, 69184610Salfred struct ifmediareq *); 70188412Sthompsa int (*ue_ioctl)(struct ifnet *, u_long, caddr_t); 71188412Sthompsa int (*ue_attach_post_sub)(struct usb_ether *); 72184610Salfred}; 73184610Salfred 74184610Salfredstruct usb_ether_cfg_task { 75184610Salfred struct usb_proc_msg hdr; 76184610Salfred struct usb_ether *ue; 77184610Salfred}; 78184610Salfred 79184610Salfredstruct usb_ether { 80184610Salfred /* NOTE: the "ue_ifp" pointer must be first --hps */ 81184610Salfred struct ifnet *ue_ifp; 82184610Salfred struct mtx *ue_mtx; 83184610Salfred const struct usb_ether_methods *ue_methods; 84184610Salfred struct sysctl_oid *ue_sysctl_oid; 85184610Salfred void *ue_sc; 86184610Salfred struct usb_device *ue_udev; /* used by uether_do_request() */ 87184610Salfred device_t ue_dev; 88184610Salfred device_t ue_miibus; 89184610Salfred 90184610Salfred struct usb_process ue_tq; 91184610Salfred struct sysctl_ctx_list ue_sysctl_ctx; 92184610Salfred struct ifqueue ue_rxq; 93184610Salfred struct usb_callout ue_watchdog; 94184610Salfred struct usb_ether_cfg_task ue_sync_task[2]; 95184610Salfred struct usb_ether_cfg_task ue_media_task[2]; 96184610Salfred struct usb_ether_cfg_task ue_multi_task[2]; 97184610Salfred struct usb_ether_cfg_task ue_promisc_task[2]; 98184610Salfred struct usb_ether_cfg_task ue_tick_task[2]; 99184610Salfred 100184610Salfred int ue_unit; 101184610Salfred 102184610Salfred /* ethernet address from eeprom */ 103184610Salfred uint8_t ue_eaddr[ETHER_ADDR_LEN]; 104184610Salfred}; 105184610Salfred 106184610Salfred#define uether_do_request(ue,req,data,timo) \ 107184610Salfred usbd_do_request_proc((ue)->ue_udev,&(ue)->ue_tq,req,data,0,NULL,timo) 108184610Salfred 109184610Salfreduint8_t uether_pause(struct usb_ether *, unsigned int); 110184610Salfredstruct ifnet *uether_getifp(struct usb_ether *); 111184610Salfredstruct mii_data *uether_getmii(struct usb_ether *); 112184610Salfredvoid *uether_getsc(struct usb_ether *); 113184610Salfredint uether_ifattach(struct usb_ether *); 114184610Salfredvoid uether_ifattach_wait(struct usb_ether *); 115184610Salfredvoid uether_ifdetach(struct usb_ether *); 116184610Salfredint uether_ifmedia_upd(struct ifnet *); 117184610Salfredvoid uether_init(void *); 118184610Salfredint uether_ioctl(struct ifnet *, u_long, caddr_t); 119184610Salfredstruct mbuf *uether_newbuf(void); 120187259Sthompsaint uether_rxmbuf(struct usb_ether *, struct mbuf *, 121187259Sthompsa unsigned int); 122187259Sthompsaint uether_rxbuf(struct usb_ether *, 123188412Sthompsa struct usb_page_cache *, 124187259Sthompsa unsigned int, unsigned int); 125184610Salfredvoid uether_rxflush(struct usb_ether *); 126184610Salfreduint8_t uether_is_gone(struct usb_ether *); 127192984Sthompsavoid uether_start(struct ifnet *); 128188412Sthompsa#endif /* _USB_ETHERNET_H_ */ 129188412Sthompsa