FD.io VPP  v17.04.2-2-ga8f93f8
Vector Packet Processing
pci_config.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /*
16  * pci.h: PCI definitions.
17  *
18  * Copyright (c) 2008 Eliot Dresselhaus
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  */
39 
40 #ifndef included_vlib_pci_config_h
41 #define included_vlib_pci_config_h
42 
43 #include <vppinfra/byte_order.h>
44 #include <vppinfra/error.h>
45 
46 typedef enum
47 {
50 
58 
65 
71 
77 
81  PCI_CLASS_MEMORY = 0x0500,
82 
93  PCI_CLASS_BRIDGE = 0x0600,
94 
101 
109 
116  PCI_CLASS_INPUT = 0x0900,
117 
121 
130 
138 
141 
147 
151  PCI_CLASS_CRYPT = 0x1000,
152 
155  PCI_CLASS_SP = 0x1100,
157 
158 static inline pci_device_class_t
160 {
161  return c & ~0xff;
162 }
163 
164 /*
165  * Under PCI, each device has 256 bytes of configuration address space,
166  * of which the first 64 bytes are standardized as follows:
167  */
168 typedef struct
169 {
172 
174 #define PCI_COMMAND_IO (1 << 0) /* Enable response in I/O space */
175 #define PCI_COMMAND_MEMORY (1 << 1) /* Enable response in Memory space */
176 #define PCI_COMMAND_BUS_MASTER (1 << 2) /* Enable bus mastering */
177 #define PCI_COMMAND_SPECIAL (1 << 3) /* Enable response to special cycles */
178 #define PCI_COMMAND_WRITE_INVALIDATE (1 << 4) /* Use memory write and invalidate */
179 #define PCI_COMMAND_VGA_PALETTE_SNOOP (1 << 5)
180 #define PCI_COMMAND_PARITY (1 << 6)
181 #define PCI_COMMAND_WAIT (1 << 7) /* Enable address/data stepping */
182 #define PCI_COMMAND_SERR (1 << 8) /* Enable SERR */
183 #define PCI_COMMAND_BACK_TO_BACK_WRITE (1 << 9)
184 #define PCI_COMMAND_INTX_DISABLE (1 << 10) /* INTx Emulation Disable */
185 
187 #define PCI_STATUS_INTX_PENDING (1 << 3)
188 #define PCI_STATUS_CAPABILITY_LIST (1 << 4)
189 #define PCI_STATUS_66MHZ (1 << 5) /* Support 66 Mhz PCI 2.1 bus */
190 #define PCI_STATUS_UDF (1 << 6) /* Support User Definable Features (obsolete) */
191 #define PCI_STATUS_BACK_TO_BACK_WRITE (1 << 7) /* Accept fast-back to back */
192 #define PCI_STATUS_PARITY_ERROR (1 << 8) /* Detected parity error */
193 #define PCI_STATUS_DEVSEL_GET(x) ((x >> 9) & 3) /* DEVSEL timing */
194 #define PCI_STATUS_DEVSEL_FAST (0 << 9)
195 #define PCI_STATUS_DEVSEL_MEDIUM (1 << 9)
196 #define PCI_STATUS_DEVSEL_SLOW (2 << 9)
197 #define PCI_STATUS_SIG_TARGET_ABORT (1 << 11) /* Set on target abort */
198 #define PCI_STATUS_REC_TARGET_ABORT (1 << 12) /* Master ack of " */
199 #define PCI_STATUS_REC_MASTER_ABORT (1 << 13) /* Set on master abort */
200 #define PCI_STATUS_SIG_SYSTEM_ERROR (1 << 14) /* Set when we drive SERR */
201 #define PCI_STATUS_DETECTED_PARITY_ERROR (1 << 15)
202 
204  u8 programming_interface_class; /* Reg. Level Programming Interface */
205 
206  pci_device_class_t device_class:16;
207 
210 
212 #define PCI_HEADER_TYPE_NORMAL 0
213 #define PCI_HEADER_TYPE_BRIDGE 1
214 #define PCI_HEADER_TYPE_CARDBUS 2
215 
217 #define PCI_BIST_CODE_MASK 0x0f /* Return result */
218 #define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */
219 #define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */
221 
222 /* Byte swap config header. */
223 always_inline void
225 {
227  return;
228 #define _(f,t) r->f = clib_byte_swap_##t (r->f)
229  _(vendor_id, u16);
230  _(device_id, u16);
231  _(command, u16);
232  _(status, u16);
233  _(device_class, u16);
234 #undef _
235 }
236 
237 /* Header type 0 (normal devices) */
238 typedef struct
239 {
241 
242  /*
243  * Base addresses specify locations in memory or I/O space.
244  * Decoded size can be determined by writing a value of
245  * 0xffffffff to the register, and reading it back. Only
246  * 1 bits are decoded.
247  */
248  u32 base_address[6];
249 
251 
254 
256 #define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */
257 #define PCI_ROM_ADDRESS_ENABLE 0x01
258 #define PCI_ROM_ADDRESS_MASK (~0x7ffUL)
259 
261  CLIB_PAD_FROM_TO (0x35, 0x3c);
262 
267 
268  u8 capability_data[0];
270 
271 always_inline void
273 {
274  int i;
276  return;
278 #define _(f,t) r->f = clib_byte_swap_##t (r->f)
279  for (i = 0; i < ARRAY_LEN (r->base_address); i++)
280  _(base_address[i], u32);
281  _(cardbus_cis, u16);
282  _(subsystem_vendor_id, u16);
283  _(subsystem_id, u16);
284  _(rom_address, u32);
285 #undef _
286 }
287 
288 /* Header type 1 (PCI-to-PCI bridges) */
289 typedef struct
290 {
292 
293  u32 base_address[2];
294 
295  /* Primary/secondary bus number. */
298 
299  /* Highest bus number behind the bridge */
301 
303 
304  /* I/O range behind bridge. */
305  u8 io_base, io_limit;
306 
307  /* Secondary status register, only bit 14 used */
309 
310  /* Memory range behind bridge in units of 64k bytes. */
311  u16 memory_base, memory_limit;
312 #define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL
313 #define PCI_MEMORY_RANGE_MASK (~0x0fUL)
314 
315  u16 prefetchable_memory_base, prefetchable_memory_limit;
316 #define PCI_PREF_RANGE_TYPE_MASK 0x0fUL
317 #define PCI_PREF_RANGE_TYPE_32 0x00
318 #define PCI_PREF_RANGE_TYPE_64 0x01
319 #define PCI_PREF_RANGE_MASK (~0x0fUL)
320 
325 
326  /* Same as for type 0. */
328  CLIB_PAD_FROM_TO (0x35, 0x37);
329 
331  CLIB_PAD_FROM_TO (0x3c, 0x3e);
332 
334 #define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */
335 #define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */
336 #define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */
337 #define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */
338 #define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */
339 #define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */
340 #define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */
341 
342  u8 capability_data[0];
344 
345 always_inline void
347 {
348  int i;
350  return;
352 #define _(f,t) r->f = clib_byte_swap_##t (r->f)
353  for (i = 0; i < ARRAY_LEN (r->base_address); i++)
354  _(base_address[i], u32);
355  _(secondary_status, u16);
356  _(memory_base, u16);
357  _(memory_limit, u16);
358  _(prefetchable_memory_base, u16);
359  _(prefetchable_memory_limit, u16);
360  _(prefetchable_memory_base_upper_32bits, u32);
361  _(prefetchable_memory_limit_upper_32bits, u32);
362  _(io_base_upper_16bits, u16);
363  _(io_limit_upper_16bits, u16);
364  _(rom_address, u32);
365  _(bridge_control, u16);
366 #undef _
367 }
368 
369 /* Capabilities. */
371 {
372  /* Power Management */
374 
375  /* Accelerated Graphics Port */
377 
378  /* Vital Product Data */
380 
381  /* Slot Identification */
383 
384  /* Message Signalled Interrupts */
386 
387  /* CompactPCI HotSwap */
389 
390  /* PCI-X */
392 
393  /* Hypertransport. */
395 
396  /* PCI Standard Hot-Plug Controller */
398 
399  /* PCI Express */
401 
402  /* MSI-X */
405 
406 /* Common header for capabilities. */
407 /* *INDENT-OFF* */
408 typedef CLIB_PACKED (struct
409  {
410  enum pci_capability_type type:8;
411  u8 next_offset;}) pci_capability_regs_t;
412 /* *INDENT-ON* */
413 
414 always_inline void *
416 {
417  pci_capability_regs_t *c;
418  u32 next_offset;
419  u32 ttl = 48;
420 
422  return 0;
423 
424  next_offset = t->first_capability_offset;
425  while (ttl-- && next_offset >= 0x40)
426  {
427  c = (void *) t + (next_offset & ~3);
428  if ((u8) c->type == 0xff)
429  break;
430  if (c->type == cap_type)
431  return c;
432  next_offset = c->next_offset;
433  }
434  return 0;
435 }
436 
437 /* Power Management Registers */
438 /* *INDENT-OFF* */
439 typedef CLIB_PACKED (struct
440  {
441  pci_capability_regs_t header; u16 capabilities;
442 #define PCI_PM_CAP_VER_MASK 0x0007 /* Version */
443 #define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */
444 #define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */
445 #define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
446 #define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */
447 #define PCI_PM_CAP_D1 0x0200 /* D1 power state support */
448 #define PCI_PM_CAP_D2 0x0400 /* D2 power state support */
449 #define PCI_PM_CAP_PME 0x0800 /* PME pin supported */
450 #define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */
451 #define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */
452 #define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */
453 #define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */
454 #define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */
455 #define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */
456  u16 control;
457 #define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
458 #define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
459 #define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */
460 #define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */
461 #define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
462  u8 extensions;
463 #define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */
464 #define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */
465  u8 data;}) pci_power_management_regs_t;
466 /* *INDENT-ON* */
467 
468 /* AGP registers */
469 /* *INDENT-OFF* */
470 typedef CLIB_PACKED (struct
471  {
472  pci_capability_regs_t header; u8 version;
473  u8 rest_of_capability_flags; u32 status; u32 command;
474  /* Command & status common bits. */
475 #define PCI_AGP_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */
476 #define PCI_AGP_SBA 0x0200 /* Sideband addressing supported */
477 #define PCI_AGP_64BIT 0x0020 /* 64-bit addressing supported */
478 #define PCI_AGP_ALLOW_TRANSACTIONS 0x0100 /* Allow processing of AGP transactions */
479 #define PCI_AGP_FW 0x0010 /* FW transfers supported/forced */
480 #define PCI_AGP_RATE4 0x0004 /* 4x transfer rate supported */
481 #define PCI_AGP_RATE2 0x0002 /* 2x transfer rate supported */
482 #define PCI_AGP_RATE1 0x0001 /* 1x transfer rate supported */
483  }) pci_agp_regs_t;
484 /* *INDENT-ON* */
485 
486 /* Vital Product Data */
487 /* *INDENT-OFF* */
488 typedef CLIB_PACKED (struct
489  {
490  pci_capability_regs_t header; u16 address;
491 #define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */
492 #define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */
493  u32 data;}) pci_vpd_regs_t;
494 /* *INDENT-ON* */
495 
496 /* Slot Identification */
497 /* *INDENT-OFF* */
498 typedef CLIB_PACKED (struct
499  {
500  pci_capability_regs_t header; u8 esr;
501 #define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */
502 #define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */
503  u8 chassis;}) pci_sid_regs_t;
504 /* *INDENT-ON* */
505 
506 /* Message Signalled Interrupts registers */
507 /* *INDENT-OFF* */
508 typedef CLIB_PACKED (struct
509  {
510  pci_capability_regs_t header; u16 flags;
511 #define PCI_MSI_FLAGS_ENABLE (1 << 0) /* MSI feature enabled */
512 #define PCI_MSI_FLAGS_GET_MAX_QUEUE_SIZE(x) ((x >> 1) & 0x7)
513 #define PCI_MSI_FLAGS_MAX_QUEUE_SIZE(x) (((x) & 0x7) << 1)
514 #define PCI_MSI_FLAGS_GET_QUEUE_SIZE(x) ((x >> 4) & 0x7)
515 #define PCI_MSI_FLAGS_QUEUE_SIZE(x) (((x) & 0x7) << 4)
516 #define PCI_MSI_FLAGS_64BIT (1 << 7) /* 64-bit addresses allowed */
517 #define PCI_MSI_FLAGS_MASKBIT (1 << 8) /* 64-bit mask bits allowed */
518  u32 address; u32 data; u32 mask_bits;}) pci_msi32_regs_t;
519 /* *INDENT-ON* */
520 
521 /* *INDENT-OFF* */
522 typedef CLIB_PACKED (struct
523  {
524  pci_capability_regs_t header; u16 flags;
525  u32 address[2];
526  u32 data; u32 mask_bits;}) pci_msi64_regs_t;
527 /* *INDENT-ON* */
528 
529 /* CompactPCI Hotswap Register */
530 /* *INDENT-OFF* */
531 typedef CLIB_PACKED (struct
532  {
533  pci_capability_regs_t header; u16 control_status;
534 #define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */
535 #define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */
536 #define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */
537 #define PCI_CHSWP_LOO 0x08 /* LED On / Off */
538 #define PCI_CHSWP_PI 0x30 /* Programming Interface */
539 #define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */
540 #define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */
541  }) pci_chswp_regs_t;
542 /* *INDENT-ON* */
543 
544 /* PCIX registers */
545 /* *INDENT-OFF* */
546 typedef CLIB_PACKED (struct
547  {
548  pci_capability_regs_t header; u16 command;
549 #define PCIX_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */
550 #define PCIX_CMD_ERO 0x0002 /* Enable Relaxed Ordering */
551 #define PCIX_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */
552 #define PCIX_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */
553 #define PCIX_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */
554  u32 status;
555 #define PCIX_STATUS_DEVFN 0x000000ff /* A copy of devfn */
556 #define PCIX_STATUS_BUS 0x0000ff00 /* A copy of bus nr */
557 #define PCIX_STATUS_64BIT 0x00010000 /* 64-bit device */
558 #define PCIX_STATUS_133MHZ 0x00020000 /* 133 MHz capable */
559 #define PCIX_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */
560 #define PCIX_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */
561 #define PCIX_STATUS_COMPLEX 0x00100000 /* Device Complexity */
562 #define PCIX_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */
563 #define PCIX_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */
564 #define PCIX_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */
565 #define PCIX_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */
566 #define PCIX_STATUS_266MHZ 0x40000000 /* 266 MHz capable */
567 #define PCIX_STATUS_533MHZ 0x80000000 /* 533 MHz capable */
568  }) pcix_config_regs_t;
569 /* *INDENT-ON* */
570 
571 static inline int
572 pcie_size_to_code (int bytes)
573 {
574  ASSERT (is_pow2 (bytes));
575  ASSERT (bytes <= 4096);
576  return min_log2 (bytes) - 7;
577 }
578 
579 static inline int
581 {
582  int size = 1 << (code + 7);
583  ASSERT (size <= 4096);
584  return size;
585 }
586 
587 /* PCI Express capability registers */
588 /* *INDENT-OFF* */
589 typedef CLIB_PACKED (struct
590  {
591  pci_capability_regs_t header; u16 pcie_capabilities;
592 #define PCIE_CAP_VERSION(x) (((x) >> 0) & 0xf)
593 #define PCIE_CAP_DEVICE_TYPE(x) (((x) >> 4) & 0xf)
594 #define PCIE_DEVICE_TYPE_ENDPOINT 0
595 #define PCIE_DEVICE_TYPE_LEGACY_ENDPOINT 1
596 #define PCIE_DEVICE_TYPE_ROOT_PORT 4
597  /* Upstream/downstream port of PCI Express switch. */
598 #define PCIE_DEVICE_TYPE_SWITCH_UPSTREAM 5
599 #define PCIE_DEVICE_TYPE_SWITCH_DOWNSTREAM 6
600 #define PCIE_DEVICE_TYPE_PCIE_TO_PCI_BRIDGE 7
601 #define PCIE_DEVICE_TYPE_PCI_TO_PCIE_BRIDGE 8
602  /* Root complex integrated endpoint. */
603 #define PCIE_DEVICE_TYPE_ROOT_COMPLEX_ENDPOINT 9
604 #define PCIE_DEVICE_TYPE_ROOT_COMPLEX_EVENT_COLLECTOR 10
605 #define PCIE_CAP_SLOW_IMPLEMENTED (1 << 8)
606 #define PCIE_CAP_MSI_IRQ(x) (((x) >> 9) & 0x1f)
607  u32 dev_capabilities;
608 #define PCIE_DEVCAP_MAX_PAYLOAD(x) (128 << (((x) >> 0) & 0x7))
609 #define PCIE_DEVCAP_PHANTOM_BITS(x) (((x) >> 3) & 0x3)
610 #define PCIE_DEVCAP_EXTENTED_TAG (1 << 5)
611 #define PCIE_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */
612 #define PCIE_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */
613 #define PCIE_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */
614 #define PCIE_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */
615 #define PCIE_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */
616 #define PCIE_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */
617 #define PCIE_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */
618  u16 dev_control;
619 #define PCIE_CTRL_CERE 0x0001 /* Correctable Error Reporting En. */
620 #define PCIE_CTRL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */
621 #define PCIE_CTRL_FERE 0x0004 /* Fatal Error Reporting Enable */
622 #define PCIE_CTRL_URRE 0x0008 /* Unsupported Request Reporting En. */
623 #define PCIE_CTRL_RELAX_EN 0x0010 /* Enable relaxed ordering */
624 #define PCIE_CTRL_MAX_PAYLOAD(n) (((n) & 7) << 5)
625 #define PCIE_CTRL_EXT_TAG 0x0100 /* Extended Tag Field Enable */
626 #define PCIE_CTRL_PHANTOM 0x0200 /* Phantom Functions Enable */
627 #define PCIE_CTRL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */
628 #define PCIE_CTRL_NOSNOOP_EN 0x0800 /* Enable No Snoop */
629 #define PCIE_CTRL_MAX_READ_REQUEST(n) (((n) & 7) << 12)
630  u16 dev_status;
631 #define PCIE_DEVSTA_AUXPD 0x10 /* AUX Power Detected */
632 #define PCIE_DEVSTA_TRPND 0x20 /* Transactions Pending */
633  u32 link_capabilities; u16 link_control; u16 link_status;
634  u32 slot_capabilities;
635  u16 slot_control; u16 slot_status; u16 root_control;
636 #define PCIE_RTCTL_SECEE 0x01 /* System Error on Correctable Error */
637 #define PCIE_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */
638 #define PCIE_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */
639 #define PCIE_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */
640 #define PCIE_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */
641  u16 root_capabilities;
642  u32 root_status;
643  u32 dev_capabilities2;
644  u16 dev_control2;
645  u16 dev_status2;
646  u32 link_capabilities2;
647  u16 link_control2;
648  u16 link_status2;
649  u32 slot_capabilities2; u16 slot_control2;
650  u16 slot_status2;}) pcie_config_regs_t;
651 /* *INDENT-ON* */
652 
653 /* PCI express extended capabilities. */
655 {
661 
662 /* Common header for capabilities. */
663 /* *INDENT-OFF* */
664 typedef CLIB_PACKED (struct
665  {
666 enum pcie_capability_type type:16; u16 version: 4; u16 next_capability:12;})
667  /* *INDENT-ON* */
668 pcie_capability_regs_t;
669 
670 /* *INDENT-OFF* */
671 typedef CLIB_PACKED (struct
672  {
673  pcie_capability_regs_t header; u32 uncorrectable_status;
674 #define PCIE_ERROR_UNC_LINK_TRAINING (1 << 0)
675 #define PCIE_ERROR_UNC_DATA_LINK_PROTOCOL (1 << 4)
676 #define PCIE_ERROR_UNC_SURPRISE_DOWN (1 << 5)
677 #define PCIE_ERROR_UNC_POISONED_TLP (1 << 12)
678 #define PCIE_ERROR_UNC_FLOW_CONTROL (1 << 13)
679 #define PCIE_ERROR_UNC_COMPLETION_TIMEOUT (1 << 14)
680 #define PCIE_ERROR_UNC_COMPLETER_ABORT (1 << 15)
681 #define PCIE_ERROR_UNC_UNEXPECTED_COMPLETION (1 << 16)
682 #define PCIE_ERROR_UNC_RX_OVERFLOW (1 << 17)
683 #define PCIE_ERROR_UNC_MALFORMED_TLP (1 << 18)
684 #define PCIE_ERROR_UNC_CRC_ERROR (1 << 19)
685 #define PCIE_ERROR_UNC_UNSUPPORTED_REQUEST (1 << 20)
686  u32 uncorrectable_mask;
687  u32 uncorrectable_severity; u32 correctable_status;
688 #define PCIE_ERROR_COR_RX_ERROR (1 << 0)
689 #define PCIE_ERROR_COR_BAD_TLP (1 << 6)
690 #define PCIE_ERROR_COR_BAD_DLLP (1 << 7)
691 #define PCIE_ERROR_COR_REPLAY_ROLLOVER (1 << 8)
692 #define PCIE_ERROR_COR_REPLAY_TIMER (1 << 12)
693 #define PCIE_ERROR_COR_ADVISORY (1 << 13)
694  u32 correctable_mask;
695  u32 control;
696  u32 log[4];
697  u32 root_command;
698  u32 root_status; u16 correctable_error_source;
699  u16 error_source;}) pcie_advanced_error_regs_t;
700 /* *INDENT-ON* */
701 
702 /* Virtual Channel */
703 #define PCI_VC_PORT_REG1 4
704 #define PCI_VC_PORT_REG2 8
705 #define PCI_VC_PORT_CTRL 12
706 #define PCI_VC_PORT_STATUS 14
707 #define PCI_VC_RES_CAP 16
708 #define PCI_VC_RES_CTRL 20
709 #define PCI_VC_RES_STATUS 26
710 
711 /* Power Budgeting */
712 #define PCI_PWR_DSR 4 /* Data Select Register */
713 #define PCI_PWR_DATA 8 /* Data Register */
714 #define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */
715 #define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */
716 #define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */
717 #define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */
718 #define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */
719 #define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */
720 #define PCI_PWR_CAP 12 /* Capability */
721 #define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */
722 
723 #endif /* included_vlib_pci_config_h */
724 
725 /*
726  * fd.io coding-style-patch-verification: ON
727  *
728  * Local Variables:
729  * eval: (c-set-style "gnu")
730  * End:
731  */
static pci_device_class_t pci_device_class_base(pci_device_class_t c)
Definition: pci_config.h:159
pci_config_header_t header
Definition: pci_config.h:291
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
pcie_capability_type
Definition: pci_config.h:654
static void * pci_config_find_capability(pci_config_type0_regs_t *t, int cap_type)
Definition: pci_config.h:415
pci_capability_type
Definition: pci_config.h:370
enum pcie_capability_type pcie_capability_type_t
enum pci_capability_type pci_capability_type_t
static void pci_config_header_little_to_host(pci_config_header_t *r)
Definition: pci_config.h:224
static uword min_log2(uword x)
Definition: clib.h:189
static void pci_config_type1_little_to_host(pci_config_type1_regs_t *r)
Definition: pci_config.h:346
#define always_inline
Definition: clib.h:84
static int pcie_size_to_code(int bytes)
Definition: pci_config.h:572
vhost_user_log_t log
Definition: vhost-user.h:86
pci_device_class_t
Definition: pci_config.h:46
static void pci_config_type0_little_to_host(pci_config_type0_regs_t *r)
Definition: pci_config.h:272
svmdb_client_t * c
#define PCI_STATUS_CAPABILITY_LIST
Definition: pci_config.h:188
#define ARRAY_LEN(x)
Definition: clib.h:59
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
typedef CLIB_PACKED(struct{enum pci_capability_type type:8;u8 next_offset;}) pci_capability_regs_t
u64 size
Definition: vhost-user.h:77
static uword is_pow2(uword x)
Definition: clib.h:272
#define CLIB_ARCH_IS_BIG_ENDIAN
Definition: byte_order.h:44
unsigned short u16
Definition: types.h:57
u32 prefetchable_memory_limit_upper_32bits
Definition: pci_config.h:322
unsigned char u8
Definition: types.h:56
static int pcie_code_to_size(int code)
Definition: pci_config.h:580
u32 flags
Definition: vhost-user.h:78
u32 prefetchable_memory_base_upper_32bits
Definition: pci_config.h:321
pci_config_header_t header
Definition: pci_config.h:240