fsl_qbman_base.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2014 Freescale Semiconductor
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _FSL_QBMAN_BASE_H
  7. #define _FSL_QBMAN_BASE_H
  8. /* Descriptor for a QBMan instance on the SoC. On partitions/targets that do not
  9. * control this QBMan instance, these values may simply be place-holders. The
  10. * idea is simply that we be able to distinguish between them, eg. so that SWP
  11. * descriptors can identify which QBMan instance they belong to. */
  12. struct qbman_block_desc {
  13. void *ccsr_reg_bar; /* CCSR register map */
  14. int irq_rerr; /* Recoverable error interrupt line */
  15. int irq_nrerr; /* Non-recoverable error interrupt line */
  16. };
  17. /* Descriptor for a QBMan software portal, expressed in terms that make sense to
  18. * the user context. Ie. on MC, this information is likely to be true-physical,
  19. * and instantiated statically at compile-time. On GPP, this information is
  20. * likely to be obtained via "discovery" over a partition's "layerscape bus"
  21. * (ie. in response to a MC portal command), and would take into account any
  22. * virtualisation of the GPP user's address space and/or interrupt numbering. */
  23. struct qbman_swp_desc {
  24. const struct qbman_block_desc *block; /* The QBMan instance */
  25. void *cena_bar; /* Cache-enabled portal register map */
  26. void *cinh_bar; /* Cache-inhibited portal register map */
  27. };
  28. /* Driver object for managing a QBMan portal */
  29. struct qbman_swp;
  30. /* Place-holder for FDs, we represent it via the simplest form that we need for
  31. * now. Different overlays may be needed to support different options, etc. (It
  32. * is impractical to define One True Struct, because the resulting encoding
  33. * routines (lots of read-modify-writes) would be worst-case performance whether
  34. * or not circumstances required them.)
  35. *
  36. * Note, as with all data-structures exchanged between software and hardware (be
  37. * they located in the portal register map or DMA'd to and from main-memory),
  38. * the driver ensures that the caller of the driver API sees the data-structures
  39. * in host-endianness. "struct qbman_fd" is no exception. The 32-bit words
  40. * contained within this structure are represented in host-endianness, even if
  41. * hardware always treats them as little-endian. As such, if any of these fields
  42. * are interpreted in a binary (rather than numerical) fashion by hardware
  43. * blocks (eg. accelerators), then the user should be careful. We illustrate
  44. * with an example;
  45. *
  46. * Suppose the desired behaviour of an accelerator is controlled by the "frc"
  47. * field of the FDs that are sent to it. Suppose also that the behaviour desired
  48. * by the user corresponds to an "frc" value which is expressed as the literal
  49. * sequence of bytes 0xfe, 0xed, 0xab, and 0xba. So "frc" should be the 32-bit
  50. * value in which 0xfe is the first byte and 0xba is the last byte, and as
  51. * hardware is little-endian, this amounts to a 32-bit "value" of 0xbaabedfe. If
  52. * the software is little-endian also, this can simply be achieved by setting
  53. * frc=0xbaabedfe. On the other hand, if software is big-endian, it should set
  54. * frc=0xfeedabba! The best away of avoiding trouble with this sort of thing is
  55. * to treat the 32-bit words as numerical values, in which the offset of a field
  56. * from the beginning of the first byte (as required or generated by hardware)
  57. * is numerically encoded by a left-shift (ie. by raising the field to a
  58. * corresponding power of 2). Ie. in the current example, software could set
  59. * "frc" in the following way, and it would work correctly on both little-endian
  60. * and big-endian operation;
  61. * fd.frc = (0xfe << 0) | (0xed << 8) | (0xab << 16) | (0xba << 24);
  62. */
  63. struct qbman_fd {
  64. union {
  65. uint32_t words[8];
  66. struct qbman_fd_simple {
  67. uint32_t addr_lo;
  68. uint32_t addr_hi;
  69. uint32_t len;
  70. /* offset in the MS 16 bits, BPID in the LS 16 bits */
  71. uint32_t bpid_offset;
  72. uint32_t frc; /* frame context */
  73. /* "err", "va", "cbmt", "asal", [...] */
  74. uint32_t ctrl;
  75. /* flow context */
  76. uint32_t flc_lo;
  77. uint32_t flc_hi;
  78. } simple;
  79. };
  80. };
  81. #endif /* !_FSL_QBMAN_BASE_H */