1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. 5 * Copyright (c) 2009 Diego Giagio. 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 29/* 30 * Thanks to Diego Giagio for figuring out the programming details for 31 * the Apple iPhone Ethernet driver. 32 */ 33 34#ifndef _IF_IPHETHVAR_H_ 35#define _IF_IPHETHVAR_H_ 36 37#define IPHETH_USBINTF_CLASS 255 38#define IPHETH_USBINTF_SUBCLASS 253 39#define IPHETH_USBINTF_PROTO 1 40 41#define IPHETH_BUF_SIZE 1514 42#define IPHETH_TX_TIMEOUT 5000 /* ms */ 43 44#define IPHETH_RX_FRAMES_MAX 1 45#define IPHETH_TX_FRAMES_MAX 8 46 47#define IPHETH_RX_ADJ 2 48 49#define IPHETH_CFG_INDEX 0 50#define IPHETH_IF_INDEX 2 51#define IPHETH_ALT_INTFNUM 1 52 53#define IPHETH_CTRL_ENDP 0x00 54#define IPHETH_CTRL_BUF_SIZE 0x40 55#define IPHETH_CTRL_TIMEOUT 5000 /* ms */ 56 57#define IPHETH_CMD_GET_MACADDR 0x00 58#define IPHETH_CMD_CARRIER_CHECK 0x45 59 60#define IPHETH_CARRIER_ON 0x04 61 62enum { 63 IPHETH_BULK_TX, 64 IPHETH_BULK_RX, 65 IPHETH_N_TRANSFER, 66}; 67 68struct ipheth_softc { 69 struct usb_ether sc_ue; 70 struct mtx sc_mtx; 71 72 struct usb_xfer *sc_xfer[IPHETH_N_TRANSFER]; 73 struct mbuf *sc_rx_buf[IPHETH_RX_FRAMES_MAX]; 74 struct mbuf *sc_tx_buf[IPHETH_TX_FRAMES_MAX]; 75 76 uint8_t sc_data[IPHETH_CTRL_BUF_SIZE]; 77 uint8_t sc_iface_no; 78 uint8_t sc_carrier_on; 79}; 80 81#define IPHETH_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) 82#define IPHETH_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) 83#define IPHETH_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t) 84 85#endif /* _IF_IPHETHVAR_H_ */ 86