예제 #1
0
/*
 * Iterate's through all the rport's in the given port to
 * determine the maximum operating speed.
 *
 * To be used in TRL Functionality only
 */
enum bfa_pport_speed
bfa_fcs_port_get_rport_max_speed(struct bfa_fcs_port_s *port)
{
	struct list_head *qh, *qe;
	struct bfa_fcs_rport_s *rport = NULL;
	struct bfa_fcs_s *fcs;
	enum bfa_pport_speed max_speed = 0;
	struct bfa_pport_attr_s pport_attr;
	enum bfa_pport_speed pport_speed, rport_speed;
	bfa_boolean_t     trl_enabled = bfa_fcport_is_ratelim(port->fcs->bfa);

	if (port == NULL)
		return 0;

	fcs = port->fcs;

	/*
	 * Get Physical port's current speed
	 */
	bfa_fcport_get_attr(port->fcs->bfa, &pport_attr);
	pport_speed = pport_attr.speed;
	bfa_trc(fcs, pport_speed);

	qh = &port->rport_q;
	qe = bfa_q_first(qh);

	while (qe != qh) {
		rport = (struct bfa_fcs_rport_s *) qe;
		if ((bfa_os_ntoh3b(rport->pid) > 0xFFF000) ||
			(bfa_fcs_rport_get_state(rport) ==
						BFA_RPORT_OFFLINE)) {
			qe = bfa_q_next(qe);
			continue;
		}

		rport_speed = rport->rpf.rpsc_speed;
		if ((trl_enabled) &&  (rport_speed ==
						BFA_PPORT_SPEED_UNKNOWN)) {
			/* Use default ratelim speed setting */
			rport_speed =
				bfa_fcport_get_ratelim_speed(port->fcs->bfa);
		}

		if ((rport_speed  == BFA_PPORT_SPEED_8GBPS) ||
			(rport_speed > pport_speed)) {
			max_speed = rport_speed;
			break;
		} else if (rport_speed > max_speed) {
			max_speed = rport_speed;
		}

		qe = bfa_q_next(qe);
	}

	bfa_trc(fcs, max_speed);
	return max_speed;
}
void
bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
			struct bfa_rport_attr_s *rport_attr)
{
	struct bfa_rport_qos_attr_s qos_attr;
	struct bfa_fcs_port_s *port = rport->port;

	bfa_os_memset(rport_attr, 0, sizeof(struct bfa_rport_attr_s));

	rport_attr->pid = rport->pid;
	rport_attr->pwwn = rport->pwwn;
	rport_attr->nwwn = rport->nwwn;
	rport_attr->cos_supported = rport->fc_cos;
	rport_attr->df_sz = rport->maxfrsize;
	rport_attr->state = bfa_fcs_rport_get_state(rport);
	rport_attr->fc_cos = rport->fc_cos;
	rport_attr->cisc = rport->cisc;
	rport_attr->scsi_function = rport->scsi_function;
	rport_attr->curr_speed  = rport->rpf.rpsc_speed;
	rport_attr->assigned_speed  = rport->rpf.assigned_speed;

	bfa_rport_get_qos_attr(rport->bfa_rport, &qos_attr);
	rport_attr->qos_attr = qos_attr;

	rport_attr->trl_enforced = BFA_FALSE;
	if (bfa_fcport_is_ratelim(port->fcs->bfa)) {
		if ((rport->rpf.rpsc_speed == BFA_PPORT_SPEED_UNKNOWN) ||
			(rport->rpf.rpsc_speed <
			bfa_fcs_port_get_rport_max_speed(port)))
			rport_attr->trl_enforced = BFA_TRUE;
	}

	/*
	 * TODO
	 * rport->symname
	 */
}