xref: /openbsd-src/sys/arch/octeon/dev/if_cnmacvar.h (revision 52334306b2a9705ff71115f6fb78beb8340dd9a4)
1*52334306Syasuoka /*	$OpenBSD: if_cnmacvar.h,v 1.20 2022/12/28 01:39:21 yasuoka Exp $	*/
24a04f2fdSsyuu 
3196eba87Syasuoka /*
4196eba87Syasuoka  * Copyright (c) 2007 Internet Initiative Japan, Inc.
5196eba87Syasuoka  * All rights reserved.
6196eba87Syasuoka  *
7196eba87Syasuoka  * Redistribution and use in source and binary forms, with or without
8196eba87Syasuoka  * modification, are permitted provided that the following conditions
9196eba87Syasuoka  * are met:
10196eba87Syasuoka  * 1. Redistributions of source code must retain the above copyright
11196eba87Syasuoka  *    notice, this list of conditions and the following disclaimer.
12196eba87Syasuoka  * 2. Redistributions in binary form must reproduce the above copyright
13196eba87Syasuoka  *    notice, this list of conditions and the following disclaimer in the
14196eba87Syasuoka  *    documentation and/or other materials provided with the distribution.
15196eba87Syasuoka  *
16*52334306Syasuoka  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17196eba87Syasuoka  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18196eba87Syasuoka  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*52334306Syasuoka  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20196eba87Syasuoka  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21196eba87Syasuoka  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22196eba87Syasuoka  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23196eba87Syasuoka  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24196eba87Syasuoka  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25196eba87Syasuoka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26196eba87Syasuoka  * SUCH DAMAGE.
27196eba87Syasuoka  */
284a04f2fdSsyuu 
296ece48ccSvisa #include <sys/kstat.h>
306ece48ccSvisa #include <sys/mutex.h>
316ece48ccSvisa 
326ece48ccSvisa #include "kstat.h"
336ece48ccSvisa 
344a04f2fdSsyuu #define IS_MAC_MULTICASTBIT(addr) \
354a04f2fdSsyuu         ((addr)[0] & 0x01)
364a04f2fdSsyuu 
374a04f2fdSsyuu #define SEND_QUEUE_SIZE		(32)
384a04f2fdSsyuu #define GATHER_QUEUE_SIZE	(1024)
394a04f2fdSsyuu #define FREE_QUEUE_SIZE		GATHER_QUEUE_SIZE
404a04f2fdSsyuu #define RECV_QUEUE_SIZE		(GATHER_QUEUE_SIZE * 2)
414a04f2fdSsyuu 
421e2bb501Svisa #define CNMAC_MAX_MTU		12288
437e5cda19Svisa 
448d999ab0Svisa /* Number of mbufs per port to keep in the packet pool */
451e2bb501Svisa #define CNMAC_MBUFS_PER_PORT	256
468d999ab0Svisa 
474a04f2fdSsyuu struct _send_queue_entry;
484a04f2fdSsyuu struct cn30xxpow_softc;
494a04f2fdSsyuu struct cn30xxpip_softc;
504a04f2fdSsyuu struct cn30xxipd_softc;
514a04f2fdSsyuu struct cn30xxpko_softc;
524a04f2fdSsyuu struct cn30xxasx_softc;
534a04f2fdSsyuu struct cn30xxsmi_softc;
544a04f2fdSsyuu struct cn30xxgmx_port_softc;
554a04f2fdSsyuu struct cn30xxpow_softc;
564a04f2fdSsyuu 
574a04f2fdSsyuu extern struct cn30xxpow_softc	cn30xxpow_softc;
584a04f2fdSsyuu 
591e2bb501Svisa struct cnmac_softc {
604a04f2fdSsyuu 	struct device		sc_dev;
614a04f2fdSsyuu 	bus_space_tag_t		sc_regt;
624a04f2fdSsyuu 	bus_dma_tag_t		sc_dmat;
634a04f2fdSsyuu 
644a04f2fdSsyuu 	bus_dmamap_t		sc_dmap;
654a04f2fdSsyuu 
66e842824bSvisa 	void			*sc_ih;
674a04f2fdSsyuu 	struct cn30xxpip_softc	*sc_pip;
684a04f2fdSsyuu 	struct cn30xxipd_softc	*sc_ipd;
694a04f2fdSsyuu 	struct cn30xxpko_softc	*sc_pko;
704a04f2fdSsyuu 	struct cn30xxsmi_softc	*sc_smi;
714a04f2fdSsyuu 	struct cn30xxgmx_softc	*sc_gmx;
724a04f2fdSsyuu 	struct cn30xxgmx_port_softc
734a04f2fdSsyuu 				*sc_gmx_port;
744a04f2fdSsyuu 	struct cn30xxpow_softc
754a04f2fdSsyuu 				*sc_pow;
764a04f2fdSsyuu 
774a04f2fdSsyuu 	struct arpcom		sc_arpcom;
784a04f2fdSsyuu 	struct mii_data		sc_mii;
794a04f2fdSsyuu 
804a04f2fdSsyuu 	struct timeout		sc_tick_misc_ch;
814a04f2fdSsyuu 	struct timeout		sc_tick_free_ch;
824a04f2fdSsyuu 
8340af4038Svisa 	struct task		sc_free_task;
8440af4038Svisa 
854a04f2fdSsyuu 	int64_t			sc_soft_req_thresh;
864a04f2fdSsyuu 	int64_t			sc_hard_done_cnt;
874a04f2fdSsyuu 	int			sc_prefetch;
88310b705cSjmatthew 	struct mbuf_list	sc_sendq;
894a04f2fdSsyuu 	uint64_t		sc_ext_callback_cnt;
904a04f2fdSsyuu 
914a04f2fdSsyuu 	uint32_t		sc_port;
924a04f2fdSsyuu 	uint32_t		sc_port_type;
934a04f2fdSsyuu 	uint32_t		sc_init_flag;
948d5465ddSjmatthew 	int			sc_phy_addr;
95e842824bSvisa 	int			sc_powgroup;
964a04f2fdSsyuu 
974a04f2fdSsyuu 	/*
984a04f2fdSsyuu 	 * Redirection - received (input) packets are redirected (directly sent)
994a04f2fdSsyuu 	 * to another port.  Only meant to test hardware + driver performance.
1004a04f2fdSsyuu 	 *
1014a04f2fdSsyuu 	 *  0	- disabled
1024a04f2fdSsyuu 	 * >0	- redirected to ports that correspond to bits
1034a04f2fdSsyuu 	 *		0b001 (0x1)	- Port 0
1044a04f2fdSsyuu 	 *		0b010 (0x2)	- Port 1
1054a04f2fdSsyuu 	 *		0b100 (0x4)	- Port 2
1064a04f2fdSsyuu 	 */
1074a04f2fdSsyuu 	int			sc_redir;
1084a04f2fdSsyuu 
1094a04f2fdSsyuu 	struct cn30xxfau_desc	sc_fau_done;
1104a04f2fdSsyuu 	struct cn30xxpko_cmdptr_desc
1114a04f2fdSsyuu 				sc_cmdptr;
1124a04f2fdSsyuu 
1134a04f2fdSsyuu 	size_t			sc_ip_offset;
1144a04f2fdSsyuu 
1159253bf3fSvisa 	struct timeval		sc_rxerr_log_last;
1166ece48ccSvisa 
1176ece48ccSvisa 	struct mutex		sc_kstat_mtx;
1186ece48ccSvisa 	struct kstat		*sc_kstat;
1194a04f2fdSsyuu };
120