xref: /openbsd/sys/arch/octeon/dev/if_cnmacvar.h (revision 52334306)
1 /*	$OpenBSD: if_cnmacvar.h,v 1.20 2022/12/28 01:39:21 yasuoka 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 AUTHORS 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 AUTHORS 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 #include <sys/kstat.h>
30 #include <sys/mutex.h>
31 
32 #include "kstat.h"
33 
34 #define IS_MAC_MULTICASTBIT(addr) \
35         ((addr)[0] & 0x01)
36 
37 #define SEND_QUEUE_SIZE		(32)
38 #define GATHER_QUEUE_SIZE	(1024)
39 #define FREE_QUEUE_SIZE		GATHER_QUEUE_SIZE
40 #define RECV_QUEUE_SIZE		(GATHER_QUEUE_SIZE * 2)
41 
42 #define CNMAC_MAX_MTU		12288
43 
44 /* Number of mbufs per port to keep in the packet pool */
45 #define CNMAC_MBUFS_PER_PORT	256
46 
47 struct _send_queue_entry;
48 struct cn30xxpow_softc;
49 struct cn30xxpip_softc;
50 struct cn30xxipd_softc;
51 struct cn30xxpko_softc;
52 struct cn30xxasx_softc;
53 struct cn30xxsmi_softc;
54 struct cn30xxgmx_port_softc;
55 struct cn30xxpow_softc;
56 
57 extern struct cn30xxpow_softc	cn30xxpow_softc;
58 
59 struct cnmac_softc {
60 	struct device		sc_dev;
61 	bus_space_tag_t		sc_regt;
62 	bus_dma_tag_t		sc_dmat;
63 
64 	bus_dmamap_t		sc_dmap;
65 
66 	void			*sc_ih;
67 	struct cn30xxpip_softc	*sc_pip;
68 	struct cn30xxipd_softc	*sc_ipd;
69 	struct cn30xxpko_softc	*sc_pko;
70 	struct cn30xxsmi_softc	*sc_smi;
71 	struct cn30xxgmx_softc	*sc_gmx;
72 	struct cn30xxgmx_port_softc
73 				*sc_gmx_port;
74 	struct cn30xxpow_softc
75 				*sc_pow;
76 
77 	struct arpcom		sc_arpcom;
78 	struct mii_data		sc_mii;
79 
80 	struct timeout		sc_tick_misc_ch;
81 	struct timeout		sc_tick_free_ch;
82 
83 	struct task		sc_free_task;
84 
85 	int64_t			sc_soft_req_thresh;
86 	int64_t			sc_hard_done_cnt;
87 	int			sc_prefetch;
88 	struct mbuf_list	sc_sendq;
89 	uint64_t		sc_ext_callback_cnt;
90 
91 	uint32_t		sc_port;
92 	uint32_t		sc_port_type;
93 	uint32_t		sc_init_flag;
94 	int			sc_phy_addr;
95 	int			sc_powgroup;
96 
97 	/*
98 	 * Redirection - received (input) packets are redirected (directly sent)
99 	 * to another port.  Only meant to test hardware + driver performance.
100 	 *
101 	 *  0	- disabled
102 	 * >0	- redirected to ports that correspond to bits
103 	 *		0b001 (0x1)	- Port 0
104 	 *		0b010 (0x2)	- Port 1
105 	 *		0b100 (0x4)	- Port 2
106 	 */
107 	int			sc_redir;
108 
109 	struct cn30xxfau_desc	sc_fau_done;
110 	struct cn30xxpko_cmdptr_desc
111 				sc_cmdptr;
112 
113 	size_t			sc_ip_offset;
114 
115 	struct timeval		sc_rxerr_log_last;
116 
117 	struct mutex		sc_kstat_mtx;
118 	struct kstat		*sc_kstat;
119 };
120