2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
19 #include "fcs_vport.h"
20 #include "fcs_lport.h"
21 #include "fcs_rport.h"
22 #include "fcs_trcmod.h"
24 BFA_TRC_FILE(FCS
, RPORT_API
);
27 * rport_api.c Remote port implementation.
31 * fcs_rport_api FCS rport API.
35 * Direct API to add a target by port wwn. This interface is used, for
36 * example, by bios when target pwwn is known from boot lun configuration.
39 bfa_fcs_rport_add(struct bfa_fcs_port_s
*port
, wwn_t
*pwwn
,
40 struct bfa_fcs_rport_s
*rport
,
41 struct bfad_rport_s
*rport_drv
)
43 bfa_trc(port
->fcs
, *pwwn
);
49 * Direct API to remove a target and its associated resources. This
50 * interface is used, for example, by vmware driver to remove target
51 * ports from the target list for a VM.
54 bfa_fcs_rport_remove(struct bfa_fcs_rport_s
*rport_in
)
57 struct bfa_fcs_rport_s
*rport
;
59 bfa_trc(rport_in
->fcs
, rport_in
->pwwn
);
61 rport
= bfa_fcs_port_get_rport_by_pwwn(rport_in
->port
, rport_in
->pwwn
);
66 bfa_trc(rport_in
->fcs
, rport_in
->pid
);
67 return BFA_STATUS_UNKNOWN_RWWN
;
71 * TBD if this remote port is online, send a logo
78 * Remote device status for display/debug.
81 bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s
*rport
,
82 struct bfa_rport_attr_s
*rport_attr
)
84 struct bfa_rport_qos_attr_s qos_attr
;
85 struct bfa_fcs_port_s
*port
= rport
->port
;
87 bfa_os_memset(rport_attr
, 0, sizeof(struct bfa_rport_attr_s
));
89 rport_attr
->pid
= rport
->pid
;
90 rport_attr
->pwwn
= rport
->pwwn
;
91 rport_attr
->nwwn
= rport
->nwwn
;
92 rport_attr
->cos_supported
= rport
->fc_cos
;
93 rport_attr
->df_sz
= rport
->maxfrsize
;
94 rport_attr
->state
= bfa_fcs_rport_get_state(rport
);
95 rport_attr
->fc_cos
= rport
->fc_cos
;
96 rport_attr
->cisc
= rport
->cisc
;
97 rport_attr
->scsi_function
= rport
->scsi_function
;
98 rport_attr
->curr_speed
= rport
->rpf
.rpsc_speed
;
99 rport_attr
->assigned_speed
= rport
->rpf
.assigned_speed
;
101 bfa_rport_get_qos_attr(rport
->bfa_rport
, &qos_attr
);
102 rport_attr
->qos_attr
= qos_attr
;
104 rport_attr
->trl_enforced
= BFA_FALSE
;
105 if (bfa_pport_is_ratelim(port
->fcs
->bfa
)) {
106 if ((rport
->rpf
.rpsc_speed
== BFA_PPORT_SPEED_UNKNOWN
) ||
107 (rport
->rpf
.rpsc_speed
<
108 bfa_fcs_port_get_rport_max_speed(port
)))
109 rport_attr
->trl_enforced
= BFA_TRUE
;
119 * Per remote device statistics.
122 bfa_fcs_rport_get_stats(struct bfa_fcs_rport_s
*rport
,
123 struct bfa_rport_stats_s
*stats
)
125 *stats
= rport
->stats
;
129 bfa_fcs_rport_clear_stats(struct bfa_fcs_rport_s
*rport
)
131 bfa_os_memset((char *)&rport
->stats
, 0,
132 sizeof(struct bfa_rport_stats_s
));
135 struct bfa_fcs_rport_s
*
136 bfa_fcs_rport_lookup(struct bfa_fcs_port_s
*port
, wwn_t rpwwn
)
138 struct bfa_fcs_rport_s
*rport
;
140 rport
= bfa_fcs_port_get_rport_by_pwwn(port
, rpwwn
);
150 struct bfa_fcs_rport_s
*
151 bfa_fcs_rport_lookup_by_nwwn(struct bfa_fcs_port_s
*port
, wwn_t rnwwn
)
153 struct bfa_fcs_rport_s
*rport
;
155 rport
= bfa_fcs_port_get_rport_by_nwwn(port
, rnwwn
);
166 * This API is to set the Rport's speed. Should be used when RPSC is not
167 * supported by the rport.
170 bfa_fcs_rport_set_speed(struct bfa_fcs_rport_s
*rport
,
171 enum bfa_pport_speed speed
)
173 rport
->rpf
.assigned_speed
= speed
;
175 /* Set this speed in f/w only if the RPSC speed is not available */
176 if (rport
->rpf
.rpsc_speed
== BFA_PPORT_SPEED_UNKNOWN
)
177 bfa_rport_speed(rport
->bfa_rport
, speed
);