1/*	$OpenBSD: if_smscreg.h,v 1.2 2012/09/27 12:38:11 jsg Exp $	*/
2/*-
3 * Copyright (c) 2012
4 *	Ben Gray <bgray@freebsd.org>.
5 * 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 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 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: src/sys/dev/usb/net/if_smscreg.h,v 1.1 2012/08/15 04:03:55 gonzo Exp $
29 */
30#ifndef _IF_SMSCVAR_H_
31#define _IF_SMSCVAR_H_
32
33struct smsc_chain {
34	struct smsc_softc	*sc_sc;
35	usbd_xfer_handle	 sc_xfer;
36	char			*sc_buf;
37	struct mbuf		*sc_mbuf;
38	int			 sc_accum;
39	int			 sc_idx;
40};
41
42struct smsc_cdata {
43	struct smsc_chain	 tx_chain[SMSC_TX_LIST_CNT];
44	struct smsc_chain	 rx_chain[SMSC_RX_LIST_CNT];
45	int			 tx_prod;
46	int			 tx_cons;
47	int			 tx_cnt;
48	int			 rx_prod;
49};
50
51struct smsc_softc {
52	device_t		sc_dev;
53	usbd_device_handle	sc_udev;
54	bool			sc_dying;
55
56	uint8_t			sc_enaddr[ETHER_ADDR_LEN];
57	struct ethercom		sc_ec;
58	struct mii_data		sc_mii;
59	krndsource_t		sc_rnd_source;
60	int			sc_phyno;
61	usbd_interface_handle	sc_iface;
62
63	/*
64	 * The following stores the settings in the mac control (MAC_CSR)
65	 * register
66	 */
67	uint32_t		sc_mac_csr;
68	uint32_t		sc_rev_id;
69
70	int			sc_if_flags;
71	int			sc_refcnt;
72
73	struct usb_task		sc_tick_task;
74	struct usb_task		sc_stop_task;
75
76	int			sc_ed[SMSC_ENDPT_MAX];
77	usbd_pipe_handle	sc_ep[SMSC_ENDPT_MAX];
78
79	kmutex_t		sc_mii_lock;
80
81	struct smsc_cdata	sc_cdata;
82	callout_t		sc_stat_ch;
83
84	struct timeval		sc_rx_notice;
85	u_int			sc_bufsz;
86
87	uint32_t		sc_flags;
88#define	SMSC_FLAG_LINK      0x0001
89};
90
91#define SMSC_MIN_BUFSZ		2048
92#define SMSC_MAX_BUFSZ		18944
93
94#endif  /* _IF_SMSCVAR_H_ */
95