Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bbe37a67 authored by Vijaya Mohan Guvva's avatar Vijaya Mohan Guvva Committed by James Bottomley
Browse files

[SCSI] bfa: Support for FC BB credit recovery



This patch includes changes to  1) Enable/disable fc credit recovery on
Brocade FC adapter port operating at max supported speed. 2) Get credit
recovery status and stats related to credit loss and recovered credits

Signed-off-by: default avatarVijaya Mohan Guvva <vmohan@brocade.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 32d3d793
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -185,6 +185,8 @@ enum bfa_status {
	BFA_STATUS_FAA_DISABLED = 198,	/* FAA is already disabled */
	BFA_STATUS_FAA_ACQUIRED = 199,	/* FAA is already acquired */
	BFA_STATUS_FAA_ACQ_ADDR = 200,	/* Acquiring addr */
	BFA_STATUS_BBCR_FC_ONLY = 201, /*!< BBCredit Recovery is supported for *
					* FC mode only */
	BFA_STATUS_ERROR_TRUNK_ENABLED = 203,	/* Trunk enabled on adapter */
	BFA_STATUS_MAX_ENTRY_REACHED = 212,	/* MAX entry reached */
	BFA_STATUS_TOPOLOGY_LOOP = 230, /* Topology is set to Loop */
@@ -198,6 +200,14 @@ enum bfa_status {
	BFA_STATUS_CMD_NOTSUPP_MEZZ = 239, /* Cmd not supported for MEZZ card */
	BFA_STATUS_FRU_NOT_PRESENT = 240, /* fru module not present */
	BFA_STATUS_DPORT_ERR = 245,	/* D-port mode is enabled */
	BFA_STATUS_ERR_BBCR_SPEED_UNSUPPORT = 258, /*!< BB credit recovery is
					* supported at max port speed alone */
	BFA_STATUS_ERROR_BBCR_ENABLED  = 259, /*!< BB credit recovery
					* is enabled */
	BFA_STATUS_INVALID_BBSCN = 260, /*!< Invalid BBSCN value.
					 * Valid range is [1-15] */
	BFA_STATUS_BBCR_CFG_NO_CHANGE = 265, /*!< BBCR is operational.
			* Disable BBCR and try this operation again. */
	BFA_STATUS_MAX_VAL		/* Unknown error code */
};
#define bfa_status_t enum bfa_status
+40 −9
Original line number Diff line number Diff line
@@ -257,8 +257,6 @@ struct bfa_fw_port_lksm_stats_s {
	u32    nos_tx;             /*  No. of times NOS tx started         */
	u32    hwsm_lrr_rx;        /*  No. of times LRR rx-ed by HWSM      */
	u32    hwsm_lr_rx;         /*  No. of times LR rx-ed by HWSM       */
	u32    bbsc_lr;		   /* LKSM LR tx for credit recovery       */
	u32	rsvd;
};

struct bfa_fw_port_snsm_stats_s {
@@ -409,7 +407,7 @@ struct bfa_fw_trunk_stats_s {
	u32 rsvd;		/*  padding for 64 bit alignment */
};

struct bfa_fw_advsm_stats_s {
struct bfa_fw_aport_stats_s {
	u32 flogi_sent;		/*  Flogi sent			*/
	u32 flogi_acc_recvd;	/*  Flogi Acc received		*/
	u32 flogi_rjt_recvd;	/*  Flogi rejects received	*/
@@ -419,6 +417,12 @@ struct bfa_fw_advsm_stats_s {
	u32 elp_accepted;	/*  ELP Accepted		*/
	u32 elp_rejected;	/*  ELP rejected		*/
	u32 elp_dropped;	/*  ELP dropped			*/

	u32 bbcr_lr_count;	/*!< BBCR Link Resets		*/
	u32 frame_lost_intrs;	/*!< BBCR Frame loss intrs	*/
	u32 rrdy_lost_intrs;	/*!< BBCR Rrdy loss intrs	*/

	u32 rsvd;
};

/*
@@ -489,7 +493,7 @@ struct bfa_fw_stats_s {
	struct bfa_fw_fcxchg_stats_s	fcxchg_stats;
	struct bfa_fw_lps_stats_s	lps_stats;
	struct bfa_fw_trunk_stats_s	trunk_stats;
	struct bfa_fw_advsm_stats_s	advsm_stats;
	struct bfa_fw_aport_stats_s	aport_stats;
	struct bfa_fw_mac_mod_stats_s	macmod_stats;
	struct bfa_fw_ct_mod_stats_s	ctmod_stats;
	struct bfa_fw_eth_sndrcv_stats_s	ethsndrcv_stats;
@@ -545,6 +549,27 @@ struct bfa_qos_attr_s {
	struct bfa_qos_bw_s qos_bw_op;	/* QOS bw operational */
};

enum bfa_bbcr_state {
	BFA_BBCR_DISABLED,	/*!< BBCR is disable */
	BFA_BBCR_ONLINE,	/*!< BBCR is online  */
	BFA_BBCR_OFFLINE,	/*!< BBCR is offline */
};

enum bfa_bbcr_err_reason {
	BFA_BBCR_ERR_REASON_NONE, /*!< Unknown */
	BFA_BBCR_ERR_REASON_SPEED_UNSUP, /*!< Port speed < max sup_speed */
	BFA_BBCR_ERR_REASON_PEER_UNSUP,	/*!< BBCR is disable on peer port */
	BFA_BBCR_ERR_REASON_NON_BRCD_SW, /*!< Connected to non BRCD switch */
	BFA_BBCR_ERR_REASON_FLOGI_RJT, /*!< Login rejected by the switch */
};

struct bfa_bbcr_attr_s {
	u8	state;
	u8	peer_bb_scn;
	u8	reason;
	u8	rsvd;
};

/*
 * These fields should be displayed only from the CLI.
 * There will be a separate BFAL API (get_qos_vc_attr ?)
@@ -892,6 +917,9 @@ struct bfa_defs_fcpim_throttle_s {
	u16	rsvd;
};

#define BFA_BB_SCN_DEF 3
#define BFA_BB_SCN_MAX 0x0F

/*
 *      Physical port configuration
 */
@@ -907,8 +935,8 @@ struct bfa_port_cfg_s {
	u8	 tx_bbcredit;	/*  transmit buffer credits	*/
	u8	 ratelimit;	/*  ratelimit enabled or not	*/
	u8	 trl_def_speed;	/*  ratelimit default speed	*/
	u8	 bb_scn;	/*  BB_SCN value from FLOGI Exchg */
	u8	 bb_scn_state;	/*  Config state of BB_SCN */
	u8	 bb_cr_enabled; /*!< Config state of BB_SCN	*/
	u8	 bb_scn;	/*!< BB_SCN value for FLOGI Exchg */
	u8	 faa_state;	/*  FAA enabled/disabled        */
	u8	 rsvd1;
	u16	 path_tov;	/*  device path timeout	*/
@@ -1052,6 +1080,7 @@ struct bfa_port_link_s {
	struct bfa_qos_attr_s  qos_attr;   /* QoS Attributes */
	union {
		struct bfa_fcport_loop_info_s loop_info;
		struct bfa_bbcr_attr_s bbcr_attr;
		union {
			struct bfa_qos_vc_attr_s qos_vc_attr;
					/*  VC info from ELP */
@@ -1215,9 +1244,11 @@ struct bfa_port_fc_stats_s {
	u64     bad_os_count;   /*  Invalid ordered sets        */
	u64     err_enc_out;    /*  Encoding err nonframe_8b10b */
	u64     err_enc;        /*  Encoding err frame_8b10b    */
	u64	bbsc_frames_lost; /* Credit Recovery-Frames Lost  */
	u64	bbsc_credits_lost; /* Credit Recovery-Credits Lost */
	u64	bbsc_link_resets; /* Credit Recovery-Link Resets   */
	u64	bbcr_frames_lost; /*!< BBCR Frames Lost */
	u64	bbcr_rrdys_lost; /*!< BBCR RRDYs Lost */
	u64	bbcr_link_resets; /*!< BBCR Link Resets */
	u64	bbcr_frame_lost_intrs; /*!< BBCR Frame loss intrs */
	u64	bbcr_rrdy_lost_intrs; /*!< BBCR Rrdy loss intrs */
	u64	loop_timeouts;	/*  Loop timeouts		*/
};

+6 −56
Original line number Diff line number Diff line
@@ -240,9 +240,6 @@ static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg,
					 u32 rsp_len,
					 u32 resid_len,
					 struct fchs_s *rspfchs);
static u8 bfa_fcs_fabric_oper_bbscn(struct bfa_fcs_fabric_s *fabric);
static bfa_boolean_t bfa_fcs_fabric_is_bbscn_enabled(
				struct bfa_fcs_fabric_s *fabric);

static void	bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
					 enum bfa_fcs_fabric_event event);
@@ -404,8 +401,7 @@ bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
	case BFA_FCS_FABRIC_SM_CONT_OP:

		bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
					   fabric->bb_credit,
					   bfa_fcs_fabric_oper_bbscn(fabric));
					   fabric->bb_credit);
		fabric->fab_type = BFA_FCS_FABRIC_SWITCHED;

		if (fabric->auth_reqd && fabric->is_auth) {
@@ -433,8 +429,7 @@ bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
	case BFA_FCS_FABRIC_SM_NO_FABRIC:
		fabric->fab_type = BFA_FCS_FABRIC_N2N;
		bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
					   fabric->bb_credit,
					   bfa_fcs_fabric_oper_bbscn(fabric));
					   fabric->bb_credit);
		bfa_fcs_fabric_notify_online(fabric);
		bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_nofabric);
		break;
@@ -602,8 +597,7 @@ bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
	case BFA_FCS_FABRIC_SM_NO_FABRIC:
		bfa_trc(fabric->fcs, fabric->bb_credit);
		bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
					   fabric->bb_credit,
					   bfa_fcs_fabric_oper_bbscn(fabric));
					   fabric->bb_credit);
		break;

	case BFA_FCS_FABRIC_SM_RETRY_OP:
