From 88393161210493e317ae391696ee8ef463cb3c23 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Tue, 16 Mar 2010 11:47:56 +0100 Subject: Fix typos in comments [Ss]ytem => [Ss]ystem udpate => update paramters => parameters orginal => original Signed-off-by: Thomas Weber Acked-by: Randy Dunlap Signed-off-by: Jiri Kosina --- drivers/scsi/bfa/include/defs/bfa_defs_cee.h | 2 +- drivers/scsi/bfa/include/defs/bfa_defs_status.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/bfa') diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_cee.h b/drivers/scsi/bfa/include/defs/bfa_defs_cee.h index 520a22f52dd..6217eec8c60 100644 --- a/drivers/scsi/bfa/include/defs/bfa_defs_cee.h +++ b/drivers/scsi/bfa/include/defs/bfa_defs_cee.h @@ -54,7 +54,7 @@ struct bfa_cee_lldp_str_s { }; -/* LLDP paramters */ +/* LLDP parameters */ struct bfa_cee_lldp_cfg_s { struct bfa_cee_lldp_str_s chassis_id; struct bfa_cee_lldp_str_s port_id; diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_status.h b/drivers/scsi/bfa/include/defs/bfa_defs_status.h index cdceaeb9f4b..03ce0331eb4 100644 --- a/drivers/scsi/bfa/include/defs/bfa_defs_status.h +++ b/drivers/scsi/bfa/include/defs/bfa_defs_status.h @@ -223,9 +223,9 @@ enum bfa_status { BFA_STATUS_IM_PVID_NON_ZERO = 140, /* Port VLAN ID (PVID) is Set to * Non-Zero Value */ BFA_STATUS_IM_INETCFG_LOCK_FAILED = 141, /* Acquiring Network - * Subsytem Lock Failed.Please + * Subsystem Lock Failed.Please * try after some time */ - BFA_STATUS_IM_GET_INETCFG_FAILED = 142, /* Acquiring Network Subsytem + BFA_STATUS_IM_GET_INETCFG_FAILED = 142, /* Acquiring Network Subsystem * handle Failed. Please try * after some time */ BFA_STATUS_IM_NOT_BOUND = 143, /* Brocade 10G Ethernet Service is not -- cgit v1.2.3-18-g5258 From 4644efabde172808c0a8b6e3f17e4c204a4e52e7 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 11 Mar 2010 14:09:55 -0800 Subject: [SCSI] bfa: eliminate useless code The variable bfa_itnim is initialized twice to the same (side effect-free) expression. Drop one initialization. A simplified version of the semantic match that finds this problem is: (http://coccinelle.lip6.fr/) // @forall@ idexpression *x; identifier f!=ERR_PTR; @@ x = f(...) ... when != x ( x = f(...,<+...x...+>,...) | * x = f(...) ) // Signed-off-by: Julia Lawall Acked-by: Jing Huang Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/scsi/bfa/bfad_im.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/scsi/bfa') diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index 78f42aa5736..e2c70de2dba 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -252,7 +252,6 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd, struct bfa_itnim_s *bfa_itnim; bfa_status_t rc = BFA_STATUS_OK; - bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim); tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd); if (!tskim) { BFA_DEV_PRINTF(bfad, BFA_ERR, -- cgit v1.2.3-18-g5258 From b504293fe9dc42917a919044f2b672fb361329d0 Mon Sep 17 00:00:00 2001 From: Jing Huang Date: Fri, 19 Mar 2010 11:05:39 -0700 Subject: [SCSI] bfa: add fc transport class based vport create/delete Use duplicate fc transport template for physical and vitual port. Add vport create/delete/disalbe functions in the transport template of physical port. Changes to make the vport create/delete function to work under this framework. Signed-off-by: Jing Huang Signed-off-by: James Bottomley --- drivers/scsi/bfa/bfad.c | 10 +-- drivers/scsi/bfa/bfad_attr.c | 201 +++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/bfa/bfad_drv.h | 2 +- drivers/scsi/bfa/bfad_im.c | 53 ++++++------ drivers/scsi/bfa/bfad_im.h | 6 +- 5 files changed, 239 insertions(+), 33 deletions(-) (limited to 'drivers/scsi/bfa') diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c index 13f5feb308c..3a5163d3675 100644 --- a/drivers/scsi/bfa/bfad.c +++ b/drivers/scsi/bfa/bfad.c @@ -299,8 +299,6 @@ bfa_fcb_vport_delete(struct bfad_vport_s *vport_drv) complete(vport_drv->comp_del); return; } - - kfree(vport_drv); } /** @@ -483,7 +481,7 @@ ext: */ bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id, - struct bfa_port_cfg_s *port_cfg) + struct bfa_port_cfg_s *port_cfg, struct device *dev) { struct bfad_vport_s *vport; int rc = BFA_STATUS_OK; @@ -506,7 +504,8 @@ bfad_vport_create(struct bfad_s *bfad, u16 vf_id, goto ext_free_vport; if (port_cfg->roles & BFA_PORT_ROLE_FCP_IM) { - rc = bfad_im_scsi_host_alloc(bfad, vport->drv_port.im_port); + rc = bfad_im_scsi_host_alloc(bfad, vport->drv_port.im_port, + dev); if (rc != BFA_STATUS_OK) goto ext_free_fcs_vport; } @@ -848,7 +847,8 @@ bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role) goto out; } - rc = bfad_im_scsi_host_alloc(bfad, bfad->pport.im_port); + rc = bfad_im_scsi_host_alloc(bfad, bfad->pport.im_port, + &bfad->pcidev->dev); if (rc != BFA_STATUS_OK) goto out; diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c index 6a2efdd5ef2..e477bfbfa7d 100644 --- a/drivers/scsi/bfa/bfad_attr.c +++ b/drivers/scsi/bfa/bfad_attr.c @@ -364,6 +364,152 @@ bfad_im_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout) } +static int +bfad_im_vport_create(struct fc_vport *fc_vport, bool disable) +{ + char *vname = fc_vport->symbolic_name; + struct Scsi_Host *shost = fc_vport->shost; + struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0]; + struct bfad_s *bfad = im_port->bfad; + struct bfa_port_cfg_s port_cfg; + int status = 0, rc; + unsigned long flags; + + memset(&port_cfg, 0, sizeof(port_cfg)); + + port_cfg.pwwn = wwn_to_u64((u8 *) &fc_vport->port_name); + port_cfg.nwwn = wwn_to_u64((u8 *) &fc_vport->node_name); + + if (strlen(vname) > 0) + strcpy((char *)&port_cfg.sym_name, vname); + + port_cfg.roles = BFA_PORT_ROLE_FCP_IM; + rc = bfad_vport_create(bfad, 0, &port_cfg, &fc_vport->dev); + + if (rc == BFA_STATUS_OK) { + struct bfad_vport_s *vport; + struct bfa_fcs_vport_s *fcs_vport; + struct Scsi_Host *vshost; + + spin_lock_irqsave(&bfad->bfad_lock, flags); + fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, + port_cfg.pwwn); + if (fcs_vport == NULL) { + spin_unlock_irqrestore(&bfad->bfad_lock, flags); + return VPCERR_BAD_WWN; + } + + fc_vport_set_state(fc_vport, FC_VPORT_ACTIVE); + if (disable) { + bfa_fcs_vport_stop(fcs_vport); + fc_vport_set_state(fc_vport, FC_VPORT_DISABLED); + } + spin_unlock_irqrestore(&bfad->bfad_lock, flags); + + vport = fcs_vport->vport_drv; + vshost = vport->drv_port.im_port->shost; + fc_host_node_name(vshost) = wwn_to_u64((u8 *) &port_cfg.nwwn); + fc_host_port_name(vshost) = wwn_to_u64((u8 *) &port_cfg.pwwn); + fc_vport->dd_data = vport; + vport->drv_port.im_port->fc_vport = fc_vport; + + } else if (rc == BFA_STATUS_INVALID_WWN) + return VPCERR_BAD_WWN; + else if (rc == BFA_STATUS_VPORT_EXISTS) + return VPCERR_BAD_WWN; + else if (rc == BFA_STATUS_VPORT_MAX) + return VPCERR_NO_FABRIC_SUPP; + else if (rc == BFA_STATUS_VPORT_WWN_BP) + return VPCERR_BAD_WWN; + else + return FC_VPORT_FAILED; + + return status; +} + +static int +bfad_im_vport_delete(struct fc_vport *fc_vport) +{ + struct bfad_vport_s *vport = (struct bfad_vport_s *)fc_vport->dd_data; + struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) vport->drv_port.im_port; + struct bfad_s *bfad = im_port->bfad; + struct bfad_port_s *port; + struct bfa_fcs_vport_s *fcs_vport; + struct Scsi_Host *vshost; + wwn_t pwwn; + int rc; + unsigned long flags; + struct completion fcomp; + + if (im_port->flags & BFAD_PORT_DELETE) + goto free_scsi_host; + + port = im_port->port; + + vshost = vport->drv_port.im_port->shost; + pwwn = wwn_to_u64((u8 *) &fc_host_port_name(vshost)); + + spin_lock_irqsave(&bfad->bfad_lock, flags); + fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, pwwn); + spin_unlock_irqrestore(&bfad->bfad_lock, flags); + + if (fcs_vport == NULL) + return VPCERR_BAD_WWN; + + vport->drv_port.flags |= BFAD_PORT_DELETE; + + vport->comp_del = &fcomp; + init_completion(vport->comp_del); + + spin_lock_irqsave(&bfad->bfad_lock, flags); + rc = bfa_fcs_vport_delete(&vport->fcs_vport); + spin_unlock_irqrestore(&bfad->bfad_lock, flags); + + wait_for_completion(vport->comp_del); + +free_scsi_host: + bfad_os_scsi_host_free(bfad, im_port); + + kfree(vport); + + return 0; +} + +static int +bfad_im_vport_disable(struct fc_vport *fc_vport, bool disable) +{ + struct bfad_vport_s *vport; + struct bfad_s *bfad; + struct bfa_fcs_vport_s *fcs_vport; + struct Scsi_Host *vshost; + wwn_t pwwn; + unsigned long flags; + + vport = (struct bfad_vport_s *)fc_vport->dd_data; + bfad = vport->drv_port.bfad; + vshost = vport->drv_port.im_port->shost; + pwwn = wwn_to_u64((u8 *) &fc_vport->port_name); + + spin_lock_irqsave(&bfad->bfad_lock, flags); + fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, pwwn); + spin_unlock_irqrestore(&bfad->bfad_lock, flags); + + if (fcs_vport == NULL) + return VPCERR_BAD_WWN; + + if (disable) { + bfa_fcs_vport_stop(fcs_vport); + fc_vport_set_state(fc_vport, FC_VPORT_DISABLED); + } else { + bfa_fcs_vport_start(fcs_vport); + fc_vport_set_state(fc_vport, FC_VPORT_ACTIVE); + } + + return 0; +} + struct fc_function_template bfad_im_fc_function_template = { /* Target dynamic attributes */ @@ -413,6 +559,61 @@ struct fc_function_template bfad_im_fc_function_template = { .show_rport_dev_loss_tmo = 1, .get_rport_dev_loss_tmo = bfad_im_get_rport_loss_tmo, .set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo, + + .vport_create = bfad_im_vport_create, + .vport_delete = bfad_im_vport_delete, + .vport_disable = bfad_im_vport_disable, +}; + +struct fc_function_template bfad_im_vport_fc_function_template = { + + /* Target dynamic attributes */ + .get_starget_port_id = bfad_im_get_starget_port_id, + .show_starget_port_id = 1, + .get_starget_node_name = bfad_im_get_starget_node_name, + .show_starget_node_name = 1, + .get_starget_port_name = bfad_im_get_starget_port_name, + .show_starget_port_name = 1, + + /* Host dynamic attribute */ + .get_host_port_id = bfad_im_get_host_port_id, + .show_host_port_id = 1, + + /* Host fixed attributes */ + .show_host_node_name = 1, + .show_host_port_name = 1, + .show_host_supported_classes = 1, + .show_host_supported_fc4s = 1, + .show_host_supported_speeds = 1, + .show_host_maxframe_size = 1, + + /* More host dynamic attributes */ + .show_host_port_type = 1, + .get_host_port_type = bfad_im_get_host_port_type, + .show_host_port_state = 1, + .get_host_port_state = bfad_im_get_host_port_state, + .show_host_active_fc4s = 1, + .get_host_active_fc4s = bfad_im_get_host_active_fc4s, + .show_host_speed = 1, + .get_host_speed = bfad_im_get_host_speed, + .show_host_fabric_name = 1, + .get_host_fabric_name = bfad_im_get_host_fabric_name, + + .show_host_symbolic_name = 1, + + /* Statistics */ + .get_fc_host_stats = bfad_im_get_stats, + .reset_fc_host_stats = bfad_im_reset_stats, + + /* Allocation length for host specific data */ + .dd_fcrport_size = sizeof(struct bfad_itnim_data_s *), + + /* Remote port fixed attributes */ + .show_rport_maxframe_size = 1, + .show_rport_supported_classes = 1, + .show_rport_dev_loss_tmo = 1, + .get_rport_dev_loss_tmo = bfad_im_get_rport_loss_tmo, + .set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo, }; /** diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h index 107848cd3b6..f4b14396c4a 100644 --- a/drivers/scsi/bfa/bfad_drv.h +++ b/drivers/scsi/bfa/bfad_drv.h @@ -254,7 +254,7 @@ do { \ bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id, - struct bfa_port_cfg_s *port_cfg); + struct bfa_port_cfg_s *port_cfg, struct device *dev); bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id, struct bfa_port_cfg_s *port_cfg); bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role); diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index e2c70de2dba..f263891b8cc 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -30,6 +30,7 @@ BFA_TRC_FILE(LDRV, IM); DEFINE_IDR(bfad_im_port_index); struct scsi_transport_template *bfad_im_scsi_transport_template; +struct scsi_transport_template *bfad_im_scsi_vport_transport_template; static void bfad_im_itnim_work_handler(struct work_struct *work); static int bfad_im_queuecommand(struct scsi_cmnd *cmnd, void (*done)(struct scsi_cmnd *)); @@ -512,7 +513,8 @@ void bfa_fcb_itnim_tov(struct bfad_itnim_s *itnim) * Allocate a Scsi_Host for a port. */ int -bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port) +bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, + struct device *dev) { int error = 1; @@ -541,12 +543,15 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port) im_port->shost->max_lun = MAX_FCP_LUN; im_port->shost->max_cmd_len = 16; im_port->shost->can_queue = bfad->cfg_data.ioc_queue_depth; - im_port->shost->transportt = bfad_im_scsi_transport_template; + if (im_port->port->pvb_type == BFAD_PORT_PHYS_BASE) + im_port->shost->transportt = bfad_im_scsi_transport_template; + else + im_port->shost->transportt = + bfad_im_scsi_vport_transport_template; - error = bfad_os_scsi_add_host(im_port->shost, im_port, bfad); + error = scsi_add_host(im_port->shost, dev); if (error) { - printk(KERN_WARNING "bfad_os_scsi_add_host failure %d\n", - error); + printk(KERN_WARNING "scsi_add_host failure %d\n", error); goto out_fc_rel; } @@ -588,9 +593,11 @@ bfad_im_port_delete_handler(struct work_struct *work) struct bfad_im_port_s *im_port = container_of(work, struct bfad_im_port_s, port_delete_work); - bfad_im_scsi_host_free(im_port->bfad, im_port); - bfad_im_port_clean(im_port); - kfree(im_port); + if (im_port->port->pvb_type != BFAD_PORT_PHYS_BASE) { + im_port->flags |= BFAD_PORT_DELETE; + fc_vport_terminate(im_port->fc_vport); + } + } bfa_status_t @@ -689,23 +696,6 @@ bfad_im_probe_undo(struct bfad_s *bfad) } } - - - -int -bfad_os_scsi_add_host(struct Scsi_Host *shost, struct bfad_im_port_s *im_port, - struct bfad_s *bfad) -{ - struct device *dev; - - if (im_port->port->pvb_type == BFAD_PORT_PHYS_BASE) - dev = &bfad->pcidev->dev; - else - dev = &bfad->pport.im_port->shost->shost_gendev; - - return scsi_add_host(shost, dev); -} - struct Scsi_Host * bfad_os_scsi_host_alloc(struct bfad_im_port_s *im_port, struct bfad_s *bfad) { @@ -724,7 +714,8 @@ bfad_os_scsi_host_alloc(struct bfad_im_port_s *im_port, struct bfad_s *bfad) void bfad_os_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port) { - flush_workqueue(bfad->im->drv_workq); + if (!(im_port->flags & BFAD_PORT_DELETE)) + flush_workqueue(bfad->im->drv_workq); bfad_im_scsi_host_free(im_port->bfad, im_port); bfad_im_port_clean(im_port); kfree(im_port); @@ -829,6 +820,13 @@ bfad_im_module_init(void) if (!bfad_im_scsi_transport_template) return BFA_STATUS_ENOMEM; + bfad_im_scsi_vport_transport_template = + fc_attach_transport(&bfad_im_vport_fc_function_template); + if (!bfad_im_scsi_vport_transport_template) { + fc_release_transport(bfad_im_scsi_transport_template); + return BFA_STATUS_ENOMEM; + } + return BFA_STATUS_OK; } @@ -837,6 +835,8 @@ bfad_im_module_exit(void) { if (bfad_im_scsi_transport_template) fc_release_transport(bfad_im_scsi_transport_template); + if (bfad_im_scsi_vport_transport_template) + fc_release_transport(bfad_im_scsi_vport_transport_template); } void @@ -937,6 +937,7 @@ bfad_os_fc_host_init(struct bfad_im_port_s *im_port) bfa_os_htonll((bfa_fcs_port_get_nwwn(port->fcs_port))); fc_host_port_name(host) = bfa_os_htonll((bfa_fcs_port_get_pwwn(port->fcs_port))); + fc_host_max_npiv_vports(host) = bfa_lps_get_max_vport(&bfad->bfa); fc_host_supported_classes(host) = FC_COS_CLASS3; diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h index 85ab2da2132..973cab4d09c 100644 --- a/drivers/scsi/bfa/bfad_im.h +++ b/drivers/scsi/bfa/bfad_im.h @@ -34,7 +34,7 @@ void bfad_im_port_online(struct bfad_s *bfad, struct bfad_port_s *port); void bfad_im_port_offline(struct bfad_s *bfad, struct bfad_port_s *port); void bfad_im_port_clean(struct bfad_im_port_s *im_port); int bfad_im_scsi_host_alloc(struct bfad_s *bfad, - struct bfad_im_port_s *im_port); + struct bfad_im_port_s *im_port, struct device *dev); void bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port); @@ -64,9 +64,11 @@ struct bfad_im_port_s { struct work_struct port_delete_work; int idr_id; u16 cur_scsi_id; + u16 flags; struct list_head binding_list; struct Scsi_Host *shost; struct list_head itnim_mapped_list; + struct fc_vport *fc_vport; }; enum bfad_itnim_state { @@ -140,6 +142,8 @@ void bfad_im_itnim_unmap(struct bfad_im_port_s *im_port, extern struct scsi_host_template bfad_im_scsi_host_template; extern struct scsi_host_template bfad_im_vport_template; extern struct fc_function_template bfad_im_fc_function_template; +extern struct fc_function_template bfad_im_vport_fc_function_template; extern struct scsi_transport_template *bfad_im_scsi_transport_template; +extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template; #endif -- cgit v1.2.3-18-g5258 From 2eba0d4c000777ce43012d7fda806b075f6cf877 Mon Sep 17 00:00:00 2001 From: Jing Huang Date: Fri, 19 Mar 2010 11:06:05 -0700 Subject: [SCSI] bfa: fix the issue of not handling scsi_cmnd sg chaining case Currently the driver doesn't take into consideraion of possible sg chaining when it walks through the sg list. This is fixed by using the sg_next() which automatically handles the chaining case. Obosolete code is removed as a result of this change. Signed-off-by: Jing Huang Signed-off-by: James Bottomley --- drivers/scsi/bfa/bfa_cb_ioim_macros.h | 29 ----------------------------- drivers/scsi/bfa/bfa_ioim.c | 22 +++++++++++++++++----- 2 files changed, 17 insertions(+), 34 deletions(-) (limited to 'drivers/scsi/bfa') diff --git a/drivers/scsi/bfa/bfa_cb_ioim_macros.h b/drivers/scsi/bfa/bfa_cb_ioim_macros.h index 961fe439daa..53a616f5f50 100644 --- a/drivers/scsi/bfa/bfa_cb_ioim_macros.h +++ b/drivers/scsi/bfa/bfa_cb_ioim_macros.h @@ -116,35 +116,6 @@ bfa_cb_ioim_get_timeout(struct bfad_ioim_s *dio) return 0; } -/** - * Get SG element for the I/O request given the SG element index - */ -static inline union bfi_addr_u -bfa_cb_ioim_get_sgaddr(struct bfad_ioim_s *dio, int sgeid) -{ - struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio; - struct scatterlist *sge; - u64 addr; - - sge = (struct scatterlist *)scsi_sglist(cmnd) + sgeid; - addr = (u64) sg_dma_address(sge); - - return *((union bfi_addr_u *) &addr); -} - -static inline u32 -bfa_cb_ioim_get_sglen(struct bfad_ioim_s *dio, int sgeid) -{ - struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio; - struct scatterlist *sge; - u32 len; - - sge = (struct scatterlist *)scsi_sglist(cmnd) + sgeid; - len = sg_dma_len(sge); - - return len; -} - /** * Get Command Reference Number for the I/O request. 0 if none. */ diff --git a/drivers/scsi/bfa/bfa_ioim.c b/drivers/scsi/bfa/bfa_ioim.c index 5b107abe46e..8a1be201d29 100644 --- a/drivers/scsi/bfa/bfa_ioim.c +++ b/drivers/scsi/bfa/bfa_ioim.c @@ -731,6 +731,9 @@ bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim) static struct fcp_cmnd_s cmnd_z0 = { 0 }; struct bfi_sge_s *sge; u32 pgdlen = 0; + u64 addr; + struct scatterlist *sg; + struct scsi_cmnd *cmnd = (struct scsi_cmnd *) ioim->dio; /** * check for room in queue to send request now @@ -754,8 +757,10 @@ bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim) */ sge = &m->sges[0]; if (ioim->nsges) { - sge->sga = bfa_cb_ioim_get_sgaddr(ioim->dio, 0); - pgdlen = bfa_cb_ioim_get_sglen(ioim->dio, 0); + sg = (struct scatterlist *)scsi_sglist(cmnd); + addr = (u64) sg_dma_address(sg); + sge->sga = *(union bfi_addr_u *) &addr; + pgdlen = sg_dma_len(sg); sge->sg_len = pgdlen; sge->flags = (ioim->nsges > BFI_SGE_INLINE) ? BFI_SGE_DATA_CPL : BFI_SGE_DATA_LAST; @@ -868,10 +873,16 @@ bfa_ioim_sgpg_setup(struct bfa_ioim_s *ioim) struct bfi_sge_s *sge; struct bfa_sgpg_s *sgpg; u32 pgcumsz; + u64 addr; + struct scatterlist *sg; + struct scsi_cmnd *cmnd = (struct scsi_cmnd *) ioim->dio; sgeid = BFI_SGE_INLINE; ioim->sgpg = sgpg = bfa_q_first(&ioim->sgpg_q); + sg = scsi_sglist(cmnd); + sg = sg_next(sg); + do { sge = sgpg->sgpg->sges; nsges = ioim->nsges - sgeid; @@ -879,9 +890,10 @@ bfa_ioim_sgpg_setup(struct bfa_ioim_s *ioim) nsges = BFI_SGPG_DATA_SGES; pgcumsz = 0; - for (i = 0; i < nsges; i++, sge++, sgeid++) { - sge->sga = bfa_cb_ioim_get_sgaddr(ioim->dio, sgeid); - sge->sg_len = bfa_cb_ioim_get_sglen(ioim->dio, sgeid); + for (i = 0; i < nsges; i++, sge++, sgeid++, sg = sg_next(sg)) { + addr = (u64) sg_dma_address(sg); + sge->sga = *(union bfi_addr_u *) &addr; + sge->sg_len = sg_dma_len(sg); pgcumsz += sge->sg_len; /** -- cgit v1.2.3-18-g5258 From b3522f08ec7011aed0abc477bfedd00d189e9cd6 Mon Sep 17 00:00:00 2001 From: Jing Huang Date: Fri, 19 Mar 2010 11:06:44 -0700 Subject: [SCSI] bfa: use pci_iomap() and pci_iounmap() Use pci_iomap() and pci_iounmap() to simplify the code. Remove uncessary #ifdef check for ia64 (it was added as a workaound for some RHEL 5.x release which doesn't export iounmap function) Signed-off-by: Jing Huang Signed-off-by: James Bottomley --- drivers/scsi/bfa/bfad.c | 9 +-------- drivers/scsi/bfa/bfad_drv.h | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'drivers/scsi/bfa') diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c index 3a5163d3675..0baeabadb5b 100644 --- a/drivers/scsi/bfa/bfad.c +++ b/drivers/scsi/bfa/bfad.c @@ -590,7 +590,6 @@ bfad_init_timer(struct bfad_s *bfad) int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad) { - unsigned long bar0_len; int rc = -ENODEV; if (pci_enable_device(pdev)) { @@ -610,9 +609,7 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad) goto out_release_region; } - bfad->pci_bar0_map = pci_resource_start(pdev, 0); - bar0_len = pci_resource_len(pdev, 0); - bfad->pci_bar0_kva = ioremap(bfad->pci_bar0_map, bar0_len); + bfad->pci_bar0_kva = pci_iomap(pdev, 0, pci_resource_len(pdev, 0)); if (bfad->pci_bar0_kva == NULL) { BFA_PRINTF(BFA_ERR, "Fail to map bar0\n"); @@ -645,11 +642,7 @@ out: void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad) { -#if defined(__ia64__) pci_iounmap(pdev, bfad->pci_bar0_kva); -#else - iounmap(bfad->pci_bar0_kva); -#endif pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h index f4b14396c4a..0639aedcb61 100644 --- a/drivers/scsi/bfa/bfad_drv.h +++ b/drivers/scsi/bfa/bfad_drv.h @@ -162,7 +162,6 @@ struct bfad_s { const char *pci_name; struct bfa_pcidev_s hal_pcidev; struct bfa_ioc_pci_attr_s pci_attr; - unsigned long pci_bar0_map; void __iomem *pci_bar0_kva; struct completion comp; struct completion suspend; -- cgit v1.2.3-18-g5258 From 42b426ecb453cf49c3d16cf1d7a5e5d8cab9869d Mon Sep 17 00:00:00 2001 From: Jing Huang Date: Fri, 19 Mar 2010 11:07:09 -0700 Subject: [SCSI] bfa: protect idr using bfad_mutex idr is a global resource, protect it with global bfad_mutex. Signed-off-by: Jing Huang Signed-off-by: James Bottomley --- drivers/scsi/bfa/bfad.c | 2 +- drivers/scsi/bfa/bfad_drv.h | 1 + drivers/scsi/bfa/bfad_im.c | 13 +++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'drivers/scsi/bfa') diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c index 0baeabadb5b..d4fc4287ebd 100644 --- a/drivers/scsi/bfa/bfad.c +++ b/drivers/scsi/bfa/bfad.c @@ -33,7 +33,7 @@ #include BFA_TRC_FILE(LDRV, BFAD); -static DEFINE_MUTEX(bfad_mutex); +DEFINE_MUTEX(bfad_mutex); LIST_HEAD(bfad_list); static int bfad_inst; int bfad_supported_fc4s; diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h index 0639aedcb61..6c920c1b53a 100644 --- a/drivers/scsi/bfa/bfad_drv.h +++ b/drivers/scsi/bfa/bfad_drv.h @@ -293,5 +293,6 @@ extern struct list_head bfad_list; extern int bfa_lun_queue_depth; extern int bfad_supported_fc4s; extern int bfa_linkup_delay; +extern struct mutex bfad_mutex; #endif /* __BFAD_DRV_H__ */ diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index f263891b8cc..5b7cf539e50 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -518,7 +518,9 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, { int error = 1; + mutex_lock(&bfad_mutex); if (!idr_pre_get(&bfad_im_port_index, GFP_KERNEL)) { + mutex_unlock(&bfad_mutex); printk(KERN_WARNING "idr_pre_get failure\n"); goto out; } @@ -526,10 +528,13 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, error = idr_get_new(&bfad_im_port_index, im_port, &im_port->idr_id); if (error) { + mutex_unlock(&bfad_mutex); printk(KERN_WARNING "idr_get_new failure\n"); goto out; } + mutex_unlock(&bfad_mutex); + im_port->shost = bfad_os_scsi_host_alloc(im_port, bfad); if (!im_port->shost) { error = 1; @@ -563,7 +568,9 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, out_fc_rel: scsi_host_put(im_port->shost); out_free_idr: + mutex_lock(&bfad_mutex); idr_remove(&bfad_im_port_index, im_port->idr_id); + mutex_unlock(&bfad_mutex); out: return error; } @@ -571,8 +578,6 @@ out: void bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port) { - unsigned long flags; - bfa_trc(bfad, bfad->inst_no); bfa_log(bfad->logmod, BFA_LOG_LINUX_SCSI_HOST_FREE, im_port->shost->host_no); @@ -582,9 +587,9 @@ bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port) scsi_remove_host(im_port->shost); scsi_host_put(im_port->shost); - spin_lock_irqsave(&bfad->bfad_lock, flags); + mutex_lock(&bfad_mutex); idr_remove(&bfad_im_port_index, im_port->idr_id); - spin_unlock_irqrestore(&bfad->bfad_lock, flags); + mutex_unlock(&bfad_mutex); } static void -- cgit v1.2.3-18-g5258 From 077424e2e2c97c830d903891dfcd1532068b85b7 Mon Sep 17 00:00:00 2001 From: Jing Huang Date: Fri, 19 Mar 2010 11:07:36 -0700 Subject: [SCSI] bfa: sg addr big endian fix sg address in IO request is not set up correctly for big endian platform. add new macros to properly swap the address. Signed-off-by: Jing Huang Signed-off-by: James Bottomley --- drivers/scsi/bfa/bfa_ioim.c | 4 ++-- drivers/scsi/bfa/bfa_os_inc.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/bfa') diff --git a/drivers/scsi/bfa/bfa_ioim.c b/drivers/scsi/bfa/bfa_ioim.c index 8a1be201d29..687f3d6e252 100644 --- a/drivers/scsi/bfa/bfa_ioim.c +++ b/drivers/scsi/bfa/bfa_ioim.c @@ -758,7 +758,7 @@ bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim) sge = &m->sges[0]; if (ioim->nsges) { sg = (struct scatterlist *)scsi_sglist(cmnd); - addr = (u64) sg_dma_address(sg); + addr = bfa_os_sgaddr(sg_dma_address(sg)); sge->sga = *(union bfi_addr_u *) &addr; pgdlen = sg_dma_len(sg); sge->sg_len = pgdlen; @@ -891,7 +891,7 @@ bfa_ioim_sgpg_setup(struct bfa_ioim_s *ioim) pgcumsz = 0; for (i = 0; i < nsges; i++, sge++, sgeid++, sg = sg_next(sg)) { - addr = (u64) sg_dma_address(sg); + addr = bfa_os_sgaddr(sg_dma_address(sg)); sge->sga = *(union bfi_addr_u *) &addr; sge->sg_len = sg_dma_len(sg); pgcumsz += sge->sg_len; diff --git a/drivers/scsi/bfa/bfa_os_inc.h b/drivers/scsi/bfa/bfa_os_inc.h index 10a89f75fa9..4eb1330d5b3 100644 --- a/drivers/scsi/bfa/bfa_os_inc.h +++ b/drivers/scsi/bfa/bfa_os_inc.h @@ -50,6 +50,10 @@ #include #include +#ifdef __BIG_ENDIAN +#define __BIGENDIAN +#endif + #define BFA_ERR KERN_ERR #define BFA_WARNING KERN_WARNING #define BFA_NOTICE KERN_NOTICE @@ -123,6 +127,15 @@ int bfa_os_MWB(void *); (((_x) & 0x00ff0000) >> 8) | \ (((_x) & 0xff000000) >> 24)) +#define bfa_os_swap_sgaddr(_x) ((u64)( \ + (((u64)(_x) & (u64)0x00000000000000ffull) << 32) | \ + (((u64)(_x) & (u64)0x000000000000ff00ull) << 32) | \ + (((u64)(_x) & (u64)0x0000000000ff0000ull) << 32) | \ + (((u64)(_x) & (u64)0x00000000ff000000ull) << 32) | \ + (((u64)(_x) & (u64)0x000000ff00000000ull) >> 32) | \ + (((u64)(_x) & (u64)0x0000ff0000000000ull) >> 32) | \ + (((u64)(_x) & (u64)0x00ff000000000000ull) >> 32) | \ + (((u64)(_x) & (u64)0xff00000000000000ull) >> 32))) #ifndef __BIGENDIAN #define bfa_os_htons(_x) ((u16)((((_x) & 0xff00) >> 8) | \ @@ -133,6 +146,7 @@ int bfa_os_MWB(void *); #define bfa_os_hton3b(_x) bfa_swap_3b(_x) #define bfa_os_wtole(_x) (_x) +#define bfa_os_sgaddr(_x) (_x) #else @@ -141,6 +155,7 @@ int bfa_os_MWB(void *); #define bfa_os_hton3b(_x) (_x) #define bfa_os_htonll(_x) (_x) #define bfa_os_wtole(_x) bfa_os_swap32(_x) +#define bfa_os_sgaddr(_x) bfa_os_swap_sgaddr(_x) #endif -- cgit v1.2.3-18-g5258 From 8637ac3340eca9d01f056f81c10fd61d15d2f5ee Mon Sep 17 00:00:00 2001 From: Jing Huang Date: Tue, 13 Apr 2010 12:22:29 -0700 Subject: [SCSI] bfa: fix compilation warning in powerpc Fix the compilation warning in powerpc. The same change also fixes endian issue we found in powerpc test. This patch has been tested in x86 and powerpc platform. it is created using scsi-misc-2.6. Signed-off-by: Jing Huang Signed-off-by: James Bottomley --- drivers/scsi/bfa/bfa_os_inc.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/bfa') diff --git a/drivers/scsi/bfa/bfa_os_inc.h b/drivers/scsi/bfa/bfa_os_inc.h index 4eb1330d5b3..bd1cd3ee302 100644 --- a/drivers/scsi/bfa/bfa_os_inc.h +++ b/drivers/scsi/bfa/bfa_os_inc.h @@ -176,12 +176,12 @@ int bfa_os_MWB(void *); #define bfa_os_addr_t char __iomem * #define bfa_os_panic() -#define bfa_os_reg_read(_raddr) bfa_os_wtole(readl(_raddr)) -#define bfa_os_reg_write(_raddr, _val) writel(bfa_os_wtole((_val)), (_raddr)) +#define bfa_os_reg_read(_raddr) readl(_raddr) +#define bfa_os_reg_write(_raddr, _val) writel((_val), (_raddr)) #define bfa_os_mem_read(_raddr, _off) \ - bfa_os_ntohl(readl(((_raddr) + (_off)))) + bfa_os_swap32(readl(((_raddr) + (_off)))) #define bfa_os_mem_write(_raddr, _off, _val) \ - writel(bfa_os_htonl((_val)), ((_raddr) + (_off))) + writel(bfa_os_swap32((_val)), ((_raddr) + (_off))) #define BFA_TRC_TS(_trcm) \ ({ \ -- cgit v1.2.3-18-g5258