13126df22SRasesh Mody /* SPDX-License-Identifier: BSD-3-Clause
29adde217SRasesh Mody * Copyright (c) 2016 - 2018 Cavium Inc.
32ea6f76aSRasesh Mody * All rights reserved.
49adde217SRasesh Mody * www.cavium.com
52ea6f76aSRasesh Mody */
62ea6f76aSRasesh Mody
72ea6f76aSRasesh Mody #include <limits.h>
840edb9c0SDavid Marchand
986a2265eSRasesh Mody #include <rte_alarm.h>
10f28742baSAndy Green #include <rte_string_fns.h>
112ea6f76aSRasesh Mody
1240edb9c0SDavid Marchand #include "eal_firmware.h"
1340edb9c0SDavid Marchand
142ea6f76aSRasesh Mody #include "qede_ethdev.h"
15ec55c118SRasesh Mody /* ######### DEBUG ###########*/
16ec55c118SRasesh Mody #include "qede_debug.h"
172ea6f76aSRasesh Mody
1886a2265eSRasesh Mody /* Alarm timeout. */
1986a2265eSRasesh Mody #define QEDE_ALARM_TIMEOUT_US 100000
2086a2265eSRasesh Mody
212ea6f76aSRasesh Mody /* Global variable to hold absolute path of fw file */
22520dd992SFerruh Yigit char qede_fw_file[PATH_MAX];
232ea6f76aSRasesh Mody
24b74fd6b8SFerruh Yigit static const char * const QEDE_DEFAULT_FIRMWARE =
2558bb1ee4SRasesh Mody "/lib/firmware/qed/qed_init_values-8.40.33.0.bin";
262ea6f76aSRasesh Mody
272ea6f76aSRasesh Mody static void
qed_update_pf_params(struct ecore_dev * edev,struct ecore_pf_params * params)282ea6f76aSRasesh Mody qed_update_pf_params(struct ecore_dev *edev, struct ecore_pf_params *params)
292ea6f76aSRasesh Mody {
302ea6f76aSRasesh Mody int i;
312ea6f76aSRasesh Mody
322ea6f76aSRasesh Mody for (i = 0; i < edev->num_hwfns; i++) {
332ea6f76aSRasesh Mody struct ecore_hwfn *p_hwfn = &edev->hwfns[i];
342ea6f76aSRasesh Mody p_hwfn->pf_params = *params;
352ea6f76aSRasesh Mody }
362ea6f76aSRasesh Mody }
372ea6f76aSRasesh Mody
qed_init_pci(struct ecore_dev * edev,struct rte_pci_device * pci_dev)382ea6f76aSRasesh Mody static void qed_init_pci(struct ecore_dev *edev, struct rte_pci_device *pci_dev)
392ea6f76aSRasesh Mody {
402ea6f76aSRasesh Mody edev->regview = pci_dev->mem_resource[0].addr;
412ea6f76aSRasesh Mody edev->doorbells = pci_dev->mem_resource[2].addr;
42e916697fSRasesh Mody edev->db_size = pci_dev->mem_resource[2].len;
4392c6786eSManish Chopra edev->pci_dev = pci_dev;
442ea6f76aSRasesh Mody }
452ea6f76aSRasesh Mody
462ea6f76aSRasesh Mody static int
qed_probe(struct ecore_dev * edev,struct rte_pci_device * pci_dev,uint32_t dp_module,uint8_t dp_level,bool is_vf)472ea6f76aSRasesh Mody qed_probe(struct ecore_dev *edev, struct rte_pci_device *pci_dev,
484c4bdadfSHarish Patil uint32_t dp_module, uint8_t dp_level, bool is_vf)
492ea6f76aSRasesh Mody {
5022d07d93SRasesh Mody struct ecore_hw_prepare_params hw_prepare_params;
512ea6f76aSRasesh Mody int rc;
522ea6f76aSRasesh Mody
532ea6f76aSRasesh Mody ecore_init_struct(edev);
54de5588afSRasesh Mody edev->drv_type = DRV_ID_DRV_TYPE_LINUX;
554c4bdadfSHarish Patil /* Protocol type is always fixed to PROTOCOL_ETH */
56de5588afSRasesh Mody
57c0bd1181SRasesh Mody if (is_vf)
582ea6f76aSRasesh Mody edev->b_is_vf = true;
59c0bd1181SRasesh Mody
602ea6f76aSRasesh Mody ecore_init_dp(edev, dp_module, dp_level, NULL);
612ea6f76aSRasesh Mody qed_init_pci(edev, pci_dev);
6222d07d93SRasesh Mody
6322d07d93SRasesh Mody memset(&hw_prepare_params, 0, sizeof(hw_prepare_params));
64f44ca48cSManish Chopra
65f44ca48cSManish Chopra if (is_vf)
66f44ca48cSManish Chopra hw_prepare_params.acquire_retry_cnt = ECORE_VF_ACQUIRE_THRESH;
67f44ca48cSManish Chopra
6822d07d93SRasesh Mody hw_prepare_params.personality = ECORE_PCI_ETH;
6922d07d93SRasesh Mody hw_prepare_params.drv_resc_alloc = false;
7022d07d93SRasesh Mody hw_prepare_params.chk_reg_fifo = false;
719e2f08a4SRasesh Mody hw_prepare_params.initiate_pf_flr = true;
723d5083f2SRasesh Mody hw_prepare_params.allow_mdump = false;
7376d37490SRasesh Mody hw_prepare_params.b_en_pacing = false;
742352f348SRasesh Mody hw_prepare_params.epoch = OSAL_GET_EPOCH(ECORE_LEADING_HWFN(edev));
75*38689022SOphir Munk rc = ecore_mz_mapping_alloc();
76*38689022SOphir Munk if (rc) {
77*38689022SOphir Munk DP_ERR(edev, "mem zones array allocation failed\n");
78*38689022SOphir Munk return rc;
79*38689022SOphir Munk }
80*38689022SOphir Munk
8122d07d93SRasesh Mody rc = ecore_hw_prepare(edev, &hw_prepare_params);
822ea6f76aSRasesh Mody if (rc) {
832ea6f76aSRasesh Mody DP_ERR(edev, "hw prepare failed\n");
842ea6f76aSRasesh Mody return rc;
852ea6f76aSRasesh Mody }
862ea6f76aSRasesh Mody
872ea6f76aSRasesh Mody return rc;
882ea6f76aSRasesh Mody }
892ea6f76aSRasesh Mody
qed_nic_setup(struct ecore_dev * edev)902ea6f76aSRasesh Mody static int qed_nic_setup(struct ecore_dev *edev)
912ea6f76aSRasesh Mody {
92af785e47SRasesh Mody int rc;
932ea6f76aSRasesh Mody
942ea6f76aSRasesh Mody rc = ecore_resc_alloc(edev);
952ea6f76aSRasesh Mody if (rc)
962ea6f76aSRasesh Mody return rc;
972ea6f76aSRasesh Mody
982ea6f76aSRasesh Mody DP_INFO(edev, "Allocated qed resources\n");
992ea6f76aSRasesh Mody ecore_resc_setup(edev);
1002ea6f76aSRasesh Mody
1012ea6f76aSRasesh Mody return rc;
1022ea6f76aSRasesh Mody }
1032ea6f76aSRasesh Mody
10448e8d239SRasesh Mody #ifdef CONFIG_ECORE_ZIPPED_FW
qed_alloc_stream_mem(struct ecore_dev * edev)1052ea6f76aSRasesh Mody static int qed_alloc_stream_mem(struct ecore_dev *edev)
1062ea6f76aSRasesh Mody {
1072ea6f76aSRasesh Mody int i;
1082ea6f76aSRasesh Mody
1092ea6f76aSRasesh Mody for_each_hwfn(edev, i) {
1102ea6f76aSRasesh Mody struct ecore_hwfn *p_hwfn = &edev->hwfns[i];
1112ea6f76aSRasesh Mody
1122ea6f76aSRasesh Mody p_hwfn->stream = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
1132ea6f76aSRasesh Mody sizeof(*p_hwfn->stream));
1142ea6f76aSRasesh Mody if (!p_hwfn->stream)
1152ea6f76aSRasesh Mody return -ENOMEM;
1162ea6f76aSRasesh Mody }
1172ea6f76aSRasesh Mody
1182ea6f76aSRasesh Mody return 0;
1192ea6f76aSRasesh Mody }
1202ea6f76aSRasesh Mody
qed_free_stream_mem(struct ecore_dev * edev)1212ea6f76aSRasesh Mody static void qed_free_stream_mem(struct ecore_dev *edev)
1222ea6f76aSRasesh Mody {
1232ea6f76aSRasesh Mody int i;
1242ea6f76aSRasesh Mody
1252ea6f76aSRasesh Mody for_each_hwfn(edev, i) {
1262ea6f76aSRasesh Mody struct ecore_hwfn *p_hwfn = &edev->hwfns[i];
1272ea6f76aSRasesh Mody
1282ea6f76aSRasesh Mody if (!p_hwfn->stream)
1292ea6f76aSRasesh Mody return;
1302ea6f76aSRasesh Mody
1312ea6f76aSRasesh Mody OSAL_FREE(p_hwfn->p_dev, p_hwfn->stream);
1322ea6f76aSRasesh Mody }
1332ea6f76aSRasesh Mody }
13448e8d239SRasesh Mody #endif
1352ea6f76aSRasesh Mody
13648e8d239SRasesh Mody #ifdef CONFIG_ECORE_BINARY_FW
qed_load_firmware_data(struct ecore_dev * edev)1372ea6f76aSRasesh Mody static int qed_load_firmware_data(struct ecore_dev *edev)
1382ea6f76aSRasesh Mody {
1392ea6f76aSRasesh Mody const char *fw = RTE_LIBRTE_QEDE_FW;
14040edb9c0SDavid Marchand void *buf;
14140edb9c0SDavid Marchand size_t bufsz;
14240edb9c0SDavid Marchand int ret;
1432ea6f76aSRasesh Mody
1442ea6f76aSRasesh Mody if (strcmp(fw, "") == 0)
145520dd992SFerruh Yigit strcpy(qede_fw_file, QEDE_DEFAULT_FIRMWARE);
1462ea6f76aSRasesh Mody else
147520dd992SFerruh Yigit strcpy(qede_fw_file, fw);
1482ea6f76aSRasesh Mody
14940edb9c0SDavid Marchand if (rte_firmware_read(qede_fw_file, &buf, &bufsz) < 0) {
15040edb9c0SDavid Marchand DP_ERR(edev, "Can't read firmware data: %s\n", qede_fw_file);
1512ea6f76aSRasesh Mody return -1;
1522ea6f76aSRasesh Mody }
1532ea6f76aSRasesh Mody
15440edb9c0SDavid Marchand edev->firmware = rte_zmalloc("qede_fw", bufsz, RTE_CACHE_LINE_SIZE);
1552ea6f76aSRasesh Mody if (!edev->firmware) {
1564ffa2af9SRasesh Mody DP_ERR(edev, "Can't allocate memory for firmware\n");
15740edb9c0SDavid Marchand ret = -ENOMEM;
15840edb9c0SDavid Marchand goto out;
1592ea6f76aSRasesh Mody }
1602ea6f76aSRasesh Mody
16140edb9c0SDavid Marchand memcpy(edev->firmware, buf, bufsz);
16240edb9c0SDavid Marchand edev->fw_len = bufsz;
1632ea6f76aSRasesh Mody if (edev->fw_len < 104) {
1644ffa2af9SRasesh Mody DP_ERR(edev, "Invalid fw size: %" PRIu64 "\n",
1652ea6f76aSRasesh Mody edev->fw_len);
16640edb9c0SDavid Marchand ret = -EINVAL;
16740edb9c0SDavid Marchand goto out;
1682ea6f76aSRasesh Mody }
16940edb9c0SDavid Marchand ret = 0;
17040edb9c0SDavid Marchand out:
17140edb9c0SDavid Marchand free(buf);
17240edb9c0SDavid Marchand return ret;
1732ea6f76aSRasesh Mody }
17448e8d239SRasesh Mody #endif
1752ea6f76aSRasesh Mody
qed_handle_bulletin_change(struct ecore_hwfn * hwfn)17686a2265eSRasesh Mody static void qed_handle_bulletin_change(struct ecore_hwfn *hwfn)
17786a2265eSRasesh Mody {
17886a2265eSRasesh Mody uint8_t mac[ETH_ALEN], is_mac_exist, is_mac_forced;
17986a2265eSRasesh Mody
18086a2265eSRasesh Mody is_mac_exist = ecore_vf_bulletin_get_forced_mac(hwfn, mac,
18186a2265eSRasesh Mody &is_mac_forced);
18286a2265eSRasesh Mody if (is_mac_exist && is_mac_forced)
18386a2265eSRasesh Mody rte_memcpy(hwfn->hw_info.hw_mac_addr, mac, ETH_ALEN);
18486a2265eSRasesh Mody
18586a2265eSRasesh Mody /* Always update link configuration according to bulletin */
1868aab5d6fSRasesh Mody qed_link_update(hwfn);
18786a2265eSRasesh Mody }
18886a2265eSRasesh Mody
qede_vf_task(void * arg)18986a2265eSRasesh Mody static void qede_vf_task(void *arg)
19086a2265eSRasesh Mody {
19186a2265eSRasesh Mody struct ecore_hwfn *p_hwfn = arg;
19286a2265eSRasesh Mody uint8_t change = 0;
19386a2265eSRasesh Mody
19486a2265eSRasesh Mody /* Read the bulletin board, and re-schedule the task */
19586a2265eSRasesh Mody ecore_vf_read_bulletin(p_hwfn, &change);
19686a2265eSRasesh Mody if (change)
19786a2265eSRasesh Mody qed_handle_bulletin_change(p_hwfn);
19886a2265eSRasesh Mody
19986a2265eSRasesh Mody rte_eal_alarm_set(QEDE_ALARM_TIMEOUT_US, qede_vf_task, p_hwfn);
20086a2265eSRasesh Mody }
20186a2265eSRasesh Mody
qed_start_iov_task(struct ecore_dev * edev)20286a2265eSRasesh Mody static void qed_start_iov_task(struct ecore_dev *edev)
20386a2265eSRasesh Mody {
20486a2265eSRasesh Mody struct ecore_hwfn *p_hwfn;
20586a2265eSRasesh Mody int i;
20686a2265eSRasesh Mody
20786a2265eSRasesh Mody for_each_hwfn(edev, i) {
20886a2265eSRasesh Mody p_hwfn = &edev->hwfns[i];
20986a2265eSRasesh Mody if (!IS_PF(edev))
21086a2265eSRasesh Mody rte_eal_alarm_set(QEDE_ALARM_TIMEOUT_US, qede_vf_task,
21186a2265eSRasesh Mody p_hwfn);
21286a2265eSRasesh Mody }
21386a2265eSRasesh Mody }
21486a2265eSRasesh Mody
qed_stop_iov_task(struct ecore_dev * edev)21586a2265eSRasesh Mody static void qed_stop_iov_task(struct ecore_dev *edev)
21686a2265eSRasesh Mody {
21786a2265eSRasesh Mody struct ecore_hwfn *p_hwfn;
21886a2265eSRasesh Mody int i;
21986a2265eSRasesh Mody
22086a2265eSRasesh Mody for_each_hwfn(edev, i) {
22186a2265eSRasesh Mody p_hwfn = &edev->hwfns[i];
222d459b043SManish Chopra if (IS_PF(edev))
223d459b043SManish Chopra rte_eal_alarm_cancel(qed_iov_pf_task, p_hwfn);
224d459b043SManish Chopra else
22586a2265eSRasesh Mody rte_eal_alarm_cancel(qede_vf_task, p_hwfn);
22686a2265eSRasesh Mody }
22786a2265eSRasesh Mody }
qed_slowpath_start(struct ecore_dev * edev,struct qed_slowpath_params * params)2282ea6f76aSRasesh Mody static int qed_slowpath_start(struct ecore_dev *edev,
2292ea6f76aSRasesh Mody struct qed_slowpath_params *params)
2302ea6f76aSRasesh Mody {
231c5e11089SRasesh Mody struct ecore_drv_load_params drv_load_params;
232c5e11089SRasesh Mody struct ecore_hw_init_params hw_init_params;
233c5e11089SRasesh Mody struct ecore_mcp_drv_version drv_version;
2342ea6f76aSRasesh Mody const uint8_t *data = NULL;
2352ea6f76aSRasesh Mody struct ecore_hwfn *hwfn;
23662207535SHarish Patil struct ecore_ptt *p_ptt;
2372ea6f76aSRasesh Mody int rc;
2382ea6f76aSRasesh Mody
23986a2265eSRasesh Mody if (IS_PF(edev)) {
24062207535SHarish Patil #ifdef CONFIG_ECORE_BINARY_FW
2412ea6f76aSRasesh Mody rc = qed_load_firmware_data(edev);
2422ea6f76aSRasesh Mody if (rc) {
243520dd992SFerruh Yigit DP_ERR(edev, "Failed to find fw file %s\n",
244520dd992SFerruh Yigit qede_fw_file);
2452ea6f76aSRasesh Mody goto err;
2462ea6f76aSRasesh Mody }
2472ea6f76aSRasesh Mody #endif
24862207535SHarish Patil hwfn = ECORE_LEADING_HWFN(edev);
24962207535SHarish Patil if (edev->num_hwfns == 1) { /* skip aRFS for 100G device */
25062207535SHarish Patil p_ptt = ecore_ptt_acquire(hwfn);
25162207535SHarish Patil if (p_ptt) {
25262207535SHarish Patil ECORE_LEADING_HWFN(edev)->p_arfs_ptt = p_ptt;
25362207535SHarish Patil } else {
25462207535SHarish Patil DP_ERR(edev, "Failed to acquire PTT for flowdir\n");
25562207535SHarish Patil rc = -ENOMEM;
25662207535SHarish Patil goto err;
25762207535SHarish Patil }
25862207535SHarish Patil }
25962207535SHarish Patil }
2602ea6f76aSRasesh Mody
2612ea6f76aSRasesh Mody rc = qed_nic_setup(edev);
2622ea6f76aSRasesh Mody if (rc)
2632ea6f76aSRasesh Mody goto err;
2642ea6f76aSRasesh Mody
2652ea6f76aSRasesh Mody /* set int_coalescing_mode */
2662ea6f76aSRasesh Mody edev->int_coalescing_mode = ECORE_COAL_MODE_ENABLE;
2672ea6f76aSRasesh Mody
26848e8d239SRasesh Mody #ifdef CONFIG_ECORE_ZIPPED_FW
26986a2265eSRasesh Mody if (IS_PF(edev)) {
2702ea6f76aSRasesh Mody /* Allocate stream for unzipping */
2712ea6f76aSRasesh Mody rc = qed_alloc_stream_mem(edev);
2722ea6f76aSRasesh Mody if (rc) {
2734ffa2af9SRasesh Mody DP_ERR(edev, "Failed to allocate stream memory\n");
274c2069af8SRasesh Mody goto err1;
2752ea6f76aSRasesh Mody }
27686a2265eSRasesh Mody }
277af785e47SRasesh Mody #endif
27886a2265eSRasesh Mody
27986a2265eSRasesh Mody qed_start_iov_task(edev);
2802ea6f76aSRasesh Mody
28148e8d239SRasesh Mody #ifdef CONFIG_ECORE_BINARY_FW
282ec55c118SRasesh Mody if (IS_PF(edev)) {
28322d07d93SRasesh Mody data = (const uint8_t *)edev->firmware + sizeof(u32);
284ec55c118SRasesh Mody
285ec55c118SRasesh Mody /* ############### DEBUG ################## */
286ec55c118SRasesh Mody qed_dbg_pf_init(edev);
287ec55c118SRasesh Mody }
2882ea6f76aSRasesh Mody #endif
28922d07d93SRasesh Mody
290ec55c118SRasesh Mody
291301ea2d7SRasesh Mody /* Start the slowpath */
292301ea2d7SRasesh Mody memset(&hw_init_params, 0, sizeof(hw_init_params));
293301ea2d7SRasesh Mody hw_init_params.b_hw_start = true;
294245aec28SShahed Shaikh hw_init_params.int_mode = params->int_mode;
29562207535SHarish Patil hw_init_params.allow_npar_tx_switch = true;
296301ea2d7SRasesh Mody hw_init_params.bin_fw_data = data;
297c5e11089SRasesh Mody
298c5e11089SRasesh Mody memset(&drv_load_params, 0, sizeof(drv_load_params));
299c5e11089SRasesh Mody drv_load_params.mfw_timeout_val = ECORE_LOAD_REQ_LOCK_TO_DEFAULT;
300c5e11089SRasesh Mody drv_load_params.avoid_eng_reset = false;
301c5e11089SRasesh Mody drv_load_params.override_force_load = ECORE_OVERRIDE_FORCE_LOAD_ALWAYS;
30266c4904fSRasesh Mody hw_init_params.avoid_eng_affin = false;
303c5e11089SRasesh Mody hw_init_params.p_drv_load_params = &drv_load_params;
304c5e11089SRasesh Mody
305301ea2d7SRasesh Mody rc = ecore_hw_init(edev, &hw_init_params);
3062ea6f76aSRasesh Mody if (rc) {
3072ea6f76aSRasesh Mody DP_ERR(edev, "ecore_hw_init failed\n");
3082ea6f76aSRasesh Mody goto err2;
3092ea6f76aSRasesh Mody }
3102ea6f76aSRasesh Mody
3112ea6f76aSRasesh Mody DP_INFO(edev, "HW inited and function started\n");
3122ea6f76aSRasesh Mody
31386a2265eSRasesh Mody if (IS_PF(edev)) {
3142ea6f76aSRasesh Mody hwfn = ECORE_LEADING_HWFN(edev);
3152ea6f76aSRasesh Mody drv_version.version = (params->drv_major << 24) |
3162ea6f76aSRasesh Mody (params->drv_minor << 16) |
3172ea6f76aSRasesh Mody (params->drv_rev << 8) | (params->drv_eng);
318f28742baSAndy Green strlcpy((char *)drv_version.name, (const char *)params->name,
319f28742baSAndy Green sizeof(drv_version.name));
3202ea6f76aSRasesh Mody rc = ecore_mcp_send_drv_version(hwfn, hwfn->p_main_ptt,
3212ea6f76aSRasesh Mody &drv_version);
3222ea6f76aSRasesh Mody if (rc) {
3234ffa2af9SRasesh Mody DP_ERR(edev, "Failed sending drv version command\n");
324c2069af8SRasesh Mody goto err3;
3252ea6f76aSRasesh Mody }
32686a2265eSRasesh Mody }
3272ea6f76aSRasesh Mody
3285cdd769aSRasesh Mody ecore_reset_vport_stats(edev);
3295cdd769aSRasesh Mody
3302ea6f76aSRasesh Mody return 0;
3312ea6f76aSRasesh Mody
332c2069af8SRasesh Mody err3:
3332ea6f76aSRasesh Mody ecore_hw_stop(edev);
3342ea6f76aSRasesh Mody err2:
335c2069af8SRasesh Mody qed_stop_iov_task(edev);
336c2069af8SRasesh Mody #ifdef CONFIG_ECORE_ZIPPED_FW
337c2069af8SRasesh Mody qed_free_stream_mem(edev);
338c2069af8SRasesh Mody err1:
339c2069af8SRasesh Mody #endif
3402ea6f76aSRasesh Mody ecore_resc_free(edev);
3412ea6f76aSRasesh Mody err:
34248e8d239SRasesh Mody #ifdef CONFIG_ECORE_BINARY_FW
34386a2265eSRasesh Mody if (IS_PF(edev)) {
3442ea6f76aSRasesh Mody rte_free(edev->firmware);
3452ea6f76aSRasesh Mody edev->firmware = NULL;
34686a2265eSRasesh Mody }
3472ea6f76aSRasesh Mody #endif
34886a2265eSRasesh Mody qed_stop_iov_task(edev);
34986a2265eSRasesh Mody
3502ea6f76aSRasesh Mody return rc;
3512ea6f76aSRasesh Mody }
3522ea6f76aSRasesh Mody
3532ea6f76aSRasesh Mody static int
qed_fill_dev_info(struct ecore_dev * edev,struct qed_dev_info * dev_info)3542ea6f76aSRasesh Mody qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info)
3552ea6f76aSRasesh Mody {
356652ee28aSRasesh Mody struct ecore_hwfn *p_hwfn = ECORE_LEADING_HWFN(edev);
3572ea6f76aSRasesh Mody struct ecore_ptt *ptt = NULL;
358a7f3cac3SRasesh Mody struct ecore_tunnel_info *tun = &edev->tunnel;
3592ea6f76aSRasesh Mody
3602ea6f76aSRasesh Mody memset(dev_info, 0, sizeof(struct qed_dev_info));
361a7f3cac3SRasesh Mody
362adce1f86SRasesh Mody if (tun->vxlan.tun_cls == ECORE_TUNN_CLSS_MAC_VLAN &&
363adce1f86SRasesh Mody tun->vxlan.b_mode_enabled)
364a7f3cac3SRasesh Mody dev_info->vxlan_enable = true;
365a7f3cac3SRasesh Mody
366adce1f86SRasesh Mody if (tun->l2_gre.b_mode_enabled && tun->ip_gre.b_mode_enabled &&
367adce1f86SRasesh Mody tun->l2_gre.tun_cls == ECORE_TUNN_CLSS_MAC_VLAN &&
368adce1f86SRasesh Mody tun->ip_gre.tun_cls == ECORE_TUNN_CLSS_MAC_VLAN)
369a7f3cac3SRasesh Mody dev_info->gre_enable = true;
370a7f3cac3SRasesh Mody
371adce1f86SRasesh Mody if (tun->l2_geneve.b_mode_enabled && tun->ip_geneve.b_mode_enabled &&
372adce1f86SRasesh Mody tun->l2_geneve.tun_cls == ECORE_TUNN_CLSS_MAC_VLAN &&
373adce1f86SRasesh Mody tun->ip_geneve.tun_cls == ECORE_TUNN_CLSS_MAC_VLAN)
374a7f3cac3SRasesh Mody dev_info->geneve_enable = true;
375a7f3cac3SRasesh Mody
3762ea6f76aSRasesh Mody dev_info->num_hwfns = edev->num_hwfns;
3772ea6f76aSRasesh Mody dev_info->is_mf_default = IS_MF_DEFAULT(&edev->hwfns[0]);
3784fc58baeSRasesh Mody dev_info->mtu = ECORE_LEADING_HWFN(edev)->hw_info.mtu;
379dc8eba81SRasesh Mody dev_info->dev_type = edev->type;
3804fc58baeSRasesh Mody
3814200c4d6SStephen Hemminger memcpy(&dev_info->hw_mac, &edev->hwfns[0].hw_info.hw_mac_addr,
38235b2d13fSOlivier Matz RTE_ETHER_ADDR_LEN);
3832ea6f76aSRasesh Mody
3842ea6f76aSRasesh Mody dev_info->fw_major = FW_MAJOR_VERSION;
3852ea6f76aSRasesh Mody dev_info->fw_minor = FW_MINOR_VERSION;
3862ea6f76aSRasesh Mody dev_info->fw_rev = FW_REVISION_VERSION;
3872ea6f76aSRasesh Mody dev_info->fw_eng = FW_ENGINEERING_VERSION;
388738f56d4SRasesh Mody
389738f56d4SRasesh Mody if (IS_PF(edev)) {
39047af7019SRasesh Mody dev_info->b_inter_pf_switch =
3915018f1fcSJoyce Kong OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH, &edev->mf_bits);
3925018f1fcSJoyce Kong if (!OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS, &edev->mf_bits))
393a2dc43f3SRasesh Mody dev_info->b_arfs_capable = true;
3942ea6f76aSRasesh Mody dev_info->tx_switching = false;
3952ea6f76aSRasesh Mody
396652ee28aSRasesh Mody dev_info->smart_an = ecore_mcp_is_smart_an_supported(p_hwfn);
397652ee28aSRasesh Mody
3982ea6f76aSRasesh Mody ptt = ecore_ptt_acquire(ECORE_LEADING_HWFN(edev));
3992ea6f76aSRasesh Mody if (ptt) {
40022d07d93SRasesh Mody ecore_mcp_get_mfw_ver(ECORE_LEADING_HWFN(edev), ptt,
4012ea6f76aSRasesh Mody &dev_info->mfw_rev, NULL);
4022ea6f76aSRasesh Mody
403f97b56f9SRasesh Mody ecore_mcp_get_mbi_ver(ECORE_LEADING_HWFN(edev), ptt,
404f97b56f9SRasesh Mody &dev_info->mbi_version);
405f97b56f9SRasesh Mody
4062ea6f76aSRasesh Mody ecore_mcp_get_flash_size(ECORE_LEADING_HWFN(edev), ptt,
4072ea6f76aSRasesh Mody &dev_info->flash_size);
4082ea6f76aSRasesh Mody
4092ea6f76aSRasesh Mody /* Workaround to allow PHY-read commands for
4102ea6f76aSRasesh Mody * B0 bringup.
4112ea6f76aSRasesh Mody */
4122ea6f76aSRasesh Mody if (ECORE_IS_BB_B0(edev))
4132ea6f76aSRasesh Mody dev_info->flash_size = 0xffffffff;
4142ea6f76aSRasesh Mody
4152ea6f76aSRasesh Mody ecore_ptt_release(ECORE_LEADING_HWFN(edev), ptt);
4162ea6f76aSRasesh Mody }
41786a2265eSRasesh Mody } else {
41822d07d93SRasesh Mody ecore_mcp_get_mfw_ver(ECORE_LEADING_HWFN(edev), ptt,
41922d07d93SRasesh Mody &dev_info->mfw_rev, NULL);
42086a2265eSRasesh Mody }
4212ea6f76aSRasesh Mody
4222ea6f76aSRasesh Mody return 0;
4232ea6f76aSRasesh Mody }
4242ea6f76aSRasesh Mody
4252ea6f76aSRasesh Mody int
qed_fill_eth_dev_info(struct ecore_dev * edev,struct qed_dev_eth_info * info)4262ea6f76aSRasesh Mody qed_fill_eth_dev_info(struct ecore_dev *edev, struct qed_dev_eth_info *info)
4272ea6f76aSRasesh Mody {
428f1e4b6c0SHarish Patil uint8_t queues = 0;
4292ea6f76aSRasesh Mody int i;
4302ea6f76aSRasesh Mody
4312ea6f76aSRasesh Mody memset(info, 0, sizeof(*info));
4322ea6f76aSRasesh Mody
4332ea6f76aSRasesh Mody info->num_tc = 1 /* @@@TBD aelior MULTI_COS */;
4342ea6f76aSRasesh Mody
43586a2265eSRasesh Mody if (IS_PF(edev)) {
436d6cb1753SHarish Patil int max_vf_vlan_filters = 0;
437d6cb1753SHarish Patil
4382ea6f76aSRasesh Mody info->num_queues = 0;
4392ea6f76aSRasesh Mody for_each_hwfn(edev, i)
4402ea6f76aSRasesh Mody info->num_queues +=
4412ea6f76aSRasesh Mody FEAT_NUM(&edev->hwfns[i], ECORE_PF_L2_QUE);
4422ea6f76aSRasesh Mody
443eafbc6fcSRasesh Mody if (IS_ECORE_SRIOV(edev))
444d6cb1753SHarish Patil max_vf_vlan_filters = edev->p_iov_info->total_vfs *
445d6cb1753SHarish Patil ECORE_ETH_VF_NUM_VLAN_FILTERS;
446d6cb1753SHarish Patil info->num_vlan_filters = RESC_NUM(&edev->hwfns[0], ECORE_VLAN) -
447d6cb1753SHarish Patil max_vf_vlan_filters;
4482ea6f76aSRasesh Mody
4494200c4d6SStephen Hemminger memcpy(&info->port_mac, &edev->hwfns[0].hw_info.hw_mac_addr,
45035b2d13fSOlivier Matz RTE_ETHER_ADDR_LEN);
45186a2265eSRasesh Mody } else {
452f1e4b6c0SHarish Patil ecore_vf_get_num_rxqs(ECORE_LEADING_HWFN(edev),
453f1e4b6c0SHarish Patil &info->num_queues);
454c0845c33SRasesh Mody if (ECORE_IS_CMT(edev)) {
455f1e4b6c0SHarish Patil ecore_vf_get_num_rxqs(&edev->hwfns[1], &queues);
456f1e4b6c0SHarish Patil info->num_queues += queues;
457f1e4b6c0SHarish Patil }
45886a2265eSRasesh Mody
45986a2265eSRasesh Mody ecore_vf_get_num_vlan_filters(&edev->hwfns[0],
460d6cb1753SHarish Patil (u8 *)&info->num_vlan_filters);
46186a2265eSRasesh Mody
46286a2265eSRasesh Mody ecore_vf_get_port_mac(&edev->hwfns[0],
46386a2265eSRasesh Mody (uint8_t *)&info->port_mac);
4643d4bb441SHarish Patil
4653d4bb441SHarish Patil info->is_legacy = ecore_vf_get_pre_fp_hsi(&edev->hwfns[0]);
46686a2265eSRasesh Mody }
4672ea6f76aSRasesh Mody
4682ea6f76aSRasesh Mody qed_fill_dev_info(edev, &info->common);
4692ea6f76aSRasesh Mody
47086a2265eSRasesh Mody if (IS_VF(edev))
47135b2d13fSOlivier Matz memset(&info->common.hw_mac, 0, RTE_ETHER_ADDR_LEN);
47286a2265eSRasesh Mody
4732ea6f76aSRasesh Mody return 0;
4742ea6f76aSRasesh Mody }
4752ea6f76aSRasesh Mody
qed_set_name(struct ecore_dev * edev,char name[NAME_SIZE])476de5588afSRasesh Mody static void qed_set_name(struct ecore_dev *edev, char name[NAME_SIZE])
4772ea6f76aSRasesh Mody {
4782ea6f76aSRasesh Mody int i;
4792ea6f76aSRasesh Mody
4804200c4d6SStephen Hemminger memcpy(edev->name, name, NAME_SIZE);
4812ea6f76aSRasesh Mody for_each_hwfn(edev, i) {
4822ea6f76aSRasesh Mody snprintf(edev->hwfns[i].name, NAME_SIZE, "%s-%d", name, i);
4832ea6f76aSRasesh Mody }
4842ea6f76aSRasesh Mody }
4852ea6f76aSRasesh Mody
4862ea6f76aSRasesh Mody static uint32_t
qed_sb_init(struct ecore_dev * edev,struct ecore_sb_info * sb_info,void * sb_virt_addr,dma_addr_t sb_phy_addr,uint16_t sb_id)4872ea6f76aSRasesh Mody qed_sb_init(struct ecore_dev *edev, struct ecore_sb_info *sb_info,
4884c4bdadfSHarish Patil void *sb_virt_addr, dma_addr_t sb_phy_addr, uint16_t sb_id)
4892ea6f76aSRasesh Mody {
4902ea6f76aSRasesh Mody struct ecore_hwfn *p_hwfn;
4912ea6f76aSRasesh Mody int hwfn_index;
4922ea6f76aSRasesh Mody uint16_t rel_sb_id;
4934c4bdadfSHarish Patil uint8_t n_hwfns = edev->num_hwfns;
4942ea6f76aSRasesh Mody uint32_t rc;
4952ea6f76aSRasesh Mody
4962ea6f76aSRasesh Mody hwfn_index = sb_id % n_hwfns;
4972ea6f76aSRasesh Mody p_hwfn = &edev->hwfns[hwfn_index];
4982ea6f76aSRasesh Mody rel_sb_id = sb_id / n_hwfns;
4992ea6f76aSRasesh Mody
5002ea6f76aSRasesh Mody DP_INFO(edev, "hwfn [%d] <--[init]-- SB %04x [0x%04x upper]\n",
5012ea6f76aSRasesh Mody hwfn_index, rel_sb_id, sb_id);
5022ea6f76aSRasesh Mody
5032ea6f76aSRasesh Mody rc = ecore_int_sb_init(p_hwfn, p_hwfn->p_main_ptt, sb_info,
5042ea6f76aSRasesh Mody sb_virt_addr, sb_phy_addr, rel_sb_id);
5052ea6f76aSRasesh Mody
5062ea6f76aSRasesh Mody return rc;
5072ea6f76aSRasesh Mody }
5082ea6f76aSRasesh Mody
qed_fill_link(struct ecore_hwfn * hwfn,__rte_unused struct ecore_ptt * ptt,struct qed_link_output * if_link)5092ea6f76aSRasesh Mody static void qed_fill_link(struct ecore_hwfn *hwfn,
510739a5b2fSRasesh Mody __rte_unused struct ecore_ptt *ptt,
5112ea6f76aSRasesh Mody struct qed_link_output *if_link)
5122ea6f76aSRasesh Mody {
5132ea6f76aSRasesh Mody struct ecore_mcp_link_params params;
5142ea6f76aSRasesh Mody struct ecore_mcp_link_state link;
5152ea6f76aSRasesh Mody struct ecore_mcp_link_capabilities link_caps;
5162ea6f76aSRasesh Mody uint8_t change = 0;
5172ea6f76aSRasesh Mody
5182ea6f76aSRasesh Mody memset(if_link, 0, sizeof(*if_link));
5192ea6f76aSRasesh Mody
5202ea6f76aSRasesh Mody /* Prepare source inputs */
52186a2265eSRasesh Mody if (IS_PF(hwfn->p_dev)) {
5224200c4d6SStephen Hemminger memcpy(¶ms, ecore_mcp_get_link_params(hwfn), sizeof(params));
5234200c4d6SStephen Hemminger memcpy(&link, ecore_mcp_get_link_state(hwfn), sizeof(link));
5244200c4d6SStephen Hemminger memcpy(&link_caps, ecore_mcp_get_link_capabilities(hwfn),
5252ea6f76aSRasesh Mody sizeof(link_caps));
52686a2265eSRasesh Mody } else {
52786a2265eSRasesh Mody ecore_vf_read_bulletin(hwfn, &change);
52886a2265eSRasesh Mody ecore_vf_get_link_params(hwfn, ¶ms);
52986a2265eSRasesh Mody ecore_vf_get_link_state(hwfn, &link);
53086a2265eSRasesh Mody ecore_vf_get_link_caps(hwfn, &link_caps);
53186a2265eSRasesh Mody }
5322ea6f76aSRasesh Mody
5332ea6f76aSRasesh Mody /* Set the link parameters to pass to protocol driver */
5342ea6f76aSRasesh Mody if (link.link_up)
5352ea6f76aSRasesh Mody if_link->link_up = true;
5362ea6f76aSRasesh Mody
5372ea6f76aSRasesh Mody if (link.link_up)
5382ea6f76aSRasesh Mody if_link->speed = link.speed;
5392ea6f76aSRasesh Mody
5402ea6f76aSRasesh Mody if_link->duplex = QEDE_DUPLEX_FULL;
5412ea6f76aSRasesh Mody
5421ea56b80SHarish Patil /* Fill up the native advertised speed cap mask */
5431ea56b80SHarish Patil if_link->adv_speed = params.speed.advertised_speeds;
54464c239b7SHarish Patil
5452ea6f76aSRasesh Mody if (params.speed.autoneg)
5462ea6f76aSRasesh Mody if_link->supported_caps |= QEDE_SUPPORTED_AUTONEG;
5472ea6f76aSRasesh Mody
5482ea6f76aSRasesh Mody if (params.pause.autoneg || params.pause.forced_rx ||
5492ea6f76aSRasesh Mody params.pause.forced_tx)
5502ea6f76aSRasesh Mody if_link->supported_caps |= QEDE_SUPPORTED_PAUSE;
5512ea6f76aSRasesh Mody
5522ea6f76aSRasesh Mody if (params.pause.autoneg)
5532ea6f76aSRasesh Mody if_link->pause_config |= QED_LINK_PAUSE_AUTONEG_ENABLE;
5542ea6f76aSRasesh Mody
5552ea6f76aSRasesh Mody if (params.pause.forced_rx)
5562ea6f76aSRasesh Mody if_link->pause_config |= QED_LINK_PAUSE_RX_ENABLE;
5572ea6f76aSRasesh Mody
5582ea6f76aSRasesh Mody if (params.pause.forced_tx)
5592ea6f76aSRasesh Mody if_link->pause_config |= QED_LINK_PAUSE_TX_ENABLE;
5603c6a3cf6SRasesh Mody
5613c6a3cf6SRasesh Mody if (link_caps.default_eee == ECORE_MCP_EEE_UNSUPPORTED) {
5623c6a3cf6SRasesh Mody if_link->eee_supported = false;
5633c6a3cf6SRasesh Mody } else {
5643c6a3cf6SRasesh Mody if_link->eee_supported = true;
5653c6a3cf6SRasesh Mody if_link->eee_active = link.eee_active;
5663c6a3cf6SRasesh Mody if_link->sup_caps = link_caps.eee_speed_caps;
5673c6a3cf6SRasesh Mody /* MFW clears adv_caps on eee disable; use configured value */
5683c6a3cf6SRasesh Mody if_link->eee.adv_caps = link.eee_adv_caps ? link.eee_adv_caps :
5693c6a3cf6SRasesh Mody params.eee.adv_caps;
5703c6a3cf6SRasesh Mody if_link->eee.lp_adv_caps = link.eee_lp_adv_caps;
5713c6a3cf6SRasesh Mody if_link->eee.enable = params.eee.enable;
5723c6a3cf6SRasesh Mody if_link->eee.tx_lpi_enable = params.eee.tx_lpi_enable;
5733c6a3cf6SRasesh Mody if_link->eee.tx_lpi_timer = params.eee.tx_lpi_timer;
5743c6a3cf6SRasesh Mody }
5752ea6f76aSRasesh Mody }
5762ea6f76aSRasesh Mody
5772ea6f76aSRasesh Mody static void
qed_get_current_link(struct ecore_dev * edev,struct qed_link_output * if_link)5782ea6f76aSRasesh Mody qed_get_current_link(struct ecore_dev *edev, struct qed_link_output *if_link)
5792ea6f76aSRasesh Mody {
580739a5b2fSRasesh Mody struct ecore_hwfn *hwfn;
581739a5b2fSRasesh Mody struct ecore_ptt *ptt;
5822ea6f76aSRasesh Mody
583739a5b2fSRasesh Mody hwfn = &edev->hwfns[0];
584739a5b2fSRasesh Mody if (IS_PF(edev)) {
585739a5b2fSRasesh Mody ptt = ecore_ptt_acquire(hwfn);
586effb1d0bSRasesh Mody if (ptt) {
587739a5b2fSRasesh Mody qed_fill_link(hwfn, ptt, if_link);
588739a5b2fSRasesh Mody ecore_ptt_release(hwfn, ptt);
589739a5b2fSRasesh Mody } else {
590effb1d0bSRasesh Mody DP_NOTICE(hwfn, true, "Failed to fill link; No PTT\n");
591effb1d0bSRasesh Mody }
592effb1d0bSRasesh Mody } else {
593739a5b2fSRasesh Mody qed_fill_link(hwfn, NULL, if_link);
594739a5b2fSRasesh Mody }
5952ea6f76aSRasesh Mody }
5962ea6f76aSRasesh Mody
qed_set_link(struct ecore_dev * edev,struct qed_link_params * params)5972ea6f76aSRasesh Mody static int qed_set_link(struct ecore_dev *edev, struct qed_link_params *params)
5982ea6f76aSRasesh Mody {
5992ea6f76aSRasesh Mody struct ecore_hwfn *hwfn;
6002ea6f76aSRasesh Mody struct ecore_ptt *ptt;
6012ea6f76aSRasesh Mody struct ecore_mcp_link_params *link_params;
6022ea6f76aSRasesh Mody int rc;
6032ea6f76aSRasesh Mody
60486a2265eSRasesh Mody if (IS_VF(edev))
60586a2265eSRasesh Mody return 0;
60686a2265eSRasesh Mody
6072ea6f76aSRasesh Mody /* The link should be set only once per PF */
6082ea6f76aSRasesh Mody hwfn = &edev->hwfns[0];
6092ea6f76aSRasesh Mody
6102ea6f76aSRasesh Mody ptt = ecore_ptt_acquire(hwfn);
6112ea6f76aSRasesh Mody if (!ptt)
6122ea6f76aSRasesh Mody return -EBUSY;
6132ea6f76aSRasesh Mody
6142ea6f76aSRasesh Mody link_params = ecore_mcp_get_link_params(hwfn);
6152ea6f76aSRasesh Mody if (params->override_flags & QED_LINK_OVERRIDE_SPEED_AUTONEG)
6162ea6f76aSRasesh Mody link_params->speed.autoneg = params->autoneg;
6172ea6f76aSRasesh Mody
6182ea6f76aSRasesh Mody if (params->override_flags & QED_LINK_OVERRIDE_PAUSE_CONFIG) {
6192ea6f76aSRasesh Mody if (params->pause_config & QED_LINK_PAUSE_AUTONEG_ENABLE)
6202ea6f76aSRasesh Mody link_params->pause.autoneg = true;
6212ea6f76aSRasesh Mody else
6222ea6f76aSRasesh Mody link_params->pause.autoneg = false;
6232ea6f76aSRasesh Mody if (params->pause_config & QED_LINK_PAUSE_RX_ENABLE)
6242ea6f76aSRasesh Mody link_params->pause.forced_rx = true;
6252ea6f76aSRasesh Mody else
6262ea6f76aSRasesh Mody link_params->pause.forced_rx = false;
6272ea6f76aSRasesh Mody if (params->pause_config & QED_LINK_PAUSE_TX_ENABLE)
6282ea6f76aSRasesh Mody link_params->pause.forced_tx = true;
6292ea6f76aSRasesh Mody else
6302ea6f76aSRasesh Mody link_params->pause.forced_tx = false;
6312ea6f76aSRasesh Mody }
6322ea6f76aSRasesh Mody
6333c6a3cf6SRasesh Mody if (params->override_flags & QED_LINK_OVERRIDE_EEE_CONFIG)
6343c6a3cf6SRasesh Mody memcpy(&link_params->eee, ¶ms->eee,
6353c6a3cf6SRasesh Mody sizeof(link_params->eee));
6363c6a3cf6SRasesh Mody
6372ea6f76aSRasesh Mody rc = ecore_mcp_set_link(hwfn, ptt, params->link_up);
6382ea6f76aSRasesh Mody
6392ea6f76aSRasesh Mody ecore_ptt_release(hwfn, ptt);
6402ea6f76aSRasesh Mody
6412ea6f76aSRasesh Mody return rc;
6422ea6f76aSRasesh Mody }
6432ea6f76aSRasesh Mody
qed_link_update(struct ecore_hwfn * hwfn)6448aab5d6fSRasesh Mody void qed_link_update(struct ecore_hwfn *hwfn)
64586a2265eSRasesh Mody {
6468aab5d6fSRasesh Mody struct ecore_dev *edev = hwfn->p_dev;
6478aab5d6fSRasesh Mody struct qede_dev *qdev = (struct qede_dev *)edev;
648cfab13aaSShahed Shaikh struct rte_eth_dev *dev = (struct rte_eth_dev *)qdev->ethdev;
649c176fd86SManish Chopra int rc;
65086a2265eSRasesh Mody
651c176fd86SManish Chopra rc = qede_link_update(dev, 0);
652c176fd86SManish Chopra qed_inform_vf_link_state(hwfn);
653c176fd86SManish Chopra
654c176fd86SManish Chopra if (!rc)
6555723fbedSFerruh Yigit rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
65686a2265eSRasesh Mody }
65786a2265eSRasesh Mody
qed_drain(struct ecore_dev * edev)6582ea6f76aSRasesh Mody static int qed_drain(struct ecore_dev *edev)
6592ea6f76aSRasesh Mody {
6602ea6f76aSRasesh Mody struct ecore_hwfn *hwfn;
6612ea6f76aSRasesh Mody struct ecore_ptt *ptt;
6622ea6f76aSRasesh Mody int i, rc;
6632ea6f76aSRasesh Mody
66486a2265eSRasesh Mody if (IS_VF(edev))
66586a2265eSRasesh Mody return 0;
66686a2265eSRasesh Mody
6672ea6f76aSRasesh Mody for_each_hwfn(edev, i) {
6682ea6f76aSRasesh Mody hwfn = &edev->hwfns[i];
6692ea6f76aSRasesh Mody ptt = ecore_ptt_acquire(hwfn);
6702ea6f76aSRasesh Mody if (!ptt) {
6714ffa2af9SRasesh Mody DP_ERR(hwfn, "Failed to drain NIG; No PTT\n");
6722ea6f76aSRasesh Mody return -EBUSY;
6732ea6f76aSRasesh Mody }
6742ea6f76aSRasesh Mody rc = ecore_mcp_drain(hwfn, ptt);
6752ea6f76aSRasesh Mody if (rc)
6762ea6f76aSRasesh Mody return rc;
6772ea6f76aSRasesh Mody ecore_ptt_release(hwfn, ptt);
6782ea6f76aSRasesh Mody }
6792ea6f76aSRasesh Mody
6802ea6f76aSRasesh Mody return 0;
6812ea6f76aSRasesh Mody }
6822ea6f76aSRasesh Mody
qed_nic_stop(struct ecore_dev * edev)6832ea6f76aSRasesh Mody static int qed_nic_stop(struct ecore_dev *edev)
6842ea6f76aSRasesh Mody {
6852ea6f76aSRasesh Mody int i, rc;
6862ea6f76aSRasesh Mody
6872ea6f76aSRasesh Mody rc = ecore_hw_stop(edev);
6882ea6f76aSRasesh Mody for (i = 0; i < edev->num_hwfns; i++) {
6892ea6f76aSRasesh Mody struct ecore_hwfn *p_hwfn = &edev->hwfns[i];
6902ea6f76aSRasesh Mody
6912ea6f76aSRasesh Mody if (p_hwfn->b_sp_dpc_enabled)
6922ea6f76aSRasesh Mody p_hwfn->b_sp_dpc_enabled = false;
6932ea6f76aSRasesh Mody }
6942ea6f76aSRasesh Mody return rc;
6952ea6f76aSRasesh Mody }
6962ea6f76aSRasesh Mody
qed_slowpath_stop(struct ecore_dev * edev)6972ea6f76aSRasesh Mody static int qed_slowpath_stop(struct ecore_dev *edev)
6982ea6f76aSRasesh Mody {
6992ea6f76aSRasesh Mody #ifdef CONFIG_QED_SRIOV
7002ea6f76aSRasesh Mody int i;
7012ea6f76aSRasesh Mody #endif
7022ea6f76aSRasesh Mody
7032ea6f76aSRasesh Mody if (!edev)
7042ea6f76aSRasesh Mody return -ENODEV;
7052ea6f76aSRasesh Mody
70686a2265eSRasesh Mody if (IS_PF(edev)) {
70748e8d239SRasesh Mody #ifdef CONFIG_ECORE_ZIPPED_FW
7082ea6f76aSRasesh Mody qed_free_stream_mem(edev);
70948e8d239SRasesh Mody #endif
7102ea6f76aSRasesh Mody
71186a2265eSRasesh Mody #ifdef CONFIG_QED_SRIOV
71286a2265eSRasesh Mody if (IS_QED_ETH_IF(edev))
71386a2265eSRasesh Mody qed_sriov_disable(edev, true);
71486a2265eSRasesh Mody #endif
71586a2265eSRasesh Mody }
7162ea6f76aSRasesh Mody
71739f0eb3bSRasesh Mody qed_nic_stop(edev);
71839f0eb3bSRasesh Mody
71939f0eb3bSRasesh Mody ecore_resc_free(edev);
72086a2265eSRasesh Mody qed_stop_iov_task(edev);
7212ea6f76aSRasesh Mody
7222ea6f76aSRasesh Mody return 0;
7232ea6f76aSRasesh Mody }
7242ea6f76aSRasesh Mody
qed_remove(struct ecore_dev * edev)7252ea6f76aSRasesh Mody static void qed_remove(struct ecore_dev *edev)
7262ea6f76aSRasesh Mody {
7272ea6f76aSRasesh Mody if (!edev)
7282ea6f76aSRasesh Mody return;
7292ea6f76aSRasesh Mody
7302ea6f76aSRasesh Mody ecore_hw_remove(edev);
731*38689022SOphir Munk ecore_mz_mapping_free();
7322ea6f76aSRasesh Mody }
7332ea6f76aSRasesh Mody
qed_send_drv_state(struct ecore_dev * edev,bool active)7343ca097bbSRasesh Mody static int qed_send_drv_state(struct ecore_dev *edev, bool active)
7353ca097bbSRasesh Mody {
7363ca097bbSRasesh Mody struct ecore_hwfn *hwfn = ECORE_LEADING_HWFN(edev);
7373ca097bbSRasesh Mody struct ecore_ptt *ptt;
7383ca097bbSRasesh Mody int status = 0;
7393ca097bbSRasesh Mody
7403ca097bbSRasesh Mody ptt = ecore_ptt_acquire(hwfn);
7413ca097bbSRasesh Mody if (!ptt)
7423ca097bbSRasesh Mody return -EAGAIN;
7433ca097bbSRasesh Mody
7443ca097bbSRasesh Mody status = ecore_mcp_ov_update_driver_state(hwfn, ptt, active ?
7453ca097bbSRasesh Mody ECORE_OV_DRIVER_STATE_ACTIVE :
7463ca097bbSRasesh Mody ECORE_OV_DRIVER_STATE_DISABLED);
7473ca097bbSRasesh Mody
7483ca097bbSRasesh Mody ecore_ptt_release(hwfn, ptt);
7493ca097bbSRasesh Mody
7503ca097bbSRasesh Mody return status;
7513ca097bbSRasesh Mody }
7523ca097bbSRasesh Mody
qed_get_sb_info(struct ecore_dev * edev,struct ecore_sb_info * sb,u16 qid,struct ecore_sb_info_dbg * sb_dbg)7531a998268SRasesh Mody static int qed_get_sb_info(struct ecore_dev *edev, struct ecore_sb_info *sb,
7541a998268SRasesh Mody u16 qid, struct ecore_sb_info_dbg *sb_dbg)
7551a998268SRasesh Mody {
7561a998268SRasesh Mody struct ecore_hwfn *hwfn = &edev->hwfns[qid % edev->num_hwfns];
7571a998268SRasesh Mody struct ecore_ptt *ptt;
7581a998268SRasesh Mody int rc;
7591a998268SRasesh Mody
7601a998268SRasesh Mody if (IS_VF(edev))
7611a998268SRasesh Mody return -EINVAL;
7621a998268SRasesh Mody
7631a998268SRasesh Mody ptt = ecore_ptt_acquire(hwfn);
7641a998268SRasesh Mody if (!ptt) {
7654ffa2af9SRasesh Mody DP_ERR(hwfn, "Can't acquire PTT\n");
7661a998268SRasesh Mody return -EAGAIN;
7671a998268SRasesh Mody }
7681a998268SRasesh Mody
7691a998268SRasesh Mody memset(sb_dbg, 0, sizeof(*sb_dbg));
7701a998268SRasesh Mody rc = ecore_int_get_sb_dbg(hwfn, ptt, sb, sb_dbg);
7711a998268SRasesh Mody
7721a998268SRasesh Mody ecore_ptt_release(hwfn, ptt);
7731a998268SRasesh Mody return rc;
7741a998268SRasesh Mody }
7751a998268SRasesh Mody
7762ea6f76aSRasesh Mody const struct qed_common_ops qed_common_ops_pass = {
7772ea6f76aSRasesh Mody INIT_STRUCT_FIELD(probe, &qed_probe),
7782ea6f76aSRasesh Mody INIT_STRUCT_FIELD(update_pf_params, &qed_update_pf_params),
7792ea6f76aSRasesh Mody INIT_STRUCT_FIELD(slowpath_start, &qed_slowpath_start),
780de5588afSRasesh Mody INIT_STRUCT_FIELD(set_name, &qed_set_name),
7812ea6f76aSRasesh Mody INIT_STRUCT_FIELD(chain_alloc, &ecore_chain_alloc),
7822ea6f76aSRasesh Mody INIT_STRUCT_FIELD(chain_free, &ecore_chain_free),
7832ea6f76aSRasesh Mody INIT_STRUCT_FIELD(sb_init, &qed_sb_init),
784af785e47SRasesh Mody INIT_STRUCT_FIELD(get_sb_info, &qed_get_sb_info),
7852ea6f76aSRasesh Mody INIT_STRUCT_FIELD(get_link, &qed_get_current_link),
7862ea6f76aSRasesh Mody INIT_STRUCT_FIELD(set_link, &qed_set_link),
7872ea6f76aSRasesh Mody INIT_STRUCT_FIELD(drain, &qed_drain),
7882ea6f76aSRasesh Mody INIT_STRUCT_FIELD(slowpath_stop, &qed_slowpath_stop),
7892ea6f76aSRasesh Mody INIT_STRUCT_FIELD(remove, &qed_remove),
7903ca097bbSRasesh Mody INIT_STRUCT_FIELD(send_drv_state, &qed_send_drv_state),
791ec55c118SRasesh Mody /* ############### DEBUG ####################*/
792ec55c118SRasesh Mody
793ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_get_debug_engine, &qed_get_debug_engine),
794ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_set_debug_engine, &qed_set_debug_engine),
795ec55c118SRasesh Mody
796ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_protection_override,
797ec55c118SRasesh Mody &qed_dbg_protection_override),
798ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_protection_override_size,
799ec55c118SRasesh Mody &qed_dbg_protection_override_size),
800ec55c118SRasesh Mody
801ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_grc, &qed_dbg_grc),
802ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_grc_size, &qed_dbg_grc_size),
803ec55c118SRasesh Mody
804ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_idle_chk, &qed_dbg_idle_chk),
805ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_idle_chk_size, &qed_dbg_idle_chk_size),
806ec55c118SRasesh Mody
807ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_mcp_trace, &qed_dbg_mcp_trace),
808ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_mcp_trace_size, &qed_dbg_mcp_trace_size),
809ec55c118SRasesh Mody
810ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_fw_asserts, &qed_dbg_fw_asserts),
811ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_fw_asserts_size, &qed_dbg_fw_asserts_size),
812ec55c118SRasesh Mody
813ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_ilt, &qed_dbg_ilt),
814ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_ilt_size, &qed_dbg_ilt_size),
815ec55c118SRasesh Mody
816ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_reg_fifo_size, &qed_dbg_reg_fifo_size),
817ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_reg_fifo, &qed_dbg_reg_fifo),
818ec55c118SRasesh Mody
819ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_igu_fifo_size, &qed_dbg_igu_fifo_size),
820ec55c118SRasesh Mody INIT_STRUCT_FIELD(dbg_igu_fifo, &qed_dbg_igu_fifo),
8212ea6f76aSRasesh Mody };
8224c4bdadfSHarish Patil
8234c4bdadfSHarish Patil const struct qed_eth_ops qed_eth_ops_pass = {
8244c4bdadfSHarish Patil INIT_STRUCT_FIELD(common, &qed_common_ops_pass),
8254c4bdadfSHarish Patil INIT_STRUCT_FIELD(fill_dev_info, &qed_fill_eth_dev_info),
8269ffe2a15SManish Chopra INIT_STRUCT_FIELD(sriov_configure, &qed_sriov_configure),
8274c4bdadfSHarish Patil };
8284c4bdadfSHarish Patil
qed_get_eth_ops(void)8294c4bdadfSHarish Patil const struct qed_eth_ops *qed_get_eth_ops(void)
8304c4bdadfSHarish Patil {
8314c4bdadfSHarish Patil return &qed_eth_ops_pass;
8324c4bdadfSHarish Patil }
833