Skip to content

Commit a714134

Browse files
Krishna GudipatiJames Bottomley
authored andcommitted
[SCSI] bfa: Added Fabric Assigned Address(FAA) support
- Updated/added data structures and definitions to support FAA protocol. - Modified the IOC state machine to support FAA. - Introduced FAA feature configuration - enable/disable/query. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 5a0adae commit a714134

12 files changed

Lines changed: 466 additions & 6 deletions

File tree

‎drivers/scsi/bfa/bfa.h‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,31 @@ struct bfa_hwif_s {
241241
};
242242
typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
243243

244+
struct bfa_faa_cbfn_s {
245+
bfa_cb_iocfc_t faa_cbfn;
246+
void *faa_cbarg;
247+
};
248+
249+
#define BFA_FAA_ENABLED 1
250+
#define BFA_FAA_DISABLED 2
251+
252+
/*
253+
* FAA attributes
254+
*/
255+
struct bfa_faa_attr_s {
256+
wwn_t faa;
257+
u8 faa_state;
258+
u8 pwwn_source;
259+
u8 rsvd[6];
260+
};
261+
262+
struct bfa_faa_args_s {
263+
struct bfa_faa_attr_s *faa_attr;
264+
struct bfa_faa_cbfn_s faa_cb;
265+
u8 faa_state;
266+
bfa_boolean_t busy;
267+
};
268+
244269
struct bfa_iocfc_s {
245270
struct bfa_s *bfa;
246271
struct bfa_iocfc_cfg_s cfg;
@@ -266,6 +291,7 @@ struct bfa_iocfc_s {
266291
bfa_cb_iocfc_t updateq_cbfn; /* bios callback function */
267292
void *updateq_cbarg; /* bios callback arg */
268293
u32 intr_mask;
294+
struct bfa_faa_args_s faa_args;
269295
};
270296

271297
#define bfa_lpuid(__bfa) \

‎drivers/scsi/bfa/bfa_core.c‎

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,181 @@ bfa_iocfc_reset_queues(struct bfa_s *bfa)
795795
}
796796
}
797797

