]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/mips/nlm/dev/net/xlpge.h
Import tzdata 2018c
[FreeBSD/FreeBSD.git] / sys / mips / nlm / dev / net / xlpge.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2003-2012 Broadcom Corporation
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  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
25  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * $FreeBSD$
31  */
32
33 #ifndef __XLPGE_H__
34 #define __XLPGE_H__
35
36 #define NLM_XLPGE_TXQ_SIZE      1024
37 #define MAC_CRC_LEN             4
38
39 enum xlpge_link_state {
40         NLM_LINK_DOWN,
41         NLM_LINK_UP
42 };
43
44 enum xlpge_floctrl_status {
45         NLM_FLOWCTRL_DISABLED,
46         NLM_FLOWCTRL_ENABLED
47 };
48
49 struct nlm_xlp_portdata {
50         struct ifnet *xlpge_if;
51         struct nlm_xlpge_softc *xlpge_sc;
52 };
53
54 struct nlm_xlpnae_softc {
55         device_t        xlpnae_dev;
56         int             node;           /* XLP Node id */
57         uint64_t        base;           /* NAE IO base */
58         uint64_t        poe_base;       /* POE IO base */
59         uint64_t        poedv_base;     /* POE distribution vec IO base */
60
61         int             freq;           /* frequency of nae block */
62         int             flow_crc_poly;  /* Flow CRC16 polynomial */
63         int             total_free_desc; /* total for node */
64         int             max_ports;
65         int             total_num_ports;
66         int             per_port_num_flows;
67
68         u_int           nucores;
69         u_int           nblocks;
70         u_int           num_complex;
71         u_int           ncontexts;
72
73         /*  Ingress side parameters */
74         u_int           num_desc;       /* no of descriptors in each packet */
75         u_int           parser_threshold;/* threshold of entries above which */
76                                         /* the parser sequencer is scheduled */
77         /* NetIOR configs */
78         u_int           cmplx_type[8];          /* XXXJC: redundant? */
79         struct nae_port_config *portcfg;
80         u_int           blockmask;
81         u_int           portmask[XLP_NAE_NBLOCKS];
82         u_int           ilmask;
83         u_int           xauimask;
84         u_int           sgmiimask;
85         u_int           hw_parser_en;
86         u_int           prepad_en;
87         u_int           prepad_size;
88         u_int           driver_mode;
89         u_int           ieee_1588_en;
90 };
91
92 struct nlm_xlpge_softc {
93         struct ifnet    *xlpge_if;      /* should be first member */
94                                         /* see - mii.c:miibus_attach() */
95         device_t        xlpge_dev;
96         device_t        mii_bus;
97         struct nlm_xlpnae_softc *network_sc;
98         uint64_t        base_addr;      /* NAE IO base */
99         int             node;           /* node id (quickread) */
100         int             block;          /* network block id (quickread) */
101         int             port;           /* port id - among the 18 in XLP */
102         int             type;           /* port type - see xlp_gmac_port_types */
103         int             valid;          /* boolean: valid port or not */
104         struct mii_data xlpge_mii;
105         int             nfree_desc;     /* No of free descriptors sent to port */
106         int             phy_addr;       /* PHY id for the interface */
107
108         int             speed;          /* Port speed */
109         int             duplexity;      /* Port duplexity */
110         int             link;           /* Port link status */
111         int              flowctrl;      /* Port flow control setting */
112
113         unsigned char   dev_addr[ETHER_ADDR_LEN];
114         struct mtx      sc_lock;
115         int             if_flags;
116         struct nae_port_config *portcfg;
117         struct callout  xlpge_callout;
118         int             mdio_bus;
119         int             txq;
120         int             rxfreeq;
121         int             hw_parser_en;
122         int             prepad_en;
123         int             prepad_size;
124 };
125
126 #define XLP_NTXFRAGS            16
127 #define NULL_VFBID              127
128
129 struct xlpge_tx_desc {
130         uint64_t        frag[XLP_NTXFRAGS];
131 };
132
133 #define XLPGE_LOCK_INIT(_sc, _name)     \
134         mtx_init(&(_sc)->sc_lock, _name, MTX_NETWORK_LOCK, MTX_DEF)
135 #define XLPGE_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_lock)
136 #define XLPGE_LOCK(_sc)         mtx_lock(&(_sc)->sc_lock)
137 #define XLPGE_UNLOCK(_sc)       mtx_unlock(&(_sc)->sc_lock)
138 #define XLPGE_LOCK_ASSERT(_sc)  mtx_assert(&(_sc)->sc_lock, MA_OWNED)
139
140 #endif