Skip to content

Commit f665340

Browse files
Mark Zhangjgunthorpe
authored andcommitted
RDMA/cma: Initialize the flow label of CM's route path record
If flow label is not set by the user or it's not IPv4, initialize it with the cma src/dst based on the "Kernighan and Ritchie's hash function". Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Zhang <[email protected]> Reviewed-by: Maor Gottlieb <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 2b880b2 commit f665340

File tree

1 file changed

+23
-0
lines changed
  • drivers/infiniband/core

1 file changed

+23
-0
lines changed

drivers/infiniband/core/cma.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,6 +2909,24 @@ static int iboe_tos_to_sl(struct net_device *ndev, int tos)
29092909
return 0;
29102910
}
29112911

2912+
static __be32 cma_get_roce_udp_flow_label(struct rdma_id_private *id_priv)
2913+
{
2914+
struct sockaddr_in6 *addr6;
2915+
u16 dport, sport;
2916+
u32 hash, fl;
2917+
2918+
addr6 = (struct sockaddr_in6 *)cma_src_addr(id_priv);
2919+
fl = be32_to_cpu(addr6->sin6_flowinfo) & IB_GRH_FLOWLABEL_MASK;
2920+
if ((cma_family(id_priv) != AF_INET6) || !fl) {
2921+
dport = be16_to_cpu(cma_port(cma_dst_addr(id_priv)));
2922+
sport = be16_to_cpu(cma_port(cma_src_addr(id_priv)));
2923+
hash = (u32)sport * 31 + dport;
2924+
fl = hash & IB_GRH_FLOWLABEL_MASK;
2925+
}
2926+
2927+
return cpu_to_be32(fl);
2928+
}
2929+
29122930
static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
29132931
{
29142932
struct rdma_route *route = &id_priv->id.route;
@@ -2975,6 +2993,11 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
29752993
goto err2;
29762994
}
29772995

2996+
if (rdma_protocol_roce_udp_encap(id_priv->id.device,
2997+
id_priv->id.port_num))
2998+
route->path_rec->flow_label =
2999+
cma_get_roce_udp_flow_label(id_priv);
3000+
29783001
cma_init_resolve_route_work(work, id_priv);
29793002
queue_work(cma_wq, &work->work);
29803003

0 commit comments

Comments
 (0)