t4vf_defs.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * This file is part of the Chelsio T4 PCI-E SR-IOV Virtual Function Ethernet
  3. * driver for Linux.
  4. *
  5. * Copyright (c) 2009-2010 Chelsio Communications, Inc. All rights reserved.
  6. *
  7. * This software is available to you under a choice of one of two
  8. * licenses. You may choose to be licensed under the terms of the GNU
  9. * General Public License (GPL) Version 2, available from the file
  10. * COPYING in the main directory of this source tree, or the
  11. * OpenIB.org BSD license below:
  12. *
  13. * Redistribution and use in source and binary forms, with or
  14. * without modification, are permitted provided that the following
  15. * conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above
  18. * copyright notice, this list of conditions and the following
  19. * disclaimer.
  20. *
  21. * - Redistributions in binary form must reproduce the above
  22. * copyright notice, this list of conditions and the following
  23. * disclaimer in the documentation and/or other materials
  24. * provided with the distribution.
  25. *
  26. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  27. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  29. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  30. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  31. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  32. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33. * SOFTWARE.
  34. */
  35. #ifndef __T4VF_DEFS_H__
  36. #define __T4VF_DEFS_H__
  37. #include "../cxgb4/t4_regs.h"
  38. /*
  39. * The VF Register Map.
  40. *
  41. * The Scatter Gather Engine (SGE), Multiport Support module (MPS), PIO Local
  42. * bus module (PL) and CPU Interface Module (CIM) components are mapped via
  43. * the Slice to Module Map Table (see below) in the Physical Function Register
  44. * Map. The Mail Box Data (MBDATA) range is mapped via the PCI-E Mailbox Base
  45. * and Offset registers in the PF Register Map. The MBDATA base address is
  46. * quite constrained as it determines the Mailbox Data addresses for both PFs
  47. * and VFs, and therefore must fit in both the VF and PF Register Maps without
  48. * overlapping other registers.
  49. */
  50. #define T4VF_SGE_BASE_ADDR 0x0000
  51. #define T4VF_MPS_BASE_ADDR 0x0100
  52. #define T4VF_PL_BASE_ADDR 0x0200
  53. #define T4VF_MBDATA_BASE_ADDR 0x0240
  54. #define T6VF_MBDATA_BASE_ADDR 0x0280
  55. #define T4VF_CIM_BASE_ADDR 0x0300
  56. #define T4VF_REGMAP_START 0x0000
  57. #define T4VF_REGMAP_SIZE 0x0400
  58. /*
  59. * There's no hardware limitation which requires that the addresses of the
  60. * Mailbox Data in the fixed CIM PF map and the programmable VF map must
  61. * match. However, it's a useful convention ...
  62. */
  63. #if T4VF_MBDATA_BASE_ADDR != CIM_PF_MAILBOX_DATA_A
  64. #error T4VF_MBDATA_BASE_ADDR must match CIM_PF_MAILBOX_DATA_A!
  65. #endif
  66. /*
  67. * Virtual Function "Slice to Module Map Table" definitions.
  68. *
  69. * This table allows us to map subsets of the various module register sets
  70. * into the T4VF Register Map. Each table entry identifies the index of the
  71. * module whose registers are being mapped, the offset within the module's
  72. * register set that the mapping should start at, the limit of the mapping,
  73. * and the offset within the T4VF Register Map to which the module's registers
  74. * are being mapped. All addresses and qualtities are in terms of 32-bit
  75. * words. The "limit" value is also in terms of 32-bit words and is equal to
  76. * the last address mapped in the T4VF Register Map 1 (i.e. it's a "<="
  77. * relation rather than a "<").
  78. */
  79. #define T4VF_MOD_MAP(module, index, first, last) \
  80. T4VF_MOD_MAP_##module##_INDEX = (index), \
  81. T4VF_MOD_MAP_##module##_FIRST = (first), \
  82. T4VF_MOD_MAP_##module##_LAST = (last), \
  83. T4VF_MOD_MAP_##module##_OFFSET = ((first)/4), \
  84. T4VF_MOD_MAP_##module##_BASE = \
  85. (T4VF_##module##_BASE_ADDR/4 + (first)/4), \
  86. T4VF_MOD_MAP_##module##_LIMIT = \
  87. (T4VF_##module##_BASE_ADDR/4 + (last)/4),
  88. #define SGE_VF_KDOORBELL 0x0
  89. #define SGE_VF_GTS 0x4
  90. #define MPS_VF_CTL 0x0
  91. #define MPS_VF_STAT_RX_VF_ERR_FRAMES_H 0xfc
  92. #define PL_VF_WHOAMI 0x0
  93. #define CIM_VF_EXT_MAILBOX_CTRL 0x0
  94. #define CIM_VF_EXT_MAILBOX_STATUS 0x4
  95. enum {
  96. T4VF_MOD_MAP(SGE, 2, SGE_VF_KDOORBELL, SGE_VF_GTS)
  97. T4VF_MOD_MAP(MPS, 0, MPS_VF_CTL, MPS_VF_STAT_RX_VF_ERR_FRAMES_H)
  98. T4VF_MOD_MAP(PL, 3, PL_VF_WHOAMI, PL_VF_WHOAMI)
  99. T4VF_MOD_MAP(CIM, 1, CIM_VF_EXT_MAILBOX_CTRL, CIM_VF_EXT_MAILBOX_STATUS)
  100. };
  101. /*
  102. * There isn't a Slice to Module Map Table entry for the Mailbox Data
  103. * registers, but it's convenient to use similar names as above. There are 8
  104. * little-endian 64-bit Mailbox Data registers. Note that the "instances"
  105. * value below is in terms of 32-bit words which matches the "word" addressing
  106. * space we use above for the Slice to Module Map Space.
  107. */
  108. #define NUM_CIM_VF_MAILBOX_DATA_INSTANCES 16
  109. #define T4VF_MBDATA_FIRST 0
  110. #define T4VF_MBDATA_LAST ((NUM_CIM_VF_MAILBOX_DATA_INSTANCES-1)*4)
  111. #endif /* __T4T4VF_DEFS_H__ */