forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/qlogic/qed/qed_fcoe.c
....@@ -1,33 +1,7 @@
1
+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
12 /* QLogic qed NIC Driver
23 * Copyright (c) 2015-2017 QLogic Corporation
3
- *
4
- * This software is available to you under a choice of one of two
5
- * licenses. You may choose to be licensed under the terms of the GNU
6
- * General Public License (GPL) Version 2, available from the file
7
- * COPYING in the main directory of this source tree, or the
8
- * OpenIB.org BSD license below:
9
- *
10
- * Redistribution and use in source and binary forms, with or
11
- * without modification, are permitted provided that the following
12
- * conditions are met:
13
- *
14
- * - Redistributions of source code must retain the above
15
- * copyright notice, this list of conditions and the following
16
- * disclaimer.
17
- *
18
- * - Redistributions in binary form must reproduce the above
19
- * copyright notice, this list of conditions and the following
20
- * disclaimer in the documentation and /or other materials
21
- * provided with the distribution.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
4
+ * Copyright (c) 2019-2020 Marvell International Ltd.
315 */
326
337 #include <linux/types.h>
....@@ -121,7 +95,7 @@
12195 struct qed_cxt_info cxt_info;
12296 u32 dummy_cid;
12397 int rc = 0;
124
- u16 tmp;
98
+ __le16 tmp;
12599 u8 i;
126100
127101 /* Get SPQ entry */
....@@ -167,6 +141,8 @@
167141 goto err;
168142 }
169143 p_cxt = cxt_info.p_cxt;
144
+ memset(p_cxt, 0, sizeof(*p_cxt));
145
+
170146 SET_FIELD(p_cxt->tstorm_ag_context.flags3,
171147 E4_TSTORM_FCOE_CONN_AG_CTX_DUMMY_TIMER_CF_EN, 1);
172148
....@@ -186,17 +162,13 @@
186162 tmp = cpu_to_le16(fcoe_pf_params->cmdq_num_entries);
187163 p_data->q_params.cmdq_num_entries = tmp;
188164
189
- tmp = fcoe_pf_params->num_cqs;
190
- p_data->q_params.num_queues = (u8)tmp;
165
+ p_data->q_params.num_queues = fcoe_pf_params->num_cqs;
191166
192
- tmp = (u16)p_hwfn->hw_info.resc_start[QED_CMDQS_CQS];
193
- p_data->q_params.queue_relative_offset = (u8)tmp;
167
+ tmp = (__force __le16)p_hwfn->hw_info.resc_start[QED_CMDQS_CQS];
168
+ p_data->q_params.queue_relative_offset = (__force u8)tmp;
194169
195170 for (i = 0; i < fcoe_pf_params->num_cqs; i++) {
196
- u16 igu_sb_id;
197
-
198
- igu_sb_id = qed_get_igu_sb_id(p_hwfn, i);
199
- tmp = cpu_to_le16(igu_sb_id);
171
+ tmp = cpu_to_le16(qed_get_igu_sb_id(p_hwfn, i));
200172 p_data->q_params.cq_cmdq_sb_num_arr[i] = tmp;
201173 }
202174
....@@ -209,21 +181,21 @@
209181 fcoe_pf_params->bdq_pbl_base_addr[BDQ_ID_RQ]);
210182 p_data->q_params.bdq_pbl_num_entries[BDQ_ID_RQ] =
211183 fcoe_pf_params->bdq_pbl_num_entries[BDQ_ID_RQ];
212
- tmp = fcoe_pf_params->bdq_xoff_threshold[BDQ_ID_RQ];
213
- p_data->q_params.bdq_xoff_threshold[BDQ_ID_RQ] = cpu_to_le16(tmp);
214
- tmp = fcoe_pf_params->bdq_xon_threshold[BDQ_ID_RQ];
215
- p_data->q_params.bdq_xon_threshold[BDQ_ID_RQ] = cpu_to_le16(tmp);
184
+ tmp = cpu_to_le16(fcoe_pf_params->bdq_xoff_threshold[BDQ_ID_RQ]);
185
+ p_data->q_params.bdq_xoff_threshold[BDQ_ID_RQ] = tmp;
186
+ tmp = cpu_to_le16(fcoe_pf_params->bdq_xon_threshold[BDQ_ID_RQ]);
187
+ p_data->q_params.bdq_xon_threshold[BDQ_ID_RQ] = tmp;
216188
217189 DMA_REGPAIR_LE(p_data->q_params.bdq_pbl_base_address[BDQ_ID_IMM_DATA],
218190 fcoe_pf_params->bdq_pbl_base_addr[BDQ_ID_IMM_DATA]);
219191 p_data->q_params.bdq_pbl_num_entries[BDQ_ID_IMM_DATA] =
220192 fcoe_pf_params->bdq_pbl_num_entries[BDQ_ID_IMM_DATA];
221
- tmp = fcoe_pf_params->bdq_xoff_threshold[BDQ_ID_IMM_DATA];
222
- p_data->q_params.bdq_xoff_threshold[BDQ_ID_IMM_DATA] = cpu_to_le16(tmp);
223
- tmp = fcoe_pf_params->bdq_xon_threshold[BDQ_ID_IMM_DATA];
224
- p_data->q_params.bdq_xon_threshold[BDQ_ID_IMM_DATA] = cpu_to_le16(tmp);
225
- tmp = fcoe_pf_params->rq_buffer_size;
226
- p_data->q_params.rq_buffer_size = cpu_to_le16(tmp);
193
+ tmp = cpu_to_le16(fcoe_pf_params->bdq_xoff_threshold[BDQ_ID_IMM_DATA]);
194
+ p_data->q_params.bdq_xoff_threshold[BDQ_ID_IMM_DATA] = tmp;
195
+ tmp = cpu_to_le16(fcoe_pf_params->bdq_xon_threshold[BDQ_ID_IMM_DATA]);
196
+ p_data->q_params.bdq_xon_threshold[BDQ_ID_IMM_DATA] = tmp;
197
+ tmp = cpu_to_le16(fcoe_pf_params->rq_buffer_size);
198
+ p_data->q_params.rq_buffer_size = tmp;
227199
228200 if (fcoe_pf_params->is_target) {
229201 SET_FIELD(p_data->q_params.q_validity,
....@@ -257,7 +229,8 @@
257229 struct fcoe_conn_offload_ramrod_data *p_data;
258230 struct qed_spq_entry *p_ent = NULL;
259231 struct qed_sp_init_data init_data;
260
- u16 physical_q0, tmp;
232
+ u16 physical_q0;
233
+ __le16 tmp;
261234 int rc;
262235
263236 /* Get SPQ entry */
....@@ -278,7 +251,7 @@
278251
279252 /* Transmission PQ is the first of the PF */
280253 physical_q0 = qed_get_cm_pq_idx(p_hwfn, PQ_FLAGS_OFLD);
281
- p_conn->physical_q0 = cpu_to_le16(physical_q0);
254
+ p_conn->physical_q0 = physical_q0;
282255 p_data->physical_q0 = cpu_to_le16(physical_q0);
283256
284257 p_data->conn_id = cpu_to_le16(p_conn->conn_id);
....@@ -577,8 +550,8 @@
577550 void qed_fcoe_setup(struct qed_hwfn *p_hwfn)
578551 {
579552 struct e4_fcoe_task_context *p_task_ctx = NULL;
553
+ u32 i, lc;
580554 int rc;
581
- u32 i;
582555
583556 spin_lock_init(&p_hwfn->p_fcoe_info->lock);
584557 for (i = 0; i < p_hwfn->pf_params.fcoe_pf_params.num_tasks; i++) {
....@@ -589,10 +562,15 @@
589562 continue;
590563
591564 memset(p_task_ctx, 0, sizeof(struct e4_fcoe_task_context));
592
- SET_FIELD(p_task_ctx->timer_context.logical_client_0,
593
- TIMERS_CONTEXT_VALIDLC0, 1);
594
- SET_FIELD(p_task_ctx->timer_context.logical_client_1,
595
- TIMERS_CONTEXT_VALIDLC1, 1);
565
+
566
+ lc = 0;
567
+ SET_FIELD(lc, TIMERS_CONTEXT_VALIDLC0, 1);
568
+ p_task_ctx->timer_context.logical_client_0 = cpu_to_le32(lc);
569
+
570
+ lc = 0;
571
+ SET_FIELD(lc, TIMERS_CONTEXT_VALIDLC1, 1);
572
+ p_task_ctx->timer_context.logical_client_1 = cpu_to_le32(lc);
573
+
596574 SET_FIELD(p_task_ctx->tstorm_ag_context.flags0,
597575 E4_TSTORM_FCOE_TASK_AG_CTX_CONNECTION_TYPE, 1);
598576 }
....@@ -745,7 +723,7 @@
745723 static int qed_fill_fcoe_dev_info(struct qed_dev *cdev,
746724 struct qed_dev_fcoe_info *info)
747725 {
748
- struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
726
+ struct qed_hwfn *hwfn = QED_AFFIN_HWFN(cdev);
749727 int rc;
750728
751729 memset(info, 0, sizeof(*info));
....@@ -806,15 +784,15 @@
806784 return -EINVAL;
807785 }
808786
809
- p_ptt = qed_ptt_acquire(QED_LEADING_HWFN(cdev));
787
+ p_ptt = qed_ptt_acquire(QED_AFFIN_HWFN(cdev));
810788 if (!p_ptt)
811789 return -EAGAIN;
812790
813791 /* Stop the fcoe */
814
- rc = qed_sp_fcoe_func_stop(QED_LEADING_HWFN(cdev), p_ptt,
792
+ rc = qed_sp_fcoe_func_stop(QED_AFFIN_HWFN(cdev), p_ptt,
815793 QED_SPQ_MODE_EBLOCK, NULL);
816794 cdev->flags &= ~QED_FLAG_STORAGE_STARTED;
817
- qed_ptt_release(QED_LEADING_HWFN(cdev), p_ptt);
795
+ qed_ptt_release(QED_AFFIN_HWFN(cdev), p_ptt);
818796
819797 return rc;
820798 }
....@@ -828,8 +806,8 @@
828806 return 0;
829807 }
830808
831
- rc = qed_sp_fcoe_func_start(QED_LEADING_HWFN(cdev),
832
- QED_SPQ_MODE_EBLOCK, NULL);
809
+ rc = qed_sp_fcoe_func_start(QED_AFFIN_HWFN(cdev), QED_SPQ_MODE_EBLOCK,
810
+ NULL);
833811 if (rc) {
834812 DP_NOTICE(cdev, "Failed to start fcoe\n");
835813 return rc;
....@@ -849,7 +827,7 @@
849827 return -ENOMEM;
850828 }
851829
852
- rc = qed_cxt_get_tid_mem_info(QED_LEADING_HWFN(cdev), tid_info);
830
+ rc = qed_cxt_get_tid_mem_info(QED_AFFIN_HWFN(cdev), tid_info);
853831 if (rc) {
854832 DP_NOTICE(cdev, "Failed to gather task information\n");
855833 qed_fcoe_stop(cdev);
....@@ -884,7 +862,7 @@
884862 }
885863
886864 /* Acquire the connection */
887
- rc = qed_fcoe_acquire_connection(QED_LEADING_HWFN(cdev), NULL,
865
+ rc = qed_fcoe_acquire_connection(QED_AFFIN_HWFN(cdev), NULL,
888866 &hash_con->con);
889867 if (rc) {
890868 DP_NOTICE(cdev, "Failed to acquire Connection\n");
....@@ -898,7 +876,7 @@
898876 hash_add(cdev->connections, &hash_con->node, *handle);
899877
900878 if (p_doorbell)
901
- *p_doorbell = qed_fcoe_get_db_addr(QED_LEADING_HWFN(cdev),
879
+ *p_doorbell = qed_fcoe_get_db_addr(QED_AFFIN_HWFN(cdev),
902880 *handle);
903881
904882 return 0;
....@@ -916,7 +894,7 @@
916894 }
917895
918896 hlist_del(&hash_con->node);
919
- qed_fcoe_release_connection(QED_LEADING_HWFN(cdev), hash_con->con);
897
+ qed_fcoe_release_connection(QED_AFFIN_HWFN(cdev), hash_con->con);
920898 kfree(hash_con);
921899
922900 return 0;
....@@ -971,7 +949,7 @@
971949 con->d_id.addr_mid = conn_info->d_id.addr_mid;
972950 con->d_id.addr_lo = conn_info->d_id.addr_lo;
973951
974
- return qed_sp_fcoe_conn_offload(QED_LEADING_HWFN(cdev), con,
952
+ return qed_sp_fcoe_conn_offload(QED_AFFIN_HWFN(cdev), con,
975953 QED_SPQ_MODE_EBLOCK, NULL);
976954 }
977955
....@@ -992,13 +970,13 @@
992970 con = hash_con->con;
993971 con->terminate_params = terminate_params;
994972
995
- return qed_sp_fcoe_conn_destroy(QED_LEADING_HWFN(cdev), con,
973
+ return qed_sp_fcoe_conn_destroy(QED_AFFIN_HWFN(cdev), con,
996974 QED_SPQ_MODE_EBLOCK, NULL);
997975 }
998976
999977 static int qed_fcoe_stats(struct qed_dev *cdev, struct qed_fcoe_stats *stats)
1000978 {
1001
- return qed_fcoe_get_stats(QED_LEADING_HWFN(cdev), stats);
979
+ return qed_fcoe_get_stats(QED_AFFIN_HWFN(cdev), stats);
1002980 }
1003981
1004982 void qed_get_protocol_stats_fcoe(struct qed_dev *cdev,