usb_ethernet.h revision 190633
1139749Simp/* $FreeBSD: head/sys/dev/usb/net/usb_ethernet.h 190633 2009-04-01 20:23:47Z piso $ */ 2158078Smarcel/*- 3158078Smarcel * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4158078Smarcel * 5119815Smarcel * Redistribution and use in source and binary forms, with or without 6119815Smarcel * modification, are permitted provided that the following conditions 7119815Smarcel * are met: 8119815Smarcel * 1. Redistributions of source code must retain the above copyright 9119815Smarcel * notice, this list of conditions and the following disclaimer. 10119815Smarcel * 2. Redistributions in binary form must reproduce the above copyright 11119815Smarcel * notice, this list of conditions and the following disclaimer in the 12119815Smarcel * documentation and/or other materials provided with the distribution. 13119815Smarcel * 14119815Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15119815Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16119815Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17119815Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18119815Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19119815Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20119815Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21119815Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22119815Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23119815Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24119815Smarcel * SUCH DAMAGE. 25119815Smarcel */ 26119815Smarcel 27119815Smarcel#ifndef _USB2_ETHERNET_H_ 28119815Smarcel#define _USB2_ETHERNET_H_ 29119815Smarcel 30119815Smarcel#include "opt_inet.h" 31119815Smarcel 32119815Smarcel#include <sys/param.h> 33119815Smarcel#include <sys/systm.h> 34119815Smarcel#include <sys/mbuf.h> 35119815Smarcel#include <sys/socket.h> 36119815Smarcel#include <sys/sockio.h> 37119815Smarcel#include <sys/limits.h> 38119815Smarcel 39119815Smarcel#include <net/if.h> 40119815Smarcel#include <net/if_arp.h> 41119815Smarcel#include <net/if_dl.h> 42119815Smarcel#include <net/if_media.h> 43119815Smarcel#include <net/if_types.h> 44119815Smarcel#include <net/bpf.h> 45158058Smarcel#include <net/ethernet.h> 46158058Smarcel 47119815Smarcel#include "miibus_if.h" 48119815Smarcel 49119815Smarcel#include <dev/mii/mii.h> 50119815Smarcel#include <dev/mii/miivar.h> 51119815Smarcel 52119815Smarcelstruct usb2_ether; 53119815Smarcelstruct usb2_device_request; 54119815Smarcel 55119815Smarceltypedef void (usb2_ether_fn_t)(struct usb2_ether *); 56119815Smarcel 57119815Smarcelstruct usb2_ether_methods { 58119815Smarcel usb2_ether_fn_t *ue_attach_post; 59119815Smarcel usb2_ether_fn_t *ue_start; 60119815Smarcel usb2_ether_fn_t *ue_init; 61119815Smarcel usb2_ether_fn_t *ue_stop; 62119815Smarcel usb2_ether_fn_t *ue_setmulti; 63119815Smarcel usb2_ether_fn_t *ue_setpromisc; 64158058Smarcel usb2_ether_fn_t *ue_tick; 65158058Smarcel int (*ue_mii_upd)(struct ifnet *); 66158058Smarcel void (*ue_mii_sts)(struct ifnet *, 67158058Smarcel struct ifmediareq *); 68119815Smarcel int (*ue_ioctl)(struct ifnet *, u_long, caddr_t); 69119815Smarcel 70158058Smarcel}; 71119815Smarcel 72119815Smarcelstruct usb2_ether_cfg_task { 73119815Smarcel struct usb2_proc_msg hdr; 74158078Smarcel struct usb2_ether *ue; 75158078Smarcel}; 76158078Smarcel 77158078Smarcelstruct usb2_ether { 78158058Smarcel /* NOTE: the "ue_ifp" pointer must be first --hps */ 79158058Smarcel struct ifnet *ue_ifp; 80158078Smarcel struct mtx *ue_mtx; 81158078Smarcel const struct usb2_ether_methods *ue_methods; 82158078Smarcel struct sysctl_oid *ue_sysctl_oid; 83158058Smarcel void *ue_sc; 84158058Smarcel struct usb2_device *ue_udev; /* used by usb2_ether_do_request() */ 85158058Smarcel device_t ue_dev; 86158058Smarcel device_t ue_miibus; 87158058Smarcel 88158058Smarcel struct usb2_process ue_tq; 89158058Smarcel struct sysctl_ctx_list ue_sysctl_ctx; 90158058Smarcel struct ifqueue ue_rxq; 91158058Smarcel struct usb2_callout ue_watchdog; 92158058Smarcel struct usb2_ether_cfg_task ue_sync_task[2]; 93158058Smarcel struct usb2_ether_cfg_task ue_media_task[2]; 94158078Smarcel struct usb2_ether_cfg_task ue_multi_task[2]; 95158078Smarcel struct usb2_ether_cfg_task ue_promisc_task[2]; 96158058Smarcel struct usb2_ether_cfg_task ue_tick_task[2]; 97158058Smarcel 98158078Smarcel int ue_unit; 99158078Smarcel 100158078Smarcel /* ethernet address from eeprom */ 101158078Smarcel uint8_t ue_eaddr[ETHER_ADDR_LEN]; 102158078Smarcel}; 103158078Smarcel 104158078Smarcel#define usb2_ether_do_request(ue,req,data,timo) \ 105158078Smarcel usb2_do_request_proc((ue)->ue_udev,&(ue)->ue_tq,req,data,0,NULL,timo) 106158078Smarcel 107158078Smarceluint8_t usb2_ether_pause(struct usb2_ether *, unsigned int); 108158078Smarcelstruct ifnet *usb2_ether_getifp(struct usb2_ether *); 109158078Smarcelstruct mii_data *usb2_ether_getmii(struct usb2_ether *); 110158078Smarcelvoid *usb2_ether_getsc(struct usb2_ether *); 111158058Smarcelint usb2_ether_ifattach(struct usb2_ether *); 112158058Smarcelvoid usb2_ether_ifdetach(struct usb2_ether *); 113119815Smarcelint usb2_ether_ioctl(struct ifnet *, u_long, caddr_t); 114119815Smarcelstruct mbuf *usb2_ether_newbuf(void); 115119815Smarcelint usb2_ether_rxmbuf(struct usb2_ether *, struct mbuf *, 116158058Smarcel unsigned int); 117119815Smarcelint usb2_ether_rxbuf(struct usb2_ether *, 118158058Smarcel struct usb2_page_cache *, 119119815Smarcel unsigned int, unsigned int); 120158058Smarcelvoid usb2_ether_rxflush(struct usb2_ether *); 121158058Smarcelvoid usb2_ether_ifshutdown(struct usb2_ether *); 122158058Smarceluint8_t usb2_ether_is_gone(struct usb2_ether *); 123158058Smarcel#endif /* _USB2_ETHERNET_H_ */ 124119815Smarcel