Commit 6d72344c authored by Kaike Wan's avatar Kaike Wan Committed by Jason Gunthorpe

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/20200511160618.173205.23053.stgit@awfm-01.aw.intel.comReviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarSadanand Warrier <sadanand.warrier@intel.com>
Signed-off-by: default avatarKaike Wan <kaike.wan@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 19d8b90a
/* /*
* Copyright(c) 2015 - 2019 Intel Corporation. * Copyright(c) 2015 - 2020 Intel Corporation.
* *
* This file is provided under a dual BSD/GPLv2 license. When using or * This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license. * redistributing this file, you may do so under either license.
...@@ -186,15 +186,6 @@ static void flush_iowait(struct rvt_qp *qp) ...@@ -186,15 +186,6 @@ static void flush_iowait(struct rvt_qp *qp)
write_sequnlock_irqrestore(lock, flags); write_sequnlock_irqrestore(lock, flags);
} }
static inline int opa_mtu_enum_to_int(int mtu)
{
switch (mtu) {
case OPA_MTU_8192: return 8192;
case OPA_MTU_10240: return 10240;
default: return -1;
}
}
/** /**
* This function is what we would push to the core layer if we wanted to be a * This function is what we would push to the core layer if we wanted to be a
* "first class citizen". Instead we hide this here and rely on Verbs ULPs * "first class citizen". Instead we hide this here and rely on Verbs ULPs
...@@ -202,15 +193,10 @@ static inline int opa_mtu_enum_to_int(int mtu) ...@@ -202,15 +193,10 @@ static inline int opa_mtu_enum_to_int(int mtu)
*/ */
static inline int verbs_mtu_enum_to_int(struct ib_device *dev, enum ib_mtu mtu) static inline int verbs_mtu_enum_to_int(struct ib_device *dev, enum ib_mtu mtu)
{ {
int val;
/* Constraining 10KB packets to 8KB packets */ /* Constraining 10KB packets to 8KB packets */
if (mtu == (enum ib_mtu)OPA_MTU_10240) if (mtu == (enum ib_mtu)OPA_MTU_10240)
mtu = OPA_MTU_8192; mtu = OPA_MTU_8192;
val = opa_mtu_enum_to_int((int)mtu); return opa_mtu_enum_to_int((enum opa_mtu)mtu);
if (val > 0)
return val;
return ib_mtu_enum_to_int(mtu);
} }
int hfi1_check_modify_qp(struct rvt_qp *qp, struct ib_qp_attr *attr, int hfi1_check_modify_qp(struct rvt_qp *qp, struct ib_qp_attr *attr,
......
...@@ -1439,6 +1439,8 @@ static int query_port(struct rvt_dev_info *rdi, u8 port_num, ...@@ -1439,6 +1439,8 @@ static int query_port(struct rvt_dev_info *rdi, u8 port_num,
4096 : hfi1_max_mtu), IB_MTU_4096); 4096 : hfi1_max_mtu), IB_MTU_4096);
props->active_mtu = !valid_ib_mtu(ppd->ibmtu) ? props->max_mtu : props->active_mtu = !valid_ib_mtu(ppd->ibmtu) ? props->max_mtu :
mtu_to_enum(ppd->ibmtu, IB_MTU_4096); mtu_to_enum(ppd->ibmtu, IB_MTU_4096);
props->phys_mtu = HFI1_CAP_IS_KSET(AIP) ? hfi1_max_mtu :
ib_mtu_enum_to_int(props->max_mtu);
return 0; return 0;
} }
......
...@@ -1855,7 +1855,7 @@ static int ipoib_parent_init(struct net_device *ndev) ...@@ -1855,7 +1855,7 @@ static int ipoib_parent_init(struct net_device *ndev)
priv->port); priv->port);
return result; return result;
} }
priv->max_ib_mtu = ib_mtu_enum_to_int(attr.max_mtu); priv->max_ib_mtu = rdma_mtu_from_attr(priv->ca, priv->port, &attr);
result = ib_query_pkey(priv->ca, priv->port, 0, &priv->pkey); result = ib_query_pkey(priv->ca, priv->port, 0, &priv->pkey);
if (result) { if (result) {
......
...@@ -218,6 +218,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast, ...@@ -218,6 +218,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
struct rdma_ah_attr av; struct rdma_ah_attr av;
int ret; int ret;
int set_qkey = 0; int set_qkey = 0;
int mtu;
mcast->mcmember = *mcmember; mcast->mcmember = *mcmember;
...@@ -240,13 +241,11 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast, ...@@ -240,13 +241,11 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
priv->broadcast->mcmember.flow_label = mcmember->flow_label; priv->broadcast->mcmember.flow_label = mcmember->flow_label;
priv->broadcast->mcmember.hop_limit = mcmember->hop_limit; priv->broadcast->mcmember.hop_limit = mcmember->hop_limit;
/* assume if the admin and the mcast are the same both can be changed */ /* assume if the admin and the mcast are the same both can be changed */
mtu = rdma_mtu_enum_to_int(priv->ca, priv->port,
priv->broadcast->mcmember.mtu);
if (priv->mcast_mtu == priv->admin_mtu) if (priv->mcast_mtu == priv->admin_mtu)
priv->admin_mtu = priv->admin_mtu = IPOIB_UD_MTU(mtu);
priv->mcast_mtu = priv->mcast_mtu = IPOIB_UD_MTU(mtu);
IPOIB_UD_MTU(ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu));
else
priv->mcast_mtu =
IPOIB_UD_MTU(ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu));
priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey); priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey);
spin_unlock_irq(&priv->lock); spin_unlock_irq(&priv->lock);
......
...@@ -462,6 +462,11 @@ enum ib_mtu { ...@@ -462,6 +462,11 @@ enum ib_mtu {
IB_MTU_4096 = 5 IB_MTU_4096 = 5
}; };
enum opa_mtu {
OPA_MTU_8192 = 6,
OPA_MTU_10240 = 7
};
static inline int ib_mtu_enum_to_int(enum ib_mtu mtu) static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
{ {
switch (mtu) { switch (mtu) {
...@@ -488,6 +493,28 @@ static inline enum ib_mtu ib_mtu_int_to_enum(int mtu) ...@@ -488,6 +493,28 @@ static inline enum ib_mtu ib_mtu_int_to_enum(int mtu)
return IB_MTU_256; return IB_MTU_256;
} }
static inline int opa_mtu_enum_to_int(enum opa_mtu mtu)
{
switch (mtu) {
case OPA_MTU_8192:
return 8192;
case OPA_MTU_10240:
return 10240;
default:
return(ib_mtu_enum_to_int((enum ib_mtu)mtu));
}
}
static inline enum opa_mtu opa_mtu_int_to_enum(int mtu)
{
if (mtu >= 10240)
return OPA_MTU_10240;
else if (mtu >= 8192)
return OPA_MTU_8192;
else
return ((enum opa_mtu)ib_mtu_int_to_enum(mtu));
}
enum ib_port_state { enum ib_port_state {
IB_PORT_NOP = 0, IB_PORT_NOP = 0,
IB_PORT_DOWN = 1, IB_PORT_DOWN = 1,
...@@ -651,6 +678,7 @@ struct ib_port_attr { ...@@ -651,6 +678,7 @@ struct ib_port_attr {
enum ib_port_state state; enum ib_port_state state;
enum ib_mtu max_mtu; enum ib_mtu max_mtu;
enum ib_mtu active_mtu; enum ib_mtu active_mtu;
u32 phys_mtu;
int gid_tbl_len; int gid_tbl_len;
unsigned int ip_gids:1; unsigned int ip_gids:1;
/* This is the value from PortInfo CapabilityMask, defined by IBA */ /* 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, ...@@ -3364,6 +3392,55 @@ static inline unsigned int rdma_find_pg_bit(unsigned long addr,
return __fls(pgsz); return __fls(pgsz);
} }
/**
* rdma_core_cap_opa_port - Return whether the RDMA Port is OPA or not.
* @device: Device
* @port_num: 1 based Port number
*
* Return true if port is an Intel OPA port , false if not
*/
static inline bool rdma_core_cap_opa_port(struct ib_device *device,
u32 port_num)
{
return (device->port_data[port_num].immutable.core_cap_flags &
RDMA_CORE_PORT_INTEL_OPA) == RDMA_CORE_PORT_INTEL_OPA;
}
/**
* rdma_mtu_enum_to_int - Return the mtu of the port as an integer value.
* @device: Device
* @port_num: Port number
* @mtu: enum value of MTU
*
* Return the MTU size supported by the port as an integer value. Will return
* -1 if enum value of mtu is not supported.
*/
static inline int rdma_mtu_enum_to_int(struct ib_device *device, u8 port,
int mtu)
{
if (rdma_core_cap_opa_port(device, port))
return opa_mtu_enum_to_int((enum opa_mtu)mtu);
else
return ib_mtu_enum_to_int((enum ib_mtu)mtu);
}
/**
* rdma_mtu_from_attr - Return the mtu of the port from the port attribute.
* @device: Device
* @port_num: Port number
* @attr: port attribute
*
* Return the MTU size supported by the port as an integer value.
*/
static inline int rdma_mtu_from_attr(struct ib_device *device, u8 port,
struct ib_port_attr *attr)
{
if (rdma_core_cap_opa_port(device, port))
return attr->phys_mtu;
else
return ib_mtu_enum_to_int(attr->max_mtu);
}
int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port, int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port,
int state); int state);
int ib_get_vf_config(struct ib_device *device, int vf, u8 port, int ib_get_vf_config(struct ib_device *device, int vf, u8 port,
......
/* /*
* Copyright (c) 2014-2017 Intel Corporation. All rights reserved. * Copyright (c) 2014-2020 Intel Corporation. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -139,14 +139,6 @@ ...@@ -139,14 +139,6 @@
#define OPA_CAP_MASK3_IsVLMarkerSupported (1 << 1) #define OPA_CAP_MASK3_IsVLMarkerSupported (1 << 1)
#define OPA_CAP_MASK3_IsVLrSupported (1 << 0) #define OPA_CAP_MASK3_IsVLrSupported (1 << 0)
/**
* new MTU values
*/
enum {
OPA_MTU_8192 = 6,
OPA_MTU_10240 = 7,
};
enum { enum {
OPA_PORT_PHYS_CONF_DISCONNECTED = 0, OPA_PORT_PHYS_CONF_DISCONNECTED = 0,
OPA_PORT_PHYS_CONF_STANDARD = 1, OPA_PORT_PHYS_CONF_STANDARD = 1,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment