aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa/bfad_im.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/bfa/bfad_im.c')
-rw-r--r--drivers/scsi/bfa/bfad_im.c78
1 files changed, 40 insertions, 38 deletions
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index d950ee44016e..8ca967dee66d 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -15,7 +15,7 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18/** 18/*
19 * bfad_im.c Linux driver IM module. 19 * bfad_im.c Linux driver IM module.
20 */ 20 */
21 21
@@ -30,8 +30,7 @@ DEFINE_IDR(bfad_im_port_index);
30struct scsi_transport_template *bfad_im_scsi_transport_template; 30struct scsi_transport_template *bfad_im_scsi_transport_template;
31struct scsi_transport_template *bfad_im_scsi_vport_transport_template; 31struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
32static void bfad_im_itnim_work_handler(struct work_struct *work); 32static void bfad_im_itnim_work_handler(struct work_struct *work);
33static int bfad_im_queuecommand(struct scsi_cmnd *cmnd, 33static int bfad_im_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmnd);
34 void (*done)(struct scsi_cmnd *));
35static int bfad_im_slave_alloc(struct scsi_device *sdev); 34static int bfad_im_slave_alloc(struct scsi_device *sdev);
36static void bfad_im_fc_rport_add(struct bfad_im_port_s *im_port, 35static void bfad_im_fc_rport_add(struct bfad_im_port_s *im_port,
37 struct bfad_itnim_s *itnim); 36 struct bfad_itnim_s *itnim);
@@ -164,10 +163,10 @@ bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,
164 wake_up(wq); 163 wake_up(wq);
165} 164}
166 165
167/** 166/*
168 * Scsi_Host_template SCSI host template 167 * Scsi_Host_template SCSI host template
169 */ 168 */
170/** 169/*
171 * Scsi_Host template entry, returns BFAD PCI info. 170 * Scsi_Host template entry, returns BFAD PCI info.
172 */ 171 */
173static const char * 172static const char *
@@ -196,7 +195,7 @@ bfad_im_info(struct Scsi_Host *shost)
196 return bfa_buf; 195 return bfa_buf;
197} 196}
198 197
199/** 198/*
200 * Scsi_Host template entry, aborts the specified SCSI command. 199 * Scsi_Host template entry, aborts the specified SCSI command.
201 * 200 *
202 * Returns: SUCCESS or FAILED. 201 * Returns: SUCCESS or FAILED.
@@ -280,7 +279,7 @@ out:
280 return rc; 279 return rc;
281} 280}
282 281
283/** 282/*
284 * Scsi_Host template entry, resets a LUN and abort its all commands. 283 * Scsi_Host template entry, resets a LUN and abort its all commands.
285 * 284 *
286 * Returns: SUCCESS or FAILED. 285 * Returns: SUCCESS or FAILED.
@@ -319,7 +318,7 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
319 goto out; 318 goto out;
320 } 319 }
321 320
322 /** 321 /*
323 * Set host_scribble to NULL to avoid aborting a task command 322 * Set host_scribble to NULL to avoid aborting a task command
324 * if happens. 323 * if happens.
325 */ 324 */
@@ -346,7 +345,7 @@ out:
346 return rc; 345 return rc;
347} 346}
348 347
349/** 348/*
350 * Scsi_Host template entry, resets the bus and abort all commands. 349 * Scsi_Host template entry, resets the bus and abort all commands.
351 */ 350 */
352static int 351static int
@@ -396,7 +395,7 @@ bfad_im_reset_bus_handler(struct scsi_cmnd *cmnd)
396 return SUCCESS; 395 return SUCCESS;
397} 396}
398 397
399/** 398/*
400 * Scsi_Host template entry slave_destroy. 399 * Scsi_Host template entry slave_destroy.
401 */ 400 */
402static void 401static void
@@ -406,11 +405,11 @@ bfad_im_slave_destroy(struct scsi_device *sdev)
406 return; 405 return;
407} 406}
408 407
409/** 408/*
410 * BFA FCS itnim callbacks 409 * BFA FCS itnim callbacks
411 */ 410 */
412 411
413/** 412/*
414 * BFA FCS itnim alloc callback, after successful PRLI 413 * BFA FCS itnim alloc callback, after successful PRLI
415 * Context: Interrupt 414 * Context: Interrupt
416 */ 415 */
@@ -433,7 +432,7 @@ bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
433 bfad->bfad_flags |= BFAD_RPORT_ONLINE; 432 bfad->bfad_flags |= BFAD_RPORT_ONLINE;
434} 433}
435 434
436/** 435/*
437 * BFA FCS itnim free callback. 436 * BFA FCS itnim free callback.
438 * Context: Interrupt. bfad_lock is held 437 * Context: Interrupt. bfad_lock is held
439 */ 438 */
@@ -471,7 +470,7 @@ bfa_fcb_itnim_free(struct bfad_s *bfad, struct bfad_itnim_s *itnim_drv)
471 queue_work(im->drv_workq, &itnim_drv->itnim_work); 470 queue_work(im->drv_workq, &itnim_drv->itnim_work);
472} 471}
473 472
474/** 473/*
475 * BFA FCS itnim online callback. 474 * BFA FCS itnim online callback.
476 * Context: Interrupt. bfad_lock is held 475 * Context: Interrupt. bfad_lock is held
477 */ 476 */
@@ -492,7 +491,7 @@ bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv)
492 queue_work(im->drv_workq, &itnim_drv->itnim_work); 491 queue_work(im->drv_workq, &itnim_drv->itnim_work);
493} 492}
494 493
495/** 494/*
496 * BFA FCS itnim offline callback. 495 * BFA FCS itnim offline callback.
497 * Context: Interrupt. bfad_lock is held 496 * Context: Interrupt. bfad_lock is held
498 */ 497 */
@@ -519,7 +518,7 @@ bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv)
519 queue_work(im->drv_workq, &itnim_drv->itnim_work); 518 queue_work(im->drv_workq, &itnim_drv->itnim_work);
520} 519}
521 520
522/** 521/*
523 * Allocate a Scsi_Host for a port. 522 * Allocate a Scsi_Host for a port.
524 */ 523 */
525int 524int
@@ -751,7 +750,7 @@ bfad_os_thread_workq(struct bfad_s *bfad)
751 return BFA_STATUS_OK; 750 return BFA_STATUS_OK;
752} 751}
753 752
754/** 753/*
755 * Scsi_Host template entry. 754 * Scsi_Host template entry.
756 * 755 *
757 * Description: 756 * Description:
@@ -896,7 +895,7 @@ bfad_os_get_itnim(struct bfad_im_port_s *im_port, int id)
896 return NULL; 895 return NULL;
897} 896}
898 897
899/** 898/*
900 * Scsi_Host template entry slave_alloc 899 * Scsi_Host template entry slave_alloc
901 */ 900 */
902static int 901static int
@@ -915,12 +914,16 @@ bfad_im_slave_alloc(struct scsi_device *sdev)
915static u32 914static u32
916bfad_im_supported_speeds(struct bfa_s *bfa) 915bfad_im_supported_speeds(struct bfa_s *bfa)
917{ 916{
918 struct bfa_ioc_attr_s ioc_attr; 917 struct bfa_ioc_attr_s *ioc_attr;
919 u32 supported_speed = 0; 918 u32 supported_speed = 0;
920 919
921 bfa_get_attr(bfa, &ioc_attr); 920 ioc_attr = kzalloc(sizeof(struct bfa_ioc_attr_s), GFP_KERNEL);
922 if (ioc_attr.adapter_attr.max_speed == BFA_PORT_SPEED_8GBPS) { 921 if (!ioc_attr)
923 if (ioc_attr.adapter_attr.is_mezz) { 922 return 0;
923
924 bfa_get_attr(bfa, ioc_attr);
925 if (ioc_attr->adapter_attr.max_speed == BFA_PORT_SPEED_8GBPS) {
926 if (ioc_attr->adapter_attr.is_mezz) {
924 supported_speed |= FC_PORTSPEED_8GBIT | 927 supported_speed |= FC_PORTSPEED_8GBIT |
925 FC_PORTSPEED_4GBIT | 928 FC_PORTSPEED_4GBIT |
926 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT; 929 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
@@ -929,12 +932,13 @@ bfad_im_supported_speeds(struct bfa_s *bfa)
929 FC_PORTSPEED_4GBIT | 932 FC_PORTSPEED_4GBIT |
930 FC_PORTSPEED_2GBIT; 933 FC_PORTSPEED_2GBIT;
931 } 934 }
932 } else if (ioc_attr.adapter_attr.max_speed == BFA_PORT_SPEED_4GBPS) { 935 } else if (ioc_attr->adapter_attr.max_speed == BFA_PORT_SPEED_4GBPS) {
933 supported_speed |= FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT | 936 supported_speed |= FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT |
934 FC_PORTSPEED_1GBIT; 937 FC_PORTSPEED_1GBIT;
935 } else if (ioc_attr.adapter_attr.max_speed == BFA_PORT_SPEED_10GBPS) { 938 } else if (ioc_attr->adapter_attr.max_speed == BFA_PORT_SPEED_10GBPS) {
936 supported_speed |= FC_PORTSPEED_10GBIT; 939 supported_speed |= FC_PORTSPEED_10GBIT;
937 } 940 }
941 kfree(ioc_attr);
938 return supported_speed; 942 return supported_speed;
939} 943}
940 944
@@ -944,14 +948,13 @@ bfad_os_fc_host_init(struct bfad_im_port_s *im_port)
944 struct Scsi_Host *host = im_port->shost; 948 struct Scsi_Host *host = im_port->shost;
945 struct bfad_s *bfad = im_port->bfad; 949 struct bfad_s *bfad = im_port->bfad;
946 struct bfad_port_s *port = im_port->port; 950 struct bfad_port_s *port = im_port->port;
947 struct bfa_port_attr_s pattr;
948 struct bfa_lport_attr_s port_attr;
949 char symname[BFA_SYMNAME_MAXLEN]; 951 char symname[BFA_SYMNAME_MAXLEN];
952 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa);
950 953
951 fc_host_node_name(host) = 954 fc_host_node_name(host) =
952 bfa_os_htonll((bfa_fcs_lport_get_nwwn(port->fcs_port))); 955 cpu_to_be64((bfa_fcs_lport_get_nwwn(port->fcs_port)));
953 fc_host_port_name(host) = 956 fc_host_port_name(host) =
954 bfa_os_htonll((bfa_fcs_lport_get_pwwn(port->fcs_port))); 957 cpu_to_be64((bfa_fcs_lport_get_pwwn(port->fcs_port)));
955 fc_host_max_npiv_vports(host) = bfa_lps_get_max_vport(&bfad->bfa); 958 fc_host_max_npiv_vports(host) = bfa_lps_get_max_vport(&bfad->bfa);
956 959
957 fc_host_supported_classes(host) = FC_COS_CLASS3; 960 fc_host_supported_classes(host) = FC_COS_CLASS3;
@@ -964,15 +967,12 @@ bfad_os_fc_host_init(struct bfad_im_port_s *im_port)
964 /* For fibre channel services type 0x20 */ 967 /* For fibre channel services type 0x20 */
965 fc_host_supported_fc4s(host)[7] = 1; 968 fc_host_supported_fc4s(host)[7] = 1;
966 969
967 bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr); 970 strncpy(symname, bfad->bfa_fcs.fabric.bport.port_cfg.sym_name.symname,
968 strncpy(symname, port_attr.port_cfg.sym_name.symname,
969 BFA_SYMNAME_MAXLEN); 971 BFA_SYMNAME_MAXLEN);
970 sprintf(fc_host_symbolic_name(host), "%s", symname); 972 sprintf(fc_host_symbolic_name(host), "%s", symname);
971 973
972 fc_host_supported_speeds(host) = bfad_im_supported_speeds(&bfad->bfa); 974 fc_host_supported_speeds(host) = bfad_im_supported_speeds(&bfad->bfa);
973 975 fc_host_maxframe_size(host) = fcport->cfg.maxfrsize;
974 bfa_fcport_get_attr(&bfad->bfa, &pattr);
975 fc_host_maxframe_size(host) = pattr.pport_cfg.maxfrsize;
976} 976}
977 977
978static void 978static void
@@ -983,9 +983,9 @@ bfad_im_fc_rport_add(struct bfad_im_port_s *im_port, struct bfad_itnim_s *itnim)
983 struct bfad_itnim_data_s *itnim_data; 983 struct bfad_itnim_data_s *itnim_data;
984 984
985 rport_ids.node_name = 985 rport_ids.node_name =
986 bfa_os_htonll(bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim)); 986 cpu_to_be64(bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim));
987 rport_ids.port_name = 987 rport_ids.port_name =
988 bfa_os_htonll(bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim)); 988 cpu_to_be64(bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim));
989 rport_ids.port_id = 989 rport_ids.port_id =
990 bfa_os_hton3b(bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim)); 990 bfa_os_hton3b(bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim));
991 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 991 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
@@ -1015,7 +1015,7 @@ bfad_im_fc_rport_add(struct bfad_im_port_s *im_port, struct bfad_itnim_s *itnim)
1015 return; 1015 return;
1016} 1016}
1017 1017
1018/** 1018/*
1019 * Work queue handler using FC transport service 1019 * Work queue handler using FC transport service
1020* Context: kernel 1020* Context: kernel
1021 */ 1021 */
@@ -1115,11 +1115,11 @@ bfad_im_itnim_work_handler(struct work_struct *work)
1115 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 1115 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1116} 1116}
1117 1117
1118/** 1118/*
1119 * Scsi_Host template entry, queue a SCSI command to the BFAD. 1119 * Scsi_Host template entry, queue a SCSI command to the BFAD.
1120 */ 1120 */
1121static int 1121static int
1122bfad_im_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) 1122bfad_im_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
1123{ 1123{
1124 struct bfad_im_port_s *im_port = 1124 struct bfad_im_port_s *im_port =
1125 (struct bfad_im_port_s *) cmnd->device->host->hostdata[0]; 1125 (struct bfad_im_port_s *) cmnd->device->host->hostdata[0];
@@ -1186,6 +1186,8 @@ out_fail_cmd:
1186 return 0; 1186 return 0;
1187} 1187}
1188 1188
1189static DEF_SCSI_QCMD(bfad_im_queuecommand)
1190
1189void 1191void
1190bfad_os_rport_online_wait(struct bfad_s *bfad) 1192bfad_os_rport_online_wait(struct bfad_s *bfad)
1191{ 1193{