2 * Copyright (c) 2003-2012 Broadcom Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #define NLM_XLPGE_TXQ_SIZE 1024
37 enum xlpge_link_state {
42 enum xlpge_floctrl_status {
43 NLM_FLOWCTRL_DISABLED,
47 struct nlm_xlp_portdata {
48 struct ifnet *xlpge_if;
49 struct nlm_xlpge_softc *xlpge_sc;
52 struct nlm_xlpnae_softc {
54 int node; /* XLP Node id */
55 uint64_t base; /* NAE IO base */
56 uint64_t poe_base; /* POE IO base */
57 uint64_t poedv_base; /* POE distribution vec IO base */
59 int freq; /* frequency of nae block */
60 int flow_crc_poly; /* Flow CRC16 polynomial */
61 int total_free_desc; /* total for node */
64 int per_port_num_flows;
71 /* Ingress side parameters */
72 u_int num_desc; /* no of descriptors in each packet */
73 u_int parser_threshold;/* threshold of entries above which */
74 /* the parser sequencer is scheduled */
76 u_int cmplx_type[8]; /* XXXJC: redundant? */
77 struct nae_port_config *portcfg;
79 u_int portmask[XLP_NAE_NBLOCKS];
90 struct nlm_xlpge_softc {
91 struct ifnet *xlpge_if; /* should be first member */
92 /* see - mii.c:miibus_attach() */
95 struct nlm_xlpnae_softc *network_sc;
96 uint64_t base_addr; /* NAE IO base */
97 int node; /* node id (quickread) */
98 int block; /* network block id (quickread) */
99 int port; /* port id - among the 18 in XLP */
100 int type; /* port type - see xlp_gmac_port_types */
101 int valid; /* boolean: valid port or not */
102 struct mii_data xlpge_mii;
103 int nfree_desc; /* No of free descriptors sent to port */
104 int phy_addr; /* PHY id for the interface */
106 int speed; /* Port speed */
107 int duplexity; /* Port duplexity */
108 int link; /* Port link status */
109 int flowctrl; /* Port flow control setting */
111 unsigned char dev_addr[ETHER_ADDR_LEN];
114 struct nae_port_config *portcfg;
115 struct callout xlpge_callout;
124 #define XLP_NTXFRAGS 16
125 #define NULL_VFBID 127
127 struct xlpge_tx_desc {
128 uint64_t frag[XLP_NTXFRAGS];
131 #define XLPGE_LOCK_INIT(_sc, _name) \
132 mtx_init(&(_sc)->sc_lock, _name, MTX_NETWORK_LOCK, MTX_DEF)
133 #define XLPGE_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_lock)
134 #define XLPGE_LOCK(_sc) mtx_lock(&(_sc)->sc_lock)
135 #define XLPGE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_lock)
136 #define XLPGE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_lock, MA_OWNED)