Commit 1a898a79 authored by Vijaya Mohan Guvva's avatar Vijaya Mohan Guvva Committed by James Bottomley

[SCSI] bfa: Add dynamic diagnostic port support

D-Port is a new port type created with the intention of running link
level diagnostic tests like loopback, traffic test. In static D-port
mode, user configures the port to D-port mode and starts the test, but
in dynamic D-port, once the Brocade switch port is configured to
D-port, it will reject the regular FLOGI from HBA with reason that it is
in D-port mode. So based on the reason code HBA port will turn itself into
D-port and start diagnostic test.
Signed-off-by: default avatarSudarsana Reddy Kalluru <skalluru@brocade.com>
Signed-off-by: default avatarVijaya Mohan Guvva <vmohan@brocade.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 4e1e0d8d
......@@ -199,15 +199,34 @@ enum bfa_status {
BFA_STATUS_DPORT_DISABLED = 236, /* D-port mode is already disabled */
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_NO_SFP = 243, /* SFP is not present.\n D-port will be
* enabled but it will be operational
* only after inserting a valid SFP. */
BFA_STATUS_DPORT_ERR = 245, /* D-port mode is enabled */
BFA_STATUS_DPORT_ENOSYS = 254, /* Switch has no D_Port functionality */
BFA_STATUS_DPORT_CANT_PERF = 255, /* Switch port is not D_Port capable
* or D_Port is disabled */
BFA_STATUS_DPORT_LOGICALERR = 256, /* Switch D_Port fail */
BFA_STATUS_DPORT_SWBUSY = 257, /* Switch port busy */
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_DDPORT_ERR = 261, /* Dynamic D_Port mode is active.\n To
* exit dynamic mode, disable D_Port on
* the remote port */
BFA_STATUS_DPORT_SFPWRAP_ERR = 262, /* Clear e/o_wrap fail, check or
* replace SFP */
BFA_STATUS_BBCR_CFG_NO_CHANGE = 265, /*!< BBCR is operational.
* Disable BBCR and try this operation again. */
BFA_STATUS_DPORT_SW_NOTREADY = 268, /* Remote port is not ready to
* start dport test. Check remote
* port status. */
BFA_STATUS_DPORT_INV_SFP = 271, /* Invalid SFP for D-PORT mode. */
BFA_STATUS_DPORT_CMD_NOTSUPP = 273, /* Dport is not supported by
* remote port */
BFA_STATUS_MAX_VAL /* Unknown error code */
};
#define bfa_status_t enum bfa_status
......@@ -526,17 +545,6 @@ struct bfa_ioc_aen_data_s {
mac_t mac;
};
/*
* D-port states
*
*/
enum bfa_dport_state {
BFA_DPORT_ST_DISABLED = 0, /* D-port is Disabled */
BFA_DPORT_ST_DISABLING = 1, /* D-port is Disabling */
BFA_DPORT_ST_ENABLING = 2, /* D-port is Enabling */
BFA_DPORT_ST_ENABLED = 3, /* D-port is Enabled */
};
/*
* ---------------------- mfg definitions ------------
*/
......@@ -1136,6 +1144,7 @@ struct bfa_flash_attr_s {
#define LB_PATTERN_DEFAULT 0xB5B5B5B5
#define QTEST_CNT_DEFAULT 10
#define QTEST_PAT_DEFAULT LB_PATTERN_DEFAULT
#define DPORT_ENABLE_LOOPCNT_DEFAULT (1024 * 1024)
struct bfa_diag_memtest_s {
u8 algo;
......@@ -1164,6 +1173,54 @@ struct bfa_diag_loopback_result_s {
u8 rsvd[3];
};
enum bfa_diag_dport_test_status {
DPORT_TEST_ST_IDLE = 0, /* the test has not started yet. */
DPORT_TEST_ST_FINAL = 1, /* the test done successfully */
DPORT_TEST_ST_SKIP = 2, /* the test skipped */
DPORT_TEST_ST_FAIL = 3, /* the test failed */
DPORT_TEST_ST_INPRG = 4, /* the testing is in progress */
DPORT_TEST_ST_RESPONDER = 5, /* test triggered from remote port */
DPORT_TEST_ST_STOPPED = 6, /* the test stopped by user. */
DPORT_TEST_ST_MAX
};
enum bfa_diag_dport_test_type {
DPORT_TEST_ELOOP = 0,
DPORT_TEST_OLOOP = 1,
DPORT_TEST_ROLOOP = 2,
DPORT_TEST_LINK = 3,
DPORT_TEST_MAX
};
enum bfa_diag_dport_test_opmode {
BFA_DPORT_OPMODE_AUTO = 0,
BFA_DPORT_OPMODE_MANU = 1,
};
struct bfa_diag_dport_subtest_result_s {
u8 status; /* bfa_diag_dport_test_status */
u8 rsvd[7]; /* 64bit align */
u64 start_time; /* timestamp */
};
struct bfa_diag_dport_result_s {
wwn_t rp_pwwn; /* switch port wwn */
wwn_t rp_nwwn; /* switch node wwn */
u64 start_time; /* user/sw start time */
u64 end_time; /* timestamp */
u8 status; /* bfa_diag_dport_test_status */
u8 mode; /* bfa_diag_dport_test_opmode */
u8 rsvd; /* 64bit align */
u8 speed; /* link speed for buf_reqd */
u16 buffer_required;
u16 frmsz; /* frame size for buf_reqd */
u32 lpcnt; /* Frame count */
u32 pat; /* Pattern */
u32 roundtrip_latency; /* in nano sec */
u32 est_cable_distance; /* in meter */
struct bfa_diag_dport_subtest_result_s subtest[DPORT_TEST_MAX];
};
struct bfa_diag_ledtest_s {
u32 cmd; /* bfa_led_op_t */
u32 color; /* bfa_led_color_t */
......
......@@ -761,6 +761,7 @@ enum bfa_port_states {
BFA_PORT_ST_TOGGLING_QWAIT = 14,
BFA_PORT_ST_FAA_MISCONFIG = 15,
BFA_PORT_ST_DPORT = 16,
BFA_PORT_ST_DDPORT = 17,
BFA_PORT_ST_MAX_STATE,
};
......
This diff is collapsed.
......@@ -551,6 +551,7 @@ void bfa_fcport_event_register(struct bfa_s *bfa,
enum bfa_port_linkstate event), void *event_cbarg);
bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
bfa_boolean_t bfa_fcport_is_dport(struct bfa_s *bfa);
bfa_boolean_t bfa_fcport_is_ddport(struct bfa_s *bfa);
bfa_status_t bfa_fcport_set_qos_bw(struct bfa_s *bfa,
struct bfa_qos_bw_s *qos_bw);
enum bfa_port_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
......@@ -715,10 +716,18 @@ struct bfa_fcdiag_lb_s {
struct bfa_dport_s {
struct bfa_s *bfa; /* Back pointer to BFA */
bfa_sm_t sm; /* finite state machine */
u32 msgtag; /* firmware msg tag for reply */
struct bfa_reqq_wait_s reqq_wait;
bfa_cb_diag_t cbfn;
void *cbarg;
union bfi_diag_dport_msg_u i2hmsg;
u8 test_state; /* enum dport_test_state */
u8 dynamic; /* boolean_t */
u8 rsvd[2];
u32 lpcnt;
u32 payload; /* user defined payload pattern */
wwn_t rp_pwwn;
wwn_t rp_nwwn;
struct bfa_diag_dport_result_s result;
};
struct bfa_fcdiag_s {
......@@ -742,11 +751,13 @@ bfa_status_t bfa_fcdiag_queuetest(struct bfa_s *bfa, u32 ignore,
u32 queue, struct bfa_diag_qtest_result_s *result,
bfa_cb_diag_t cbfn, void *cbarg);
bfa_status_t bfa_fcdiag_lb_is_running(struct bfa_s *bfa);
bfa_status_t bfa_dport_enable(struct bfa_s *bfa, bfa_cb_diag_t cbfn,
void *cbarg);
bfa_status_t bfa_dport_enable(struct bfa_s *bfa, u32 lpcnt, u32 pat,
bfa_cb_diag_t cbfn, void *cbarg);
bfa_status_t bfa_dport_disable(struct bfa_s *bfa, bfa_cb_diag_t cbfn,
void *cbarg);
bfa_status_t bfa_dport_get_state(struct bfa_s *bfa,
enum bfa_dport_state *state);
bfa_status_t bfa_dport_start(struct bfa_s *bfa, u32 lpcnt, u32 pat,
bfa_cb_diag_t cbfn, void *cbarg);
bfa_status_t bfa_dport_show(struct bfa_s *bfa,
struct bfa_diag_dport_result_s *result);
#endif /* __BFA_SVC_H__ */
......@@ -1785,51 +1785,87 @@ bfad_iocmd_diag_lb_stat(struct bfad_s *bfad, void *cmd)
}
int
bfad_iocmd_diag_cfg_dport(struct bfad_s *bfad, unsigned int cmd, void *pcmd)
bfad_iocmd_diag_dport_enable(struct bfad_s *bfad, void *pcmd)
{
struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)pcmd;
struct bfa_bsg_dport_enable_s *iocmd =
(struct bfa_bsg_dport_enable_s *)pcmd;
unsigned long flags;
struct bfad_hal_comp fcomp;
init_completion(&fcomp.comp);
spin_lock_irqsave(&bfad->bfad_lock, flags);
if (cmd == IOCMD_DIAG_DPORT_ENABLE)
iocmd->status = bfa_dport_enable(&bfad->bfa,
bfad_hcb_comp, &fcomp);
else if (cmd == IOCMD_DIAG_DPORT_DISABLE)
iocmd->status = bfa_dport_disable(&bfad->bfa,
bfad_hcb_comp, &fcomp);
iocmd->status = bfa_dport_enable(&bfad->bfa, iocmd->lpcnt,
iocmd->pat, bfad_hcb_comp, &fcomp);
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
if (iocmd->status != BFA_STATUS_OK)
bfa_trc(bfad, iocmd->status);
else {
bfa_trc(bfad, 0);
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
return -EINVAL;
wait_for_completion(&fcomp.comp);
iocmd->status = fcomp.status;
}
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
return 0;
}
int
bfad_iocmd_diag_dport_disable(struct bfad_s *bfad, void *pcmd)
{
struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)pcmd;
unsigned long flags;
struct bfad_hal_comp fcomp;
init_completion(&fcomp.comp);
spin_lock_irqsave(&bfad->bfad_lock, flags);
iocmd->status = bfa_dport_disable(&bfad->bfa, bfad_hcb_comp, &fcomp);
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
if (iocmd->status != BFA_STATUS_OK)
bfa_trc(bfad, iocmd->status);
else {
wait_for_completion(&fcomp.comp);
iocmd->status = fcomp.status;
}
return 0;
}
int
bfad_iocmd_diag_dport_start(struct bfad_s *bfad, void *pcmd)
{
struct bfa_bsg_dport_enable_s *iocmd =
(struct bfa_bsg_dport_enable_s *)pcmd;
unsigned long flags;
struct bfad_hal_comp fcomp;
init_completion(&fcomp.comp);
spin_lock_irqsave(&bfad->bfad_lock, flags);
iocmd->status = bfa_dport_start(&bfad->bfa, iocmd->lpcnt,
iocmd->pat, bfad_hcb_comp,
&fcomp);
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
if (iocmd->status != BFA_STATUS_OK) {
bfa_trc(bfad, iocmd->status);
} else {
wait_for_completion(&fcomp.comp);
iocmd->status = fcomp.status;
}
return 0;
}
int
bfad_iocmd_diag_dport_get_state(struct bfad_s *bfad, void *pcmd)
bfad_iocmd_diag_dport_show(struct bfad_s *bfad, void *pcmd)
{
struct bfa_bsg_diag_dport_get_state_s *iocmd =
(struct bfa_bsg_diag_dport_get_state_s *)pcmd;
unsigned long flags;
struct bfa_bsg_diag_dport_show_s *iocmd =
(struct bfa_bsg_diag_dport_show_s *)pcmd;
unsigned long flags;
spin_lock_irqsave(&bfad->bfad_lock, flags);
iocmd->status = bfa_dport_get_state(&bfad->bfa, &iocmd->state);
iocmd->status = bfa_dport_show(&bfad->bfa, &iocmd->result);
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
return 0;
}
int
bfad_iocmd_phy_get_attr(struct bfad_s *bfad, void *cmd)
{
......@@ -2934,11 +2970,16 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd,
rc = bfad_iocmd_diag_lb_stat(bfad, iocmd);
break;
case IOCMD_DIAG_DPORT_ENABLE:
rc = bfad_iocmd_diag_dport_enable(bfad, iocmd);
break;
case IOCMD_DIAG_DPORT_DISABLE:
rc = bfad_iocmd_diag_cfg_dport(bfad, cmd, iocmd);
rc = bfad_iocmd_diag_dport_disable(bfad, iocmd);
break;
case IOCMD_DIAG_DPORT_SHOW:
rc = bfad_iocmd_diag_dport_show(bfad, iocmd);
break;
case IOCMD_DIAG_DPORT_GET_STATE:
rc = bfad_iocmd_diag_dport_get_state(bfad, iocmd);
case IOCMD_DIAG_DPORT_START:
rc = bfad_iocmd_diag_dport_start(bfad, iocmd);
break;
case IOCMD_PHY_GET_ATTR:
rc = bfad_iocmd_phy_get_attr(bfad, iocmd);
......
......@@ -144,7 +144,6 @@ enum {
IOCMD_FCPIM_LUNMASK_DELETE,
IOCMD_DIAG_DPORT_ENABLE,
IOCMD_DIAG_DPORT_DISABLE,
IOCMD_DIAG_DPORT_GET_STATE,
IOCMD_QOS_SET_BW,
IOCMD_FCPIM_THROTTLE_QUERY,
IOCMD_FCPIM_THROTTLE_SET,
......@@ -153,6 +152,8 @@ enum {
IOCMD_FRUVPD_READ,
IOCMD_FRUVPD_UPDATE,
IOCMD_FRUVPD_GET_MAX_SIZE,
IOCMD_DIAG_DPORT_SHOW,
IOCMD_DIAG_DPORT_START,
};
struct bfa_bsg_gen_s {
......@@ -593,6 +594,21 @@ struct bfa_bsg_diag_loopback_s {
struct bfa_diag_loopback_result_s result;
};
struct bfa_bsg_diag_dport_show_s {
bfa_status_t status;
u16 bfad_num;
u16 rsvd;
struct bfa_diag_dport_result_s result;
};
struct bfa_bsg_dport_enable_s {
bfa_status_t status;
u16 bfad_num;
u16 rsvd;
u16 lpcnt;
u16 pat;
};
struct bfa_bsg_diag_fwping_s {
bfa_status_t status;
u16 bfad_num;
......@@ -640,13 +656,6 @@ struct bfa_bsg_diag_lb_stat_s {
u16 rsvd;
};
struct bfa_bsg_diag_dport_get_state_s {
bfa_status_t status;
u16 bfad_num;
u16 rsvd;
enum bfa_dport_state state;
};
struct bfa_bsg_phy_attr_s {
bfa_status_t status;
u16 bfad_num;
......
......@@ -973,6 +973,7 @@ enum bfi_diag_i2h {
BFI_DIAG_I2H_LEDTEST = BFA_I2HM(BFI_DIAG_H2I_LEDTEST),
BFI_DIAG_I2H_QTEST = BFA_I2HM(BFI_DIAG_H2I_QTEST),
BFI_DIAG_I2H_DPORT = BFA_I2HM(BFI_DIAG_H2I_DPORT),
BFI_DIAG_I2H_DPORT_SCN = BFA_I2HM(8),
};
#define BFI_DIAG_MAX_SGES 2
......@@ -1064,16 +1065,73 @@ struct bfi_diag_qtest_req_s {
enum bfi_dport_req {
BFI_DPORT_DISABLE = 0, /* disable dport request */
BFI_DPORT_ENABLE = 1, /* enable dport request */
BFI_DPORT_START = 2, /* start dport request */
BFI_DPORT_SHOW = 3, /* show dport request */
BFI_DPORT_DYN_DISABLE = 4, /* disable dynamic dport request */
};
enum bfi_dport_scn {
BFI_DPORT_SCN_TESTSTART = 1,
BFI_DPORT_SCN_TESTCOMP = 2,
BFI_DPORT_SCN_SFP_REMOVED = 3,
BFI_DPORT_SCN_DDPORT_ENABLE = 4,
BFI_DPORT_SCN_DDPORT_DISABLE = 5,
BFI_DPORT_SCN_FCPORT_DISABLE = 6,
BFI_DPORT_SCN_SUBTESTSTART = 7,
BFI_DPORT_SCN_TESTSKIP = 8,
BFI_DPORT_SCN_DDPORT_DISABLED = 9,
};
struct bfi_diag_dport_req_s {
struct bfi_mhdr_s mh; /* 4 bytes */
u8 req; /* request 1: enable 0: disable */
u8 status; /* reply status */
u8 rsvd[2];
u32 msgtag; /* msgtag for reply */
u8 req; /* request 1: enable 0: disable */
u8 rsvd[3];
u32 lpcnt;
u32 payload;
};
struct bfi_diag_dport_rsp_s {
struct bfi_mhdr_s mh; /* header 4 bytes */
bfa_status_t status; /* reply status */
wwn_t pwwn; /* switch port wwn. 8 bytes */
wwn_t nwwn; /* switch node wwn. 8 bytes */
};
struct bfi_diag_dport_scn_teststart_s {
wwn_t pwwn; /* switch port wwn. 8 bytes */
wwn_t nwwn; /* switch node wwn. 8 bytes */
u8 type; /* bfa_diag_dport_test_type_e */
u8 rsvd[3];
u32 numfrm; /* from switch uint in 1M */
};
struct bfi_diag_dport_scn_testcomp_s {
u8 status; /* bfa_diag_dport_test_status_e */
u8 speed; /* bfa_port_speed_t */
u16 numbuffer; /* from switch */
u8 subtest_status[DPORT_TEST_MAX]; /* 4 bytes */
u32 latency; /* from switch */
u32 distance; /* from swtich unit in meters */
/* Buffers required to saturate the link */
u16 frm_sz; /* from switch for buf_reqd */
u8 rsvd[2];
};
struct bfi_diag_dport_scn_s { /* max size == RDS_RMESZ */
struct bfi_mhdr_s mh; /* header 4 bytes */
u8 state; /* new state */
u8 rsvd[3];
union {
struct bfi_diag_dport_scn_teststart_s teststart;
struct bfi_diag_dport_scn_testcomp_s testcomp;
} info;
};
union bfi_diag_dport_msg_u {
struct bfi_diag_dport_req_s req;
struct bfi_diag_dport_rsp_s rsp;
struct bfi_diag_dport_scn_s scn;
};
#define bfi_diag_dport_rsp_t struct bfi_diag_dport_req_s
/*
* PHY module specific
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment