forked from Minki/linux
1fb7f8973f
Current code uses many different types when dealing with a port of a RDMA device: u8, unsigned int and u32. Switch to u32 to clean up the logic. This allows us to make (at least) the core view consistent and use the same type. Unfortunately not all places can be converted. Many uverbs functions expect port to be u8 so keep those places in order not to break UAPIs. HW/Spec defined values must also not be changed. With the switch to u32 we now can support devices with more than 255 ports. U32_MAX is reserved to make control logic a bit easier to deal with. As a device with U32_MAX ports probably isn't going to happen any time soon this seems like a non issue. When a device with more than 255 ports is created uverbs will report the RDMA device as having 255 ports as this is the max currently supported. The verbs interface is not changed yet because the IBTA spec limits the port size in too many places to be u8 and all applications that relies in verbs won't be able to cope with this change. At this stage, we are extending the interfaces that are using vendor channel solely Once the limitation is lifted mlx5 in switchdev mode will be able to have thousands of SFs created by the device. As the only instance of an RDMA device that reports more than 255 ports will be a representor device and it exposes itself as a RAW Ethernet only device CM/MAD/IPoIB and other ULPs aren't effected by this change and their sysfs/interfaces that are exposes to userspace can remain unchanged. While here cleanup some alignment issues and remove unneeded sanity checks (mainly in rdmavt), Link: https://lore.kernel.org/r/20210301070420.439400-1-leon@kernel.org Signed-off-by: Mark Bloch <mbloch@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
74 lines
2.2 KiB
C
74 lines
2.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2016 HGST, a Western Digital Company.
|
|
*/
|
|
#ifndef _RDMA_RW_H
|
|
#define _RDMA_RW_H
|
|
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/scatterlist.h>
|
|
#include <rdma/ib_verbs.h>
|
|
#include <rdma/rdma_cm.h>
|
|
#include <rdma/mr_pool.h>
|
|
|
|
struct rdma_rw_ctx {
|
|
/* number of RDMA READ/WRITE WRs (not counting MR WRs) */
|
|
u32 nr_ops;
|
|
|
|
/* tag for the union below: */
|
|
u8 type;
|
|
|
|
union {
|
|
/* for mapping a single SGE: */
|
|
struct {
|
|
struct ib_sge sge;
|
|
struct ib_rdma_wr wr;
|
|
} single;
|
|
|
|
/* for mapping of multiple SGEs: */
|
|
struct {
|
|
struct ib_sge *sges;
|
|
struct ib_rdma_wr *wrs;
|
|
} map;
|
|
|
|
/* for registering multiple WRs: */
|
|
struct rdma_rw_reg_ctx {
|
|
struct ib_sge sge;
|
|
struct ib_rdma_wr wr;
|
|
struct ib_reg_wr reg_wr;
|
|
struct ib_send_wr inv_wr;
|
|
struct ib_mr *mr;
|
|
} *reg;
|
|
};
|
|
};
|
|
|
|
int rdma_rw_ctx_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num,
|
|
struct scatterlist *sg, u32 sg_cnt, u32 sg_offset,
|
|
u64 remote_addr, u32 rkey, enum dma_data_direction dir);
|
|
void rdma_rw_ctx_destroy(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
|
|
u32 port_num, struct scatterlist *sg, u32 sg_cnt,
|
|
enum dma_data_direction dir);
|
|
|
|
int rdma_rw_ctx_signature_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
|
|
u32 port_num, struct scatterlist *sg, u32 sg_cnt,
|
|
struct scatterlist *prot_sg, u32 prot_sg_cnt,
|
|
struct ib_sig_attrs *sig_attrs, u64 remote_addr, u32 rkey,
|
|
enum dma_data_direction dir);
|
|
void rdma_rw_ctx_destroy_signature(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
|
|
u32 port_num, struct scatterlist *sg, u32 sg_cnt,
|
|
struct scatterlist *prot_sg, u32 prot_sg_cnt,
|
|
enum dma_data_direction dir);
|
|
|
|
struct ib_send_wr *rdma_rw_ctx_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
|
|
u32 port_num, struct ib_cqe *cqe, struct ib_send_wr *chain_wr);
|
|
int rdma_rw_ctx_post(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num,
|
|
struct ib_cqe *cqe, struct ib_send_wr *chain_wr);
|
|
|
|
unsigned int rdma_rw_mr_factor(struct ib_device *device, u32 port_num,
|
|
unsigned int maxpages);
|
|
void rdma_rw_init_qp(struct ib_device *dev, struct ib_qp_init_attr *attr);
|
|
int rdma_rw_init_mrs(struct ib_qp *qp, struct ib_qp_init_attr *attr);
|
|
void rdma_rw_cleanup_mrs(struct ib_qp *qp);
|
|
|
|
#endif /* _RDMA_RW_H */
|