xref: /openbmc/linux/drivers/scsi/bfa/bfad_attr.c (revision 973464fd)
152fa7bf9SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
27725ccfdSJing Huang /*
3889d0d42SAnil Gurumurthy  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
4889d0d42SAnil Gurumurthy  * Copyright (c) 2014- QLogic Corporation.
57725ccfdSJing Huang  * All rights reserved
6889d0d42SAnil Gurumurthy  * www.qlogic.com
77725ccfdSJing Huang  *
831e1d569SAnil Gurumurthy  * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
97725ccfdSJing Huang  */
107725ccfdSJing Huang 
115fbe25c7SJing Huang /*
127725ccfdSJing Huang  *  bfa_attr.c Linux driver configuration interface module.
137725ccfdSJing Huang  */
147725ccfdSJing Huang 
157725ccfdSJing Huang #include "bfad_drv.h"
167725ccfdSJing Huang #include "bfad_im.h"
177725ccfdSJing Huang 
185fbe25c7SJing Huang /*
197725ccfdSJing Huang  * FC transport template entry, get SCSI target port ID.
207725ccfdSJing Huang  */
2152f94b6fSMaggie static void
bfad_im_get_starget_port_id(struct scsi_target * starget)227725ccfdSJing Huang bfad_im_get_starget_port_id(struct scsi_target *starget)
237725ccfdSJing Huang {
247725ccfdSJing Huang 	struct Scsi_Host *shost;
257725ccfdSJing Huang 	struct bfad_im_port_s *im_port;
267725ccfdSJing Huang 	struct bfad_s         *bfad;
277725ccfdSJing Huang 	struct bfad_itnim_s   *itnim = NULL;
287725ccfdSJing Huang 	u32        fc_id = -1;
297725ccfdSJing Huang 	unsigned long   flags;
307725ccfdSJing Huang 
31a36c61f9SKrishna Gudipati 	shost = dev_to_shost(starget->dev.parent);
327725ccfdSJing Huang 	im_port = (struct bfad_im_port_s *) shost->hostdata[0];
337725ccfdSJing Huang 	bfad = im_port->bfad;
347725ccfdSJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
357725ccfdSJing Huang 
36f16a1750SMaggie Zhang 	itnim = bfad_get_itnim(im_port, starget->id);
377725ccfdSJing Huang 	if (itnim)
387725ccfdSJing Huang 		fc_id = bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim);
397725ccfdSJing Huang 
407725ccfdSJing Huang 	fc_starget_port_id(starget) = fc_id;
417725ccfdSJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
427725ccfdSJing Huang }
437725ccfdSJing Huang 
445fbe25c7SJing Huang /*
457725ccfdSJing Huang  * FC transport template entry, get SCSI target nwwn.
467725ccfdSJing Huang  */
4752f94b6fSMaggie static void
bfad_im_get_starget_node_name(struct scsi_target * starget)487725ccfdSJing Huang bfad_im_get_starget_node_name(struct scsi_target *starget)
497725ccfdSJing Huang {
507725ccfdSJing Huang 	struct Scsi_Host *shost;
517725ccfdSJing Huang 	struct bfad_im_port_s *im_port;
527725ccfdSJing Huang 	struct bfad_s         *bfad;
537725ccfdSJing Huang 	struct bfad_itnim_s   *itnim = NULL;
547725ccfdSJing Huang 	u64             node_name = 0;
557725ccfdSJing Huang 	unsigned long   flags;
567725ccfdSJing Huang 
57a36c61f9SKrishna Gudipati 	shost = dev_to_shost(starget->dev.parent);
587725ccfdSJing Huang 	im_port = (struct bfad_im_port_s *) shost->hostdata[0];
597725ccfdSJing Huang 	bfad = im_port->bfad;
607725ccfdSJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
617725ccfdSJing Huang 
62f16a1750SMaggie Zhang 	itnim = bfad_get_itnim(im_port, starget->id);
637725ccfdSJing Huang 	if (itnim)
647725ccfdSJing Huang 		node_name = bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim);
657725ccfdSJing Huang 
66ba816ea8SJing Huang 	fc_starget_node_name(starget) = cpu_to_be64(node_name);
677725ccfdSJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
687725ccfdSJing Huang }
697725ccfdSJing Huang 
705fbe25c7SJing Huang /*
717725ccfdSJing Huang  * FC transport template entry, get SCSI target pwwn.
727725ccfdSJing Huang  */
7352f94b6fSMaggie static void
bfad_im_get_starget_port_name(struct scsi_target * starget)747725ccfdSJing Huang bfad_im_get_starget_port_name(struct scsi_target *starget)
757725ccfdSJing Huang {
767725ccfdSJing Huang 	struct Scsi_Host *shost;
777725ccfdSJing Huang 	struct bfad_im_port_s *im_port;
787725ccfdSJing Huang 	struct bfad_s         *bfad;
797725ccfdSJing Huang 	struct bfad_itnim_s   *itnim = NULL;
807725ccfdSJing Huang 	u64             port_name = 0;
817725ccfdSJing Huang 	unsigned long   flags;
827725ccfdSJing Huang 
83a36c61f9SKrishna Gudipati 	shost = dev_to_shost(starget->dev.parent);
847725ccfdSJing Huang 	im_port = (struct bfad_im_port_s *) shost->hostdata[0];
857725ccfdSJing Huang 	bfad = im_port->bfad;
867725ccfdSJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
877725ccfdSJing Huang 
88f16a1750SMaggie Zhang 	itnim = bfad_get_itnim(im_port, starget->id);
897725ccfdSJing Huang 	if (itnim)
907725ccfdSJing Huang 		port_name = bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim);
917725ccfdSJing Huang 
92ba816ea8SJing Huang 	fc_starget_port_name(starget) = cpu_to_be64(port_name);
937725ccfdSJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
947725ccfdSJing Huang }
957725ccfdSJing Huang 
965fbe25c7SJing Huang /*
977725ccfdSJing Huang  * FC transport template entry, get SCSI host port ID.
987725ccfdSJing Huang  */
9952f94b6fSMaggie static void
bfad_im_get_host_port_id(struct Scsi_Host * shost)1007725ccfdSJing Huang bfad_im_get_host_port_id(struct Scsi_Host *shost)
1017725ccfdSJing Huang {
1027725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
1037725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
1047725ccfdSJing Huang 	struct bfad_port_s    *port = im_port->port;
1057725ccfdSJing Huang 
1067725ccfdSJing Huang 	fc_host_port_id(shost) =
107f16a1750SMaggie Zhang 			bfa_hton3b(bfa_fcs_lport_get_fcid(port->fcs_port));
1087725ccfdSJing Huang }
1097725ccfdSJing Huang 
1105fbe25c7SJing Huang /*
1117725ccfdSJing Huang  * FC transport template entry, get SCSI host port type.
1127725ccfdSJing Huang  */
1137725ccfdSJing Huang static void
bfad_im_get_host_port_type(struct Scsi_Host * shost)1147725ccfdSJing Huang bfad_im_get_host_port_type(struct Scsi_Host *shost)
1157725ccfdSJing Huang {
1167725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
1177725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
1187725ccfdSJing Huang 	struct bfad_s         *bfad = im_port->bfad;
119a36c61f9SKrishna Gudipati 	struct bfa_lport_attr_s port_attr;
1207725ccfdSJing Huang 
121a36c61f9SKrishna Gudipati 	bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
1227725ccfdSJing Huang 
123a36c61f9SKrishna Gudipati 	switch (port_attr.port_type) {
124a36c61f9SKrishna Gudipati 	case BFA_PORT_TYPE_NPORT:
1257725ccfdSJing Huang 		fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
1267725ccfdSJing Huang 		break;
127a36c61f9SKrishna Gudipati 	case BFA_PORT_TYPE_NLPORT:
1287725ccfdSJing Huang 		fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
1297725ccfdSJing Huang 		break;
130a36c61f9SKrishna Gudipati 	case BFA_PORT_TYPE_P2P:
1317725ccfdSJing Huang 		fc_host_port_type(shost) = FC_PORTTYPE_PTP;
1327725ccfdSJing Huang 		break;
133a36c61f9SKrishna Gudipati 	case BFA_PORT_TYPE_LPORT:
1347725ccfdSJing Huang 		fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
1357725ccfdSJing Huang 		break;
1367725ccfdSJing Huang 	default:
1377725ccfdSJing Huang 		fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
1387725ccfdSJing Huang 		break;
1397725ccfdSJing Huang 	}
1407725ccfdSJing Huang }
1417725ccfdSJing Huang 
1425fbe25c7SJing Huang /*
1437725ccfdSJing Huang  * FC transport template entry, get SCSI host port state.
1447725ccfdSJing Huang  */
1457725ccfdSJing Huang static void
bfad_im_get_host_port_state(struct Scsi_Host * shost)1467725ccfdSJing Huang bfad_im_get_host_port_state(struct Scsi_Host *shost)
1477725ccfdSJing Huang {
1487725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
1497725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
1507725ccfdSJing Huang 	struct bfad_s         *bfad = im_port->bfad;
151a36c61f9SKrishna Gudipati 	struct bfa_port_attr_s attr;
1527725ccfdSJing Huang 
1531c8a4c37SKrishna Gudipati 	bfa_fcport_get_attr(&bfad->bfa, &attr);
1547725ccfdSJing Huang 
1557725ccfdSJing Huang 	switch (attr.port_state) {
156a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_LINKDOWN:
1577725ccfdSJing Huang 		fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
1587725ccfdSJing Huang 		break;
159a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_LINKUP:
1607725ccfdSJing Huang 		fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
1617725ccfdSJing Huang 		break;
162a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_DISABLED:
163a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_STOPPED:
164a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_IOCDOWN:
165a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_IOCDIS:
166a36c61f9SKrishna Gudipati 		fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
167a36c61f9SKrishna Gudipati 		break;
168a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_UNINIT:
169a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_ENABLING_QWAIT:
170a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_ENABLING:
171a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_DISABLING_QWAIT:
172a36c61f9SKrishna Gudipati 	case BFA_PORT_ST_DISABLING:
1737725ccfdSJing Huang 	default:
1747725ccfdSJing Huang 		fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
1757725ccfdSJing Huang 		break;
1767725ccfdSJing Huang 	}
1777725ccfdSJing Huang }
1787725ccfdSJing Huang 
1795fbe25c7SJing Huang /*
1807725ccfdSJing Huang  * FC transport template entry, get SCSI host active fc4s.
1817725ccfdSJing Huang  */
1827725ccfdSJing Huang static void
bfad_im_get_host_active_fc4s(struct Scsi_Host * shost)1837725ccfdSJing Huang bfad_im_get_host_active_fc4s(struct Scsi_Host *shost)
1847725ccfdSJing Huang {
1857725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
1867725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
1877725ccfdSJing Huang 	struct bfad_port_s    *port = im_port->port;
1887725ccfdSJing Huang 
1897725ccfdSJing Huang 	memset(fc_host_active_fc4s(shost), 0,
1907725ccfdSJing Huang 	       sizeof(fc_host_active_fc4s(shost)));
1917725ccfdSJing Huang 
192a36c61f9SKrishna Gudipati 	if (port->supported_fc4s & BFA_LPORT_ROLE_FCP_IM)
1937725ccfdSJing Huang 		fc_host_active_fc4s(shost)[2] = 1;
1947725ccfdSJing Huang 
1957725ccfdSJing Huang 	fc_host_active_fc4s(shost)[7] = 1;
1967725ccfdSJing Huang }
1977725ccfdSJing Huang 
1985fbe25c7SJing Huang /*
1997725ccfdSJing Huang  * FC transport template entry, get SCSI host link speed.
2007725ccfdSJing Huang  */
2017725ccfdSJing Huang static void
bfad_im_get_host_speed(struct Scsi_Host * shost)2027725ccfdSJing Huang bfad_im_get_host_speed(struct Scsi_Host *shost)
2037725ccfdSJing Huang {
2047725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
2057725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
2067725ccfdSJing Huang 	struct bfad_s         *bfad = im_port->bfad;
207a36c61f9SKrishna Gudipati 	struct bfa_port_attr_s attr;
2087725ccfdSJing Huang 
2091c8a4c37SKrishna Gudipati 	bfa_fcport_get_attr(&bfad->bfa, &attr);
2107725ccfdSJing Huang 	switch (attr.speed) {
211a36c61f9SKrishna Gudipati 	case BFA_PORT_SPEED_10GBPS:
212a36c61f9SKrishna Gudipati 		fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
213a36c61f9SKrishna Gudipati 		break;
2148b070b4aSKrishna Gudipati 	case BFA_PORT_SPEED_16GBPS:
2158b070b4aSKrishna Gudipati 		fc_host_speed(shost) = FC_PORTSPEED_16GBIT;
2168b070b4aSKrishna Gudipati 		break;
217a36c61f9SKrishna Gudipati 	case BFA_PORT_SPEED_8GBPS:
2187725ccfdSJing Huang 		fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
2197725ccfdSJing Huang 		break;
220a36c61f9SKrishna Gudipati 	case BFA_PORT_SPEED_4GBPS:
2217725ccfdSJing Huang 		fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
2227725ccfdSJing Huang 		break;
223a36c61f9SKrishna Gudipati 	case BFA_PORT_SPEED_2GBPS:
2247725ccfdSJing Huang 		fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
2257725ccfdSJing Huang 		break;
226a36c61f9SKrishna Gudipati 	case BFA_PORT_SPEED_1GBPS:
2277725ccfdSJing Huang 		fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
2287725ccfdSJing Huang 		break;
2297725ccfdSJing Huang 	default:
2307725ccfdSJing Huang 		fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
2317725ccfdSJing Huang 		break;
2327725ccfdSJing Huang 	}
2337725ccfdSJing Huang }
2347725ccfdSJing Huang 
2355fbe25c7SJing Huang /*
2367725ccfdSJing Huang  * FC transport template entry, get SCSI host port type.
2377725ccfdSJing Huang  */
2387725ccfdSJing Huang static void
bfad_im_get_host_fabric_name(struct Scsi_Host * shost)2397725ccfdSJing Huang bfad_im_get_host_fabric_name(struct Scsi_Host *shost)
2407725ccfdSJing Huang {
2417725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
2427725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
2437725ccfdSJing Huang 	struct bfad_port_s    *port = im_port->port;
2447725ccfdSJing Huang 	wwn_t           fabric_nwwn = 0;
2457725ccfdSJing Huang 
246a36c61f9SKrishna Gudipati 	fabric_nwwn = bfa_fcs_lport_get_fabric_name(port->fcs_port);
2477725ccfdSJing Huang 
248ba816ea8SJing Huang 	fc_host_fabric_name(shost) = cpu_to_be64(fabric_nwwn);
2497725ccfdSJing Huang 
2507725ccfdSJing Huang }
2517725ccfdSJing Huang 
2525fbe25c7SJing Huang /*
2537725ccfdSJing Huang  * FC transport template entry, get BFAD statistics.
2547725ccfdSJing Huang  */
2557725ccfdSJing Huang static struct fc_host_statistics *
bfad_im_get_stats(struct Scsi_Host * shost)2567725ccfdSJing Huang bfad_im_get_stats(struct Scsi_Host *shost)
2577725ccfdSJing Huang {
2587725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
2597725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
2607725ccfdSJing Huang 	struct bfad_s         *bfad = im_port->bfad;
2617725ccfdSJing Huang 	struct bfad_hal_comp fcomp;
262a36c61f9SKrishna Gudipati 	union bfa_port_stats_u *fcstats;
2637725ccfdSJing Huang 	struct fc_host_statistics *hstats;
2647725ccfdSJing Huang 	bfa_status_t    rc;
2657725ccfdSJing Huang 	unsigned long   flags;
2667725ccfdSJing Huang 
267a36c61f9SKrishna Gudipati 	fcstats = kzalloc(sizeof(union bfa_port_stats_u), GFP_KERNEL);
268a36c61f9SKrishna Gudipati 	if (fcstats == NULL)
269a36c61f9SKrishna Gudipati 		return NULL;
270a36c61f9SKrishna Gudipati 
2717725ccfdSJing Huang 	hstats = &bfad->link_stats;
2727725ccfdSJing Huang 	init_completion(&fcomp.comp);
2737725ccfdSJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
2747725ccfdSJing Huang 	memset(hstats, 0, sizeof(struct fc_host_statistics));
275ca8b4327SKrishna Gudipati 	rc = bfa_port_get_stats(BFA_FCPORT(&bfad->bfa),
276a36c61f9SKrishna Gudipati 				fcstats, bfad_hcb_comp, &fcomp);
2777725ccfdSJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
2780e62395dSNavid Emamdoost 	if (rc != BFA_STATUS_OK) {
2790e62395dSNavid Emamdoost 		kfree(fcstats);
2807725ccfdSJing Huang 		return NULL;
2810e62395dSNavid Emamdoost 	}
2827725ccfdSJing Huang 
2837725ccfdSJing Huang 	wait_for_completion(&fcomp.comp);
2847725ccfdSJing Huang 
285a36c61f9SKrishna Gudipati 	/* Fill the fc_host_statistics structure */
286a36c61f9SKrishna Gudipati 	hstats->seconds_since_last_reset = fcstats->fc.secs_reset;
287a36c61f9SKrishna Gudipati 	hstats->tx_frames = fcstats->fc.tx_frames;
288a36c61f9SKrishna Gudipati 	hstats->tx_words  = fcstats->fc.tx_words;
289a36c61f9SKrishna Gudipati 	hstats->rx_frames = fcstats->fc.rx_frames;
290a36c61f9SKrishna Gudipati 	hstats->rx_words  = fcstats->fc.rx_words;
291a36c61f9SKrishna Gudipati 	hstats->lip_count = fcstats->fc.lip_count;
292a36c61f9SKrishna Gudipati 	hstats->nos_count = fcstats->fc.nos_count;
293a36c61f9SKrishna Gudipati 	hstats->error_frames = fcstats->fc.error_frames;
294a36c61f9SKrishna Gudipati 	hstats->dumped_frames = fcstats->fc.dropped_frames;
295a36c61f9SKrishna Gudipati 	hstats->link_failure_count = fcstats->fc.link_failures;
296a36c61f9SKrishna Gudipati 	hstats->loss_of_sync_count = fcstats->fc.loss_of_syncs;
297a36c61f9SKrishna Gudipati 	hstats->loss_of_signal_count = fcstats->fc.loss_of_signals;
298a36c61f9SKrishna Gudipati 	hstats->prim_seq_protocol_err_count = fcstats->fc.primseq_errs;
299a36c61f9SKrishna Gudipati 	hstats->invalid_crc_count = fcstats->fc.invalid_crcs;
300a36c61f9SKrishna Gudipati 
301a36c61f9SKrishna Gudipati 	kfree(fcstats);
3027725ccfdSJing Huang 	return hstats;
3037725ccfdSJing Huang }
3047725ccfdSJing Huang 
3055fbe25c7SJing Huang /*
3067725ccfdSJing Huang  * FC transport template entry, reset BFAD statistics.
3077725ccfdSJing Huang  */
3087725ccfdSJing Huang static void
bfad_im_reset_stats(struct Scsi_Host * shost)3097725ccfdSJing Huang bfad_im_reset_stats(struct Scsi_Host *shost)
3107725ccfdSJing Huang {
3117725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
3127725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
3137725ccfdSJing Huang 	struct bfad_s         *bfad = im_port->bfad;
3147725ccfdSJing Huang 	struct bfad_hal_comp fcomp;
3157725ccfdSJing Huang 	unsigned long   flags;
3167725ccfdSJing Huang 	bfa_status_t    rc;
3177725ccfdSJing Huang 
3187725ccfdSJing Huang 	init_completion(&fcomp.comp);
3197725ccfdSJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
320ca8b4327SKrishna Gudipati 	rc = bfa_port_clear_stats(BFA_FCPORT(&bfad->bfa), bfad_hcb_comp,
321ca8b4327SKrishna Gudipati 					&fcomp);
3227725ccfdSJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
3237725ccfdSJing Huang 
3247725ccfdSJing Huang 	if (rc != BFA_STATUS_OK)
3257725ccfdSJing Huang 		return;
3267725ccfdSJing Huang 
3277725ccfdSJing Huang 	wait_for_completion(&fcomp.comp);
3287725ccfdSJing Huang 
3297725ccfdSJing Huang 	return;
3307725ccfdSJing Huang }
3317725ccfdSJing Huang 
3325fbe25c7SJing Huang /*
3337725ccfdSJing Huang  * FC transport template entry, set rport loss timeout.
3344dde5069SVijaya Mohan Guvva  * Update dev_loss_tmo based on the value pushed down by the stack
3354dde5069SVijaya Mohan Guvva  * In case it is lesser than path_tov of driver, set it to path_tov + 1
3364dde5069SVijaya Mohan Guvva  * to ensure that the driver times out before the application
3377725ccfdSJing Huang  */
3387725ccfdSJing Huang static void
bfad_im_set_rport_loss_tmo(struct fc_rport * rport,u32 timeout)3397725ccfdSJing Huang bfad_im_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout)
3407725ccfdSJing Huang {
3417725ccfdSJing Huang 	struct bfad_itnim_data_s *itnim_data = rport->dd_data;
3427725ccfdSJing Huang 	struct bfad_itnim_s   *itnim = itnim_data->itnim;
3437725ccfdSJing Huang 	struct bfad_s         *bfad = itnim->im->bfad;
3444dde5069SVijaya Mohan Guvva 	uint16_t path_tov = bfa_fcpim_path_tov_get(&bfad->bfa);
3457725ccfdSJing Huang 
3464dde5069SVijaya Mohan Guvva 	rport->dev_loss_tmo = timeout;
3474dde5069SVijaya Mohan Guvva 	if (timeout < path_tov)
3484dde5069SVijaya Mohan Guvva 		rport->dev_loss_tmo = path_tov + 1;
3497725ccfdSJing Huang }
3507725ccfdSJing Huang 
351b504293fSJing Huang static int
bfad_im_vport_create(struct fc_vport * fc_vport,bool disable)352b504293fSJing Huang bfad_im_vport_create(struct fc_vport *fc_vport, bool disable)
353b504293fSJing Huang {
354b504293fSJing Huang 	char *vname = fc_vport->symbolic_name;
355b504293fSJing Huang 	struct Scsi_Host *shost = fc_vport->shost;
356b504293fSJing Huang 	struct bfad_im_port_s *im_port =
357b504293fSJing Huang 		(struct bfad_im_port_s *) shost->hostdata[0];
358b504293fSJing Huang 	struct bfad_s *bfad = im_port->bfad;
359a36c61f9SKrishna Gudipati 	struct bfa_lport_cfg_s port_cfg;
360a36c61f9SKrishna Gudipati 	struct bfad_vport_s *vp;
361b504293fSJing Huang 	int status = 0, rc;
362b504293fSJing Huang 	unsigned long flags;
363b504293fSJing Huang 
364b504293fSJing Huang 	memset(&port_cfg, 0, sizeof(port_cfg));
365d9883548SJing Huang 	u64_to_wwn(fc_vport->node_name, (u8 *)&port_cfg.nwwn);
366d9883548SJing Huang 	u64_to_wwn(fc_vport->port_name, (u8 *)&port_cfg.pwwn);
367b504293fSJing Huang 	if (strlen(vname) > 0)
368b504293fSJing Huang 		strcpy((char *)&port_cfg.sym_name, vname);
369a36c61f9SKrishna Gudipati 	port_cfg.roles = BFA_LPORT_ROLE_FCP_IM;
370b504293fSJing Huang 
371d9883548SJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
372a36c61f9SKrishna Gudipati 	list_for_each_entry(vp, &bfad->pbc_vport_list, list_entry) {
373a36c61f9SKrishna Gudipati 		if (port_cfg.pwwn ==
374a36c61f9SKrishna Gudipati 				vp->fcs_vport.lport.port_cfg.pwwn) {
375a36c61f9SKrishna Gudipati 			port_cfg.preboot_vp =
376a36c61f9SKrishna Gudipati 				vp->fcs_vport.lport.port_cfg.preboot_vp;
377d9883548SJing Huang 			break;
378d9883548SJing Huang 		}
379d9883548SJing Huang 	}
380d9883548SJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
381d9883548SJing Huang 
382d9883548SJing Huang 	rc = bfad_vport_create(bfad, 0, &port_cfg, &fc_vport->dev);
383b504293fSJing Huang 	if (rc == BFA_STATUS_OK) {
384b504293fSJing Huang 		struct bfad_vport_s *vport;
385b504293fSJing Huang 		struct bfa_fcs_vport_s *fcs_vport;
386b504293fSJing Huang 		struct Scsi_Host *vshost;
387b504293fSJing Huang 
388b504293fSJing Huang 		spin_lock_irqsave(&bfad->bfad_lock, flags);
389b504293fSJing Huang 		fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0,
390b504293fSJing Huang 					port_cfg.pwwn);
391b504293fSJing Huang 		spin_unlock_irqrestore(&bfad->bfad_lock, flags);
392d9883548SJing Huang 		if (fcs_vport == NULL)
393b504293fSJing Huang 			return VPCERR_BAD_WWN;
394b504293fSJing Huang 
395b504293fSJing Huang 		fc_vport_set_state(fc_vport, FC_VPORT_ACTIVE);
396b504293fSJing Huang 		if (disable) {
397d9883548SJing Huang 			spin_lock_irqsave(&bfad->bfad_lock, flags);
398b504293fSJing Huang 			bfa_fcs_vport_stop(fcs_vport);
399d9883548SJing Huang 			spin_unlock_irqrestore(&bfad->bfad_lock, flags);
400b504293fSJing Huang 			fc_vport_set_state(fc_vport, FC_VPORT_DISABLED);
401b504293fSJing Huang 		}
402b504293fSJing Huang 
403b504293fSJing Huang 		vport = fcs_vport->vport_drv;
404b504293fSJing Huang 		vshost = vport->drv_port.im_port->shost;
405b504293fSJing Huang 		fc_host_node_name(vshost) = wwn_to_u64((u8 *)&port_cfg.nwwn);
406b504293fSJing Huang 		fc_host_port_name(vshost) = wwn_to_u64((u8 *)&port_cfg.pwwn);
4076192bd7cSKrishna Gudipati 		fc_host_supported_classes(vshost) = FC_COS_CLASS3;
4086192bd7cSKrishna Gudipati 
4096192bd7cSKrishna Gudipati 		memset(fc_host_supported_fc4s(vshost), 0,
4106192bd7cSKrishna Gudipati 			sizeof(fc_host_supported_fc4s(vshost)));
4116192bd7cSKrishna Gudipati 
4126192bd7cSKrishna Gudipati 		/* For FCP type 0x08 */
4136192bd7cSKrishna Gudipati 		if (supported_fc4s & BFA_LPORT_ROLE_FCP_IM)
4146192bd7cSKrishna Gudipati 			fc_host_supported_fc4s(vshost)[2] = 1;
4156192bd7cSKrishna Gudipati 
4166192bd7cSKrishna Gudipati 		/* For fibre channel services type 0x20 */
4176192bd7cSKrishna Gudipati 		fc_host_supported_fc4s(vshost)[7] = 1;
4186192bd7cSKrishna Gudipati 
4196192bd7cSKrishna Gudipati 		fc_host_supported_speeds(vshost) =
4206192bd7cSKrishna Gudipati 				bfad_im_supported_speeds(&bfad->bfa);
4216192bd7cSKrishna Gudipati 		fc_host_maxframe_size(vshost) =
4226192bd7cSKrishna Gudipati 				bfa_fcport_get_maxfrsize(&bfad->bfa);
4236192bd7cSKrishna Gudipati 
424b504293fSJing Huang 		fc_vport->dd_data = vport;
425b504293fSJing Huang 		vport->drv_port.im_port->fc_vport = fc_vport;
426b504293fSJing Huang 	} else if (rc == BFA_STATUS_INVALID_WWN)
427b504293fSJing Huang 		return VPCERR_BAD_WWN;
428b504293fSJing Huang 	else if (rc == BFA_STATUS_VPORT_EXISTS)
429b504293fSJing Huang 		return VPCERR_BAD_WWN;
430b504293fSJing Huang 	else if (rc == BFA_STATUS_VPORT_MAX)
431b504293fSJing Huang 		return VPCERR_NO_FABRIC_SUPP;
432b504293fSJing Huang 	else if (rc == BFA_STATUS_VPORT_WWN_BP)
433b504293fSJing Huang 		return VPCERR_BAD_WWN;
434b504293fSJing Huang 	else
435b504293fSJing Huang 		return FC_VPORT_FAILED;
436b504293fSJing Huang 
437b504293fSJing Huang 	return status;
438b504293fSJing Huang }
439b504293fSJing Huang 
440938b1846SJason Yan static int
bfad_im_issue_fc_host_lip(struct Scsi_Host * shost)441acea2415SKrishna Gudipati bfad_im_issue_fc_host_lip(struct Scsi_Host *shost)
442acea2415SKrishna Gudipati {
443acea2415SKrishna Gudipati 	struct bfad_im_port_s *im_port =
444acea2415SKrishna Gudipati 			(struct bfad_im_port_s *) shost->hostdata[0];
445acea2415SKrishna Gudipati 	struct bfad_s *bfad = im_port->bfad;
446acea2415SKrishna Gudipati 	struct bfad_hal_comp fcomp;
447acea2415SKrishna Gudipati 	unsigned long flags;
448acea2415SKrishna Gudipati 	uint32_t status;
449acea2415SKrishna Gudipati 
450acea2415SKrishna Gudipati 	init_completion(&fcomp.comp);
451acea2415SKrishna Gudipati 	spin_lock_irqsave(&bfad->bfad_lock, flags);
452acea2415SKrishna Gudipati 	status = bfa_port_disable(&bfad->bfa.modules.port,
453acea2415SKrishna Gudipati 					bfad_hcb_comp, &fcomp);
454acea2415SKrishna Gudipati 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
455acea2415SKrishna Gudipati 
456acea2415SKrishna Gudipati 	if (status != BFA_STATUS_OK)
457acea2415SKrishna Gudipati 		return -EIO;
458acea2415SKrishna Gudipati 
459acea2415SKrishna Gudipati 	wait_for_completion(&fcomp.comp);
460acea2415SKrishna Gudipati 	if (fcomp.status != BFA_STATUS_OK)
461acea2415SKrishna Gudipati 		return -EIO;
462acea2415SKrishna Gudipati 
463acea2415SKrishna Gudipati 	spin_lock_irqsave(&bfad->bfad_lock, flags);
464acea2415SKrishna Gudipati 	status = bfa_port_enable(&bfad->bfa.modules.port,
465acea2415SKrishna Gudipati 					bfad_hcb_comp, &fcomp);
466acea2415SKrishna Gudipati 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
467acea2415SKrishna Gudipati 	if (status != BFA_STATUS_OK)
468acea2415SKrishna Gudipati 		return -EIO;
469acea2415SKrishna Gudipati 
470acea2415SKrishna Gudipati 	wait_for_completion(&fcomp.comp);
471acea2415SKrishna Gudipati 	if (fcomp.status != BFA_STATUS_OK)
472acea2415SKrishna Gudipati 		return -EIO;
473acea2415SKrishna Gudipati 
474acea2415SKrishna Gudipati 	return 0;
475acea2415SKrishna Gudipati }
476acea2415SKrishna Gudipati 
477b504293fSJing Huang static int
bfad_im_vport_delete(struct fc_vport * fc_vport)478b504293fSJing Huang bfad_im_vport_delete(struct fc_vport *fc_vport)
479b504293fSJing Huang {
480b504293fSJing Huang 	struct bfad_vport_s *vport = (struct bfad_vport_s *)fc_vport->dd_data;
481b504293fSJing Huang 	struct bfad_im_port_s *im_port =
482b504293fSJing Huang 			(struct bfad_im_port_s *) vport->drv_port.im_port;
483b504293fSJing Huang 	struct bfad_s *bfad = im_port->bfad;
484b504293fSJing Huang 	struct bfa_fcs_vport_s *fcs_vport;
485b504293fSJing Huang 	struct Scsi_Host *vshost;
486b504293fSJing Huang 	wwn_t   pwwn;
487b504293fSJing Huang 	int rc;
488b504293fSJing Huang 	unsigned long flags;
489b504293fSJing Huang 	struct completion fcomp;
490b504293fSJing Huang 
491ff179e0fSKrishna Gudipati 	if (im_port->flags & BFAD_PORT_DELETE) {
492ff179e0fSKrishna Gudipati 		bfad_scsi_host_free(bfad, im_port);
493ff179e0fSKrishna Gudipati 		list_del(&vport->list_entry);
49417c201b3SKrishna Gudipati 		kfree(vport);
495ff179e0fSKrishna Gudipati 		return 0;
496ff179e0fSKrishna Gudipati 	}
497b504293fSJing Huang 
498b504293fSJing Huang 	vshost = vport->drv_port.im_port->shost;
499d9883548SJing Huang 	u64_to_wwn(fc_host_port_name(vshost), (u8 *)&pwwn);
500b504293fSJing Huang 
501b504293fSJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
502b504293fSJing Huang 	fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, pwwn);
503b504293fSJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
504b504293fSJing Huang 
505b504293fSJing Huang 	if (fcs_vport == NULL)
506b504293fSJing Huang 		return VPCERR_BAD_WWN;
507b504293fSJing Huang 
508b504293fSJing Huang 	vport->drv_port.flags |= BFAD_PORT_DELETE;
509b504293fSJing Huang 
510b504293fSJing Huang 	vport->comp_del = &fcomp;
511b504293fSJing Huang 	init_completion(vport->comp_del);
512b504293fSJing Huang 
513b504293fSJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
514b504293fSJing Huang 	rc = bfa_fcs_vport_delete(&vport->fcs_vport);
515b504293fSJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
516b504293fSJing Huang 
517c54d557cSJing Huang 	if (rc == BFA_STATUS_PBC) {
518c54d557cSJing Huang 		vport->drv_port.flags &= ~BFAD_PORT_DELETE;
519c54d557cSJing Huang 		vport->comp_del = NULL;
520d9883548SJing Huang 		return -1;
521c54d557cSJing Huang 	}
522d9883548SJing Huang 
523b504293fSJing Huang 	wait_for_completion(vport->comp_del);
524b504293fSJing Huang 
525f16a1750SMaggie Zhang 	bfad_scsi_host_free(bfad, im_port);
5265b7db7afSKrishna Gudipati 	list_del(&vport->list_entry);
527b504293fSJing Huang 	kfree(vport);
528b504293fSJing Huang 
529b504293fSJing Huang 	return 0;
530b504293fSJing Huang }
531b504293fSJing Huang 
532b504293fSJing Huang static int
bfad_im_vport_disable(struct fc_vport * fc_vport,bool disable)533b504293fSJing Huang bfad_im_vport_disable(struct fc_vport *fc_vport, bool disable)
534b504293fSJing Huang {
535b504293fSJing Huang 	struct bfad_vport_s *vport;
536b504293fSJing Huang 	struct bfad_s *bfad;
537b504293fSJing Huang 	struct bfa_fcs_vport_s *fcs_vport;
538b504293fSJing Huang 	struct Scsi_Host *vshost;
539b504293fSJing Huang 	wwn_t   pwwn;
540b504293fSJing Huang 	unsigned long flags;
541b504293fSJing Huang 
542b504293fSJing Huang 	vport = (struct bfad_vport_s *)fc_vport->dd_data;
543b504293fSJing Huang 	bfad = vport->drv_port.bfad;
544b504293fSJing Huang 	vshost = vport->drv_port.im_port->shost;
545d9883548SJing Huang 	u64_to_wwn(fc_host_port_name(vshost), (u8 *)&pwwn);
546b504293fSJing Huang 
547b504293fSJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
548b504293fSJing Huang 	fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, pwwn);
549b504293fSJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
550b504293fSJing Huang 
551b504293fSJing Huang 	if (fcs_vport == NULL)
552b504293fSJing Huang 		return VPCERR_BAD_WWN;
553b504293fSJing Huang 
554b504293fSJing Huang 	if (disable) {
555b504293fSJing Huang 		bfa_fcs_vport_stop(fcs_vport);
556b504293fSJing Huang 		fc_vport_set_state(fc_vport, FC_VPORT_DISABLED);
557b504293fSJing Huang 	} else {
558b504293fSJing Huang 		bfa_fcs_vport_start(fcs_vport);
559b504293fSJing Huang 		fc_vport_set_state(fc_vport, FC_VPORT_ACTIVE);
560b504293fSJing Huang 	}
561b504293fSJing Huang 
562b504293fSJing Huang 	return 0;
563b504293fSJing Huang }
564b504293fSJing Huang 
565938b1846SJason Yan static void
bfad_im_vport_set_symbolic_name(struct fc_vport * fc_vport)566ebfe8392SKrishna Gudipati bfad_im_vport_set_symbolic_name(struct fc_vport *fc_vport)
567ebfe8392SKrishna Gudipati {
568ebfe8392SKrishna Gudipati 	struct bfad_vport_s *vport = (struct bfad_vport_s *)fc_vport->dd_data;
569ebfe8392SKrishna Gudipati 	struct bfad_im_port_s *im_port =
570ebfe8392SKrishna Gudipati 			(struct bfad_im_port_s *)vport->drv_port.im_port;
571ebfe8392SKrishna Gudipati 	struct bfad_s *bfad = im_port->bfad;
572ebfe8392SKrishna Gudipati 	struct Scsi_Host *vshost = vport->drv_port.im_port->shost;
573ebfe8392SKrishna Gudipati 	char *sym_name = fc_vport->symbolic_name;
574ebfe8392SKrishna Gudipati 	struct bfa_fcs_vport_s *fcs_vport;
575ebfe8392SKrishna Gudipati 	wwn_t	pwwn;
576ebfe8392SKrishna Gudipati 	unsigned long flags;
577ebfe8392SKrishna Gudipati 
578ebfe8392SKrishna Gudipati 	u64_to_wwn(fc_host_port_name(vshost), (u8 *)&pwwn);
579ebfe8392SKrishna Gudipati 
580ebfe8392SKrishna Gudipati 	spin_lock_irqsave(&bfad->bfad_lock, flags);
581ebfe8392SKrishna Gudipati 	fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, pwwn);
582ebfe8392SKrishna Gudipati 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
583ebfe8392SKrishna Gudipati 
584ebfe8392SKrishna Gudipati 	if (fcs_vport == NULL)
585ebfe8392SKrishna Gudipati 		return;
586ebfe8392SKrishna Gudipati 
587ebfe8392SKrishna Gudipati 	spin_lock_irqsave(&bfad->bfad_lock, flags);
58822a08538SVijaya Mohan Guvva 	if (strlen(sym_name) > 0)
58922a08538SVijaya Mohan Guvva 		bfa_fcs_lport_set_symname(&fcs_vport->lport, sym_name);
590ebfe8392SKrishna Gudipati 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
591ebfe8392SKrishna Gudipati }
592ebfe8392SKrishna Gudipati 
5937725ccfdSJing Huang struct fc_function_template bfad_im_fc_function_template = {
5947725ccfdSJing Huang 
5957725ccfdSJing Huang 	/* Target dynamic attributes */
5967725ccfdSJing Huang 	.get_starget_port_id = bfad_im_get_starget_port_id,
5977725ccfdSJing Huang 	.show_starget_port_id = 1,
5987725ccfdSJing Huang 	.get_starget_node_name = bfad_im_get_starget_node_name,
5997725ccfdSJing Huang 	.show_starget_node_name = 1,
6007725ccfdSJing Huang 	.get_starget_port_name = bfad_im_get_starget_port_name,
6017725ccfdSJing Huang 	.show_starget_port_name = 1,
6027725ccfdSJing Huang 
6037725ccfdSJing Huang 	/* Host dynamic attribute */
6047725ccfdSJing Huang 	.get_host_port_id = bfad_im_get_host_port_id,
6057725ccfdSJing Huang 	.show_host_port_id = 1,
6067725ccfdSJing Huang 
6077725ccfdSJing Huang 	/* Host fixed attributes */
6087725ccfdSJing Huang 	.show_host_node_name = 1,
6097725ccfdSJing Huang 	.show_host_port_name = 1,
6107725ccfdSJing Huang 	.show_host_supported_classes = 1,
6117725ccfdSJing Huang 	.show_host_supported_fc4s = 1,
6127725ccfdSJing Huang 	.show_host_supported_speeds = 1,
6137725ccfdSJing Huang 	.show_host_maxframe_size = 1,
6147725ccfdSJing Huang 
6157725ccfdSJing Huang 	/* More host dynamic attributes */
6167725ccfdSJing Huang 	.show_host_port_type = 1,
6177725ccfdSJing Huang 	.get_host_port_type = bfad_im_get_host_port_type,
6187725ccfdSJing Huang 	.show_host_port_state = 1,
6197725ccfdSJing Huang 	.get_host_port_state = bfad_im_get_host_port_state,
6207725ccfdSJing Huang 	.show_host_active_fc4s = 1,
6217725ccfdSJing Huang 	.get_host_active_fc4s = bfad_im_get_host_active_fc4s,
6227725ccfdSJing Huang 	.show_host_speed = 1,
6237725ccfdSJing Huang 	.get_host_speed = bfad_im_get_host_speed,
6247725ccfdSJing Huang 	.show_host_fabric_name = 1,
6257725ccfdSJing Huang 	.get_host_fabric_name = bfad_im_get_host_fabric_name,
6267725ccfdSJing Huang 
6277725ccfdSJing Huang 	.show_host_symbolic_name = 1,
6287725ccfdSJing Huang 
6297725ccfdSJing Huang 	/* Statistics */
6307725ccfdSJing Huang 	.get_fc_host_stats = bfad_im_get_stats,
6317725ccfdSJing Huang 	.reset_fc_host_stats = bfad_im_reset_stats,
6327725ccfdSJing Huang 
6337725ccfdSJing Huang 	/* Allocation length for host specific data */
6347725ccfdSJing Huang 	.dd_fcrport_size = sizeof(struct bfad_itnim_data_s *),
6357725ccfdSJing Huang 
6367725ccfdSJing Huang 	/* Remote port fixed attributes */
6377725ccfdSJing Huang 	.show_rport_maxframe_size = 1,
6387725ccfdSJing Huang 	.show_rport_supported_classes = 1,
6397725ccfdSJing Huang 	.show_rport_dev_loss_tmo = 1,
6407725ccfdSJing Huang 	.set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo,
641acea2415SKrishna Gudipati 	.issue_fc_host_lip = bfad_im_issue_fc_host_lip,
642b504293fSJing Huang 	.vport_create = bfad_im_vport_create,
643b504293fSJing Huang 	.vport_delete = bfad_im_vport_delete,
644b504293fSJing Huang 	.vport_disable = bfad_im_vport_disable,
645ebfe8392SKrishna Gudipati 	.set_vport_symbolic_name = bfad_im_vport_set_symbolic_name,
646b85daafeSKrishna Gudipati 	.bsg_request = bfad_im_bsg_request,
647b85daafeSKrishna Gudipati 	.bsg_timeout = bfad_im_bsg_timeout,
648b504293fSJing Huang };
649b504293fSJing Huang 
650b504293fSJing Huang struct fc_function_template bfad_im_vport_fc_function_template = {
651b504293fSJing Huang 
652b504293fSJing Huang 	/* Target dynamic attributes */
653b504293fSJing Huang 	.get_starget_port_id = bfad_im_get_starget_port_id,
654b504293fSJing Huang 	.show_starget_port_id = 1,
655b504293fSJing Huang 	.get_starget_node_name = bfad_im_get_starget_node_name,
656b504293fSJing Huang 	.show_starget_node_name = 1,
657b504293fSJing Huang 	.get_starget_port_name = bfad_im_get_starget_port_name,
658b504293fSJing Huang 	.show_starget_port_name = 1,
659b504293fSJing Huang 
660b504293fSJing Huang 	/* Host dynamic attribute */
661b504293fSJing Huang 	.get_host_port_id = bfad_im_get_host_port_id,
662b504293fSJing Huang 	.show_host_port_id = 1,
663b504293fSJing Huang 
664b504293fSJing Huang 	/* Host fixed attributes */
665b504293fSJing Huang 	.show_host_node_name = 1,
666b504293fSJing Huang 	.show_host_port_name = 1,
667b504293fSJing Huang 	.show_host_supported_classes = 1,
668b504293fSJing Huang 	.show_host_supported_fc4s = 1,
669b504293fSJing Huang 	.show_host_supported_speeds = 1,
670b504293fSJing Huang 	.show_host_maxframe_size = 1,
671b504293fSJing Huang 
672b504293fSJing Huang 	/* More host dynamic attributes */
673b504293fSJing Huang 	.show_host_port_type = 1,
674b504293fSJing Huang 	.get_host_port_type = bfad_im_get_host_port_type,
675b504293fSJing Huang 	.show_host_port_state = 1,
676b504293fSJing Huang 	.get_host_port_state = bfad_im_get_host_port_state,
677b504293fSJing Huang 	.show_host_active_fc4s = 1,
678b504293fSJing Huang 	.get_host_active_fc4s = bfad_im_get_host_active_fc4s,
679b504293fSJing Huang 	.show_host_speed = 1,
680b504293fSJing Huang 	.get_host_speed = bfad_im_get_host_speed,
681b504293fSJing Huang 	.show_host_fabric_name = 1,
682b504293fSJing Huang 	.get_host_fabric_name = bfad_im_get_host_fabric_name,
683b504293fSJing Huang 
684b504293fSJing Huang 	.show_host_symbolic_name = 1,
685b504293fSJing Huang 
686b504293fSJing Huang 	/* Statistics */
687b504293fSJing Huang 	.get_fc_host_stats = bfad_im_get_stats,
688b504293fSJing Huang 	.reset_fc_host_stats = bfad_im_reset_stats,
689b504293fSJing Huang 
690b504293fSJing Huang 	/* Allocation length for host specific data */
691b504293fSJing Huang 	.dd_fcrport_size = sizeof(struct bfad_itnim_data_s *),
692b504293fSJing Huang 
693b504293fSJing Huang 	/* Remote port fixed attributes */
694b504293fSJing Huang 	.show_rport_maxframe_size = 1,
695b504293fSJing Huang 	.show_rport_supported_classes = 1,
696b504293fSJing Huang 	.show_rport_dev_loss_tmo = 1,
697b504293fSJing Huang 	.set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo,
6987725ccfdSJing Huang };
6997725ccfdSJing Huang 
7005fbe25c7SJing Huang /*
7017725ccfdSJing Huang  *  Scsi_Host_attrs SCSI host attributes
7027725ccfdSJing Huang  */
7037725ccfdSJing Huang static ssize_t
bfad_im_serial_num_show(struct device * dev,struct device_attribute * attr,char * buf)7047725ccfdSJing Huang bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr,
7057725ccfdSJing Huang 			 char *buf)
7067725ccfdSJing Huang {
7077725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
7087725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
7097725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
7107725ccfdSJing Huang 	struct bfad_s *bfad = im_port->bfad;
7110a4b1fc0SKrishna Gudipati 	char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
7127725ccfdSJing Huang 
7130a4b1fc0SKrishna Gudipati 	bfa_get_adapter_serial_num(&bfad->bfa, serial_num);
7142245ea91SYang Guang 	return sysfs_emit(buf, "%s\n", serial_num);
7157725ccfdSJing Huang }
7167725ccfdSJing Huang 
7177725ccfdSJing Huang static ssize_t
bfad_im_model_show(struct device * dev,struct device_attribute * attr,char * buf)7187725ccfdSJing Huang bfad_im_model_show(struct device *dev, struct device_attribute *attr,
7197725ccfdSJing Huang 			char *buf)
7207725ccfdSJing Huang {
7217725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
7227725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
7237725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
7247725ccfdSJing Huang 	struct bfad_s *bfad = im_port->bfad;
7250a4b1fc0SKrishna Gudipati 	char model[BFA_ADAPTER_MODEL_NAME_LEN];
7267725ccfdSJing Huang 
7270a4b1fc0SKrishna Gudipati 	bfa_get_adapter_model(&bfad->bfa, model);
7282245ea91SYang Guang 	return sysfs_emit(buf, "%s\n", model);
7297725ccfdSJing Huang }
7307725ccfdSJing Huang 
7317725ccfdSJing Huang static ssize_t
bfad_im_model_desc_show(struct device * dev,struct device_attribute * attr,char * buf)7327725ccfdSJing Huang bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr,
7337725ccfdSJing Huang 				 char *buf)
7347725ccfdSJing Huang {
7357725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
7367725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
7377725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
7387725ccfdSJing Huang 	struct bfad_s *bfad = im_port->bfad;
739a36c61f9SKrishna Gudipati 	char model[BFA_ADAPTER_MODEL_NAME_LEN];
7400a4b1fc0SKrishna Gudipati 	char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
74175332a70SKrishna Gudipati 	int nports = 0;
7427725ccfdSJing Huang 
743a36c61f9SKrishna Gudipati 	bfa_get_adapter_model(&bfad->bfa, model);
74475332a70SKrishna Gudipati 	nports = bfa_get_nports(&bfad->bfa);
74531e1d569SAnil Gurumurthy 	if (!strcmp(model, "QLogic-425"))
746a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
74731e1d569SAnil Gurumurthy 			"QLogic BR-series 4Gbps PCIe dual port FC HBA");
74831e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-825"))
749a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
75031e1d569SAnil Gurumurthy 			"QLogic BR-series 8Gbps PCIe dual port FC HBA");
75131e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-42B"))
752a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
75331e1d569SAnil Gurumurthy 			"QLogic BR-series 4Gbps PCIe dual port FC HBA for HP");
75431e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-82B"))
755a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
75631e1d569SAnil Gurumurthy 			"QLogic BR-series 8Gbps PCIe dual port FC HBA for HP");
75731e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-1010"))
758a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
75931e1d569SAnil Gurumurthy 			"QLogic BR-series 10Gbps single port CNA");
76031e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-1020"))
761a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
76231e1d569SAnil Gurumurthy 			"QLogic BR-series 10Gbps dual port CNA");
76331e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-1007"))
764a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
76531e1d569SAnil Gurumurthy 			"QLogic BR-series 10Gbps CNA for IBM Blade Center");
76631e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-415"))
767a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
76831e1d569SAnil Gurumurthy 			"QLogic BR-series 4Gbps PCIe single port FC HBA");
76931e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-815"))
770a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
77131e1d569SAnil Gurumurthy 			"QLogic BR-series 8Gbps PCIe single port FC HBA");
77231e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-41B"))
773a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
77431e1d569SAnil Gurumurthy 			"QLogic BR-series 4Gbps PCIe single port FC HBA for HP");
77531e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-81B"))
776a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
77731e1d569SAnil Gurumurthy 			"QLogic BR-series 8Gbps PCIe single port FC HBA for HP");
77831e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-804"))
779a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
78031e1d569SAnil Gurumurthy 			"QLogic BR-series 8Gbps FC HBA for HP Bladesystem C-class");
78131e1d569SAnil Gurumurthy 	else if (!strcmp(model, "QLogic-1741"))
782a36c61f9SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
78331e1d569SAnil Gurumurthy 			"QLogic BR-series 10Gbps CNA for Dell M-Series Blade Servers");
78431e1d569SAnil Gurumurthy 	else if (strstr(model, "QLogic-1860")) {
78575332a70SKrishna Gudipati 		if (nports == 1 && bfa_ioc_is_cna(&bfad->bfa.ioc))
78675332a70SKrishna Gudipati 			snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
78731e1d569SAnil Gurumurthy 				"QLogic BR-series 10Gbps single port CNA");
78875332a70SKrishna Gudipati 		else if (nports == 1 && !bfa_ioc_is_cna(&bfad->bfa.ioc))
78975332a70SKrishna Gudipati 			snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
79031e1d569SAnil Gurumurthy 				"QLogic BR-series 16Gbps PCIe single port FC HBA");
79175332a70SKrishna Gudipati 		else if (nports == 2 && bfa_ioc_is_cna(&bfad->bfa.ioc))
79275332a70SKrishna Gudipati 			snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
79331e1d569SAnil Gurumurthy 				"QLogic BR-series 10Gbps dual port CNA");
79475332a70SKrishna Gudipati 		else if (nports == 2 && !bfa_ioc_is_cna(&bfad->bfa.ioc))
79575332a70SKrishna Gudipati 			snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
79631e1d569SAnil Gurumurthy 				"QLogic BR-series 16Gbps PCIe dual port FC HBA");
79731e1d569SAnil Gurumurthy 	} else if (!strcmp(model, "QLogic-1867")) {
7986dca60a3SKrishna Gudipati 		if (nports == 1 && !bfa_ioc_is_cna(&bfad->bfa.ioc))
7996dca60a3SKrishna Gudipati 			snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
80031e1d569SAnil Gurumurthy 				"QLogic BR-series 16Gbps PCIe single port FC HBA for IBM");
8016dca60a3SKrishna Gudipati 		else if (nports == 2 && !bfa_ioc_is_cna(&bfad->bfa.ioc))
8026dca60a3SKrishna Gudipati 			snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
80331e1d569SAnil Gurumurthy 				"QLogic BR-series 16Gbps PCIe dual port FC HBA for IBM");
80475332a70SKrishna Gudipati 	} else
80575332a70SKrishna Gudipati 		snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
806a36c61f9SKrishna Gudipati 			"Invalid Model");
807a36c61f9SKrishna Gudipati 
8082245ea91SYang Guang 	return sysfs_emit(buf, "%s\n", model_descr);
8097725ccfdSJing Huang }
8107725ccfdSJing Huang 
8117725ccfdSJing Huang static ssize_t
bfad_im_node_name_show(struct device * dev,struct device_attribute * attr,char * buf)8127725ccfdSJing Huang bfad_im_node_name_show(struct device *dev, struct device_attribute *attr,
8137725ccfdSJing Huang 				 char *buf)
8147725ccfdSJing Huang {
8157725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
8167725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
8177725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
8187725ccfdSJing Huang 	struct bfad_port_s    *port = im_port->port;
8197725ccfdSJing Huang 	u64        nwwn;
8207725ccfdSJing Huang 
821a36c61f9SKrishna Gudipati 	nwwn = bfa_fcs_lport_get_nwwn(port->fcs_port);
8222245ea91SYang Guang 	return sysfs_emit(buf, "0x%llx\n", cpu_to_be64(nwwn));
8237725ccfdSJing Huang }
8247725ccfdSJing Huang 
8257725ccfdSJing Huang static ssize_t
bfad_im_symbolic_name_show(struct device * dev,struct device_attribute * attr,char * buf)8267725ccfdSJing Huang bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,
8277725ccfdSJing Huang 				 char *buf)
8287725ccfdSJing Huang {
8297725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
8307725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
8317725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
8327725ccfdSJing Huang 	struct bfad_s *bfad = im_port->bfad;
833a36c61f9SKrishna Gudipati 	struct bfa_lport_attr_s port_attr;
834a36c61f9SKrishna Gudipati 	char symname[BFA_SYMNAME_MAXLEN];
8357725ccfdSJing Huang 
836a36c61f9SKrishna Gudipati 	bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
837*973464fdSAzeem Shaikh 	strscpy(symname, port_attr.port_cfg.sym_name.symname,
838a36c61f9SKrishna Gudipati 			BFA_SYMNAME_MAXLEN);
8392245ea91SYang Guang 	return sysfs_emit(buf, "%s\n", symname);
8407725ccfdSJing Huang }
8417725ccfdSJing Huang 
8427725ccfdSJing Huang static ssize_t
bfad_im_hw_version_show(struct device * dev,struct device_attribute * attr,char * buf)8437725ccfdSJing Huang bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,
8447725ccfdSJing Huang 				char *buf)
8457725ccfdSJing Huang {
8467725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
8477725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
8487725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
8497725ccfdSJing Huang 	struct bfad_s *bfad = im_port->bfad;
8500a4b1fc0SKrishna Gudipati 	char hw_ver[BFA_VERSION_LEN];
8517725ccfdSJing Huang 
8520a4b1fc0SKrishna Gudipati 	bfa_get_pci_chip_rev(&bfad->bfa, hw_ver);
8532245ea91SYang Guang 	return sysfs_emit(buf, "%s\n", hw_ver);
8547725ccfdSJing Huang }
8557725ccfdSJing Huang 
8567725ccfdSJing Huang static ssize_t
bfad_im_drv_version_show(struct device * dev,struct device_attribute * attr,char * buf)8577725ccfdSJing Huang bfad_im_drv_version_show(struct device *dev, struct device_attribute *attr,
8587725ccfdSJing Huang 				char *buf)
8597725ccfdSJing Huang {
8602245ea91SYang Guang 	return sysfs_emit(buf, "%s\n", BFAD_DRIVER_VERSION);
8617725ccfdSJing Huang }
8627725ccfdSJing Huang 
8637725ccfdSJing Huang static ssize_t
bfad_im_optionrom_version_show(struct device * dev,struct device_attribute * attr,char * buf)8647725ccfdSJing Huang bfad_im_optionrom_version_show(struct device *dev,
8657725ccfdSJing Huang 			 struct device_attribute *attr, char *buf)
8667725ccfdSJing Huang {
8677725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
8687725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
8697725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
8707725ccfdSJing Huang 	struct bfad_s *bfad = im_port->bfad;
8710a4b1fc0SKrishna Gudipati 	char optrom_ver[BFA_VERSION_LEN];
8727725ccfdSJing Huang 
8730a4b1fc0SKrishna Gudipati 	bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver);
8742245ea91SYang Guang 	return sysfs_emit(buf, "%s\n", optrom_ver);
8757725ccfdSJing Huang }
8767725ccfdSJing Huang 
8777725ccfdSJing Huang static ssize_t
bfad_im_fw_version_show(struct device * dev,struct device_attribute * attr,char * buf)8787725ccfdSJing Huang bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr,
8797725ccfdSJing Huang 				 char *buf)
8807725ccfdSJing Huang {
8817725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
8827725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
8837725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
8847725ccfdSJing Huang 	struct bfad_s *bfad = im_port->bfad;
8850a4b1fc0SKrishna Gudipati 	char fw_ver[BFA_VERSION_LEN];
8867725ccfdSJing Huang 
8870a4b1fc0SKrishna Gudipati 	bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver);
8882245ea91SYang Guang 	return sysfs_emit(buf, "%s\n", fw_ver);
8897725ccfdSJing Huang }
8907725ccfdSJing Huang 
8917725ccfdSJing Huang static ssize_t
bfad_im_num_of_ports_show(struct device * dev,struct device_attribute * attr,char * buf)8927725ccfdSJing Huang bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr,
8937725ccfdSJing Huang 				char *buf)
8947725ccfdSJing Huang {
8957725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
8967725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
8977725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
8987725ccfdSJing Huang 	struct bfad_s *bfad = im_port->bfad;
8997725ccfdSJing Huang 
9002245ea91SYang Guang 	return sysfs_emit(buf, "%d\n",
9010a4b1fc0SKrishna Gudipati 			bfa_get_nports(&bfad->bfa));
9027725ccfdSJing Huang }
9037725ccfdSJing Huang 
9047725ccfdSJing Huang static ssize_t
bfad_im_drv_name_show(struct device * dev,struct device_attribute * attr,char * buf)9057725ccfdSJing Huang bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr,
9067725ccfdSJing Huang 				char *buf)
9077725ccfdSJing Huang {
9082245ea91SYang Guang 	return sysfs_emit(buf, "%s\n", BFAD_DRIVER_NAME);
9097725ccfdSJing Huang }
9107725ccfdSJing Huang 
9117725ccfdSJing Huang static ssize_t
bfad_im_num_of_discovered_ports_show(struct device * dev,struct device_attribute * attr,char * buf)9127725ccfdSJing Huang bfad_im_num_of_discovered_ports_show(struct device *dev,
9137725ccfdSJing Huang 			struct device_attribute *attr, char *buf)
9147725ccfdSJing Huang {
9157725ccfdSJing Huang 	struct Scsi_Host *shost = class_to_shost(dev);
9167725ccfdSJing Huang 	struct bfad_im_port_s *im_port =
9177725ccfdSJing Huang 			(struct bfad_im_port_s *) shost->hostdata[0];
9187725ccfdSJing Huang 	struct bfad_port_s    *port = im_port->port;
9197725ccfdSJing Huang 	struct bfad_s         *bfad = im_port->bfad;
9207725ccfdSJing Huang 	int        nrports = 2048;
921ee1a4a42SKrishna Gudipati 	struct bfa_rport_qualifier_s *rports = NULL;
9227725ccfdSJing Huang 	unsigned long   flags;
9237725ccfdSJing Huang 
9246396bb22SKees Cook 	rports = kcalloc(nrports, sizeof(struct bfa_rport_qualifier_s),
925ee1a4a42SKrishna Gudipati 			 GFP_ATOMIC);
9267725ccfdSJing Huang 	if (rports == NULL)
9272245ea91SYang Guang 		return sysfs_emit(buf, "Failed\n");
9287725ccfdSJing Huang 
9297725ccfdSJing Huang 	spin_lock_irqsave(&bfad->bfad_lock, flags);
930ee1a4a42SKrishna Gudipati 	bfa_fcs_lport_get_rport_quals(port->fcs_port, rports, &nrports);
9317725ccfdSJing Huang 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
9327725ccfdSJing Huang 	kfree(rports);
9337725ccfdSJing Huang 
9342245ea91SYang Guang 	return sysfs_emit(buf, "%d\n", nrports);
9357725ccfdSJing Huang }
9367725ccfdSJing Huang 
9377725ccfdSJing Huang static          DEVICE_ATTR(serial_number, S_IRUGO,
9387725ccfdSJing Huang 				bfad_im_serial_num_show, NULL);
9397725ccfdSJing Huang static          DEVICE_ATTR(model, S_IRUGO, bfad_im_model_show, NULL);
9407725ccfdSJing Huang static          DEVICE_ATTR(model_description, S_IRUGO,
9417725ccfdSJing Huang 				bfad_im_model_desc_show, NULL);
9427725ccfdSJing Huang static          DEVICE_ATTR(node_name, S_IRUGO, bfad_im_node_name_show, NULL);
9437725ccfdSJing Huang static          DEVICE_ATTR(symbolic_name, S_IRUGO,
9447725ccfdSJing Huang 				bfad_im_symbolic_name_show, NULL);
9457725ccfdSJing Huang static          DEVICE_ATTR(hardware_version, S_IRUGO,
9467725ccfdSJing Huang 				bfad_im_hw_version_show, NULL);
9477725ccfdSJing Huang static          DEVICE_ATTR(driver_version, S_IRUGO,
9487725ccfdSJing Huang 				bfad_im_drv_version_show, NULL);
9497725ccfdSJing Huang static          DEVICE_ATTR(option_rom_version, S_IRUGO,
9507725ccfdSJing Huang 				bfad_im_optionrom_version_show, NULL);
9517725ccfdSJing Huang static          DEVICE_ATTR(firmware_version, S_IRUGO,
9527725ccfdSJing Huang 				bfad_im_fw_version_show, NULL);
9537725ccfdSJing Huang static          DEVICE_ATTR(number_of_ports, S_IRUGO,
9547725ccfdSJing Huang 				bfad_im_num_of_ports_show, NULL);
9557725ccfdSJing Huang static          DEVICE_ATTR(driver_name, S_IRUGO, bfad_im_drv_name_show, NULL);
9567725ccfdSJing Huang static          DEVICE_ATTR(number_of_discovered_ports, S_IRUGO,
9577725ccfdSJing Huang 				bfad_im_num_of_discovered_ports_show, NULL);
9587725ccfdSJing Huang 
959e73af234SBart Van Assche static struct attribute *bfad_im_host_attrs[] = {
960e73af234SBart Van Assche 	&dev_attr_serial_number.attr,
961e73af234SBart Van Assche 	&dev_attr_model.attr,
962e73af234SBart Van Assche 	&dev_attr_model_description.attr,
963e73af234SBart Van Assche 	&dev_attr_node_name.attr,
964e73af234SBart Van Assche 	&dev_attr_symbolic_name.attr,
965e73af234SBart Van Assche 	&dev_attr_hardware_version.attr,
966e73af234SBart Van Assche 	&dev_attr_driver_version.attr,
967e73af234SBart Van Assche 	&dev_attr_option_rom_version.attr,
968e73af234SBart Van Assche 	&dev_attr_firmware_version.attr,
969e73af234SBart Van Assche 	&dev_attr_number_of_ports.attr,
970e73af234SBart Van Assche 	&dev_attr_driver_name.attr,
971e73af234SBart Van Assche 	&dev_attr_number_of_discovered_ports.attr,
9727725ccfdSJing Huang 	NULL,
9737725ccfdSJing Huang };
9747725ccfdSJing Huang 
975e73af234SBart Van Assche static const struct attribute_group bfad_im_host_attr_group = {
976e73af234SBart Van Assche 	.attrs = bfad_im_host_attrs
977e73af234SBart Van Assche };
978e73af234SBart Van Assche 
979e73af234SBart Van Assche const struct attribute_group *bfad_im_host_groups[] = {
980e73af234SBart Van Assche 	&bfad_im_host_attr_group,
981e73af234SBart Van Assche 	NULL
982e73af234SBart Van Assche };
983e73af234SBart Van Assche 
98469e62379SBart Van Assche static struct attribute *bfad_im_vport_attrs[] = {
985e73af234SBart Van Assche 	&dev_attr_serial_number.attr,
986e73af234SBart Van Assche 	&dev_attr_model.attr,
987e73af234SBart Van Assche 	&dev_attr_model_description.attr,
988e73af234SBart Van Assche 	&dev_attr_node_name.attr,
989e73af234SBart Van Assche 	&dev_attr_symbolic_name.attr,
990e73af234SBart Van Assche 	&dev_attr_hardware_version.attr,
991e73af234SBart Van Assche 	&dev_attr_driver_version.attr,
992e73af234SBart Van Assche 	&dev_attr_option_rom_version.attr,
993e73af234SBart Van Assche 	&dev_attr_firmware_version.attr,
994e73af234SBart Van Assche 	&dev_attr_number_of_ports.attr,
995e73af234SBart Van Assche 	&dev_attr_driver_name.attr,
996e73af234SBart Van Assche 	&dev_attr_number_of_discovered_ports.attr,
9977725ccfdSJing Huang 	NULL,
9987725ccfdSJing Huang };
9997725ccfdSJing Huang 
1000e73af234SBart Van Assche static const struct attribute_group bfad_im_vport_attr_group = {
1001e73af234SBart Van Assche 	.attrs = bfad_im_vport_attrs
1002e73af234SBart Van Assche };
10037725ccfdSJing Huang 
1004e73af234SBart Van Assche const struct attribute_group *bfad_im_vport_groups[] = {
1005e73af234SBart Van Assche 	&bfad_im_vport_attr_group,
1006e73af234SBart Van Assche 	NULL
1007e73af234SBart Van Assche };
1008