]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/usb/net/if_iphethvar.h
Import mandoc 1.14.4
[FreeBSD/FreeBSD.git] / sys / dev / usb / net / if_iphethvar.h
1 /* $FreeBSD$ */
2 /*-
3  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4  *
5  * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
6  * Copyright (c) 2009 Diego Giagio. All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29
30 /*
31  * Thanks to Diego Giagio for figuring out the programming details for
32  * the Apple iPhone Ethernet driver.
33  */
34
35 #ifndef _IF_IPHETHVAR_H_
36 #define _IF_IPHETHVAR_H_
37
38 #define IPHETH_USBINTF_CLASS    255
39 #define IPHETH_USBINTF_SUBCLASS 253
40 #define IPHETH_USBINTF_PROTO    1
41
42 #define IPHETH_BUF_SIZE         1516
43 #define IPHETH_TX_TIMEOUT       5000    /* ms */
44
45 #define IPHETH_RX_FRAMES_MAX    1
46 #define IPHETH_TX_FRAMES_MAX    8
47
48 #define IPHETH_RX_ADJ           2
49
50 #define IPHETH_CFG_INDEX        0
51 #define IPHETH_IF_INDEX         2
52 #define IPHETH_ALT_INTFNUM      1
53
54 #define IPHETH_CTRL_ENDP        0x00
55 #define IPHETH_CTRL_BUF_SIZE    0x40
56 #define IPHETH_CTRL_TIMEOUT     5000    /* ms */
57
58 #define IPHETH_CMD_GET_MACADDR   0x00
59 #define IPHETH_CMD_CARRIER_CHECK 0x45
60
61 #define IPHETH_CARRIER_ON       0x04
62
63 enum {
64         IPHETH_BULK_TX,
65         IPHETH_BULK_RX,
66         IPHETH_N_TRANSFER,
67 };
68
69 struct ipheth_softc {
70         struct usb_ether sc_ue;
71         struct mtx sc_mtx;
72
73         struct usb_xfer *sc_xfer[IPHETH_N_TRANSFER];
74         struct mbuf *sc_rx_buf[IPHETH_RX_FRAMES_MAX];
75         struct mbuf *sc_tx_buf[IPHETH_TX_FRAMES_MAX];
76
77         uint8_t sc_data[IPHETH_CTRL_BUF_SIZE];
78         uint8_t sc_iface_no;
79         uint8_t sc_carrier_on;
80 };
81
82 #define IPHETH_LOCK(_sc)                        mtx_lock(&(_sc)->sc_mtx)
83 #define IPHETH_UNLOCK(_sc)              mtx_unlock(&(_sc)->sc_mtx)
84 #define IPHETH_LOCK_ASSERT(_sc, t)      mtx_assert(&(_sc)->sc_mtx, t)
85
86 #endif                                  /* _IF_IPHETHVAR_H_ */