FreeBSD kernel usb device Code
usb_ethernet.h
Go to the documentation of this file.
1/* $FreeBSD$ */
2/*-
3 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 *
5 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD$
29 */
30
31#ifndef _USB_ETHERNET_H_
32#define _USB_ETHERNET_H_
33
34#include "opt_inet.h"
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/mbuf.h>
39#include <sys/socket.h>
40#include <sys/sockio.h>
41#include <sys/limits.h>
42
43#include <net/if.h>
44#include <net/if_arp.h>
45#include <net/if_dl.h>
46#include <net/if_media.h>
47#include <net/if_types.h>
48#include <net/bpf.h>
49#include <net/ethernet.h>
50
51struct mii_data;
52struct usb_ether;
54
55typedef void (uether_fn_t)(struct usb_ether *);
56
65 int (*ue_mii_upd)(struct ifnet *);
66 void (*ue_mii_sts)(struct ifnet *,
67 struct ifmediareq *);
68 int (*ue_ioctl)(struct ifnet *, u_long, caddr_t);
69 int (*ue_attach_post_sub)(struct usb_ether *);
70};
71
74 struct usb_ether *ue;
75};
76
77struct usb_ether {
78 /* NOTE: the "ue_ifp" pointer must be first --hps */
79 struct ifnet *ue_ifp;
80 struct mtx *ue_mtx;
82 struct sysctl_oid *ue_sysctl_oid;
83 void *ue_sc;
84 struct usb_device *ue_udev; /* used by uether_do_request() */
85 device_t ue_dev;
86 device_t ue_miibus;
87
89 struct sysctl_ctx_list ue_sysctl_ctx;
90 struct mbufq ue_rxq;
97
99
100 /* ethernet address from eeprom */
101 uint8_t ue_eaddr[ETHER_ADDR_LEN];
102};
103
104#define uether_do_request(ue,req,data,timo) \
105 usbd_do_request_proc((ue)->ue_udev,&(ue)->ue_tq,req,data,0,NULL,timo)
106
107uint8_t uether_pause(struct usb_ether *, unsigned int);
108struct ifnet *uether_getifp(struct usb_ether *);
109struct mii_data *uether_getmii(struct usb_ether *);
110void *uether_getsc(struct usb_ether *);
111int uether_ifattach(struct usb_ether *);
112void uether_ifattach_wait(struct usb_ether *);
113void uether_ifdetach(struct usb_ether *);
114int uether_ifmedia_upd(struct ifnet *);
115void uether_init(void *);
116int uether_ioctl(struct ifnet *, u_long, caddr_t);
117struct mbuf *uether_newbuf(void);
118int uether_rxmbuf(struct usb_ether *, struct mbuf *,
119 unsigned int);
120int uether_rxbuf(struct usb_ether *,
121 struct usb_page_cache *,
122 unsigned int, unsigned int);
123void uether_rxflush(struct usb_ether *);
124uint8_t uether_is_gone(struct usb_ether *);
125void uether_start(struct ifnet *);
126#endif /* _USB_ETHERNET_H_ */
struct usb_ether * ue
Definition: usb_ethernet.h:74
struct usb_proc_msg hdr
Definition: usb_ethernet.h:73
int(* ue_mii_upd)(struct ifnet *)
Definition: usb_ethernet.h:65
uether_fn_t * ue_setmulti
Definition: usb_ethernet.h:62
int(* ue_attach_post_sub)(struct usb_ether *)
Definition: usb_ethernet.h:69
void(* ue_mii_sts)(struct ifnet *, struct ifmediareq *)
Definition: usb_ethernet.h:66
uether_fn_t * ue_attach_post
Definition: usb_ethernet.h:58
uether_fn_t * ue_init
Definition: usb_ethernet.h:60
int(* ue_ioctl)(struct ifnet *, u_long, caddr_t)
Definition: usb_ethernet.h:68
uether_fn_t * ue_setpromisc
Definition: usb_ethernet.h:63
uether_fn_t * ue_stop
Definition: usb_ethernet.h:61
uether_fn_t * ue_tick
Definition: usb_ethernet.h:64
uether_fn_t * ue_start
Definition: usb_ethernet.h:59
struct usb_callout ue_watchdog
Definition: usb_ethernet.h:91
const struct usb_ether_methods * ue_methods
Definition: usb_ethernet.h:81
struct usb_ether_cfg_task ue_media_task[2]
Definition: usb_ethernet.h:93
struct sysctl_oid * ue_sysctl_oid
Definition: usb_ethernet.h:82
struct usb_ether_cfg_task ue_tick_task[2]
Definition: usb_ethernet.h:96
struct ifnet * ue_ifp
Definition: usb_ethernet.h:79
struct usb_ether_cfg_task ue_promisc_task[2]
Definition: usb_ethernet.h:95
struct usb_device * ue_udev
Definition: usb_ethernet.h:84
struct mbufq ue_rxq
Definition: usb_ethernet.h:90
device_t ue_miibus
Definition: usb_ethernet.h:86
struct sysctl_ctx_list ue_sysctl_ctx
Definition: usb_ethernet.h:89
struct usb_process ue_tq
Definition: usb_ethernet.h:88
uint8_t ue_eaddr[ETHER_ADDR_LEN]
Definition: usb_ethernet.h:101
device_t ue_dev
Definition: usb_ethernet.h:85
struct usb_ether_cfg_task ue_multi_task[2]
Definition: usb_ethernet.h:94
struct usb_ether_cfg_task ue_sync_task[2]
Definition: usb_ethernet.h:92
struct mtx * ue_mtx
Definition: usb_ethernet.h:80
void * ue_sc
Definition: usb_ethernet.h:83
uint8_t uether_pause(struct usb_ether *, unsigned int)
Definition: usb_ethernet.c:94
int uether_ifmedia_upd(struct ifnet *)
Definition: usb_ethernet.c:450
struct mbuf * uether_newbuf(void)
Definition: usb_ethernet.c:584
struct mii_data * uether_getmii(struct usb_ether *)
Definition: usb_ethernet.c:142
int uether_ioctl(struct ifnet *, u_long, caddr_t)
Definition: usb_ethernet.c:513
void uether_start(struct ifnet *)
Definition: usb_ethernet.c:410
void uether_rxflush(struct usb_ether *)
Definition: usb_ethernet.c:646
int uether_rxbuf(struct usb_ether *, struct usb_page_cache *, unsigned int, unsigned int)
Definition: usb_ethernet.c:616
void uether_ifattach_wait(struct usb_ether *)
Definition: usb_ethernet.c:194
uint8_t uether_is_gone(struct usb_ether *)
Definition: usb_ethernet.c:352
void * uether_getsc(struct usb_ether *)
Definition: usb_ethernet.c:148
int uether_rxmbuf(struct usb_ether *, struct mbuf *, unsigned int)
Definition: usb_ethernet.c:598
void uether_ifdetach(struct usb_ether *)
Definition: usb_ethernet.c:302
int uether_ifattach(struct usb_ether *)
Definition: usb_ethernet.c:164
void() uether_fn_t(struct usb_ether *)
Definition: usb_ethernet.h:55
struct ifnet * uether_getifp(struct usb_ether *)
Definition: usb_ethernet.c:136
void uether_init(void *)
Definition: usb_ethernet.c:358