2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2003-2012 Broadcom Corporation
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
36 #define NLM_XLPGE_TXQ_SIZE 1024
39 enum xlpge_link_state {
44 enum xlpge_floctrl_status {
45 NLM_FLOWCTRL_DISABLED,
49 struct nlm_xlp_portdata {
50 struct ifnet *xlpge_if;
51 struct nlm_xlpge_softc *xlpge_sc;
54 struct nlm_xlpnae_softc {
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 */
61 int freq; /* frequency of nae block */
62 int flow_crc_poly; /* Flow CRC16 polynomial */
63 int total_free_desc; /* total for node */
66 int per_port_num_flows;
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 */
78 u_int cmplx_type[8]; /* XXXJC: redundant? */
79 struct nae_port_config *portcfg;
81 u_int portmask[XLP_NAE_NBLOCKS];
92 struct nlm_xlpge_softc {
93 struct ifnet *xlpge_if; /* should be first member */
94 /* see - mii.c:miibus_attach() */
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 */
108 int speed; /* Port speed */
109 int duplexity; /* Port duplexity */
110 int link; /* Port link status */
111 int flowctrl; /* Port flow control setting */
113 unsigned char dev_addr[ETHER_ADDR_LEN];
116 struct nae_port_config *portcfg;
117 struct callout xlpge_callout;
126 #define XLP_NTXFRAGS 16
127 #define NULL_VFBID 127
129 struct xlpge_tx_desc {
130 uint64_t frag[XLP_NTXFRAGS];
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)