event/dlb2: add port setup
[dpdk.git] / drivers / event / dlb2 / pf / dlb2_main.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2020 Intel Corporation
3  */
4
5 #include <stdint.h>
6 #include <stdbool.h>
7 #include <stdio.h>
8 #include <errno.h>
9 #include <assert.h>
10 #include <unistd.h>
11 #include <string.h>
12
13 #include <rte_malloc.h>
14 #include <rte_errno.h>
15
16 #include "base/dlb2_resource.h"
17 #include "base/dlb2_osdep.h"
18 #include "base/dlb2_regs.h"
19 #include "dlb2_main.h"
20 #include "../dlb2_user.h"
21 #include "../dlb2_priv.h"
22 #include "../dlb2_iface.h"
23 #include "../dlb2_inline_fns.h"
24
25 #define PF_ID_ZERO 0    /* PF ONLY! */
26 #define NO_OWNER_VF 0   /* PF ONLY! */
27 #define NOT_VF_REQ false /* PF ONLY! */
28
29 #define DLB2_PCI_CFG_SPACE_SIZE 256
30 #define DLB2_PCI_CAP_POINTER 0x34
31 #define DLB2_PCI_CAP_NEXT(hdr) (((hdr) >> 8) & 0xFC)
32 #define DLB2_PCI_CAP_ID(hdr) ((hdr) & 0xFF)
33 #define DLB2_PCI_EXT_CAP_NEXT(hdr) (((hdr) >> 20) & 0xFFC)
34 #define DLB2_PCI_EXT_CAP_ID(hdr) ((hdr) & 0xFFFF)
35 #define DLB2_PCI_EXT_CAP_ID_ERR 1
36 #define DLB2_PCI_ERR_UNCOR_MASK 8
37 #define DLB2_PCI_ERR_UNC_UNSUP  0x00100000
38
39 #define DLB2_PCI_EXP_DEVCTL 8
40 #define DLB2_PCI_LNKCTL 16
41 #define DLB2_PCI_SLTCTL 24
42 #define DLB2_PCI_RTCTL 28
43 #define DLB2_PCI_EXP_DEVCTL2 40
44 #define DLB2_PCI_LNKCTL2 48
45 #define DLB2_PCI_SLTCTL2 56
46 #define DLB2_PCI_CMD 4
47 #define DLB2_PCI_X_CMD 2
48 #define DLB2_PCI_EXP_DEVSTA 10
49 #define DLB2_PCI_EXP_DEVSTA_TRPND 0x20
50 #define DLB2_PCI_EXP_DEVCTL_BCR_FLR 0x8000
51
52 #define DLB2_PCI_CAP_ID_EXP       0x10
53 #define DLB2_PCI_CAP_ID_MSIX      0x11
54 #define DLB2_PCI_EXT_CAP_ID_PAS   0x1B
55 #define DLB2_PCI_EXT_CAP_ID_PRI   0x13
56 #define DLB2_PCI_EXT_CAP_ID_ACS   0xD
57
58 #define DLB2_PCI_PRI_CTRL_ENABLE         0x1
59 #define DLB2_PCI_PRI_ALLOC_REQ           0xC
60 #define DLB2_PCI_PRI_CTRL                0x4
61 #define DLB2_PCI_MSIX_FLAGS              0x2
62 #define DLB2_PCI_MSIX_FLAGS_ENABLE       0x8000
63 #define DLB2_PCI_MSIX_FLAGS_MASKALL      0x4000
64 #define DLB2_PCI_ERR_ROOT_STATUS         0x30
65 #define DLB2_PCI_ERR_COR_STATUS          0x10
66 #define DLB2_PCI_ERR_UNCOR_STATUS        0x4
67 #define DLB2_PCI_COMMAND_INTX_DISABLE    0x400
68 #define DLB2_PCI_ACS_CAP                 0x4
69 #define DLB2_PCI_ACS_CTRL                0x6
70 #define DLB2_PCI_ACS_SV                  0x1
71 #define DLB2_PCI_ACS_RR                  0x4
72 #define DLB2_PCI_ACS_CR                  0x8
73 #define DLB2_PCI_ACS_UF                  0x10
74 #define DLB2_PCI_ACS_EC                  0x20
75
76 static int
77 dlb2_pci_find_ext_capability(struct rte_pci_device *pdev, uint32_t id)
78 {
79         uint32_t hdr;
80         size_t sz;
81         int pos;
82
83         pos = DLB2_PCI_CFG_SPACE_SIZE;
84         sz = sizeof(hdr);
85
86         while (pos > 0xFF) {
87                 if (rte_pci_read_config(pdev, &hdr, sz, pos) != (int)sz)
88                         return -1;
89
90                 if (DLB2_PCI_EXT_CAP_ID(hdr) == id)
91                         return pos;
92
93                 pos = DLB2_PCI_EXT_CAP_NEXT(hdr);
94         }
95
96         return -1;
97 }
98
99 static int dlb2_pci_find_capability(struct rte_pci_device *pdev, uint32_t id)
100 {
101         uint8_t pos;
102         int ret;
103         uint16_t hdr;
104
105         ret = rte_pci_read_config(pdev, &pos, 1, DLB2_PCI_CAP_POINTER);
106         pos &= 0xFC;
107
108         if (ret != 1)
109                 return -1;
110
111         while (pos > 0x3F) {
112                 ret = rte_pci_read_config(pdev, &hdr, 2, pos);
113                 if (ret != 2)
114                         return -1;
115
116                 if (DLB2_PCI_CAP_ID(hdr) == id)
117                         return pos;
118
119                 if (DLB2_PCI_CAP_ID(hdr) == 0xFF)
120                         return -1;
121
122                 pos = DLB2_PCI_CAP_NEXT(hdr);
123         }
124
125         return -1;
126 }
127
128 static int
129 dlb2_pf_init_driver_state(struct dlb2_dev *dlb2_dev)
130 {
131         rte_spinlock_init(&dlb2_dev->resource_mutex);
132
133         return 0;
134 }
135
136 static void dlb2_pf_enable_pm(struct dlb2_dev *dlb2_dev)
137 {
138         dlb2_clr_pmcsr_disable(&dlb2_dev->hw);
139 }
140
141 #define DLB2_READY_RETRY_LIMIT 1000
142 static int dlb2_pf_wait_for_device_ready(struct dlb2_dev *dlb2_dev)
143 {
144         u32 retries = 0;
145
146         /* Allow at least 1s for the device to become active after power-on */
147         for (retries = 0; retries < DLB2_READY_RETRY_LIMIT; retries++) {
148                 union dlb2_cfg_mstr_cfg_diagnostic_idle_status idle;
149                 union dlb2_cfg_mstr_cfg_pm_status pm_st;
150                 u32 addr;
151
152                 addr = DLB2_CFG_MSTR_CFG_PM_STATUS;
153                 pm_st.val = DLB2_CSR_RD(&dlb2_dev->hw, addr);
154                 addr = DLB2_CFG_MSTR_CFG_DIAGNOSTIC_IDLE_STATUS;
155                 idle.val = DLB2_CSR_RD(&dlb2_dev->hw, addr);
156                 if (pm_st.field.pmsm == 1 && idle.field.dlb_func_idle == 1)
157                         break;
158
159                 rte_delay_ms(1);
160         };
161
162         if (retries == DLB2_READY_RETRY_LIMIT) {
163                 DLB2_LOG_ERR("[%s()] wait for device ready timed out\n",
164                        __func__);
165                 return -1;
166         }
167
168         return 0;
169 }
170
171 struct dlb2_dev *
172 dlb2_probe(struct rte_pci_device *pdev)
173 {
174         struct dlb2_dev *dlb2_dev;
175         int ret = 0;
176
177         DLB2_INFO(dlb2_dev, "probe\n");
178
179         dlb2_dev = rte_malloc("DLB2_PF", sizeof(struct dlb2_dev),
180                               RTE_CACHE_LINE_SIZE);
181
182         if (dlb2_dev == NULL) {
183                 ret = -ENOMEM;
184                 goto dlb2_dev_malloc_fail;
185         }
186
187         /* PCI Bus driver has already mapped bar space into process.
188          * Save off our IO register and FUNC addresses.
189          */
190
191         /* BAR 0 */
192         if (pdev->mem_resource[0].addr == NULL) {
193                 DLB2_ERR(dlb2_dev, "probe: BAR 0 addr (csr_kva) is NULL\n");
194                 ret = -EINVAL;
195                 goto pci_mmap_bad_addr;
196         }
197         dlb2_dev->hw.func_kva = (void *)(uintptr_t)pdev->mem_resource[0].addr;
198         dlb2_dev->hw.func_phys_addr = pdev->mem_resource[0].phys_addr;
199
200         DLB2_INFO(dlb2_dev, "DLB2 FUNC VA=%p, PA=%p, len=%p\n",
201                   (void *)dlb2_dev->hw.func_kva,
202                   (void *)dlb2_dev->hw.func_phys_addr,
203                   (void *)(pdev->mem_resource[0].len));
204
205         /* BAR 2 */
206         if (pdev->mem_resource[2].addr == NULL) {
207                 DLB2_ERR(dlb2_dev, "probe: BAR 2 addr (func_kva) is NULL\n");
208                 ret = -EINVAL;
209                 goto pci_mmap_bad_addr;
210         }
211         dlb2_dev->hw.csr_kva = (void *)(uintptr_t)pdev->mem_resource[2].addr;
212         dlb2_dev->hw.csr_phys_addr = pdev->mem_resource[2].phys_addr;
213
214         DLB2_INFO(dlb2_dev, "DLB2 CSR VA=%p, PA=%p, len=%p\n",
215                   (void *)dlb2_dev->hw.csr_kva,
216                   (void *)dlb2_dev->hw.csr_phys_addr,
217                   (void *)(pdev->mem_resource[2].len));
218
219         dlb2_dev->pdev = pdev;
220
221         /* PM enable must be done before any other MMIO accesses, and this
222          * setting is persistent across device reset.
223          */
224         dlb2_pf_enable_pm(dlb2_dev);
225
226         ret = dlb2_pf_wait_for_device_ready(dlb2_dev);
227         if (ret)
228                 goto wait_for_device_ready_fail;
229
230         ret = dlb2_pf_reset(dlb2_dev);
231         if (ret)
232                 goto dlb2_reset_fail;
233
234         ret = dlb2_pf_init_driver_state(dlb2_dev);
235         if (ret)
236                 goto init_driver_state_fail;
237
238         ret = dlb2_resource_init(&dlb2_dev->hw);
239         if (ret)
240                 goto resource_init_fail;
241
242         return dlb2_dev;
243
244 resource_init_fail:
245         dlb2_resource_free(&dlb2_dev->hw);
246 init_driver_state_fail:
247 dlb2_reset_fail:
248 pci_mmap_bad_addr:
249 wait_for_device_ready_fail:
250         rte_free(dlb2_dev);
251 dlb2_dev_malloc_fail:
252         rte_errno = ret;
253         return NULL;
254 }
255
256 int
257 dlb2_pf_reset(struct dlb2_dev *dlb2_dev)
258 {
259         int ret = 0;
260         int i = 0;
261         uint32_t dword[16];
262         uint16_t cmd;
263         off_t off;
264
265         uint16_t dev_ctl_word;
266         uint16_t dev_ctl2_word;
267         uint16_t lnk_word;
268         uint16_t lnk_word2;
269         uint16_t slt_word;
270         uint16_t slt_word2;
271         uint16_t rt_ctl_word;
272         uint32_t pri_reqs_dword;
273         uint16_t pri_ctrl_word;
274
275         int pcie_cap_offset;
276         int pri_cap_offset;
277         int msix_cap_offset;
278         int err_cap_offset;
279         int acs_cap_offset;
280         int wait_count;
281
282         uint16_t devsta_busy_word;
283         uint16_t devctl_word;
284
285         struct rte_pci_device *pdev = dlb2_dev->pdev;
286
287         /* Save PCI config state */
288
289         for (i = 0; i < 16; i++) {
290                 if (rte_pci_read_config(pdev, &dword[i], 4, i * 4) != 4)
291                         return ret;
292         }
293
294         pcie_cap_offset = dlb2_pci_find_capability(pdev, DLB2_PCI_CAP_ID_EXP);
295
296         if (pcie_cap_offset < 0) {
297                 DLB2_LOG_ERR("[%s()] failed to find the pcie capability\n",
298                        __func__);
299                 return pcie_cap_offset;
300         }
301
302         off = pcie_cap_offset + DLB2_PCI_EXP_DEVCTL;
303         if (rte_pci_read_config(pdev, &dev_ctl_word, 2, off) != 2)
304                 dev_ctl_word = 0;
305
306         off = pcie_cap_offset + DLB2_PCI_LNKCTL;
307         if (rte_pci_read_config(pdev, &lnk_word, 2, off) != 2)
308                 lnk_word = 0;
309
310         off = pcie_cap_offset + DLB2_PCI_SLTCTL;
311         if (rte_pci_read_config(pdev, &slt_word, 2, off) != 2)
312                 slt_word = 0;
313
314         off = pcie_cap_offset + DLB2_PCI_RTCTL;
315         if (rte_pci_read_config(pdev, &rt_ctl_word, 2, off) != 2)
316                 rt_ctl_word = 0;
317
318         off = pcie_cap_offset + DLB2_PCI_EXP_DEVCTL2;
319         if (rte_pci_read_config(pdev, &dev_ctl2_word, 2, off) != 2)
320                 dev_ctl2_word = 0;
321
322         off = pcie_cap_offset + DLB2_PCI_LNKCTL2;
323         if (rte_pci_read_config(pdev, &lnk_word2, 2, off) != 2)
324                 lnk_word2 = 0;
325
326         off = pcie_cap_offset + DLB2_PCI_SLTCTL2;
327         if (rte_pci_read_config(pdev, &slt_word2, 2, off) != 2)
328                 slt_word2 = 0;
329
330         off = DLB2_PCI_EXT_CAP_ID_PRI;
331         pri_cap_offset = dlb2_pci_find_ext_capability(pdev, off);
332
333         if (pri_cap_offset >= 0) {
334                 off = pri_cap_offset + DLB2_PCI_PRI_ALLOC_REQ;
335                 if (rte_pci_read_config(pdev, &pri_reqs_dword, 4, off) != 4)
336                         pri_reqs_dword = 0;
337         }
338
339         /* clear the PCI command register before issuing the FLR */
340
341         off = DLB2_PCI_CMD;
342         cmd = 0;
343         if (rte_pci_write_config(pdev, &cmd, 2, off) != 2) {
344                 DLB2_LOG_ERR("[%s()] failed to write the pci command\n",
345                        __func__);
346                 return ret;
347         }
348
349         /* issue the FLR */
350         for (wait_count = 0; wait_count < 4; wait_count++) {
351                 int sleep_time;
352
353                 off = pcie_cap_offset + DLB2_PCI_EXP_DEVSTA;
354                 ret = rte_pci_read_config(pdev, &devsta_busy_word, 2, off);
355                 if (ret != 2) {
356                         DLB2_LOG_ERR("[%s()] failed to read the pci device status\n",
357                                __func__);
358                         return ret;
359                 }
360
361                 if (!(devsta_busy_word & DLB2_PCI_EXP_DEVSTA_TRPND))
362                         break;
363
364                 sleep_time = (1 << (wait_count)) * 100;
365                 rte_delay_ms(sleep_time);
366         }
367
368         if (wait_count == 4) {
369                 DLB2_LOG_ERR("[%s()] wait for pci pending transactions timed out\n",
370                        __func__);
371                 return -1;
372         }
373
374         off = pcie_cap_offset + DLB2_PCI_EXP_DEVCTL;
375         ret = rte_pci_read_config(pdev, &devctl_word, 2, off);
376         if (ret != 2) {
377                 DLB2_LOG_ERR("[%s()] failed to read the pcie device control\n",
378                        __func__);
379                 return ret;
380         }
381
382         devctl_word |= DLB2_PCI_EXP_DEVCTL_BCR_FLR;
383
384         ret = rte_pci_write_config(pdev, &devctl_word, 2, off);
385         if (ret != 2) {
386                 DLB2_LOG_ERR("[%s()] failed to write the pcie device control\n",
387                        __func__);
388                 return ret;
389         }
390
391         rte_delay_ms(100);
392
393         /* Restore PCI config state */
394
395         if (pcie_cap_offset >= 0) {
396                 off = pcie_cap_offset + DLB2_PCI_EXP_DEVCTL;
397                 ret = rte_pci_write_config(pdev, &dev_ctl_word, 2, off);
398                 if (ret != 2) {
399                         DLB2_LOG_ERR("[%s()] failed to write the pcie device control at offset %d\n",
400                                 __func__, (int)off);
401                         return ret;
402                 }
403
404                 off = pcie_cap_offset + DLB2_PCI_LNKCTL;
405                 ret = rte_pci_write_config(pdev, &lnk_word, 2, off);
406                 if (ret != 2) {
407                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
408                                 __func__, (int)off);
409                         return ret;
410                 }
411
412                 off = pcie_cap_offset + DLB2_PCI_SLTCTL;
413                 ret = rte_pci_write_config(pdev, &slt_word, 2, off);
414                 if (ret != 2) {
415                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
416                                 __func__, (int)off);
417                         return ret;
418                 }
419
420                 off = pcie_cap_offset + DLB2_PCI_RTCTL;
421                 ret = rte_pci_write_config(pdev, &rt_ctl_word, 2, off);
422                 if (ret != 2) {
423                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
424                                 __func__, (int)off);
425                         return ret;
426                 }
427
428                 off = pcie_cap_offset + DLB2_PCI_EXP_DEVCTL2;
429                 ret = rte_pci_write_config(pdev, &dev_ctl2_word, 2, off);
430                 if (ret != 2) {
431                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
432                                 __func__, (int)off);
433                         return ret;
434                 }
435
436                 off = pcie_cap_offset + DLB2_PCI_LNKCTL2;
437                 ret = rte_pci_write_config(pdev, &lnk_word2, 2, off);
438                 if (ret != 2) {
439                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
440                                 __func__, (int)off);
441                         return ret;
442                 }
443
444                 off = pcie_cap_offset + DLB2_PCI_SLTCTL2;
445                 ret = rte_pci_write_config(pdev, &slt_word2, 2, off);
446                 if (ret != 2) {
447                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
448                                 __func__, (int)off);
449                         return ret;
450                 }
451         }
452
453         if (pri_cap_offset >= 0) {
454                 pri_ctrl_word = DLB2_PCI_PRI_CTRL_ENABLE;
455
456                 off = pri_cap_offset + DLB2_PCI_PRI_ALLOC_REQ;
457                 ret = rte_pci_write_config(pdev, &pri_reqs_dword, 4, off);
458                 if (ret != 4) {
459                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
460                                 __func__, (int)off);
461                         return ret;
462                 }
463
464                 off = pri_cap_offset + DLB2_PCI_PRI_CTRL;
465                 ret = rte_pci_write_config(pdev, &pri_ctrl_word, 2, off);
466                 if (ret != 2) {
467                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
468                                 __func__, (int)off);
469                         return ret;
470                 }
471         }
472
473         off = DLB2_PCI_EXT_CAP_ID_ERR;
474         err_cap_offset = dlb2_pci_find_ext_capability(pdev, off);
475
476         if (err_cap_offset >= 0) {
477                 uint32_t tmp;
478
479                 off = err_cap_offset + DLB2_PCI_ERR_ROOT_STATUS;
480                 if (rte_pci_read_config(pdev, &tmp, 4, off) != 4)
481                         tmp = 0;
482
483                 ret = rte_pci_write_config(pdev, &tmp, 4, off);
484                 if (ret != 4) {
485                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
486                                 __func__, (int)off);
487                         return ret;
488                 }
489
490                 off = err_cap_offset + DLB2_PCI_ERR_COR_STATUS;
491                 if (rte_pci_read_config(pdev, &tmp, 4, off) != 4)
492                         tmp = 0;
493
494                 ret = rte_pci_write_config(pdev, &tmp, 4, off);
495                 if (ret != 4) {
496                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
497                                 __func__, (int)off);
498                         return ret;
499                 }
500
501                 off = err_cap_offset + DLB2_PCI_ERR_UNCOR_STATUS;
502                 if (rte_pci_read_config(pdev, &tmp, 4, off) != 4)
503                         tmp = 0;
504
505                 ret = rte_pci_write_config(pdev, &tmp, 4, off);
506                 if (ret != 4) {
507                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
508                                 __func__, (int)off);
509                         return ret;
510                 }
511         }
512
513         for (i = 16; i > 0; i--) {
514                 off = (i - 1) * 4;
515                 ret = rte_pci_write_config(pdev, &dword[i - 1], 4, off);
516                 if (ret != 4) {
517                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
518                                 __func__, (int)off);
519                         return ret;
520                 }
521         }
522
523         off = DLB2_PCI_CMD;
524         if (rte_pci_read_config(pdev, &cmd, 2, off) == 2) {
525                 cmd &= ~DLB2_PCI_COMMAND_INTX_DISABLE;
526                 if (rte_pci_write_config(pdev, &cmd, 2, off) != 2) {
527                         DLB2_LOG_ERR("[%s()] failed to write the pci command\n",
528                                __func__);
529                         return ret;
530                 }
531         }
532
533         msix_cap_offset = dlb2_pci_find_capability(pdev,
534                                                    DLB2_PCI_CAP_ID_MSIX);
535         if (msix_cap_offset >= 0) {
536                 off = msix_cap_offset + DLB2_PCI_MSIX_FLAGS;
537                 if (rte_pci_read_config(pdev, &cmd, 2, off) == 2) {
538                         cmd |= DLB2_PCI_MSIX_FLAGS_ENABLE;
539                         cmd |= DLB2_PCI_MSIX_FLAGS_MASKALL;
540                         if (rte_pci_write_config(pdev, &cmd, 2, off) != 2) {
541                                 DLB2_LOG_ERR("[%s()] failed to write msix flags\n",
542                                        __func__);
543                                 return ret;
544                         }
545                 }
546
547                 off = msix_cap_offset + DLB2_PCI_MSIX_FLAGS;
548                 if (rte_pci_read_config(pdev, &cmd, 2, off) == 2) {
549                         cmd &= ~DLB2_PCI_MSIX_FLAGS_MASKALL;
550                         if (rte_pci_write_config(pdev, &cmd, 2, off) != 2) {
551                                 DLB2_LOG_ERR("[%s()] failed to write msix flags\n",
552                                        __func__);
553                                 return ret;
554                         }
555                 }
556         }
557
558         off = DLB2_PCI_EXT_CAP_ID_ACS;
559         acs_cap_offset = dlb2_pci_find_ext_capability(pdev, off);
560
561         if (acs_cap_offset >= 0) {
562                 uint16_t acs_cap, acs_ctrl, acs_mask;
563                 off = acs_cap_offset + DLB2_PCI_ACS_CAP;
564                 if (rte_pci_read_config(pdev, &acs_cap, 2, off) != 2)
565                         acs_cap = 0;
566
567                 off = acs_cap_offset + DLB2_PCI_ACS_CTRL;
568                 if (rte_pci_read_config(pdev, &acs_ctrl, 2, off) != 2)
569                         acs_ctrl = 0;
570
571                 acs_mask = DLB2_PCI_ACS_SV | DLB2_PCI_ACS_RR;
572                 acs_mask |= (DLB2_PCI_ACS_CR | DLB2_PCI_ACS_UF);
573                 acs_ctrl |= (acs_cap & acs_mask);
574
575                 ret = rte_pci_write_config(pdev, &acs_ctrl, 2, off);
576                 if (ret != 2) {
577                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
578                                 __func__, (int)off);
579                         return ret;
580                 }
581
582                 off = acs_cap_offset + DLB2_PCI_ACS_CTRL;
583                 if (rte_pci_read_config(pdev, &acs_ctrl, 2, off) != 2)
584                         acs_ctrl = 0;
585
586                 acs_mask = DLB2_PCI_ACS_RR | DLB2_PCI_ACS_CR;
587                 acs_mask |= DLB2_PCI_ACS_EC;
588                 acs_ctrl &= ~acs_mask;
589
590                 off = acs_cap_offset + DLB2_PCI_ACS_CTRL;
591                 ret = rte_pci_write_config(pdev, &acs_ctrl, 2, off);
592                 if (ret != 2) {
593                         DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
594                                 __func__, (int)off);
595                         return ret;
596                 }
597         }
598
599         return 0;
600 }
601
602 int
603 dlb2_pf_create_sched_domain(struct dlb2_hw *hw,
604                             struct dlb2_create_sched_domain_args *args,
605                             struct dlb2_cmd_response *resp)
606 {
607         return dlb2_hw_create_sched_domain(hw, args, resp, NOT_VF_REQ,
608                                            PF_ID_ZERO);
609 }
610
611 int
612 dlb2_pf_reset_domain(struct dlb2_hw *hw, u32 id)
613 {
614         return dlb2_reset_domain(hw, id, NOT_VF_REQ, PF_ID_ZERO);
615 }
616
617 int
618 dlb2_pf_create_ldb_queue(struct dlb2_hw *hw,
619                          u32 id,
620                          struct dlb2_create_ldb_queue_args *args,
621                          struct dlb2_cmd_response *resp)
622 {
623         return dlb2_hw_create_ldb_queue(hw, id, args, resp, NOT_VF_REQ,
624                                         PF_ID_ZERO);
625 }
626
627 int
628 dlb2_pf_create_ldb_port(struct dlb2_hw *hw,
629                         u32 id,
630                         struct dlb2_create_ldb_port_args *args,
631                         uintptr_t cq_dma_base,
632                         struct dlb2_cmd_response *resp)
633 {
634         return dlb2_hw_create_ldb_port(hw, id, args,
635                                        cq_dma_base,
636                                        resp,
637                                        NOT_VF_REQ,
638                                        PF_ID_ZERO);
639 }
640
641 int
642 dlb2_pf_create_dir_port(struct dlb2_hw *hw,
643                         u32 id,
644                         struct dlb2_create_dir_port_args *args,
645                         uintptr_t cq_dma_base,
646                         struct dlb2_cmd_response *resp)
647 {
648         return dlb2_hw_create_dir_port(hw, id, args,
649                                        cq_dma_base,
650                                        resp,
651                                        NOT_VF_REQ,
652                                        PF_ID_ZERO);
653 }