Commit d4784187 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi: fcoe: pass in fcoe_rport structure instead of fc_rport_priv

Instead of using the generic 'fc_rport_priv' structure as argument and then
having to painstakingly outcast this to fcoe_rport we should be passing the
fcoe_rport structure itself and reduce complexity.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 023358b1
...@@ -2401,16 +2401,14 @@ static void fcoe_ctlr_vn_send_claim(struct fcoe_ctlr *fip) ...@@ -2401,16 +2401,14 @@ static void fcoe_ctlr_vn_send_claim(struct fcoe_ctlr *fip)
/** /**
* fcoe_ctlr_vn_probe_req() - handle incoming VN2VN probe request. * fcoe_ctlr_vn_probe_req() - handle incoming VN2VN probe request.
* @fip: The FCoE controller * @fip: The FCoE controller
* @rdata: parsed remote port with frport from the probe request * @frport: parsed FCoE rport from the probe request
* *
* Called with ctlr_mutex held. * Called with ctlr_mutex held.
*/ */
static void fcoe_ctlr_vn_probe_req(struct fcoe_ctlr *fip, static void fcoe_ctlr_vn_probe_req(struct fcoe_ctlr *fip,
struct fc_rport_priv *rdata) struct fcoe_rport *frport)
{ {
struct fcoe_rport *frport = fcoe_ctlr_rport(rdata); if (frport->rdata.ids.port_id != fip->port_id)
if (rdata->ids.port_id != fip->port_id)
return; return;
switch (fip->state) { switch (fip->state) {
...@@ -2430,7 +2428,7 @@ static void fcoe_ctlr_vn_probe_req(struct fcoe_ctlr *fip, ...@@ -2430,7 +2428,7 @@ static void fcoe_ctlr_vn_probe_req(struct fcoe_ctlr *fip,
* Probe's REC bit is not set. * Probe's REC bit is not set.
* If we don't reply, we will change our address. * If we don't reply, we will change our address.
*/ */
if (fip->lp->wwpn > rdata->ids.port_name && if (fip->lp->wwpn > frport->rdata.ids.port_name &&
!(frport->flags & FIP_FL_REC_OR_P2P)) { !(frport->flags & FIP_FL_REC_OR_P2P)) {
LIBFCOE_FIP_DBG(fip, "vn_probe_req: " LIBFCOE_FIP_DBG(fip, "vn_probe_req: "
"port_id collision\n"); "port_id collision\n");
...@@ -2454,14 +2452,14 @@ static void fcoe_ctlr_vn_probe_req(struct fcoe_ctlr *fip, ...@@ -2454,14 +2452,14 @@ static void fcoe_ctlr_vn_probe_req(struct fcoe_ctlr *fip,
/** /**
* fcoe_ctlr_vn_probe_reply() - handle incoming VN2VN probe reply. * fcoe_ctlr_vn_probe_reply() - handle incoming VN2VN probe reply.
* @fip: The FCoE controller * @fip: The FCoE controller
* @rdata: parsed remote port with frport from the probe request * @frport: parsed FCoE rport from the probe request
* *
* Called with ctlr_mutex held. * Called with ctlr_mutex held.
*/ */
static void fcoe_ctlr_vn_probe_reply(struct fcoe_ctlr *fip, static void fcoe_ctlr_vn_probe_reply(struct fcoe_ctlr *fip,
struct fc_rport_priv *rdata) struct fcoe_rport *frport)
{ {
if (rdata->ids.port_id != fip->port_id) if (frport->rdata.ids.port_id != fip->port_id)
return; return;
switch (fip->state) { switch (fip->state) {
case FIP_ST_VNMP_START: case FIP_ST_VNMP_START:
...@@ -2484,11 +2482,11 @@ static void fcoe_ctlr_vn_probe_reply(struct fcoe_ctlr *fip, ...@@ -2484,11 +2482,11 @@ static void fcoe_ctlr_vn_probe_reply(struct fcoe_ctlr *fip,
/** /**
* fcoe_ctlr_vn_add() - Add a VN2VN entry to the list, based on a claim reply. * fcoe_ctlr_vn_add() - Add a VN2VN entry to the list, based on a claim reply.
* @fip: The FCoE controller * @fip: The FCoE controller
* @new: newly-parsed remote port with frport as a template for new rdata * @new: newly-parsed FCoE rport as a template for new rdata
* *
* Called with ctlr_mutex held. * Called with ctlr_mutex held.
*/ */
static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fc_rport_priv *new) static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fcoe_rport *new)
{ {
struct fc_lport *lport = fip->lp; struct fc_lport *lport = fip->lp;
struct fc_rport_priv *rdata; struct fc_rport_priv *rdata;
...@@ -2496,7 +2494,7 @@ static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fc_rport_priv *new) ...@@ -2496,7 +2494,7 @@ static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fc_rport_priv *new)
struct fcoe_rport *frport; struct fcoe_rport *frport;
u32 port_id; u32 port_id;
port_id = new->ids.port_id; port_id = new->rdata.ids.port_id;
if (port_id == fip->port_id) if (port_id == fip->port_id)
return; return;
...@@ -2513,22 +2511,28 @@ static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fc_rport_priv *new) ...@@ -2513,22 +2511,28 @@ static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fc_rport_priv *new)
rdata->disc_id = lport->disc.disc_id; rdata->disc_id = lport->disc.disc_id;
ids = &rdata->ids; ids = &rdata->ids;
if ((ids->port_name != -1 && ids->port_name != new->ids.port_name) || if ((ids->port_name != -1 &&
(ids->node_name != -1 && ids->node_name != new->ids.node_name)) { ids->port_name != new->rdata.ids.port_name) ||
(ids->node_name != -1 &&
ids->node_name != new->rdata.ids.node_name)) {
mutex_unlock(&rdata->rp_mutex); mutex_unlock(&rdata->rp_mutex);
LIBFCOE_FIP_DBG(fip, "vn_add rport logoff %6.6x\n", port_id); LIBFCOE_FIP_DBG(fip, "vn_add rport logoff %6.6x\n", port_id);
fc_rport_logoff(rdata); fc_rport_logoff(rdata);
mutex_lock(&rdata->rp_mutex); mutex_lock(&rdata->rp_mutex);
} }
ids->port_name = new->ids.port_name; ids->port_name = new->rdata.ids.port_name;
ids->node_name = new->ids.node_name; ids->node_name = new->rdata.ids.node_name;
mutex_unlock(&rdata->rp_mutex); mutex_unlock(&rdata->rp_mutex);
frport = fcoe_ctlr_rport(rdata); frport = fcoe_ctlr_rport(rdata);
LIBFCOE_FIP_DBG(fip, "vn_add rport %6.6x %s state %d\n", LIBFCOE_FIP_DBG(fip, "vn_add rport %6.6x %s state %d\n",
port_id, frport->fcoe_len ? "old" : "new", port_id, frport->fcoe_len ? "old" : "new",
rdata->rp_state); rdata->rp_state);
*frport = *fcoe_ctlr_rport(new); frport->fcoe_len = new->fcoe_len;
frport->flags = new->flags;
frport->login_count = new->login_count;
memcpy(frport->enode_mac, new->enode_mac, ETH_ALEN);
memcpy(frport->vn_mac, new->vn_mac, ETH_ALEN);
frport->time = 0; frport->time = 0;
} }
...@@ -2560,16 +2564,14 @@ static int fcoe_ctlr_vn_lookup(struct fcoe_ctlr *fip, u32 port_id, u8 *mac) ...@@ -2560,16 +2564,14 @@ static int fcoe_ctlr_vn_lookup(struct fcoe_ctlr *fip, u32 port_id, u8 *mac)
/** /**
* fcoe_ctlr_vn_claim_notify() - handle received FIP VN2VN Claim Notification * fcoe_ctlr_vn_claim_notify() - handle received FIP VN2VN Claim Notification
* @fip: The FCoE controller * @fip: The FCoE controller
* @new: newly-parsed remote port with frport as a template for new rdata * @new: newly-parsed FCoE rport as a template for new rdata
* *
* Called with ctlr_mutex held. * Called with ctlr_mutex held.
*/ */
static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip, static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip,
struct fc_rport_priv *new) struct fcoe_rport *new)
{ {
struct fcoe_rport *frport = fcoe_ctlr_rport(new); if (new->flags & FIP_FL_REC_OR_P2P) {
if (frport->flags & FIP_FL_REC_OR_P2P) {
LIBFCOE_FIP_DBG(fip, "send probe req for P2P/REC\n"); LIBFCOE_FIP_DBG(fip, "send probe req for P2P/REC\n");
fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0); fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0);
return; return;
...@@ -2578,7 +2580,7 @@ static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip, ...@@ -2578,7 +2580,7 @@ static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip,
case FIP_ST_VNMP_START: case FIP_ST_VNMP_START:
case FIP_ST_VNMP_PROBE1: case FIP_ST_VNMP_PROBE1:
case FIP_ST_VNMP_PROBE2: case FIP_ST_VNMP_PROBE2:
if (new->ids.port_id == fip->port_id) { if (new->rdata.ids.port_id == fip->port_id) {
LIBFCOE_FIP_DBG(fip, "vn_claim_notify: " LIBFCOE_FIP_DBG(fip, "vn_claim_notify: "
"restart, state %d\n", "restart, state %d\n",
fip->state); fip->state);
...@@ -2587,8 +2589,8 @@ static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip, ...@@ -2587,8 +2589,8 @@ static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip,
break; break;
case FIP_ST_VNMP_CLAIM: case FIP_ST_VNMP_CLAIM:
case FIP_ST_VNMP_UP: case FIP_ST_VNMP_UP:
if (new->ids.port_id == fip->port_id) { if (new->rdata.ids.port_id == fip->port_id) {
if (new->ids.port_name > fip->lp->wwpn) { if (new->rdata.ids.port_name > fip->lp->wwpn) {
LIBFCOE_FIP_DBG(fip, "vn_claim_notify: " LIBFCOE_FIP_DBG(fip, "vn_claim_notify: "
"restart, port_id collision\n"); "restart, port_id collision\n");
fcoe_ctlr_vn_restart(fip); fcoe_ctlr_vn_restart(fip);
...@@ -2600,15 +2602,16 @@ static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip, ...@@ -2600,15 +2602,16 @@ static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip,
break; break;
} }
LIBFCOE_FIP_DBG(fip, "vn_claim_notify: send reply to %x\n", LIBFCOE_FIP_DBG(fip, "vn_claim_notify: send reply to %x\n",
new->ids.port_id); new->rdata.ids.port_id);
fcoe_ctlr_vn_send(fip, FIP_SC_VN_CLAIM_REP, frport->enode_mac, fcoe_ctlr_vn_send(fip, FIP_SC_VN_CLAIM_REP, new->enode_mac,
min((u32)frport->fcoe_len, min((u32)new->fcoe_len,
fcoe_ctlr_fcoe_size(fip))); fcoe_ctlr_fcoe_size(fip)));
fcoe_ctlr_vn_add(fip, new); fcoe_ctlr_vn_add(fip, new);
break; break;
default: default:
LIBFCOE_FIP_DBG(fip, "vn_claim_notify: " LIBFCOE_FIP_DBG(fip, "vn_claim_notify: "
"ignoring claim from %x\n", new->ids.port_id); "ignoring claim from %x\n",
new->rdata.ids.port_id);
break; break;
} }
} }
...@@ -2616,15 +2619,15 @@ static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip, ...@@ -2616,15 +2619,15 @@ static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip,
/** /**
* fcoe_ctlr_vn_claim_resp() - handle received Claim Response * fcoe_ctlr_vn_claim_resp() - handle received Claim Response
* @fip: The FCoE controller that received the frame * @fip: The FCoE controller that received the frame
* @new: newly-parsed remote port with frport from the Claim Response * @new: newly-parsed FCoE rport from the Claim Response
* *
* Called with ctlr_mutex held. * Called with ctlr_mutex held.
*/ */
static void fcoe_ctlr_vn_claim_resp(struct fcoe_ctlr *fip, static void fcoe_ctlr_vn_claim_resp(struct fcoe_ctlr *fip,
struct fc_rport_priv *new) struct fcoe_rport *new)
{ {
LIBFCOE_FIP_DBG(fip, "claim resp from from rport %x - state %s\n", LIBFCOE_FIP_DBG(fip, "claim resp from from rport %x - state %s\n",
new->ids.port_id, fcoe_ctlr_state(fip->state)); new->rdata.ids.port_id, fcoe_ctlr_state(fip->state));
if (fip->state == FIP_ST_VNMP_UP || fip->state == FIP_ST_VNMP_CLAIM) if (fip->state == FIP_ST_VNMP_UP || fip->state == FIP_ST_VNMP_CLAIM)
fcoe_ctlr_vn_add(fip, new); fcoe_ctlr_vn_add(fip, new);
} }
...@@ -2632,28 +2635,28 @@ static void fcoe_ctlr_vn_claim_resp(struct fcoe_ctlr *fip, ...@@ -2632,28 +2635,28 @@ static void fcoe_ctlr_vn_claim_resp(struct fcoe_ctlr *fip,
/** /**
* fcoe_ctlr_vn_beacon() - handle received beacon. * fcoe_ctlr_vn_beacon() - handle received beacon.
* @fip: The FCoE controller that received the frame * @fip: The FCoE controller that received the frame
* @new: newly-parsed remote port with frport from the Beacon * @new: newly-parsed FCoE rport from the Beacon
* *
* Called with ctlr_mutex held. * Called with ctlr_mutex held.
*/ */
static void fcoe_ctlr_vn_beacon(struct fcoe_ctlr *fip, static void fcoe_ctlr_vn_beacon(struct fcoe_ctlr *fip,
struct fc_rport_priv *new) struct fcoe_rport *new)
{ {
struct fc_lport *lport = fip->lp; struct fc_lport *lport = fip->lp;
struct fc_rport_priv *rdata; struct fc_rport_priv *rdata;
struct fcoe_rport *frport; struct fcoe_rport *frport;
frport = fcoe_ctlr_rport(new); if (new->flags & FIP_FL_REC_OR_P2P) {
if (frport->flags & FIP_FL_REC_OR_P2P) {
LIBFCOE_FIP_DBG(fip, "p2p beacon while in vn2vn mode\n"); LIBFCOE_FIP_DBG(fip, "p2p beacon while in vn2vn mode\n");
fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0); fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0);
return; return;
} }
rdata = fc_rport_lookup(lport, new->ids.port_id); rdata = fc_rport_lookup(lport, new->rdata.ids.port_id);
if (rdata) { if (rdata) {
if (rdata->ids.node_name == new->ids.node_name && if (rdata->ids.node_name == new->rdata.ids.node_name &&
rdata->ids.port_name == new->ids.port_name) { rdata->ids.port_name == new->rdata.ids.port_name) {
frport = fcoe_ctlr_rport(rdata); frport = fcoe_ctlr_rport(rdata);
LIBFCOE_FIP_DBG(fip, "beacon from rport %x\n", LIBFCOE_FIP_DBG(fip, "beacon from rport %x\n",
rdata->ids.port_id); rdata->ids.port_id);
if (!frport->time && fip->state == FIP_ST_VNMP_UP) { if (!frport->time && fip->state == FIP_ST_VNMP_UP) {
...@@ -2676,7 +2679,7 @@ static void fcoe_ctlr_vn_beacon(struct fcoe_ctlr *fip, ...@@ -2676,7 +2679,7 @@ static void fcoe_ctlr_vn_beacon(struct fcoe_ctlr *fip,
* Don't add the neighbor yet. * Don't add the neighbor yet.
*/ */
LIBFCOE_FIP_DBG(fip, "beacon from new rport %x. sending claim notify\n", LIBFCOE_FIP_DBG(fip, "beacon from new rport %x. sending claim notify\n",
new->ids.port_id); new->rdata.ids.port_id);
if (time_after(jiffies, if (time_after(jiffies,
fip->sol_time + msecs_to_jiffies(FIP_VN_ANN_WAIT))) fip->sol_time + msecs_to_jiffies(FIP_VN_ANN_WAIT)))
fcoe_ctlr_vn_send_claim(fip); fcoe_ctlr_vn_send_claim(fip);
...@@ -2761,19 +2764,19 @@ static int fcoe_ctlr_vn_recv(struct fcoe_ctlr *fip, struct sk_buff *skb) ...@@ -2761,19 +2764,19 @@ static int fcoe_ctlr_vn_recv(struct fcoe_ctlr *fip, struct sk_buff *skb)
mutex_lock(&fip->ctlr_mutex); mutex_lock(&fip->ctlr_mutex);
switch (sub) { switch (sub) {
case FIP_SC_VN_PROBE_REQ: case FIP_SC_VN_PROBE_REQ:
fcoe_ctlr_vn_probe_req(fip, &frport.rdata); fcoe_ctlr_vn_probe_req(fip, &frport);
break; break;
case FIP_SC_VN_PROBE_REP: case FIP_SC_VN_PROBE_REP:
fcoe_ctlr_vn_probe_reply(fip, &frport.rdata); fcoe_ctlr_vn_probe_reply(fip, &frport);
break; break;
case FIP_SC_VN_CLAIM_NOTIFY: case FIP_SC_VN_CLAIM_NOTIFY:
fcoe_ctlr_vn_claim_notify(fip, &frport.rdata); fcoe_ctlr_vn_claim_notify(fip, &frport);
break; break;
case FIP_SC_VN_CLAIM_REP: case FIP_SC_VN_CLAIM_REP:
fcoe_ctlr_vn_claim_resp(fip, &frport.rdata); fcoe_ctlr_vn_claim_resp(fip, &frport);
break; break;
case FIP_SC_VN_BEACON: case FIP_SC_VN_BEACON:
fcoe_ctlr_vn_beacon(fip, &frport.rdata); fcoe_ctlr_vn_beacon(fip, &frport);
break; break;
default: default:
LIBFCOE_FIP_DBG(fip, "vn_recv unknown subcode %d\n", sub); LIBFCOE_FIP_DBG(fip, "vn_recv unknown subcode %d\n", sub);
...@@ -2949,13 +2952,13 @@ static void fcoe_ctlr_vlan_send(struct fcoe_ctlr *fip, ...@@ -2949,13 +2952,13 @@ static void fcoe_ctlr_vlan_send(struct fcoe_ctlr *fip,
/** /**
* fcoe_ctlr_vlan_disk_reply() - send FIP VLAN Discovery Notification. * fcoe_ctlr_vlan_disk_reply() - send FIP VLAN Discovery Notification.
* @fip: The FCoE controller * @fip: The FCoE controller
* @frport: The newly-parsed FCoE rport from the Discovery Request
* *
* Called with ctlr_mutex held. * Called with ctlr_mutex held.
*/ */
static void fcoe_ctlr_vlan_disc_reply(struct fcoe_ctlr *fip, static void fcoe_ctlr_vlan_disc_reply(struct fcoe_ctlr *fip,
struct fc_rport_priv *rdata) struct fcoe_rport *frport)
{ {
struct fcoe_rport *frport = fcoe_ctlr_rport(rdata);
enum fip_vlan_subcode sub = FIP_SC_VL_NOTE; enum fip_vlan_subcode sub = FIP_SC_VL_NOTE;
if (fip->mode == FIP_MODE_VN2VN) if (fip->mode == FIP_MODE_VN2VN)
...@@ -2986,7 +2989,7 @@ static int fcoe_ctlr_vlan_recv(struct fcoe_ctlr *fip, struct sk_buff *skb) ...@@ -2986,7 +2989,7 @@ static int fcoe_ctlr_vlan_recv(struct fcoe_ctlr *fip, struct sk_buff *skb)
} }
mutex_lock(&fip->ctlr_mutex); mutex_lock(&fip->ctlr_mutex);
if (sub == FIP_SC_VL_REQ) if (sub == FIP_SC_VL_REQ)
fcoe_ctlr_vlan_disc_reply(fip, &frport.rdata); fcoe_ctlr_vlan_disc_reply(fip, &frport);
mutex_unlock(&fip->ctlr_mutex); mutex_unlock(&fip->ctlr_mutex);
drop: drop:
......
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