Example #1
0
static void
bfa_port_stats_swap(struct bfa_port_s *port, union bfa_pport_stats_u *stats)
{
	u32       *dip = (u32 *) stats;
	u32        t0, t1;
	int             i;

	for (i = 0; i < sizeof(union bfa_pport_stats_u) / sizeof(u32);
	     i += 2) {
		t0 = dip[i];
		t1 = dip[i + 1];
#ifdef __BIGENDIAN
		dip[i] = bfa_os_ntohl(t0);
		dip[i + 1] = bfa_os_ntohl(t1);
#else
		dip[i] = bfa_os_ntohl(t1);
		dip[i + 1] = bfa_os_ntohl(t0);
#endif
	}

    /** todo
     * QoS stats r also swapped as 64bit; that structure also
     * has to use 64 bit counters
     */
}
Example #2
0
static void
bfa_pport_stats_swap(union bfa_pport_stats_u *d, union bfa_pport_stats_u *s)
{
	u32       *dip = (u32 *) d;
	u32       *sip = (u32 *) s;
	int             i;

	/*
	 * Do 64 bit fields swap first
	 */
	for (i = 0;
	     i <
	     ((sizeof(union bfa_pport_stats_u) -
	       sizeof(struct bfa_qos_stats_s)) / sizeof(u32)); i = i + 2) {
#ifdef __BIGENDIAN
		dip[i] = bfa_os_ntohl(sip[i]);
		dip[i + 1] = bfa_os_ntohl(sip[i + 1]);
#else
		dip[i] = bfa_os_ntohl(sip[i + 1]);
		dip[i + 1] = bfa_os_ntohl(sip[i]);
#endif
	}

	/*
	 * Now swap the 32 bit fields
	 */
	for (; i < (sizeof(union bfa_pport_stats_u) / sizeof(u32)); ++i)
		dip[i] = bfa_os_ntohl(sip[i]);
}
Example #3
0
void
bfa_fcport_qos_get_attr(struct bfa_s *bfa, struct bfa_qos_attr_s *qos_attr)
{
	struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);

	qos_attr->state = bfa_os_ntohl(fcport->qos_attr.state);
	qos_attr->total_bb_cr = bfa_os_ntohl(fcport->qos_attr.total_bb_cr);
}
Example #4
0
void
bfa_pport_qos_get_vc_attr(struct bfa_s *bfa,
			  struct bfa_qos_vc_attr_s *qos_vc_attr)
{
	struct bfa_pport_s *pport = BFA_PORT_MOD(bfa);
	struct bfa_qos_vc_attr_s *bfa_vc_attr = &pport->qos_vc_attr;
	u32        i = 0;

	qos_vc_attr->total_vc_count = bfa_os_ntohs(bfa_vc_attr->total_vc_count);
	qos_vc_attr->shared_credit = bfa_os_ntohs(bfa_vc_attr->shared_credit);
	qos_vc_attr->elp_opmode_flags =
		bfa_os_ntohl(bfa_vc_attr->elp_opmode_flags);

