Skip to content

Commit 6d72344

Browse files
kwan-intcjgunthorpe
authored andcommitted
IB/ipoib: Increase ipoib Datagram mode MTU's upper limit
Currently the ipoib UD mtu is restricted to 4K bytes. Remove this limitation so that the IPOIB module can potentially use an MTU (in UD mode) that is bounded by the MTU of the underlying device. A field is added to the ib_port_attr structure to indicate the maximum physical MTU the underlying device supports. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Dennis Dalessandro <[email protected]> Reviewed-by: Mike Marciniszyn <[email protected]> Signed-off-by: Sadanand Warrier <[email protected]> Signed-off-by: Kaike Wan <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 19d8b90 commit 6d72344

File tree

6 files changed

+88
-32
lines changed

6 files changed

+88
-32
lines changed

drivers/infiniband/hw/hfi1/qp.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(c) 2015 - 2019 Intel Corporation.
2+
* Copyright(c) 2015 - 2020 Intel Corporation.
33
*
44
* This file is provided under a dual BSD/GPLv2 license. When using or
55
* redistributing this file, you may do so under either license.
@@ -186,31 +186,17 @@ static void flush_iowait(struct rvt_qp *qp)
186186
write_sequnlock_irqrestore(lock, flags);
187187
}
188188

189-
static inline int opa_mtu_enum_to_int(int mtu)
190-
{
191-
switch (mtu) {
192-
case OPA_MTU_8192: return 8192;
193-
case OPA_MTU_10240: return 10240;
194-
default: return -1;
195-
}
196-
}
197-
198189
/**
199190
* This function is what we would push to the core layer if we wanted to be a
200191
* "first class citizen". Instead we hide this here and rely on Verbs ULPs
201192
* to blindly pass the MTU enum value from the PathRecord to us.
202193
*/
203194
static inline int verbs_mtu_enum_to_int(struct ib_device *dev, enum ib_mtu mtu)
204195
{
205-
int val;
206-
207196
/* Constraining 10KB packets to 8KB packets */
208197
if (mtu == (enum ib_mtu)OPA_MTU_10240)
209198
mtu = OPA_MTU_8192;
210-
val = opa_mtu_enum_to_int((int)mtu);
211-
if (val > 0)
212-
return val;
213-
return ib_mtu_enum_to_int(mtu);
199+
return opa_mtu_enum_to_int((enum opa_mtu)mtu);
214200
}
215201

216202
int hfi1_check_modify_qp(struct rvt_qp *qp, struct ib_qp_attr *attr,

drivers/infiniband/hw/hfi1/verbs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,8 @@ static int query_port(struct rvt_dev_info *rdi, u8 port_num,
14391439
4096 : hfi1_max_mtu), IB_MTU_4096);
14401440
props->active_mtu = !valid_ib_mtu(ppd->ibmtu) ? props->max_mtu :
14411441
mtu_to_enum(ppd->ibmtu, IB_MTU_4096);
1442+
props->phys_mtu = HFI1_CAP_IS_KSET(AIP) ? hfi1_max_mtu :
1443+
ib_mtu_enum_to_int(props->max_mtu);
14421444

14431445
return 0;
14441446
}

drivers/infiniband/ulp/ipoib/ipoib_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ static int ipoib_parent_init(struct net_device *ndev)
18551855
priv->port);
18561856
return result;
18571857
}
1858-
priv->max_ib_mtu = ib_mtu_enum_to_int(attr.max_mtu);
1858+
priv->max_ib_mtu = rdma_mtu_from_attr(priv->ca, priv->port, &attr);
18591859

18601860
result = ib_query_pkey(priv->ca, priv->port, 0, &priv->pkey);
18611861
if (result) {

drivers/infiniband/ulp/ipoib/ipoib_multicast.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
218218
struct rdma_ah_attr av;
219219
int ret;
220220
int set_qkey = 0;
221+
int mtu;
221222

222223
mcast->mcmember = *mcmember;
223224

@@ -240,13 +241,11 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
240241
priv->broadcast->mcmember.flow_label = mcmember->flow_label;
241242
priv->broadcast->mcmember.hop_limit = mcmember->hop_limit;
242243
/* assume if the admin and the mcast are the same both can be changed */
244+
mtu = rdma_mtu_enum_to_int(priv->ca, priv->port,
245+
priv->broadcast->mcmember.mtu);
243246
if (priv->mcast_mtu == priv->admin_mtu)
244-
priv->admin_mtu =
245-
priv->mcast_mtu =
246-
IPOIB_UD_MTU(ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu));
247-
else
248-
priv->mcast_mtu =
249-
IPOIB_UD_MTU(ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu));
247+
priv->admin_mtu = IPOIB_UD_MTU(mtu);
248+
priv->mcast_mtu = IPOIB_UD_MTU(mtu);
250249

251250
priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey);
252251
spin_unlock_irq(&priv->lock);

include/rdma/ib_verbs.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,11 @@ enum ib_mtu {
462462
IB_MTU_4096 = 5
463463
};
464464

