usb_ethernet.h revision 188412
10Sstevel@tonic-gate/* $FreeBSD: head/sys/dev/usb2/ethernet/usb2_ethernet.h 188412 2009-02-09 22:02:38Z thompsa $ */ 20Sstevel@tonic-gate/*- 30Sstevel@tonic-gate * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 40Sstevel@tonic-gate * 50Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 60Sstevel@tonic-gate * modification, are permitted provided that the following conditions 70Sstevel@tonic-gate * are met: 80Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 90Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 100Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 110Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 120Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 150Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 160Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 170Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 180Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 190Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 200Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 210Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 220Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 230Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 240Sstevel@tonic-gate * SUCH DAMAGE. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate#ifndef _USB2_ETHERNET_H_ 280Sstevel@tonic-gate#define _USB2_ETHERNET_H_ 290Sstevel@tonic-gate 300Sstevel@tonic-gate#include "opt_inet.h" 310Sstevel@tonic-gate 320Sstevel@tonic-gate#include <sys/param.h> 330Sstevel@tonic-gate#include <sys/systm.h> 340Sstevel@tonic-gate#include <sys/mbuf.h> 350Sstevel@tonic-gate#include <sys/socket.h> 360Sstevel@tonic-gate#include <sys/sockio.h> 370Sstevel@tonic-gate#include <sys/limits.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate#include <net/if.h> 400Sstevel@tonic-gate#include <net/if_arp.h> 410Sstevel@tonic-gate#include <net/if_dl.h> 420Sstevel@tonic-gate#include <net/if_media.h> 430Sstevel@tonic-gate#include <net/if_types.h> 440Sstevel@tonic-gate#include <net/bpf.h> 450Sstevel@tonic-gate#include <net/ethernet.h> 460Sstevel@tonic-gate 470Sstevel@tonic-gate#include "miibus_if.h" 480Sstevel@tonic-gate 490Sstevel@tonic-gate#include <dev/mii/mii.h> 500Sstevel@tonic-gate#include <dev/mii/miivar.h> 510Sstevel@tonic-gate 520Sstevel@tonic-gatestruct usb2_ether; 530Sstevel@tonic-gatestruct usb2_device_request; 540Sstevel@tonic-gate 550Sstevel@tonic-gatetypedef void (usb2_ether_fn_t)(struct usb2_ether *); 560Sstevel@tonic-gate 570Sstevel@tonic-gatestruct usb2_ether_methods { 580Sstevel@tonic-gate usb2_ether_fn_t *ue_attach_post; 590Sstevel@tonic-gate usb2_ether_fn_t *ue_start; 600Sstevel@tonic-gate usb2_ether_fn_t *ue_init; 610Sstevel@tonic-gate usb2_ether_fn_t *ue_stop; 620Sstevel@tonic-gate usb2_ether_fn_t *ue_setmulti; 630Sstevel@tonic-gate usb2_ether_fn_t *ue_setpromisc; 640Sstevel@tonic-gate usb2_ether_fn_t *ue_tick; 650Sstevel@tonic-gate int (*ue_mii_upd)(struct ifnet *); 660Sstevel@tonic-gate void (*ue_mii_sts)(struct ifnet *, 670Sstevel@tonic-gate struct ifmediareq *); 680Sstevel@tonic-gate int (*ue_ioctl)(struct ifnet *, u_long, caddr_t); 690Sstevel@tonic-gate 700Sstevel@tonic-gate}; 710Sstevel@tonic-gate 720Sstevel@tonic-gatestruct usb2_ether_cfg_task { 730Sstevel@tonic-gate struct usb2_proc_msg hdr; 740Sstevel@tonic-gate struct usb2_ether *ue; 750Sstevel@tonic-gate}; 760Sstevel@tonic-gate 770Sstevel@tonic-gatestruct usb2_ether { 780Sstevel@tonic-gate /* NOTE: the "ue_ifp" pointer must be first --hps */ 790Sstevel@tonic-gate struct ifnet *ue_ifp; 800Sstevel@tonic-gate struct mtx *ue_mtx; 810Sstevel@tonic-gate const struct usb2_ether_methods *ue_methods; 820Sstevel@tonic-gate struct sysctl_oid *ue_sysctl_oid; 830Sstevel@tonic-gate void *ue_sc; 840Sstevel@tonic-gate struct usb2_device *ue_udev; /* used by usb2_ether_do_request() */ 850Sstevel@tonic-gate device_t ue_dev; 860Sstevel@tonic-gate device_t ue_miibus; 870Sstevel@tonic-gate 880Sstevel@tonic-gate struct usb2_process ue_tq; 890Sstevel@tonic-gate struct sysctl_ctx_list ue_sysctl_ctx; 900Sstevel@tonic-gate struct ifqueue ue_rxq; 910Sstevel@tonic-gate struct usb2_callout ue_watchdog; 920Sstevel@tonic-gate struct usb2_ether_cfg_task ue_sync_task[2]; 930Sstevel@tonic-gate struct usb2_ether_cfg_task ue_media_task[2]; 940Sstevel@tonic-gate struct usb2_ether_cfg_task ue_multi_task[2]; 950Sstevel@tonic-gate struct usb2_ether_cfg_task ue_promisc_task[2]; 960Sstevel@tonic-gate struct usb2_ether_cfg_task ue_tick_task[2]; 970Sstevel@tonic-gate 980Sstevel@tonic-gate int ue_unit; 990Sstevel@tonic-gate 1000Sstevel@tonic-gate /* ethernet address from eeprom */ 1010Sstevel@tonic-gate uint8_t ue_eaddr[ETHER_ADDR_LEN]; 1020Sstevel@tonic-gate}; 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate#define usb2_ether_do_request(ue,req,data,timo) \ 1050Sstevel@tonic-gate usb2_do_request_proc((ue)->ue_udev,&(ue)->ue_tq,req,data,0,NULL,timo) 1060Sstevel@tonic-gate 1070Sstevel@tonic-gateuint8_t usb2_ether_pause(struct usb2_ether *, unsigned int); 1080Sstevel@tonic-gatestruct ifnet *usb2_ether_getifp(struct usb2_ether *); 1090Sstevel@tonic-gatestruct mii_data *usb2_ether_getmii(struct usb2_ether *); 1100Sstevel@tonic-gatevoid *usb2_ether_getsc(struct usb2_ether *); 1110Sstevel@tonic-gateint usb2_ether_ifattach(struct usb2_ether *); 1120Sstevel@tonic-gatevoid usb2_ether_ifdetach(struct usb2_ether *); 1130Sstevel@tonic-gateint usb2_ether_ioctl(struct ifnet *, u_long, caddr_t); 1140Sstevel@tonic-gateint usb2_ether_rxmbuf(struct usb2_ether *, struct mbuf *, 1150Sstevel@tonic-gate unsigned int); 1160Sstevel@tonic-gateint usb2_ether_rxbuf(struct usb2_ether *, 1170Sstevel@tonic-gate struct usb2_page_cache *, 1180Sstevel@tonic-gate unsigned int, unsigned int); 1190Sstevel@tonic-gatevoid usb2_ether_rxflush(struct usb2_ether *); 1200Sstevel@tonic-gatevoid usb2_ether_ifshutdown(struct usb2_ether *); 1210Sstevel@tonic-gateuint8_t usb2_ether_is_gone(struct usb2_ether *); 1220Sstevel@tonic-gate#endif /* _USB2_ETHERNET_H_ */ 1230Sstevel@tonic-gate