	/*
	 * Individual VC info
	 */
	while (i < qos_vc_attr->total_vc_count) {
		qos_vc_attr->vc_info[i].vc_credit =
			bfa_vc_attr->vc_info[i].vc_credit;
		qos_vc_attr->vc_info[i].borrow_credit =
			bfa_vc_attr->vc_info[i].borrow_credit;
		qos_vc_attr->vc_info[i].priority =
			bfa_vc_attr->vc_info[i].priority;
		++i;
	}
}
Example #5
0
static void
bfa_pport_sm_linkdown(struct bfa_pport_s *pport, enum bfa_pport_sm_event event)
{
	bfa_trc(pport->bfa, event);

	switch (event) {
	case BFA_PPORT_SM_LINKUP:
		bfa_pport_update_linkinfo(pport);
		bfa_sm_set_state(pport, bfa_pport_sm_linkup);
		bfa_assert(pport->event_cbfn);
		bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL,
			     BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkup");
		bfa_pport_callback(pport, BFA_PPORT_LINKUP);
		bfa_pport_aen_post(pport, BFA_PORT_AEN_ONLINE);
		/**
		 * If QoS is enabled and it is not online,
		 * Send a separate event.
		 */
		if ((pport->cfg.qos_enabled)
		    && (bfa_os_ntohl(pport->qos_attr.state) != BFA_QOS_ONLINE))
			bfa_pport_aen_post(pport, BFA_PORT_AEN_QOS_NEG);

		break;

	case BFA_PPORT_SM_LINKDOWN:
		/**
		 * Possible to get link down event.
		 */
		break;

	case BFA_PPORT_SM_ENABLE:
		/**
		 * Already enabled.
		 */
		break;

	case BFA_PPORT_SM_DISABLE:
		if (bfa_pport_send_disable(pport))
			bfa_sm_set_state(pport, bfa_pport_sm_disabling);
		else
			bfa_sm_set_state(pport, bfa_pport_sm_disabling_qwait);

		bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL,
			     BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
		bfa_pport_aen_post(pport, BFA_PORT_AEN_DISABLE);
		break;

	case BFA_PPORT_SM_STOP:
		bfa_sm_set_state(pport, bfa_pport_sm_stopped);
		break;

	case BFA_PPORT_SM_HWFAIL:
		bfa_sm_set_state(pport, bfa_pport_sm_iocdown);
		break;

	default:
		bfa_sm_fault(pport->bfa, event);
	}
}
Example #6
0
static void
bfa_fcport_fcoe_stats_swap(struct bfa_fcoe_stats_s *d,
	struct bfa_fcoe_stats_s *s)
{
	u32     *dip = (u32 *) d;
	u32     *sip = (u32 *) s;
	int             i;

	for (i = 0; i < ((sizeof(struct bfa_fcoe_stats_s))/sizeof(u32));
		i = i + 2) {
#ifdef __BIGENDIAN
		dip[i] = bfa_os_ntohl(sip[i]);
		dip[i + 1] = bfa_os_ntohl(sip[i + 1]);
#else
		dip[i] = bfa_os_ntohl(sip[i + 1]);
		dip[i + 1] = bfa_os_ntohl(sip[i]);
#endif
	}
}
static void
bfa_iocfc_stats_swap(struct bfa_fw_stats_s *d, struct bfa_fw_stats_s *s)
{
	u32       *dip = (u32 *) d;
	u32       *sip = (u32 *) s;
	int             i;

	for (i = 0; i < (sizeof(struct bfa_fw_stats_s) / sizeof(u32)); i++)
		dip[i] = bfa_os_ntohl(sip[i]);
}
Example #8
0
static void
bfa_fcport_qos_stats_swap(struct bfa_qos_stats_s *d,
	struct bfa_qos_stats_s *s)
{
	u32     *dip = (u32 *) d;
	u32     *sip = (u32 *) s;
	int             i;

	/* Now swap the 32 bit fields */
	for (i = 0; i < (sizeof(struct bfa_qos_stats_s)/sizeof(u32)); ++i)
		dip[i] = bfa_os_ntohl(sip[i]);
}
Example #9
0
static void
__bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete)
{
	struct bfa_ioim_s	*ioim = cbarg;
	struct bfi_ioim_rsp_s *m;
	u8		*snsinfo = NULL;
	u8         sns_len = 0;
	s32         residue = 0;

	if (!complete) {
		bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
		return;
	}

	m = (struct bfi_ioim_rsp_s *) &ioim->iosp->comp_rspmsg;
	if (m->io_status == BFI_IOIM_STS_OK) {
		/**
		 * setup sense information, if present
		 */
		if (m->scsi_status == SCSI_STATUS_CHECK_CONDITION
					&& m->sns_len) {
			sns_len = m->sns_len;
			snsinfo = ioim->iosp->snsinfo;
		}

		/**
		 * setup residue value correctly for normal completions
		 */
		if (m->resid_flags == FCP_RESID_UNDER)
			residue = bfa_os_ntohl(m->residue);
		if (m->resid_flags == FCP_RESID_OVER) {
			residue = bfa_os_ntohl(m->residue);
			residue = -residue;
		}
	}

	bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, m->io_status,
			  m->scsi_status, sns_len, snsinfo, residue);
}
Example #10
0
static void
bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport,
			enum bfa_fcport_sm_event event)
{
	struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event;
	bfa_trc(fcport->bfa, event);

