Switchtec Userspace
PROJECT_NUMBER = 4.4
Toggle main menu visibility
Loading...
Searching...
No Matches
inc
switchtec
cap.h
Go to the documentation of this file.
1
/*
2
* Microsemi Switchtec(tm) PCIe Management Library
3
* Copyright (c) 2017, Microsemi Corporation
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining a
6
* copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation
8
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
* and/or sell copies of the Software, and to permit persons to whom the
10
* Software is furnished to do so, subject to the following conditions:
11
*
12
* The above copyright notice and this permission notice shall be included
13
* in all copies or substantial portions of the Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
* OTHER DEALINGS IN THE SOFTWARE.
22
*
23
*/
24
25
#ifndef LIBSWITCHTEC_CAP_H
26
#define LIBSWITCHTEC_CAP_H
27
32
33
#include <
switchtec/switchtec.h
>
34
#include <stdint.h>
35
36
#ifdef __cplusplus
37
extern
"C"
{
38
#endif
39
40
#define SWITCHTEC_CAP_GAS_BASE 0x134000
41
#define SWITCHTEC_CAP_DEV_STRIDE 0x1000
42
#define SWITCHTEC_CAP_TYPE_OFFSET 0x0C
43
#define SWITCHTEC_CAP_MULTICAST_OFFSET 0x170
44
56
struct
switchtec_multicast_cap
{
57
uint32_t header;
/* DW0: Extended Capability Header */
58
uint32_t cap_ctrl;
/* DW1: [15:0] cap, [31:16] ctrl */
59
uint64_t mc_base_addr;
/* DW2-3: MC Base Address */
60
uint64_t mc_receive;
/* DW4-5: MC Receive */
61
uint64_t mc_block_all;
/* DW6-7: MC Block All */
62
uint64_t mc_block_untranslated;
/* DW8-9: MC Block Untranslated */
63
uint64_t mc_overlay_bar;
/* DW10-11: MC Overlay BAR */
64
};
65
66
/* DW0: Extended Capability Header fields */
67
#define SWITCHTEC_MC_HDR_CAP_ID(hdr) (((hdr) >> 0) & 0xFFFF)
68
#define SWITCHTEC_MC_HDR_CAP_VER(hdr) (((hdr) >> 16) & 0xF)
69
#define SWITCHTEC_MC_HDR_NEXT_CAP(hdr) (((hdr) >> 20) & 0xFFF)
70
71
/* DW1: Multicast Capability Register [15:0] */
72
#define SWITCHTEC_MC_CAP(cap_ctrl) (((cap_ctrl) >> 0) & 0xFFFF)
73
#define SWITCHTEC_MC_CAP_MAX_GROUP(cap_ctrl) (((cap_ctrl) >> 0) & 0x3F)
74
75
/* DW1: Multicast Control Register [31:16] */
76
#define SWITCHTEC_MC_CTRL(cap_ctrl) (((cap_ctrl) >> 16) & 0xFFFF)
77
#define SWITCHTEC_MC_CTRL_NUM_GROUP(cap_ctrl) (((cap_ctrl) >> 16) & 0x3F)
78
#define SWITCHTEC_MC_CTRL_ENABLE(cap_ctrl) (((cap_ctrl) >> 31) & 0x1)
79
80
/* DW2-3: MC Base Address Register fields */
81
#define SWITCHTEC_MC_BASE_INDEX_POS(base) (((base) >> 0) & 0x3F)
82
#define SWITCHTEC_MC_BASE_ADDR(base) ((base) & 0xFFFFFFFFFFFFF000ULL)
83
84
/* DW10-11: MC Overlay BAR fields */
85
#define SWITCHTEC_MC_OVERLAY_SIZE(bar) (((bar) >> 0) & 0x3F)
86
#define SWITCHTEC_MC_OVERLAY_ADDR(bar) ((bar) & 0xFFFFFFFFFFFFFFC0ULL)
87
91
struct
switchtec_multicast_set
{
92
int
enable;
93
int
disable;
94
int
num_group;
95
int
index_pos;
96
uint64_t base_addr;
97
uint64_t receive;
98
uint64_t block_all;
99
uint64_t block_untranslated;
100
uint64_t overlay_bar;
101
int
overlay_size;
102
int
set_base_addr;
103
int
set_receive;
104
int
set_block_all;
105
int
set_block_untranslated;
106
int
set_overlay_bar;
107
};
108
109
enum
switchtec_cap_port_type {
110
SWITCHTEC_CAP_PORT_INVALID = -1,
111
SWITCHTEC_CAP_PORT_DSP = 0,
112
SWITCHTEC_CAP_PORT_USP = 1,
113
SWITCHTEC_CAP_PORT_MGMT = 2,
114
};
115
116
struct
switchtec_port_info
{
117
uint32_t gas_base;
118
enum
switchtec_cap_port_type port_type;
119
const
char
*bdf;
120
};
121
122
int
switchtec_multicast_cap_get
(
struct
switchtec_dev *dev, uint32_t gas_base,
123
struct
switchtec_multicast_cap
*cap);
124
int
switchtec_multicast_cap_set
(
struct
switchtec_dev *dev, uint32_t gas_base,
125
struct
switchtec_multicast_set
*set);
126
int
switchtec_find_port_by_bdf(
struct
switchtec_dev *dev,
const
char
*target_bdf,
127
struct
switchtec_port_info
*info);
128
129
#ifdef __cplusplus
130
}
131
#endif
132
133
#endif
switchtec_multicast_cap_set
int switchtec_multicast_cap_set(struct switchtec_dev *dev, uint32_t gas_base, struct switchtec_multicast_set *set)
Set multicast capability registers.
Definition
cap.c:118
switchtec_multicast_cap_get
int switchtec_multicast_cap_get(struct switchtec_dev *dev, uint32_t gas_base, struct switchtec_multicast_cap *cap)
Read the multicast capability registers.
Definition
cap.c:70
switchtec_multicast_cap
Multicast Extended Capability register structure (PCIe 3.1).
Definition
cap.h:56
switchtec_multicast_set
Multicast capability set parameters.
Definition
cap.h:91
switchtec_port_info
Definition
cap.h:116
switchtec.h
Main Switchtec header.
Generated by
1.17.0