net/qede/base: set driver type before sending load request
[dpdk.git] / drivers / net / qede / qede_main.c
1 /*
2  * Copyright (c) 2016 QLogic Corporation.
3  * All rights reserved.
4  * www.qlogic.com
5  *
6  * See LICENSE.qede_pmd for copyright and licensing details.
7  */
8
9 #include <limits.h>
10 #include <time.h>
11 #include <rte_alarm.h>
12
13 #include "qede_ethdev.h"
14
15 static uint8_t npar_tx_switching = 1;
16
17 /* Alarm timeout. */
18 #define QEDE_ALARM_TIMEOUT_US 100000
19
20 /* Global variable to hold absolute path of fw file */
21 char fw_file[PATH_MAX];
22
23 const char *QEDE_DEFAULT_FIRMWARE =
24         "/lib/firmware/qed/qed_init_values-8.18.9.0.bin";
25
26 static void
27 qed_update_pf_params(struct ecore_dev *edev, struct ecore_pf_params *params)
28 {
29         int i;
30
31         for (i = 0; i < edev->num_hwfns; i++) {
32                 struct ecore_hwfn *p_hwfn = &edev->hwfns[i];
33                 p_hwfn->pf_params = *params;
34         }
35 }
36
37 static void qed_init_pci(struct ecore_dev *edev, struct rte_pci_device *pci_dev)
38 {
39         edev->regview = pci_dev->mem_resource[0].addr;
40         edev->doorbells = pci_dev->mem_resource[2].addr;
41 }
42
43 static int
44 qed_probe(struct ecore_dev *edev, struct rte_pci_device *pci_dev,
45           enum qed_protocol protocol, uint32_t dp_module,
46           uint8_t dp_level, bool is_vf)
47 {
48         struct ecore_hw_prepare_params hw_prepare_params;
49         struct qede_dev *qdev = (struct qede_dev *)edev;
50         int rc;
51
52         ecore_init_struct(edev);
53         edev->drv_type = DRV_ID_DRV_TYPE_LINUX;
54         qdev->protocol = protocol;
55
56         if (is_vf)
57                 edev->b_is_vf = true;
58
59         ecore_init_dp(edev, dp_module, dp_level, NULL);
60         qed_init_pci(edev, pci_dev);
61
62         memset(&hw_prepare_params, 0, sizeof(hw_prepare_params));
63         hw_prepare_params.personality = ECORE_PCI_ETH;
64         hw_prepare_params.drv_resc_alloc = false;
65         hw_prepare_params.chk_reg_fifo = false;
66         hw_prepare_params.initiate_pf_flr = true;
67         hw_prepare_params.epoch = (u32)time(NULL);
68         rc = ecore_hw_prepare(edev, &hw_prepare_params);
69         if (rc) {
70                 DP_ERR(edev, "hw prepare failed\n");
71                 return rc;
72         }
73
74         return rc;
75 }
76
77 static int qed_nic_setup(struct ecore_dev *edev)
78 {
79         int rc, i;
80
81         rc = ecore_resc_alloc(edev);
82         if (rc)
83                 return rc;
84
85         DP_INFO(edev, "Allocated qed resources\n");
86         ecore_resc_setup(edev);
87
88         return rc;
89 }
90
91 #ifdef CONFIG_ECORE_ZIPPED_FW
92 static int qed_alloc_stream_mem(struct ecore_dev *edev)
93 {
94         int i;
95
96         for_each_hwfn(edev, i) {
97                 struct ecore_hwfn *p_hwfn = &edev->hwfns[i];
98
99                 p_hwfn->stream = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
100                                              sizeof(*p_hwfn->stream));
101                 if (!p_hwfn->stream)
102                         return -ENOMEM;
103         }
104
105         return 0;
106 }
107
108 static void qed_free_stream_mem(struct ecore_dev *edev)
109 {
110         int i;
111
112         for_each_hwfn(edev, i) {
113                 struct ecore_hwfn *p_hwfn = &edev->hwfns[i];
114
115                 if (!p_hwfn->stream)
116                         return;
117
118                 OSAL_FREE(p_hwfn->p_dev, p_hwfn->stream);
119         }
120 }
121 #endif
122
123 #ifdef CONFIG_ECORE_BINARY_FW
124 static int qed_load_firmware_data(struct ecore_dev *edev)
125 {
126         int fd;
127         struct stat st;
128         const char *fw = RTE_LIBRTE_QEDE_FW;
129
130         if (strcmp(fw, "") == 0)
131                 strcpy(fw_file, QEDE_DEFAULT_FIRMWARE);
132         else
133                 strcpy(fw_file, fw);
134
135         fd = open(fw_file, O_RDONLY);
136         if (fd < 0) {
137                 DP_NOTICE(edev, false, "Can't open firmware file\n");
138                 return -ENOENT;
139         }
140
141         if (fstat(fd, &st) < 0) {
142                 DP_NOTICE(edev, false, "Can't stat firmware file\n");
143                 close(fd);
144                 return -1;
145         }
146
147         edev->firmware = rte_zmalloc("qede_fw", st.st_size,
148                                     RTE_CACHE_LINE_SIZE);
149         if (!edev->firmware) {
150                 DP_NOTICE(edev, false, "Can't allocate memory for firmware\n");
151                 close(fd);
152                 return -ENOMEM;
153         }
154
155         if (read(fd, edev->firmware, st.st_size) != st.st_size) {
156                 DP_NOTICE(edev, false, "Can't read firmware data\n");
157                 close(fd);
158                 return -1;
159         }
160
161         edev->fw_len = st.st_size;
162         if (edev->fw_len < 104) {
163                 DP_NOTICE(edev, false, "Invalid fw size: %" PRIu64 "\n",
164                           edev->fw_len);
165                 close(fd);
166                 return -EINVAL;
167         }
168
169         close(fd);
170         return 0;
171 }
172 #endif
173
174 static void qed_handle_bulletin_change(struct ecore_hwfn *hwfn)
175 {
176         uint8_t mac[ETH_ALEN], is_mac_exist, is_mac_forced;
177
178         is_mac_exist = ecore_vf_bulletin_get_forced_mac(hwfn, mac,
179                                                       &is_mac_forced);
180         if (is_mac_exist && is_mac_forced)
181                 rte_memcpy(hwfn->hw_info.hw_mac_addr, mac, ETH_ALEN);
182
183         /* Always update link configuration according to bulletin */
184         qed_link_update(hwfn);
185 }
186
187 static void qede_vf_task(void *arg)
188 {
189         struct ecore_hwfn *p_hwfn = arg;
190         uint8_t change = 0;
191
192         /* Read the bulletin board, and re-schedule the task */
193         ecore_vf_read_bulletin(p_hwfn, &change);
194         if (change)
195                 qed_handle_bulletin_change(p_hwfn);
196
197         rte_eal_alarm_set(QEDE_ALARM_TIMEOUT_US, qede_vf_task, p_hwfn);
198 }
199
200 static void qed_start_iov_task(struct ecore_dev *edev)
201 {
202         struct ecore_hwfn *p_hwfn;
203         int i;
204
205         for_each_hwfn(edev, i) {
206                 p_hwfn = &edev->hwfns[i];
207                 if (!IS_PF(edev))
208                         rte_eal_alarm_set(QEDE_ALARM_TIMEOUT_US, qede_vf_task,
209                                           p_hwfn);
210         }
211 }
212
213 static void qed_stop_iov_task(struct ecore_dev *edev)
214 {
215         struct ecore_hwfn *p_hwfn;
216         int i;
217
218         for_each_hwfn(edev, i) {
219                 p_hwfn = &edev->hwfns[i];
220                 if (!IS_PF(edev))
221                         rte_eal_alarm_cancel(qede_vf_task, p_hwfn);
222         }
223 }
224 static int qed_slowpath_start(struct ecore_dev *edev,
225                               struct qed_slowpath_params *params)
226 {
227         bool allow_npar_tx_switching;
228         const uint8_t *data = NULL;
229         struct ecore_hwfn *hwfn;
230         struct ecore_mcp_drv_version drv_version;
231         struct ecore_hw_init_params hw_init_params;
232         struct qede_dev *qdev = (struct qede_dev *)edev;
233         int rc;
234
235 #ifdef CONFIG_ECORE_BINARY_FW
236         if (IS_PF(edev)) {
237                 rc = qed_load_firmware_data(edev);
238                 if (rc) {
239                         DP_ERR(edev, "Failed to find fw file %s\n", fw_file);
240                         goto err;
241                 }
242         }
243 #endif
244
245         rc = qed_nic_setup(edev);
246         if (rc)
247                 goto err;
248
249         /* set int_coalescing_mode */
250         edev->int_coalescing_mode = ECORE_COAL_MODE_ENABLE;
251
252 #ifdef CONFIG_ECORE_ZIPPED_FW
253         if (IS_PF(edev)) {
254                 /* Allocate stream for unzipping */
255                 rc = qed_alloc_stream_mem(edev);
256                 if (rc) {
257                         DP_NOTICE(edev, true,
258                         "Failed to allocate stream memory\n");
259                         goto err2;
260                 }
261         }
262
263         qed_start_iov_task(edev);
264 #endif
265
266 #ifdef CONFIG_ECORE_BINARY_FW
267         if (IS_PF(edev))
268                 data = (const uint8_t *)edev->firmware + sizeof(u32);
269 #endif
270
271         allow_npar_tx_switching = npar_tx_switching ? true : false;
272
273         /* Start the slowpath */
274         memset(&hw_init_params, 0, sizeof(hw_init_params));
275         hw_init_params.b_hw_start = true;
276         hw_init_params.int_mode = ECORE_INT_MODE_MSIX;
277         hw_init_params.allow_npar_tx_switch = allow_npar_tx_switching;
278         hw_init_params.bin_fw_data = data;
279         rc = ecore_hw_init(edev, &hw_init_params);
280         if (rc) {
281                 DP_ERR(edev, "ecore_hw_init failed\n");
282                 goto err2;
283         }
284
285         DP_INFO(edev, "HW inited and function started\n");
286
287         if (IS_PF(edev)) {
288                 hwfn = ECORE_LEADING_HWFN(edev);
289                 drv_version.version = (params->drv_major << 24) |
290                     (params->drv_minor << 16) |
291                     (params->drv_rev << 8) | (params->drv_eng);
292                 /* TBD: strlcpy() */
293                 strncpy((char *)drv_version.name, (const char *)params->name,
294                         MCP_DRV_VER_STR_SIZE - 4);
295                 rc = ecore_mcp_send_drv_version(hwfn, hwfn->p_main_ptt,
296                                                 &drv_version);
297                 if (rc) {
298                         DP_NOTICE(edev, true,
299                                   "Failed sending drv version command\n");
300                         return rc;
301                 }
302         }
303
304         ecore_reset_vport_stats(edev);
305
306         return 0;
307
308         ecore_hw_stop(edev);
309 err2:
310         ecore_resc_free(edev);
311 err:
312 #ifdef CONFIG_ECORE_BINARY_FW
313         if (IS_PF(edev)) {
314                 if (edev->firmware)
315                         rte_free(edev->firmware);
316                 edev->firmware = NULL;
317         }
318 #endif
319         qed_stop_iov_task(edev);
320
321         return rc;
322 }
323
324 static int
325 qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info)
326 {
327         struct ecore_ptt *ptt = NULL;
328
329         memset(dev_info, 0, sizeof(struct qed_dev_info));
330         dev_info->num_hwfns = edev->num_hwfns;
331         dev_info->is_mf_default = IS_MF_DEFAULT(&edev->hwfns[0]);
332         dev_info->mtu = ECORE_LEADING_HWFN(edev)->hw_info.mtu;
333
334         rte_memcpy(&dev_info->hw_mac, &edev->hwfns[0].hw_info.hw_mac_addr,
335                ETHER_ADDR_LEN);
336
337         if (IS_PF(edev)) {
338                 dev_info->fw_major = FW_MAJOR_VERSION;
339                 dev_info->fw_minor = FW_MINOR_VERSION;
340                 dev_info->fw_rev = FW_REVISION_VERSION;
341                 dev_info->fw_eng = FW_ENGINEERING_VERSION;
342                 dev_info->mf_mode = edev->mf_mode;
343                 dev_info->tx_switching = false;
344
345                 ptt = ecore_ptt_acquire(ECORE_LEADING_HWFN(edev));
346                 if (ptt) {
347                         ecore_mcp_get_mfw_ver(ECORE_LEADING_HWFN(edev), ptt,
348                                               &dev_info->mfw_rev, NULL);
349
350                         ecore_mcp_get_flash_size(ECORE_LEADING_HWFN(edev), ptt,
351                                                  &dev_info->flash_size);
352
353                         /* Workaround to allow PHY-read commands for
354                          * B0 bringup.
355                          */
356                         if (ECORE_IS_BB_B0(edev))
357                                 dev_info->flash_size = 0xffffffff;
358
359                         ecore_ptt_release(ECORE_LEADING_HWFN(edev), ptt);
360                 }
361         } else {
362                 ecore_vf_get_fw_version(&edev->hwfns[0], &dev_info->fw_major,
363                                         &dev_info->fw_minor, &dev_info->fw_rev,
364                                         &dev_info->fw_eng);
365
366                 ecore_mcp_get_mfw_ver(ECORE_LEADING_HWFN(edev), ptt,
367                                       &dev_info->mfw_rev, NULL);
368         }
369
370         return 0;
371 }
372
373 int
374 qed_fill_eth_dev_info(struct ecore_dev *edev, struct qed_dev_eth_info *info)
375 {
376         struct qede_dev *qdev = (struct qede_dev *)edev;
377         uint8_t queues = 0;
378         int i;
379
380         memset(info, 0, sizeof(*info));
381
382         info->num_tc = 1 /* @@@TBD aelior MULTI_COS */;
383
384         if (IS_PF(edev)) {
385                 int max_vf_vlan_filters = 0;
386
387                 info->num_queues = 0;
388                 for_each_hwfn(edev, i)
389                         info->num_queues +=
390                         FEAT_NUM(&edev->hwfns[i], ECORE_PF_L2_QUE);
391
392                 if (edev->p_iov_info)
393                         max_vf_vlan_filters = edev->p_iov_info->total_vfs *
394                                               ECORE_ETH_VF_NUM_VLAN_FILTERS;
395                 info->num_vlan_filters = RESC_NUM(&edev->hwfns[0], ECORE_VLAN) -
396                                          max_vf_vlan_filters;
397
398                 rte_memcpy(&info->port_mac, &edev->hwfns[0].hw_info.hw_mac_addr,
399                            ETHER_ADDR_LEN);
400         } else {
401                 ecore_vf_get_num_rxqs(ECORE_LEADING_HWFN(edev),
402                                       &info->num_queues);
403                 if (edev->num_hwfns > 1) {
404                         ecore_vf_get_num_rxqs(&edev->hwfns[1], &queues);
405                         info->num_queues += queues;
406                 }
407
408                 ecore_vf_get_num_vlan_filters(&edev->hwfns[0],
409                                               (u8 *)&info->num_vlan_filters);
410
411                 ecore_vf_get_port_mac(&edev->hwfns[0],
412                                       (uint8_t *)&info->port_mac);
413
414                 info->is_legacy = ecore_vf_get_pre_fp_hsi(&edev->hwfns[0]);
415         }
416
417         qed_fill_dev_info(edev, &info->common);
418
419         if (IS_VF(edev))
420                 memset(&info->common.hw_mac, 0, ETHER_ADDR_LEN);
421
422         return 0;
423 }
424
425 static void qed_set_name(struct ecore_dev *edev, char name[NAME_SIZE])
426 {
427         int i;
428
429         rte_memcpy(edev->name, name, NAME_SIZE);
430         for_each_hwfn(edev, i) {
431                 snprintf(edev->hwfns[i].name, NAME_SIZE, "%s-%d", name, i);
432         }
433 }
434
435 static uint32_t
436 qed_sb_init(struct ecore_dev *edev, struct ecore_sb_info *sb_info,
437             void *sb_virt_addr, dma_addr_t sb_phy_addr,
438             uint16_t sb_id, enum qed_sb_type type)
439 {
440         struct ecore_hwfn *p_hwfn;
441         int hwfn_index;
442         uint16_t rel_sb_id;
443         uint8_t n_hwfns;
444         uint32_t rc;
445
446         /* RoCE uses single engine and CMT uses two engines. When using both
447          * we force only a single engine. Storage uses only engine 0 too.
448          */
449         if (type == QED_SB_TYPE_L2_QUEUE)
450                 n_hwfns = edev->num_hwfns;
451         else
452                 n_hwfns = 1;
453
454         hwfn_index = sb_id % n_hwfns;
455         p_hwfn = &edev->hwfns[hwfn_index];
456         rel_sb_id = sb_id / n_hwfns;
457
458         DP_INFO(edev, "hwfn [%d] <--[init]-- SB %04x [0x%04x upper]\n",
459                 hwfn_index, rel_sb_id, sb_id);
460
461         rc = ecore_int_sb_init(p_hwfn, p_hwfn->p_main_ptt, sb_info,
462                                sb_virt_addr, sb_phy_addr, rel_sb_id);
463
464         return rc;
465 }
466
467 static void qed_fill_link(struct ecore_hwfn *hwfn,
468                           struct qed_link_output *if_link)
469 {
470         struct ecore_mcp_link_params params;
471         struct ecore_mcp_link_state link;
472         struct ecore_mcp_link_capabilities link_caps;
473         uint32_t media_type;
474         uint8_t change = 0;
475
476         memset(if_link, 0, sizeof(*if_link));
477
478         /* Prepare source inputs */
479         if (IS_PF(hwfn->p_dev)) {
480                 rte_memcpy(&params, ecore_mcp_get_link_params(hwfn),
481                        sizeof(params));
482                 rte_memcpy(&link, ecore_mcp_get_link_state(hwfn), sizeof(link));
483                 rte_memcpy(&link_caps, ecore_mcp_get_link_capabilities(hwfn),
484                        sizeof(link_caps));
485         } else {
486                 ecore_vf_read_bulletin(hwfn, &change);
487                 ecore_vf_get_link_params(hwfn, &params);
488                 ecore_vf_get_link_state(hwfn, &link);
489                 ecore_vf_get_link_caps(hwfn, &link_caps);
490         }
491
492         /* Set the link parameters to pass to protocol driver */
493         if (link.link_up)
494                 if_link->link_up = true;
495
496         if (link.link_up)
497                 if_link->speed = link.speed;
498
499         if_link->duplex = QEDE_DUPLEX_FULL;
500
501         /* Fill up the native advertised speed cap mask */
502         if_link->adv_speed = params.speed.advertised_speeds;
503
504         if (params.speed.autoneg)
505                 if_link->supported_caps |= QEDE_SUPPORTED_AUTONEG;
506
507         if (params.pause.autoneg || params.pause.forced_rx ||
508             params.pause.forced_tx)
509                 if_link->supported_caps |= QEDE_SUPPORTED_PAUSE;
510
511         if (params.pause.autoneg)
512                 if_link->pause_config |= QED_LINK_PAUSE_AUTONEG_ENABLE;
513
514         if (params.pause.forced_rx)
515                 if_link->pause_config |= QED_LINK_PAUSE_RX_ENABLE;
516
517         if (params.pause.forced_tx)
518                 if_link->pause_config |= QED_LINK_PAUSE_TX_ENABLE;
519 }
520
521 static void
522 qed_get_current_link(struct ecore_dev *edev, struct qed_link_output *if_link)
523 {
524         qed_fill_link(&edev->hwfns[0], if_link);
525
526 #ifdef CONFIG_QED_SRIOV
527         for_each_hwfn(cdev, i)
528                 qed_inform_vf_link_state(&cdev->hwfns[i]);
529 #endif
530 }
531
532 static int qed_set_link(struct ecore_dev *edev, struct qed_link_params *params)
533 {
534         struct ecore_hwfn *hwfn;
535         struct ecore_ptt *ptt;
536         struct ecore_mcp_link_params *link_params;
537         int rc;
538
539         if (IS_VF(edev))
540                 return 0;
541
542         /* The link should be set only once per PF */
543         hwfn = &edev->hwfns[0];
544
545         ptt = ecore_ptt_acquire(hwfn);
546         if (!ptt)
547                 return -EBUSY;
548
549         link_params = ecore_mcp_get_link_params(hwfn);
550         if (params->override_flags & QED_LINK_OVERRIDE_SPEED_AUTONEG)
551                 link_params->speed.autoneg = params->autoneg;
552
553         if (params->override_flags & QED_LINK_OVERRIDE_PAUSE_CONFIG) {
554                 if (params->pause_config & QED_LINK_PAUSE_AUTONEG_ENABLE)
555                         link_params->pause.autoneg = true;
556                 else
557                         link_params->pause.autoneg = false;
558                 if (params->pause_config & QED_LINK_PAUSE_RX_ENABLE)
559                         link_params->pause.forced_rx = true;
560                 else
561                         link_params->pause.forced_rx = false;
562                 if (params->pause_config & QED_LINK_PAUSE_TX_ENABLE)
563                         link_params->pause.forced_tx = true;
564                 else
565                         link_params->pause.forced_tx = false;
566         }
567
568         rc = ecore_mcp_set_link(hwfn, ptt, params->link_up);
569
570         ecore_ptt_release(hwfn, ptt);
571
572         return rc;
573 }
574
575 void qed_link_update(struct ecore_hwfn *hwfn)
576 {
577         struct qed_link_output if_link;
578
579         qed_fill_link(hwfn, &if_link);
580 }
581
582 static int qed_drain(struct ecore_dev *edev)
583 {
584         struct ecore_hwfn *hwfn;
585         struct ecore_ptt *ptt;
586         int i, rc;
587
588         if (IS_VF(edev))
589                 return 0;
590
591         for_each_hwfn(edev, i) {
592                 hwfn = &edev->hwfns[i];
593                 ptt = ecore_ptt_acquire(hwfn);
594                 if (!ptt) {
595                         DP_NOTICE(hwfn, true, "Failed to drain NIG; No PTT\n");
596                         return -EBUSY;
597                 }
598                 rc = ecore_mcp_drain(hwfn, ptt);
599                 if (rc)
600                         return rc;
601                 ecore_ptt_release(hwfn, ptt);
602         }
603
604         return 0;
605 }
606
607 static int qed_nic_stop(struct ecore_dev *edev)
608 {
609         int i, rc;
610
611         rc = ecore_hw_stop(edev);
612         for (i = 0; i < edev->num_hwfns; i++) {
613                 struct ecore_hwfn *p_hwfn = &edev->hwfns[i];
614
615                 if (p_hwfn->b_sp_dpc_enabled)
616                         p_hwfn->b_sp_dpc_enabled = false;
617         }
618         return rc;
619 }
620
621 static int qed_nic_reset(struct ecore_dev *edev)
622 {
623         int rc;
624
625         rc = ecore_hw_reset(edev);
626         if (rc)
627                 return rc;
628
629         ecore_resc_free(edev);
630
631         return 0;
632 }
633
634 static int qed_slowpath_stop(struct ecore_dev *edev)
635 {
636 #ifdef CONFIG_QED_SRIOV
637         int i;
638 #endif
639
640         if (!edev)
641                 return -ENODEV;
642
643         if (IS_PF(edev)) {
644 #ifdef CONFIG_ECORE_ZIPPED_FW
645                 qed_free_stream_mem(edev);
646 #endif
647
648 #ifdef CONFIG_QED_SRIOV
649                 if (IS_QED_ETH_IF(edev))
650                         qed_sriov_disable(edev, true);
651 #endif
652                 qed_nic_stop(edev);
653         }
654
655         qed_nic_reset(edev);
656         qed_stop_iov_task(edev);
657
658         return 0;
659 }
660
661 static void qed_remove(struct ecore_dev *edev)
662 {
663         if (!edev)
664                 return;
665
666         ecore_hw_remove(edev);
667 }
668
669 static int qed_send_drv_state(struct ecore_dev *edev, bool active)
670 {
671         struct ecore_hwfn *hwfn = ECORE_LEADING_HWFN(edev);
672         struct ecore_ptt *ptt;
673         int status = 0;
674
675         ptt = ecore_ptt_acquire(hwfn);
676         if (!ptt)
677                 return -EAGAIN;
678
679         status = ecore_mcp_ov_update_driver_state(hwfn, ptt, active ?
680                                                   ECORE_OV_DRIVER_STATE_ACTIVE :
681                                                 ECORE_OV_DRIVER_STATE_DISABLED);
682
683         ecore_ptt_release(hwfn, ptt);
684
685         return status;
686 }
687
688 static int qed_get_sb_info(struct ecore_dev *edev, struct ecore_sb_info *sb,
689                            u16 qid, struct ecore_sb_info_dbg *sb_dbg)
690 {
691         struct ecore_hwfn *hwfn = &edev->hwfns[qid % edev->num_hwfns];
692         struct ecore_ptt *ptt;
693         int rc;
694
695         if (IS_VF(edev))
696                 return -EINVAL;
697
698         ptt = ecore_ptt_acquire(hwfn);
699         if (!ptt) {
700                 DP_NOTICE(hwfn, true, "Can't acquire PTT\n");
701                 return -EAGAIN;
702         }
703
704         memset(sb_dbg, 0, sizeof(*sb_dbg));
705         rc = ecore_int_get_sb_dbg(hwfn, ptt, sb, sb_dbg);
706
707         ecore_ptt_release(hwfn, ptt);
708         return rc;
709 }
710
711 const struct qed_common_ops qed_common_ops_pass = {
712         INIT_STRUCT_FIELD(probe, &qed_probe),
713         INIT_STRUCT_FIELD(update_pf_params, &qed_update_pf_params),
714         INIT_STRUCT_FIELD(slowpath_start, &qed_slowpath_start),
715         INIT_STRUCT_FIELD(set_name, &qed_set_name),
716         INIT_STRUCT_FIELD(chain_alloc, &ecore_chain_alloc),
717         INIT_STRUCT_FIELD(chain_free, &ecore_chain_free),
718         INIT_STRUCT_FIELD(sb_init, &qed_sb_init),
719         INIT_STRUCT_FIELD(get_link, &qed_get_current_link),
720         INIT_STRUCT_FIELD(set_link, &qed_set_link),
721         INIT_STRUCT_FIELD(drain, &qed_drain),
722         INIT_STRUCT_FIELD(slowpath_stop, &qed_slowpath_stop),
723         INIT_STRUCT_FIELD(remove, &qed_remove),
724         INIT_STRUCT_FIELD(send_drv_state, &qed_send_drv_state),
725 };