Skip to content

Commit 1c15b4f

Browse files
avihai1122jgunthorpe
authored andcommitted
RDMA/core: Modify enum ib_gid_type and enum rdma_network_type
Separate IB_GID_TYPE_IB and IB_GID_TYPE_ROCE to two different values, so enum ib_gid_type will match the gid types of the new query GID table API which will be introduced in the following patches. This change in enum ib_gid_type requires to change also enum rdma_network_type by separating RDMA_NETWORK_IB and RDMA_NETWORK_ROCE_V1 values. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Avihai Horon <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 3ff4de8 commit 1c15b4f

File tree

8 files changed

+30
-16
lines changed

8 files changed

+30
-16
lines changed

drivers/infiniband/core/cache.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ static void dispatch_gid_change_event(struct ib_device *ib_dev, u8 port)
133133
}
134134

135135
static const char * const gid_type_str[] = {
136+
/* IB/RoCE v1 value is set for IB_GID_TYPE_IB and IB_GID_TYPE_ROCE for
137+
* user space compatibility reasons.
138+
*/
136139
[IB_GID_TYPE_IB] = "IB/RoCE v1",
140+
[IB_GID_TYPE_ROCE] = "IB/RoCE v1",
137141
[IB_GID_TYPE_ROCE_UDP_ENCAP] = "RoCE v2",
138142
};
139143