@@ -965,10 +959,6 @@ bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status)

	case BFA_STATUS_FABRIC_RJT:
		fabric->stats.flogi_rejects++;
		if (fabric->lps->lsrjt_rsn == FC_LS_RJT_RSN_LOGICAL_ERROR &&
		    fabric->lps->lsrjt_expl == FC_LS_RJT_EXP_NO_ADDL_INFO)
			fabric->fcs->bbscn_flogi_rjt = BFA_TRUE;

		bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
		return;

@@ -1014,14 +1004,11 @@ bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric)
{
	struct bfa_s		*bfa = fabric->fcs->bfa;
	struct bfa_lport_cfg_s	*pcfg = &fabric->bport.port_cfg;
	u8			alpa = 0, bb_scn = 0;
	u8			alpa = 0;

	if (bfa_fcs_fabric_is_bbscn_enabled(fabric) &&
	    (!fabric->fcs->bbscn_flogi_rjt))
		bb_scn = BFA_FCS_PORT_DEF_BB_SCN;

	bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_fcport_get_maxfrsize(bfa),
		      pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd, bb_scn);
		      pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd);

	fabric->stats.flogi_sent++;
}
@@ -1101,40 +1088,6 @@ bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s *fabric)
	bfa_wc_wait(&fabric->stop_wc);
}

