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