All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
To: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 12/22] IB/iser: Introduce iser_reg_ops
Date: Thu, 30 Jul 2015 10:05:53 -0500	[thread overview]
Message-ID: <55BA3D51.8050003@opengridcomputing.com> (raw)
In-Reply-To: <1438243595-32288-13-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

On 7/30/2015 3:06 AM, Sagi Grimberg wrote:
> Move all the per-device function pointers to an easy
> extensible iser_reg_ops structure that contains all
> the iser registration operations.
>
> Signed-off-by: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> ---
>   drivers/infiniband/ulp/iser/iscsi_iser.h     | 39 ++++++++++++++++++----------
>   drivers/infiniband/ulp/iser/iser_initiator.c | 16 ++++++------
>   drivers/infiniband/ulp/iser/iser_memory.c    | 35 +++++++++++++++++++++++++
>   drivers/infiniband/ulp/iser/iser_verbs.c     | 30 +++++----------------
>   4 files changed, 75 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
> index 70bf6e7..9ce090c 100644
> --- a/drivers/infiniband/ulp/iser/iscsi_iser.h
> +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
> @@ -326,6 +326,25 @@ struct iser_comp {
>   };
>   
>   /**
> + * struct iser_device - Memory registration operations
> + *     per-device registration schemes
> + *
> + * @alloc_reg_res:     Allocate registration resources
> + * @free_reg_res:      Free registration resources
> + * @reg_rdma_mem:      Register memory buffers
> + * @unreg_rdma_mem:    Un-register memory buffers
> + */
> +struct iser_reg_ops {
> +	int            (*alloc_reg_res)(struct ib_conn *ib_conn,
> +					unsigned cmds_max);
> +	void           (*free_reg_res)(struct ib_conn *ib_conn);
> +	int            (*reg_rdma_mem)(struct iscsi_iser_task *iser_task,
> +				       enum iser_data_dir cmd_dir);
> +	void           (*unreg_rdma_mem)(struct iscsi_iser_task *iser_task,
> +					 enum iser_data_dir cmd_dir);
> +};
> +
> +/**
>    * struct iser_device - iSER device handle
>    *
>    * @ib_device:     RDMA device
> @@ -338,11 +357,7 @@ struct iser_comp {
>    * @comps_used:    Number of completion contexts used, Min between online
>    *                 cpus and device max completion vectors
>    * @comps:         Dinamically allocated array of completion handlers
> - * Memory registration pool Function pointers (FMR or Fastreg):
> - *     @iser_alloc_rdma_reg_res: Allocation of memory regions pool
> - *     @iser_free_rdma_reg_res:  Free of memory regions pool
> - *     @iser_reg_rdma_mem:       Memory registration routine
> - *     @iser_unreg_rdma_mem:     Memory deregistration routine
> + * @reg_ops:       Registration ops
>    */
>   struct iser_device {
>   	struct ib_device             *ib_device;
> @@ -354,13 +369,7 @@ struct iser_device {
>   	int                          refcount;
>   	int			     comps_used;
>   	struct iser_comp	     *comps;
> -	int                          (*iser_alloc_rdma_reg_res)(struct ib_conn *ib_conn,
> -								unsigned cmds_max);
> -	void                         (*iser_free_rdma_reg_res)(struct ib_conn *ib_conn);
> -	int                          (*iser_reg_rdma_mem)(struct iscsi_iser_task *iser_task,
> -							  enum iser_data_dir cmd_dir);
> -	void                         (*iser_unreg_rdma_mem)(struct iscsi_iser_task *iser_task,
> -							    enum iser_data_dir cmd_dir);
> +	struct iser_reg_ops          *reg_ops;
>   };
>   
>   #define ISER_CHECK_GUARD	0xc0
> @@ -563,6 +572,8 @@ extern int iser_debug_level;
>   extern bool iser_pi_enable;
>   extern int iser_pi_guard;
>   
> +int iser_assign_reg_ops(struct iser_device *device);
> +
>   int iser_send_control(struct iscsi_conn *conn,
>   		      struct iscsi_task *task);
>   
> @@ -636,9 +647,9 @@ int  iser_initialize_task_headers(struct iscsi_task *task,
>   			struct iser_tx_desc *tx_desc);
>   int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
>   			      struct iscsi_session *session);
> -int iser_create_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max);
> +int iser_alloc_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max);
>   void iser_free_fmr_pool(struct ib_conn *ib_conn);
> -int iser_create_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max);
> +int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max);
>   void iser_free_fastreg_pool(struct ib_conn *ib_conn);
>   u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task,
>   			     enum iser_data_dir cmd_dir, sector_t *sector);
> diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
> index 42d6f42..88d8a89 100644
> --- a/drivers/infiniband/ulp/iser/iser_initiator.c
> +++ b/drivers/infiniband/ulp/iser/iser_initiator.c
> @@ -73,7 +73,7 @@ static int iser_prepare_read_cmd(struct iscsi_task *task)
>   			return err;
>   	}
>   
> -	err = device->iser_reg_rdma_mem(iser_task, ISER_DIR_IN);
> +	err = device->reg_ops->reg_rdma_mem(iser_task, ISER_DIR_IN);
>   	if (err) {
>   		iser_err("Failed to set up Data-IN RDMA\n");
>   		return err;
> @@ -128,7 +128,7 @@ iser_prepare_write_cmd(struct iscsi_task *task,
>   			return err;
>   	}
>   
> -	err = device->iser_reg_rdma_mem(iser_task, ISER_DIR_OUT);
> +	err = device->reg_ops->reg_rdma_mem(iser_task, ISER_DIR_OUT);
>   	if (err != 0) {
>   		iser_err("Failed to register write cmd RDMA mem\n");
>   		return err;
> @@ -260,7 +260,7 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
>   	iser_conn->qp_max_recv_dtos_mask = session->cmds_max - 1; /* cmds_max is 2^N */
>   	iser_conn->min_posted_rx = iser_conn->qp_max_recv_dtos >> 2;
>   
> -	if (device->iser_alloc_rdma_reg_res(ib_conn, session->scsi_cmds_max))
> +	if (device->reg_ops->alloc_reg_res(ib_conn, session->scsi_cmds_max))
>   		goto create_rdma_reg_res_failed;
>   
>   	if (iser_alloc_login_buf(iser_conn))
> @@ -301,7 +301,7 @@ rx_desc_dma_map_failed:
>   rx_desc_alloc_fail:
>   	iser_free_login_buf(iser_conn);
>   alloc_login_buf_fail:
> -	device->iser_free_rdma_reg_res(ib_conn);
> +	device->reg_ops->free_reg_res(ib_conn);
>   create_rdma_reg_res_failed:
>   	iser_err("failed allocating rx descriptors / data buffers\n");
>   	return -ENOMEM;
> @@ -314,8 +314,8 @@ void iser_free_rx_descriptors(struct iser_conn *iser_conn)
>   	struct ib_conn *ib_conn = &iser_conn->ib_conn;
>   	struct iser_device *device = ib_conn->device;
>   
> -	if (device->iser_free_rdma_reg_res)
> -		device->iser_free_rdma_reg_res(ib_conn);
> +	if (device->reg_ops->free_reg_res)
> +		device->reg_ops->free_reg_res(ib_conn);
>   
>   	rx_desc = iser_conn->rx_descs;
>   	for (i = 0; i < iser_conn->qp_max_recv_dtos; i++, rx_desc++)
> @@ -699,7 +699,7 @@ void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task)
>   	}
>   
>   	if (iser_task->dir[ISER_DIR_IN]) {
> -		device->iser_unreg_rdma_mem(iser_task, ISER_DIR_IN);
> +		device->reg_ops->unreg_rdma_mem(iser_task, ISER_DIR_IN);
>   		if (is_rdma_data_aligned)
>   			iser_dma_unmap_task_data(iser_task,
>   						 &iser_task->data[ISER_DIR_IN],
> @@ -711,7 +711,7 @@ void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task)
>   	}
>   
>   	if (iser_task->dir[ISER_DIR_OUT]) {
> -		device->iser_unreg_rdma_mem(iser_task, ISER_DIR_OUT);
> +		device->reg_ops->unreg_rdma_mem(iser_task, ISER_DIR_OUT);
>   		if (is_rdma_data_aligned)
>   			iser_dma_unmap_task_data(iser_task,
>   						 &iser_task->data[ISER_DIR_OUT],
> diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
> index 4209d73..ff3ec53 100644
> --- a/drivers/infiniband/ulp/iser/iser_memory.c
> +++ b/drivers/infiniband/ulp/iser/iser_memory.c
> @@ -39,6 +39,41 @@
>   
>   #include "iscsi_iser.h"
>   
> +static struct iser_reg_ops fastreg_ops = {
> +	.alloc_reg_res	= iser_alloc_fastreg_pool,
> +	.free_reg_res	= iser_free_fastreg_pool,
> +	.reg_rdma_mem	= iser_reg_rdma_mem_fastreg,
> +	.unreg_rdma_mem	= iser_unreg_mem_fastreg,
> +};
> +
> +static struct iser_reg_ops fmr_ops = {
> +	.alloc_reg_res	= iser_alloc_fmr_pool,
> +	.free_reg_res	= iser_free_fmr_pool,
> +	.reg_rdma_mem	= iser_reg_rdma_mem_fmr,
> +	.unreg_rdma_mem	= iser_unreg_mem_fmr,
> +};
> +
> +int iser_assign_reg_ops(struct iser_device *device)
> +{
> +	struct ib_device_attr *dev_attr = &device->dev_attr;
> +
> +	/* Assign function handles  - based on FMR support */
> +	if (device->ib_device->alloc_fmr && device->ib_device->dealloc_fmr &&
> +	    device->ib_device->map_phys_fmr && device->ib_device->unmap_fmr) {
> +		iser_info("FMR supported, using FMR for registration\n");
> +		device->reg_ops = &fmr_ops;
> +	} else
> +	if (dev_attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS) {
> +		iser_info("FastReg supported, using FastReg for registration\n");
> +		device->reg_ops = &fastreg_ops;
> +	} else {
> +		iser_err("IB device does not support FMRs nor FastRegs, can't register memory\n");
> +		return -1;
> +	}
> +

Perhaps no device supports both FMR and FRMR, but the above code would 
choose FMR over FRMR.  Shouldn't it be the other way around?

> +	return 0;
> +}
> +
>   static void
>   iser_free_bounce_sg(struct iser_data_buf *data)
>   {
> diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
> index 2a0cb42..ca0aba3 100644
> --- a/drivers/infiniband/ulp/iser/iser_verbs.c
> +++ b/drivers/infiniband/ulp/iser/iser_verbs.c
> @@ -87,25 +87,9 @@ static int iser_create_device_ib_res(struct iser_device *device)
>   		return ret;
>   	}
>   
> -	/* Assign function handles  - based on FMR support */
> -	if (device->ib_device->alloc_fmr && device->ib_device->dealloc_fmr &&
> -	    device->ib_device->map_phys_fmr && device->ib_device->unmap_fmr) {
> -		iser_info("FMR supported, using FMR for registration\n");
> -		device->iser_alloc_rdma_reg_res = iser_create_fmr_pool;
> -		device->iser_free_rdma_reg_res = iser_free_fmr_pool;
> -		device->iser_reg_rdma_mem = iser_reg_rdma_mem_fmr;
> -		device->iser_unreg_rdma_mem = iser_unreg_mem_fmr;
> -	} else
> -	if (dev_attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS) {
> -		iser_info("FastReg supported, using FastReg for registration\n");
> -		device->iser_alloc_rdma_reg_res = iser_create_fastreg_pool;
> -		device->iser_free_rdma_reg_res = iser_free_fastreg_pool;
> -		device->iser_reg_rdma_mem = iser_reg_rdma_mem_fastreg;
> -		device->iser_unreg_rdma_mem = iser_unreg_mem_fastreg;
> -	} else {
> -		iser_err("IB device does not support FMRs nor FastRegs, can't register memory\n");
> -		return -1;
> -	}
> +	ret = iser_assign_reg_ops(device);
> +	if (ret)
> +		return ret;
>   
>   	device->comps_used = min_t(int, num_online_cpus(),
>   				 device->ib_device->num_comp_vectors);
> @@ -211,11 +195,11 @@ static void iser_free_device_ib_res(struct iser_device *device)
>   }
>   
>   /**
> - * iser_create_fmr_pool - Creates FMR pool and page_vector
> + * iser_alloc_fmr_pool - Creates FMR pool and page_vector
>    *
>    * returns 0 on success, or errno code on failure
>    */
> -int iser_create_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max)
> +int iser_alloc_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max)
>   {
>   	struct iser_device *device = ib_conn->device;
>   	struct ib_fmr_pool_param params;
> @@ -384,11 +368,11 @@ pi_ctx_alloc_failure:
>   }
>   
>   /**
> - * iser_create_fastreg_pool - Creates pool of fast_reg descriptors
> + * iser_alloc_fastreg_pool - Creates pool of fast_reg descriptors
>    * for fast registration work requests.
>    * returns 0 on success, or errno code on failure
>    */
> -int iser_create_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max)
> +int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max)
>   {
>   	struct iser_device *device = ib_conn->device;
>   	struct iser_fr_desc *desc;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-07-30 15:05 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30  8:06 [PATCH 00/22] iser patches for 4.3 Sagi Grimberg
     [not found] ` <1438243595-32288-1-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-07-30  8:06   ` [PATCH 01/22] IB/iser: Change some module parameters to be RO Sagi Grimberg
2015-07-30  8:06   ` [PATCH 02/22] IB/iser: Change minor assignments and logging prints Sagi Grimberg
2015-07-30  8:06   ` [PATCH 03/22] IB/iser: Remove '.' from log message Sagi Grimberg
2015-07-30  8:06   ` [PATCH 04/22] IB/iser: Fix missing return status check in iser_send_data_out Sagi Grimberg
2015-07-30  8:06   ` [PATCH 05/22] IB/iser: Get rid of un-maintained counters Sagi Grimberg
     [not found]     ` <1438243595-32288-6-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-07-30 10:20       ` Or Gerlitz
     [not found]         ` <CAJ3xEMj6Pupc0+ZqKEaB86kTcJq3P=Z1EoiH-EHzWuaznw48bQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-30 12:05           ` Sagi Grimberg
2015-07-30  8:06   ` [PATCH 06/22] IB/iser: Fix possible bogus DMA unmapping Sagi Grimberg
     [not found]     ` <1438243595-32288-7-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-07-30 10:23       ` Or Gerlitz
     [not found]         ` <CAJ3xEMiqQ6GNnJJ8wEJPVyenRxP=bb6ewm5aSWHHL-4X=oq1eg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-30 12:09           ` Sagi Grimberg
     [not found]             ` <55BA13F4.9090805-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-07-30 13:07               ` COMMERCIAL: " Or Gerlitz
2015-07-30  8:06   ` [PATCH 07/22] IB/iser: Remove a redundant always-false condition Sagi Grimberg
2015-07-30  8:06   ` [PATCH 08/22] IB/iser: Remove an unneeded print for unaligned memory Sagi Grimberg
2015-07-30  8:06   ` [PATCH 09/22] IB/iser: Introduce struct iser_reg_resources Sagi Grimberg
2015-07-30  8:06   ` [PATCH 10/22] IB/iser: Rename struct fast_reg_descriptor -> iser_fr_desc Sagi Grimberg
2015-07-30  8:06   ` [PATCH 11/22] IB/iser: Remove dead code in fmr_pool alloc/free Sagi Grimberg
     [not found]     ` <1438243595-32288-12-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-07-30 10:31       ` Or Gerlitz
     [not found]         ` <CAJ3xEMh7H4+hUfV8qUr5wTsV02YG0vXTPGWLR=KKHeBMxA-zYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-30 12:23           ` Sagi Grimberg
     [not found]             ` <55BA1736.2010204-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-07-30 13:52               ` Or Gerlitz
2015-07-30  8:06   ` [PATCH 12/22] IB/iser: Introduce iser_reg_ops Sagi Grimberg
     [not found]     ` <1438243595-32288-13-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-07-30 15:05       ` Steve Wise [this message]
     [not found]         ` <55BA3D51.8050003-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
2015-07-30 17:25           ` Jason Gunthorpe
     [not found]             ` <20150730172526.GC25282-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-08-02  7:59               ` Sagi Grimberg
2015-07-30 17:32       ` Jason Gunthorpe
2015-07-30  8:06   ` [PATCH 13/22] IB/iser: Move fastreg descriptor allocation to iser_create_fastreg_desc Sagi Grimberg
2015-07-30  8:06   ` [PATCH 14/22] IB/iser: Introduce iser registration pool struct Sagi Grimberg
2015-07-30  8:06   ` [PATCH 15/22] IB/iser: Maintain connection fmr_pool under a single registration descriptor Sagi Grimberg
2015-07-30  8:06   ` [PATCH 16/22] IB/iser: Rename iser_reg_page_vec to iser_fast_reg_fmr Sagi Grimberg
2015-07-30  8:06   ` [PATCH 17/22] IB/iser: Make reg_desc_get a per device routine Sagi Grimberg
2015-07-30  8:06   ` [PATCH 18/22] IB/iser: Unify fast memory registration flows Sagi Grimberg
2015-07-30  8:06   ` [PATCH 19/22] IB/iser: Pass registration pool a size parameter Sagi Grimberg
2015-07-30  8:06   ` [PATCH 20/22] IB/iser: Support up to 8MB data transfer in a single command Sagi Grimberg
     [not found]     ` <1438243595-32288-21-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-07-30 10:22       ` Or Gerlitz
     [not found]         ` <CAJ3xEMjjzrezJ6UEH3rGD5Qu7DPLQM4Lw-JnOFrEvhLGd90spA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-30 12:23           ` Sagi Grimberg
2015-07-30 15:12       ` Steve Wise
     [not found]         ` <55BA3EF6.6080800-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
2015-08-02  8:01           ` Sagi Grimberg
     [not found]             ` <55BDCE4D.5080601-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-08-03 13:57               ` Atchley, Scott
     [not found]                 ` <25F51949-82B5-4BA8-8472-6056BC43C747-1Heg1YXhbW8@public.gmane.org>
2015-08-04 17:10                   ` Sagi Grimberg
     [not found]                     ` <55C0F1FF.7010207-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-08-04 21:21                       ` Or Gerlitz
2015-07-30  8:06   ` [PATCH 21/22] IB/iser: Add debug prints to the various memory registration methods Sagi Grimberg
2015-07-30  8:06   ` [PATCH 22/22] IB/iser: Chain all iser transaction send work requests Sagi Grimberg
     [not found]     ` <1438243595-32288-23-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-07-30 10:27       ` Or Gerlitz
     [not found]         ` <CAJ3xEMhtEuf4y0=1XyC7qNRLWHSb2Bke46cZTB-QTgOhjxg-Ow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-30 12:36           ` Sagi Grimberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55BA3D51.8050003@opengridcomputing.com \
    --to=swise-7bpotxp6k4+p2yhjcf5u+vpxobypeauw@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.