/*
 * Computes operating BB_SCN value
 */
static u8
bfa_fcs_fabric_oper_bbscn(struct bfa_fcs_fabric_s *fabric)
{
	u8	pr_bbscn = fabric->lps->pr_bbscn;
	struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(fabric->fcs->bfa);

	if (!(fcport->cfg.bb_scn_state && pr_bbscn))
		return 0;

	/* return max of local/remote bb_scn values */
	return ((pr_bbscn > BFA_FCS_PORT_DEF_BB_SCN) ?
		pr_bbscn : BFA_FCS_PORT_DEF_BB_SCN);
}

/*
 * Check if BB_SCN can be enabled.
 */
static bfa_boolean_t
bfa_fcs_fabric_is_bbscn_enabled(struct bfa_fcs_fabric_s *fabric)
{
	struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(fabric->fcs->bfa);

	if (bfa_ioc_get_fcmode(&fabric->fcs->bfa->ioc) &&
			fcport->cfg.bb_scn_state &&
			!bfa_fcport_is_qos_enabled(fabric->fcs->bfa) &&
			!bfa_fcport_is_trunk_enabled(fabric->fcs->bfa))
		return BFA_TRUE;
	else
		return BFA_FALSE;
}

/*
 * Delete all vports and wait for vport delete completions.
 */
