xref: /openbsd/sys/arch/octeon/dev/if_cnmacvar.h (revision a6445c1d)
1 /*	$OpenBSD: if_cnmacvar.h,v 1.5 2014/08/11 18:29:56 miod Exp $	*/
2 
3 /*
4  * Copyright (c) 2007 Internet Initiative Japan, Inc.
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 THE REGENTS 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 REGENTS 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 #define IS_MAC_MULTICASTBIT(addr) \
30         ((addr)[0] & 0x01)
31 
32 #define SEND_QUEUE_SIZE		(32)
33 #define GATHER_QUEUE_SIZE	(1024)
34 #define FREE_QUEUE_SIZE		GATHER_QUEUE_SIZE
35 #define RECV_QUEUE_SIZE		(GATHER_QUEUE_SIZE * 2)
36 
37 #ifdef OCTEON_ETH_FIXUP_ODD_NIBBLE_DYNAMIC
38 #define PROC_NIBBLE_SOFT_THRESHOLD 2000
39 #endif
40 
41 struct _send_queue_entry;
42 struct cn30xxpow_softc;
43 struct cn30xxpip_softc;
44 struct cn30xxipd_softc;
45 struct cn30xxpko_softc;
46 struct cn30xxasx_softc;
47 struct cn30xxsmi_softc;
48 struct cn30xxgmx_port_softc;
49 struct cn30xxpow_softc;
50 
51 extern struct cn30xxpow_softc	cn30xxpow_softc;
52 
53 struct octeon_eth_softc {
54 	struct device		sc_dev;
55 	bus_space_tag_t		sc_regt;
56 	bus_dma_tag_t		sc_dmat;
57 
58 	bus_dmamap_t		sc_dmap;
59 
60 	void			*sc_pow_recv_ih;
61 	struct cn30xxpip_softc	*sc_pip;
62 	struct cn30xxipd_softc	*sc_ipd;
63 	struct cn30xxpko_softc	*sc_pko;
64 	struct cn30xxasx_softc	*sc_asx;
65 	struct cn30xxsmi_softc	*sc_smi;
66 	struct cn30xxgmx_softc	*sc_gmx;
67 	struct cn30xxgmx_port_softc
68 				*sc_gmx_port;
69 	struct cn30xxpow_softc
70 				*sc_pow;
71 
72 	struct arpcom		sc_arpcom;
73 	struct mii_data		sc_mii;
74 
75 	struct timeout		sc_tick_misc_ch;
76 	struct timeout		sc_tick_free_ch;
77 	struct timeout		sc_resume_ch;
78 
79 	int64_t			sc_soft_req_cnt;
80 	int64_t			sc_soft_req_thresh;
81 	int64_t			sc_hard_done_cnt;
82 	int			sc_flush;
83 	int			sc_prefetch;
84 	SIMPLEQ_HEAD(, _send_queue_entry)
85 				sc_sendq;
86 	uint64_t		sc_ext_callback_cnt;
87 
88 	uint32_t		sc_port;
89 	uint32_t		sc_port_type;
90 	uint32_t		sc_init_flag;
91 	int			sc_phy_addr;
92 
93 	/*
94 	 * Redirection - received (input) packets are redirected (directly sent)
95 	 * to another port.  Only meant to test hardware + driver performance.
96 	 *
97 	 *  0	- disabled
98 	 * >0	- redirected to ports that correspond to bits
99 	 *		0b001 (0x1)	- Port 0
100 	 *		0b010 (0x2)	- Port 1
101 	 *		0b100 (0x4)	- Port 2
102 	 */
103 	int			sc_redir;
104 
105 	struct cn30xxfau_desc	sc_fau_done;
106 	struct cn30xxpko_cmdptr_desc
107 				sc_cmdptr;
108 
109 	size_t			sc_ip_offset;
110 
111 	struct timeval		sc_rate_recv_check_link_last;
112 	struct timeval		sc_rate_recv_check_link_cap;
113 	struct timeval		sc_rate_recv_check_jumbo_last;
114 	struct timeval		sc_rate_recv_check_jumbo_cap;
115 	struct timeval		sc_rate_recv_check_code_last;
116 	struct timeval		sc_rate_recv_check_code_cap;
117 };
118