hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/scsi/fcoe/fcoe_ctlr.c
....@@ -1,19 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
34 * Copyright (c) 2009 Intel Corporation. All rights reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms and conditions of the GNU General Public License,
7
- * version 2, as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program; if not, write to the Free Software Foundation, Inc.,
16
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
175 *
186 * Maintained at www.Open-FCoE.org
197 */
....@@ -146,6 +134,7 @@
146134 /**
147135 * fcoe_ctlr_init() - Initialize the FCoE Controller instance
148136 * @fip: The FCoE controller to initialize
137
+ * @mode: FIP mode to set
149138 */
150139 void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_mode mode)
151140 {
....@@ -348,7 +337,7 @@
348337 printk(KERN_NOTICE "libfcoe: host%d: "
349338 "FIP Fibre-Channel Forwarder MAC %pM deselected\n",
350339 fip->lp->host->host_no, fip->dest_addr);
351
- memset(fip->dest_addr, 0, ETH_ALEN);
340
+ eth_zero_addr(fip->dest_addr);
352341 }
353342 if (sel) {
354343 printk(KERN_INFO "libfcoe: host%d: FIP selected "
....@@ -461,10 +450,10 @@
461450 switch (fip->mode) {
462451 default:
463452 LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
464
- /* fall-through */
453
+ fallthrough;
465454 case FIP_MODE_AUTO:
466455 LIBFCOE_FIP_DBG(fip, "%s", "setting AUTO mode.\n");
467
- /* fall-through */
456
+ fallthrough;
468457 case FIP_MODE_FABRIC:
469458 case FIP_MODE_NON_FIP:
470459 mutex_unlock(&fip->ctlr_mutex);
....@@ -599,6 +588,7 @@
599588 /**
600589 * fcoe_ctlr_encaps() - Encapsulate an ELS frame for FIP, without sending it
601590 * @fip: The FCoE controller for the ELS frame
591
+ * @lport: The local port
602592 * @dtype: The FIP descriptor type for the frame
603593 * @skb: The FCoE ELS frame including FC header but no FCoE headers
604594 * @d_id: The destination port ID.
....@@ -783,7 +773,7 @@
783773 fc_fcoe_set_mac(mac, fh->fh_d_id);
784774 fip->update_mac(lport, mac);
785775 }
786
- /* fall through */
776
+ fallthrough;
787777 case ELS_LS_RJT:
788778 op = fr_encaps(fp);
789779 if (op)
....@@ -1031,7 +1021,7 @@
10311021 {
10321022 struct fcoe_fcf *fcf;
10331023 struct fcoe_fcf new;
1034
- unsigned long sol_tov = msecs_to_jiffies(FCOE_CTRL_SOL_TOV);
1024
+ unsigned long sol_tov = msecs_to_jiffies(FCOE_CTLR_SOL_TOV);
10351025 int first = 0;
10361026 int mtu_valid;
10371027 int found = 0;
....@@ -1314,7 +1304,7 @@
13141304 /**
13151305 * fcoe_ctlr_recv_els() - Handle an incoming link reset frame
13161306 * @fip: The FCoE controller that received the frame
1317
- * @fh: The received FIP header
1307
+ * @skb: The received FIP packet
13181308 *
13191309 * There may be multiple VN_Port descriptors.
13201310 * The overall length has already been checked.
....@@ -1787,7 +1777,7 @@
17871777
17881778 /**
17891779 * fcoe_ctlr_timeout() - FIP timeout handler
1790
- * @arg: The FCoE controller that timed out
1780
+ * @t: Timer context use to obtain the controller reference
17911781 */
17921782 static void fcoe_ctlr_timeout(struct timer_list *t)
17931783 {
....@@ -1899,6 +1889,7 @@
18991889 /**
19001890 * fcoe_ctlr_recv_flogi() - Snoop pre-FIP receipt of FLOGI response
19011891 * @fip: The FCoE controller
1892
+ * @lport: The local port
19021893 * @fp: The FC frame to snoop
19031894 *
19041895 * Snoop potential response to FLOGI or even incoming FLOGI.
....@@ -1978,7 +1969,7 @@
19781969 *
19791970 * Returns: u64 fc world wide name
19801971 */
1981
-u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN],
1972
+u64 fcoe_wwn_from_mac(unsigned char mac[ETH_ALEN],
19821973 unsigned int scheme, unsigned int port)
19831974 {
19841975 u64 wwn;
....@@ -2170,7 +2161,7 @@
21702161
21712162 /**
21722163 * fcoe_ctlr_disc_stop_locked() - stop discovery in VN2VN mode
2173
- * @fip: The FCoE controller
2164
+ * @lport: The local port
21742165 *
21752166 * Called with ctlr_mutex held.
21762167 */
....@@ -2191,7 +2182,7 @@
21912182
21922183 /**
21932184 * fcoe_ctlr_disc_stop() - stop discovery in VN2VN mode
2194
- * @fip: The FCoE controller
2185
+ * @lport: The local port
21952186 *
21962187 * Called through the local port template for discovery.
21972188 * Called without the ctlr_mutex held.
....@@ -2207,7 +2198,7 @@
22072198
22082199 /**
22092200 * fcoe_ctlr_disc_stop_final() - stop discovery for shutdown in VN2VN mode
2210
- * @fip: The FCoE controller
2201
+ * @lport: The local port
22112202 *
22122203 * Called through the local port template for discovery.
22132204 * Called without the ctlr_mutex held.
....@@ -2274,7 +2265,7 @@
22742265 * fcoe_ctlr_vn_parse - parse probe request or response
22752266 * @fip: The FCoE controller
22762267 * @skb: incoming packet
2277
- * @rdata: buffer for resulting parsed VN entry plus fcoe_rport
2268
+ * @frport: parsed FCoE rport from the probe request
22782269 *
22792270 * Returns non-zero error number on error.
22802271 * Does not consume the packet.
....@@ -2413,16 +2404,14 @@
24132404 /**
24142405 * fcoe_ctlr_vn_probe_req() - handle incoming VN2VN probe request.
24152406 * @fip: The FCoE controller
2416
- * @rdata: parsed remote port with frport from the probe request
2407
+ * @frport: parsed FCoE rport from the probe request
24172408 *
24182409 * Called with ctlr_mutex held.
24192410 */
24202411 static void fcoe_ctlr_vn_probe_req(struct fcoe_ctlr *fip,
2421
- struct fc_rport_priv *rdata)
2412
+ struct fcoe_rport *frport)
24222413 {
2423
- struct fcoe_rport *frport = fcoe_ctlr_rport(rdata);
2424
-
2425
- if (rdata->ids.port_id != fip->port_id)
2414
+ if (frport->rdata.ids.port_id != fip->port_id)
24262415 return;
24272416
24282417 switch (fip->state) {
....@@ -2442,7 +2431,7 @@
24422431 * Probe's REC bit is not set.
24432432 * If we don't reply, we will change our address.
24442433 */
2445
- if (fip->lp->wwpn > rdata->ids.port_name &&
2434
+ if (fip->lp->wwpn > frport->rdata.ids.port_name &&
24462435 !(frport->flags & FIP_FL_REC_OR_P2P)) {
24472436 LIBFCOE_FIP_DBG(fip, "vn_probe_req: "
24482437 "port_id collision\n");
....@@ -2450,7 +2439,7 @@
24502439 frport->enode_mac, 0);
24512440 break;
24522441 }
2453
- /* fall through */
2442
+ fallthrough;
24542443 case FIP_ST_VNMP_START:
24552444 LIBFCOE_FIP_DBG(fip, "vn_probe_req: "
24562445 "restart VN2VN negotiation\n");
....@@ -2466,14 +2455,14 @@
24662455 /**
24672456 * fcoe_ctlr_vn_probe_reply() - handle incoming VN2VN probe reply.
24682457 * @fip: The FCoE controller
2469
- * @rdata: parsed remote port with frport from the probe request
2458
+ * @frport: parsed FCoE rport from the probe request
24702459 *
24712460 * Called with ctlr_mutex held.
24722461 */
24732462 static void fcoe_ctlr_vn_probe_reply(struct fcoe_ctlr *fip,
2474
- struct fc_rport_priv *rdata)
2463
+ struct fcoe_rport *frport)
24752464 {
2476
- if (rdata->ids.port_id != fip->port_id)
2465
+ if (frport->rdata.ids.port_id != fip->port_id)
24772466 return;
24782467 switch (fip->state) {
24792468 case FIP_ST_VNMP_START:
....@@ -2496,11 +2485,11 @@
24962485 /**
24972486 * fcoe_ctlr_vn_add() - Add a VN2VN entry to the list, based on a claim reply.
24982487 * @fip: The FCoE controller
2499
- * @new: newly-parsed remote port with frport as a template for new rdata
2488
+ * @new: newly-parsed FCoE rport as a template for new rdata
25002489 *
25012490 * Called with ctlr_mutex held.
25022491 */
2503
-static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fc_rport_priv *new)
2492
+static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fcoe_rport *new)
25042493 {
25052494 struct fc_lport *lport = fip->lp;
25062495 struct fc_rport_priv *rdata;
....@@ -2508,7 +2497,7 @@
25082497 struct fcoe_rport *frport;
25092498 u32 port_id;
25102499
2511
- port_id = new->ids.port_id;
2500
+ port_id = new->rdata.ids.port_id;
25122501 if (port_id == fip->port_id)
25132502 return;
25142503
....@@ -2525,22 +2514,28 @@
25252514 rdata->disc_id = lport->disc.disc_id;
25262515
25272516 ids = &rdata->ids;
2528
- if ((ids->port_name != -1 && ids->port_name != new->ids.port_name) ||
2529
- (ids->node_name != -1 && ids->node_name != new->ids.node_name)) {
2517
+ if ((ids->port_name != -1 &&
2518
+ ids->port_name != new->rdata.ids.port_name) ||
2519
+ (ids->node_name != -1 &&
2520
+ ids->node_name != new->rdata.ids.node_name)) {
25302521 mutex_unlock(&rdata->rp_mutex);
25312522 LIBFCOE_FIP_DBG(fip, "vn_add rport logoff %6.6x\n", port_id);
25322523 fc_rport_logoff(rdata);
25332524 mutex_lock(&rdata->rp_mutex);
25342525 }
2535
- ids->port_name = new->ids.port_name;
2536
- ids->node_name = new->ids.node_name;
2526
+ ids->port_name = new->rdata.ids.port_name;
2527
+ ids->node_name = new->rdata.ids.node_name;
25372528 mutex_unlock(&rdata->rp_mutex);
25382529
25392530 frport = fcoe_ctlr_rport(rdata);
25402531 LIBFCOE_FIP_DBG(fip, "vn_add rport %6.6x %s state %d\n",
25412532 port_id, frport->fcoe_len ? "old" : "new",
25422533 rdata->rp_state);
2543
- *frport = *fcoe_ctlr_rport(new);
2534
+ frport->fcoe_len = new->fcoe_len;
2535
+ frport->flags = new->flags;
2536
+ frport->login_count = new->login_count;
2537
+ memcpy(frport->enode_mac, new->enode_mac, ETH_ALEN);
2538
+ memcpy(frport->vn_mac, new->vn_mac, ETH_ALEN);
25442539 frport->time = 0;
25452540 }
25462541
....@@ -2572,16 +2567,14 @@
25722567 /**
25732568 * fcoe_ctlr_vn_claim_notify() - handle received FIP VN2VN Claim Notification
25742569 * @fip: The FCoE controller
2575
- * @new: newly-parsed remote port with frport as a template for new rdata
2570
+ * @new: newly-parsed FCoE rport as a template for new rdata
25762571 *
25772572 * Called with ctlr_mutex held.
25782573 */
25792574 static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip,
2580
- struct fc_rport_priv *new)
2575
+ struct fcoe_rport *new)
25812576 {
2582
- struct fcoe_rport *frport = fcoe_ctlr_rport(new);
2583
-
2584
- if (frport->flags & FIP_FL_REC_OR_P2P) {
2577
+ if (new->flags & FIP_FL_REC_OR_P2P) {
25852578 LIBFCOE_FIP_DBG(fip, "send probe req for P2P/REC\n");
25862579 fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0);
25872580 return;
....@@ -2590,7 +2583,7 @@
25902583 case FIP_ST_VNMP_START:
25912584 case FIP_ST_VNMP_PROBE1:
25922585 case FIP_ST_VNMP_PROBE2:
2593
- if (new->ids.port_id == fip->port_id) {
2586
+ if (new->rdata.ids.port_id == fip->port_id) {
25942587 LIBFCOE_FIP_DBG(fip, "vn_claim_notify: "
25952588 "restart, state %d\n",
25962589 fip->state);
....@@ -2599,8 +2592,8 @@
25992592 break;
26002593 case FIP_ST_VNMP_CLAIM:
26012594 case FIP_ST_VNMP_UP:
2602
- if (new->ids.port_id == fip->port_id) {
2603
- if (new->ids.port_name > fip->lp->wwpn) {
2595
+ if (new->rdata.ids.port_id == fip->port_id) {
2596
+ if (new->rdata.ids.port_name > fip->lp->wwpn) {
26042597 LIBFCOE_FIP_DBG(fip, "vn_claim_notify: "
26052598 "restart, port_id collision\n");
26062599 fcoe_ctlr_vn_restart(fip);
....@@ -2612,15 +2605,16 @@
26122605 break;
26132606 }
26142607 LIBFCOE_FIP_DBG(fip, "vn_claim_notify: send reply to %x\n",
2615
- new->ids.port_id);
2616
- fcoe_ctlr_vn_send(fip, FIP_SC_VN_CLAIM_REP, frport->enode_mac,
2617
- min((u32)frport->fcoe_len,
2608
+ new->rdata.ids.port_id);
2609
+ fcoe_ctlr_vn_send(fip, FIP_SC_VN_CLAIM_REP, new->enode_mac,
2610
+ min((u32)new->fcoe_len,
26182611 fcoe_ctlr_fcoe_size(fip)));
26192612 fcoe_ctlr_vn_add(fip, new);
26202613 break;
26212614 default:
26222615 LIBFCOE_FIP_DBG(fip, "vn_claim_notify: "
2623
- "ignoring claim from %x\n", new->ids.port_id);
2616
+ "ignoring claim from %x\n",
2617
+ new->rdata.ids.port_id);
26242618 break;
26252619 }
26262620 }
....@@ -2628,15 +2622,15 @@
26282622 /**
26292623 * fcoe_ctlr_vn_claim_resp() - handle received Claim Response
26302624 * @fip: The FCoE controller that received the frame
2631
- * @new: newly-parsed remote port with frport from the Claim Response
2625
+ * @new: newly-parsed FCoE rport from the Claim Response
26322626 *
26332627 * Called with ctlr_mutex held.
26342628 */
26352629 static void fcoe_ctlr_vn_claim_resp(struct fcoe_ctlr *fip,
2636
- struct fc_rport_priv *new)
2630
+ struct fcoe_rport *new)
26372631 {
26382632 LIBFCOE_FIP_DBG(fip, "claim resp from from rport %x - state %s\n",
2639
- new->ids.port_id, fcoe_ctlr_state(fip->state));
2633
+ new->rdata.ids.port_id, fcoe_ctlr_state(fip->state));
26402634 if (fip->state == FIP_ST_VNMP_UP || fip->state == FIP_ST_VNMP_CLAIM)
26412635 fcoe_ctlr_vn_add(fip, new);
26422636 }
....@@ -2644,28 +2638,28 @@
26442638 /**
26452639 * fcoe_ctlr_vn_beacon() - handle received beacon.
26462640 * @fip: The FCoE controller that received the frame
2647
- * @new: newly-parsed remote port with frport from the Beacon
2641
+ * @new: newly-parsed FCoE rport from the Beacon
26482642 *
26492643 * Called with ctlr_mutex held.
26502644 */
26512645 static void fcoe_ctlr_vn_beacon(struct fcoe_ctlr *fip,
2652
- struct fc_rport_priv *new)
2646
+ struct fcoe_rport *new)
26532647 {
26542648 struct fc_lport *lport = fip->lp;
26552649 struct fc_rport_priv *rdata;
26562650 struct fcoe_rport *frport;
26572651
2658
- frport = fcoe_ctlr_rport(new);
2659
- if (frport->flags & FIP_FL_REC_OR_P2P) {
2652
+ if (new->flags & FIP_FL_REC_OR_P2P) {
26602653 LIBFCOE_FIP_DBG(fip, "p2p beacon while in vn2vn mode\n");
26612654 fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0);
26622655 return;
26632656 }
2664
- rdata = fc_rport_lookup(lport, new->ids.port_id);
2657
+ rdata = fc_rport_lookup(lport, new->rdata.ids.port_id);
26652658 if (rdata) {
2666
- if (rdata->ids.node_name == new->ids.node_name &&
2667
- rdata->ids.port_name == new->ids.port_name) {
2659
+ if (rdata->ids.node_name == new->rdata.ids.node_name &&
2660
+ rdata->ids.port_name == new->rdata.ids.port_name) {
26682661 frport = fcoe_ctlr_rport(rdata);
2662
+
26692663 LIBFCOE_FIP_DBG(fip, "beacon from rport %x\n",
26702664 rdata->ids.port_id);
26712665 if (!frport->time && fip->state == FIP_ST_VNMP_UP) {
....@@ -2688,7 +2682,7 @@
26882682 * Don't add the neighbor yet.
26892683 */
26902684 LIBFCOE_FIP_DBG(fip, "beacon from new rport %x. sending claim notify\n",
2691
- new->ids.port_id);
2685
+ new->rdata.ids.port_id);
26922686 if (time_after(jiffies,
26932687 fip->sol_time + msecs_to_jiffies(FIP_VN_ANN_WAIT)))
26942688 fcoe_ctlr_vn_send_claim(fip);
....@@ -2773,19 +2767,19 @@
27732767 mutex_lock(&fip->ctlr_mutex);
27742768 switch (sub) {
27752769 case FIP_SC_VN_PROBE_REQ:
2776
- fcoe_ctlr_vn_probe_req(fip, &frport.rdata);
2770
+ fcoe_ctlr_vn_probe_req(fip, &frport);
27772771 break;
27782772 case FIP_SC_VN_PROBE_REP:
2779
- fcoe_ctlr_vn_probe_reply(fip, &frport.rdata);
2773
+ fcoe_ctlr_vn_probe_reply(fip, &frport);
27802774 break;
27812775 case FIP_SC_VN_CLAIM_NOTIFY:
2782
- fcoe_ctlr_vn_claim_notify(fip, &frport.rdata);
2776
+ fcoe_ctlr_vn_claim_notify(fip, &frport);
27832777 break;
27842778 case FIP_SC_VN_CLAIM_REP:
2785
- fcoe_ctlr_vn_claim_resp(fip, &frport.rdata);
2779
+ fcoe_ctlr_vn_claim_resp(fip, &frport);
27862780 break;
27872781 case FIP_SC_VN_BEACON:
2788
- fcoe_ctlr_vn_beacon(fip, &frport.rdata);
2782
+ fcoe_ctlr_vn_beacon(fip, &frport);
27892783 break;
27902784 default:
27912785 LIBFCOE_FIP_DBG(fip, "vn_recv unknown subcode %d\n", sub);
....@@ -2802,7 +2796,7 @@
28022796 * fcoe_ctlr_vlan_parse - parse vlan discovery request or response
28032797 * @fip: The FCoE controller
28042798 * @skb: incoming packet
2805
- * @rdata: buffer for resulting parsed VLAN entry plus fcoe_rport
2799
+ * @frport: parsed FCoE rport from the probe request
28062800 *
28072801 * Returns non-zero error number on error.
28082802 * Does not consume the packet.
....@@ -2901,7 +2895,6 @@
29012895 * @fip: The FCoE controller
29022896 * @sub: sub-opcode for vlan notification or vn2vn vlan notification
29032897 * @dest: The destination Ethernet MAC address
2904
- * @min_len: minimum size of the Ethernet payload to be sent
29052898 */
29062899 static void fcoe_ctlr_vlan_send(struct fcoe_ctlr *fip,
29072900 enum fip_vlan_subcode sub,
....@@ -2961,13 +2954,13 @@
29612954 /**
29622955 * fcoe_ctlr_vlan_disk_reply() - send FIP VLAN Discovery Notification.
29632956 * @fip: The FCoE controller
2957
+ * @frport: The newly-parsed FCoE rport from the Discovery Request
29642958 *
29652959 * Called with ctlr_mutex held.
29662960 */
29672961 static void fcoe_ctlr_vlan_disc_reply(struct fcoe_ctlr *fip,
2968
- struct fc_rport_priv *rdata)
2962
+ struct fcoe_rport *frport)
29692963 {
2970
- struct fcoe_rport *frport = fcoe_ctlr_rport(rdata);
29712964 enum fip_vlan_subcode sub = FIP_SC_VL_NOTE;
29722965
29732966 if (fip->mode == FIP_MODE_VN2VN)
....@@ -2978,9 +2971,8 @@
29782971
29792972 /**
29802973 * fcoe_ctlr_vlan_recv - vlan request receive handler for VN2VN mode.
2981
- * @lport: The local port
2982
- * @fp: The received frame
2983
- *
2974
+ * @fip: The FCoE controller
2975
+ * @skb: The received FIP packet
29842976 */
29852977 static int fcoe_ctlr_vlan_recv(struct fcoe_ctlr *fip, struct sk_buff *skb)
29862978 {
....@@ -2998,7 +2990,7 @@
29982990 }
29992991 mutex_lock(&fip->ctlr_mutex);
30002992 if (sub == FIP_SC_VL_REQ)
3001
- fcoe_ctlr_vlan_disc_reply(fip, &frport.rdata);
2993
+ fcoe_ctlr_vlan_disc_reply(fip, &frport);
30022994 mutex_unlock(&fip->ctlr_mutex);
30032995
30042996 drop:
....@@ -3024,9 +3016,8 @@
30243016 fc_frame_free(fp);
30253017 }
30263018
3027
-/**
3028
- * fcoe_ctlr_disc_recv - start discovery for VN2VN mode.
3029
- * @fip: The FCoE controller
3019
+/*
3020
+ * fcoe_ctlr_disc_start - start discovery for VN2VN mode.
30303021 *
30313022 * This sets a flag indicating that remote ports should be created
30323023 * and started for the peers we discover. We use the disc_callback