hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/scsi/bnx2fc/bnx2fc_els.c
....@@ -610,7 +610,6 @@
610610 rc = bnx2fc_initiate_els(tgt, ELS_REC, &rec, sizeof(rec),
611611 bnx2fc_rec_compl, cb_arg,
612612 r_a_tov);
613
-rec_err:
614613 if (rc) {
615614 BNX2FC_IO_DBG(orig_io_req, "REC failed - release\n");
616615 spin_lock_bh(&tgt->tgt_lock);
....@@ -618,6 +617,7 @@
618617 spin_unlock_bh(&tgt->tgt_lock);
619618 kfree(cb_arg);
620619 }
620
+rec_err:
621621 return rc;
622622 }
623623
....@@ -654,7 +654,6 @@
654654 rc = bnx2fc_initiate_els(tgt, ELS_SRR, &srr, sizeof(srr),
655655 bnx2fc_srr_compl, cb_arg,
656656 r_a_tov);
657
-srr_err:
658657 if (rc) {
659658 BNX2FC_IO_DBG(orig_io_req, "SRR failed - release\n");
660659 spin_lock_bh(&tgt->tgt_lock);
....@@ -664,6 +663,7 @@
664663 } else
665664 set_bit(BNX2FC_FLAG_SRR_SENT, &orig_io_req->req_flags);
666665
666
+srr_err:
667667 return rc;
668668 }
669669
....@@ -854,33 +854,57 @@
854854 kref_put(&els_req->refcount, bnx2fc_cmd_release);
855855 }
856856
857
+#define BNX2FC_FCOE_MAC_METHOD_GRANGED_MAC 1
858
+#define BNX2FC_FCOE_MAC_METHOD_FCF_MAP 2
859
+#define BNX2FC_FCOE_MAC_METHOD_FCOE_SET_MAC 3
857860 static void bnx2fc_flogi_resp(struct fc_seq *seq, struct fc_frame *fp,
858861 void *arg)
859862 {
860863 struct fcoe_ctlr *fip = arg;
861864 struct fc_exch *exch = fc_seq_exch(seq);
862865 struct fc_lport *lport = exch->lp;
863
- u8 *mac;
864
- u8 op;
866
+
867
+ struct fc_frame_header *fh;
868
+ u8 *granted_mac;
869
+ u8 fcoe_mac[6];
870
+ u8 fc_map[3];
871
+ int method;
865872
866873 if (IS_ERR(fp))
867874 goto done;
868875
869
- mac = fr_cb(fp)->granted_mac;
870
- if (is_zero_ether_addr(mac)) {
871
- op = fc_frame_payload_op(fp);
872
- if (lport->vport) {
873
- if (op == ELS_LS_RJT) {
874
- printk(KERN_ERR PFX "bnx2fc_flogi_resp is LS_RJT\n");
875
- fc_vport_terminate(lport->vport);
876
- fc_frame_free(fp);
877
- return;
878
- }
879
- }
880
- fcoe_ctlr_recv_flogi(fip, lport, fp);
876
+ fh = fc_frame_header_get(fp);
877
+ granted_mac = fr_cb(fp)->granted_mac;
878
+
879
+ /*
880
+ * We set the source MAC for FCoE traffic based on the Granted MAC
881
+ * address from the switch.
882
+ *
883
+ * If granted_mac is non-zero, we use that.
884
+ * If the granted_mac is zeroed out, create the FCoE MAC based on
885
+ * the sel_fcf->fc_map and the d_id fo the FLOGI frame.
886
+ * If sel_fcf->fc_map is 0, then we use the default FCF-MAC plus the
887
+ * d_id of the FLOGI frame.
888
+ */
889
+ if (!is_zero_ether_addr(granted_mac)) {
890
+ ether_addr_copy(fcoe_mac, granted_mac);
891
+ method = BNX2FC_FCOE_MAC_METHOD_GRANGED_MAC;
892
+ } else if (fip->sel_fcf && fip->sel_fcf->fc_map != 0) {
893
+ hton24(fc_map, fip->sel_fcf->fc_map);
894
+ fcoe_mac[0] = fc_map[0];
895
+ fcoe_mac[1] = fc_map[1];
896
+ fcoe_mac[2] = fc_map[2];
897
+ fcoe_mac[3] = fh->fh_d_id[0];
898
+ fcoe_mac[4] = fh->fh_d_id[1];
899
+ fcoe_mac[5] = fh->fh_d_id[2];
900
+ method = BNX2FC_FCOE_MAC_METHOD_FCF_MAP;
901
+ } else {
902
+ fc_fcoe_set_mac(fcoe_mac, fh->fh_d_id);
903
+ method = BNX2FC_FCOE_MAC_METHOD_FCOE_SET_MAC;
881904 }
882
- if (!is_zero_ether_addr(mac))
883
- fip->update_mac(lport, mac);
905
+
906
+ BNX2FC_HBA_DBG(lport, "fcoe_mac=%pM method=%d\n", fcoe_mac, method);
907
+ fip->update_mac(lport, fcoe_mac);
884908 done:
885909 fc_lport_flogi_resp(seq, fp, lport);
886910 }