drivers/infiniband/core/cma.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ int cma_set_default_gid_type(struct cma_device *cma_dev,
304304
if (!rdma_is_port_valid(cma_dev->device, port))
305305
return -EINVAL;
306306

307+
if (default_gid_type == IB_GID_TYPE_IB &&
308+
rdma_protocol_roce_eth_encap(cma_dev->device, port))
309+
default_gid_type = IB_GID_TYPE_ROCE;
310+
307311
supported_gids = roce_gid_type_mask_support(cma_dev->device, port);
308312

309313
if (!(supported_gids & 1 << default_gid_type))

drivers/infiniband/core/cma_configfs.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,17 @@ static ssize_t default_roce_mode_store(struct config_item *item,
123123
{
124124
struct cma_device *cma_dev;
125125
struct cma_dev_port_group *group;
126-
int gid_type = ib_cache_gid_parse_type_str(buf);
126+
int gid_type;
127127
ssize_t ret;
128128

129-
if (gid_type < 0)
130-
return -EINVAL;
131-
132129
ret = cma_configfs_params_get(item, &cma_dev, &group);
133130
if (ret)
134131
return ret;
135132

133+
gid_type = ib_cache_gid_parse_type_str(buf);
134+
if (gid_type < 0)
135+
return -EINVAL;
136+
136137
ret = cma_set_default_gid_type(cma_dev, group->port_num, gid_type);
137138

138139
cma_configfs_params_put(cma_dev);

drivers/infiniband/core/verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ int ib_get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr,
733733
(struct in6_addr *)dgid);
734734
return 0;
735735
} else if (net_type == RDMA_NETWORK_IPV6 ||
736-
net_type == RDMA_NETWORK_IB) {
736+
net_type == RDMA_NETWORK_IB || RDMA_NETWORK_ROCE_V1) {
737737
*dgid = hdr->ibgrh.dgid;
738738
*sgid = hdr->ibgrh.sgid;
739739
return 0;

drivers/infiniband/hw/mlx5/cq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
255255

256256
switch (roce_packet_type) {
257257
case MLX5_CQE_ROCE_L3_HEADER_TYPE_GRH:
258-
wc->network_hdr_type = RDMA_NETWORK_IB;
258+
wc->network_hdr_type = RDMA_NETWORK_ROCE_V1;
259259
break;
260260
case MLX5_CQE_ROCE_L3_HEADER_TYPE_IPV6:
261261
wc->network_hdr_type = RDMA_NETWORK_IPV6;

drivers/infiniband/hw/mlx5/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static int set_roce_addr(struct mlx5_ib_dev *dev, u8 port_num,
546546
unsigned int index, const union ib_gid *gid,
547547
const struct ib_gid_attr *attr)
548548
{
549-
enum ib_gid_type gid_type = IB_GID_TYPE_IB;
549+
enum ib_gid_type gid_type = IB_GID_TYPE_ROCE;
550550
u16 vlan_id = 0xffff;
551551
u8 roce_version = 0;
552552
u8 roce_l3_type = 0;
@@ -561,7 +561,7 @@ static int set_roce_addr(struct mlx5_ib_dev *dev, u8 port_num,
561561
}
562562

563563
switch (gid_type) {
564-
case IB_GID_TYPE_IB:
564+
case IB_GID_TYPE_ROCE:
565565
roce_version = MLX5_ROCE_VERSION_1;
566566
break;
567567
case IB_GID_TYPE_ROCE_UDP_ENCAP:

drivers/infiniband/hw/qedr/verbs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ static inline int get_gid_info_from_table(struct ib_qp *ibqp,
11571157
SET_FIELD(qp_params->modify_flags,
11581158
QED_ROCE_MODIFY_QP_VALID_ROCE_MODE, 1);
11591159
break;
1160-
case RDMA_NETWORK_IB:
1160+
case RDMA_NETWORK_ROCE_V1:
11611161
memcpy(&qp_params->sgid.bytes[0], &gid_attr->gid.raw[0],
11621162
sizeof(qp_params->sgid));
11631163
memcpy(&qp_params->dgid.bytes[0],
@@ -1177,6 +1177,8 @@ static inline int get_gid_info_from_table(struct ib_qp *ibqp,
11771177
QED_ROCE_MODIFY_QP_VALID_ROCE_MODE, 1);
11781178
qp_params->roce_mode = ROCE_V2_IPV4;
11791179
break;
1180+
default:
1181+
return -EINVAL;
11801182
}
11811183

11821184
for (i = 0; i < 4; i++) {

include/rdma/ib_verbs.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ union ib_gid {
138138
extern union ib_gid zgid;
139139

140140
enum ib_gid_type {
141-
/* If link layer is Ethernet, this is RoCE V1 */
142141
IB_GID_TYPE_IB = 0,
143-
IB_GID_TYPE_ROCE = 0,
144-
IB_GID_TYPE_ROCE_UDP_ENCAP = 1,
142+
IB_GID_TYPE_ROCE = 1,
143+
IB_GID_TYPE_ROCE_UDP_ENCAP = 2,
145144
IB_GID_TYPE_SIZE
146145
};
147146

@@ -180,7 +179,7 @@ rdma_node_get_transport(unsigned int node_type);
180179

181180
enum rdma_network_type {
182181
RDMA_NETWORK_IB,
183-
RDMA_NETWORK_ROCE_V1 = RDMA_NETWORK_IB,
182+
RDMA_NETWORK_ROCE_V1,
184183
RDMA_NETWORK_IPV4,
185184
RDMA_NETWORK_IPV6
186185
};
@@ -190,9 +189,10 @@ static inline enum ib_gid_type ib_network_to_gid_type(enum rdma_network_type net
190189
if (network_type == RDMA_NETWORK_IPV4 ||
191190
network_type == RDMA_NETWORK_IPV6)
192191
return IB_GID_TYPE_ROCE_UDP_ENCAP;
193-
194-
/* IB_GID_TYPE_IB same as RDMA_NETWORK_ROCE_V1 */
195-
return IB_GID_TYPE_IB;
192+
else if (network_type == RDMA_NETWORK_ROCE_V1)
193+
return IB_GID_TYPE_ROCE;
194+
else
195+
return IB_GID_TYPE_IB;
196196
}
197197

198198
static inline enum rdma_network_type
@@ -201,6 +201,9 @@ rdma_gid_attr_network_type(const struct ib_gid_attr *attr)
201201
if (attr->gid_type == IB_GID_TYPE_IB)
202202
return RDMA_NETWORK_IB;
203203

204+
if (attr->gid_type == IB_GID_TYPE_ROCE)
205+
return RDMA_NETWORK_ROCE_V1;
206+
204207
if (ipv6_addr_v4mapped((struct in6_addr *)&attr->gid))
205208
return RDMA_NETWORK_IPV4;
206209
else

0 commit comments

Comments
 (0)