1*d14abf15SRobert Mustacchi /*
2*d14abf15SRobert Mustacchi * CDDL HEADER START
3*d14abf15SRobert Mustacchi *
4*d14abf15SRobert Mustacchi * The contents of this file are subject to the terms of the
5*d14abf15SRobert Mustacchi * Common Development and Distribution License (the "License").
6*d14abf15SRobert Mustacchi * You may not use this file except in compliance with the License.
7*d14abf15SRobert Mustacchi *
8*d14abf15SRobert Mustacchi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*d14abf15SRobert Mustacchi * or http://www.opensolaris.org/os/licensing.
10*d14abf15SRobert Mustacchi * See the License for the specific language governing permissions
11*d14abf15SRobert Mustacchi * and limitations under the License.
12*d14abf15SRobert Mustacchi *
13*d14abf15SRobert Mustacchi * When distributing Covered Code, include this CDDL HEADER in each
14*d14abf15SRobert Mustacchi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*d14abf15SRobert Mustacchi * If applicable, add the following below this CDDL HEADER, with the
16*d14abf15SRobert Mustacchi * fields enclosed by brackets "[]" replaced with your own identifying
17*d14abf15SRobert Mustacchi * information: Portions Copyright [yyyy] [name of copyright owner]
18*d14abf15SRobert Mustacchi *
19*d14abf15SRobert Mustacchi * CDDL HEADER END
20*d14abf15SRobert Mustacchi */
21*d14abf15SRobert Mustacchi
22*d14abf15SRobert Mustacchi /*
23*d14abf15SRobert Mustacchi * Copyright 2014 QLogic Corporation
24*d14abf15SRobert Mustacchi * The contents of this file are subject to the terms of the
25*d14abf15SRobert Mustacchi * QLogic End User License (the "License").
26*d14abf15SRobert Mustacchi * You may not use this file except in compliance with the License.
27*d14abf15SRobert Mustacchi *
28*d14abf15SRobert Mustacchi * You can obtain a copy of the License at
29*d14abf15SRobert Mustacchi * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
30*d14abf15SRobert Mustacchi * QLogic_End_User_Software_License.txt
31*d14abf15SRobert Mustacchi * See the License for the specific language governing permissions
32*d14abf15SRobert Mustacchi * and limitations under the License.
33*d14abf15SRobert Mustacchi */
34*d14abf15SRobert Mustacchi
35*d14abf15SRobert Mustacchi /*
36*d14abf15SRobert Mustacchi * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
37*d14abf15SRobert Mustacchi */
38*d14abf15SRobert Mustacchi
39*d14abf15SRobert Mustacchi #include "bnxe.h"
40*d14abf15SRobert Mustacchi
41*d14abf15SRobert Mustacchi #define BNXE_DEF_TX_BD_PAGE_CNT 12
42*d14abf15SRobert Mustacchi #define BNXE_DEF_TX_COAL_BUF_CNT 10
43*d14abf15SRobert Mustacchi
44*d14abf15SRobert Mustacchi typedef struct
45*d14abf15SRobert Mustacchi {
46*d14abf15SRobert Mustacchi int bufCnt;
47*d14abf15SRobert Mustacchi int txBdPageCnt;
48*d14abf15SRobert Mustacchi int txCoalBufCnt;
49*d14abf15SRobert Mustacchi } BnxeHwPageConfig;
50*d14abf15SRobert Mustacchi
51*d14abf15SRobert Mustacchi static BnxeHwPageConfig bnxeHwPageConfigs[] =
52*d14abf15SRobert Mustacchi {
53*d14abf15SRobert Mustacchi /* Buffers TX BD Pages TX Coalesce Bufs */
54*d14abf15SRobert Mustacchi { 1000, 4, 10 },
55*d14abf15SRobert Mustacchi { 1500, 6, 10 },
56*d14abf15SRobert Mustacchi { 3000, 12, 10 },
57*d14abf15SRobert Mustacchi { 0, 0, 0 }
58*d14abf15SRobert Mustacchi };
59*d14abf15SRobert Mustacchi
60*d14abf15SRobert Mustacchi #if 0
61*d14abf15SRobert Mustacchi #define MEM_LOG BnxeLogInfo
62*d14abf15SRobert Mustacchi #else
63*d14abf15SRobert Mustacchi #define MEM_LOG
64*d14abf15SRobert Mustacchi #endif
65*d14abf15SRobert Mustacchi
66*d14abf15SRobert Mustacchi ddi_device_acc_attr_t bnxeAccessAttribBAR =
67*d14abf15SRobert Mustacchi {
68*d14abf15SRobert Mustacchi DDI_DEVICE_ATTR_V0, /* devacc_attr_version */
69*d14abf15SRobert Mustacchi DDI_STRUCTURE_LE_ACC, /* devacc_attr_endian_flags */
70*d14abf15SRobert Mustacchi DDI_STRICTORDER_ACC, /* devacc_attr_dataorder */
71*d14abf15SRobert Mustacchi DDI_DEFAULT_ACC /* devacc_attr_access */
72*d14abf15SRobert Mustacchi };
73*d14abf15SRobert Mustacchi
74*d14abf15SRobert Mustacchi ddi_device_acc_attr_t bnxeAccessAttribBUF =
75*d14abf15SRobert Mustacchi {
76*d14abf15SRobert Mustacchi DDI_DEVICE_ATTR_V0, /* devacc_attr_version */
77*d14abf15SRobert Mustacchi DDI_NEVERSWAP_ACC, /* devacc_attr_endian_flags */
78*d14abf15SRobert Mustacchi DDI_STRICTORDER_ACC, /* devacc_attr_dataorder */
79*d14abf15SRobert Mustacchi DDI_DEFAULT_ACC /* devacc_attr_access */
80*d14abf15SRobert Mustacchi };
81*d14abf15SRobert Mustacchi
82*d14abf15SRobert Mustacchi ddi_dma_attr_t bnxeDmaPageAttrib =
83*d14abf15SRobert Mustacchi {
84*d14abf15SRobert Mustacchi DMA_ATTR_V0, /* dma_attr_version */
85*d14abf15SRobert Mustacchi 0, /* dma_attr_addr_lo */
86*d14abf15SRobert Mustacchi 0xffffffffffffffff, /* dma_attr_addr_hi */
87*d14abf15SRobert Mustacchi 0xffffffffffffffff, /* dma_attr_count_max */
88*d14abf15SRobert Mustacchi 0, /* dma_attr_align */
89*d14abf15SRobert Mustacchi 0xffffffff, /* dma_attr_burstsizes */
90*d14abf15SRobert Mustacchi 1, /* dma_attr_minxfer */
91*d14abf15SRobert Mustacchi 0xffffffffffffffff, /* dma_attr_maxxfer */
92*d14abf15SRobert Mustacchi 0xffffffffffffffff, /* dma_attr_seg */
93*d14abf15SRobert Mustacchi 1, /* dma_attr_sgllen */
94*d14abf15SRobert Mustacchi 1, /* dma_attr_granular */
95*d14abf15SRobert Mustacchi 0, /* dma_attr_flags */
96*d14abf15SRobert Mustacchi };
97*d14abf15SRobert Mustacchi
98*d14abf15SRobert Mustacchi
mm_wait(lm_device_t * pDev,u32_t delayUs)99*d14abf15SRobert Mustacchi void mm_wait(lm_device_t * pDev,
100*d14abf15SRobert Mustacchi u32_t delayUs)
101*d14abf15SRobert Mustacchi {
102*d14abf15SRobert Mustacchi (void)pDev;
103*d14abf15SRobert Mustacchi drv_usecwait(delayUs);
104*d14abf15SRobert Mustacchi }
105*d14abf15SRobert Mustacchi
106*d14abf15SRobert Mustacchi
mm_read_pci(lm_device_t * pDev,u32_t pciReg,u32_t * pRegValue)107*d14abf15SRobert Mustacchi lm_status_t mm_read_pci(lm_device_t * pDev,
108*d14abf15SRobert Mustacchi u32_t pciReg,
109*d14abf15SRobert Mustacchi u32_t * pRegValue)
110*d14abf15SRobert Mustacchi {
111*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
112*d14abf15SRobert Mustacchi
113*d14abf15SRobert Mustacchi *pRegValue = pci_config_get32(pUM->pPciCfg, (off_t)pciReg);
114*d14abf15SRobert Mustacchi
115*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
116*d14abf15SRobert Mustacchi }
117*d14abf15SRobert Mustacchi
118*d14abf15SRobert Mustacchi
mm_write_pci(lm_device_t * pDev,u32_t pciReg,u32_t regValue)119*d14abf15SRobert Mustacchi lm_status_t mm_write_pci(lm_device_t * pDev,
120*d14abf15SRobert Mustacchi u32_t pciReg,
121*d14abf15SRobert Mustacchi u32_t regValue)
122*d14abf15SRobert Mustacchi {
123*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
124*d14abf15SRobert Mustacchi
125*d14abf15SRobert Mustacchi pci_config_put32(pUM->pPciCfg, (off_t)pciReg, regValue);
126*d14abf15SRobert Mustacchi
127*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
128*d14abf15SRobert Mustacchi }
129*d14abf15SRobert Mustacchi
130*d14abf15SRobert Mustacchi
BnxeInitBdCnts(um_device_t * pUM,int cli_idx)131*d14abf15SRobert Mustacchi void BnxeInitBdCnts(um_device_t * pUM,
132*d14abf15SRobert Mustacchi int cli_idx)
133*d14abf15SRobert Mustacchi {
134*d14abf15SRobert Mustacchi lm_device_t * pLM = (lm_device_t *)pUM;
135*d14abf15SRobert Mustacchi BnxeHwPageConfig * pPageCfg;
136*d14abf15SRobert Mustacchi
137*d14abf15SRobert Mustacchi pLM->params.l2_tx_bd_page_cnt[cli_idx] = BNXE_DEF_TX_BD_PAGE_CNT;
138*d14abf15SRobert Mustacchi pLM->params.l2_tx_coal_buf_cnt[cli_idx] = BNXE_DEF_TX_COAL_BUF_CNT;
139*d14abf15SRobert Mustacchi
140*d14abf15SRobert Mustacchi pPageCfg = &bnxeHwPageConfigs[0];
141*d14abf15SRobert Mustacchi while (pPageCfg->bufCnt)
142*d14abf15SRobert Mustacchi {
143*d14abf15SRobert Mustacchi if (pLM->params.l2_rx_desc_cnt[cli_idx] <= pPageCfg->bufCnt)
144*d14abf15SRobert Mustacchi {
145*d14abf15SRobert Mustacchi pLM->params.l2_tx_bd_page_cnt[cli_idx] = pPageCfg->txBdPageCnt;
146*d14abf15SRobert Mustacchi pLM->params.l2_tx_coal_buf_cnt[cli_idx] = pPageCfg->txCoalBufCnt;
147*d14abf15SRobert Mustacchi break;
148*d14abf15SRobert Mustacchi }
149*d14abf15SRobert Mustacchi
150*d14abf15SRobert Mustacchi pPageCfg++;
151*d14abf15SRobert Mustacchi }
152*d14abf15SRobert Mustacchi }
153*d14abf15SRobert Mustacchi
154*d14abf15SRobert Mustacchi
155*d14abf15SRobert Mustacchi extern u32_t LOG2(u32_t v);
156*d14abf15SRobert Mustacchi unsigned long log2_align(unsigned long n);
157*d14abf15SRobert Mustacchi
mm_get_user_config(lm_device_t * pLM)158*d14abf15SRobert Mustacchi lm_status_t mm_get_user_config(lm_device_t * pLM)
159*d14abf15SRobert Mustacchi {
160*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pLM;
161*d14abf15SRobert Mustacchi u32_t total_size;
162*d14abf15SRobert Mustacchi u32_t required_page_size;
163*d14abf15SRobert Mustacchi
164*d14abf15SRobert Mustacchi BnxeCfgInit(pUM);
165*d14abf15SRobert Mustacchi
166*d14abf15SRobert Mustacchi pLM->params.sw_config = LM_SWCFG_10G;
167*d14abf15SRobert Mustacchi
168*d14abf15SRobert Mustacchi pLM->params.ofld_cap = (LM_OFFLOAD_TX_IP_CKSUM |
169*d14abf15SRobert Mustacchi LM_OFFLOAD_RX_IP_CKSUM |
170*d14abf15SRobert Mustacchi LM_OFFLOAD_TX_TCP_CKSUM |
171*d14abf15SRobert Mustacchi LM_OFFLOAD_RX_TCP_CKSUM |
172*d14abf15SRobert Mustacchi LM_OFFLOAD_TX_TCP6_CKSUM |
173*d14abf15SRobert Mustacchi LM_OFFLOAD_RX_TCP6_CKSUM |
174*d14abf15SRobert Mustacchi LM_OFFLOAD_TX_UDP_CKSUM |
175*d14abf15SRobert Mustacchi LM_OFFLOAD_RX_UDP_CKSUM |
176*d14abf15SRobert Mustacchi LM_OFFLOAD_TX_UDP6_CKSUM |
177*d14abf15SRobert Mustacchi LM_OFFLOAD_RX_UDP6_CKSUM);
178*d14abf15SRobert Mustacchi
179*d14abf15SRobert Mustacchi /* XXX Wake on LAN? */
180*d14abf15SRobert Mustacchi //pLM->params.wol_cap = (LM_WAKE_UP_MODE_MAGIC_PACKET | LM_WAKE_UP_MODE_NWUF);
181*d14abf15SRobert Mustacchi
182*d14abf15SRobert Mustacchi /* keep the VLAN tag in the mac header when receiving */
183*d14abf15SRobert Mustacchi pLM->params.keep_vlan_tag = 1;
184*d14abf15SRobert Mustacchi
185*d14abf15SRobert Mustacchi /* set in BnxeIntrInit based on the allocated number of MSIX interrupts */
186*d14abf15SRobert Mustacchi //pLM->params.rss_chain_cnt = pUM->devParams.numRings;
187*d14abf15SRobert Mustacchi //pLM->params.tss_chain_cnt = pUM->devParams.numRings;
188*d14abf15SRobert Mustacchi
189*d14abf15SRobert Mustacchi pLM->params.l2_rx_desc_cnt[LM_CLI_IDX_NDIS] = pUM->devParams.numRxDesc[LM_CLI_IDX_NDIS];
190*d14abf15SRobert Mustacchi pLM->params.l2_tx_bd_page_cnt[LM_CLI_IDX_NDIS] = 0;
191*d14abf15SRobert Mustacchi pLM->params.l2_tx_coal_buf_cnt[LM_CLI_IDX_NDIS] = 0;
192*d14abf15SRobert Mustacchi
193*d14abf15SRobert Mustacchi BnxeInitBdCnts(pUM, LM_CLI_IDX_NDIS);
194*d14abf15SRobert Mustacchi
195*d14abf15SRobert Mustacchi pLM->params.l2_rx_desc_cnt[LM_CLI_IDX_FWD] = 0;
196*d14abf15SRobert Mustacchi pLM->params.l2_tx_bd_page_cnt[LM_CLI_IDX_FWD] = 0;
197*d14abf15SRobert Mustacchi pLM->params.l2_tx_coal_buf_cnt[LM_CLI_IDX_FWD] = 0;
198*d14abf15SRobert Mustacchi
199*d14abf15SRobert Mustacchi pLM->params.l2_rx_desc_cnt[LM_CLI_IDX_ISCSI] = 0;
200*d14abf15SRobert Mustacchi pLM->params.l2_tx_bd_page_cnt[LM_CLI_IDX_ISCSI] = 0;
201*d14abf15SRobert Mustacchi pLM->params.l2_tx_coal_buf_cnt[LM_CLI_IDX_ISCSI] = 0;
202*d14abf15SRobert Mustacchi
203*d14abf15SRobert Mustacchi pLM->params.l2_rx_desc_cnt[LM_CLI_IDX_FCOE] = 0;
204*d14abf15SRobert Mustacchi pLM->params.l2_tx_bd_page_cnt[LM_CLI_IDX_FCOE] = 0;
205*d14abf15SRobert Mustacchi pLM->params.l2_tx_coal_buf_cnt[LM_CLI_IDX_FCOE] = 0;
206*d14abf15SRobert Mustacchi
207*d14abf15SRobert Mustacchi pLM->params.max_func_toe_cons = 0;
208*d14abf15SRobert Mustacchi pLM->params.max_func_iscsi_cons = 0;
209*d14abf15SRobert Mustacchi pLM->params.max_func_rdma_cons = 0;
210*d14abf15SRobert Mustacchi pLM->params.max_func_fcoe_cons = pUM->lm_dev.hw_info.max_port_fcoe_conn;
211*d14abf15SRobert Mustacchi pLM->params.max_func_connections =
212*d14abf15SRobert Mustacchi log2_align(pLM->params.max_func_toe_cons +
213*d14abf15SRobert Mustacchi pLM->params.max_func_rdma_cons +
214*d14abf15SRobert Mustacchi pLM->params.max_func_iscsi_cons +
215*d14abf15SRobert Mustacchi pLM->params.max_func_fcoe_cons +
216*d14abf15SRobert Mustacchi MAX_ETH_CONS);
217*d14abf15SRobert Mustacchi
218*d14abf15SRobert Mustacchi /* determine: 1. itl_client_page_size, #context in page*/
219*d14abf15SRobert Mustacchi
220*d14abf15SRobert Mustacchi /* based on PCIe block INIT document */
221*d14abf15SRobert Mustacchi
222*d14abf15SRobert Mustacchi /* We now need to calculate the page size based on the maximum number of
223*d14abf15SRobert Mustacchi * connections supported. Since this property is identical to all ports, and
224*d14abf15SRobert Mustacchi * is configured in COMMON registers, we need to use the maximum number of
225*d14abf15SRobert Mustacchi * connections in all ports. */
226*d14abf15SRobert Mustacchi
227*d14abf15SRobert Mustacchi /* The L2P table is used to map logical addresses to physical ones. There
228*d14abf15SRobert Mustacchi * are four clients that use this table. We want to use only the ILT
229*d14abf15SRobert Mustacchi * (Internal), we need to calculate the total size required for all clients,
230*d14abf15SRobert Mustacchi * divide it by the number of entries in the ILT table and that will give us
231*d14abf15SRobert Mustacchi * the page size we want. The following table describes the needs of each of
232*d14abf15SRobert Mustacchi * these clients:
233*d14abf15SRobert Mustacchi *
234*d14abf15SRobert Mustacchi * HW block(L2P client) Area name Size [B]
235*d14abf15SRobert Mustacchi * Searcher T1 ROUNDUP(LOG2(N)) * 64
236*d14abf15SRobert Mustacchi * Timers Linear Array N * 8
237*d14abf15SRobert Mustacchi * QM Queues N * 32 * 4
238*d14abf15SRobert Mustacchi * CDU Context N * S + W * ROUNDUP (N/m) (W=0)
239*d14abf15SRobert Mustacchi *
240*d14abf15SRobert Mustacchi * N: Number of connections
241*d14abf15SRobert Mustacchi * S: Context Size
242*d14abf15SRobert Mustacchi * W: Block Waste (not really interesting) we configure the context size to
243*d14abf15SRobert Mustacchi * be a power of 2.
244*d14abf15SRobert Mustacchi * m: Number of cids in a block (not really interesting, since W will always
245*d14abf15SRobert Mustacchi * be 0)
246*d14abf15SRobert Mustacchi */
247*d14abf15SRobert Mustacchi total_size = (pLM->hw_info.max_common_conns *
248*d14abf15SRobert Mustacchi (SEARCHER_TOTAL_MEM_REQUIRED_PER_CON +
249*d14abf15SRobert Mustacchi TIMERS_TOTAL_MEM_REQUIRED_PER_CON +
250*d14abf15SRobert Mustacchi QM_TOTAL_MEM_REQUIRED_PER_CON +
251*d14abf15SRobert Mustacchi pLM->params.context_line_size));
252*d14abf15SRobert Mustacchi
253*d14abf15SRobert Mustacchi required_page_size = (total_size / ILT_NUM_PAGE_ENTRIES_PER_FUNC);
254*d14abf15SRobert Mustacchi required_page_size = (2 << LOG2(required_page_size));
255*d14abf15SRobert Mustacchi
256*d14abf15SRobert Mustacchi if (required_page_size < LM_PAGE_SIZE)
257*d14abf15SRobert Mustacchi {
258*d14abf15SRobert Mustacchi required_page_size = LM_PAGE_SIZE;
259*d14abf15SRobert Mustacchi }
260*d14abf15SRobert Mustacchi
261*d14abf15SRobert Mustacchi pLM->params.ilt_client_page_size = required_page_size;
262*d14abf15SRobert Mustacchi pLM->params.num_context_in_page = (pLM->params.ilt_client_page_size /
263*d14abf15SRobert Mustacchi pLM->params.context_line_size);
264*d14abf15SRobert Mustacchi
265*d14abf15SRobert Mustacchi if (pUM->devParams.intrCoalesce)
266*d14abf15SRobert Mustacchi {
267*d14abf15SRobert Mustacchi pLM->params.int_coalesing_mode = LM_INT_COAL_PERIODIC_SYNC;
268*d14abf15SRobert Mustacchi pLM->params.int_per_sec_rx_override = pUM->devParams.intrRxPerSec;
269*d14abf15SRobert Mustacchi pLM->params.int_per_sec_tx_override = pUM->devParams.intrTxPerSec;
270*d14abf15SRobert Mustacchi }
271*d14abf15SRobert Mustacchi else
272*d14abf15SRobert Mustacchi {
273*d14abf15SRobert Mustacchi pLM->params.int_coalesing_mode = LM_INT_COAL_NONE;
274*d14abf15SRobert Mustacchi }
275*d14abf15SRobert Mustacchi
276*d14abf15SRobert Mustacchi pLM->params.enable_dynamic_hc[0] = 0;
277*d14abf15SRobert Mustacchi pLM->params.enable_dynamic_hc[1] = 0;
278*d14abf15SRobert Mustacchi pLM->params.enable_dynamic_hc[2] = 0;
279*d14abf15SRobert Mustacchi pLM->params.enable_dynamic_hc[3] = 0;
280*d14abf15SRobert Mustacchi
281*d14abf15SRobert Mustacchi /*
282*d14abf15SRobert Mustacchi * l2_fw_flow_ctrl is read from the shmem in MF mode in E2 and above. In
283*d14abf15SRobert Mustacchi * all other cases this parameter is read from the driver conf. We also
284*d14abf15SRobert Mustacchi * read this parameter from the driver conf in E1.5 MF mode since 57711
285*d14abf15SRobert Mustacchi * boot code does not have the struct func_ext_cfg.
286*d14abf15SRobert Mustacchi */
287*d14abf15SRobert Mustacchi if (((pLM->hw_info.mf_info.mf_mode != MULTI_FUNCTION_SI) &&
288*d14abf15SRobert Mustacchi (pLM->hw_info.mf_info.mf_mode != MULTI_FUNCTION_AFEX)) ||
289*d14abf15SRobert Mustacchi (CHIP_IS_E1x(pLM)))
290*d14abf15SRobert Mustacchi {
291*d14abf15SRobert Mustacchi pLM->params.l2_fw_flow_ctrl = (pUM->devParams.l2_fw_flow_ctrl) ? 1 : 0;
292*d14abf15SRobert Mustacchi }
293*d14abf15SRobert Mustacchi
294*d14abf15SRobert Mustacchi pLM->params.rcv_buffer_offset = BNXE_DMA_RX_OFFSET;
295*d14abf15SRobert Mustacchi
296*d14abf15SRobert Mustacchi pLM->params.debug_cap_flags = DEFAULT_DEBUG_CAP_FLAGS_VAL;
297*d14abf15SRobert Mustacchi
298*d14abf15SRobert Mustacchi pLM->params.max_fcoe_task = lm_fc_max_fcoe_task_sup(pLM);
299*d14abf15SRobert Mustacchi
300*d14abf15SRobert Mustacchi /* enable rate shaping */
301*d14abf15SRobert Mustacchi pLM->params.cmng_enable = 1;
302*d14abf15SRobert Mustacchi
303*d14abf15SRobert Mustacchi pLM->params.validate_sq_complete = 1;
304*d14abf15SRobert Mustacchi
305*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
306*d14abf15SRobert Mustacchi }
307*d14abf15SRobert Mustacchi
308*d14abf15SRobert Mustacchi
BnxeIsBarUsed(um_device_t * pUM,int regNumber,offset_t offset,u32_t size)309*d14abf15SRobert Mustacchi static boolean_t BnxeIsBarUsed(um_device_t * pUM,
310*d14abf15SRobert Mustacchi int regNumber,
311*d14abf15SRobert Mustacchi offset_t offset,
312*d14abf15SRobert Mustacchi u32_t size)
313*d14abf15SRobert Mustacchi {
314*d14abf15SRobert Mustacchi BnxeMemRegion * pMem;
315*d14abf15SRobert Mustacchi
316*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_MEM(pUM);
317*d14abf15SRobert Mustacchi
318*d14abf15SRobert Mustacchi pMem = (BnxeMemRegion *)d_list_peek_head(&pUM->memRegionList);
319*d14abf15SRobert Mustacchi
320*d14abf15SRobert Mustacchi while (pMem)
321*d14abf15SRobert Mustacchi {
322*d14abf15SRobert Mustacchi if ((pMem->regNumber == regNumber) &&
323*d14abf15SRobert Mustacchi (pMem->offset == offset) &&
324*d14abf15SRobert Mustacchi (pMem->size == size))
325*d14abf15SRobert Mustacchi {
326*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
327*d14abf15SRobert Mustacchi return B_TRUE;
328*d14abf15SRobert Mustacchi }
329*d14abf15SRobert Mustacchi
330*d14abf15SRobert Mustacchi pMem = (BnxeMemRegion *)d_list_next_entry(D_LINK_CAST(pMem));
331*d14abf15SRobert Mustacchi }
332*d14abf15SRobert Mustacchi
333*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
334*d14abf15SRobert Mustacchi return B_FALSE;
335*d14abf15SRobert Mustacchi }
336*d14abf15SRobert Mustacchi
337*d14abf15SRobert Mustacchi
mm_map_io_base(lm_device_t * pLM,lm_address_t baseAddr,u32_t size,u8_t bar)338*d14abf15SRobert Mustacchi void * mm_map_io_base(lm_device_t * pLM,
339*d14abf15SRobert Mustacchi lm_address_t baseAddr,
340*d14abf15SRobert Mustacchi u32_t size,
341*d14abf15SRobert Mustacchi u8_t bar)
342*d14abf15SRobert Mustacchi {
343*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pLM;
344*d14abf15SRobert Mustacchi BnxeMemRegion * pMem;
345*d14abf15SRobert Mustacchi //int numRegs;
346*d14abf15SRobert Mustacchi off_t regSize;
347*d14abf15SRobert Mustacchi int rc;
348*d14abf15SRobert Mustacchi
349*d14abf15SRobert Mustacchi /*
350*d14abf15SRobert Mustacchi * Solaris identifies:
351*d14abf15SRobert Mustacchi * BAR 0 - size 0 (pci config regs?)
352*d14abf15SRobert Mustacchi * BAR 1 - size 0x800000 (Everest 1/2 LM BAR 0)
353*d14abf15SRobert Mustacchi * BAR 2 - size 0x4000000 (Everest 1 LM BAR 1)
354*d14abf15SRobert Mustacchi * 0x800000 (Everest 2 LM BAR 1)
355*d14abf15SRobert Mustacchi * BAR 3 - size 0x10000 (Everest 2 LM BAR 2)
356*d14abf15SRobert Mustacchi */
357*d14abf15SRobert Mustacchi bar++;
358*d14abf15SRobert Mustacchi
359*d14abf15SRobert Mustacchi //ddi_dev_nregs(pUM->pDev, &numRegs);
360*d14abf15SRobert Mustacchi
361*d14abf15SRobert Mustacchi ddi_dev_regsize(pUM->pDev, bar, ®Size);
362*d14abf15SRobert Mustacchi
363*d14abf15SRobert Mustacchi if ((size > regSize) || BnxeIsBarUsed(pUM, bar, 0, size))
364*d14abf15SRobert Mustacchi {
365*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "BAR %d at offset %d and size %d is already being used!",
366*d14abf15SRobert Mustacchi bar, 0, (int)regSize);
367*d14abf15SRobert Mustacchi return NULL;
368*d14abf15SRobert Mustacchi }
369*d14abf15SRobert Mustacchi
370*d14abf15SRobert Mustacchi if ((pMem = kmem_zalloc(sizeof(BnxeMemRegion), KM_NOSLEEP)) == NULL)
371*d14abf15SRobert Mustacchi {
372*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Memory allocation for BAR %d at offset %d and size %d failed!",
373*d14abf15SRobert Mustacchi bar, 0, (int)regSize);
374*d14abf15SRobert Mustacchi return NULL;
375*d14abf15SRobert Mustacchi }
376*d14abf15SRobert Mustacchi
377*d14abf15SRobert Mustacchi if ((rc = ddi_regs_map_setup(pUM->pDev,
378*d14abf15SRobert Mustacchi bar, // bar number
379*d14abf15SRobert Mustacchi &pMem->pRegAddr,
380*d14abf15SRobert Mustacchi 0, // region map offset,
381*d14abf15SRobert Mustacchi size, // region memory window size (0=all)
382*d14abf15SRobert Mustacchi &bnxeAccessAttribBAR,
383*d14abf15SRobert Mustacchi &pMem->regAccess)) != DDI_SUCCESS)
384*d14abf15SRobert Mustacchi {
385*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Failed to memory map device (BAR=%d, offset=%d, size=%d) (%d)",
386*d14abf15SRobert Mustacchi bar, 0, size, rc);
387*d14abf15SRobert Mustacchi kmem_free(pMem, sizeof(BnxeMemRegion));
388*d14abf15SRobert Mustacchi return NULL;
389*d14abf15SRobert Mustacchi }
390*d14abf15SRobert Mustacchi
391*d14abf15SRobert Mustacchi pMem->baseAddr = baseAddr;
392*d14abf15SRobert Mustacchi pMem->regNumber = bar;
393*d14abf15SRobert Mustacchi pMem->offset = 0;
394*d14abf15SRobert Mustacchi pMem->size = size;
395*d14abf15SRobert Mustacchi
396*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_MEM(pUM);
397*d14abf15SRobert Mustacchi d_list_push_head(&pUM->memRegionList, D_LINK_CAST(pMem));
398*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
399*d14abf15SRobert Mustacchi
400*d14abf15SRobert Mustacchi bar--;
401*d14abf15SRobert Mustacchi pLM->vars.reg_handle[bar] = pMem->regAccess;
402*d14abf15SRobert Mustacchi
403*d14abf15SRobert Mustacchi return pMem->pRegAddr;
404*d14abf15SRobert Mustacchi }
405*d14abf15SRobert Mustacchi
406*d14abf15SRobert Mustacchi
mm_map_io_space_solaris(lm_device_t * pLM,lm_address_t physAddr,u8_t bar,u32_t offset,u32_t size,ddi_acc_handle_t * pRegAccHandle)407*d14abf15SRobert Mustacchi void * mm_map_io_space_solaris(lm_device_t * pLM,
408*d14abf15SRobert Mustacchi lm_address_t physAddr,
409*d14abf15SRobert Mustacchi u8_t bar,
410*d14abf15SRobert Mustacchi u32_t offset,
411*d14abf15SRobert Mustacchi u32_t size,
412*d14abf15SRobert Mustacchi ddi_acc_handle_t * pRegAccHandle)
413*d14abf15SRobert Mustacchi {
414*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pLM;
415*d14abf15SRobert Mustacchi BnxeMemRegion * pMem;
416*d14abf15SRobert Mustacchi off_t regSize;
417*d14abf15SRobert Mustacchi int rc;
418*d14abf15SRobert Mustacchi
419*d14abf15SRobert Mustacchi /* see bar mapping described in mm_map_io_base above */
420*d14abf15SRobert Mustacchi bar++;
421*d14abf15SRobert Mustacchi
422*d14abf15SRobert Mustacchi ddi_dev_regsize(pUM->pDev, bar, ®Size);
423*d14abf15SRobert Mustacchi
424*d14abf15SRobert Mustacchi if ((size > regSize) || BnxeIsBarUsed(pUM, bar, offset, size))
425*d14abf15SRobert Mustacchi {
426*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "BAR %d at offset %d and size %d is already being used!",
427*d14abf15SRobert Mustacchi bar, offset, (int)regSize);
428*d14abf15SRobert Mustacchi return NULL;
429*d14abf15SRobert Mustacchi }
430*d14abf15SRobert Mustacchi
431*d14abf15SRobert Mustacchi if ((pMem = kmem_zalloc(sizeof(BnxeMemRegion), KM_NOSLEEP)) == NULL)
432*d14abf15SRobert Mustacchi {
433*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Memory allocation for BAR %d at offset %d and size %d failed!",
434*d14abf15SRobert Mustacchi bar, offset, (int)regSize);
435*d14abf15SRobert Mustacchi return NULL;
436*d14abf15SRobert Mustacchi }
437*d14abf15SRobert Mustacchi
438*d14abf15SRobert Mustacchi if ((rc = ddi_regs_map_setup(pUM->pDev,
439*d14abf15SRobert Mustacchi bar, // bar number
440*d14abf15SRobert Mustacchi &pMem->pRegAddr,
441*d14abf15SRobert Mustacchi offset, // region map offset,
442*d14abf15SRobert Mustacchi size, // region memory window size (0=all)
443*d14abf15SRobert Mustacchi &bnxeAccessAttribBAR,
444*d14abf15SRobert Mustacchi pRegAccHandle)) != DDI_SUCCESS)
445*d14abf15SRobert Mustacchi {
446*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Failed to memory map device (BAR=%d, offset=%d, size=%d) (%d)",
447*d14abf15SRobert Mustacchi bar, offset, size, rc);
448*d14abf15SRobert Mustacchi kmem_free(pMem, sizeof(BnxeMemRegion));
449*d14abf15SRobert Mustacchi return NULL;
450*d14abf15SRobert Mustacchi }
451*d14abf15SRobert Mustacchi
452*d14abf15SRobert Mustacchi pMem->baseAddr = physAddr;
453*d14abf15SRobert Mustacchi pMem->regNumber = bar;
454*d14abf15SRobert Mustacchi pMem->offset = offset;
455*d14abf15SRobert Mustacchi pMem->size = size;
456*d14abf15SRobert Mustacchi pMem->regAccess = *pRegAccHandle;
457*d14abf15SRobert Mustacchi
458*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_MEM(pUM);
459*d14abf15SRobert Mustacchi d_list_push_head(&pUM->memRegionList, D_LINK_CAST(pMem));
460*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
461*d14abf15SRobert Mustacchi
462*d14abf15SRobert Mustacchi return pMem->pRegAddr;
463*d14abf15SRobert Mustacchi }
464*d14abf15SRobert Mustacchi
465*d14abf15SRobert Mustacchi
mm_unmap_io_space(lm_device_t * pLM,void * pVirtAddr,u32_t size)466*d14abf15SRobert Mustacchi void mm_unmap_io_space(lm_device_t * pLM,
467*d14abf15SRobert Mustacchi void * pVirtAddr,
468*d14abf15SRobert Mustacchi u32_t size)
469*d14abf15SRobert Mustacchi {
470*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pLM;
471*d14abf15SRobert Mustacchi BnxeMemRegion * pMemRegion;
472*d14abf15SRobert Mustacchi
473*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_MEM(pUM);
474*d14abf15SRobert Mustacchi
475*d14abf15SRobert Mustacchi pMemRegion = (BnxeMemRegion *)d_list_peek_head(&pUM->memRegionList);
476*d14abf15SRobert Mustacchi
477*d14abf15SRobert Mustacchi while (pMemRegion)
478*d14abf15SRobert Mustacchi {
479*d14abf15SRobert Mustacchi if ((pMemRegion->pRegAddr == pVirtAddr) &&
480*d14abf15SRobert Mustacchi (pMemRegion->size == size))
481*d14abf15SRobert Mustacchi {
482*d14abf15SRobert Mustacchi d_list_remove_entry(&pUM->memRegionList, D_LINK_CAST(pMemRegion));
483*d14abf15SRobert Mustacchi ddi_regs_map_free(&pMemRegion->regAccess);
484*d14abf15SRobert Mustacchi kmem_free(pMemRegion, sizeof(BnxeMemRegion));
485*d14abf15SRobert Mustacchi break;
486*d14abf15SRobert Mustacchi }
487*d14abf15SRobert Mustacchi
488*d14abf15SRobert Mustacchi pMemRegion = (BnxeMemRegion *)d_list_next_entry(D_LINK_CAST(pMemRegion));
489*d14abf15SRobert Mustacchi }
490*d14abf15SRobert Mustacchi
491*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
492*d14abf15SRobert Mustacchi }
493*d14abf15SRobert Mustacchi
494*d14abf15SRobert Mustacchi
mm_alloc_mem_imp(lm_device_t * pLM,u32_t memSize,const char * sz_file,const unsigned long line,u8_t cli_idx)495*d14abf15SRobert Mustacchi void * mm_alloc_mem_imp(lm_device_t * pLM,
496*d14abf15SRobert Mustacchi u32_t memSize,
497*d14abf15SRobert Mustacchi const char * sz_file,
498*d14abf15SRobert Mustacchi const unsigned long line,
499*d14abf15SRobert Mustacchi u8_t cli_idx)
500*d14abf15SRobert Mustacchi {
501*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pLM;
502*d14abf15SRobert Mustacchi BnxeMemBlock * pMem;
503*d14abf15SRobert Mustacchi void * pBuf;
504*d14abf15SRobert Mustacchi u32_t * pTmp;
505*d14abf15SRobert Mustacchi int i;
506*d14abf15SRobert Mustacchi
507*d14abf15SRobert Mustacchi (void)cli_idx;
508*d14abf15SRobert Mustacchi
509*d14abf15SRobert Mustacchi if ((pMem = kmem_zalloc(sizeof(BnxeMemBlock), KM_NOSLEEP)) == NULL)
510*d14abf15SRobert Mustacchi {
511*d14abf15SRobert Mustacchi return NULL;
512*d14abf15SRobert Mustacchi }
513*d14abf15SRobert Mustacchi
514*d14abf15SRobert Mustacchi /* allocated space for header/trailer checks */
515*d14abf15SRobert Mustacchi memSize += (BNXE_MEM_CHECK_LEN * 2);
516*d14abf15SRobert Mustacchi
517*d14abf15SRobert Mustacchi MEM_LOG(pUM, "*** MEM: %8u", memSize);
518*d14abf15SRobert Mustacchi
519*d14abf15SRobert Mustacchi if ((pBuf = kmem_zalloc(memSize, KM_NOSLEEP)) == NULL)
520*d14abf15SRobert Mustacchi {
521*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Failed to allocate memory");
522*d14abf15SRobert Mustacchi kmem_free(pMem, sizeof(BnxeMemBlock));
523*d14abf15SRobert Mustacchi return NULL;
524*d14abf15SRobert Mustacchi }
525*d14abf15SRobert Mustacchi
526*d14abf15SRobert Mustacchi /* fill in the header check */
527*d14abf15SRobert Mustacchi for (i = 0, pTmp = (u32_t *)pBuf;
528*d14abf15SRobert Mustacchi i < BNXE_MEM_CHECK_LEN;
529*d14abf15SRobert Mustacchi i += 4, pTmp++)
530*d14abf15SRobert Mustacchi {
531*d14abf15SRobert Mustacchi *pTmp = BNXE_MAGIC;
532*d14abf15SRobert Mustacchi }
533*d14abf15SRobert Mustacchi
534*d14abf15SRobert Mustacchi /* fill in the trailer check */
535*d14abf15SRobert Mustacchi for (i = 0, pTmp = (u32_t *)((char *)pBuf + memSize - BNXE_MEM_CHECK_LEN);
536*d14abf15SRobert Mustacchi i < BNXE_MEM_CHECK_LEN;
537*d14abf15SRobert Mustacchi i += 4, pTmp++)
538*d14abf15SRobert Mustacchi {
539*d14abf15SRobert Mustacchi *pTmp = BNXE_MAGIC;
540*d14abf15SRobert Mustacchi }
541*d14abf15SRobert Mustacchi
542*d14abf15SRobert Mustacchi pMem->size = memSize;
543*d14abf15SRobert Mustacchi pMem->pBuf = pBuf;
544*d14abf15SRobert Mustacchi snprintf(pMem->fileName, sizeof(pMem->fileName), "%s", sz_file);
545*d14abf15SRobert Mustacchi pMem->fileLine = line;
546*d14abf15SRobert Mustacchi
547*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_MEM(pUM);
548*d14abf15SRobert Mustacchi d_list_push_head(&pUM->memBlockList, D_LINK_CAST(pMem));
549*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
550*d14abf15SRobert Mustacchi
551*d14abf15SRobert Mustacchi MEM_LOG(pUM, "Allocated %d byte block virt:%p",
552*d14abf15SRobert Mustacchi memSize, ((char *)pBuf + BNXE_MEM_CHECK_LEN));
553*d14abf15SRobert Mustacchi
554*d14abf15SRobert Mustacchi return ((char *)pBuf + BNXE_MEM_CHECK_LEN);
555*d14abf15SRobert Mustacchi }
556*d14abf15SRobert Mustacchi
557*d14abf15SRobert Mustacchi
mm_alloc_phys_mem_align_imp(lm_device_t * pLM,u32_t memSize,lm_address_t * pPhysAddr,u32_t alignment,u8_t memType,const char * sz_file,const unsigned long line,u8_t cli_idx)558*d14abf15SRobert Mustacchi void * mm_alloc_phys_mem_align_imp(lm_device_t * pLM,
559*d14abf15SRobert Mustacchi u32_t memSize,
560*d14abf15SRobert Mustacchi lm_address_t * pPhysAddr,
561*d14abf15SRobert Mustacchi u32_t alignment,
562*d14abf15SRobert Mustacchi u8_t memType,
563*d14abf15SRobert Mustacchi const char * sz_file,
564*d14abf15SRobert Mustacchi const unsigned long line,
565*d14abf15SRobert Mustacchi u8_t cli_idx)
566*d14abf15SRobert Mustacchi {
567*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pLM;
568*d14abf15SRobert Mustacchi int rc;
569*d14abf15SRobert Mustacchi caddr_t pBuf;
570*d14abf15SRobert Mustacchi size_t length;
571*d14abf15SRobert Mustacchi unsigned int count;
572*d14abf15SRobert Mustacchi ddi_dma_attr_t dmaAttrib;
573*d14abf15SRobert Mustacchi ddi_dma_handle_t * pDmaHandle;
574*d14abf15SRobert Mustacchi ddi_acc_handle_t * pDmaAccHandle;
575*d14abf15SRobert Mustacchi ddi_dma_cookie_t cookie;
576*d14abf15SRobert Mustacchi BnxeMemDma * pMem;
577*d14abf15SRobert Mustacchi size_t size;
578*d14abf15SRobert Mustacchi
579*d14abf15SRobert Mustacchi (void)memType;
580*d14abf15SRobert Mustacchi (void)cli_idx;
581*d14abf15SRobert Mustacchi
582*d14abf15SRobert Mustacchi if (memSize == 0)
583*d14abf15SRobert Mustacchi {
584*d14abf15SRobert Mustacchi return NULL;
585*d14abf15SRobert Mustacchi }
586*d14abf15SRobert Mustacchi
587*d14abf15SRobert Mustacchi if ((pMem = kmem_zalloc(sizeof(BnxeMemDma), KM_NOSLEEP)) == NULL)
588*d14abf15SRobert Mustacchi {
589*d14abf15SRobert Mustacchi return NULL;
590*d14abf15SRobert Mustacchi }
591*d14abf15SRobert Mustacchi
592*d14abf15SRobert Mustacchi dmaAttrib = bnxeDmaPageAttrib;
593*d14abf15SRobert Mustacchi dmaAttrib.dma_attr_align = alignment;
594*d14abf15SRobert Mustacchi
595*d14abf15SRobert Mustacchi pDmaHandle = &pMem->dmaHandle;
596*d14abf15SRobert Mustacchi pDmaAccHandle = &pMem->dmaAccHandle;
597*d14abf15SRobert Mustacchi
598*d14abf15SRobert Mustacchi size = memSize;
599*d14abf15SRobert Mustacchi size += (alignment - 1);
600*d14abf15SRobert Mustacchi size &= ~((u32_t)(alignment - 1));
601*d14abf15SRobert Mustacchi
602*d14abf15SRobert Mustacchi MEM_LOG(pUM, "*** DMA: %8u (%4d) - %8u", memSize, alignment, size);
603*d14abf15SRobert Mustacchi
604*d14abf15SRobert Mustacchi if ((rc = ddi_dma_alloc_handle(pUM->pDev,
605*d14abf15SRobert Mustacchi &dmaAttrib,
606*d14abf15SRobert Mustacchi DDI_DMA_DONTWAIT,
607*d14abf15SRobert Mustacchi (void *)0,
608*d14abf15SRobert Mustacchi pDmaHandle)) != DDI_SUCCESS)
609*d14abf15SRobert Mustacchi {
610*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Failed to alloc DMA handle");
611*d14abf15SRobert Mustacchi kmem_free(pMem, sizeof(BnxeMemDma));
612*d14abf15SRobert Mustacchi return NULL;
613*d14abf15SRobert Mustacchi }
614*d14abf15SRobert Mustacchi
615*d14abf15SRobert Mustacchi if ((rc = ddi_dma_mem_alloc(*pDmaHandle,
616*d14abf15SRobert Mustacchi size,
617*d14abf15SRobert Mustacchi &bnxeAccessAttribBUF,
618*d14abf15SRobert Mustacchi DDI_DMA_CONSISTENT,
619*d14abf15SRobert Mustacchi DDI_DMA_DONTWAIT,
620*d14abf15SRobert Mustacchi (void *)0,
621*d14abf15SRobert Mustacchi &pBuf,
622*d14abf15SRobert Mustacchi &length,
623*d14abf15SRobert Mustacchi pDmaAccHandle)) != DDI_SUCCESS)
624*d14abf15SRobert Mustacchi {
625*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Failed to alloc DMA memory");
626*d14abf15SRobert Mustacchi ddi_dma_free_handle(pDmaHandle);
627*d14abf15SRobert Mustacchi kmem_free(pMem, sizeof(BnxeMemDma));
628*d14abf15SRobert Mustacchi return NULL;
629*d14abf15SRobert Mustacchi }
630*d14abf15SRobert Mustacchi
631*d14abf15SRobert Mustacchi if ((rc = ddi_dma_addr_bind_handle(*pDmaHandle,
632*d14abf15SRobert Mustacchi (struct as *)0,
633*d14abf15SRobert Mustacchi pBuf,
634*d14abf15SRobert Mustacchi length,
635*d14abf15SRobert Mustacchi DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
636*d14abf15SRobert Mustacchi DDI_DMA_DONTWAIT,
637*d14abf15SRobert Mustacchi (void *)0,
638*d14abf15SRobert Mustacchi &cookie,
639*d14abf15SRobert Mustacchi &count)) != DDI_DMA_MAPPED)
640*d14abf15SRobert Mustacchi {
641*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Failed to bind DMA address");
642*d14abf15SRobert Mustacchi ddi_dma_mem_free(pDmaAccHandle);
643*d14abf15SRobert Mustacchi ddi_dma_free_handle(pDmaHandle);
644*d14abf15SRobert Mustacchi kmem_free(pMem, sizeof(BnxeMemDma));
645*d14abf15SRobert Mustacchi return NULL;
646*d14abf15SRobert Mustacchi }
647*d14abf15SRobert Mustacchi
648*d14abf15SRobert Mustacchi pPhysAddr->as_u64 = cookie.dmac_laddress;
649*d14abf15SRobert Mustacchi
650*d14abf15SRobert Mustacchi /* save the virtual memory address so we can get the dma_handle later */
651*d14abf15SRobert Mustacchi pMem->size = memSize;
652*d14abf15SRobert Mustacchi pMem->pDmaVirt = pBuf;
653*d14abf15SRobert Mustacchi pMem->physAddr = *pPhysAddr;
654*d14abf15SRobert Mustacchi snprintf(pMem->fileName, sizeof(pMem->fileName), "%s", sz_file);
655*d14abf15SRobert Mustacchi pMem->fileLine = line;
656*d14abf15SRobert Mustacchi
657*d14abf15SRobert Mustacchi #if 0
658*d14abf15SRobert Mustacchi MEM_LOG(pUM, "*** DMA: virt %p / phys 0x%0llx (%d/%d)",
659*d14abf15SRobert Mustacchi pBuf, pPhysAddr->as_u64,
660*d14abf15SRobert Mustacchi (!((u32_t)pBuf % (u32_t)alignment)) ? 1 : 0,
661*d14abf15SRobert Mustacchi (!((u32_t)pPhysAddr->as_ptr % (u32_t)alignment) ? 1 : 0));
662*d14abf15SRobert Mustacchi #endif
663*d14abf15SRobert Mustacchi
664*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_MEM(pUM);
665*d14abf15SRobert Mustacchi d_list_push_head(&pUM->memDmaList, D_LINK_CAST(pMem));
666*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
667*d14abf15SRobert Mustacchi
668*d14abf15SRobert Mustacchi MEM_LOG(pUM, "Allocated %d sized DMA block phys:%p virt:%p",
669*d14abf15SRobert Mustacchi memSize, pMem->physAddr.as_ptr, pMem->pDmaVirt);
670*d14abf15SRobert Mustacchi
671*d14abf15SRobert Mustacchi /* Zero memory! */
672*d14abf15SRobert Mustacchi bzero(pBuf, length);
673*d14abf15SRobert Mustacchi
674*d14abf15SRobert Mustacchi /* make sure the new contents are flushed back to main memory */
675*d14abf15SRobert Mustacchi ddi_dma_sync(*pDmaHandle, 0, length, DDI_DMA_SYNC_FORDEV);
676*d14abf15SRobert Mustacchi
677*d14abf15SRobert Mustacchi return pBuf;
678*d14abf15SRobert Mustacchi }
679*d14abf15SRobert Mustacchi
680*d14abf15SRobert Mustacchi
mm_alloc_phys_mem_imp(lm_device_t * pLM,u32_t memSize,lm_address_t * pPhysAddr,u8_t memType,const char * sz_file,const unsigned long line,u8_t cli_idx)681*d14abf15SRobert Mustacchi void * mm_alloc_phys_mem_imp(lm_device_t * pLM,
682*d14abf15SRobert Mustacchi u32_t memSize,
683*d14abf15SRobert Mustacchi lm_address_t * pPhysAddr,
684*d14abf15SRobert Mustacchi u8_t memType,
685*d14abf15SRobert Mustacchi const char * sz_file,
686*d14abf15SRobert Mustacchi const unsigned long line,
687*d14abf15SRobert Mustacchi u8_t cli_idx)
688*d14abf15SRobert Mustacchi {
689*d14abf15SRobert Mustacchi return mm_alloc_phys_mem_align_imp(pLM, memSize, pPhysAddr,
690*d14abf15SRobert Mustacchi BNXE_DMA_ALIGNMENT, memType,
691*d14abf15SRobert Mustacchi sz_file, line, cli_idx);
692*d14abf15SRobert Mustacchi }
693*d14abf15SRobert Mustacchi
694*d14abf15SRobert Mustacchi
mm_rt_alloc_mem_imp(lm_device_t * pDev,u32_t memSize,const char * sz_file,const unsigned long line,u8_t cli_idx)695*d14abf15SRobert Mustacchi void * mm_rt_alloc_mem_imp(lm_device_t * pDev,
696*d14abf15SRobert Mustacchi u32_t memSize,
697*d14abf15SRobert Mustacchi const char * sz_file,
698*d14abf15SRobert Mustacchi const unsigned long line,
699*d14abf15SRobert Mustacchi u8_t cli_idx)
700*d14abf15SRobert Mustacchi {
701*d14abf15SRobert Mustacchi return mm_alloc_mem_imp(pDev, memSize, sz_file, line, cli_idx);
702*d14abf15SRobert Mustacchi }
703*d14abf15SRobert Mustacchi
704*d14abf15SRobert Mustacchi
mm_rt_alloc_phys_mem_imp(lm_device_t * pDev,u32_t memSize,lm_address_t * pPhysAddr,u8_t flushType,const char * sz_file,const unsigned long line,u8_t cli_idx)705*d14abf15SRobert Mustacchi void * mm_rt_alloc_phys_mem_imp(lm_device_t * pDev,
706*d14abf15SRobert Mustacchi u32_t memSize,
707*d14abf15SRobert Mustacchi lm_address_t * pPhysAddr,
708*d14abf15SRobert Mustacchi u8_t flushType,
709*d14abf15SRobert Mustacchi const char * sz_file,
710*d14abf15SRobert Mustacchi const unsigned long line,
711*d14abf15SRobert Mustacchi u8_t cli_idx)
712*d14abf15SRobert Mustacchi {
713*d14abf15SRobert Mustacchi return mm_alloc_phys_mem_imp(pDev, memSize, pPhysAddr, flushType,
714*d14abf15SRobert Mustacchi sz_file, line, cli_idx);
715*d14abf15SRobert Mustacchi }
716*d14abf15SRobert Mustacchi
717*d14abf15SRobert Mustacchi
mm_get_current_time(lm_device_t * pDev)718*d14abf15SRobert Mustacchi u64_t mm_get_current_time(lm_device_t * pDev)
719*d14abf15SRobert Mustacchi {
720*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
721*d14abf15SRobert Mustacchi BnxeDbgBreakMsg(pUM, "MM_GET_CURRENT_TIME");
722*d14abf15SRobert Mustacchi return 0;
723*d14abf15SRobert Mustacchi }
724*d14abf15SRobert Mustacchi
725*d14abf15SRobert Mustacchi
mm_rt_free_mem(lm_device_t * pDev,void * pBuf,u32_t memSize,u8_t cli_idx)726*d14abf15SRobert Mustacchi void mm_rt_free_mem(lm_device_t * pDev,
727*d14abf15SRobert Mustacchi void * pBuf,
728*d14abf15SRobert Mustacchi u32_t memSize,
729*d14abf15SRobert Mustacchi u8_t cli_idx)
730*d14abf15SRobert Mustacchi {
731*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
732*d14abf15SRobert Mustacchi BnxeMemBlock * pMem;
733*d14abf15SRobert Mustacchi u32_t * pTmp;
734*d14abf15SRobert Mustacchi int i;
735*d14abf15SRobert Mustacchi
736*d14abf15SRobert Mustacchi (void)cli_idx;
737*d14abf15SRobert Mustacchi
738*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_MEM(pUM);
739*d14abf15SRobert Mustacchi
740*d14abf15SRobert Mustacchi pMem = (BnxeMemBlock *)d_list_peek_head(&pUM->memBlockList);
741*d14abf15SRobert Mustacchi
742*d14abf15SRobert Mustacchi /* adjuest for header/trailer checks */
743*d14abf15SRobert Mustacchi pBuf = ((char *)pBuf - BNXE_MEM_CHECK_LEN);
744*d14abf15SRobert Mustacchi memSize += (BNXE_MEM_CHECK_LEN * 2);
745*d14abf15SRobert Mustacchi
746*d14abf15SRobert Mustacchi /* verify header check */
747*d14abf15SRobert Mustacchi for (i = 0, pTmp = (u32_t *)pBuf;
748*d14abf15SRobert Mustacchi i < BNXE_MEM_CHECK_LEN;
749*d14abf15SRobert Mustacchi i += 4, pTmp++)
750*d14abf15SRobert Mustacchi {
751*d14abf15SRobert Mustacchi if (*pTmp != BNXE_MAGIC)
752*d14abf15SRobert Mustacchi {
753*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Header overflow! (%p/%u)", pBuf, memSize);
754*d14abf15SRobert Mustacchi BnxeDbgBreak(pUM);
755*d14abf15SRobert Mustacchi }
756*d14abf15SRobert Mustacchi }
757*d14abf15SRobert Mustacchi
758*d14abf15SRobert Mustacchi /* verify trailer check */
759*d14abf15SRobert Mustacchi for (i = 0, pTmp = (u32_t *)((char *)pBuf + memSize - BNXE_MEM_CHECK_LEN);
760*d14abf15SRobert Mustacchi i < BNXE_MEM_CHECK_LEN;
761*d14abf15SRobert Mustacchi i += 4, pTmp++)
762*d14abf15SRobert Mustacchi {
763*d14abf15SRobert Mustacchi if (*pTmp != BNXE_MAGIC)
764*d14abf15SRobert Mustacchi {
765*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Trailer overflow! (%p/%u)", pBuf, memSize);
766*d14abf15SRobert Mustacchi BnxeDbgBreak(pUM);
767*d14abf15SRobert Mustacchi }
768*d14abf15SRobert Mustacchi }
769*d14abf15SRobert Mustacchi
770*d14abf15SRobert Mustacchi while (pMem)
771*d14abf15SRobert Mustacchi {
772*d14abf15SRobert Mustacchi if (pBuf == pMem->pBuf)
773*d14abf15SRobert Mustacchi {
774*d14abf15SRobert Mustacchi if (memSize != pMem->size)
775*d14abf15SRobert Mustacchi {
776*d14abf15SRobert Mustacchi /* Uh-Oh! */
777*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Attempt to free memory block with invalid size (%d/%d)",
778*d14abf15SRobert Mustacchi memSize, pMem->size);
779*d14abf15SRobert Mustacchi BnxeDbgBreak(pUM);
780*d14abf15SRobert Mustacchi
781*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
782*d14abf15SRobert Mustacchi return;
783*d14abf15SRobert Mustacchi }
784*d14abf15SRobert Mustacchi
785*d14abf15SRobert Mustacchi d_list_remove_entry(&pUM->memBlockList, D_LINK_CAST(pMem));
786*d14abf15SRobert Mustacchi
787*d14abf15SRobert Mustacchi kmem_free(pBuf, memSize);
788*d14abf15SRobert Mustacchi kmem_free(pMem, sizeof(BnxeMemBlock));
789*d14abf15SRobert Mustacchi
790*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
791*d14abf15SRobert Mustacchi return;
792*d14abf15SRobert Mustacchi }
793*d14abf15SRobert Mustacchi
794*d14abf15SRobert Mustacchi pMem = (BnxeMemBlock *)d_list_next_entry(D_LINK_CAST(pMem));
795*d14abf15SRobert Mustacchi }
796*d14abf15SRobert Mustacchi
797*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
798*d14abf15SRobert Mustacchi }
799*d14abf15SRobert Mustacchi
800*d14abf15SRobert Mustacchi
mm_rt_free_phys_mem(lm_device_t * pDev,u32_t memSize,void * pBuf,lm_address_t pPhysAddr,u8_t cli_idx)801*d14abf15SRobert Mustacchi void mm_rt_free_phys_mem(lm_device_t * pDev,
802*d14abf15SRobert Mustacchi u32_t memSize,
803*d14abf15SRobert Mustacchi void * pBuf,
804*d14abf15SRobert Mustacchi lm_address_t pPhysAddr,
805*d14abf15SRobert Mustacchi u8_t cli_idx)
806*d14abf15SRobert Mustacchi {
807*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
808*d14abf15SRobert Mustacchi BnxeMemDma * pMem;
809*d14abf15SRobert Mustacchi
810*d14abf15SRobert Mustacchi (void)pPhysAddr;
811*d14abf15SRobert Mustacchi (void)cli_idx;
812*d14abf15SRobert Mustacchi
813*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_MEM(pUM);
814*d14abf15SRobert Mustacchi
815*d14abf15SRobert Mustacchi pMem = (BnxeMemDma *)d_list_peek_head(&pUM->memDmaList);
816*d14abf15SRobert Mustacchi
817*d14abf15SRobert Mustacchi while (pMem)
818*d14abf15SRobert Mustacchi {
819*d14abf15SRobert Mustacchi if (pBuf == pMem->pDmaVirt)
820*d14abf15SRobert Mustacchi {
821*d14abf15SRobert Mustacchi if (memSize != pMem->size)
822*d14abf15SRobert Mustacchi {
823*d14abf15SRobert Mustacchi /* Uh-Oh! */
824*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Attempt to free DMA memory with invalid size (%d/%d)",
825*d14abf15SRobert Mustacchi memSize, pMem->size);
826*d14abf15SRobert Mustacchi BnxeDbgBreak(pUM);
827*d14abf15SRobert Mustacchi
828*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
829*d14abf15SRobert Mustacchi return;
830*d14abf15SRobert Mustacchi }
831*d14abf15SRobert Mustacchi
832*d14abf15SRobert Mustacchi d_list_remove_entry(&pUM->memDmaList, D_LINK_CAST(pMem));
833*d14abf15SRobert Mustacchi
834*d14abf15SRobert Mustacchi ddi_dma_unbind_handle(pMem->dmaHandle);
835*d14abf15SRobert Mustacchi ddi_dma_mem_free(&pMem->dmaAccHandle);
836*d14abf15SRobert Mustacchi ddi_dma_free_handle(&pMem->dmaHandle);
837*d14abf15SRobert Mustacchi kmem_free(pMem, sizeof(BnxeMemDma));
838*d14abf15SRobert Mustacchi
839*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
840*d14abf15SRobert Mustacchi return;
841*d14abf15SRobert Mustacchi }
842*d14abf15SRobert Mustacchi
843*d14abf15SRobert Mustacchi pMem = (BnxeMemDma *)d_list_next_entry(D_LINK_CAST(pMem));
844*d14abf15SRobert Mustacchi }
845*d14abf15SRobert Mustacchi
846*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MEM(pUM);
847*d14abf15SRobert Mustacchi }
848*d14abf15SRobert Mustacchi
849*d14abf15SRobert Mustacchi
mm_memset(void * pBuf,u8_t val,u32_t memSize)850*d14abf15SRobert Mustacchi void mm_memset(void * pBuf,
851*d14abf15SRobert Mustacchi u8_t val,
852*d14abf15SRobert Mustacchi u32_t memSize)
853*d14abf15SRobert Mustacchi {
854*d14abf15SRobert Mustacchi memset(pBuf, val, memSize);
855*d14abf15SRobert Mustacchi }
856*d14abf15SRobert Mustacchi
857*d14abf15SRobert Mustacchi
mm_memcpy(void * pDest,const void * pSrc,u32_t memSize)858*d14abf15SRobert Mustacchi void mm_memcpy(void * pDest,
859*d14abf15SRobert Mustacchi const void * pSrc,
860*d14abf15SRobert Mustacchi u32_t memSize)
861*d14abf15SRobert Mustacchi {
862*d14abf15SRobert Mustacchi memcpy(pDest, pSrc, memSize);
863*d14abf15SRobert Mustacchi }
864*d14abf15SRobert Mustacchi
865*d14abf15SRobert Mustacchi
mm_memcmp(void * pBuf1,void * pBuf2,u32_t count)866*d14abf15SRobert Mustacchi u8_t mm_memcmp(void * pBuf1,
867*d14abf15SRobert Mustacchi void * pBuf2,
868*d14abf15SRobert Mustacchi u32_t count)
869*d14abf15SRobert Mustacchi {
870*d14abf15SRobert Mustacchi return (memcmp(pBuf1, pBuf2, count) == 0) ? 1 : 0;
871*d14abf15SRobert Mustacchi }
872*d14abf15SRobert Mustacchi
873*d14abf15SRobert Mustacchi
mm_indicate_tx(lm_device_t * pLM,u32_t idx,s_list_t * packet_list)874*d14abf15SRobert Mustacchi void mm_indicate_tx(lm_device_t * pLM,
875*d14abf15SRobert Mustacchi u32_t idx,
876*d14abf15SRobert Mustacchi s_list_t * packet_list)
877*d14abf15SRobert Mustacchi {
878*d14abf15SRobert Mustacchi BnxeTxPktsReclaim((um_device_t *)pLM, idx, packet_list);
879*d14abf15SRobert Mustacchi }
880*d14abf15SRobert Mustacchi
881*d14abf15SRobert Mustacchi
mm_set_done(lm_device_t * pDev,u32_t cid,void * cookie)882*d14abf15SRobert Mustacchi void mm_set_done(lm_device_t * pDev,
883*d14abf15SRobert Mustacchi u32_t cid,
884*d14abf15SRobert Mustacchi void * cookie)
885*d14abf15SRobert Mustacchi {
886*d14abf15SRobert Mustacchi #if 0
887*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
888*d14abf15SRobert Mustacchi BnxeLogInfo(pUM, "RAMROD on cid %d cmd is done", cid);
889*d14abf15SRobert Mustacchi #else
890*d14abf15SRobert Mustacchi (void)pDev;
891*d14abf15SRobert Mustacchi (void)cid;
892*d14abf15SRobert Mustacchi #endif
893*d14abf15SRobert Mustacchi }
894*d14abf15SRobert Mustacchi
895*d14abf15SRobert Mustacchi
mm_return_sq_pending_command(lm_device_t * pDev,struct sq_pending_command * pPending)896*d14abf15SRobert Mustacchi void mm_return_sq_pending_command(lm_device_t * pDev,
897*d14abf15SRobert Mustacchi struct sq_pending_command * pPending)
898*d14abf15SRobert Mustacchi {
899*d14abf15SRobert Mustacchi /* XXX probably need a memory pool to pull from... */
900*d14abf15SRobert Mustacchi mm_rt_free_mem(pDev, pPending, sizeof(struct sq_pending_command),
901*d14abf15SRobert Mustacchi LM_CLI_IDX_NDIS);
902*d14abf15SRobert Mustacchi }
903*d14abf15SRobert Mustacchi
904*d14abf15SRobert Mustacchi
mm_get_sq_pending_command(lm_device_t * pDev)905*d14abf15SRobert Mustacchi struct sq_pending_command * mm_get_sq_pending_command(lm_device_t * pDev)
906*d14abf15SRobert Mustacchi {
907*d14abf15SRobert Mustacchi /* XXX probably need a memory pool to pull from... */
908*d14abf15SRobert Mustacchi return mm_rt_alloc_mem(pDev, sizeof(struct sq_pending_command),
909*d14abf15SRobert Mustacchi LM_CLI_IDX_NDIS);
910*d14abf15SRobert Mustacchi }
911*d14abf15SRobert Mustacchi
912*d14abf15SRobert Mustacchi
mm_copy_packet_buf(lm_device_t * pDev,lm_packet_t * pLMPkt,u8_t * pMemBuf,u32_t size)913*d14abf15SRobert Mustacchi u32_t mm_copy_packet_buf(lm_device_t * pDev,
914*d14abf15SRobert Mustacchi lm_packet_t * pLMPkt,
915*d14abf15SRobert Mustacchi u8_t * pMemBuf,
916*d14abf15SRobert Mustacchi u32_t size)
917*d14abf15SRobert Mustacchi {
918*d14abf15SRobert Mustacchi //um_device_t * pUM = (um_device_t *)pDev;
919*d14abf15SRobert Mustacchi um_txpacket_t * pTxPkt = (um_txpacket_t *)pLMPkt;
920*d14abf15SRobert Mustacchi mblk_t * pMblk;
921*d14abf15SRobert Mustacchi u32_t copied;
922*d14abf15SRobert Mustacchi u32_t mblkDataLen;
923*d14abf15SRobert Mustacchi u32_t toCopy;
924*d14abf15SRobert Mustacchi
925*d14abf15SRobert Mustacchi pMblk = pTxPkt->pMblk;
926*d14abf15SRobert Mustacchi copied = 0;
927*d14abf15SRobert Mustacchi
928*d14abf15SRobert Mustacchi while (size && pMblk)
929*d14abf15SRobert Mustacchi {
930*d14abf15SRobert Mustacchi mblkDataLen = (pMblk->b_wptr - pMblk->b_rptr);
931*d14abf15SRobert Mustacchi toCopy = (mblkDataLen <= size) ? mblkDataLen : size;
932*d14abf15SRobert Mustacchi
933*d14abf15SRobert Mustacchi bcopy(pMblk->b_rptr, pMemBuf, toCopy);
934*d14abf15SRobert Mustacchi
935*d14abf15SRobert Mustacchi pMemBuf += toCopy;
936*d14abf15SRobert Mustacchi copied += toCopy;
937*d14abf15SRobert Mustacchi size -= toCopy;
938*d14abf15SRobert Mustacchi
939*d14abf15SRobert Mustacchi pMblk = pMblk->b_cont;
940*d14abf15SRobert Mustacchi }
941*d14abf15SRobert Mustacchi
942*d14abf15SRobert Mustacchi return copied;
943*d14abf15SRobert Mustacchi }
944*d14abf15SRobert Mustacchi
945*d14abf15SRobert Mustacchi
mm_fan_failure(lm_device_t * pDev)946*d14abf15SRobert Mustacchi lm_status_t mm_fan_failure(lm_device_t * pDev)
947*d14abf15SRobert Mustacchi {
948*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
949*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "FAN FAILURE!");
950*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
951*d14abf15SRobert Mustacchi }
952*d14abf15SRobert Mustacchi
953*d14abf15SRobert Mustacchi
BnxeLinkStatus(um_device_t * pUM,lm_status_t link,lm_medium_t medium)954*d14abf15SRobert Mustacchi static void BnxeLinkStatus(um_device_t * pUM,
955*d14abf15SRobert Mustacchi lm_status_t link,
956*d14abf15SRobert Mustacchi lm_medium_t medium)
957*d14abf15SRobert Mustacchi {
958*d14abf15SRobert Mustacchi #define TBUF_SIZE 64
959*d14abf15SRobert Mustacchi char tbuf[TBUF_SIZE];
960*d14abf15SRobert Mustacchi char * pDuplex;
961*d14abf15SRobert Mustacchi char * pRxFlow;
962*d14abf15SRobert Mustacchi char * pTxFlow;
963*d14abf15SRobert Mustacchi char * pSpeed;
964*d14abf15SRobert Mustacchi
965*d14abf15SRobert Mustacchi if (link != LM_STATUS_LINK_ACTIVE)
966*d14abf15SRobert Mustacchi {
967*d14abf15SRobert Mustacchi /* reset the link status */
968*d14abf15SRobert Mustacchi pUM->props.link_speed = 0;
969*d14abf15SRobert Mustacchi pUM->props.link_duplex = B_FALSE;
970*d14abf15SRobert Mustacchi pUM->props.link_txpause = B_FALSE;
971*d14abf15SRobert Mustacchi pUM->props.link_rxpause = B_FALSE;
972*d14abf15SRobert Mustacchi pUM->props.uptime = 0;
973*d14abf15SRobert Mustacchi
974*d14abf15SRobert Mustacchi /* reset the link partner status */
975*d14abf15SRobert Mustacchi pUM->remote.link_autoneg = B_FALSE;
976*d14abf15SRobert Mustacchi pUM->remote.param_20000fdx = B_FALSE;
977*d14abf15SRobert Mustacchi pUM->remote.param_10000fdx = B_FALSE;
978*d14abf15SRobert Mustacchi pUM->remote.param_2500fdx = B_FALSE;
979*d14abf15SRobert Mustacchi pUM->remote.param_1000fdx = B_FALSE;
980*d14abf15SRobert Mustacchi pUM->remote.param_100fdx = B_FALSE;
981*d14abf15SRobert Mustacchi pUM->remote.param_100hdx = B_FALSE;
982*d14abf15SRobert Mustacchi pUM->remote.param_10fdx = B_FALSE;
983*d14abf15SRobert Mustacchi pUM->remote.param_10hdx = B_FALSE;
984*d14abf15SRobert Mustacchi pUM->remote.param_txpause = B_FALSE;
985*d14abf15SRobert Mustacchi pUM->remote.param_rxpause = B_FALSE;
986*d14abf15SRobert Mustacchi
987*d14abf15SRobert Mustacchi BnxeLogInfo(pUM, "Link Down");
988*d14abf15SRobert Mustacchi return;
989*d14abf15SRobert Mustacchi }
990*d14abf15SRobert Mustacchi
991*d14abf15SRobert Mustacchi pUM->props.uptime = ddi_get_time();
992*d14abf15SRobert Mustacchi
993*d14abf15SRobert Mustacchi if (GET_MEDIUM_DUPLEX(medium) == LM_MEDIUM_HALF_DUPLEX)
994*d14abf15SRobert Mustacchi {
995*d14abf15SRobert Mustacchi pDuplex = "Half";
996*d14abf15SRobert Mustacchi pUM->props.link_duplex = B_FALSE;
997*d14abf15SRobert Mustacchi }
998*d14abf15SRobert Mustacchi else
999*d14abf15SRobert Mustacchi {
1000*d14abf15SRobert Mustacchi pDuplex = "Full";
1001*d14abf15SRobert Mustacchi pUM->props.link_duplex = B_TRUE;
1002*d14abf15SRobert Mustacchi }
1003*d14abf15SRobert Mustacchi
1004*d14abf15SRobert Mustacchi if (pUM->lm_dev.vars.flow_control & LM_FLOW_CONTROL_RECEIVE_PAUSE)
1005*d14abf15SRobert Mustacchi {
1006*d14abf15SRobert Mustacchi pRxFlow = "ON";
1007*d14abf15SRobert Mustacchi pUM->props.link_rxpause = B_TRUE;
1008*d14abf15SRobert Mustacchi }
1009*d14abf15SRobert Mustacchi else
1010*d14abf15SRobert Mustacchi {
1011*d14abf15SRobert Mustacchi pRxFlow = "OFF";
1012*d14abf15SRobert Mustacchi pUM->props.link_rxpause = B_FALSE;
1013*d14abf15SRobert Mustacchi }
1014*d14abf15SRobert Mustacchi
1015*d14abf15SRobert Mustacchi if (pUM->lm_dev.vars.flow_control & LM_FLOW_CONTROL_TRANSMIT_PAUSE)
1016*d14abf15SRobert Mustacchi {
1017*d14abf15SRobert Mustacchi pTxFlow = "ON";
1018*d14abf15SRobert Mustacchi pUM->props.link_txpause = B_TRUE;
1019*d14abf15SRobert Mustacchi }
1020*d14abf15SRobert Mustacchi else
1021*d14abf15SRobert Mustacchi {
1022*d14abf15SRobert Mustacchi pTxFlow = "OFF";
1023*d14abf15SRobert Mustacchi pUM->props.link_txpause = B_FALSE;
1024*d14abf15SRobert Mustacchi }
1025*d14abf15SRobert Mustacchi
1026*d14abf15SRobert Mustacchi #if 0
1027*d14abf15SRobert Mustacchi if (pUM->curcfg.lnkcfg.link_autoneg == B_TRUE)
1028*d14abf15SRobert Mustacchi {
1029*d14abf15SRobert Mustacchi BnxeUpdateLpCap(pUM);
1030*d14abf15SRobert Mustacchi }
1031*d14abf15SRobert Mustacchi #endif
1032*d14abf15SRobert Mustacchi
1033*d14abf15SRobert Mustacchi switch (GET_MEDIUM_SPEED(medium))
1034*d14abf15SRobert Mustacchi {
1035*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_10MBPS:
1036*d14abf15SRobert Mustacchi
1037*d14abf15SRobert Mustacchi pUM->props.link_speed = 10;
1038*d14abf15SRobert Mustacchi pSpeed = "10Mb";
1039*d14abf15SRobert Mustacchi break;
1040*d14abf15SRobert Mustacchi
1041*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_100MBPS:
1042*d14abf15SRobert Mustacchi
1043*d14abf15SRobert Mustacchi pUM->props.link_speed = 100;
1044*d14abf15SRobert Mustacchi pSpeed = "100Mb";
1045*d14abf15SRobert Mustacchi break;
1046*d14abf15SRobert Mustacchi
1047*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_1000MBPS:
1048*d14abf15SRobert Mustacchi
1049*d14abf15SRobert Mustacchi pUM->props.link_speed = 1000;
1050*d14abf15SRobert Mustacchi pSpeed = "1Gb";
1051*d14abf15SRobert Mustacchi break;
1052*d14abf15SRobert Mustacchi
1053*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_2500MBPS:
1054*d14abf15SRobert Mustacchi
1055*d14abf15SRobert Mustacchi pUM->props.link_speed = 2500;
1056*d14abf15SRobert Mustacchi pSpeed = "2.5Gb";
1057*d14abf15SRobert Mustacchi break;
1058*d14abf15SRobert Mustacchi
1059*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_10GBPS:
1060*d14abf15SRobert Mustacchi
1061*d14abf15SRobert Mustacchi pUM->props.link_speed = 10000;
1062*d14abf15SRobert Mustacchi pSpeed = "10Gb";
1063*d14abf15SRobert Mustacchi break;
1064*d14abf15SRobert Mustacchi
1065*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_12GBPS:
1066*d14abf15SRobert Mustacchi
1067*d14abf15SRobert Mustacchi pUM->props.link_speed = 12000;
1068*d14abf15SRobert Mustacchi pSpeed = "12Gb";
1069*d14abf15SRobert Mustacchi break;
1070*d14abf15SRobert Mustacchi
1071*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_12_5GBPS:
1072*d14abf15SRobert Mustacchi
1073*d14abf15SRobert Mustacchi pUM->props.link_speed = 12500;
1074*d14abf15SRobert Mustacchi pSpeed = "12.5Gb";
1075*d14abf15SRobert Mustacchi break;
1076*d14abf15SRobert Mustacchi
1077*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_13GBPS:
1078*d14abf15SRobert Mustacchi
1079*d14abf15SRobert Mustacchi pUM->props.link_speed = 13000;
1080*d14abf15SRobert Mustacchi pSpeed = "13Gb";
1081*d14abf15SRobert Mustacchi break;
1082*d14abf15SRobert Mustacchi
1083*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_15GBPS:
1084*d14abf15SRobert Mustacchi
1085*d14abf15SRobert Mustacchi pUM->props.link_speed = 15000;
1086*d14abf15SRobert Mustacchi pSpeed = "15Gb";
1087*d14abf15SRobert Mustacchi break;
1088*d14abf15SRobert Mustacchi
1089*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_16GBPS:
1090*d14abf15SRobert Mustacchi
1091*d14abf15SRobert Mustacchi pUM->props.link_speed = 16000;
1092*d14abf15SRobert Mustacchi pSpeed = "16Gb";
1093*d14abf15SRobert Mustacchi break;
1094*d14abf15SRobert Mustacchi
1095*d14abf15SRobert Mustacchi case LM_MEDIUM_SPEED_20GBPS:
1096*d14abf15SRobert Mustacchi
1097*d14abf15SRobert Mustacchi pUM->props.link_speed = 20000;
1098*d14abf15SRobert Mustacchi pSpeed = "20Gb";
1099*d14abf15SRobert Mustacchi break;
1100*d14abf15SRobert Mustacchi
1101*d14abf15SRobert Mustacchi default:
1102*d14abf15SRobert Mustacchi
1103*d14abf15SRobert Mustacchi if ((GET_MEDIUM_SPEED(medium) >= LM_MEDIUM_SPEED_SEQ_START) &&
1104*d14abf15SRobert Mustacchi (GET_MEDIUM_SPEED(medium) <= LM_MEDIUM_SPEED_SEQ_END))
1105*d14abf15SRobert Mustacchi {
1106*d14abf15SRobert Mustacchi pUM->props.link_speed = (((GET_MEDIUM_SPEED(medium) >> 8) -
1107*d14abf15SRobert Mustacchi (LM_MEDIUM_SPEED_SEQ_START >> 8) +
1108*d14abf15SRobert Mustacchi 1) * 100);
1109*d14abf15SRobert Mustacchi snprintf(tbuf, TBUF_SIZE, "%u", pUM->props.link_speed);
1110*d14abf15SRobert Mustacchi pSpeed = tbuf;
1111*d14abf15SRobert Mustacchi break;
1112*d14abf15SRobert Mustacchi }
1113*d14abf15SRobert Mustacchi
1114*d14abf15SRobert Mustacchi pUM->props.link_speed = 0;
1115*d14abf15SRobert Mustacchi pSpeed = "";
1116*d14abf15SRobert Mustacchi
1117*d14abf15SRobert Mustacchi break;
1118*d14abf15SRobert Mustacchi }
1119*d14abf15SRobert Mustacchi
1120*d14abf15SRobert Mustacchi if (*pSpeed == 0)
1121*d14abf15SRobert Mustacchi {
1122*d14abf15SRobert Mustacchi BnxeLogInfo(pUM, "%s Duplex Rx Flow %s Tx Flow %s Link Up",
1123*d14abf15SRobert Mustacchi pDuplex, pRxFlow, pTxFlow);
1124*d14abf15SRobert Mustacchi }
1125*d14abf15SRobert Mustacchi else
1126*d14abf15SRobert Mustacchi {
1127*d14abf15SRobert Mustacchi BnxeLogInfo(pUM, "%s %s Duplex Rx Flow %s Tx Flow %s Link Up",
1128*d14abf15SRobert Mustacchi pSpeed, pDuplex, pRxFlow, pTxFlow);
1129*d14abf15SRobert Mustacchi }
1130*d14abf15SRobert Mustacchi }
1131*d14abf15SRobert Mustacchi
1132*d14abf15SRobert Mustacchi
mm_indicate_link(lm_device_t * pLM,lm_status_t link,lm_medium_t medium)1133*d14abf15SRobert Mustacchi void mm_indicate_link(lm_device_t * pLM,
1134*d14abf15SRobert Mustacchi lm_status_t link,
1135*d14abf15SRobert Mustacchi lm_medium_t medium)
1136*d14abf15SRobert Mustacchi {
1137*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pLM;
1138*d14abf15SRobert Mustacchi
1139*d14abf15SRobert Mustacchi /* ignore link status if it has not changed since the last indicate */
1140*d14abf15SRobert Mustacchi if ((pUM->devParams.lastIndLink == link) &&
1141*d14abf15SRobert Mustacchi (pUM->devParams.lastIndMedium == medium))
1142*d14abf15SRobert Mustacchi {
1143*d14abf15SRobert Mustacchi return;
1144*d14abf15SRobert Mustacchi }
1145*d14abf15SRobert Mustacchi
1146*d14abf15SRobert Mustacchi pUM->devParams.lastIndLink = link;
1147*d14abf15SRobert Mustacchi pUM->devParams.lastIndMedium = medium;
1148*d14abf15SRobert Mustacchi
1149*d14abf15SRobert Mustacchi BnxeLinkStatus(pUM, link, medium);
1150*d14abf15SRobert Mustacchi
1151*d14abf15SRobert Mustacchi if (CLIENT_BOUND(pUM, LM_CLI_IDX_NDIS))
1152*d14abf15SRobert Mustacchi {
1153*d14abf15SRobert Mustacchi BnxeGldLink(pUM, (link == LM_STATUS_LINK_ACTIVE) ?
1154*d14abf15SRobert Mustacchi LINK_STATE_UP : LINK_STATE_DOWN);
1155*d14abf15SRobert Mustacchi }
1156*d14abf15SRobert Mustacchi
1157*d14abf15SRobert Mustacchi if (CLIENT_BOUND(pUM, LM_CLI_IDX_FCOE))
1158*d14abf15SRobert Mustacchi {
1159*d14abf15SRobert Mustacchi if (pUM->fcoe.pDev == NULL)
1160*d14abf15SRobert Mustacchi {
1161*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "FCoE Client bound and pDev is NULL (LINK STATUS failed!) %s@%s",
1162*d14abf15SRobert Mustacchi BNXEF_NAME, ddi_get_name_addr(pUM->pDev));
1163*d14abf15SRobert Mustacchi }
1164*d14abf15SRobert Mustacchi else if (pUM->fcoe.bind.cliCtl == NULL)
1165*d14abf15SRobert Mustacchi {
1166*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "FCoE Client bound and cliCtl is NULL (LINK STATUS failed!) %s@%s",
1167*d14abf15SRobert Mustacchi BNXEF_NAME, ddi_get_name_addr(pUM->pDev));
1168*d14abf15SRobert Mustacchi }
1169*d14abf15SRobert Mustacchi else
1170*d14abf15SRobert Mustacchi {
1171*d14abf15SRobert Mustacchi pUM->fcoe.bind.cliCtl(pUM->fcoe.pDev,
1172*d14abf15SRobert Mustacchi (link == LM_STATUS_LINK_ACTIVE) ?
1173*d14abf15SRobert Mustacchi CLI_CTL_LINK_UP : CLI_CTL_LINK_DOWN,
1174*d14abf15SRobert Mustacchi NULL,
1175*d14abf15SRobert Mustacchi 0);
1176*d14abf15SRobert Mustacchi }
1177*d14abf15SRobert Mustacchi }
1178*d14abf15SRobert Mustacchi }
1179*d14abf15SRobert Mustacchi
1180*d14abf15SRobert Mustacchi
mm_schedule_task(lm_device_t * pDev,u32_t delay_ms,lm_task_cb_t task,void * param)1181*d14abf15SRobert Mustacchi lm_status_t mm_schedule_task(lm_device_t * pDev,
1182*d14abf15SRobert Mustacchi u32_t delay_ms,
1183*d14abf15SRobert Mustacchi lm_task_cb_t task,
1184*d14abf15SRobert Mustacchi void * param)
1185*d14abf15SRobert Mustacchi {
1186*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
1187*d14abf15SRobert Mustacchi
1188*d14abf15SRobert Mustacchi BnxeWorkQueueAddDelayNoCopy(pUM, (void (*)(um_device_t *, void *))task, param, delay_ms);
1189*d14abf15SRobert Mustacchi
1190*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
1191*d14abf15SRobert Mustacchi }
1192*d14abf15SRobert Mustacchi
1193*d14abf15SRobert Mustacchi
mm_register_lpme(lm_device_t * pDev,lm_generic_workitem_function * func,u8_t b_fw_access,u8_t b_queue_for_fw)1194*d14abf15SRobert Mustacchi lm_status_t mm_register_lpme(lm_device_t * pDev,
1195*d14abf15SRobert Mustacchi lm_generic_workitem_function * func,
1196*d14abf15SRobert Mustacchi u8_t b_fw_access,
1197*d14abf15SRobert Mustacchi u8_t b_queue_for_fw)
1198*d14abf15SRobert Mustacchi {
1199*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
1200*d14abf15SRobert Mustacchi
1201*d14abf15SRobert Mustacchi (void)b_fw_access;
1202*d14abf15SRobert Mustacchi (void)b_queue_for_fw;
1203*d14abf15SRobert Mustacchi
1204*d14abf15SRobert Mustacchi BnxeWorkQueueAddGeneric(pUM, (void (*)(um_device_t *))func);
1205*d14abf15SRobert Mustacchi
1206*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
1207*d14abf15SRobert Mustacchi }
1208*d14abf15SRobert Mustacchi
1209*d14abf15SRobert Mustacchi
MM_ACQUIRE_SPQ_LOCK_IMP(lm_device_t * pDev)1210*d14abf15SRobert Mustacchi void MM_ACQUIRE_SPQ_LOCK_IMP(lm_device_t * pDev)
1211*d14abf15SRobert Mustacchi {
1212*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_SPQ((um_device_t *)pDev);
1213*d14abf15SRobert Mustacchi }
1214*d14abf15SRobert Mustacchi
1215*d14abf15SRobert Mustacchi
MM_RELEASE_SPQ_LOCK_IMP(lm_device_t * pDev)1216*d14abf15SRobert Mustacchi void MM_RELEASE_SPQ_LOCK_IMP(lm_device_t * pDev)
1217*d14abf15SRobert Mustacchi {
1218*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_SPQ((um_device_t *)pDev);
1219*d14abf15SRobert Mustacchi }
1220*d14abf15SRobert Mustacchi
1221*d14abf15SRobert Mustacchi
MM_ACQUIRE_SPQ_LOCK_DPC_IMP(lm_device_t * pDev)1222*d14abf15SRobert Mustacchi void MM_ACQUIRE_SPQ_LOCK_DPC_IMP(lm_device_t * pDev)
1223*d14abf15SRobert Mustacchi {
1224*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_SPQ((um_device_t *)pDev);
1225*d14abf15SRobert Mustacchi }
1226*d14abf15SRobert Mustacchi
1227*d14abf15SRobert Mustacchi
MM_RELEASE_SPQ_LOCK_DPC_IMP(lm_device_t * pDev)1228*d14abf15SRobert Mustacchi void MM_RELEASE_SPQ_LOCK_DPC_IMP(lm_device_t * pDev)
1229*d14abf15SRobert Mustacchi {
1230*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_SPQ((um_device_t *)pDev);
1231*d14abf15SRobert Mustacchi }
1232*d14abf15SRobert Mustacchi
1233*d14abf15SRobert Mustacchi
MM_ACQUIRE_CID_LOCK_IMP(lm_device_t * pDev)1234*d14abf15SRobert Mustacchi void MM_ACQUIRE_CID_LOCK_IMP(lm_device_t * pDev)
1235*d14abf15SRobert Mustacchi {
1236*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_CID((um_device_t *)pDev);
1237*d14abf15SRobert Mustacchi }
1238*d14abf15SRobert Mustacchi
1239*d14abf15SRobert Mustacchi
MM_RELEASE_CID_LOCK_IMP(lm_device_t * pDev)1240*d14abf15SRobert Mustacchi void MM_RELEASE_CID_LOCK_IMP(lm_device_t * pDev)
1241*d14abf15SRobert Mustacchi {
1242*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_CID((um_device_t *)pDev);
1243*d14abf15SRobert Mustacchi }
1244*d14abf15SRobert Mustacchi
1245*d14abf15SRobert Mustacchi
MM_ACQUIRE_REQUEST_LOCK_IMP(lm_device_t * pDev)1246*d14abf15SRobert Mustacchi void MM_ACQUIRE_REQUEST_LOCK_IMP(lm_device_t * pDev)
1247*d14abf15SRobert Mustacchi {
1248*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_RRREQ((um_device_t *)pDev);
1249*d14abf15SRobert Mustacchi }
1250*d14abf15SRobert Mustacchi
1251*d14abf15SRobert Mustacchi
MM_RELEASE_REQUEST_LOCK_IMP(lm_device_t * pDev)1252*d14abf15SRobert Mustacchi void MM_RELEASE_REQUEST_LOCK_IMP(lm_device_t * pDev)
1253*d14abf15SRobert Mustacchi {
1254*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_RRREQ((um_device_t *)pDev);
1255*d14abf15SRobert Mustacchi }
1256*d14abf15SRobert Mustacchi
1257*d14abf15SRobert Mustacchi
MM_ACQUIRE_PHY_LOCK_IMP(lm_device_t * pDev)1258*d14abf15SRobert Mustacchi void MM_ACQUIRE_PHY_LOCK_IMP(lm_device_t * pDev)
1259*d14abf15SRobert Mustacchi {
1260*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_PHY((um_device_t *)pDev);
1261*d14abf15SRobert Mustacchi }
1262*d14abf15SRobert Mustacchi
1263*d14abf15SRobert Mustacchi
MM_RELEASE_PHY_LOCK_IMP(lm_device_t * pDev)1264*d14abf15SRobert Mustacchi void MM_RELEASE_PHY_LOCK_IMP(lm_device_t * pDev)
1265*d14abf15SRobert Mustacchi {
1266*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_PHY((um_device_t *)pDev);
1267*d14abf15SRobert Mustacchi }
1268*d14abf15SRobert Mustacchi
1269*d14abf15SRobert Mustacchi
MM_ACQUIRE_PHY_LOCK_DPC_IMP(lm_device_t * pDev)1270*d14abf15SRobert Mustacchi void MM_ACQUIRE_PHY_LOCK_DPC_IMP(lm_device_t * pDev)
1271*d14abf15SRobert Mustacchi {
1272*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_PHY((um_device_t *)pDev);
1273*d14abf15SRobert Mustacchi }
1274*d14abf15SRobert Mustacchi
1275*d14abf15SRobert Mustacchi
MM_RELEASE_PHY_LOCK_DPC_IMP(lm_device_t * pDev)1276*d14abf15SRobert Mustacchi void MM_RELEASE_PHY_LOCK_DPC_IMP(lm_device_t * pDev)
1277*d14abf15SRobert Mustacchi {
1278*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_PHY((um_device_t *)pDev);
1279*d14abf15SRobert Mustacchi }
1280*d14abf15SRobert Mustacchi
1281*d14abf15SRobert Mustacchi
mm_init_lock(lm_device_t * pDev,mm_spin_lock_t * spinlock)1282*d14abf15SRobert Mustacchi void mm_init_lock(lm_device_t * pDev,
1283*d14abf15SRobert Mustacchi mm_spin_lock_t * spinlock)
1284*d14abf15SRobert Mustacchi {
1285*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
1286*d14abf15SRobert Mustacchi
1287*d14abf15SRobert Mustacchi mutex_init(spinlock, NULL,
1288*d14abf15SRobert Mustacchi MUTEX_DRIVER, DDI_INTR_PRI(pUM->intrPriority));
1289*d14abf15SRobert Mustacchi }
1290*d14abf15SRobert Mustacchi
1291*d14abf15SRobert Mustacchi
mm_acquire_lock(mm_spin_lock_t * spinlock)1292*d14abf15SRobert Mustacchi lm_status_t mm_acquire_lock(mm_spin_lock_t * spinlock)
1293*d14abf15SRobert Mustacchi {
1294*d14abf15SRobert Mustacchi if (spinlock == NULL)
1295*d14abf15SRobert Mustacchi {
1296*d14abf15SRobert Mustacchi return LM_STATUS_INVALID_PARAMETER;
1297*d14abf15SRobert Mustacchi }
1298*d14abf15SRobert Mustacchi
1299*d14abf15SRobert Mustacchi mutex_enter(spinlock);
1300*d14abf15SRobert Mustacchi
1301*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
1302*d14abf15SRobert Mustacchi }
1303*d14abf15SRobert Mustacchi
1304*d14abf15SRobert Mustacchi
mm_release_lock(mm_spin_lock_t * spinlock)1305*d14abf15SRobert Mustacchi lm_status_t mm_release_lock(mm_spin_lock_t * spinlock)
1306*d14abf15SRobert Mustacchi {
1307*d14abf15SRobert Mustacchi if (spinlock == NULL)
1308*d14abf15SRobert Mustacchi {
1309*d14abf15SRobert Mustacchi return LM_STATUS_INVALID_PARAMETER;
1310*d14abf15SRobert Mustacchi }
1311*d14abf15SRobert Mustacchi
1312*d14abf15SRobert Mustacchi mutex_exit(spinlock);
1313*d14abf15SRobert Mustacchi
1314*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
1315*d14abf15SRobert Mustacchi }
1316*d14abf15SRobert Mustacchi
1317*d14abf15SRobert Mustacchi
MM_ACQUIRE_MCP_LOCK_IMP(lm_device_t * pDev)1318*d14abf15SRobert Mustacchi void MM_ACQUIRE_MCP_LOCK_IMP(lm_device_t * pDev)
1319*d14abf15SRobert Mustacchi {
1320*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_MCP((um_device_t *)pDev);
1321*d14abf15SRobert Mustacchi }
1322*d14abf15SRobert Mustacchi
1323*d14abf15SRobert Mustacchi
MM_RELEASE_MCP_LOCK_IMP(lm_device_t * pDev)1324*d14abf15SRobert Mustacchi void MM_RELEASE_MCP_LOCK_IMP(lm_device_t * pDev)
1325*d14abf15SRobert Mustacchi {
1326*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_MCP((um_device_t *)pDev);
1327*d14abf15SRobert Mustacchi }
1328*d14abf15SRobert Mustacchi
1329*d14abf15SRobert Mustacchi
MM_ACQUIRE_ISLES_CONTROL_LOCK_IMP(lm_device_t * pDev)1330*d14abf15SRobert Mustacchi void MM_ACQUIRE_ISLES_CONTROL_LOCK_IMP(lm_device_t * pDev)
1331*d14abf15SRobert Mustacchi {
1332*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_ISLES_CONTROL((um_device_t *)pDev);
1333*d14abf15SRobert Mustacchi }
1334*d14abf15SRobert Mustacchi
1335*d14abf15SRobert Mustacchi
MM_RELEASE_ISLES_CONTROL_LOCK_IMP(lm_device_t * pDev)1336*d14abf15SRobert Mustacchi void MM_RELEASE_ISLES_CONTROL_LOCK_IMP(lm_device_t * pDev)
1337*d14abf15SRobert Mustacchi {
1338*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_ISLES_CONTROL((um_device_t *)pDev);
1339*d14abf15SRobert Mustacchi }
1340*d14abf15SRobert Mustacchi
1341*d14abf15SRobert Mustacchi
MM_ACQUIRE_ISLES_CONTROL_LOCK_DPC_IMP(lm_device_t * pDev)1342*d14abf15SRobert Mustacchi void MM_ACQUIRE_ISLES_CONTROL_LOCK_DPC_IMP(lm_device_t * pDev)
1343*d14abf15SRobert Mustacchi {
1344*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_ISLES_CONTROL((um_device_t *)pDev);
1345*d14abf15SRobert Mustacchi }
1346*d14abf15SRobert Mustacchi
1347*d14abf15SRobert Mustacchi
MM_RELEASE_ISLES_CONTROL_LOCK_DPC_IMP(lm_device_t * pDev)1348*d14abf15SRobert Mustacchi void MM_RELEASE_ISLES_CONTROL_LOCK_DPC_IMP(lm_device_t * pDev)
1349*d14abf15SRobert Mustacchi {
1350*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_ISLES_CONTROL((um_device_t *)pDev);
1351*d14abf15SRobert Mustacchi }
1352*d14abf15SRobert Mustacchi
1353*d14abf15SRobert Mustacchi
MM_ACQUIRE_IND_REG_LOCK_IMP(lm_device_t * pDev)1354*d14abf15SRobert Mustacchi void MM_ACQUIRE_IND_REG_LOCK_IMP(lm_device_t * pDev)
1355*d14abf15SRobert Mustacchi {
1356*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_IND((um_device_t *)pDev);
1357*d14abf15SRobert Mustacchi }
1358*d14abf15SRobert Mustacchi
1359*d14abf15SRobert Mustacchi
MM_RELEASE_IND_REG_LOCK_IMP(lm_device_t * pDev)1360*d14abf15SRobert Mustacchi void MM_RELEASE_IND_REG_LOCK_IMP(lm_device_t * pDev)
1361*d14abf15SRobert Mustacchi {
1362*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_IND((um_device_t *)pDev);
1363*d14abf15SRobert Mustacchi }
1364*d14abf15SRobert Mustacchi
1365*d14abf15SRobert Mustacchi
MM_ACQUIRE_LOADER_LOCK_IMP()1366*d14abf15SRobert Mustacchi void MM_ACQUIRE_LOADER_LOCK_IMP()
1367*d14abf15SRobert Mustacchi {
1368*d14abf15SRobert Mustacchi mutex_enter(&bnxeLoaderMutex);
1369*d14abf15SRobert Mustacchi }
1370*d14abf15SRobert Mustacchi
1371*d14abf15SRobert Mustacchi
MM_RELEASE_LOADER_LOCK_IMP()1372*d14abf15SRobert Mustacchi void MM_RELEASE_LOADER_LOCK_IMP()
1373*d14abf15SRobert Mustacchi {
1374*d14abf15SRobert Mustacchi mutex_exit(&bnxeLoaderMutex);
1375*d14abf15SRobert Mustacchi }
1376*d14abf15SRobert Mustacchi
1377*d14abf15SRobert Mustacchi
MM_ACQUIRE_SP_REQ_MGR_LOCK_IMP(lm_device_t * pDev)1378*d14abf15SRobert Mustacchi void MM_ACQUIRE_SP_REQ_MGR_LOCK_IMP(lm_device_t * pDev)
1379*d14abf15SRobert Mustacchi {
1380*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_SPREQ((um_device_t *)pDev);
1381*d14abf15SRobert Mustacchi }
1382*d14abf15SRobert Mustacchi
1383*d14abf15SRobert Mustacchi
MM_RELEASE_SP_REQ_MGR_LOCK_IMP(lm_device_t * pDev)1384*d14abf15SRobert Mustacchi void MM_RELEASE_SP_REQ_MGR_LOCK_IMP(lm_device_t * pDev)
1385*d14abf15SRobert Mustacchi {
1386*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_SPREQ((um_device_t *)pDev);
1387*d14abf15SRobert Mustacchi }
1388*d14abf15SRobert Mustacchi
1389*d14abf15SRobert Mustacchi
MM_ACQUIRE_SB_LOCK_IMP(lm_device_t * pDev,u8_t sb_idx)1390*d14abf15SRobert Mustacchi void MM_ACQUIRE_SB_LOCK_IMP(lm_device_t * pDev, u8_t sb_idx)
1391*d14abf15SRobert Mustacchi {
1392*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_SB((um_device_t *)pDev, sb_idx);
1393*d14abf15SRobert Mustacchi }
1394*d14abf15SRobert Mustacchi
1395*d14abf15SRobert Mustacchi
MM_RELEASE_SB_LOCK_IMP(lm_device_t * pDev,u8_t sb_idx)1396*d14abf15SRobert Mustacchi void MM_RELEASE_SB_LOCK_IMP(lm_device_t * pDev, u8_t sb_idx)
1397*d14abf15SRobert Mustacchi {
1398*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_SB((um_device_t *)pDev, sb_idx);
1399*d14abf15SRobert Mustacchi }
1400*d14abf15SRobert Mustacchi
1401*d14abf15SRobert Mustacchi
MM_ACQUIRE_ETH_CON_LOCK_IMP(lm_device_t * pDev)1402*d14abf15SRobert Mustacchi void MM_ACQUIRE_ETH_CON_LOCK_IMP(lm_device_t * pDev)
1403*d14abf15SRobert Mustacchi {
1404*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_ETH_CON((um_device_t *)pDev);
1405*d14abf15SRobert Mustacchi }
1406*d14abf15SRobert Mustacchi
1407*d14abf15SRobert Mustacchi
MM_RELEASE_ETH_CON_LOCK_IMP(lm_device_t * pDev)1408*d14abf15SRobert Mustacchi void MM_RELEASE_ETH_CON_LOCK_IMP(lm_device_t * pDev)
1409*d14abf15SRobert Mustacchi {
1410*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_ETH_CON((um_device_t *)pDev);
1411*d14abf15SRobert Mustacchi }
1412*d14abf15SRobert Mustacchi
1413*d14abf15SRobert Mustacchi
mm_crc32(unsigned char * address,unsigned int size,unsigned int crc)1414*d14abf15SRobert Mustacchi unsigned int mm_crc32(unsigned char * address,
1415*d14abf15SRobert Mustacchi unsigned int size,
1416*d14abf15SRobert Mustacchi unsigned int crc)
1417*d14abf15SRobert Mustacchi {
1418*d14abf15SRobert Mustacchi return 0;
1419*d14abf15SRobert Mustacchi }
1420*d14abf15SRobert Mustacchi
1421*d14abf15SRobert Mustacchi
mm_crc16(unsigned char * address,unsigned int size,unsigned short crc)1422*d14abf15SRobert Mustacchi unsigned short mm_crc16(unsigned char * address,
1423*d14abf15SRobert Mustacchi unsigned int size,
1424*d14abf15SRobert Mustacchi unsigned short crc)
1425*d14abf15SRobert Mustacchi {
1426*d14abf15SRobert Mustacchi return 0;
1427*d14abf15SRobert Mustacchi }
1428*d14abf15SRobert Mustacchi
1429*d14abf15SRobert Mustacchi
mm_event_log_generic_arg_fwd(lm_device_t * pDev,const lm_log_id_t lm_log_id,va_list argp)1430*d14abf15SRobert Mustacchi lm_status_t mm_event_log_generic_arg_fwd(lm_device_t * pDev,
1431*d14abf15SRobert Mustacchi const lm_log_id_t lm_log_id,
1432*d14abf15SRobert Mustacchi va_list argp)
1433*d14abf15SRobert Mustacchi {
1434*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
1435*d14abf15SRobert Mustacchi u8_t port = 0 ;
1436*d14abf15SRobert Mustacchi char * sz_vendor_name = NULL;
1437*d14abf15SRobert Mustacchi char * sz_vendor_pn = NULL;
1438*d14abf15SRobert Mustacchi
1439*d14abf15SRobert Mustacchi switch (lm_log_id)
1440*d14abf15SRobert Mustacchi {
1441*d14abf15SRobert Mustacchi case LM_LOG_ID_FAN_FAILURE: // fan failure detected
1442*d14abf15SRobert Mustacchi
1443*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "FAN FAILURE!");
1444*d14abf15SRobert Mustacchi break;
1445*d14abf15SRobert Mustacchi
1446*d14abf15SRobert Mustacchi case LM_LOG_ID_UNQUAL_IO_MODULE: // SFP+ unqualified io module
1447*d14abf15SRobert Mustacchi /*
1448*d14abf15SRobert Mustacchi * expected parameters:
1449*d14abf15SRobert Mustacchi * u8 port, const char * vendor_name, const char * vendor_pn
1450*d14abf15SRobert Mustacchi */
1451*d14abf15SRobert Mustacchi port = va_arg(argp, int);
1452*d14abf15SRobert Mustacchi sz_vendor_name = va_arg(argp, char*);
1453*d14abf15SRobert Mustacchi sz_vendor_pn = va_arg(argp, char*);
1454*d14abf15SRobert Mustacchi
1455*d14abf15SRobert Mustacchi BnxeLogInfo(pUM, "Unqualified IO Module: %s %s (port=%d)",
1456*d14abf15SRobert Mustacchi sz_vendor_name, sz_vendor_pn, port);
1457*d14abf15SRobert Mustacchi break;
1458*d14abf15SRobert Mustacchi
1459*d14abf15SRobert Mustacchi case LM_LOG_ID_OVER_CURRENT: // SFP+ over current power
1460*d14abf15SRobert Mustacchi /*
1461*d14abf15SRobert Mustacchi * expected parametrs:
1462*d14abf15SRobert Mustacchi * u8 port
1463*d14abf15SRobert Mustacchi */
1464*d14abf15SRobert Mustacchi port = va_arg(argp, int);
1465*d14abf15SRobert Mustacchi
1466*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "SFP+ over current, power failure! (port=%d)", port);
1467*d14abf15SRobert Mustacchi break;
1468*d14abf15SRobert Mustacchi
1469*d14abf15SRobert Mustacchi case LM_LOG_ID_NO_10G_SUPPORT: // 10g speed is requested but not supported
1470*d14abf15SRobert Mustacchi /*
1471*d14abf15SRobert Mustacchi * expected parametrs:
1472*d14abf15SRobert Mustacchi * u8 port
1473*d14abf15SRobert Mustacchi */
1474*d14abf15SRobert Mustacchi port = va_arg(argp, int);
1475*d14abf15SRobert Mustacchi
1476*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "10Gb speed not supported! (port=%d)", port);
1477*d14abf15SRobert Mustacchi break;
1478*d14abf15SRobert Mustacchi
1479*d14abf15SRobert Mustacchi case LM_LOG_ID_PHY_UNINITIALIZED:
1480*d14abf15SRobert Mustacchi /*
1481*d14abf15SRobert Mustacchi * expected parametrs:
1482*d14abf15SRobert Mustacchi * u8 port
1483*d14abf15SRobert Mustacchi */
1484*d14abf15SRobert Mustacchi port = va_arg(argp, int);
1485*d14abf15SRobert Mustacchi
1486*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "PHY uninitialized! (port=%d)", port);
1487*d14abf15SRobert Mustacchi break;
1488*d14abf15SRobert Mustacchi
1489*d14abf15SRobert Mustacchi case LM_LOG_ID_MDIO_ACCESS_TIMEOUT:
1490*d14abf15SRobert Mustacchi
1491*d14abf15SRobert Mustacchi #define MM_PORT_NUM(pdev) \
1492*d14abf15SRobert Mustacchi (CHIP_PORT_MODE(pdev) == LM_CHIP_PORT_MODE_4) ? \
1493*d14abf15SRobert Mustacchi (PATH_ID(pdev) + (2 * PORT_ID(pdev))) : \
1494*d14abf15SRobert Mustacchi (PATH_ID(pdev) + PORT_ID(pdev))
1495*d14abf15SRobert Mustacchi
1496*d14abf15SRobert Mustacchi port = MM_PORT_NUM(&pUM->lm_dev);
1497*d14abf15SRobert Mustacchi
1498*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "MDIO access timeout! (port=%d)", port);
1499*d14abf15SRobert Mustacchi break;
1500*d14abf15SRobert Mustacchi
1501*d14abf15SRobert Mustacchi default:
1502*d14abf15SRobert Mustacchi
1503*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "Unknown MM event log! (type=%d)", lm_log_id);
1504*d14abf15SRobert Mustacchi break;
1505*d14abf15SRobert Mustacchi }
1506*d14abf15SRobert Mustacchi
1507*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
1508*d14abf15SRobert Mustacchi }
1509*d14abf15SRobert Mustacchi
1510*d14abf15SRobert Mustacchi
mm_event_log_generic(lm_device_t * pDev,const lm_log_id_t lm_log_id,...)1511*d14abf15SRobert Mustacchi lm_status_t mm_event_log_generic(lm_device_t * pDev,
1512*d14abf15SRobert Mustacchi const lm_log_id_t lm_log_id,
1513*d14abf15SRobert Mustacchi ...)
1514*d14abf15SRobert Mustacchi {
1515*d14abf15SRobert Mustacchi lm_status_t lm_status = LM_STATUS_SUCCESS;
1516*d14abf15SRobert Mustacchi va_list argp;
1517*d14abf15SRobert Mustacchi
1518*d14abf15SRobert Mustacchi va_start(argp, lm_log_id);
1519*d14abf15SRobert Mustacchi lm_status = mm_event_log_generic_arg_fwd(pDev, lm_log_id, argp);
1520*d14abf15SRobert Mustacchi va_end(argp);
1521*d14abf15SRobert Mustacchi
1522*d14abf15SRobert Mustacchi return lm_status;
1523*d14abf15SRobert Mustacchi }
1524*d14abf15SRobert Mustacchi
1525*d14abf15SRobert Mustacchi
mm_build_ver_string(lm_device_t * pDev)1526*d14abf15SRobert Mustacchi u32_t mm_build_ver_string(lm_device_t * pDev)
1527*d14abf15SRobert Mustacchi {
1528*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
1529*d14abf15SRobert Mustacchi
1530*d14abf15SRobert Mustacchi snprintf((char *)pDev->ver_str,
1531*d14abf15SRobert Mustacchi sizeof(pDev->ver_str),
1532*d14abf15SRobert Mustacchi "%s",
1533*d14abf15SRobert Mustacchi pUM->version);
1534*d14abf15SRobert Mustacchi
1535*d14abf15SRobert Mustacchi return min(strlen((char *)pDev->ver_str), strlen(pUM->version));
1536*d14abf15SRobert Mustacchi }
1537*d14abf15SRobert Mustacchi
1538*d14abf15SRobert Mustacchi
mm_indicate_hw_failure(lm_device_t * pDev)1539*d14abf15SRobert Mustacchi void mm_indicate_hw_failure(lm_device_t * pDev)
1540*d14abf15SRobert Mustacchi {
1541*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pDev;
1542*d14abf15SRobert Mustacchi
1543*d14abf15SRobert Mustacchi BnxeLogWarn(pUM, "HW failure indicated!");
1544*d14abf15SRobert Mustacchi }
1545*d14abf15SRobert Mustacchi
1546*d14abf15SRobert Mustacchi
mm_bar_read_byte(struct _lm_device_t * pdev,u8_t bar,u32_t offset,u8_t * ret)1547*d14abf15SRobert Mustacchi void mm_bar_read_byte(struct _lm_device_t *pdev,
1548*d14abf15SRobert Mustacchi u8_t bar,
1549*d14abf15SRobert Mustacchi u32_t offset,
1550*d14abf15SRobert Mustacchi u8_t *ret)
1551*d14abf15SRobert Mustacchi {
1552*d14abf15SRobert Mustacchi mm_read_barrier();
1553*d14abf15SRobert Mustacchi *ret = ddi_get8(pdev->vars.reg_handle[bar],
1554*d14abf15SRobert Mustacchi (uint8_t *)((caddr_t)pdev->vars.mapped_bar_addr[bar] +
1555*d14abf15SRobert Mustacchi offset));
1556*d14abf15SRobert Mustacchi }
1557*d14abf15SRobert Mustacchi
1558*d14abf15SRobert Mustacchi
mm_bar_read_word(struct _lm_device_t * pdev,u8_t bar,u32_t offset,u16_t * ret)1559*d14abf15SRobert Mustacchi void mm_bar_read_word(struct _lm_device_t *pdev,
1560*d14abf15SRobert Mustacchi u8_t bar,
1561*d14abf15SRobert Mustacchi u32_t offset,
1562*d14abf15SRobert Mustacchi u16_t *ret)
1563*d14abf15SRobert Mustacchi {
1564*d14abf15SRobert Mustacchi mm_read_barrier();
1565*d14abf15SRobert Mustacchi *ret = ddi_get16(pdev->vars.reg_handle[bar],
1566*d14abf15SRobert Mustacchi (uint16_t *)((caddr_t)pdev->vars.mapped_bar_addr[bar] +
1567*d14abf15SRobert Mustacchi offset));
1568*d14abf15SRobert Mustacchi }
1569*d14abf15SRobert Mustacchi
1570*d14abf15SRobert Mustacchi
mm_bar_read_dword(struct _lm_device_t * pdev,u8_t bar,u32_t offset,u32_t * ret)1571*d14abf15SRobert Mustacchi void mm_bar_read_dword(struct _lm_device_t *pdev,
1572*d14abf15SRobert Mustacchi u8_t bar,
1573*d14abf15SRobert Mustacchi u32_t offset,
1574*d14abf15SRobert Mustacchi u32_t *ret)
1575*d14abf15SRobert Mustacchi {
1576*d14abf15SRobert Mustacchi mm_read_barrier();
1577*d14abf15SRobert Mustacchi *ret = ddi_get32(pdev->vars.reg_handle[bar],
1578*d14abf15SRobert Mustacchi (uint32_t *)((caddr_t)pdev->vars.mapped_bar_addr[bar] +
1579*d14abf15SRobert Mustacchi offset));
1580*d14abf15SRobert Mustacchi }
1581*d14abf15SRobert Mustacchi
1582*d14abf15SRobert Mustacchi
mm_bar_read_ddword(struct _lm_device_t * pdev,u8_t bar,u32_t offset,u64_t * ret)1583*d14abf15SRobert Mustacchi void mm_bar_read_ddword(struct _lm_device_t *pdev,
1584*d14abf15SRobert Mustacchi u8_t bar,
1585*d14abf15SRobert Mustacchi u32_t offset,
1586*d14abf15SRobert Mustacchi u64_t *ret)
1587*d14abf15SRobert Mustacchi {
1588*d14abf15SRobert Mustacchi mm_read_barrier();
1589*d14abf15SRobert Mustacchi *ret = ddi_get64(pdev->vars.reg_handle[bar],
1590*d14abf15SRobert Mustacchi (uint64_t *)((caddr_t)pdev->vars.mapped_bar_addr[bar] +
1591*d14abf15SRobert Mustacchi offset));
1592*d14abf15SRobert Mustacchi }
1593*d14abf15SRobert Mustacchi
1594*d14abf15SRobert Mustacchi
mm_bar_write_byte(struct _lm_device_t * pdev,u8_t bar,u32_t offset,u8_t val)1595*d14abf15SRobert Mustacchi void mm_bar_write_byte(struct _lm_device_t *pdev,
1596*d14abf15SRobert Mustacchi u8_t bar,
1597*d14abf15SRobert Mustacchi u32_t offset,
1598*d14abf15SRobert Mustacchi u8_t val)
1599*d14abf15SRobert Mustacchi {
1600*d14abf15SRobert Mustacchi ddi_put8(pdev->vars.reg_handle[bar],
1601*d14abf15SRobert Mustacchi (uint8_t *)((caddr_t)pdev->vars.mapped_bar_addr[bar] + offset),
1602*d14abf15SRobert Mustacchi val);
1603*d14abf15SRobert Mustacchi mm_write_barrier();
1604*d14abf15SRobert Mustacchi }
1605*d14abf15SRobert Mustacchi
1606*d14abf15SRobert Mustacchi
mm_bar_write_word(struct _lm_device_t * pdev,u8_t bar,u32_t offset,u16_t val)1607*d14abf15SRobert Mustacchi void mm_bar_write_word(struct _lm_device_t *pdev,
1608*d14abf15SRobert Mustacchi u8_t bar,
1609*d14abf15SRobert Mustacchi u32_t offset,
1610*d14abf15SRobert Mustacchi u16_t val)
1611*d14abf15SRobert Mustacchi {
1612*d14abf15SRobert Mustacchi ddi_put16(pdev->vars.reg_handle[bar],
1613*d14abf15SRobert Mustacchi (uint16_t *)((caddr_t)pdev->vars.mapped_bar_addr[bar] + offset),
1614*d14abf15SRobert Mustacchi val);
1615*d14abf15SRobert Mustacchi mm_write_barrier();
1616*d14abf15SRobert Mustacchi }
1617*d14abf15SRobert Mustacchi
1618*d14abf15SRobert Mustacchi
mm_bar_write_dword(struct _lm_device_t * pdev,u8_t bar,u32_t offset,u32_t val)1619*d14abf15SRobert Mustacchi void mm_bar_write_dword(struct _lm_device_t *pdev,
1620*d14abf15SRobert Mustacchi u8_t bar,
1621*d14abf15SRobert Mustacchi u32_t offset,
1622*d14abf15SRobert Mustacchi u32_t val)
1623*d14abf15SRobert Mustacchi {
1624*d14abf15SRobert Mustacchi ddi_put32(pdev->vars.reg_handle[bar],
1625*d14abf15SRobert Mustacchi (uint32_t *)((caddr_t)pdev->vars.mapped_bar_addr[bar] + offset),
1626*d14abf15SRobert Mustacchi val);
1627*d14abf15SRobert Mustacchi mm_write_barrier();
1628*d14abf15SRobert Mustacchi }
1629*d14abf15SRobert Mustacchi
1630*d14abf15SRobert Mustacchi
mm_bar_write_ddword(struct _lm_device_t * pdev,u8_t bar,u32_t offset,u64_t val)1631*d14abf15SRobert Mustacchi void mm_bar_write_ddword(struct _lm_device_t *pdev,
1632*d14abf15SRobert Mustacchi u8_t bar,
1633*d14abf15SRobert Mustacchi u32_t offset,
1634*d14abf15SRobert Mustacchi u64_t val)
1635*d14abf15SRobert Mustacchi {
1636*d14abf15SRobert Mustacchi ddi_put64(pdev->vars.reg_handle[bar],
1637*d14abf15SRobert Mustacchi (uint64_t *)((caddr_t)pdev->vars.mapped_bar_addr[bar] + offset),
1638*d14abf15SRobert Mustacchi val);
1639*d14abf15SRobert Mustacchi mm_write_barrier();
1640*d14abf15SRobert Mustacchi }
1641*d14abf15SRobert Mustacchi
1642*d14abf15SRobert Mustacchi
mm_bar_copy_buffer(struct _lm_device_t * pdev,u8_t bar,u32_t offset,u32_t size,u32_t * buf_ptr)1643*d14abf15SRobert Mustacchi void mm_bar_copy_buffer(struct _lm_device_t * pdev,
1644*d14abf15SRobert Mustacchi u8_t bar,
1645*d14abf15SRobert Mustacchi u32_t offset,
1646*d14abf15SRobert Mustacchi u32_t size,
1647*d14abf15SRobert Mustacchi u32_t *buf_ptr)
1648*d14abf15SRobert Mustacchi {
1649*d14abf15SRobert Mustacchi u32_t i;
1650*d14abf15SRobert Mustacchi
1651*d14abf15SRobert Mustacchi for (i = 0; i < size; i++)
1652*d14abf15SRobert Mustacchi {
1653*d14abf15SRobert Mustacchi ddi_put32(pdev->vars.reg_handle[bar],
1654*d14abf15SRobert Mustacchi (uint32_t *)((caddr_t)pdev->vars.mapped_bar_addr[bar] +
1655*d14abf15SRobert Mustacchi offset + (i * 4)),
1656*d14abf15SRobert Mustacchi *(buf_ptr + i));
1657*d14abf15SRobert Mustacchi }
1658*d14abf15SRobert Mustacchi }
1659*d14abf15SRobert Mustacchi
1660*d14abf15SRobert Mustacchi
mm_get_cap_offset(struct _lm_device_t * pdev,u32_t capabilityID)1661*d14abf15SRobert Mustacchi u32_t mm_get_cap_offset(struct _lm_device_t * pdev,
1662*d14abf15SRobert Mustacchi u32_t capabilityID)
1663*d14abf15SRobert Mustacchi {
1664*d14abf15SRobert Mustacchi u32_t cap_offset = PCI_CAPABILITY_LIST; //CapPtr ofset
1665*d14abf15SRobert Mustacchi u8_t cap_id;
1666*d14abf15SRobert Mustacchi u32_t reg_value = 0;
1667*d14abf15SRobert Mustacchi
1668*d14abf15SRobert Mustacchi lm_status_t lm_status = mm_read_pci(pdev, cap_offset, ®_value);
1669*d14abf15SRobert Mustacchi if ((lm_status == LM_STATUS_SUCCESS) && (reg_value != 0xFFFFFFFF)) {
1670*d14abf15SRobert Mustacchi cap_offset = (u8_t)(reg_value & 0x000000FF);
1671*d14abf15SRobert Mustacchi if ((cap_offset == 0) || (cap_offset >= 0x100)) {
1672*d14abf15SRobert Mustacchi return 0xFFFFFFFF;
1673*d14abf15SRobert Mustacchi }
1674*d14abf15SRobert Mustacchi } else {
1675*d14abf15SRobert Mustacchi return 0xFFFFFFFF;
1676*d14abf15SRobert Mustacchi }
1677*d14abf15SRobert Mustacchi do {
1678*d14abf15SRobert Mustacchi reg_value = 0;
1679*d14abf15SRobert Mustacchi lm_status = mm_read_pci(pdev, cap_offset, ®_value);
1680*d14abf15SRobert Mustacchi if ((lm_status == LM_STATUS_SUCCESS) && (reg_value != 0xFFFFFFFF)) {
1681*d14abf15SRobert Mustacchi cap_id = (u8_t)(reg_value & 0x000000FF);
1682*d14abf15SRobert Mustacchi if (cap_id == capabilityID) {
1683*d14abf15SRobert Mustacchi break;
1684*d14abf15SRobert Mustacchi }
1685*d14abf15SRobert Mustacchi cap_offset = (reg_value & 0x0000FF00) >> 8;
1686*d14abf15SRobert Mustacchi if (cap_offset == 0) {
1687*d14abf15SRobert Mustacchi break;
1688*d14abf15SRobert Mustacchi }
1689*d14abf15SRobert Mustacchi } else {
1690*d14abf15SRobert Mustacchi cap_offset = 0xFFFFFFFF;
1691*d14abf15SRobert Mustacchi break;
1692*d14abf15SRobert Mustacchi }
1693*d14abf15SRobert Mustacchi } while ((lm_status == LM_STATUS_SUCCESS));
1694*d14abf15SRobert Mustacchi
1695*d14abf15SRobert Mustacchi return cap_offset;
1696*d14abf15SRobert Mustacchi }
1697*d14abf15SRobert Mustacchi
mm_get_wol_flags(struct _lm_device_t * pdev)1698*d14abf15SRobert Mustacchi u32_t mm_get_wol_flags(struct _lm_device_t * pdev)
1699*d14abf15SRobert Mustacchi {
1700*d14abf15SRobert Mustacchi return LM_WAKE_UP_MODE_NONE;
1701*d14abf15SRobert Mustacchi }
1702*d14abf15SRobert Mustacchi
mm_get_feature_flags(struct _lm_device_t * pdev)1703*d14abf15SRobert Mustacchi u32_t mm_get_feature_flags(struct _lm_device_t * pdev)
1704*d14abf15SRobert Mustacchi {
1705*d14abf15SRobert Mustacchi return 0;
1706*d14abf15SRobert Mustacchi }
1707*d14abf15SRobert Mustacchi
mm_get_vmq_cnt(struct _lm_device_t * pdev)1708*d14abf15SRobert Mustacchi u32_t mm_get_vmq_cnt(struct _lm_device_t * pdev)
1709*d14abf15SRobert Mustacchi {
1710*d14abf15SRobert Mustacchi return 0;
1711*d14abf15SRobert Mustacchi }
1712*d14abf15SRobert Mustacchi
mm_i2c_update(struct _lm_device_t * pdev)1713*d14abf15SRobert Mustacchi lm_status_t mm_i2c_update(struct _lm_device_t * pdev)
1714*d14abf15SRobert Mustacchi {
1715*d14abf15SRobert Mustacchi return LM_STATUS_SUCCESS;
1716*d14abf15SRobert Mustacchi }
1717*d14abf15SRobert Mustacchi
mm_query_system_time(void)1718*d14abf15SRobert Mustacchi u64_t mm_query_system_time(void)
1719*d14abf15SRobert Mustacchi {
1720*d14abf15SRobert Mustacchi return 0;
1721*d14abf15SRobert Mustacchi }
1722*d14abf15SRobert Mustacchi
1723