IB/iser: Align coding style across driver

The following changes were made:
1. Align function signatures to 80 characters per line.
2. Remove tabs for variable assignment and use 1 space instead.
3. Don't compare to NULL in "if" clause.
4. Remove strange indentations.

This will ease on the maintenance of the driver for the future.

Link: https://lore.kernel.org/r/20211215135721.3662-7-mgurtovoy@nvidia.com
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
Max Gurtovoy 2021-12-15 15:57:21 +02:00 committed by Jason Gunthorpe
parent 48886a84a3
commit ca2770c65b
4 changed files with 87 additions and 126 deletions

View File

@ -135,9 +135,8 @@ static int iscsi_iser_set(const char *val, const struct kernel_param *kp)
* Notes: In case of data length errors or iscsi PDU completion failures * Notes: In case of data length errors or iscsi PDU completion failures
* this routine will signal iscsi layer of connection failure. * this routine will signal iscsi layer of connection failure.
*/ */
void void iscsi_iser_recv(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
iscsi_iser_recv(struct iscsi_conn *conn, struct iscsi_hdr *hdr, char *rx_data, int rx_data_len)
char *rx_data, int rx_data_len)
{ {
int rc = 0; int rc = 0;
int datalen; int datalen;
@ -172,8 +171,7 @@ error:
* Netes: This routine can't fail, just assign iscsi task * Netes: This routine can't fail, just assign iscsi task
* hdr and max hdr size. * hdr and max hdr size.
*/ */
static int static int iscsi_iser_pdu_alloc(struct iscsi_task *task, uint8_t opcode)
iscsi_iser_pdu_alloc(struct iscsi_task *task, uint8_t opcode)
{ {
struct iscsi_iser_task *iser_task = task->dd_data; struct iscsi_iser_task *iser_task = task->dd_data;
@ -194,9 +192,8 @@ iscsi_iser_pdu_alloc(struct iscsi_task *task, uint8_t opcode)
* state mutex to avoid dereferencing the IB device which * state mutex to avoid dereferencing the IB device which
* may have already been terminated. * may have already been terminated.
*/ */
int int iser_initialize_task_headers(struct iscsi_task *task,
iser_initialize_task_headers(struct iscsi_task *task, struct iser_tx_desc *tx_desc)
struct iser_tx_desc *tx_desc)
{ {
struct iser_conn *iser_conn = task->conn->dd_data; struct iser_conn *iser_conn = task->conn->dd_data;
struct iser_device *device = iser_conn->ib_conn.device; struct iser_device *device = iser_conn->ib_conn.device;
@ -233,8 +230,7 @@ iser_initialize_task_headers(struct iscsi_task *task,
* Return: Returns zero on success or -ENOMEM when failing * Return: Returns zero on success or -ENOMEM when failing
* to init task headers (dma mapping error). * to init task headers (dma mapping error).
*/ */
static int static int iscsi_iser_task_init(struct iscsi_task *task)
iscsi_iser_task_init(struct iscsi_task *task)
{ {
struct iscsi_iser_task *iser_task = task->dd_data; struct iscsi_iser_task *iser_task = task->dd_data;
int ret; int ret;
@ -268,8 +264,8 @@ iscsi_iser_task_init(struct iscsi_task *task)
* xmit. * xmit.
* *
**/ **/
static int static int iscsi_iser_mtask_xmit(struct iscsi_conn *conn,
iscsi_iser_mtask_xmit(struct iscsi_conn *conn, struct iscsi_task *task) struct iscsi_task *task)
{ {
int error = 0; int error = 0;
@ -286,9 +282,8 @@ iscsi_iser_mtask_xmit(struct iscsi_conn *conn, struct iscsi_task *task)
return error; return error;
} }
static int static int iscsi_iser_task_xmit_unsol_data(struct iscsi_conn *conn,
iscsi_iser_task_xmit_unsol_data(struct iscsi_conn *conn, struct iscsi_task *task)
struct iscsi_task *task)
{ {
struct iscsi_r2t_info *r2t = &task->unsol_r2t; struct iscsi_r2t_info *r2t = &task->unsol_r2t;
struct iscsi_data hdr; struct iscsi_data hdr;
@ -322,8 +317,7 @@ iscsi_iser_task_xmit_unsol_data_exit:
* *
* Return: zero on success or escalates $error on failure. * Return: zero on success or escalates $error on failure.
*/ */
static int static int iscsi_iser_task_xmit(struct iscsi_task *task)
iscsi_iser_task_xmit(struct iscsi_task *task)
{ {
struct iscsi_conn *conn = task->conn; struct iscsi_conn *conn = task->conn;
struct iscsi_iser_task *iser_task = task->dd_data; struct iscsi_iser_task *iser_task = task->dd_data;
@ -406,8 +400,7 @@ static void iscsi_iser_cleanup_task(struct iscsi_task *task)
* *
* In addition the error sector is marked. * In addition the error sector is marked.
*/ */
static u8 static u8 iscsi_iser_check_protection(struct iscsi_task *task, sector_t *sector)
iscsi_iser_check_protection(struct iscsi_task *task, sector_t *sector)
{ {
struct iscsi_iser_task *iser_task = task->dd_data; struct iscsi_iser_task *iser_task = task->dd_data;
enum iser_data_dir dir = iser_task->dir[ISER_DIR_IN] ? enum iser_data_dir dir = iser_task->dir[ISER_DIR_IN] ?
@ -456,11 +449,9 @@ iscsi_iser_conn_create(struct iscsi_cls_session *cls_session,
* -EINVAL in case end-point doesn't exsits anymore or iser connection * -EINVAL in case end-point doesn't exsits anymore or iser connection
* state is not UP (teardown already started). * state is not UP (teardown already started).
*/ */
static int static int iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session, struct iscsi_cls_conn *cls_conn,
struct iscsi_cls_conn *cls_conn, uint64_t transport_eph, int is_leading)
uint64_t transport_eph,
int is_leading)
{ {
struct iscsi_conn *conn = cls_conn->dd_data; struct iscsi_conn *conn = cls_conn->dd_data;
struct iser_conn *iser_conn; struct iser_conn *iser_conn;
@ -515,8 +506,7 @@ out:
* from this point iscsi must call conn_stop in session/connection * from this point iscsi must call conn_stop in session/connection
* teardown so iser transport must wait for it. * teardown so iser transport must wait for it.
*/ */
static int static int iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)
iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)
{ {
struct iscsi_conn *iscsi_conn; struct iscsi_conn *iscsi_conn;
struct iser_conn *iser_conn; struct iser_conn *iser_conn;
@ -538,8 +528,7 @@ iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)
* handle, so we call it under iser the state lock to protect against * handle, so we call it under iser the state lock to protect against
* this kind of race. * this kind of race.
*/ */
static void static void iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
{ {
struct iscsi_conn *conn = cls_conn->dd_data; struct iscsi_conn *conn = cls_conn->dd_data;
struct iser_conn *iser_conn = conn->dd_data; struct iser_conn *iser_conn = conn->dd_data;
@ -574,8 +563,7 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
* *
* Removes and free iscsi host. * Removes and free iscsi host.
*/ */
static void static void iscsi_iser_session_destroy(struct iscsi_cls_session *cls_session)
iscsi_iser_session_destroy(struct iscsi_cls_session *cls_session)
{ {
struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
@ -584,8 +572,7 @@ iscsi_iser_session_destroy(struct iscsi_cls_session *cls_session)
iscsi_host_free(shost); iscsi_host_free(shost);
} }
static inline unsigned int static inline unsigned int iser_dif_prot_caps(int prot_caps)
iser_dif_prot_caps(int prot_caps)
{ {
int ret = 0; int ret = 0;
@ -704,9 +691,8 @@ free_host:
return NULL; return NULL;
} }
static int static int iscsi_iser_set_param(struct iscsi_cls_conn *cls_conn,
iscsi_iser_set_param(struct iscsi_cls_conn *cls_conn, enum iscsi_param param, char *buf, int buflen)
enum iscsi_param param, char *buf, int buflen)
{ {
int value; int value;
@ -756,8 +742,8 @@ iscsi_iser_set_param(struct iscsi_cls_conn *cls_conn,
* *
* Output connection statistics. * Output connection statistics.
*/ */
static void static void iscsi_iser_conn_get_stats(struct iscsi_cls_conn *cls_conn,
iscsi_iser_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats) struct iscsi_stats *stats)
{ {
struct iscsi_conn *conn = cls_conn->dd_data; struct iscsi_conn *conn = cls_conn->dd_data;
@ -808,9 +794,9 @@ static int iscsi_iser_get_ep_param(struct iscsi_endpoint *ep,
* Return: iscsi_endpoint created by iscsi layer or ERR_PTR(error) * Return: iscsi_endpoint created by iscsi layer or ERR_PTR(error)
* if fails. * if fails.
*/ */
static struct iscsi_endpoint * static struct iscsi_endpoint *iscsi_iser_ep_connect(struct Scsi_Host *shost,
iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, struct sockaddr *dst_addr,
int non_blocking) int non_blocking)
{ {
int err; int err;
struct iser_conn *iser_conn; struct iser_conn *iser_conn;
@ -853,8 +839,7 @@ failure:
* or more likely iser connection state transitioned to TEMINATING or * or more likely iser connection state transitioned to TEMINATING or
* DOWN during the wait period. * DOWN during the wait period.
*/ */
static int static int iscsi_iser_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
iscsi_iser_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
{ {
struct iser_conn *iser_conn = ep->dd_data; struct iser_conn *iser_conn = ep->dd_data;
int rc; int rc;
@ -889,8 +874,7 @@ iscsi_iser_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
* and cleanup or actually call it immediately in case we didn't pass * and cleanup or actually call it immediately in case we didn't pass
* iscsi conn bind/start stage, thus it is safe. * iscsi conn bind/start stage, thus it is safe.
*/ */
static void static void iscsi_iser_ep_disconnect(struct iscsi_endpoint *ep)
iscsi_iser_ep_disconnect(struct iscsi_endpoint *ep)
{ {
struct iser_conn *iser_conn = ep->dd_data; struct iser_conn *iser_conn = ep->dd_data;

View File

@ -95,11 +95,8 @@ static int iser_prepare_read_cmd(struct iscsi_task *task)
* task->data[ISER_DIR_OUT].data_len, Protection size * task->data[ISER_DIR_OUT].data_len, Protection size
* is stored at task->prot[ISER_DIR_OUT].data_len * is stored at task->prot[ISER_DIR_OUT].data_len
*/ */
static int static int iser_prepare_write_cmd(struct iscsi_task *task, unsigned int imm_sz,
iser_prepare_write_cmd(struct iscsi_task *task, unsigned int unsol_sz, unsigned int edtl)
unsigned int imm_sz,
unsigned int unsol_sz,
unsigned int edtl)
{ {
struct iscsi_iser_task *iser_task = task->dd_data; struct iscsi_iser_task *iser_task = task->dd_data;
struct iser_mem_reg *mem_reg; struct iser_mem_reg *mem_reg;
@ -160,8 +157,8 @@ iser_prepare_write_cmd(struct iscsi_task *task,
} }
/* creates a new tx descriptor and adds header regd buffer */ /* creates a new tx descriptor and adds header regd buffer */
static void iser_create_send_desc(struct iser_conn *iser_conn, static void iser_create_send_desc(struct iser_conn *iser_conn,
struct iser_tx_desc *tx_desc) struct iser_tx_desc *tx_desc)
{ {
struct iser_device *device = iser_conn->ib_conn.device; struct iser_device *device = iser_conn->ib_conn.device;
@ -355,8 +352,7 @@ out:
* @conn: link to matching iscsi connection * @conn: link to matching iscsi connection
* @task: SCSI command task * @task: SCSI command task
*/ */
int iser_send_command(struct iscsi_conn *conn, int iser_send_command(struct iscsi_conn *conn, struct iscsi_task *task)
struct iscsi_task *task)
{ {
struct iser_conn *iser_conn = conn->dd_data; struct iser_conn *iser_conn = conn->dd_data;
struct iscsi_iser_task *iser_task = task->dd_data; struct iscsi_iser_task *iser_task = task->dd_data;
@ -427,8 +423,7 @@ send_command_error:
* @task: SCSI command task * @task: SCSI command task
* @hdr: pointer to the LLD's iSCSI message header * @hdr: pointer to the LLD's iSCSI message header
*/ */
int iser_send_data_out(struct iscsi_conn *conn, int iser_send_data_out(struct iscsi_conn *conn, struct iscsi_task *task,
struct iscsi_task *task,
struct iscsi_data *hdr) struct iscsi_data *hdr)
{ {
struct iser_conn *iser_conn = conn->dd_data; struct iser_conn *iser_conn = conn->dd_data;
@ -490,8 +485,7 @@ send_data_out_error:
return err; return err;
} }
int iser_send_control(struct iscsi_conn *conn, int iser_send_control(struct iscsi_conn *conn, struct iscsi_task *task)
struct iscsi_task *task)
{ {
struct iser_conn *iser_conn = conn->dd_data; struct iser_conn *iser_conn = conn->dd_data;
struct iscsi_iser_task *iser_task = task->dd_data; struct iscsi_iser_task *iser_task = task->dd_data;
@ -590,8 +584,7 @@ void iser_login_rsp(struct ib_cq *cq, struct ib_wc *wc)
iser_post_recvm(iser_conn, iser_conn->rx_descs); iser_post_recvm(iser_conn, iser_conn->rx_descs);
} }
static inline int static inline int iser_inv_desc(struct iser_fr_desc *desc, u32 rkey)
iser_inv_desc(struct iser_fr_desc *desc, u32 rkey)
{ {
if (unlikely((!desc->sig_protected && rkey != desc->rsc.mr->rkey) || if (unlikely((!desc->sig_protected && rkey != desc->rsc.mr->rkey) ||
(desc->sig_protected && rkey != desc->rsc.sig_mr->rkey))) { (desc->sig_protected && rkey != desc->rsc.sig_mr->rkey))) {
@ -604,10 +597,8 @@ iser_inv_desc(struct iser_fr_desc *desc, u32 rkey)
return 0; return 0;
} }
static int static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc,
iser_check_remote_inv(struct iser_conn *iser_conn, struct iscsi_hdr *hdr)
struct ib_wc *wc,
struct iscsi_hdr *hdr)
{ {
if (wc->wc_flags & IB_WC_WITH_INVALIDATE) { if (wc->wc_flags & IB_WC_WITH_INVALIDATE) {
struct iscsi_task *task; struct iscsi_task *task;

View File

@ -44,8 +44,7 @@ void iser_reg_comp(struct ib_cq *cq, struct ib_wc *wc)
iser_err_comp(wc, "memreg"); iser_err_comp(wc, "memreg");
} }
static struct iser_fr_desc * static struct iser_fr_desc *iser_reg_desc_get_fr(struct ib_conn *ib_conn)
iser_reg_desc_get_fr(struct ib_conn *ib_conn)
{ {
struct iser_fr_pool *fr_pool = &ib_conn->fr_pool; struct iser_fr_pool *fr_pool = &ib_conn->fr_pool;
struct iser_fr_desc *desc; struct iser_fr_desc *desc;
@ -60,9 +59,8 @@ iser_reg_desc_get_fr(struct ib_conn *ib_conn)
return desc; return desc;
} }
static void static void iser_reg_desc_put_fr(struct ib_conn *ib_conn,
iser_reg_desc_put_fr(struct ib_conn *ib_conn, struct iser_fr_desc *desc)
struct iser_fr_desc *desc)
{ {
struct iser_fr_pool *fr_pool = &ib_conn->fr_pool; struct iser_fr_pool *fr_pool = &ib_conn->fr_pool;
unsigned long flags; unsigned long flags;
@ -73,9 +71,9 @@ iser_reg_desc_put_fr(struct ib_conn *ib_conn,
} }
int iser_dma_map_task_data(struct iscsi_iser_task *iser_task, int iser_dma_map_task_data(struct iscsi_iser_task *iser_task,
struct iser_data_buf *data, struct iser_data_buf *data,
enum iser_data_dir iser_dir, enum iser_data_dir iser_dir,
enum dma_data_direction dma_dir) enum dma_data_direction dma_dir)
{ {
struct ib_device *dev; struct ib_device *dev;
@ -100,9 +98,8 @@ void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task,
ib_dma_unmap_sg(dev, data->sg, data->size, dir); ib_dma_unmap_sg(dev, data->sg, data->size, dir);
} }
static int static int iser_reg_dma(struct iser_device *device, struct iser_data_buf *mem,
iser_reg_dma(struct iser_device *device, struct iser_data_buf *mem, struct iser_mem_reg *reg)
struct iser_mem_reg *reg)
{ {
struct scatterlist *sg = mem->sg; struct scatterlist *sg = mem->sg;
@ -154,8 +151,8 @@ void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task,
reg->mem_h = NULL; reg->mem_h = NULL;
} }
static void static void iser_set_dif_domain(struct scsi_cmnd *sc,
iser_set_dif_domain(struct scsi_cmnd *sc, struct ib_sig_domain *domain) struct ib_sig_domain *domain)
{ {
domain->sig_type = IB_SIG_TYPE_T10_DIF; domain->sig_type = IB_SIG_TYPE_T10_DIF;
domain->sig.dif.pi_interval = scsi_prot_interval(sc); domain->sig.dif.pi_interval = scsi_prot_interval(sc);
@ -171,8 +168,8 @@ iser_set_dif_domain(struct scsi_cmnd *sc, struct ib_sig_domain *domain)
domain->sig.dif.ref_remap = true; domain->sig.dif.ref_remap = true;
} }
static int static int iser_set_sig_attrs(struct scsi_cmnd *sc,
iser_set_sig_attrs(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs) struct ib_sig_attrs *sig_attrs)
{ {
switch (scsi_get_prot_op(sc)) { switch (scsi_get_prot_op(sc)) {
case SCSI_PROT_WRITE_INSERT: case SCSI_PROT_WRITE_INSERT:
@ -205,8 +202,7 @@ iser_set_sig_attrs(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs)
return 0; return 0;
} }
static inline void static inline void iser_set_prot_checks(struct scsi_cmnd *sc, u8 *mask)
iser_set_prot_checks(struct scsi_cmnd *sc, u8 *mask)
{ {
*mask = 0; *mask = 0;
if (sc->prot_flags & SCSI_PROT_REF_CHECK) if (sc->prot_flags & SCSI_PROT_REF_CHECK)
@ -215,11 +211,8 @@ iser_set_prot_checks(struct scsi_cmnd *sc, u8 *mask)
*mask |= IB_SIG_CHECK_GUARD; *mask |= IB_SIG_CHECK_GUARD;
} }
static inline void static inline void iser_inv_rkey(struct ib_send_wr *inv_wr, struct ib_mr *mr,
iser_inv_rkey(struct ib_send_wr *inv_wr, struct ib_cqe *cqe, struct ib_send_wr *next_wr)
struct ib_mr *mr,
struct ib_cqe *cqe,
struct ib_send_wr *next_wr)
{ {
inv_wr->opcode = IB_WR_LOCAL_INV; inv_wr->opcode = IB_WR_LOCAL_INV;
inv_wr->wr_cqe = cqe; inv_wr->wr_cqe = cqe;
@ -229,12 +222,11 @@ iser_inv_rkey(struct ib_send_wr *inv_wr,
inv_wr->next = next_wr; inv_wr->next = next_wr;
} }
static int static int iser_reg_sig_mr(struct iscsi_iser_task *iser_task,
iser_reg_sig_mr(struct iscsi_iser_task *iser_task, struct iser_data_buf *mem,
struct iser_data_buf *mem, struct iser_data_buf *sig_mem,
struct iser_data_buf *sig_mem, struct iser_reg_resources *rsc,
struct iser_reg_resources *rsc, struct iser_mem_reg *sig_reg)
struct iser_mem_reg *sig_reg)
{ {
struct iser_tx_desc *tx_desc = &iser_task->desc; struct iser_tx_desc *tx_desc = &iser_task->desc;
struct ib_cqe *cqe = &iser_task->iser_conn->ib_conn.reg_cqe; struct ib_cqe *cqe = &iser_task->iser_conn->ib_conn.reg_cqe;
@ -335,12 +327,10 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task,
return 0; return 0;
} }
static int static int iser_reg_data_sg(struct iscsi_iser_task *task,
iser_reg_data_sg(struct iscsi_iser_task *task, struct iser_data_buf *mem,
struct iser_data_buf *mem, struct iser_fr_desc *desc, bool use_dma_key,
struct iser_fr_desc *desc, struct iser_mem_reg *reg)
bool use_dma_key,
struct iser_mem_reg *reg)
{ {
struct iser_device *device = task->iser_conn->ib_conn.device; struct iser_device *device = task->iser_conn->ib_conn.device;

View File

@ -265,14 +265,14 @@ static int iser_create_ib_conn_res(struct ib_conn *ib_conn)
memset(&init_attr, 0, sizeof(init_attr)); memset(&init_attr, 0, sizeof(init_attr));
init_attr.event_handler = iser_qp_event_callback; init_attr.event_handler = iser_qp_event_callback;
init_attr.qp_context = (void *)ib_conn; init_attr.qp_context = (void *)ib_conn;
init_attr.send_cq = ib_conn->cq; init_attr.send_cq = ib_conn->cq;
init_attr.recv_cq = ib_conn->cq; init_attr.recv_cq = ib_conn->cq;
init_attr.cap.max_recv_wr = ISER_QP_MAX_RECV_DTOS; init_attr.cap.max_recv_wr = ISER_QP_MAX_RECV_DTOS;
init_attr.cap.max_send_sge = 2; init_attr.cap.max_send_sge = 2;
init_attr.cap.max_recv_sge = 1; init_attr.cap.max_recv_sge = 1;
init_attr.sq_sig_type = IB_SIGNAL_REQ_WR; init_attr.sq_sig_type = IB_SIGNAL_REQ_WR;
init_attr.qp_type = IB_QPT_RC; init_attr.qp_type = IB_QPT_RC;
init_attr.cap.max_send_wr = max_send_wr; init_attr.cap.max_send_wr = max_send_wr;
if (ib_conn->pi_support) if (ib_conn->pi_support)
init_attr.create_flags |= IB_QP_CREATE_INTEGRITY_EN; init_attr.create_flags |= IB_QP_CREATE_INTEGRITY_EN;
@ -283,9 +283,8 @@ static int iser_create_ib_conn_res(struct ib_conn *ib_conn)
goto out_err; goto out_err;
ib_conn->qp = ib_conn->cma_id->qp; ib_conn->qp = ib_conn->cma_id->qp;
iser_info("setting conn %p cma_id %p qp %p max_send_wr %d\n", iser_info("setting conn %p cma_id %p qp %p max_send_wr %d\n", ib_conn,
ib_conn, ib_conn->cma_id, ib_conn->cma_id, ib_conn->cma_id->qp, max_send_wr);
ib_conn->cma_id->qp, max_send_wr);
return ret; return ret;
out_err: out_err:
@ -313,7 +312,7 @@ struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id)
goto inc_refcnt; goto inc_refcnt;
device = kzalloc(sizeof *device, GFP_KERNEL); device = kzalloc(sizeof *device, GFP_KERNEL);
if (device == NULL) if (!device)
goto out; goto out;
/* assign this device to the device */ /* assign this device to the device */
@ -392,8 +391,7 @@ void iser_release_work(struct work_struct *work)
* so the cm_id removal is out of here. It is Safe to * so the cm_id removal is out of here. It is Safe to
* be invoked multiple times. * be invoked multiple times.
*/ */
static void iser_free_ib_conn_res(struct iser_conn *iser_conn, static void iser_free_ib_conn_res(struct iser_conn *iser_conn, bool destroy)
bool destroy)
{ {
struct ib_conn *ib_conn = &iser_conn->ib_conn; struct ib_conn *ib_conn = &iser_conn->ib_conn;
struct iser_device *device = ib_conn->device; struct iser_device *device = ib_conn->device;
@ -401,7 +399,7 @@ static void iser_free_ib_conn_res(struct iser_conn *iser_conn,
iser_info("freeing conn %p cma_id %p qp %p\n", iser_info("freeing conn %p cma_id %p qp %p\n",
iser_conn, ib_conn->cma_id, ib_conn->qp); iser_conn, ib_conn->cma_id, ib_conn->qp);
if (ib_conn->qp != NULL) { if (ib_conn->qp) {
rdma_destroy_qp(ib_conn->cma_id); rdma_destroy_qp(ib_conn->cma_id);
ib_cq_pool_put(ib_conn->cq, ib_conn->cq_size); ib_cq_pool_put(ib_conn->cq, ib_conn->cq_size);
ib_conn->qp = NULL; ib_conn->qp = NULL;
@ -411,7 +409,7 @@ static void iser_free_ib_conn_res(struct iser_conn *iser_conn,
if (iser_conn->rx_descs) if (iser_conn->rx_descs)
iser_free_rx_descriptors(iser_conn); iser_free_rx_descriptors(iser_conn);
if (device != NULL) { if (device) {
iser_device_try_release(device); iser_device_try_release(device);
ib_conn->device = NULL; ib_conn->device = NULL;
} }
@ -445,7 +443,7 @@ void iser_conn_release(struct iser_conn *iser_conn)
iser_free_ib_conn_res(iser_conn, true); iser_free_ib_conn_res(iser_conn, true);
mutex_unlock(&iser_conn->state_mutex); mutex_unlock(&iser_conn->state_mutex);
if (ib_conn->cma_id != NULL) { if (ib_conn->cma_id) {
rdma_destroy_id(ib_conn->cma_id); rdma_destroy_id(ib_conn->cma_id);
ib_conn->cma_id = NULL; ib_conn->cma_id = NULL;
} }
@ -505,9 +503,8 @@ static void iser_connect_error(struct rdma_cm_id *cma_id)
iser_conn->state = ISER_CONN_TERMINATING; iser_conn->state = ISER_CONN_TERMINATING;
} }
static void static void iser_calc_scsi_params(struct iser_conn *iser_conn,
iser_calc_scsi_params(struct iser_conn *iser_conn, unsigned int max_sectors)
unsigned int max_sectors)
{ {
struct iser_device *device = iser_conn->ib_conn.device; struct iser_device *device = iser_conn->ib_conn.device;
struct ib_device_attr *attr = &device->ib_device->attrs; struct ib_device_attr *attr = &device->ib_device->attrs;
@ -545,8 +542,8 @@ iser_calc_scsi_params(struct iser_conn *iser_conn,
static void iser_addr_handler(struct rdma_cm_id *cma_id) static void iser_addr_handler(struct rdma_cm_id *cma_id)
{ {
struct iser_device *device; struct iser_device *device;
struct iser_conn *iser_conn; struct iser_conn *iser_conn;
struct ib_conn *ib_conn; struct ib_conn *ib_conn;
int ret; int ret;
iser_conn = cma_id->context; iser_conn = cma_id->context;
@ -593,7 +590,7 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id)
static void iser_route_handler(struct rdma_cm_id *cma_id) static void iser_route_handler(struct rdma_cm_id *cma_id)
{ {
struct rdma_conn_param conn_param; struct rdma_conn_param conn_param;
int ret; int ret;
struct iser_cm_hdr req_hdr; struct iser_cm_hdr req_hdr;
struct iser_conn *iser_conn = cma_id->context; struct iser_conn *iser_conn = cma_id->context;
struct ib_conn *ib_conn = &iser_conn->ib_conn; struct ib_conn *ib_conn = &iser_conn->ib_conn;
@ -609,9 +606,9 @@ static void iser_route_handler(struct rdma_cm_id *cma_id)
memset(&conn_param, 0, sizeof conn_param); memset(&conn_param, 0, sizeof conn_param);
conn_param.responder_resources = ib_dev->attrs.max_qp_rd_atom; conn_param.responder_resources = ib_dev->attrs.max_qp_rd_atom;
conn_param.initiator_depth = 1; conn_param.initiator_depth = 1;
conn_param.retry_count = 7; conn_param.retry_count = 7;
conn_param.rnr_retry_count = 6; conn_param.rnr_retry_count = 6;
memset(&req_hdr, 0, sizeof(req_hdr)); memset(&req_hdr, 0, sizeof(req_hdr));
req_hdr.flags = ISER_ZBVA_NOT_SUP; req_hdr.flags = ISER_ZBVA_NOT_SUP;
@ -687,7 +684,8 @@ static void iser_cleanup_handler(struct rdma_cm_id *cma_id,
complete(&iser_conn->ib_completion); complete(&iser_conn->ib_completion);
} }
static int iser_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) static int iser_cma_handler(struct rdma_cm_id *cma_id,
struct rdma_cm_event *event)
{ {
struct iser_conn *iser_conn; struct iser_conn *iser_conn;
int ret = 0; int ret = 0;
@ -764,10 +762,8 @@ void iser_conn_init(struct iser_conn *iser_conn)
* starts the process of connecting to the target * starts the process of connecting to the target
* sleeps until the connection is established or rejected * sleeps until the connection is established or rejected
*/ */
int iser_connect(struct iser_conn *iser_conn, int iser_connect(struct iser_conn *iser_conn, struct sockaddr *src_addr,
struct sockaddr *src_addr, struct sockaddr *dst_addr, int non_blocking)
struct sockaddr *dst_addr,
int non_blocking)
{ {
struct ib_conn *ib_conn = &iser_conn->ib_conn; struct ib_conn *ib_conn = &iser_conn->ib_conn;
int err = 0; int err = 0;