13126df22SRasesh Mody /* SPDX-License-Identifier: BSD-3-Clause
29adde217SRasesh Mody * Copyright (c) 2016 - 2018 Cavium Inc.
3ec94dbc5SRasesh Mody * All rights reserved.
49adde217SRasesh Mody * www.cavium.com
5ec94dbc5SRasesh Mody */
6ec94dbc5SRasesh Mody
7ec94dbc5SRasesh Mody #include <rte_memzone.h>
8ec94dbc5SRasesh Mody #include <rte_errno.h>
9ec94dbc5SRasesh Mody
10ec94dbc5SRasesh Mody #include "bcm_osal.h"
11ec94dbc5SRasesh Mody #include "ecore.h"
12ec94dbc5SRasesh Mody #include "ecore_hw.h"
137ed1cd53SRasesh Mody #include "ecore_dev_api.h"
1486a2265eSRasesh Mody #include "ecore_iov_api.h"
158a9c69aeSHarish Patil #include "ecore_mcp_api.h"
168a9c69aeSHarish Patil #include "ecore_l2_api.h"
17d459b043SManish Chopra #include "../qede_sriov.h"
18d459b043SManish Chopra
osal_pf_vf_msg(struct ecore_hwfn * p_hwfn)19d459b043SManish Chopra int osal_pf_vf_msg(struct ecore_hwfn *p_hwfn)
20d459b043SManish Chopra {
21d459b043SManish Chopra int rc;
22d459b043SManish Chopra
23d459b043SManish Chopra rc = qed_schedule_iov(p_hwfn, QED_IOV_WQ_MSG_FLAG);
24d459b043SManish Chopra if (rc) {
25d459b043SManish Chopra DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
26d459b043SManish Chopra "Failed to schedule alarm handler rc=%d\n", rc);
27d459b043SManish Chopra }
28d459b043SManish Chopra
29d459b043SManish Chopra return rc;
30d459b043SManish Chopra }
31d459b043SManish Chopra
osal_vf_flr_update(struct ecore_hwfn * p_hwfn)325700d0f0SManish Chopra void osal_vf_flr_update(struct ecore_hwfn *p_hwfn)
335700d0f0SManish Chopra {
345700d0f0SManish Chopra qed_schedule_iov(p_hwfn, QED_IOV_WQ_FLR_FLAG);
355700d0f0SManish Chopra }
365700d0f0SManish Chopra
osal_poll_mode_dpc(osal_int_ptr_t hwfn_cookie)37d459b043SManish Chopra void osal_poll_mode_dpc(osal_int_ptr_t hwfn_cookie)
38d459b043SManish Chopra {
39d459b043SManish Chopra struct ecore_hwfn *p_hwfn = (struct ecore_hwfn *)hwfn_cookie;
40d459b043SManish Chopra
41d459b043SManish Chopra if (!p_hwfn)
42d459b043SManish Chopra return;
43d459b043SManish Chopra
44d459b043SManish Chopra OSAL_SPIN_LOCK(&p_hwfn->spq_lock);
45d459b043SManish Chopra ecore_int_sp_dpc((osal_int_ptr_t)(p_hwfn));
46d459b043SManish Chopra OSAL_SPIN_UNLOCK(&p_hwfn->spq_lock);
47d459b043SManish Chopra }
488a9c69aeSHarish Patil
49a39001d9SHarish Patil /* Array of memzone pointers */
5038689022SOphir Munk static const struct rte_memzone **ecore_mz_mapping;
51a39001d9SHarish Patil /* Counter to track current memzone allocated */
52b74fd6b8SFerruh Yigit static uint16_t ecore_mz_count;
53ec94dbc5SRasesh Mody
54*e12a0166STyler Retzlaff static RTE_ATOMIC(uint32_t) ref_cnt;
5538689022SOphir Munk
ecore_mz_mapping_alloc(void)5638689022SOphir Munk int ecore_mz_mapping_alloc(void)
5738689022SOphir Munk {
58*e12a0166STyler Retzlaff if (rte_atomic_fetch_add_explicit(&ref_cnt, 1, rte_memory_order_relaxed) == 0) {
5938689022SOphir Munk ecore_mz_mapping = rte_calloc("ecore_mz_map",
6038689022SOphir Munk rte_memzone_max_get(), sizeof(struct rte_memzone *), 0);
6138689022SOphir Munk }
6238689022SOphir Munk
6338689022SOphir Munk if (!ecore_mz_mapping)
6438689022SOphir Munk return -ENOMEM;
6538689022SOphir Munk
6638689022SOphir Munk return 0;
6738689022SOphir Munk }
6838689022SOphir Munk
ecore_mz_mapping_free(void)6938689022SOphir Munk void ecore_mz_mapping_free(void)
7038689022SOphir Munk {
71*e12a0166STyler Retzlaff if (rte_atomic_fetch_sub_explicit(&ref_cnt, 1, rte_memory_order_relaxed) - 1 == 0) {
7238689022SOphir Munk rte_free(ecore_mz_mapping);
7338689022SOphir Munk ecore_mz_mapping = NULL;
7438689022SOphir Munk }
7538689022SOphir Munk }
7638689022SOphir Munk
qede_log2_align(unsigned long n)77ec94dbc5SRasesh Mody unsigned long qede_log2_align(unsigned long n)
78ec94dbc5SRasesh Mody {
79ec94dbc5SRasesh Mody unsigned long ret = n ? 1 : 0;
80ec94dbc5SRasesh Mody unsigned long _n = n >> 1;
81ec94dbc5SRasesh Mody
82ec94dbc5SRasesh Mody while (_n) {
83ec94dbc5SRasesh Mody _n >>= 1;
84ec94dbc5SRasesh Mody ret <<= 1;
85ec94dbc5SRasesh Mody }
86ec94dbc5SRasesh Mody
87ec94dbc5SRasesh Mody if (ret < n)
88ec94dbc5SRasesh Mody ret <<= 1;
89ec94dbc5SRasesh Mody
90ec94dbc5SRasesh Mody return ret;
91ec94dbc5SRasesh Mody }
92ec94dbc5SRasesh Mody
qede_osal_log2(u32 val)93ec94dbc5SRasesh Mody u32 qede_osal_log2(u32 val)
94ec94dbc5SRasesh Mody {
95ec94dbc5SRasesh Mody u32 log = 0;
96ec94dbc5SRasesh Mody
97ec94dbc5SRasesh Mody while (val >>= 1)
98ec94dbc5SRasesh Mody log++;
99ec94dbc5SRasesh Mody
100ec94dbc5SRasesh Mody return log;
101ec94dbc5SRasesh Mody }
102ec94dbc5SRasesh Mody
qede_ffb(unsigned long word)1038427c664SRasesh Mody static inline u32 qede_ffb(unsigned long word)
1048427c664SRasesh Mody {
1058427c664SRasesh Mody unsigned long first_bit;
1068427c664SRasesh Mody
1078427c664SRasesh Mody first_bit = __builtin_ffsl(word);
1088427c664SRasesh Mody return first_bit ? (first_bit - 1) : OSAL_BITS_PER_UL;
1098427c664SRasesh Mody }
1108427c664SRasesh Mody
qede_find_first_bit(unsigned long * addr,u32 limit)1118427c664SRasesh Mody inline u32 qede_find_first_bit(unsigned long *addr, u32 limit)
1128427c664SRasesh Mody {
1138427c664SRasesh Mody u32 i;
1148427c664SRasesh Mody u32 nwords = 0;
1158427c664SRasesh Mody OSAL_BUILD_BUG_ON(!limit);
1168427c664SRasesh Mody nwords = (limit - 1) / OSAL_BITS_PER_UL + 1;
1178427c664SRasesh Mody for (i = 0; i < nwords; i++)
1188427c664SRasesh Mody if (addr[i] != 0)
1198427c664SRasesh Mody break;
1208427c664SRasesh Mody
1218427c664SRasesh Mody return (i == nwords) ? limit : i * OSAL_BITS_PER_UL + qede_ffb(addr[i]);
1228427c664SRasesh Mody }
1238427c664SRasesh Mody
qede_ffz(unsigned long word)124ec94dbc5SRasesh Mody static inline u32 qede_ffz(unsigned long word)
125ec94dbc5SRasesh Mody {
126ec94dbc5SRasesh Mody unsigned long first_zero;
127ec94dbc5SRasesh Mody
128ec94dbc5SRasesh Mody first_zero = __builtin_ffsl(~word);
129ec94dbc5SRasesh Mody return first_zero ? (first_zero - 1) : OSAL_BITS_PER_UL;
130ec94dbc5SRasesh Mody }
131ec94dbc5SRasesh Mody
qede_find_first_zero_bit(u32 * addr,u32 limit)1325018f1fcSJoyce Kong inline u32 qede_find_first_zero_bit(u32 *addr, u32 limit)
133ec94dbc5SRasesh Mody {
134ec94dbc5SRasesh Mody u32 i;
135ec94dbc5SRasesh Mody u32 nwords = 0;
136ec94dbc5SRasesh Mody OSAL_BUILD_BUG_ON(!limit);
137ec94dbc5SRasesh Mody nwords = (limit - 1) / OSAL_BITS_PER_UL + 1;
1389a671097SRasesh Mody for (i = 0; i < nwords && ~(addr[i]) == 0; i++);
139ec94dbc5SRasesh Mody return (i == nwords) ? limit : i * OSAL_BITS_PER_UL + qede_ffz(addr[i]);
140ec94dbc5SRasesh Mody }
141ec94dbc5SRasesh Mody
qede_vf_fill_driver_data(struct ecore_hwfn * hwfn,__rte_unused struct vf_pf_resc_request * resc_req,struct ecore_vf_acquire_sw_info * vf_sw_info)14286a2265eSRasesh Mody void qede_vf_fill_driver_data(struct ecore_hwfn *hwfn,
14386a2265eSRasesh Mody __rte_unused struct vf_pf_resc_request *resc_req,
14486a2265eSRasesh Mody struct ecore_vf_acquire_sw_info *vf_sw_info)
14586a2265eSRasesh Mody {
14686a2265eSRasesh Mody vf_sw_info->os_type = VFPF_ACQUIRE_OS_LINUX_USERSPACE;
14786a2265eSRasesh Mody vf_sw_info->override_fw_version = 1;
14886a2265eSRasesh Mody }
14986a2265eSRasesh Mody
osal_dma_alloc_coherent(struct ecore_dev * p_dev,dma_addr_t * phys,size_t size)150ec94dbc5SRasesh Mody void *osal_dma_alloc_coherent(struct ecore_dev *p_dev,
151ec94dbc5SRasesh Mody dma_addr_t *phys, size_t size)
152ec94dbc5SRasesh Mody {
153ec94dbc5SRasesh Mody const struct rte_memzone *mz;
154ec94dbc5SRasesh Mody char mz_name[RTE_MEMZONE_NAMESIZE];
155ec94dbc5SRasesh Mody uint32_t core_id = rte_lcore_id();
156ec94dbc5SRasesh Mody unsigned int socket_id;
157ec94dbc5SRasesh Mody
15838689022SOphir Munk if (ecore_mz_count >= rte_memzone_max_get()) {
15938689022SOphir Munk DP_ERR(p_dev, "Memzone allocation count exceeds %zu\n",
16038689022SOphir Munk rte_memzone_max_get());
161a39001d9SHarish Patil *phys = 0;
162a39001d9SHarish Patil return OSAL_NULL;
163a39001d9SHarish Patil }
164a39001d9SHarish Patil
165ec94dbc5SRasesh Mody OSAL_MEM_ZERO(mz_name, sizeof(*mz_name));
166f4be6a9aSMichael Santana snprintf(mz_name, sizeof(mz_name), "%lx",
167ec94dbc5SRasesh Mody (unsigned long)rte_get_timer_cycles());
168ec94dbc5SRasesh Mody if (core_id == (unsigned int)LCORE_ID_ANY)
169cb056611SStephen Hemminger core_id = rte_get_main_lcore();
170ec94dbc5SRasesh Mody socket_id = rte_lcore_to_socket_id(core_id);
17117a4cd24SAnatoly Burakov mz = rte_memzone_reserve_aligned(mz_name, size, socket_id,
17217a4cd24SAnatoly Burakov RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
173ec94dbc5SRasesh Mody if (!mz) {
174ec94dbc5SRasesh Mody DP_ERR(p_dev, "Unable to allocate DMA memory "
175ec94dbc5SRasesh Mody "of size %zu bytes - %s\n",
176ec94dbc5SRasesh Mody size, rte_strerror(rte_errno));
177ec94dbc5SRasesh Mody *phys = 0;
178ec94dbc5SRasesh Mody return OSAL_NULL;
179ec94dbc5SRasesh Mody }
180f17ca787SThomas Monjalon *phys = mz->iova;
181a39001d9SHarish Patil ecore_mz_mapping[ecore_mz_count++] = mz;
182e8fb98d6SRasesh Mody DP_VERBOSE(p_dev, ECORE_MSG_SP,
183e8fb98d6SRasesh Mody "Allocated dma memory size=%zu phys=0x%lx"
184e8fb98d6SRasesh Mody " virt=%p core=%d\n",
185f17ca787SThomas Monjalon mz->len, (unsigned long)mz->iova, mz->addr, core_id);
186ec94dbc5SRasesh Mody return mz->addr;
187ec94dbc5SRasesh Mody }
188ec94dbc5SRasesh Mody
osal_dma_alloc_coherent_aligned(struct ecore_dev * p_dev,dma_addr_t * phys,size_t size,int align)189ec94dbc5SRasesh Mody void *osal_dma_alloc_coherent_aligned(struct ecore_dev *p_dev,
190ec94dbc5SRasesh Mody dma_addr_t *phys, size_t size, int align)
191ec94dbc5SRasesh Mody {
192ec94dbc5SRasesh Mody const struct rte_memzone *mz;
193ec94dbc5SRasesh Mody char mz_name[RTE_MEMZONE_NAMESIZE];
194ec94dbc5SRasesh Mody uint32_t core_id = rte_lcore_id();
195ec94dbc5SRasesh Mody unsigned int socket_id;
196ec94dbc5SRasesh Mody
19738689022SOphir Munk if (ecore_mz_count >= rte_memzone_max_get()) {
19838689022SOphir Munk DP_ERR(p_dev, "Memzone allocation count exceeds %zu\n",
19938689022SOphir Munk rte_memzone_max_get());
200a39001d9SHarish Patil *phys = 0;
201a39001d9SHarish Patil return OSAL_NULL;
202a39001d9SHarish Patil }
203a39001d9SHarish Patil
204ec94dbc5SRasesh Mody OSAL_MEM_ZERO(mz_name, sizeof(*mz_name));
205f4be6a9aSMichael Santana snprintf(mz_name, sizeof(mz_name), "%lx",
206ec94dbc5SRasesh Mody (unsigned long)rte_get_timer_cycles());
207ec94dbc5SRasesh Mody if (core_id == (unsigned int)LCORE_ID_ANY)
208cb056611SStephen Hemminger core_id = rte_get_main_lcore();
209ec94dbc5SRasesh Mody socket_id = rte_lcore_to_socket_id(core_id);
21017a4cd24SAnatoly Burakov mz = rte_memzone_reserve_aligned(mz_name, size, socket_id,
21117a4cd24SAnatoly Burakov RTE_MEMZONE_IOVA_CONTIG, align);
212ec94dbc5SRasesh Mody if (!mz) {
213ec94dbc5SRasesh Mody DP_ERR(p_dev, "Unable to allocate DMA memory "
214ec94dbc5SRasesh Mody "of size %zu bytes - %s\n",
215ec94dbc5SRasesh Mody size, rte_strerror(rte_errno));
216ec94dbc5SRasesh Mody *phys = 0;
217ec94dbc5SRasesh Mody return OSAL_NULL;
218ec94dbc5SRasesh Mody }
219f17ca787SThomas Monjalon *phys = mz->iova;
220a39001d9SHarish Patil ecore_mz_mapping[ecore_mz_count++] = mz;
221e8fb98d6SRasesh Mody DP_VERBOSE(p_dev, ECORE_MSG_SP,
222e8fb98d6SRasesh Mody "Allocated aligned dma memory size=%zu phys=0x%lx"
223e8fb98d6SRasesh Mody " virt=%p core=%d\n",
224f17ca787SThomas Monjalon mz->len, (unsigned long)mz->iova, mz->addr, core_id);
225ec94dbc5SRasesh Mody return mz->addr;
226ec94dbc5SRasesh Mody }
227ec94dbc5SRasesh Mody
osal_dma_free_mem(struct ecore_dev * p_dev,dma_addr_t phys)228a39001d9SHarish Patil void osal_dma_free_mem(struct ecore_dev *p_dev, dma_addr_t phys)
229a39001d9SHarish Patil {
230a39001d9SHarish Patil uint16_t j;
231a39001d9SHarish Patil
232a39001d9SHarish Patil for (j = 0 ; j < ecore_mz_count; j++) {
233f17ca787SThomas Monjalon if (phys == ecore_mz_mapping[j]->iova) {
234a39001d9SHarish Patil DP_VERBOSE(p_dev, ECORE_MSG_SP,
235a39001d9SHarish Patil "Free memzone %s\n", ecore_mz_mapping[j]->name);
236a39001d9SHarish Patil rte_memzone_free(ecore_mz_mapping[j]);
2377105b24fSRasesh Mody while (j < ecore_mz_count - 1) {
2387105b24fSRasesh Mody ecore_mz_mapping[j] = ecore_mz_mapping[j + 1];
2397105b24fSRasesh Mody j++;
2407105b24fSRasesh Mody }
2417105b24fSRasesh Mody ecore_mz_count--;
242a39001d9SHarish Patil return;
243a39001d9SHarish Patil }
244a39001d9SHarish Patil }
245a39001d9SHarish Patil
246a39001d9SHarish Patil DP_ERR(p_dev, "Unexpected memory free request\n");
247a39001d9SHarish Patil }
248a39001d9SHarish Patil
24948e8d239SRasesh Mody #ifdef CONFIG_ECORE_ZIPPED_FW
qede_unzip_data(struct ecore_hwfn * p_hwfn,u32 input_len,u8 * input_buf,u32 max_size,u8 * unzip_buf)250ec94dbc5SRasesh Mody u32 qede_unzip_data(struct ecore_hwfn *p_hwfn, u32 input_len,
251ec94dbc5SRasesh Mody u8 *input_buf, u32 max_size, u8 *unzip_buf)
252ec94dbc5SRasesh Mody {
253ec94dbc5SRasesh Mody int rc;
254ec94dbc5SRasesh Mody
255ec94dbc5SRasesh Mody p_hwfn->stream->next_in = input_buf;
256ec94dbc5SRasesh Mody p_hwfn->stream->avail_in = input_len;
257ec94dbc5SRasesh Mody p_hwfn->stream->next_out = unzip_buf;
258ec94dbc5SRasesh Mody p_hwfn->stream->avail_out = max_size;
259ec94dbc5SRasesh Mody
260ec94dbc5SRasesh Mody rc = inflateInit2(p_hwfn->stream, MAX_WBITS);
261ec94dbc5SRasesh Mody
262ec94dbc5SRasesh Mody if (rc != Z_OK) {
263ec94dbc5SRasesh Mody DP_ERR(p_hwfn,
264ec94dbc5SRasesh Mody "zlib init failed, rc = %d\n", rc);
265ec94dbc5SRasesh Mody return 0;
266ec94dbc5SRasesh Mody }
267ec94dbc5SRasesh Mody
268ec94dbc5SRasesh Mody rc = inflate(p_hwfn->stream, Z_FINISH);
269ec94dbc5SRasesh Mody inflateEnd(p_hwfn->stream);
270ec94dbc5SRasesh Mody
271ec94dbc5SRasesh Mody if (rc != Z_OK && rc != Z_STREAM_END) {
272ec94dbc5SRasesh Mody DP_ERR(p_hwfn,
273ec94dbc5SRasesh Mody "FW unzip error: %s, rc=%d\n", p_hwfn->stream->msg,
274ec94dbc5SRasesh Mody rc);
275ec94dbc5SRasesh Mody return 0;
276ec94dbc5SRasesh Mody }
277ec94dbc5SRasesh Mody
278ec94dbc5SRasesh Mody return p_hwfn->stream->total_out / 4;
279ec94dbc5SRasesh Mody }
28048e8d239SRasesh Mody #endif
2818a9c69aeSHarish Patil
2828a9c69aeSHarish Patil void
qede_get_mcp_proto_stats(struct ecore_dev * edev,enum ecore_mcp_protocol_type type,union ecore_mcp_protocol_stats * stats)2838a9c69aeSHarish Patil qede_get_mcp_proto_stats(struct ecore_dev *edev,
2848a9c69aeSHarish Patil enum ecore_mcp_protocol_type type,
2858a9c69aeSHarish Patil union ecore_mcp_protocol_stats *stats)
2868a9c69aeSHarish Patil {
2878a9c69aeSHarish Patil struct ecore_eth_stats lan_stats;
2888a9c69aeSHarish Patil
2898a9c69aeSHarish Patil if (type == ECORE_MCP_LAN_STATS) {
2908a9c69aeSHarish Patil ecore_get_vport_stats(edev, &lan_stats);
2919c1aa3e1SRasesh Mody
2929c1aa3e1SRasesh Mody /* @DPDK */
2939c1aa3e1SRasesh Mody stats->lan_stats.ucast_rx_pkts = lan_stats.common.rx_ucast_pkts;
2949c1aa3e1SRasesh Mody stats->lan_stats.ucast_tx_pkts = lan_stats.common.tx_ucast_pkts;
2959c1aa3e1SRasesh Mody
2968a9c69aeSHarish Patil stats->lan_stats.fcs_err = -1;
2978a9c69aeSHarish Patil } else {
2988a9c69aeSHarish Patil DP_INFO(edev, "Statistics request type %d not supported\n",
2998a9c69aeSHarish Patil type);
3008a9c69aeSHarish Patil }
3018a9c69aeSHarish Patil }
302e1c9b999SHarish Patil
qede_hw_err_handler(void * dev,enum ecore_hw_err_type err_type)303a50d7cbbSRasesh Mody static void qede_hw_err_handler(void *dev, enum ecore_hw_err_type err_type)
304a50d7cbbSRasesh Mody {
305a50d7cbbSRasesh Mody struct ecore_dev *edev = dev;
306a50d7cbbSRasesh Mody
307a50d7cbbSRasesh Mody switch (err_type) {
308a50d7cbbSRasesh Mody case ECORE_HW_ERR_FAN_FAIL:
309a50d7cbbSRasesh Mody break;
310a50d7cbbSRasesh Mody
311a50d7cbbSRasesh Mody case ECORE_HW_ERR_MFW_RESP_FAIL:
312a50d7cbbSRasesh Mody case ECORE_HW_ERR_HW_ATTN:
313a50d7cbbSRasesh Mody case ECORE_HW_ERR_DMAE_FAIL:
314a50d7cbbSRasesh Mody case ECORE_HW_ERR_RAMROD_FAIL:
315a50d7cbbSRasesh Mody case ECORE_HW_ERR_FW_ASSERT:
316a50d7cbbSRasesh Mody OSAL_SAVE_FW_DUMP(0); /* Using port 0 as default port_id */
317a50d7cbbSRasesh Mody break;
318a50d7cbbSRasesh Mody
319a50d7cbbSRasesh Mody default:
320a50d7cbbSRasesh Mody DP_NOTICE(edev, false, "Unknown HW error [%d]\n", err_type);
321a50d7cbbSRasesh Mody return;
322a50d7cbbSRasesh Mody }
323a50d7cbbSRasesh Mody }
324a50d7cbbSRasesh Mody
325e1c9b999SHarish Patil void
qede_hw_err_notify(struct ecore_hwfn * p_hwfn,enum ecore_hw_err_type err_type)326e1c9b999SHarish Patil qede_hw_err_notify(struct ecore_hwfn *p_hwfn, enum ecore_hw_err_type err_type)
327e1c9b999SHarish Patil {
328e1c9b999SHarish Patil char err_str[64];
329e1c9b999SHarish Patil
330e1c9b999SHarish Patil switch (err_type) {
331e1c9b999SHarish Patil case ECORE_HW_ERR_FAN_FAIL:
332e1c9b999SHarish Patil strcpy(err_str, "Fan Failure");
333e1c9b999SHarish Patil break;
334e1c9b999SHarish Patil case ECORE_HW_ERR_MFW_RESP_FAIL:
335e1c9b999SHarish Patil strcpy(err_str, "MFW Response Failure");
336e1c9b999SHarish Patil break;
337e1c9b999SHarish Patil case ECORE_HW_ERR_HW_ATTN:
338e1c9b999SHarish Patil strcpy(err_str, "HW Attention");
339e1c9b999SHarish Patil break;
340e1c9b999SHarish Patil case ECORE_HW_ERR_DMAE_FAIL:
341e1c9b999SHarish Patil strcpy(err_str, "DMAE Failure");
342e1c9b999SHarish Patil break;
343e1c9b999SHarish Patil case ECORE_HW_ERR_RAMROD_FAIL:
344e1c9b999SHarish Patil strcpy(err_str, "Ramrod Failure");
345e1c9b999SHarish Patil break;
346e1c9b999SHarish Patil case ECORE_HW_ERR_FW_ASSERT:
347e1c9b999SHarish Patil strcpy(err_str, "FW Assertion");
348e1c9b999SHarish Patil break;
349e1c9b999SHarish Patil default:
350e1c9b999SHarish Patil strcpy(err_str, "Unknown");
351e1c9b999SHarish Patil }
352e1c9b999SHarish Patil
353e1c9b999SHarish Patil DP_ERR(p_hwfn, "HW error occurred [%s]\n", err_str);
354a50d7cbbSRasesh Mody
355a50d7cbbSRasesh Mody qede_hw_err_handler(p_hwfn->p_dev, err_type);
356a50d7cbbSRasesh Mody
357e1c9b999SHarish Patil ecore_int_attn_clr_enable(p_hwfn->p_dev, true);
358e1c9b999SHarish Patil }
35903637634SRasesh Mody
qede_crc32(u32 crc,u8 * ptr,u32 length)36003637634SRasesh Mody u32 qede_crc32(u32 crc, u8 *ptr, u32 length)
36103637634SRasesh Mody {
36203637634SRasesh Mody int i;
36303637634SRasesh Mody
36403637634SRasesh Mody while (length--) {
36503637634SRasesh Mody crc ^= *ptr++;
36603637634SRasesh Mody for (i = 0; i < 8; i++)
36703637634SRasesh Mody crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
36803637634SRasesh Mody }
36903637634SRasesh Mody return crc;
37003637634SRasesh Mody }
3712352f348SRasesh Mody
qed_set_platform_str(struct ecore_hwfn * p_hwfn,char * buf_str,u32 buf_size)3722352f348SRasesh Mody void qed_set_platform_str(struct ecore_hwfn *p_hwfn,
3732352f348SRasesh Mody char *buf_str, u32 buf_size)
3742352f348SRasesh Mody {
3752352f348SRasesh Mody snprintf(buf_str, buf_size, "%s.", rte_version());
3762352f348SRasesh Mody }
377