1213805Shselasky/* $FreeBSD: stable/11/sys/dev/usb/net/if_iphethvar.h 368292 2020-12-03 02:22:05Z lwhsu $ */
2213805Shselasky/*-
3213805Shselasky * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
4213805Shselasky * Copyright (c) 2009 Diego Giagio. All rights reserved.
5213805Shselasky *
6213805Shselasky * Redistribution and use in source and binary forms, with or without
7213805Shselasky * modification, are permitted provided that the following conditions
8213805Shselasky * are met:
9213805Shselasky * 1. Redistributions of source code must retain the above copyright
10213805Shselasky *    notice, this list of conditions and the following disclaimer.
11213805Shselasky * 2. Redistributions in binary form must reproduce the above copyright
12213805Shselasky *    notice, this list of conditions and the following disclaimer in the
13213805Shselasky *    documentation and/or other materials provided with the distribution.
14213805Shselasky *
15213805Shselasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16213805Shselasky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17213805Shselasky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18213805Shselasky * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19213805Shselasky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20213805Shselasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21213805Shselasky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22213805Shselasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23213805Shselasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24213805Shselasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25213805Shselasky * SUCH DAMAGE.
26213805Shselasky */
27213805Shselasky
28213805Shselasky/*
29213805Shselasky * Thanks to Diego Giagio for figuring out the programming details for
30213805Shselasky * the Apple iPhone Ethernet driver.
31213805Shselasky */
32213805Shselasky
33213805Shselasky#ifndef _IF_IPHETHVAR_H_
34213805Shselasky#define	_IF_IPHETHVAR_H_
35213805Shselasky
36213805Shselasky#define	IPHETH_USBINTF_CLASS    255
37213805Shselasky#define	IPHETH_USBINTF_SUBCLASS 253
38213805Shselasky#define	IPHETH_USBINTF_PROTO    1
39213805Shselasky
40368292Slwhsu#define	IPHETH_BUF_SIZE         1514
41213805Shselasky#define	IPHETH_TX_TIMEOUT       5000	/* ms */
42213805Shselasky
43213805Shselasky#define	IPHETH_RX_FRAMES_MAX	1
44213805Shselasky#define	IPHETH_TX_FRAMES_MAX	8
45213805Shselasky
46213805Shselasky#define	IPHETH_RX_ADJ		2
47213805Shselasky
48213805Shselasky#define	IPHETH_CFG_INDEX	0
49213805Shselasky#define	IPHETH_IF_INDEX		2
50213805Shselasky#define	IPHETH_ALT_INTFNUM      1
51213805Shselasky
52213805Shselasky#define	IPHETH_CTRL_ENDP        0x00
53213805Shselasky#define	IPHETH_CTRL_BUF_SIZE    0x40
54213805Shselasky#define	IPHETH_CTRL_TIMEOUT     5000	/* ms */
55213805Shselasky
56213805Shselasky#define	IPHETH_CMD_GET_MACADDR   0x00
57213805Shselasky#define	IPHETH_CMD_CARRIER_CHECK 0x45
58213805Shselasky
59213805Shselasky#define	IPHETH_CARRIER_ON       0x04
60213805Shselasky
61213805Shselaskyenum {
62213805Shselasky	IPHETH_BULK_TX,
63213805Shselasky	IPHETH_BULK_RX,
64213805Shselasky	IPHETH_N_TRANSFER,
65213805Shselasky};
66213805Shselasky
67213805Shselaskystruct ipheth_softc {
68213805Shselasky	struct usb_ether sc_ue;
69213805Shselasky	struct mtx sc_mtx;
70213805Shselasky
71213805Shselasky	struct usb_xfer *sc_xfer[IPHETH_N_TRANSFER];
72213805Shselasky	struct mbuf *sc_rx_buf[IPHETH_RX_FRAMES_MAX];
73213805Shselasky	struct mbuf *sc_tx_buf[IPHETH_TX_FRAMES_MAX];
74213805Shselasky
75213805Shselasky	uint8_t	sc_data[IPHETH_CTRL_BUF_SIZE];
76213805Shselasky	uint8_t	sc_iface_no;
77213805Shselasky	uint8_t	sc_carrier_on;
78213805Shselasky};
79213805Shselasky
80213805Shselasky#define	IPHETH_LOCK(_sc)			mtx_lock(&(_sc)->sc_mtx)
81213805Shselasky#define	IPHETH_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
82213805Shselasky#define	IPHETH_LOCK_ASSERT(_sc, t)	mtx_assert(&(_sc)->sc_mtx, t)
83213805Shselasky
84213805Shselasky#endif					/* _IF_IPHETHVAR_H_ */
85