@@ -1273,7 +1226,6 @@ void
bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric)
{
	bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
	fabric->fcs->bbscn_flogi_rjt = BFA_FALSE;
	bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_DOWN);
}

@@ -1480,7 +1432,6 @@ bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
	}

	fabric->bb_credit = be16_to_cpu(flogi->csp.bbcred);
	fabric->lps->pr_bbscn = (be16_to_cpu(flogi->csp.rxsz) >> 12);
	bport->port_topo.pn2n.rem_port_wwn = flogi->port_name;
	bport->port_topo.pn2n.reply_oxid = fchs->ox_id;

@@ -1513,8 +1464,7 @@ bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric)
				    n2n_port->reply_oxid, pcfg->pwwn,
				    pcfg->nwwn,
				    bfa_fcport_get_maxfrsize(bfa),
				    bfa_fcport_get_rx_bbcredit(bfa),
				    bfa_fcs_fabric_oper_bbscn(fabric));
				    bfa_fcport_get_rx_bbcredit(bfa), 0);

	bfa_fcxp_send(fcxp, NULL, fabric->vf_id, fabric->lps->bfa_tag,
		      BFA_FALSE, FC_CLASS_3,
+0 −5
Original line number Diff line number Diff line
@@ -258,9 +258,6 @@ struct bfa_fcs_fabric_s;
#define BFA_FCS_PORT_SYMBNAME_OSINFO_SZ			48
#define BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ		16

/* bb_scn value in 2^bb_scn */
#define BFA_FCS_PORT_DEF_BB_SCN				3

/*
 * Get FC port ID for a logical port.
 */
@@ -683,8 +680,6 @@ struct bfa_fcs_s {
	struct bfa_trc_mod_s  *trcmod;	/*  tracing module */
	bfa_boolean_t	vf_enabled;	/*  VF mode is enabled */
	bfa_boolean_t	fdmi_enabled;	/*  FDMI is enabled */
	bfa_boolean_t	bbscn_enabled;	/*  Driver Config Parameter */
	bfa_boolean_t	bbscn_flogi_rjt;/*  FLOGI reject due to BB_SCN */
	bfa_boolean_t min_cfg;		/* min cfg enabled/disabled */
	u16	port_vfid;	/*  port default VF ID */
	struct bfa_fcs_driver_info_s driver_info;
+1 −1
Original line number Diff line number Diff line
@@ -2577,7 +2577,7 @@ bfa_fcs_rport_update(struct bfa_fcs_rport_s *rport, struct fc_logi_s *plogi)

		port->fabric->bb_credit = be16_to_cpu(plogi->csp.bbcred);
		bfa_fcport_set_tx_bbcredit(port->fcs->bfa,
					  port->fabric->bb_credit, 0);
					  port->fabric->bb_credit);
	}

}
Loading