IB/mlx4: Add RoCEv2 support
cover IB/mlx4: Add RoCEv2 support
RoCEv2 is the InfiniBand transport protocol encapsulated in ETH/IP/UDP link and network protocols.
The implementation to the IB/core driver was added by Matan Barak as an infrastructure for any vendor driver and this patch set uses it to add RoCEv2 support for ConnectX-3Pro NICs
Matan Barak (1):
IB/mlx4: Advertise RoCE v2 support
Moni Shoua (11):
net/mlx4: Query RoCE support
IB/mlx4: Add gid_type to GID properties
net/mlx4_core: Configure mlx4 hardware for mixed RoCE v1/v2 modes IB/mlx4: Add support for setting RoCEv2 gids in hardware net/mlx4_core: Add support for configuring RoCE v2 UDP port net/mlx4_core: Add support for RoCE v2 entropy IB/core: Add definition for the standard RoCE V2 UDP port IB/mlx4: Support modify_qp for RoCE v2
IB/mlx4: Enable RoCE v2 when the IB device is added IB/mlx4: Enable send of RoCE QP1 packets with IP/UDP headers IB/mlx4: Create and use another QP1 for RoCEv2
drivers/infiniband/core/ud_header.c | 2 +- drivers/infiniband/hw/mlx4/main.c | 101 ++++++++++-- drivers/infiniband/hw/mlx4/mlx4_ib.h | 8 + drivers/infiniband/hw/mlx4/qp.c | 256 ++++++++++++++++++++++++++---- drivers/net/ethernet/mellanox/mlx4/fw.c | 39 ++++- drivers/net/ethernet/mellanox/mlx4/mlx4.h | 5 +- drivers/net/ethernet/mellanox/mlx4/port.c | 7 + drivers/net/ethernet/mellanox/mlx4/qp.c | 26 +++ include/linux/mlx4/cmd.h | 3 +- include/linux/mlx4/device.h | 11 +- include/linux/mlx4/qp.h | 15 +- include/rdma/ib_pack.h | 4 +- include/rdma/ib_verbs.h | 1 + 13 files changed, 425 insertions(+), 53 deletions(-)
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): cover.1452780849.git.monis-VPRAkNaXOzVWk0Htik3J/[email protected]
PATCH 1/12 net/mlx4: Query RoCE support
Query the RoCE support from firmware using the appropriate firmware commands. Downstream patches will read these capabilities and act accordingly.
--- drivers/net/ethernet/mellanox/mlx4/fw.c | 23 +++++++++++++++++++++++ include/linux/mlx4/device.h | 10 +++++++--- 2 files changed, 30 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx4/fw.c +23 -0
@@ -157,6 +157,7 @@ static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags) [29] = "802.1ad offload support", [31] = "Modifying loopback source checks using UPDATE_QP support", [32] = "Loopback source checks support", + [33] = "RoCEv2 support" };int i;
@@ -626,6 +627,8 @@ out:return err; } +static void disable_unsupported_roce_caps (void *buf); +int mlx4_QUERY_DEV_CAP (struct mlx4_dev *dev,struct mlx4_dev_cap *dev_cap) {struct mlx4_cmd_mailbox *mailbox;
@@ -738,6 +741,8 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)if (err) goto out; +if (mlx4_is_mfunc (dev)) +disable_unsupported_roce_caps (outbox);MLX4_GET (field, outbox,QUERY_DEV_CAP_RSVD_QP_OFFSET ); dev_cap->reserved_qps =1 << (field &0xf );MLX4_GET (field, outbox,QUERY_DEV_CAP_MAX_QP_OFFSET );
@@ -905,6 +910,8 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) dev_cap->flags2 |=MLX4_DEV_CAP_FLAG2_EQE_STRIDE ;MLX4_GET (dev_cap->bmme_flags, outbox,QUERY_DEV_CAP_BMME_FLAGS_OFFSET ); +if (dev_cap->bmme_flags &MLX4_FLAG_ROCE_V1_V2 ) + dev_cap->flags2 |=MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 ;if (dev_cap->bmme_flags &MLX4_FLAG_PORT_REMAP ) dev_cap->flags2 |=MLX4_DEV_CAP_FLAG2_PORT_REMAP ;MLX4_GET (field, outbox,QUERY_DEV_CAP_CONFIG_DEV_OFFSET );
@@ -1161,6 +1168,7 @@ int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave,if (err)return err; +disable_unsupported_roce_caps (outbox->buf);/* add port mng change event capability and disable mw type 1 * unconditionally to slaves */
@@ -1258,6 +1266,21 @@ int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave,return 0 ; } +static void disable_unsupported_roce_caps (void *buf) +{ +u32 flags; + +MLX4_GET (flags, buf,QUERY_DEV_CAP_EXT_FLAGS_OFFSET ); + flags &= ~(1UL <<31 ); +MLX4_PUT (buf, flags,QUERY_DEV_CAP_EXT_FLAGS_OFFSET ); +MLX4_GET (flags, buf,QUERY_DEV_CAP_EXT_2_FLAGS_OFFSET ); + flags &= ~(1UL <<24 ); +MLX4_PUT (buf, flags,QUERY_DEV_CAP_EXT_2_FLAGS_OFFSET ); +MLX4_GET (flags, buf,QUERY_DEV_CAP_BMME_FLAGS_OFFSET ); + flags &= ~(MLX4_FLAG_ROCE_V1_V2 ); +MLX4_PUT (buf, flags,QUERY_DEV_CAP_BMME_FLAGS_OFFSET ); +} + int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox,
include/linux/mlx4/device.h +7 -3
@@ -218,6 +218,7 @@ enum {MLX4_DEV_CAP_FLAG2_SKIP_OUTER_VLAN =1LL <<30 ,MLX4_DEV_CAP_FLAG2_UPDATE_QP_SRC_CHECK_LB =1ULL <<31 ,MLX4_DEV_CAP_FLAG2_LB_SRC_CHK =1ULL <<32 , + MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 = 1ULL << 33, }; enum {
@@ -269,12 +270,14 @@ enum {MLX4_BMME_FLAG_TYPE_2_WIN =1 <<9 ,MLX4_BMME_FLAG_RESERVED_LKEY =1 <<10 ,MLX4_BMME_FLAG_FAST_REG_WR =1 <<11 , +MLX4_BMME_FLAG_ROCE_V1_V2 =1 <<19 ,MLX4_BMME_FLAG_PORT_REMAP =1 <<24 , MLX4_BMME_FLAG_VSD_INIT2RTR = 1 << 28, };enum { -MLX4_FLAG_PORT_REMAP =MLX4_BMME_FLAG_PORT_REMAP +MLX4_FLAG_PORT_REMAP =MLX4_BMME_FLAG_PORT_REMAP , +MLX4_FLAG_ROCE_V1_V2 =MLX4_BMME_FLAG_ROCE_V1_V2 }; enum mlx4_event {
@@ -983,9 +986,10 @@ struct mlx4_mad_ifc { if ((type) == (dev)->caps.port_mask[(port)])#define mlx4_foreach_ib_transport_port (port, dev) \ - for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \ + for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \ if (((dev)->caps.port_mask[port] == MLX4_PORT_TYPE_IB) || \ - ((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE)) + ((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE) || \ + ((dev)->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2))#define MLX4_INVALID_SLAVE_ID 0xFF#define MLX4_SINK_COUNTER_INDEX (dev) (dev->caps.max_counters - 1)
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/12 IB/mlx4: Add gid_type to GID properties
In reply to a message not in the archiveIB core driver adds a property of type to struct ib_gid_attr. The mlx4 driver should take that in consideration when modifying or querying the hardware gid table.
--- drivers/infiniband/hw/mlx4/main.c | 17 +++++++++++++---- drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx4/main.c +13 -4
@@ -215,7 +215,8 @@ static int mlx4_ib_add_gid(struct ib_device *device, port_gid_table = &iboe->gids[port_num -1 ];spin_lock_bh (&iboe->lock);for (i =0 ; i <MLX4_MAX_PORT_GIDS ; ++i) { -if (!memcmp (&port_gid_table->gids[i].gid, gid,sizeof (*gid))) { +if (!memcmp (&port_gid_table->gids[i].gid, gid,sizeof (*gid)) && + (port_gid_table->gids[i].gid_type == attr->gid_type)) { found = i;break ; }
@@ -233,6 +234,7 @@ static int mlx4_ib_add_gid(struct ib_device *device, }else { *context = port_gid_table->gids[free].ctx;memcpy (&port_gid_table->gids[free].gid, gid,sizeof (*gid)); + port_gid_table->gids[free].gid_type = attr->gid_type; port_gid_table->gids[free].ctx->real_index = free; port_gid_table->gids[free].ctx->refcount =1 ; hw_update =1 ;
@@ -248,8 +250,10 @@ static int mlx4_ib_add_gid(struct ib_device *device,if (!gids) { ret = -ENOMEM ; }else { -for (i =0 ; i <MLX4_MAX_PORT_GIDS ; i++) +for (i =0 ; i <MLX4_MAX_PORT_GIDS ; i++) {memcpy (&gids[i].gid, &port_gid_table->gids[i].gid,sizeof (union ib_gid )); + gids[i].gid_type = port_gid_table->gids[i].gid_type; + } } }spin_unlock_bh (&iboe->lock);
@@ -325,6 +329,7 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,int i;int ret;unsigned long flags; +struct ib_gid_attr attr;if (port_num >MLX4_MAX_PORTS )return -EINVAL ;
@@ -335,10 +340,13 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,if (!rdma_cap_roce_gid_table (&ibdev->ib_dev, port_num))return index; - ret =ib_get_cached_gid (&ibdev->ib_dev, port_num, index, &gid,NULL ); + ret =ib_get_cached_gid (&ibdev->ib_dev, port_num, index, &gid, &attr);if (ret)return ret; +if (attr.ndev) +dev_put (attr.ndev); +if (!memcmp (&gid, &zgid,sizeof (gid)))return -EINVAL ;
@@ -346,7 +354,8 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev, port_gid_table = &iboe->gids[port_num -1 ];for (i =0 ; i <MLX4_MAX_PORT_GIDS ; ++i) -if (!memcmp (&port_gid_table->gids[i].gid, &gid,sizeof (gid))) { +if (!memcmp (&port_gid_table->gids[i].gid, &gid,sizeof (gid)) && + attr.gid_type == port_gid_table->gids[i].gid_type) { ctx = port_gid_table->gids[i].ctx;break ; }
drivers/infiniband/hw/mlx4/mlx4_ib.h +1 -0
@@ -478,6 +478,7 @@ struct gid_cache_context {struct gid_entry {union ib_gid gid; +enum ib_gid_type gid_type;struct gid_cache_context *ctx; };
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/12 net/mlx4_core: Configure mlx4 hardware for mixed RoCE v1/v2 modes
In reply to a message not in the archiveIf the hardware supports RoCE v2 (mixed with RoCE v1) mode, we enable it. This is necessary in order to support RoCE v2.
--- drivers/net/ethernet/mellanox/mlx4/mlx4.h | 5 ++++- drivers/net/ethernet/mellanox/mlx4/port.c | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/mlx4.h +4 -1
@@ -780,7 +780,10 @@ struct mlx4_set_port_general_context {u16 reserved1;u8 v_ignore_fcs;u8 flags; -u8 ignore_fcs; +union { +u8 ignore_fcs; +u8 roce_mode; + };u8 reserved2;__be16 mtu;u8 pptx;
drivers/net/ethernet/mellanox/mlx4/port.c +7 -0
@@ -1520,6 +1520,8 @@ int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz)return err; } +#define SET_PORT_ROCE_2_FLAGS 0x10 +#define MLX4_SET_PORT_ROCE_V1_V2 0x2int mlx4_SET_PORT_general (struct mlx4_dev *dev,u8 port,int mtu,u8 pptx,u8 pfctx,u8 pprx,u8 pfcrx) {
@@ -1539,6 +1541,11 @@ int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, context->pprx = (pprx * (!pfcrx)) <<7 ; context->pfcrx = pfcrx; +if (dev->caps.flags2 &MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 ) { + context->flags |=SET_PORT_ROCE_2_FLAGS ; + context->roce_mode |= +MLX4_SET_PORT_ROCE_V1_V2 <<4 ; + } in_mod =MLX4_SET_PORT_GENERAL <<8 | port; err = mlx4_cmd(dev, mailbox->dma, in_mod, MLX4_SET_PORT_ETH_OPCODE, MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B,
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/12 IB/mlx4: Add support for setting RoCEv2 gids in hardware
In reply to a message not in the archiveTo tell hardware about a gid with type RoCEv2, software needs a new modifier to the SET_PORT command: MLX4_SET_PORT_ROCE_ADDR. This can replace the old method, MLX4_SET_PORT_GID_TABLE, for RoCEv1 gids.
--- drivers/infiniband/hw/mlx4/main.c | 63 +++++++++++++++++++++++++++++++++++++-- include/linux/mlx4/cmd.h | 3 +- 2 files changed, 62 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx4/main.c +60 -3
@@ -154,9 +154,9 @@ static struct net_device *mlx4_ib_get_netdev(struct ib_device *device, u8 port_nreturn dev; } -static int mlx4_ib_update_gids (struct gid_entry *gids, -struct mlx4_ib_dev *ibdev, -u8 port_num) +static int mlx4_ib_update_gids_v1 (struct gid_entry *gids, +struct mlx4_ib_dev *ibdev, +u8 port_num) {struct mlx4_cmd_mailbox *mailbox;int err;
@@ -187,6 +187,63 @@ static int mlx4_ib_update_gids(struct gid_entry *gids,return err; } +static int mlx4_ib_update_gids_v1_v2 (struct gid_entry *gids, +struct mlx4_ib_dev *ibdev, +u8 port_num) +{ +struct mlx4_cmd_mailbox *mailbox; +int err; +struct mlx4_dev *dev = ibdev->dev; +int i; +struct { +union ib_gid gid; +__be32 rsrvd1[2 ]; +__be16 rsrvd2; +u8 type; +u8 version; +__be32 rsrvd3; + } *gid_tbl; + + mailbox =mlx4_alloc_cmd_mailbox (dev); +if (IS_ERR (mailbox)) +return -ENOMEM ; + + gid_tbl = mailbox->buf; +for (i =0 ; i <MLX4_MAX_PORT_GIDS ; ++i) { +memcpy (&gid_tbl[i].gid, &gids[i].gid,sizeof (union ib_gid )); +if (gids[i].gid_type ==IB_GID_TYPE_ROCE_UDP_ENCAP ) { + gid_tbl[i].version =2 ; +if (!ipv6_addr_v4mapped ((struct in6_addr *)&gids[i].gid)) + gid_tbl[i].type =1 ; +else +memset (&gid_tbl[i].gid,0 ,12 ); + } + } + + err =mlx4_cmd (dev, mailbox->dma, +MLX4_SET_PORT_ROCE_ADDR <<8 | port_num, +1 ,MLX4_CMD_SET_PORT ,MLX4_CMD_TIME_CLASS_B , +MLX4_CMD_WRAPPED ); +if (mlx4_is_bonded (dev)) + err +=mlx4_cmd (dev, mailbox->dma, +MLX4_SET_PORT_ROCE_ADDR <<8 |2 , +1 ,MLX4_CMD_SET_PORT ,MLX4_CMD_TIME_CLASS_B , +MLX4_CMD_WRAPPED ); + +mlx4_free_cmd_mailbox (dev, mailbox); +return err; +} + +static int mlx4_ib_update_gids (struct gid_entry *gids, +struct mlx4_ib_dev *ibdev, +u8 port_num) +{ +if (ibdev->dev->caps.flags2 &MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 ) +return mlx4_ib_update_gids_v1_v2 (gids, ibdev, port_num); + +return mlx4_ib_update_gids_v1 (gids, ibdev, port_num); +} + static int mlx4_ib_add_gid(struct ib_device *device, u8 port_num, unsigned int index,
include/linux/mlx4/cmd.h +2 -1
@@ -206,7 +206,8 @@ enum {MLX4_SET_PORT_GID_TABLE =0x5 ,MLX4_SET_PORT_PRIO2TC =0x8 ,MLX4_SET_PORT_SCHEDULER =0x9 , -MLX4_SET_PORT_VXLAN =0xB +MLX4_SET_PORT_VXLAN =0xB , +MLX4_SET_PORT_ROCE_ADDR =0xD }; enum {
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/12 net/mlx4_core: Add support for configuring RoCE v2 UDP port
In reply to a message not in the archiveIn order to support RoCE v2, the hardware needs to be configured to classify certain UDP packets as RoCE v2 packets and pass it through its RoCE pipeline. This patch enables configuring this UDP port.
--- drivers/net/ethernet/mellanox/mlx4/fw.c | 16 +++++++++++++++- include/linux/mlx4/device.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/fw.c +15 -1
@@ -2262,7 +2262,8 @@ struct mlx4_config_dev {__be32 rsvd1[3 ];__be16 vxlan_udp_dport;__be16 rsvd2; -__be32 rsvd3; +__be16 roce_v2_entropy; +__be16 roce_v2_udp_dport;__be32 roce_flags;__be32 rsvd4[25 ];__be16 rsvd5;
@@ -2271,6 +2272,7 @@ struct mlx4_config_dev { };#define MLX4_VXLAN_UDP_DPORT (1 << 0) +#define MLX4_ROCE_V2_UDP_DPORT BIT(3)#define MLX4_DISABLE_RX_PORT BIT(18)static int mlx4_CONFIG_DEV_set (struct mlx4_dev *dev,struct mlx4_config_dev *config_dev)
@@ -2388,6 +2390,18 @@ int mlx4_disable_rx_port_check(struct mlx4_dev *dev, bool dis)return mlx4_CONFIG_DEV_set (dev, &config_dev); } +int mlx4_config_roce_v2_port (struct mlx4_dev *dev,u16 udp_port) +{ +struct mlx4_config_dev config_dev; + +memset (&config_dev,0 ,sizeof (config_dev)); + config_dev.update_flags =cpu_to_be32 (MLX4_ROCE_V2_UDP_DPORT ); + config_dev.roce_v2_udp_dport =cpu_to_be16 (udp_port); + +return mlx4_CONFIG_DEV_set (dev, &config_dev); +} +EXPORT_SYMBOL_GPL (mlx4_config_roce_v2_port); +int mlx4_virt2phy_port_map (struct mlx4_dev *dev,u32 port1,u32 port2) {struct mlx4_cmd_mailbox *mailbox;
include/linux/mlx4/device.h +1 -0
@@ -1460,6 +1460,7 @@ int mlx4_get_base_gid_ix(struct mlx4_dev *dev, int slave, int port);int mlx4_config_vxlan_port (struct mlx4_dev *dev,__be16 udp_port);int mlx4_disable_rx_port_check (struct mlx4_dev *dev,bool dis); +int mlx4_config_roce_v2_port (struct mlx4_dev *dev,u16 udp_port);int mlx4_virt2phy_port_map (struct mlx4_dev *dev,u32 port1,u32 port2);int mlx4_vf_smi_enabled (struct mlx4_dev *dev,int slave,int port);int mlx4_vf_get_enable_smi_admin (struct mlx4_dev *dev,int slave,int port);
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/12 net/mlx4_core: Add support for RoCE v2 entropy
In reply to a message not in the archiveIn RoCE v2 we need to choose a source UDP port, we do so by using entropy over the source and dest QPNs.
--- drivers/net/ethernet/mellanox/mlx4/qp.c | 26 ++++++++++++++++++++++++++ include/linux/mlx4/qp.h | 13 ++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/qp.c +26 -0
@@ -167,6 +167,12 @@ static int __mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt, context->log_page_size = mtt->page_shift -MLX4_ICM_PAGE_SHIFT ; } +if ((cur_state ==MLX4_QP_STATE_RTR ) && + (new_state ==MLX4_QP_STATE_RTS ) && + dev->caps.flags2 &MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 ) + context->roce_entropy = +cpu_to_be16 (mlx4_qp_roce_entropy (dev, qp->qpn)); + *(__be32 *) mailbox->buf =cpu_to_be32 (optpar);memcpy (mailbox->buf +8 , context,sizeof *context);
@@ -921,3 +927,23 @@ int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt,return 0 ; }EXPORT_SYMBOL_GPL (mlx4_qp_to_ready); + +u16 mlx4_qp_roce_entropy (struct mlx4_dev *dev,u32 qpn) +{ +struct mlx4_qp_context context; +struct mlx4_qp qp; +int err; + + qp.qpn = qpn; + err =mlx4_qp_query (dev, &qp, &context); +if (!err) { +u32 dest_qpn =be32_to_cpu (context.remote_qpn) &0xffffff ; +u16 folded_dst =folded_qp (dest_qpn); +u16 folded_src =folded_qp (qpn); + +return (dest_qpn != qpn) ? + ((folded_dst ^ folded_src) |0xC000 ) : + folded_src |0xC000 ; + } +return 0xdead ; +}
include/linux/mlx4/qp.h +12 -1
@@ -204,7 +204,8 @@ struct mlx4_qp_context {u32 reserved1;__be32 next_send_psn;__be32 cqn_send; -u32 reserved2[2 ]; +__be16 roce_entropy; +__be16 reserved2[3 ];__be32 last_acked_psn;__be32 ssn;__be32 params2;
@@ -487,4 +488,14 @@ static inline struct mlx4_qp *__mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn)void mlx4_qp_remove (struct mlx4_dev *dev,struct mlx4_qp *qp); +static inline u16 folded_qp (u32 q) +{ +u16 res; + + res = ((q &0xff ) ^ ((q &0xff0000 ) >>16 )) | (q &0xff00 ); +return res; +} + +u16 mlx4_qp_roce_entropy (struct mlx4_dev *dev,u32 qpn); +#endif /* MLX4_QP_H */
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/12 IB/core: Add definition for the standard RoCE V2 UDP port
In reply to a message not in the archiveThis will be used in hardware device driver when building QP or AH contexts.
--- include/rdma/ib_verbs.h | 1 + 1 file changed, 1 insertion(+)
include/rdma/ib_verbs.h +1 -0
@@ -81,6 +81,7 @@ enum ib_gid_type {IB_GID_TYPE_SIZE }; +#define ROCE_V2_UDP_DPORT 4791struct ib_gid_attr {enum ib_gid_type gid_type;struct net_device *ndev;
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/12 IB/mlx4: Support modify_qp for RoCE v2
In reply to a message not in the archiveIn order to support modify_qp for RoCE v2, we need to set the gid_type in the QP context.
--- drivers/infiniband/hw/mlx4/qp.c | 37 ++++++++++++++++++++++++++++++++++--- include/linux/mlx4/qp.h | 2 +- 2 files changed, 35 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx4/qp.c +34 -3
@@ -1509,6 +1509,24 @@ static int create_qp_lb_counter(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)return 0 ; } +enum { +MLX4_QPC_ROCE_MODE_1 =0 , +MLX4_QPC_ROCE_MODE_2 =2 , +MLX4_QPC_ROCE_MODE_UNDEFINED =0xff +}; + +static u8 gid_type_to_qpc (enum ib_gid_type gid_type) +{ +switch (gid_type) { +case IB_GID_TYPE_ROCE : +return MLX4_QPC_ROCE_MODE_1 ; +case IB_GID_TYPE_ROCE_UDP_ENCAP : +return MLX4_QPC_ROCE_MODE_2 ; +default : +return MLX4_QPC_ROCE_MODE_UNDEFINED ; + } +} +static int __mlx4_ib_modify_qp (struct ib_qp *ibqp,const struct ib_qp_attr *attr,int attr_mask,enum ib_qp_state cur_state,enum ib_qp_state new_state)
@@ -1655,9 +1673,10 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,u16 vlan =0xffff ;u8 smac[ETH_ALEN ];int status =0 ; +int is_eth =rdma_cap_eth_ah (&dev->ib_dev, port_num) && + attr->ah_attr.ah_flags &IB_AH_GRH ; -if (rdma_cap_eth_ah (&dev->ib_dev, port_num) && - attr->ah_attr.ah_flags &IB_AH_GRH ) { +if (is_eth) {int index = attr->ah_attr.grh.sgid_index; status = ib_get_cached_gid(ibqp->device, port_num,
@@ -1679,6 +1698,18 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp, optpar |= (MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH |MLX4_QP_OPTPAR_SCHED_QUEUE ); + +if (is_eth && + (cur_state ==IB_QPS_INIT && new_state ==IB_QPS_RTR )) { +u8 qpc_roce_mode =gid_type_to_qpc (gid_attr.gid_type); + +if (qpc_roce_mode ==MLX4_QPC_ROCE_MODE_UNDEFINED ) { + err = -EINVAL ; + goto out; + } + context->rlkey_roce_mode |= (qpc_roce_mode <<6 ); + } + }if (attr_mask &IB_QP_TIMEOUT ) {
@@ -1850,7 +1881,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp, sqd_event =0 ;if (!ibqp->uobject && cur_state ==IB_QPS_RESET && new_state ==IB_QPS_INIT ) - context->rlkey |= (1 <<4 ); + context->rlkey_roce_mode |= (1 <<4 );/* * Before passing a kernel QP to the HW, make sure that the
include/linux/mlx4/qp.h +1 -1
@@ -194,7 +194,7 @@ struct mlx4_qp_context {u8 mtu_msgmax;u8 rq_size_stride;u8 sq_size_stride; -u8 rlkey; +u8 rlkey_roce_mode;__be32 usr_page;__be32 local_qpn;__be32 remote_qpn;
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/12 IB/mlx4: Enable RoCE v2 when the IB device is added
In reply to a message not in the archiveIf the hardware supports RoCE v2, we configure the hardware UDP port according to the RoCE v2 Annex when mlx4_ib device is added.
--- drivers/infiniband/hw/mlx4/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/main.c +8 -1
@@ -2493,7 +2493,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)if (mlx4_ib_init_sriov (ibdev)) goto err_mad; -if (dev->caps.flags &MLX4_DEV_CAP_FLAG_IBOE ) { +if (dev->caps.flags &MLX4_DEV_CAP_FLAG_IBOE || + dev->caps.flags2 &MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 ) {if (!iboe->nb.notifier_call) { iboe->nb.notifier_call = mlx4_ib_netdev_event; err =register_netdevice_notifier (&iboe->nb);
@@ -2502,6 +2503,12 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) goto err_notif; } } +if (dev->caps.flags2 &MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 ) { + err =mlx4_config_roce_v2_port (dev,ROCE_V2_UDP_DPORT ); +if (err) { + goto err_notif; + } + } }for (j =0 ; j <ARRAY_SIZE (mlx4_class_attributes); ++j) {
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 10/12 IB/mlx4: Enable send of RoCE QP1 packets with IP/UDP headers
In reply to a message not in the archiveRoCEv2 packets are sent over IP/UDP protocols.
The mlx4 driver uses a type of RAW QP to send packets for QP1 and therefore needs to build the network headers below BTH in software.
This patch adds option to build QP1 packets with IP and UDP headers if RoCEv2 is requested.
--- drivers/infiniband/core/ud_header.c | 2 +- drivers/infiniband/hw/mlx4/qp.c | 60 +++++++++++++++++++++++++++++++------ include/rdma/ib_pack.h | 4 +-- 3 files changed, 54 insertions(+), 12 deletions(-)
drivers/infiniband/core/ud_header.c +1 -1
@@ -280,7 +280,7 @@ static const struct ib_field deth_table[] = { .size_bits = 24 } }; -__be16 ib_ud_ip4_csum (struct ib_ud_header *header) +__sum16 ib_ud_ip4_csum (struct ib_ud_header *header) {struct iphdr iph;
drivers/infiniband/hw/mlx4/qp.c +51 -9
125 lines not on this page · raw message
include/rdma/ib_pack.h +2 -2
@@ -234,7 +234,7 @@ struct ib_unpacked_ip4 {__be16 frag_off;u8 ttl;u8 protocol; -__be16 check; +__sum16 check;__be32 saddr;__be32 daddr; };
@@ -280,7 +280,7 @@ void ib_unpack(const struct ib_field *desc,void *buf, void *structure); -__be16 ib_ud_ip4_csum (struct ib_ud_header *header); +__sum16 ib_ud_ip4_csum (struct ib_ud_header *header); int ib_ud_header_init(int payload_bytes, int lrh_present,
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 11/12 IB/mlx4: Create and use another QP1 for RoCEv2
In reply to a message not in the archiveThe mlx4 driver uses a special QP to implement the GSI QP. This kind of QP allows to build the InfiniBand headers in software. When mlx4 hardware builds the packet, it calculates the ICRC and puts it at the end of the payload. However, this ICRC calculation depends on the QP configuration, which is determined when the QP is modified (roce_mode during INIT->RTR).
When receiving a packet, the ICRC verification doesn't depend on this configuration.
Therefore, using two GSI QPs for send (one for each RoCE version) and one GSI QP for receive are required.
--- drivers/infiniband/hw/mlx4/mlx4_ib.h | 7 ++ drivers/infiniband/hw/mlx4/qp.c | 159 ++++++++++++++++++++++++++++++----- 2 files changed, 147 insertions(+), 19 deletions(-)
drivers/infiniband/hw/mlx4/mlx4_ib.h +7 -0
@@ -177,11 +177,18 @@ struct mlx4_ib_wq {unsigned tail; }; +enum { +MLX4_IB_QP_CREATE_ROCE_V2_GSI =IB_QP_CREATE_RESERVED_START +}; +enum mlx4_ib_qp_flags {MLX4_IB_QP_LSO =IB_QP_CREATE_IPOIB_UD_LSO ,MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK =IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK ,MLX4_IB_QP_NETIF =IB_QP_CREATE_NETIF_QP ,MLX4_IB_QP_CREATE_USE_GFP_NOIO =IB_QP_CREATE_USE_GFP_NOIO , + +/* Mellanox specific flags start from IB_QP_CREATE_RESERVED_START */ +MLX4_IB_ROCE_V2_GSI_QP =MLX4_IB_QP_CREATE_ROCE_V2_GSI ,MLX4_IB_SRIOV_TUNNEL_QP =1 <<30 ,MLX4_IB_SRIOV_SQP =1 <<31 , };
drivers/infiniband/hw/mlx4/qp.c +140 -19
241 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 12/12 IB/mlx4: Advertise RoCE v2 support
In reply to a message not in the archiveFrom: Matan Barak <matanb-VPRAkNaXOzVWk0Htik3J/[email protected]>
Advertise RoCE v2 support in port_immutable attributes according to the hardware's capabilities. This enables the verbs stack to use RoCE v2 mode.
--- drivers/infiniband/hw/mlx4/main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mlx4/main.c +9 -3
@@ -2185,6 +2185,7 @@ static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num, struct ib_port_immutable *immutable) {struct ib_port_attr attr; +struct mlx4_ib_dev *mdev =to_mdev (ibdev);int err; err =mlx4_ib_query_port (ibdev, port_num, &attr);
@@ -2194,10 +2195,15 @@ static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num, immutable->pkey_tbl_len = attr.pkey_tbl_len; immutable->gid_tbl_len = attr.gid_tbl_len; -if (mlx4_ib_port_link_layer (ibdev, port_num) ==IB_LINK_LAYER_INFINIBAND ) +if (mlx4_ib_port_link_layer (ibdev, port_num) ==IB_LINK_LAYER_INFINIBAND ) { immutable->core_cap_flags =RDMA_CORE_PORT_IBA_IB ; -else - immutable->core_cap_flags =RDMA_CORE_PORT_IBA_ROCE ; + }else { +if (mdev->dev->caps.flags &MLX4_DEV_CAP_FLAG_IBOE ) + immutable->core_cap_flags =RDMA_CORE_PORT_IBA_ROCE ; +if (mdev->dev->caps.flags2 &MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 ) + immutable->core_cap_flags =RDMA_CORE_PORT_IBA_ROCE | +RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP ; + } immutable->max_mad_size =IB_MGMT_MAD_SIZE ;
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 22 lines · Moni Shoua
RoCEv2 is the InfiniBand transport protocol encapsulated in ETH/IP/UDP link and network protocols.
The implementation to the IB/core driver was added by Matan Barak as an infrastructure for any vendor driver and this patch set uses it to add RoCEv2 support for ConnectX-3Pro NICsMatan Barak (1):
IB/mlx4: Advertise RoCE v2 supportMoni Shoua (11):
net/mlx4: Query RoCE support
IB/mlx4: Addgid_typeto GID properties
net/mlx4_core: Configure mlx4 hardware for mixed RoCE v1/v2 modes IB/mlx4: Add support for setting RoCEv2 gids in hardwarenet/mlx4_core: Add support for configuring RoCE v2 UDP portnet/mlx4_core: Add support for RoCE v2 entropy IB/core: Add definition for the standard RoCE V2 UDP port IB/mlx4: Supportmodify_qpfor RoCE v2
IB/mlx4: Enable RoCE v2 when the IB device is added IB/mlx4: Enable send of RoCE QP1 packets with IP/UDP headers IB/mlx4: Create and use another QP1 for RoCEv2
Quoted 15 lines
drivers/infiniband/core/ud_header.c | 2 +- drivers/infiniband/hw/mlx4/main.c | 101 ++++++++++-- drivers/infiniband/hw/mlx4/mlx4_ib.h | 8 + drivers/infiniband/hw/mlx4/qp.c | 256 ++++++++++++++++++++++++++---- drivers/net/ethernet/mellanox/mlx4/fw.c | 39 ++++- drivers/net/ethernet/mellanox/mlx4/mlx4.h | 5 +- drivers/net/ethernet/mellanox/mlx4/port.c | 7 + drivers/net/ethernet/mellanox/mlx4/qp.c | 26 +++ include/linux/mlx4/cmd.h | 3 +- include/linux/mlx4/device.h | 11 +- include/linux/mlx4/qp.h | 15 +- include/rdma/ib_pack.h | 4 +- include/rdma/ib_verbs.h | 1 + 13 files changed, 425 insertions(+), 53 deletions(-)
Series applied.
Signature · 2 lines
Doug Ledford <[email protected]> GPG KeyID: 0E572FDD