Commit 5554345b authored by Joe Eykholt's avatar Joe Eykholt Committed by James Bottomley

[SCSI] libfcoe: Fix FIP ELS encapsulation details for FLOGI responses

When sending a FLOGI LS_ACC, which we only do in point-to-multipoint
mode, the MAC descriptor should have the granted MAC set to
0x0efd00 || D_ID.

When sending an LS_RJT, there should be no MAC descriptor.

When sending either an LS_ACC or LS_RJT, the subcode should indicate
an reply, not a request.
Signed-off-by: default avatarJoe Eykholt <jeykholt@cisco.com>
Signed-off-by: default avatarRobert Love <robert.w.love@intel.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent e10f8c66
...@@ -469,11 +469,15 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip, struct fc_lport *lport, ...@@ -469,11 +469,15 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip, struct fc_lport *lport,
struct fip_header fip; struct fip_header fip;
struct fip_encaps encaps; struct fip_encaps encaps;
} __attribute__((packed)) *cap; } __attribute__((packed)) *cap;
struct fc_frame_header *fh;
struct fip_mac_desc *mac; struct fip_mac_desc *mac;
struct fcoe_fcf *fcf; struct fcoe_fcf *fcf;
size_t dlen; size_t dlen;
u16 fip_flags; u16 fip_flags;
u8 op;
fh = (struct fc_frame_header *)skb->data;
op = *(u8 *)(fh + 1);
dlen = sizeof(struct fip_encaps) + skb->len; /* len before push */ dlen = sizeof(struct fip_encaps) + skb->len; /* len before push */
cap = (struct fip_encaps_head *)skb_push(skb, sizeof(*cap)); cap = (struct fip_encaps_head *)skb_push(skb, sizeof(*cap));
memset(cap, 0, sizeof(*cap)); memset(cap, 0, sizeof(*cap));
...@@ -481,6 +485,7 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip, struct fc_lport *lport, ...@@ -481,6 +485,7 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip, struct fc_lport *lport,
if (lport->point_to_multipoint) { if (lport->point_to_multipoint) {
if (fcoe_ctlr_vn_lookup(fip, d_id, cap->eth.h_dest)) if (fcoe_ctlr_vn_lookup(fip, d_id, cap->eth.h_dest))
return -ENODEV; return -ENODEV;
fip_flags = 0;
} else { } else {
fcf = fip->sel_fcf; fcf = fip->sel_fcf;
if (!fcf) if (!fcf)
...@@ -497,26 +502,35 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip, struct fc_lport *lport, ...@@ -497,26 +502,35 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip, struct fc_lport *lport,
cap->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER); cap->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
cap->fip.fip_op = htons(FIP_OP_LS); cap->fip.fip_op = htons(FIP_OP_LS);
cap->fip.fip_subcode = FIP_SC_REQ; if (op == ELS_LS_ACC || op == ELS_LS_RJT)
cap->fip.fip_dl_len = htons((dlen + sizeof(*mac)) / FIP_BPW); cap->fip.fip_subcode = FIP_SC_REP;
else
cap->fip.fip_subcode = FIP_SC_REQ;
cap->fip.fip_flags = htons(fip_flags); cap->fip.fip_flags = htons(fip_flags);
cap->encaps.fd_desc.fip_dtype = dtype; cap->encaps.fd_desc.fip_dtype = dtype;
cap->encaps.fd_desc.fip_dlen = dlen / FIP_BPW; cap->encaps.fd_desc.fip_dlen = dlen / FIP_BPW;
mac = (struct fip_mac_desc *)skb_put(skb, sizeof(*mac)); if (op != ELS_LS_RJT) {
memset(mac, 0, sizeof(*mac)); dlen += sizeof(*mac);
mac->fd_desc.fip_dtype = FIP_DT_MAC; mac = (struct fip_mac_desc *)skb_put(skb, sizeof(*mac));
mac->fd_desc.fip_dlen = sizeof(*mac) / FIP_BPW; memset(mac, 0, sizeof(*mac));
if (dtype != FIP_DT_FLOGI && dtype != FIP_DT_FDISC) { mac->fd_desc.fip_dtype = FIP_DT_MAC;
memcpy(mac->fd_mac, fip->get_src_addr(lport), ETH_ALEN); mac->fd_desc.fip_dlen = sizeof(*mac) / FIP_BPW;
} else if (fip_flags & FIP_FL_SPMA) { if (dtype != FIP_DT_FLOGI && dtype != FIP_DT_FDISC) {
LIBFCOE_FIP_DBG(fip, "FLOGI/FDISC sent with SPMA\n"); memcpy(mac->fd_mac, fip->get_src_addr(lport), ETH_ALEN);
memcpy(mac->fd_mac, fip->ctl_src_addr, ETH_ALEN); } else if (fip->mode == FIP_MODE_VN2VN) {
} else { hton24(mac->fd_mac, FIP_VN_FC_MAP);
LIBFCOE_FIP_DBG(fip, "FLOGI/FDISC sent with FPMA\n"); hton24(mac->fd_mac + 3, fip->port_id);
/* FPMA only FLOGI must leave the MAC desc set to all 0s */ } else if (fip_flags & FIP_FL_SPMA) {
LIBFCOE_FIP_DBG(fip, "FLOGI/FDISC sent with SPMA\n");
memcpy(mac->fd_mac, fip->ctl_src_addr, ETH_ALEN);
} else {
LIBFCOE_FIP_DBG(fip, "FLOGI/FDISC sent with FPMA\n");
/* FPMA only FLOGI. Must leave the MAC desc zeroed. */
}
} }
cap->fip.fip_dl_len = htons(dlen / FIP_BPW);
skb->protocol = htons(ETH_P_FIP); skb->protocol = htons(ETH_P_FIP);
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
......
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