File: nvlink_common.h

package info (click to toggle)
nvidia-open-gpu-kernel-modules 550.163.01-4
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 87,488 kB
  • sloc: ansic: 1,143,669; cpp: 22,547; sh: 3,721; makefile: 627; python: 315
file content (174 lines) | stat: -rw-r--r-- 4,953 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
 * SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#ifndef _NVLINK_COMMON_H_
#define _NVLINK_COMMON_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "nvtypes.h"
#include "nvCpuUuid.h"
#include "nvlink_errors.h"


#ifndef NULL
#define NULL ((void *)0)
#endif

// nvlink pci bar information
struct nvlink_pci_bar_info
{
    NvU64  busAddress;
    NvU64  baseAddr;
    NvU64  barSize;
    NvU32  offset;
    void  *pBar;
};

#define MAX_NVLINK_BARS    2

// nvlink pci information
struct nvlink_pci_info
{
    NvU32   domain;
    NvU8    bus;
    NvU8    device;
    NvU8    function;
    NvU32   pciDeviceId;
    NvU32   irq;
    NvBool  intHooked;
    struct  nvlink_pci_bar_info bars[MAX_NVLINK_BARS];
};

// nvlink detailed device information
struct nvlink_detailed_device_info
{
    char       *deviceName;
    NvU64       deviceType;
    NvU8       *devUuid;
    NvBool      bInitialized;
    NvBool      bEnableALI;
    void       *dev_info;     // Endpoint driver device info opaque
                              // to core lib. Passed from end point
                              // driver to core

    struct nvlink_pci_info  *pciInfo;
};

// nvlink device registration parameters
struct nvlink_device_register_params
{
    //
    // Core lib device info opaque to endpoint driver 
    // Passed from core lib to endpoint driver
    //
    void  **deviceHandle;
    char   *driverName;

    struct nvlink_detailed_device_info *device_params;
};

// nvlink detailed link information
struct nvlink_detailed_link_info
{
    void        *deviceHandle; // Core library device handle passed
                               // to endpoint driver during  device
                               // registration

    void        *link_info;    // End point driver link info  opaque 
                               // to core lib. Passed from end point
                               // driver to core

    char        *linkName;
    NvU32        linkNumber;
    NvU32        version;
    NvBool       bAcCoupled;
    const void  *link_handlers;
};

// nvlink link registration parameters
struct nvlink_link_register_params
{
    //
    // Core lib link info opaque to endpoint driver 
    // Passed from core lib to endpoint driver
    //
    void  **linkHandle;

    struct nvlink_detailed_link_info *link_params;
};

// nvlink client device handle
struct nvlink_device_handle
{
    NvU32                  linkMask;
    struct nvlink_pci_info pciInfo;
};

#define NVLINK_PCI_DEV_FMT              "%04x:%02x:%02x.%x"
#define NVLINK_PCI_DEV_FMT_ARGS(info)   (info)->domain, \
                                        (info)->bus,    \
                                        (info)->device, \
                                        (info)->function

// nvlink connection information
struct nvlink_conn_info
{
    NvU32  domain;
    NvU16  bus;
    NvU16  device;
    NvU16  function;
    NvU32  pciDeviceId;
    NvU8   devUuid[NV_UUID_LEN];
    NvU64  deviceType;
    NvU32  linkNumber;
    NvBool bConnected;
    NvU64  chipSid;
};

// nvlink ioctrl params
struct nvlink_ioctrl_params
{
    void  *osPrivate;
    NvU32  cmd;
    void  *buf;
    NvU32  size;
};

// Typedefs
typedef struct nvlink_pci_bar_info           nvlink_pci_bar_info;
typedef struct nvlink_pci_info               nvlink_pci_info;
typedef struct nvlink_detailed_device_info   nvlink_detailed_device_info;
typedef struct nvlink_detailed_link_info     nvlink_detailed_link_info;
typedef struct nvlink_device_register_params nvlink_device_register_params;
typedef struct nvlink_link_register_params   nvlink_link_register_params;
typedef struct nvlink_conn_info              nvlink_conn_info;
typedef struct nvlink_ioctrl_params          nvlink_ioctrl_params;

#ifdef __cplusplus
}
#endif

#endif //_NVLINK_COMMON_H_