RDMA queue
* hw/rdma: fix gcc 9.2 warnings * hw/rdma: eliminate data-path processing * hw/rdma: Replace strncpy with pstrcpy -----BEGIN PGP SIGNATURE----- iQEcBAABAgAGBQJedk8XAAoJEDbUwPDPL+RtJagH/RaI247pEdDuBhul14xfzAwH rJU79CglrLmNne6q7UPFvH8iHfEIZRKlDNqeC/1M8MsY+2aieCvydyg82kqiyhzH Lt1FL2sT5beQ14Fa0qT3XkswZXYGDuU5apmDIrzz7Yjwx28e8kDPLTXb91C9WBHK YLkx27BwiFwDnh3BQbxlEbQBAQ2rwZ4vwC2MateU/sfFenHhJMIfhaFFyshTLrEW 55pMGLtBdByOrlNu9T93UOdZsfY+q5w6/iwvOupf7qN9rYnke6O/gc/hY3LE0Pp8 PDZjpNl54JHgJVBDW1u3CqLiYiyTj0y3G86HandV2+dr8bHC27jyWf3U4dWKlfM= =HEVb -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/marcel/tags/rdma-pull-request' into staging RDMA queue * hw/rdma: fix gcc 9.2 warnings * hw/rdma: eliminate data-path processing * hw/rdma: Replace strncpy with pstrcpy # gpg: Signature made Sat 21 Mar 2020 17:29:59 GMT # gpg: using RSA key 36D4C0F0CF2FE46D # gpg: Good signature from "Marcel Apfelbaum <marcel.apfelbaum@zoho.com>" [marginal] # gpg: aka "Marcel Apfelbaum <marcel@redhat.com>" [marginal] # gpg: aka "Marcel Apfelbaum <marcel.apfelbaum@gmail.com>" [marginal] # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: B1C6 3A57 F92E 08F2 640F 31F5 36D4 C0F0 CF2F E46D * remotes/marcel/tags/rdma-pull-request: hw/rdma: avoid suspicious strncpy() use hw/rdma: Skip data-path mr_id translation hw/rdma: Cosmetic change - no need for two sge arrays hw/rdma/vmw/pvrdma_dev_ring: Replace strncpy with pstrcpy Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
7b1e7cb7c5
|
@ -377,35 +377,42 @@ static void ah_cache_init(void)
|
|||
destroy_ah_hash_key, destroy_ah_hast_data);
|
||||
}
|
||||
|
||||
#ifdef LEGACY_RDMA_REG_MR
|
||||
static int build_host_sge_array(RdmaDeviceResources *rdma_dev_res,
|
||||
struct ibv_sge *dsge, struct ibv_sge *ssge,
|
||||
uint8_t num_sge, uint64_t *total_length)
|
||||
struct ibv_sge *sge, uint8_t num_sge,
|
||||
uint64_t *total_length)
|
||||
{
|
||||
RdmaRmMR *mr;
|
||||
int ssge_idx;
|
||||
int idx;
|
||||
|
||||
for (ssge_idx = 0; ssge_idx < num_sge; ssge_idx++) {
|
||||
mr = rdma_rm_get_mr(rdma_dev_res, ssge[ssge_idx].lkey);
|
||||
for (idx = 0; idx < num_sge; idx++) {
|
||||
mr = rdma_rm_get_mr(rdma_dev_res, sge[idx].lkey);
|
||||
if (unlikely(!mr)) {
|
||||
rdma_error_report("Invalid lkey 0x%x", ssge[ssge_idx].lkey);
|
||||
return VENDOR_ERR_INVLKEY | ssge[ssge_idx].lkey;
|
||||
rdma_error_report("Invalid lkey 0x%x", sge[idx].lkey);
|
||||
return VENDOR_ERR_INVLKEY | sge[idx].lkey;
|
||||
}
|
||||
|
||||
#ifdef LEGACY_RDMA_REG_MR
|
||||
dsge->addr = (uintptr_t)mr->virt + ssge[ssge_idx].addr - mr->start;
|
||||
#else
|
||||
dsge->addr = ssge[ssge_idx].addr;
|
||||
#endif
|
||||
dsge->length = ssge[ssge_idx].length;
|
||||
dsge->lkey = rdma_backend_mr_lkey(&mr->backend_mr);
|
||||
sge[idx].addr = (uintptr_t)mr->virt + sge[idx].addr - mr->start;
|
||||
sge[idx].lkey = rdma_backend_mr_lkey(&mr->backend_mr);
|
||||
|
||||
*total_length += dsge->length;
|
||||
|
||||
dsge++;
|
||||
*total_length += sge[idx].length;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static inline int build_host_sge_array(RdmaDeviceResources *rdma_dev_res,
|
||||
struct ibv_sge *sge, uint8_t num_sge,
|
||||
uint64_t *total_length)
|
||||
{
|
||||
int idx;
|
||||
|
||||
for (idx = 0; idx < num_sge; idx++) {
|
||||
*total_length += sge[idx].length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void trace_mad_message(const char *title, char *buf, int len)
|
||||
{
|
||||
|
@ -484,7 +491,6 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
|
|||
void *ctx)
|
||||
{
|
||||
BackendCtx *bctx;
|
||||
struct ibv_sge new_sge[MAX_SGE];
|
||||
uint32_t bctx_id;
|
||||
int rc;
|
||||
struct ibv_send_wr wr = {}, *bad_wr;
|
||||
|
@ -518,7 +524,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
|
|||
|
||||
rdma_protected_gslist_append_int32(&qp->cqe_ctx_list, bctx_id);
|
||||
|
||||
rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
|
||||
rc = build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge,
|
||||
&backend_dev->rdma_dev_res->stats.tx_len);
|
||||
if (rc) {
|
||||
complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
|
||||
|
@ -538,7 +544,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
|
|||
wr.num_sge = num_sge;
|
||||
wr.opcode = IBV_WR_SEND;
|
||||
wr.send_flags = IBV_SEND_SIGNALED;
|
||||
wr.sg_list = new_sge;
|
||||
wr.sg_list = sge;
|
||||
wr.wr_id = bctx_id;
|
||||
|
||||
rc = ibv_post_send(qp->ibqp, &wr, &bad_wr);
|
||||
|
@ -601,7 +607,6 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
|
|||
struct ibv_sge *sge, uint32_t num_sge, void *ctx)
|
||||
{
|
||||
BackendCtx *bctx;
|
||||
struct ibv_sge new_sge[MAX_SGE];
|
||||
uint32_t bctx_id;
|
||||
int rc;
|
||||
struct ibv_recv_wr wr = {}, *bad_wr;
|
||||
|
@ -635,7 +640,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
|
|||
|
||||
rdma_protected_gslist_append_int32(&qp->cqe_ctx_list, bctx_id);
|
||||
|
||||
rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
|
||||
rc = build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge,
|
||||
&backend_dev->rdma_dev_res->stats.rx_bufs_len);
|
||||
if (rc) {
|
||||
complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
|
||||
|
@ -643,7 +648,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
|
|||
}
|
||||
|
||||
wr.num_sge = num_sge;
|
||||
wr.sg_list = new_sge;
|
||||
wr.sg_list = sge;
|
||||
wr.wr_id = bctx_id;
|
||||
rc = ibv_post_recv(qp->ibqp, &wr, &bad_wr);
|
||||
if (rc) {
|
||||
|
@ -671,7 +676,6 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend_dev,
|
|||
uint32_t num_sge, void *ctx)
|
||||
{
|
||||
BackendCtx *bctx;
|
||||
struct ibv_sge new_sge[MAX_SGE];
|
||||
uint32_t bctx_id;
|
||||
int rc;
|
||||
struct ibv_recv_wr wr = {}, *bad_wr;
|
||||
|
@ -688,7 +692,7 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend_dev,
|
|||
|
||||
rdma_protected_gslist_append_int32(&srq->cqe_ctx_list, bctx_id);
|
||||
|
||||
rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
|
||||
rc = build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge,
|
||||
&backend_dev->rdma_dev_res->stats.rx_bufs_len);
|
||||
if (rc) {
|
||||
complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
|
||||
|
@ -696,7 +700,7 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend_dev,
|
|||
}
|
||||
|
||||
wr.num_sge = num_sge;
|
||||
wr.sg_list = new_sge;
|
||||
wr.sg_list = sge;
|
||||
wr.wr_id = bctx_id;
|
||||
rc = ibv_post_srq_recv(srq->ibsrq, &wr, &bad_wr);
|
||||
if (rc) {
|
||||
|
@ -739,13 +743,8 @@ void rdma_backend_destroy_pd(RdmaBackendPD *pd)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef LEGACY_RDMA_REG_MR
|
||||
int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *addr,
|
||||
size_t length, int access)
|
||||
#else
|
||||
int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *addr,
|
||||
size_t length, uint64_t guest_start, int access)
|
||||
#endif
|
||||
{
|
||||
#ifdef LEGACY_RDMA_REG_MR
|
||||
mr->ibmr = ibv_reg_mr(pd->ibpd, addr, length, access);
|
||||
|
|
|
@ -78,13 +78,8 @@ int rdma_backend_query_port(RdmaBackendDev *backend_dev,
|
|||
int rdma_backend_create_pd(RdmaBackendDev *backend_dev, RdmaBackendPD *pd);
|
||||
void rdma_backend_destroy_pd(RdmaBackendPD *pd);
|
||||
|
||||
#ifdef LEGACY_RDMA_REG_MR
|
||||
int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *addr,
|
||||
size_t length, int access);
|
||||
#else
|
||||
int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *addr,
|
||||
size_t length, uint64_t guest_start, int access);
|
||||
#endif
|
||||
void rdma_backend_destroy_mr(RdmaBackendMR *mr);
|
||||
|
||||
int rdma_backend_create_cq(RdmaBackendDev *backend_dev, RdmaBackendCQ *cq,
|
||||
|
|
|
@ -227,21 +227,20 @@ int rdma_rm_alloc_mr(RdmaDeviceResources *dev_res, uint32_t pd_handle,
|
|||
mr->length = guest_length;
|
||||
mr->virt += (mr->start & (TARGET_PAGE_SIZE - 1));
|
||||
|
||||
#ifdef LEGACY_RDMA_REG_MR
|
||||
ret = rdma_backend_create_mr(&mr->backend_mr, &pd->backend_pd, mr->virt,
|
||||
mr->length, access_flags);
|
||||
#else
|
||||
ret = rdma_backend_create_mr(&mr->backend_mr, &pd->backend_pd, mr->virt,
|
||||
mr->length, guest_start, access_flags);
|
||||
#endif
|
||||
if (ret) {
|
||||
ret = -EIO;
|
||||
goto out_dealloc_mr;
|
||||
}
|
||||
#ifdef LEGACY_RDMA_REG_MR
|
||||
/* We keep mr_handle in lkey so send and recv get get mr ptr */
|
||||
*lkey = *mr_handle;
|
||||
#else
|
||||
*lkey = rdma_backend_mr_lkey(&mr->backend_mr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We keep mr_handle in lkey so send and recv get get mr ptr */
|
||||
*lkey = *mr_handle;
|
||||
*rkey = -1;
|
||||
|
||||
mr->pd_handle = pd_handle;
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "cpu.h"
|
||||
#include "qemu/cutils.h"
|
||||
|
||||
#include "trace.h"
|
||||
|
||||
|
@ -30,8 +32,7 @@ int pvrdma_ring_init(PvrdmaRing *ring, const char *name, PCIDevice *dev,
|
|||
int i;
|
||||
int rc = 0;
|
||||
|
||||
strncpy(ring->name, name, MAX_RING_NAME_SZ);
|
||||
ring->name[MAX_RING_NAME_SZ - 1] = 0;
|
||||
pstrcpy(ring->name, MAX_RING_NAME_SZ, name);
|
||||
ring->dev = dev;
|
||||
ring->ring_state = ring_state;
|
||||
ring->max_elems = max_elems;
|
||||
|
|
Loading…
Reference in a new issue