aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa/bfad_attr.c
diff options
context:
space:
mode:
authorKrishna Gudipati <kgudipat@brocade.com>2010-09-15 14:50:55 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-09-16 22:54:24 -0400
commita36c61f9025b8924f99f54d518763bee7aa84085 (patch)
treee1d58c382ad31fe1ad3c5f6bccde1b9df1d9fd8c /drivers/scsi/bfa/bfad_attr.c
parentedaed859e63aac174fcc3fed81886b91bb124661 (diff)
[SCSI] bfa: cleanup driver
We have flattened the BFA hierarchy and also reduced the number of source and header files we used to have earlier. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/bfa/bfad_attr.c')
-rw-r--r--drivers/scsi/bfa/bfad_attr.c241
1 files changed, 145 insertions, 96 deletions
diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c
index 0818eb07ef88..d8843720eac1 100644
--- a/drivers/scsi/bfa/bfad_attr.c
+++ b/drivers/scsi/bfa/bfad_attr.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -19,15 +19,8 @@
19 * bfa_attr.c Linux driver configuration interface module. 19 * bfa_attr.c Linux driver configuration interface module.
20 */ 20 */
21 21
22#include <linux/slab.h>
23#include "bfad_drv.h" 22#include "bfad_drv.h"
24#include "bfad_im.h" 23#include "bfad_im.h"
25#include "bfad_trcmod.h"
26#include "bfad_attr.h"
27
28/**
29 * FC_transport_template FC transport template
30 */
31 24
32/** 25/**
33 * FC transport template entry, get SCSI target port ID. 26 * FC transport template entry, get SCSI target port ID.
@@ -42,7 +35,7 @@ bfad_im_get_starget_port_id(struct scsi_target *starget)
42 u32 fc_id = -1; 35 u32 fc_id = -1;
43 unsigned long flags; 36 unsigned long flags;
44 37
45 shost = bfad_os_starget_to_shost(starget); 38 shost = dev_to_shost(starget->dev.parent);
46 im_port = (struct bfad_im_port_s *) shost->hostdata[0]; 39 im_port = (struct bfad_im_port_s *) shost->hostdata[0];
47 bfad = im_port->bfad; 40 bfad = im_port->bfad;
48 spin_lock_irqsave(&bfad->bfad_lock, flags); 41 spin_lock_irqsave(&bfad->bfad_lock, flags);
@@ -68,7 +61,7 @@ bfad_im_get_starget_node_name(struct scsi_target *starget)
68 u64 node_name = 0; 61 u64 node_name = 0;
69 unsigned long flags; 62 unsigned long flags;
70 63
71 shost = bfad_os_starget_to_shost(starget); 64 shost = dev_to_shost(starget->dev.parent);
72 im_port = (struct bfad_im_port_s *) shost->hostdata[0]; 65 im_port = (struct bfad_im_port_s *) shost->hostdata[0];
73 bfad = im_port->bfad; 66 bfad = im_port->bfad;
74 spin_lock_irqsave(&bfad->bfad_lock, flags); 67 spin_lock_irqsave(&bfad->bfad_lock, flags);
@@ -94,7 +87,7 @@ bfad_im_get_starget_port_name(struct scsi_target *starget)
94 u64 port_name = 0; 87 u64 port_name = 0;
95 unsigned long flags; 88 unsigned long flags;
96 89
97 shost = bfad_os_starget_to_shost(starget); 90 shost = dev_to_shost(starget->dev.parent);
98 im_port = (struct bfad_im_port_s *) shost->hostdata[0]; 91 im_port = (struct bfad_im_port_s *) shost->hostdata[0];
99 bfad = im_port->bfad; 92 bfad = im_port->bfad;
100 spin_lock_irqsave(&bfad->bfad_lock, flags); 93 spin_lock_irqsave(&bfad->bfad_lock, flags);
@@ -118,17 +111,7 @@ bfad_im_get_host_port_id(struct Scsi_Host *shost)
118 struct bfad_port_s *port = im_port->port; 111 struct bfad_port_s *port = im_port->port;
119 112
120 fc_host_port_id(shost) = 113 fc_host_port_id(shost) =
121 bfa_os_hton3b(bfa_fcs_port_get_fcid(port->fcs_port)); 114 bfa_os_hton3b(bfa_fcs_lport_get_fcid(port->fcs_port));
122}
123
124
125
126
127
128struct Scsi_Host *
129bfad_os_starget_to_shost(struct scsi_target *starget)
130{
131 return dev_to_shost(starget->dev.parent);
132} 115}
133 116
134/** 117/**
@@ -140,21 +123,21 @@ bfad_im_get_host_port_type(struct Scsi_Host *shost)
140 struct bfad_im_port_s *im_port = 123 struct bfad_im_port_s *im_port =
141 (struct bfad_im_port_s *) shost->hostdata[0]; 124 (struct bfad_im_port_s *) shost->hostdata[0];
142 struct bfad_s *bfad = im_port->bfad; 125 struct bfad_s *bfad = im_port->bfad;
143 struct bfa_pport_attr_s attr; 126 struct bfa_lport_attr_s port_attr;
144 127
145 bfa_fcport_get_attr(&bfad->bfa, &attr); 128 bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
146 129
147 switch (attr.port_type) { 130 switch (port_attr.port_type) {
148 case BFA_PPORT_TYPE_NPORT: 131 case BFA_PORT_TYPE_NPORT:
149 fc_host_port_type(shost) = FC_PORTTYPE_NPORT; 132 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
150 break; 133 break;
151 case BFA_PPORT_TYPE_NLPORT: 134 case BFA_PORT_TYPE_NLPORT:
152 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; 135 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
153 break; 136 break;
154 case BFA_PPORT_TYPE_P2P: 137 case BFA_PORT_TYPE_P2P:
155 fc_host_port_type(shost) = FC_PORTTYPE_PTP; 138 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
156 break; 139 break;
157 case BFA_PPORT_TYPE_LPORT: 140 case BFA_PORT_TYPE_LPORT:
158 fc_host_port_type(shost) = FC_PORTTYPE_LPORT; 141 fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
159 break; 142 break;
160 default: 143 default:
@@ -172,25 +155,28 @@ bfad_im_get_host_port_state(struct Scsi_Host *shost)
172 struct bfad_im_port_s *im_port = 155 struct bfad_im_port_s *im_port =
173 (struct bfad_im_port_s *) shost->hostdata[0]; 156 (struct bfad_im_port_s *) shost->hostdata[0];
174 struct bfad_s *bfad = im_port->bfad; 157 struct bfad_s *bfad = im_port->bfad;
175 struct bfa_pport_attr_s attr; 158 struct bfa_port_attr_s attr;
176 159
177 bfa_fcport_get_attr(&bfad->bfa, &attr); 160 bfa_fcport_get_attr(&bfad->bfa, &attr);
178 161
179 switch (attr.port_state) { 162 switch (attr.port_state) {
180 case BFA_PPORT_ST_LINKDOWN: 163 case BFA_PORT_ST_LINKDOWN:
181 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; 164 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
182 break; 165 break;
183 case BFA_PPORT_ST_LINKUP: 166 case BFA_PORT_ST_LINKUP:
184 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; 167 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
185 break; 168 break;
186 case BFA_PPORT_ST_UNINIT: 169 case BFA_PORT_ST_DISABLED:
187 case BFA_PPORT_ST_ENABLING_QWAIT: 170 case BFA_PORT_ST_STOPPED:
188 case BFA_PPORT_ST_ENABLING: 171 case BFA_PORT_ST_IOCDOWN:
189 case BFA_PPORT_ST_DISABLING_QWAIT: 172 case BFA_PORT_ST_IOCDIS:
190 case BFA_PPORT_ST_DISABLING: 173 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
191 case BFA_PPORT_ST_DISABLED: 174 break;
192 case BFA_PPORT_ST_STOPPED: 175 case BFA_PORT_ST_UNINIT:
193 case BFA_PPORT_ST_IOCDOWN: 176 case BFA_PORT_ST_ENABLING_QWAIT:
177 case BFA_PORT_ST_ENABLING:
178 case BFA_PORT_ST_DISABLING_QWAIT:
179 case BFA_PORT_ST_DISABLING:
194 default: 180 default:
195 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; 181 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
196 break; 182 break;
@@ -210,13 +196,9 @@ bfad_im_get_host_active_fc4s(struct Scsi_Host *shost)
210 memset(fc_host_active_fc4s(shost), 0, 196 memset(fc_host_active_fc4s(shost), 0,
211 sizeof(fc_host_active_fc4s(shost))); 197 sizeof(fc_host_active_fc4s(shost)));
212 198
213 if (port->supported_fc4s & 199 if (port->supported_fc4s & BFA_LPORT_ROLE_FCP_IM)
214 (BFA_PORT_ROLE_FCP_IM | BFA_PORT_ROLE_FCP_TM))
215 fc_host_active_fc4s(shost)[2] = 1; 200 fc_host_active_fc4s(shost)[2] = 1;
216 201
217 if (port->supported_fc4s & BFA_PORT_ROLE_FCP_IPFC)
218 fc_host_active_fc4s(shost)[3] = 0x20;
219
220 fc_host_active_fc4s(shost)[7] = 1; 202 fc_host_active_fc4s(shost)[7] = 1;
221} 203}
222 204
@@ -229,29 +211,29 @@ bfad_im_get_host_speed(struct Scsi_Host *shost)
229 struct bfad_im_port_s *im_port = 211 struct bfad_im_port_s *im_port =
230 (struct bfad_im_port_s *) shost->hostdata[0]; 212 (struct bfad_im_port_s *) shost->hostdata[0];
231 struct bfad_s *bfad = im_port->bfad; 213 struct bfad_s *bfad = im_port->bfad;
232 struct bfa_pport_attr_s attr; 214 struct bfa_port_attr_s attr;
233 unsigned long flags;
234 215
235 spin_lock_irqsave(shost->host_lock, flags);
236 bfa_fcport_get_attr(&bfad->bfa, &attr); 216 bfa_fcport_get_attr(&bfad->bfa, &attr);
237 switch (attr.speed) { 217 switch (attr.speed) {
238 case BFA_PPORT_SPEED_8GBPS: 218 case BFA_PORT_SPEED_10GBPS:
219 fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
220 break;
221 case BFA_PORT_SPEED_8GBPS:
239 fc_host_speed(shost) = FC_PORTSPEED_8GBIT; 222 fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
240 break; 223 break;
241 case BFA_PPORT_SPEED_4GBPS: 224 case BFA_PORT_SPEED_4GBPS:
242 fc_host_speed(shost) = FC_PORTSPEED_4GBIT; 225 fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
243 break; 226 break;
244 case BFA_PPORT_SPEED_2GBPS: 227 case BFA_PORT_SPEED_2GBPS:
245 fc_host_speed(shost) = FC_PORTSPEED_2GBIT; 228 fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
246 break; 229 break;
247 case BFA_PPORT_SPEED_1GBPS: 230 case BFA_PORT_SPEED_1GBPS:
248 fc_host_speed(shost) = FC_PORTSPEED_1GBIT; 231 fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
249 break; 232 break;
250 default: 233 default:
251 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; 234 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
252 break; 235 break;
253 } 236 }
254 spin_unlock_irqrestore(shost->host_lock, flags);
255} 237}
256 238
257/** 239/**
@@ -265,7 +247,7 @@ bfad_im_get_host_fabric_name(struct Scsi_Host *shost)
265 struct bfad_port_s *port = im_port->port; 247 struct bfad_port_s *port = im_port->port;
266 wwn_t fabric_nwwn = 0; 248 wwn_t fabric_nwwn = 0;
267 249
268 fabric_nwwn = bfa_fcs_port_get_fabric_name(port->fcs_port); 250 fabric_nwwn = bfa_fcs_lport_get_fabric_name(port->fcs_port);
269 251
270 fc_host_fabric_name(shost) = bfa_os_htonll(fabric_nwwn); 252 fc_host_fabric_name(shost) = bfa_os_htonll(fabric_nwwn);
271 253
@@ -281,23 +263,44 @@ bfad_im_get_stats(struct Scsi_Host *shost)
281 (struct bfad_im_port_s *) shost->hostdata[0]; 263 (struct bfad_im_port_s *) shost->hostdata[0];
282 struct bfad_s *bfad = im_port->bfad; 264 struct bfad_s *bfad = im_port->bfad;
283 struct bfad_hal_comp fcomp; 265 struct bfad_hal_comp fcomp;
266 union bfa_port_stats_u *fcstats;
284 struct fc_host_statistics *hstats; 267 struct fc_host_statistics *hstats;
285 bfa_status_t rc; 268 bfa_status_t rc;
286 unsigned long flags; 269 unsigned long flags;
287 270
271 fcstats = kzalloc(sizeof(union bfa_port_stats_u), GFP_KERNEL);
272 if (fcstats == NULL)
273 return NULL;
274
288 hstats = &bfad->link_stats; 275 hstats = &bfad->link_stats;
289 init_completion(&fcomp.comp); 276 init_completion(&fcomp.comp);
290 spin_lock_irqsave(&bfad->bfad_lock, flags); 277 spin_lock_irqsave(&bfad->bfad_lock, flags);
291 memset(hstats, 0, sizeof(struct fc_host_statistics)); 278 memset(hstats, 0, sizeof(struct fc_host_statistics));
292 rc = bfa_port_get_stats(BFA_FCPORT(&bfad->bfa), 279 rc = bfa_port_get_stats(BFA_FCPORT(&bfad->bfa),
293 (union bfa_pport_stats_u *) hstats, 280 fcstats, bfad_hcb_comp, &fcomp);
294 bfad_hcb_comp, &fcomp);
295 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 281 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
296 if (rc != BFA_STATUS_OK) 282 if (rc != BFA_STATUS_OK)
297 return NULL; 283 return NULL;
298 284
299 wait_for_completion(&fcomp.comp); 285 wait_for_completion(&fcomp.comp);
300 286
287 /* Fill the fc_host_statistics structure */
288 hstats->seconds_since_last_reset = fcstats->fc.secs_reset;
289 hstats->tx_frames = fcstats->fc.tx_frames;
290 hstats->tx_words = fcstats->fc.tx_words;
291 hstats->rx_frames = fcstats->fc.rx_frames;
292 hstats->rx_words = fcstats->fc.rx_words;
293 hstats->lip_count = fcstats->fc.lip_count;
294 hstats->nos_count = fcstats->fc.nos_count;
295 hstats->error_frames = fcstats->fc.error_frames;
296 hstats->dumped_frames = fcstats->fc.dropped_frames;
297 hstats->link_failure_count = fcstats->fc.link_failures;
298 hstats->loss_of_sync_count = fcstats->fc.loss_of_syncs;
299 hstats->loss_of_signal_count = fcstats->fc.loss_of_signals;
300 hstats->prim_seq_protocol_err_count = fcstats->fc.primseq_errs;
301 hstats->invalid_crc_count = fcstats->fc.invalid_crcs;
302
303 kfree(fcstats);
301 return hstats; 304 return hstats;
302} 305}
303 306
@@ -317,7 +320,7 @@ bfad_im_reset_stats(struct Scsi_Host *shost)
317 init_completion(&fcomp.comp); 320 init_completion(&fcomp.comp);
318 spin_lock_irqsave(&bfad->bfad_lock, flags); 321 spin_lock_irqsave(&bfad->bfad_lock, flags);
319 rc = bfa_port_clear_stats(BFA_FCPORT(&bfad->bfa), bfad_hcb_comp, 322 rc = bfa_port_clear_stats(BFA_FCPORT(&bfad->bfa), bfad_hcb_comp,
320 &fcomp); 323 &fcomp);
321 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 324 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
322 325
323 if (rc != BFA_STATUS_OK) 326 if (rc != BFA_STATUS_OK)
@@ -372,8 +375,8 @@ bfad_im_vport_create(struct fc_vport *fc_vport, bool disable)
372 struct bfad_im_port_s *im_port = 375 struct bfad_im_port_s *im_port =
373 (struct bfad_im_port_s *) shost->hostdata[0]; 376 (struct bfad_im_port_s *) shost->hostdata[0];
374 struct bfad_s *bfad = im_port->bfad; 377 struct bfad_s *bfad = im_port->bfad;
375 struct bfa_port_cfg_s port_cfg; 378 struct bfa_lport_cfg_s port_cfg;
376 struct bfad_pcfg_s *pcfg; 379 struct bfad_vport_s *vp;
377 int status = 0, rc; 380 int status = 0, rc;
378 unsigned long flags; 381 unsigned long flags;
379 382
@@ -382,12 +385,14 @@ bfad_im_vport_create(struct fc_vport *fc_vport, bool disable)
382 u64_to_wwn(fc_vport->port_name, (u8 *)&port_cfg.pwwn); 385 u64_to_wwn(fc_vport->port_name, (u8 *)&port_cfg.pwwn);
383 if (strlen(vname) > 0) 386 if (strlen(vname) > 0)
384 strcpy((char *)&port_cfg.sym_name, vname); 387 strcpy((char *)&port_cfg.sym_name, vname);
385 port_cfg.roles = BFA_PORT_ROLE_FCP_IM; 388 port_cfg.roles = BFA_LPORT_ROLE_FCP_IM;
386 389
387 spin_lock_irqsave(&bfad->bfad_lock, flags); 390 spin_lock_irqsave(&bfad->bfad_lock, flags);
388 list_for_each_entry(pcfg, &bfad->pbc_pcfg_list, list_entry) { 391 list_for_each_entry(vp, &bfad->pbc_vport_list, list_entry) {
389 if (port_cfg.pwwn == pcfg->port_cfg.pwwn) { 392 if (port_cfg.pwwn ==
390 port_cfg.preboot_vp = pcfg->port_cfg.preboot_vp; 393 vp->fcs_vport.lport.port_cfg.pwwn) {
394 port_cfg.preboot_vp =
395 vp->fcs_vport.lport.port_cfg.preboot_vp;
391 break; 396 break;
392 } 397 }
393 } 398 }
@@ -638,7 +643,7 @@ bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr,
638 struct Scsi_Host *shost = class_to_shost(dev); 643 struct Scsi_Host *shost = class_to_shost(dev);
639 struct bfad_im_port_s *im_port = 644 struct bfad_im_port_s *im_port =
640 (struct bfad_im_port_s *) shost->hostdata[0]; 645 (struct bfad_im_port_s *) shost->hostdata[0];
641 struct bfad_s *bfad = im_port->bfad; 646 struct bfad_s *bfad = im_port->bfad;
642 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN]; 647 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
643 648
644 bfa_get_adapter_serial_num(&bfad->bfa, serial_num); 649 bfa_get_adapter_serial_num(&bfad->bfa, serial_num);
@@ -652,7 +657,7 @@ bfad_im_model_show(struct device *dev, struct device_attribute *attr,
652 struct Scsi_Host *shost = class_to_shost(dev); 657 struct Scsi_Host *shost = class_to_shost(dev);
653 struct bfad_im_port_s *im_port = 658 struct bfad_im_port_s *im_port =
654 (struct bfad_im_port_s *) shost->hostdata[0]; 659 (struct bfad_im_port_s *) shost->hostdata[0];
655 struct bfad_s *bfad = im_port->bfad; 660 struct bfad_s *bfad = im_port->bfad;
656 char model[BFA_ADAPTER_MODEL_NAME_LEN]; 661 char model[BFA_ADAPTER_MODEL_NAME_LEN];
657 662
658 bfa_get_adapter_model(&bfad->bfa, model); 663 bfa_get_adapter_model(&bfad->bfa, model);
@@ -666,10 +671,54 @@ bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr,
666 struct Scsi_Host *shost = class_to_shost(dev); 671 struct Scsi_Host *shost = class_to_shost(dev);
667 struct bfad_im_port_s *im_port = 672 struct bfad_im_port_s *im_port =
668 (struct bfad_im_port_s *) shost->hostdata[0]; 673 (struct bfad_im_port_s *) shost->hostdata[0];
669 struct bfad_s *bfad = im_port->bfad; 674 struct bfad_s *bfad = im_port->bfad;
675 char model[BFA_ADAPTER_MODEL_NAME_LEN];
670 char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN]; 676 char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
671 677
672 bfa_get_adapter_model(&bfad->bfa, model_descr); 678 bfa_get_adapter_model(&bfad->bfa, model);
679 if (!strcmp(model, "Brocade-425"))
680 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
681 "Brocade 4Gbps PCIe dual port FC HBA");
682 else if (!strcmp(model, "Brocade-825"))
683 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
684 "Brocade 8Gbps PCIe dual port FC HBA");
685 else if (!strcmp(model, "Brocade-42B"))
686 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
687 "HP 4Gbps PCIe dual port FC HBA");
688 else if (!strcmp(model, "Brocade-82B"))
689 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
690 "HP 8Gbps PCIe dual port FC HBA");
691 else if (!strcmp(model, "Brocade-1010"))
692 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
693 "Brocade 10Gbps single port CNA");
694 else if (!strcmp(model, "Brocade-1020"))
695 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
696 "Brocade 10Gbps dual port CNA");
697 else if (!strcmp(model, "Brocade-1007"))
698 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
699 "Brocade 10Gbps CNA");
700 else if (!strcmp(model, "Brocade-415"))
701 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
702 "Brocade 4Gbps PCIe single port FC HBA");
703 else if (!strcmp(model, "Brocade-815"))
704 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
705 "Brocade 8Gbps PCIe single port FC HBA");
706 else if (!strcmp(model, "Brocade-41B"))
707 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
708 "HP 4Gbps PCIe single port FC HBA");
709 else if (!strcmp(model, "Brocade-81B"))
710 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
711 "HP 8Gbps PCIe single port FC HBA");
712 else if (!strcmp(model, "Brocade-804"))
713 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
714 "HP Bladesystem C-class 8Gbps FC HBA");
715 else if (!strcmp(model, "Brocade-902"))
716 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
717 "Brocade 10Gbps CNA");
718 else
719 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
720 "Invalid Model");
721
673 return snprintf(buf, PAGE_SIZE, "%s\n", model_descr); 722 return snprintf(buf, PAGE_SIZE, "%s\n", model_descr);
674} 723}
675 724
@@ -683,7 +732,7 @@ bfad_im_node_name_show(struct device *dev, struct device_attribute *attr,
683 struct bfad_port_s *port = im_port->port; 732 struct bfad_port_s *port = im_port->port;
684 u64 nwwn; 733 u64 nwwn;
685 734
686 nwwn = bfa_fcs_port_get_nwwn(port->fcs_port); 735 nwwn = bfa_fcs_lport_get_nwwn(port->fcs_port);
687 return snprintf(buf, PAGE_SIZE, "0x%llx\n", bfa_os_htonll(nwwn)); 736 return snprintf(buf, PAGE_SIZE, "0x%llx\n", bfa_os_htonll(nwwn));
688} 737}
689 738
@@ -694,14 +743,14 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,
694 struct Scsi_Host *shost = class_to_shost(dev); 743 struct Scsi_Host *shost = class_to_shost(dev);
695 struct bfad_im_port_s *im_port = 744 struct bfad_im_port_s *im_port =
696 (struct bfad_im_port_s *) shost->hostdata[0]; 745 (struct bfad_im_port_s *) shost->hostdata[0];
697 struct bfad_s *bfad = im_port->bfad; 746 struct bfad_s *bfad = im_port->bfad;
698 char model[BFA_ADAPTER_MODEL_NAME_LEN]; 747 struct bfa_lport_attr_s port_attr;
699 char fw_ver[BFA_VERSION_LEN]; 748 char symname[BFA_SYMNAME_MAXLEN];
700 749
701 bfa_get_adapter_model(&bfad->bfa, model); 750 bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
702 bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver); 751 strncpy(symname, port_attr.port_cfg.sym_name.symname,
703 return snprintf(buf, PAGE_SIZE, "Brocade %s FV%s DV%s\n", 752 BFA_SYMNAME_MAXLEN);
704 model, fw_ver, BFAD_DRIVER_VERSION); 753 return snprintf(buf, PAGE_SIZE, "%s\n", symname);
705} 754}
706 755
707static ssize_t 756static ssize_t
@@ -711,7 +760,7 @@ bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,
711 struct Scsi_Host *shost = class_to_shost(dev); 760 struct Scsi_Host *shost = class_to_shost(dev);
712 struct bfad_im_port_s *im_port = 761 struct bfad_im_port_s *im_port =
713 (struct bfad_im_port_s *) shost->hostdata[0]; 762 (struct bfad_im_port_s *) shost->hostdata[0];
714 struct bfad_s *bfad = im_port->bfad; 763 struct bfad_s *bfad = im_port->bfad;
715 char hw_ver[BFA_VERSION_LEN]; 764 char hw_ver[BFA_VERSION_LEN];
716 765
717 bfa_get_pci_chip_rev(&bfad->bfa, hw_ver); 766 bfa_get_pci_chip_rev(&bfad->bfa, hw_ver);
@@ -732,7 +781,7 @@ bfad_im_optionrom_version_show(struct device *dev,
732 struct Scsi_Host *shost = class_to_shost(dev); 781 struct Scsi_Host *shost = class_to_shost(dev);
733 struct bfad_im_port_s *im_port = 782 struct bfad_im_port_s *im_port =
734 (struct bfad_im_port_s *) shost->hostdata[0]; 783 (struct bfad_im_port_s *) shost->hostdata[0];
735 struct bfad_s *bfad = im_port->bfad; 784 struct bfad_s *bfad = im_port->bfad;
736 char optrom_ver[BFA_VERSION_LEN]; 785 char optrom_ver[BFA_VERSION_LEN];
737 786
738 bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver); 787 bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver);
@@ -746,7 +795,7 @@ bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr,
746 struct Scsi_Host *shost = class_to_shost(dev); 795 struct Scsi_Host *shost = class_to_shost(dev);
747 struct bfad_im_port_s *im_port = 796 struct bfad_im_port_s *im_port =
748 (struct bfad_im_port_s *) shost->hostdata[0]; 797 (struct bfad_im_port_s *) shost->hostdata[0];
749 struct bfad_s *bfad = im_port->bfad; 798 struct bfad_s *bfad = im_port->bfad;
750 char fw_ver[BFA_VERSION_LEN]; 799 char fw_ver[BFA_VERSION_LEN];
751 800
752 bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver); 801 bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver);
@@ -760,10 +809,10 @@ bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr,
760 struct Scsi_Host *shost = class_to_shost(dev); 809 struct Scsi_Host *shost = class_to_shost(dev);
761 struct bfad_im_port_s *im_port = 810 struct bfad_im_port_s *im_port =
762 (struct bfad_im_port_s *) shost->hostdata[0]; 811 (struct bfad_im_port_s *) shost->hostdata[0];
763 struct bfad_s *bfad = im_port->bfad; 812 struct bfad_s *bfad = im_port->bfad;
764 813
765 return snprintf(buf, PAGE_SIZE, "%d\n", 814 return snprintf(buf, PAGE_SIZE, "%d\n",
766 bfa_get_nports(&bfad->bfa)); 815 bfa_get_nports(&bfad->bfa));
767} 816}
768 817
769static ssize_t 818static ssize_t
@@ -788,10 +837,10 @@ bfad_im_num_of_discovered_ports_show(struct device *dev,
788 837
789 rports = kzalloc(sizeof(wwn_t) * nrports , GFP_ATOMIC); 838 rports = kzalloc(sizeof(wwn_t) * nrports , GFP_ATOMIC);
790 if (rports == NULL) 839 if (rports == NULL)
791 return -ENOMEM; 840 return snprintf(buf, PAGE_SIZE, "Failed\n");
792 841
793 spin_lock_irqsave(&bfad->bfad_lock, flags); 842 spin_lock_irqsave(&bfad->bfad_lock, flags);
794 bfa_fcs_port_get_rports(port->fcs_port, rports, &nrports); 843 bfa_fcs_lport_get_rports(port->fcs_port, rports, &nrports);
795 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 844 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
796 kfree(rports); 845 kfree(rports);
797 846
@@ -837,19 +886,19 @@ struct device_attribute *bfad_im_host_attrs[] = {
837}; 886};
838 887
839struct device_attribute *bfad_im_vport_attrs[] = { 888struct device_attribute *bfad_im_vport_attrs[] = {
840 &dev_attr_serial_number, 889 &dev_attr_serial_number,
841 &dev_attr_model, 890 &dev_attr_model,
842 &dev_attr_model_description, 891 &dev_attr_model_description,
843 &dev_attr_node_name, 892 &dev_attr_node_name,
844 &dev_attr_symbolic_name, 893 &dev_attr_symbolic_name,
845 &dev_attr_hardware_version, 894 &dev_attr_hardware_version,
846 &dev_attr_driver_version, 895 &dev_attr_driver_version,
847 &dev_attr_option_rom_version, 896 &dev_attr_option_rom_version,
848 &dev_attr_firmware_version, 897 &dev_attr_firmware_version,
849 &dev_attr_number_of_ports, 898 &dev_attr_number_of_ports,
850 &dev_attr_driver_name, 899 &dev_attr_driver_name,
851 &dev_attr_number_of_discovered_ports, 900 &dev_attr_number_of_discovered_ports,
852 NULL, 901 NULL,
853}; 902};
854 903
855 904