465+
enum opa_mtu {
466+
OPA_MTU_8192 = 6,
467+
OPA_MTU_10240 = 7
468+
};
469+
465470
static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
466471
{
467472
switch (mtu) {
@@ -488,6 +493,28 @@ static inline enum ib_mtu ib_mtu_int_to_enum(int mtu)
488493
return IB_MTU_256;
489494
}
490495

496+
static inline int opa_mtu_enum_to_int(enum opa_mtu mtu)
497+
{
498+
switch (mtu) {
499+
case OPA_MTU_8192:
500+
return 8192;
501+
case OPA_MTU_10240:
502+
return 10240;
503+
default:
504+
return(ib_mtu_enum_to_int((enum ib_mtu)mtu));
505+
}
506+
}
507+
508+
static inline enum opa_mtu opa_mtu_int_to_enum(int mtu)
509+
{
510+
if (mtu >= 10240)
511+
return OPA_MTU_10240;
512+
else if (mtu >= 8192)
513+
return OPA_MTU_8192;
514+
else
515+
return ((enum opa_mtu)ib_mtu_int_to_enum(mtu));
516+
}
517+
491518
enum ib_port_state {
492519
IB_PORT_NOP = 0,
493520
IB_PORT_DOWN = 1,
@@ -651,6 +678,7 @@ struct ib_port_attr {
651678
enum ib_port_state state;
652679
enum ib_mtu max_mtu;
653680
enum ib_mtu active_mtu;
681+
u32 phys_mtu;
654682
int gid_tbl_len;
655683
unsigned int ip_gids:1;
656684
/* This is the value from PortInfo CapabilityMask, defined by IBA */
@@ -3364,6 +3392,55 @@ static inline unsigned int rdma_find_pg_bit(unsigned long addr,
33643392
return __fls(pgsz);
33653393
}
33663394

3395+
/**
3396+
* rdma_core_cap_opa_port - Return whether the RDMA Port is OPA or not.
3397+
* @device: Device
3398+
* @port_num: 1 based Port number
3399+
*
3400+
* Return true if port is an Intel OPA port , false if not
3401+
*/
3402+
static inline bool rdma_core_cap_opa_port(struct ib_device *device,
3403+
u32 port_num)
3404+
{
3405+
return (device->port_data[port_num].immutable.core_cap_flags &
3406+
RDMA_CORE_PORT_INTEL_OPA) == RDMA_CORE_PORT_INTEL_OPA;
3407+
}
3408+
3409+
/**
3410+
* rdma_mtu_enum_to_int - Return the mtu of the port as an integer value.
3411+
* @device: Device
3412+
* @port_num: Port number
3413+
* @mtu: enum value of MTU
3414+
*
3415+
* Return the MTU size supported by the port as an integer value. Will return
3416+
* -1 if enum value of mtu is not supported.
3417+
*/
3418+
static inline int rdma_mtu_enum_to_int(struct ib_device *device, u8 port,
3419+
int mtu)
3420+
{
3421+
if (rdma_core_cap_opa_port(device, port))
3422+
return opa_mtu_enum_to_int((enum opa_mtu)mtu);
3423+
else
3424+
return ib_mtu_enum_to_int((enum ib_mtu)mtu);
3425+
}
3426+
3427+
/**
3428+
* rdma_mtu_from_attr - Return the mtu of the port from the port attribute.
3429+
* @device: Device
3430+
* @port_num: Port number
3431+
* @attr: port attribute
3432+
*
3433+
* Return the MTU size supported by the port as an integer value.
3434+
*/
3435+
static inline int rdma_mtu_from_attr(struct ib_device *device, u8 port,
3436+
struct ib_port_attr *attr)
3437+
{
3438+
if (rdma_core_cap_opa_port(device, port))
3439+
return attr->phys_mtu;
3440+
else
3441+
return ib_mtu_enum_to_int(attr->max_mtu);
3442+
}
3443+
33673444
int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port,
33683445
int state);
33693446
int ib_get_vf_config(struct ib_device *device, int vf, u8 port,

include/rdma/opa_port_info.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014-2017 Intel Corporation. All rights reserved.
2+
* Copyright (c) 2014-2020 Intel Corporation. All rights reserved.
33
*
44
* This software is available to you under a choice of one of two
55
* licenses. You may choose to be licensed under the terms of the GNU
@@ -139,14 +139,6 @@
139139
#define OPA_CAP_MASK3_IsVLMarkerSupported (1 << 1)
140140
#define OPA_CAP_MASK3_IsVLrSupported (1 << 0)
141141

142-
/**
143-
* new MTU values
144-
*/
145-
enum {
146-
OPA_MTU_8192 = 6,
147-
OPA_MTU_10240 = 7,
148-
};
149-
150142
enum {
151143
OPA_PORT_PHYS_CONF_DISCONNECTED = 0,
152144
OPA_PORT_PHYS_CONF_STANDARD = 1,

0 commit comments

Comments
 (0)