	switch (event) {
	case BFA_FCPORT_SM_LINKUP:
		bfa_fcport_update_linkinfo(fcport);
		bfa_sm_set_state(fcport, bfa_fcport_sm_linkup);
		bfa_assert(fcport->event_cbfn);
		bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
			     BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkup");

		if (!bfa_ioc_get_fcmode(&fcport->bfa->ioc)) {

			bfa_trc(fcport->bfa,
				pevent->link_state.vc_fcf.fcf.fipenabled);
			bfa_trc(fcport->bfa,
				pevent->link_state.vc_fcf.fcf.fipfailed);

			if (pevent->link_state.vc_fcf.fcf.fipfailed)
				bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
					BFA_PL_EID_FIP_FCF_DISC, 0,
					"FIP FCF Discovery Failed");
			else
				bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
					BFA_PL_EID_FIP_FCF_DISC, 0,
					"FIP FCF Discovered");
		}

		bfa_fcport_callback(fcport, BFA_PPORT_LINKUP);
		bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ONLINE);
		/**
		 * If QoS is enabled and it is not online,
		 * Send a separate event.
		 */
		if ((fcport->cfg.qos_enabled)
		    && (bfa_os_ntohl(fcport->qos_attr.state) != BFA_QOS_ONLINE))
			bfa_fcport_aen_post(fcport, BFA_PORT_AEN_QOS_NEG);

		break;

	case BFA_FCPORT_SM_LINKDOWN:
		/**
		 * Possible to get link down event.
		 */
		break;

	case BFA_FCPORT_SM_ENABLE:
		/**
		 * Already enabled.
		 */
		break;

	case BFA_FCPORT_SM_DISABLE:
		if (bfa_fcport_send_disable(fcport))
			bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
		else
			bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait);

		bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
			     BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
		bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
		break;

	case BFA_FCPORT_SM_STOP:
		bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
		break;

	case BFA_FCPORT_SM_HWFAIL:
		bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
		break;

	default:
		bfa_sm_fault(fcport->bfa, event);
	}
}
Example #11
0
static void
bfa_fcs_port_ms_gmal_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
			      void *cbarg, bfa_status_t req_status,
			      u32 rsp_len, u32 resid_len,
			      struct fchs_s *rsp_fchs)
{
	struct bfa_fcs_port_ms_s *ms = (struct bfa_fcs_port_ms_s *)cbarg;
	struct bfa_fcs_port_s *port = ms->port;
	struct ct_hdr_s       *cthdr = NULL;
	struct fcgs_gmal_resp_s *gmal_resp;
	struct fc_gmal_entry_s *gmal_entry;
	u32        num_entries;
	u8        *rsp_str;

	bfa_trc(port->fcs, req_status);
	bfa_trc(port->fcs, port->port_cfg.pwwn);

	/*
	 * Sanity Checks
	 */
	if (req_status != BFA_STATUS_OK) {
		bfa_trc(port->fcs, req_status);
		bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
		return;
	}

	cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
	cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);

	if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
		gmal_resp = (struct fcgs_gmal_resp_s *)(cthdr + 1);
		num_entries = bfa_os_ntohl(gmal_resp->ms_len);
		if (num_entries == 0) {
			bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
			return;
		}
		/*
		 * The response could contain multiple Entries.
		 * Entries for SNMP interface, etc.
		 * We look for the entry with a telnet prefix.
		 * First "http://" entry refers to IP addr
		 */

		gmal_entry = (struct fc_gmal_entry_s *)gmal_resp->ms_ma;
		while (num_entries > 0) {
			if (strncmp
			    (gmal_entry->prefix, CT_GMAL_RESP_PREFIX_HTTP,
			     sizeof(gmal_entry->prefix)) == 0) {

				/*
				 * if the IP address is terminating with a '/',
				 * remove it. *Byte 0 consists of the length
				 * of the string.
				 */
				rsp_str = &(gmal_entry->prefix[0]);
				if (rsp_str[gmal_entry->len - 1] == '/')
					rsp_str[gmal_entry->len - 1] = 0;
				/*
				 * copy IP Address to fabric
				 */
				strncpy(bfa_fcs_port_get_fabric_ipaddr(port),
					gmal_entry->ip_addr,
					BFA_FCS_FABRIC_IPADDR_SZ);
				break;
			} else {
				--num_entries;
				++gmal_entry;
			}
		}

		bfa_sm_send_event(ms, MSSM_EVENT_RSP_OK);
		return;
	}

	bfa_trc(port->fcs, cthdr->reason_code);
	bfa_trc(port->fcs, cthdr->exp_code);
	bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
}