798+
/* Fabric Assigned Address specific functions */
799+
800+
/*
801+
* Check whether IOC is ready before sending command down
802+
*/
803+
static bfa_status_t
804+
bfa_faa_validate_request(struct bfa_s *bfa)
805+
{
806+
enum bfa_ioc_type_e ioc_type = bfa_get_type(bfa);
807+
u32 card_type = bfa->ioc.attr->card_type;
808+
809+
if (bfa_ioc_is_operational(&bfa->ioc)) {
810+
if ((ioc_type != BFA_IOC_TYPE_FC) || bfa_mfg_is_mezz(card_type))
811+
return BFA_STATUS_FEATURE_NOT_SUPPORTED;
812+
} else {
813+
if (!bfa_ioc_is_acq_addr(&bfa->ioc))
814+
return BFA_STATUS_IOC_NON_OP;
815+
}
816+
817+
return BFA_STATUS_OK;
818+
}
819+
820+
bfa_status_t
821+
bfa_faa_enable(struct bfa_s *bfa, bfa_cb_iocfc_t cbfn, void *cbarg)
822+
{
823+
struct bfi_faa_en_dis_s faa_enable_req;
824+
struct bfa_iocfc_s *iocfc = &bfa->iocfc;
825+
bfa_status_t status;
826+
827+
iocfc->faa_args.faa_cb.faa_cbfn = cbfn;
828+
iocfc->faa_args.faa_cb.faa_cbarg = cbarg;
829+
830+
status = bfa_faa_validate_request(bfa);
831+
if (status != BFA_STATUS_OK)
832+
return status;
833+
834+
if (iocfc->faa_args.busy == BFA_TRUE)
835+
return BFA_STATUS_DEVBUSY;
836+
837+
if (iocfc->faa_args.faa_state == BFA_FAA_ENABLED)
838+
return BFA_STATUS_FAA_ENABLED;
839+
840+
if (bfa_fcport_is_trunk_enabled(bfa))
841+
return BFA_STATUS_ERROR_TRUNK_ENABLED;
842+
843+
bfa_fcport_cfg_faa(bfa, BFA_FAA_ENABLED);
844+
iocfc->faa_args.busy = BFA_TRUE;
845+
846+
memset(&faa_enable_req, 0, sizeof(struct bfi_faa_en_dis_s));
847+
bfi_h2i_set(faa_enable_req.mh, BFI_MC_IOCFC,
848+
BFI_IOCFC_H2I_FAA_ENABLE_REQ, bfa_lpuid(bfa));
849+
850+
bfa_ioc_mbox_send(&bfa->ioc, &faa_enable_req,
851+
sizeof(struct bfi_faa_en_dis_s));
852+
853+
return BFA_STATUS_OK;
854+
}
855+
856+
bfa_status_t
857+
bfa_faa_disable(struct bfa_s *bfa, bfa_cb_iocfc_t cbfn,
858+
void *cbarg)
859+
{
860+
struct bfi_faa_en_dis_s faa_disable_req;
861+
struct bfa_iocfc_s *iocfc = &bfa->iocfc;
862+
bfa_status_t status;
863+
864+
iocfc->faa_args.faa_cb.faa_cbfn = cbfn;
865+
iocfc->faa_args.faa_cb.faa_cbarg = cbarg;
866+
867+
status = bfa_faa_validate_request(bfa);
868+
if (status != BFA_STATUS_OK)
869+
return status;
870+
871+
if (iocfc->faa_args.busy == BFA_TRUE)
872+
return BFA_STATUS_DEVBUSY;
873+
874+
if (iocfc->faa_args.faa_state == BFA_FAA_DISABLED)
875+
return BFA_STATUS_FAA_DISABLED;
876+
877+
bfa_fcport_cfg_faa(bfa, BFA_FAA_DISABLED);
878+
iocfc->faa_args.busy = BFA_TRUE;
879+
880+
memset(&faa_disable_req, 0, sizeof(struct bfi_faa_en_dis_s));
881+
bfi_h2i_set(faa_disable_req.mh, BFI_MC_IOCFC,
882+
BFI_IOCFC_H2I_FAA_DISABLE_REQ, bfa_lpuid(bfa));
883+
884+
bfa_ioc_mbox_send(&bfa->ioc, &faa_disable_req,
885+
sizeof(struct bfi_faa_en_dis_s));
886+
887+
return BFA_STATUS_OK;
888+
}
889+
890+
bfa_status_t
891+
bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr,
892+
bfa_cb_iocfc_t cbfn, void *cbarg)
893+
{
894+
struct bfi_faa_query_s faa_attr_req;
895+
struct bfa_iocfc_s *iocfc = &bfa->iocfc;
896+
bfa_status_t status;
897+
898+
iocfc->faa_args.faa_attr = attr;
899+
iocfc->faa_args.faa_cb.faa_cbfn = cbfn;
900+
iocfc->faa_args.faa_cb.faa_cbarg = cbarg;
901+
902+
status = bfa_faa_validate_request(bfa);
903+
if (status != BFA_STATUS_OK)
904+
return status;
905+
906+
if (iocfc->faa_args.busy == BFA_TRUE)
907+
return BFA_STATUS_DEVBUSY;
908+
909+
iocfc->faa_args.busy = BFA_TRUE;
910+
memset(&faa_attr_req, 0, sizeof(struct bfi_faa_query_s));
911+
bfi_h2i_set(faa_attr_req.mh, BFI_MC_IOCFC,
912+
BFI_IOCFC_H2I_FAA_QUERY_REQ, bfa_lpuid(bfa));
913+
914+
bfa_ioc_mbox_send(&bfa->ioc, &faa_attr_req,
915+
sizeof(struct bfi_faa_query_s));
916+
917+
return BFA_STATUS_OK;
918+
}
919+
920+
/*
921+
* FAA enable response
922+
*/
923+
static void
924+
bfa_faa_enable_reply(struct bfa_iocfc_s *iocfc,
925+
struct bfi_faa_en_dis_rsp_s *rsp)
926+
{
927+
void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg;
928+
bfa_status_t status = rsp->status;
929+
930+
WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn);
931+
932+
iocfc->faa_args.faa_cb.faa_cbfn(cbarg, status);
933+
iocfc->faa_args.busy = BFA_FALSE;
934+
}
935+
936+
/*
937+
* FAA disable response
938+
*/
939+
static void
940+
bfa_faa_disable_reply(struct bfa_iocfc_s *iocfc,
941+
struct bfi_faa_en_dis_rsp_s *rsp)
942+
{
943+
void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg;
944+
bfa_status_t status = rsp->status;
945+
946+
WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn);
947+
948+
iocfc->faa_args.faa_cb.faa_cbfn(cbarg, status);
949+
iocfc->faa_args.busy = BFA_FALSE;
950+
}
951+
952+
/*
953+
* FAA query response
954+
*/
955+
static void
956+
bfa_faa_query_reply(struct bfa_iocfc_s *iocfc,
957+
bfi_faa_query_rsp_t *rsp)
958+
{
959+
void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg;
960+
961+
if (iocfc->faa_args.faa_attr) {
962+
iocfc->faa_args.faa_attr->faa = rsp->faa;
963+
iocfc->faa_args.faa_attr->faa_state = rsp->faa_status;
964+
iocfc->faa_args.faa_attr->pwwn_source = rsp->addr_source;
965+
}
966+
967+
WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn);
968+
969+
iocfc->faa_args.faa_cb.faa_cbfn(cbarg, BFA_STATUS_OK);
970+
iocfc->faa_args.busy = BFA_FALSE;
971+
}
972+
798973
/*
799974
* IOC enable request is complete
800975
*/
@@ -803,6 +978,12 @@ bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status)
803978
{
804979
struct bfa_s *bfa = bfa_arg;
805980

981+
if (status == BFA_STATUS_FAA_ACQ_ADDR) {
982+
bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
983+
bfa_iocfc_init_cb, bfa);
984+
return;
985+
}
986+
806987
if (status != BFA_STATUS_OK) {
807988
bfa_isr_disable(bfa);
808989
if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
@@ -968,6 +1149,17 @@ bfa_iocfc_isr(void *bfaarg, struct bfi_mbmsg_s *m)
9681149
case BFI_IOCFC_I2H_UPDATEQ_RSP:
9691150
iocfc->updateq_cbfn(iocfc->updateq_cbarg, BFA_STATUS_OK);
9701151
break;
1152+
case BFI_IOCFC_I2H_FAA_ENABLE_RSP:
1153+
bfa_faa_enable_reply(iocfc,
1154+
(struct bfi_faa_en_dis_rsp_s *)msg);
1155+
break;
1156+
case BFI_IOCFC_I2H_FAA_DISABLE_RSP:
1157+
bfa_faa_disable_reply(iocfc,
1158+
(struct bfi_faa_en_dis_rsp_s *)msg);
1159+
break;
1160+
case BFI_IOCFC_I2H_FAA_QUERY_RSP:
1161+
bfa_faa_query_reply(iocfc, (bfi_faa_query_rsp_t *)msg);
1162+
break;
9711163
default:
9721164
WARN_ON(1);
9731165
}

