^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2014- QLogic Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * All rights reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * www.qlogic.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * bfa_attr.c Linux driver configuration interface module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "bfad_drv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "bfad_im.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * FC transport template entry, get SCSI target port ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) bfad_im_get_starget_port_id(struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct bfad_im_port_s *im_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct bfad_s *bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct bfad_itnim_s *itnim = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) u32 fc_id = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) shost = dev_to_shost(starget->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) im_port = (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) itnim = bfad_get_itnim(im_port, starget->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) if (itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) fc_id = bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) fc_starget_port_id(starget) = fc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * FC transport template entry, get SCSI target nwwn.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) bfad_im_get_starget_node_name(struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct bfad_im_port_s *im_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct bfad_s *bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct bfad_itnim_s *itnim = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) u64 node_name = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) shost = dev_to_shost(starget->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) im_port = (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) itnim = bfad_get_itnim(im_port, starget->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) node_name = bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) fc_starget_node_name(starget) = cpu_to_be64(node_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * FC transport template entry, get SCSI target pwwn.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) bfad_im_get_starget_port_name(struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct bfad_im_port_s *im_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct bfad_s *bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct bfad_itnim_s *itnim = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) u64 port_name = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) shost = dev_to_shost(starget->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) im_port = (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) itnim = bfad_get_itnim(im_port, starget->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if (itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) port_name = bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) fc_starget_port_name(starget) = cpu_to_be64(port_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * FC transport template entry, get SCSI host port ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) bfad_im_get_host_port_id(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct bfad_port_s *port = im_port->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) fc_host_port_id(shost) =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) bfa_hton3b(bfa_fcs_lport_get_fcid(port->fcs_port));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * FC transport template entry, get SCSI host port type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) bfad_im_get_host_port_type(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct bfa_lport_attr_s port_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) switch (port_attr.port_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) case BFA_PORT_TYPE_NPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) case BFA_PORT_TYPE_NLPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) case BFA_PORT_TYPE_P2P:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) fc_host_port_type(shost) = FC_PORTTYPE_PTP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) case BFA_PORT_TYPE_LPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * FC transport template entry, get SCSI host port state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) bfad_im_get_host_port_state(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct bfa_port_attr_s attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) bfa_fcport_get_attr(&bfad->bfa, &attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) switch (attr.port_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) case BFA_PORT_ST_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) case BFA_PORT_ST_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) case BFA_PORT_ST_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) case BFA_PORT_ST_STOPPED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) case BFA_PORT_ST_IOCDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) case BFA_PORT_ST_IOCDIS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) case BFA_PORT_ST_UNINIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) case BFA_PORT_ST_ENABLING_QWAIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) case BFA_PORT_ST_ENABLING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) case BFA_PORT_ST_DISABLING_QWAIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) case BFA_PORT_ST_DISABLING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * FC transport template entry, get SCSI host active fc4s.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) bfad_im_get_host_active_fc4s(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct bfad_port_s *port = im_port->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) memset(fc_host_active_fc4s(shost), 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) sizeof(fc_host_active_fc4s(shost)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (port->supported_fc4s & BFA_LPORT_ROLE_FCP_IM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) fc_host_active_fc4s(shost)[2] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) fc_host_active_fc4s(shost)[7] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * FC transport template entry, get SCSI host link speed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) bfad_im_get_host_speed(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct bfa_port_attr_s attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) bfa_fcport_get_attr(&bfad->bfa, &attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) switch (attr.speed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) case BFA_PORT_SPEED_10GBPS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) case BFA_PORT_SPEED_16GBPS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) fc_host_speed(shost) = FC_PORTSPEED_16GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) case BFA_PORT_SPEED_8GBPS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) case BFA_PORT_SPEED_4GBPS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) case BFA_PORT_SPEED_2GBPS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) case BFA_PORT_SPEED_1GBPS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * FC transport template entry, get SCSI host port type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) bfad_im_get_host_fabric_name(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct bfad_port_s *port = im_port->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) wwn_t fabric_nwwn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) fabric_nwwn = bfa_fcs_lport_get_fabric_name(port->fcs_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) fc_host_fabric_name(shost) = cpu_to_be64(fabric_nwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * FC transport template entry, get BFAD statistics.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static struct fc_host_statistics *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) bfad_im_get_stats(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct bfad_hal_comp fcomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) union bfa_port_stats_u *fcstats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct fc_host_statistics *hstats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) bfa_status_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) fcstats = kzalloc(sizeof(union bfa_port_stats_u), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) if (fcstats == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) hstats = &bfad->link_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) init_completion(&fcomp.comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) memset(hstats, 0, sizeof(struct fc_host_statistics));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) rc = bfa_port_get_stats(BFA_FCPORT(&bfad->bfa),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) fcstats, bfad_hcb_comp, &fcomp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) if (rc != BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) kfree(fcstats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) wait_for_completion(&fcomp.comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) /* Fill the fc_host_statistics structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) hstats->seconds_since_last_reset = fcstats->fc.secs_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) hstats->tx_frames = fcstats->fc.tx_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) hstats->tx_words = fcstats->fc.tx_words;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) hstats->rx_frames = fcstats->fc.rx_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) hstats->rx_words = fcstats->fc.rx_words;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) hstats->lip_count = fcstats->fc.lip_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) hstats->nos_count = fcstats->fc.nos_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) hstats->error_frames = fcstats->fc.error_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) hstats->dumped_frames = fcstats->fc.dropped_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) hstats->link_failure_count = fcstats->fc.link_failures;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) hstats->loss_of_sync_count = fcstats->fc.loss_of_syncs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) hstats->loss_of_signal_count = fcstats->fc.loss_of_signals;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) hstats->prim_seq_protocol_err_count = fcstats->fc.primseq_errs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) hstats->invalid_crc_count = fcstats->fc.invalid_crcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) kfree(fcstats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return hstats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * FC transport template entry, reset BFAD statistics.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) bfad_im_reset_stats(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) struct bfad_hal_comp fcomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) bfa_status_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) init_completion(&fcomp.comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) rc = bfa_port_clear_stats(BFA_FCPORT(&bfad->bfa), bfad_hcb_comp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) &fcomp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) if (rc != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) wait_for_completion(&fcomp.comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * FC transport template entry, set rport loss timeout.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) * Update dev_loss_tmo based on the value pushed down by the stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * In case it is lesser than path_tov of driver, set it to path_tov + 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) * to ensure that the driver times out before the application
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) bfad_im_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) struct bfad_itnim_data_s *itnim_data = rport->dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) struct bfad_itnim_s *itnim = itnim_data->itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) struct bfad_s *bfad = itnim->im->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) uint16_t path_tov = bfa_fcpim_path_tov_get(&bfad->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) rport->dev_loss_tmo = timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) if (timeout < path_tov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) rport->dev_loss_tmo = path_tov + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) bfad_im_vport_create(struct fc_vport *fc_vport, bool disable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) char *vname = fc_vport->symbolic_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) struct Scsi_Host *shost = fc_vport->shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) struct bfa_lport_cfg_s port_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) struct bfad_vport_s *vp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) int status = 0, rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) memset(&port_cfg, 0, sizeof(port_cfg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) u64_to_wwn(fc_vport->node_name, (u8 *)&port_cfg.nwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) u64_to_wwn(fc_vport->port_name, (u8 *)&port_cfg.pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) if (strlen(vname) > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) strcpy((char *)&port_cfg.sym_name, vname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) port_cfg.roles = BFA_LPORT_ROLE_FCP_IM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) list_for_each_entry(vp, &bfad->pbc_vport_list, list_entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) if (port_cfg.pwwn ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) vp->fcs_vport.lport.port_cfg.pwwn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) port_cfg.preboot_vp =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) vp->fcs_vport.lport.port_cfg.preboot_vp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) rc = bfad_vport_create(bfad, 0, &port_cfg, &fc_vport->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) if (rc == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) struct bfad_vport_s *vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) struct bfa_fcs_vport_s *fcs_vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) struct Scsi_Host *vshost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) port_cfg.pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) if (fcs_vport == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) return VPCERR_BAD_WWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) fc_vport_set_state(fc_vport, FC_VPORT_ACTIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) if (disable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) bfa_fcs_vport_stop(fcs_vport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) fc_vport_set_state(fc_vport, FC_VPORT_DISABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) vport = fcs_vport->vport_drv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) vshost = vport->drv_port.im_port->shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) fc_host_node_name(vshost) = wwn_to_u64((u8 *)&port_cfg.nwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) fc_host_port_name(vshost) = wwn_to_u64((u8 *)&port_cfg.pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) fc_host_supported_classes(vshost) = FC_COS_CLASS3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) memset(fc_host_supported_fc4s(vshost), 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) sizeof(fc_host_supported_fc4s(vshost)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) /* For FCP type 0x08 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) if (supported_fc4s & BFA_LPORT_ROLE_FCP_IM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) fc_host_supported_fc4s(vshost)[2] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) /* For fibre channel services type 0x20 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) fc_host_supported_fc4s(vshost)[7] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) fc_host_supported_speeds(vshost) =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) bfad_im_supported_speeds(&bfad->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) fc_host_maxframe_size(vshost) =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) bfa_fcport_get_maxfrsize(&bfad->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) fc_vport->dd_data = vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) vport->drv_port.im_port->fc_vport = fc_vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) } else if (rc == BFA_STATUS_INVALID_WWN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) return VPCERR_BAD_WWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) else if (rc == BFA_STATUS_VPORT_EXISTS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) return VPCERR_BAD_WWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) else if (rc == BFA_STATUS_VPORT_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) return VPCERR_NO_FABRIC_SUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) else if (rc == BFA_STATUS_VPORT_WWN_BP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) return VPCERR_BAD_WWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) return FC_VPORT_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) bfad_im_issue_fc_host_lip(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) struct bfad_hal_comp fcomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) uint32_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) init_completion(&fcomp.comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) status = bfa_port_disable(&bfad->bfa.modules.port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) bfad_hcb_comp, &fcomp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) if (status != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) wait_for_completion(&fcomp.comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) if (fcomp.status != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) status = bfa_port_enable(&bfad->bfa.modules.port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) bfad_hcb_comp, &fcomp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) if (status != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) wait_for_completion(&fcomp.comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) if (fcomp.status != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) bfad_im_vport_delete(struct fc_vport *fc_vport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) struct bfad_vport_s *vport = (struct bfad_vport_s *)fc_vport->dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) (struct bfad_im_port_s *) vport->drv_port.im_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) struct bfa_fcs_vport_s *fcs_vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) struct Scsi_Host *vshost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) wwn_t pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) struct completion fcomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) if (im_port->flags & BFAD_PORT_DELETE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) bfad_scsi_host_free(bfad, im_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) list_del(&vport->list_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) kfree(vport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) vshost = vport->drv_port.im_port->shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) u64_to_wwn(fc_host_port_name(vshost), (u8 *)&pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) if (fcs_vport == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) return VPCERR_BAD_WWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) vport->drv_port.flags |= BFAD_PORT_DELETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) vport->comp_del = &fcomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) init_completion(vport->comp_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) rc = bfa_fcs_vport_delete(&vport->fcs_vport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) if (rc == BFA_STATUS_PBC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) vport->drv_port.flags &= ~BFAD_PORT_DELETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) vport->comp_del = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) wait_for_completion(vport->comp_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) bfad_scsi_host_free(bfad, im_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) list_del(&vport->list_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) kfree(vport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) bfad_im_vport_disable(struct fc_vport *fc_vport, bool disable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) struct bfad_vport_s *vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) struct bfad_s *bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) struct bfa_fcs_vport_s *fcs_vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) struct Scsi_Host *vshost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) wwn_t pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) vport = (struct bfad_vport_s *)fc_vport->dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) bfad = vport->drv_port.bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) vshost = vport->drv_port.im_port->shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) u64_to_wwn(fc_host_port_name(vshost), (u8 *)&pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) if (fcs_vport == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) return VPCERR_BAD_WWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) if (disable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) bfa_fcs_vport_stop(fcs_vport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) fc_vport_set_state(fc_vport, FC_VPORT_DISABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) bfa_fcs_vport_start(fcs_vport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) fc_vport_set_state(fc_vport, FC_VPORT_ACTIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) bfad_im_vport_set_symbolic_name(struct fc_vport *fc_vport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) struct bfad_vport_s *vport = (struct bfad_vport_s *)fc_vport->dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) (struct bfad_im_port_s *)vport->drv_port.im_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) struct Scsi_Host *vshost = vport->drv_port.im_port->shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) char *sym_name = fc_vport->symbolic_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) struct bfa_fcs_vport_s *fcs_vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) wwn_t pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) u64_to_wwn(fc_host_port_name(vshost), (u8 *)&pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) if (fcs_vport == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) if (strlen(sym_name) > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) bfa_fcs_lport_set_symname(&fcs_vport->lport, sym_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) struct fc_function_template bfad_im_fc_function_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) /* Target dynamic attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) .get_starget_port_id = bfad_im_get_starget_port_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) .show_starget_port_id = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) .get_starget_node_name = bfad_im_get_starget_node_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) .show_starget_node_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) .get_starget_port_name = bfad_im_get_starget_port_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) .show_starget_port_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) /* Host dynamic attribute */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) .get_host_port_id = bfad_im_get_host_port_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) .show_host_port_id = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) /* Host fixed attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) .show_host_node_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) .show_host_port_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) .show_host_supported_classes = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) .show_host_supported_fc4s = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) .show_host_supported_speeds = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) .show_host_maxframe_size = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) /* More host dynamic attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) .show_host_port_type = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) .get_host_port_type = bfad_im_get_host_port_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) .show_host_port_state = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) .get_host_port_state = bfad_im_get_host_port_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) .show_host_active_fc4s = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) .get_host_active_fc4s = bfad_im_get_host_active_fc4s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) .show_host_speed = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) .get_host_speed = bfad_im_get_host_speed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) .show_host_fabric_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) .get_host_fabric_name = bfad_im_get_host_fabric_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) .show_host_symbolic_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) /* Statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) .get_fc_host_stats = bfad_im_get_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) .reset_fc_host_stats = bfad_im_reset_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) /* Allocation length for host specific data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) .dd_fcrport_size = sizeof(struct bfad_itnim_data_s *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) /* Remote port fixed attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) .show_rport_maxframe_size = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) .show_rport_supported_classes = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) .show_rport_dev_loss_tmo = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) .set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) .issue_fc_host_lip = bfad_im_issue_fc_host_lip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) .vport_create = bfad_im_vport_create,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) .vport_delete = bfad_im_vport_delete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) .vport_disable = bfad_im_vport_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) .set_vport_symbolic_name = bfad_im_vport_set_symbolic_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) .bsg_request = bfad_im_bsg_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) .bsg_timeout = bfad_im_bsg_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) struct fc_function_template bfad_im_vport_fc_function_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) /* Target dynamic attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) .get_starget_port_id = bfad_im_get_starget_port_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) .show_starget_port_id = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) .get_starget_node_name = bfad_im_get_starget_node_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) .show_starget_node_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) .get_starget_port_name = bfad_im_get_starget_port_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) .show_starget_port_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) /* Host dynamic attribute */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) .get_host_port_id = bfad_im_get_host_port_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) .show_host_port_id = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) /* Host fixed attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) .show_host_node_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) .show_host_port_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) .show_host_supported_classes = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) .show_host_supported_fc4s = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) .show_host_supported_speeds = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) .show_host_maxframe_size = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) /* More host dynamic attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) .show_host_port_type = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) .get_host_port_type = bfad_im_get_host_port_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) .show_host_port_state = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) .get_host_port_state = bfad_im_get_host_port_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) .show_host_active_fc4s = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) .get_host_active_fc4s = bfad_im_get_host_active_fc4s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) .show_host_speed = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) .get_host_speed = bfad_im_get_host_speed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) .show_host_fabric_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) .get_host_fabric_name = bfad_im_get_host_fabric_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) .show_host_symbolic_name = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) /* Statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) .get_fc_host_stats = bfad_im_get_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) .reset_fc_host_stats = bfad_im_reset_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) /* Allocation length for host specific data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) .dd_fcrport_size = sizeof(struct bfad_itnim_data_s *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) /* Remote port fixed attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) .show_rport_maxframe_size = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) .show_rport_supported_classes = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) .show_rport_dev_loss_tmo = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) .set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) * Scsi_Host_attrs SCSI host attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) bfa_get_adapter_serial_num(&bfad->bfa, serial_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) return snprintf(buf, PAGE_SIZE, "%s\n", serial_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) bfad_im_model_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) char model[BFA_ADAPTER_MODEL_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) bfa_get_adapter_model(&bfad->bfa, model);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) return snprintf(buf, PAGE_SIZE, "%s\n", model);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) char model[BFA_ADAPTER_MODEL_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) int nports = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) bfa_get_adapter_model(&bfad->bfa, model);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) nports = bfa_get_nports(&bfad->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) if (!strcmp(model, "QLogic-425"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) "QLogic BR-series 4Gbps PCIe dual port FC HBA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) else if (!strcmp(model, "QLogic-825"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) "QLogic BR-series 8Gbps PCIe dual port FC HBA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) else if (!strcmp(model, "QLogic-42B"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) "QLogic BR-series 4Gbps PCIe dual port FC HBA for HP");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) else if (!strcmp(model, "QLogic-82B"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) "QLogic BR-series 8Gbps PCIe dual port FC HBA for HP");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) else if (!strcmp(model, "QLogic-1010"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) "QLogic BR-series 10Gbps single port CNA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) else if (!strcmp(model, "QLogic-1020"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) "QLogic BR-series 10Gbps dual port CNA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) else if (!strcmp(model, "QLogic-1007"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) "QLogic BR-series 10Gbps CNA for IBM Blade Center");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) else if (!strcmp(model, "QLogic-415"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) "QLogic BR-series 4Gbps PCIe single port FC HBA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) else if (!strcmp(model, "QLogic-815"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) "QLogic BR-series 8Gbps PCIe single port FC HBA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) else if (!strcmp(model, "QLogic-41B"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) "QLogic BR-series 4Gbps PCIe single port FC HBA for HP");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) else if (!strcmp(model, "QLogic-81B"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) "QLogic BR-series 8Gbps PCIe single port FC HBA for HP");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) else if (!strcmp(model, "QLogic-804"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) "QLogic BR-series 8Gbps FC HBA for HP Bladesystem C-class");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) else if (!strcmp(model, "QLogic-1741"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) "QLogic BR-series 10Gbps CNA for Dell M-Series Blade Servers");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) else if (strstr(model, "QLogic-1860")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) if (nports == 1 && bfa_ioc_is_cna(&bfad->bfa.ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) "QLogic BR-series 10Gbps single port CNA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) else if (nports == 1 && !bfa_ioc_is_cna(&bfad->bfa.ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) "QLogic BR-series 16Gbps PCIe single port FC HBA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) else if (nports == 2 && bfa_ioc_is_cna(&bfad->bfa.ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) "QLogic BR-series 10Gbps dual port CNA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) else if (nports == 2 && !bfa_ioc_is_cna(&bfad->bfa.ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) "QLogic BR-series 16Gbps PCIe dual port FC HBA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) } else if (!strcmp(model, "QLogic-1867")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) if (nports == 1 && !bfa_ioc_is_cna(&bfad->bfa.ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) "QLogic BR-series 16Gbps PCIe single port FC HBA for IBM");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) else if (nports == 2 && !bfa_ioc_is_cna(&bfad->bfa.ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) "QLogic BR-series 16Gbps PCIe dual port FC HBA for IBM");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) "Invalid Model");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) return snprintf(buf, PAGE_SIZE, "%s\n", model_descr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) bfad_im_node_name_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) struct bfad_port_s *port = im_port->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) u64 nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) nwwn = bfa_fcs_lport_get_nwwn(port->fcs_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) return snprintf(buf, PAGE_SIZE, "0x%llx\n", cpu_to_be64(nwwn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) struct bfa_lport_attr_s port_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) char symname[BFA_SYMNAME_MAXLEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) strlcpy(symname, port_attr.port_cfg.sym_name.symname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) BFA_SYMNAME_MAXLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) return snprintf(buf, PAGE_SIZE, "%s\n", symname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) char hw_ver[BFA_VERSION_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) bfa_get_pci_chip_rev(&bfad->bfa, hw_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) return snprintf(buf, PAGE_SIZE, "%s\n", hw_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) bfad_im_drv_version_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) bfad_im_optionrom_version_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) char optrom_ver[BFA_VERSION_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) return snprintf(buf, PAGE_SIZE, "%s\n", optrom_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) char fw_ver[BFA_VERSION_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) return snprintf(buf, PAGE_SIZE, "%s\n", fw_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) return snprintf(buf, PAGE_SIZE, "%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) bfa_get_nports(&bfad->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) bfad_im_num_of_discovered_ports_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) struct bfad_im_port_s *im_port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) (struct bfad_im_port_s *) shost->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) struct bfad_port_s *port = im_port->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) struct bfad_s *bfad = im_port->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) int nrports = 2048;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) struct bfa_rport_qualifier_s *rports = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) rports = kcalloc(nrports, sizeof(struct bfa_rport_qualifier_s),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) if (rports == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) return snprintf(buf, PAGE_SIZE, "Failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) spin_lock_irqsave(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) bfa_fcs_lport_get_rport_quals(port->fcs_port, rports, &nrports);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) spin_unlock_irqrestore(&bfad->bfad_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) kfree(rports);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) return snprintf(buf, PAGE_SIZE, "%d\n", nrports);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) static DEVICE_ATTR(serial_number, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) bfad_im_serial_num_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) static DEVICE_ATTR(model, S_IRUGO, bfad_im_model_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) static DEVICE_ATTR(model_description, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) bfad_im_model_desc_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) static DEVICE_ATTR(node_name, S_IRUGO, bfad_im_node_name_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) static DEVICE_ATTR(symbolic_name, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) bfad_im_symbolic_name_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) static DEVICE_ATTR(hardware_version, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) bfad_im_hw_version_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) static DEVICE_ATTR(driver_version, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) bfad_im_drv_version_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) static DEVICE_ATTR(option_rom_version, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) bfad_im_optionrom_version_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) static DEVICE_ATTR(firmware_version, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) bfad_im_fw_version_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) static DEVICE_ATTR(number_of_ports, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) bfad_im_num_of_ports_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) static DEVICE_ATTR(driver_name, S_IRUGO, bfad_im_drv_name_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) static DEVICE_ATTR(number_of_discovered_ports, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) bfad_im_num_of_discovered_ports_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) struct device_attribute *bfad_im_host_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) &dev_attr_serial_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) &dev_attr_model,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) &dev_attr_model_description,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) &dev_attr_node_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) &dev_attr_symbolic_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) &dev_attr_hardware_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) &dev_attr_driver_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) &dev_attr_option_rom_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) &dev_attr_firmware_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) &dev_attr_number_of_ports,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) &dev_attr_driver_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) &dev_attr_number_of_discovered_ports,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) struct device_attribute *bfad_im_vport_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) &dev_attr_serial_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) &dev_attr_model,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) &dev_attr_model_description,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) &dev_attr_node_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) &dev_attr_symbolic_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) &dev_attr_hardware_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) &dev_attr_driver_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) &dev_attr_option_rom_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) &dev_attr_firmware_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) &dev_attr_number_of_ports,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) &dev_attr_driver_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) &dev_attr_number_of_discovered_ports,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991)