‎drivers/scsi/bfa/bfa_defs.h‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ enum bfa_status {
145145
BFA_STATUS_IOC_FAILURE = 56, /* IOC failure - Retry, if persists
146146
* contact support */
147147
BFA_STATUS_INVALID_WWN = 57, /* Invalid WWN */
148+
BFA_STATUS_IOC_NON_OP = 61, /* IOC is not operational */
148149
BFA_STATUS_VERSION_FAIL = 70, /* Application/Driver version mismatch */
149150
BFA_STATUS_DIAG_BUSY = 71, /* diag busy */
150151
BFA_STATUS_ENOFSAVE = 78, /* No saved firmware trace */
@@ -157,6 +158,12 @@ enum bfa_status {
157158
BFA_STATUS_TRUNK_DISABLED = 165, /* Trunking is disabled on
158159
* the adapter */
159160
BFA_STATUS_IOPROFILE_OFF = 175, /* IO profile OFF */
161+
BFA_STATUS_FEATURE_NOT_SUPPORTED = 192, /* Feature not supported */
162+
BFA_STATUS_FAA_ENABLED = 197, /* FAA is already enabled */
163+
BFA_STATUS_FAA_DISABLED = 198, /* FAA is already disabled */
164+
BFA_STATUS_FAA_ACQUIRED = 199, /* FAA is already acquired */
165+
BFA_STATUS_FAA_ACQ_ADDR = 200, /* Acquiring addr */
166+
BFA_STATUS_ERROR_TRUNK_ENABLED = 203, /* Trunk enabled on adapter */
160167
BFA_STATUS_MAX_VAL /* Unknown error code */
161168
};
162169
#define bfa_status_t enum bfa_status
@@ -275,6 +282,7 @@ enum bfa_ioc_state {
275282
BFA_IOC_FWMISMATCH = 11, /* IOC f/w different from drivers */
276283
BFA_IOC_ENABLING = 12, /* IOC is being enabled */
277284
BFA_IOC_HWFAIL = 13, /* PCI mapping doesn't exist */
285+
BFA_IOC_ACQ_ADDR = 14, /* Acquiring addr from fabric */
278286
};
279287

280288
/*
@@ -455,10 +463,7 @@ enum bfa_port_speed {
455463
BFA_PORT_SPEED_8GBPS = 8,
456464
BFA_PORT_SPEED_10GBPS = 10,
457465
BFA_PORT_SPEED_16GBPS = 16,
458-
BFA_PORT_SPEED_AUTO =
459-
(BFA_PORT_SPEED_1GBPS | BFA_PORT_SPEED_2GBPS |
460-
BFA_PORT_SPEED_4GBPS | BFA_PORT_SPEED_8GBPS |
461-
BFA_PORT_SPEED_16GBPS),
466+
BFA_PORT_SPEED_AUTO = 0xf,
462467
};
463468
#define bfa_port_speed_t enum bfa_port_speed
464469

‎drivers/scsi/bfa/bfa_defs_svc.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ enum bfa_port_states {
635635
BFA_PORT_ST_FWMISMATCH = 12,
636636
BFA_PORT_ST_PREBOOT_DISABLED = 13,
637637
BFA_PORT_ST_TOGGLING_QWAIT = 14,
638+
BFA_PORT_ST_ACQ_ADDR = 15,
638639
BFA_PORT_ST_MAX_STATE,
639640
};
640641

@@ -748,7 +749,8 @@ struct bfa_port_cfg_s {
748749
u8 ratelimit; /* ratelimit enabled or not */
749750
u8 trl_def_speed; /* ratelimit default speed */
750751
u8 bb_scn;
751-
u8 rsvd[3];
752+
u8 faa_state; /* FAA enabled/disabled */
753+
u8 rsvd[2];
752754
u16 path_tov; /* device path timeout */
753755
u16 q_depth; /* SCSI Queue depth */
754756
};

0 commit comments

Comments
 (0)