forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/emulex/benet/be_cmds.c
....@@ -1,11 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2005 - 2016 Broadcom
34 * All rights reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU General Public License version 2
7
- * as published by the Free Software Foundation. The full GNU General
8
- * Public License is included in this distribution in the file called COPYING.
95 *
106 * Contact Information:
117 * linux-drivers@emulex.com
....@@ -1808,9 +1804,9 @@
18081804 total_size = buf_len;
18091805
18101806 get_fat_cmd.size = sizeof(struct be_cmd_req_get_fat) + 60*1024;
1811
- get_fat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
1812
- get_fat_cmd.size,
1813
- &get_fat_cmd.dma, GFP_ATOMIC);
1807
+ get_fat_cmd.va = dma_alloc_coherent(&adapter->pdev->dev,
1808
+ get_fat_cmd.size,
1809
+ &get_fat_cmd.dma, GFP_ATOMIC);
18141810 if (!get_fat_cmd.va)
18151811 return -ENOMEM;
18161812
....@@ -2291,7 +2287,7 @@
22912287
22922288 /* Uses sync mcc */
22932289 int be_cmd_read_port_transceiver_data(struct be_adapter *adapter,
2294
- u8 page_num, u8 *data)
2290
+ u8 page_num, u32 off, u32 len, u8 *data)
22952291 {
22962292 struct be_dma_mem cmd;
22972293 struct be_mcc_wrb *wrb;
....@@ -2302,8 +2298,8 @@
23022298 return -EINVAL;
23032299
23042300 cmd.size = sizeof(struct be_cmd_resp_port_type);
2305
- cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
2306
- GFP_ATOMIC);
2301
+ cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
2302
+ GFP_ATOMIC);
23072303 if (!cmd.va) {
23082304 dev_err(&adapter->pdev->dev, "Memory allocation failed\n");
23092305 return -ENOMEM;
....@@ -2325,10 +2321,10 @@
23252321 req->port = cpu_to_le32(adapter->hba_port_num);
23262322 req->page_num = cpu_to_le32(page_num);
23272323 status = be_mcc_notify_wait(adapter);
2328
- if (!status) {
2324
+ if (!status && len > 0) {
23292325 struct be_cmd_resp_port_type *resp = cmd.va;
23302326
2331
- memcpy(data, resp->page_data, PAGE_DATA_LEN);
2327
+ memcpy(data, resp->page_data + off, len);
23322328 }
23332329 err:
23342330 mutex_unlock(&adapter->mcc_lock);
....@@ -2419,7 +2415,7 @@
24192415 int status;
24202416
24212417 status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
2422
- page_data);
2418
+ 0, PAGE_DATA_LEN, page_data);
24232419 if (!status) {
24242420 switch (adapter->phy.interface_type) {
24252421 case PHY_TYPE_QSFP:
....@@ -2444,7 +2440,7 @@
24442440 int status;
24452441
24462442 status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
2447
- page_data);
2443
+ 0, PAGE_DATA_LEN, page_data);
24482444 if (!status) {
24492445 strlcpy(adapter->phy.vendor_name, page_data +
24502446 SFP_VENDOR_NAME_OFFSET, SFP_VENDOR_NAME_LEN - 1);
....@@ -2762,7 +2758,7 @@
27622758 bool crc_match;
27632759 const u8 *p;
27642760
2765
- struct flash_comp gen3_flash_types[] = {
2761
+ static const struct flash_comp gen3_flash_types[] = {
27662762 { BE3_ISCSI_PRIMARY_IMAGE_START, OPTYPE_ISCSI_ACTIVE,
27672763 BE3_COMP_MAX_SIZE, IMAGE_FIRMWARE_ISCSI},
27682764 { BE3_REDBOOT_START, OPTYPE_REDBOOT,
....@@ -2785,7 +2781,7 @@
27852781 BE3_PHY_FW_COMP_MAX_SIZE, IMAGE_FIRMWARE_PHY}
27862782 };
27872783
2788
- struct flash_comp gen2_flash_types[] = {
2784
+ static const struct flash_comp gen2_flash_types[] = {
27892785 { BE2_ISCSI_PRIMARY_IMAGE_START, OPTYPE_ISCSI_ACTIVE,
27902786 BE2_COMP_MAX_SIZE, IMAGE_FIRMWARE_ISCSI},
27912787 { BE2_REDBOOT_START, OPTYPE_REDBOOT,
....@@ -3066,8 +3062,8 @@
30663062
30673063 flash_cmd.size = sizeof(struct lancer_cmd_req_write_object)
30683064 + LANCER_FW_DOWNLOAD_CHUNK;
3069
- flash_cmd.va = dma_zalloc_coherent(dev, flash_cmd.size,
3070
- &flash_cmd.dma, GFP_KERNEL);
3065
+ flash_cmd.va = dma_alloc_coherent(dev, flash_cmd.size, &flash_cmd.dma,
3066
+ GFP_KERNEL);
30713067 if (!flash_cmd.va)
30723068 return -ENOMEM;
30733069
....@@ -3184,8 +3180,8 @@
31843180 }
31853181
31863182 flash_cmd.size = sizeof(struct be_cmd_write_flashrom);
3187
- flash_cmd.va = dma_zalloc_coherent(dev, flash_cmd.size, &flash_cmd.dma,
3188
- GFP_KERNEL);
3183
+ flash_cmd.va = dma_alloc_coherent(dev, flash_cmd.size, &flash_cmd.dma,
3184
+ GFP_KERNEL);
31893185 if (!flash_cmd.va)
31903186 return -ENOMEM;
31913187
....@@ -3435,8 +3431,8 @@
34353431 goto err;
34363432 }
34373433 cmd.size = sizeof(struct be_cmd_req_get_phy_info);
3438
- cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
3439
- GFP_ATOMIC);
3434
+ cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
3435
+ GFP_ATOMIC);
34403436 if (!cmd.va) {
34413437 dev_err(&adapter->pdev->dev, "Memory alloc failure\n");
34423438 status = -ENOMEM;
....@@ -3522,9 +3518,9 @@
35223518
35233519 memset(&attribs_cmd, 0, sizeof(struct be_dma_mem));
35243520 attribs_cmd.size = sizeof(struct be_cmd_resp_cntl_attribs);
3525
- attribs_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
3526
- attribs_cmd.size,
3527
- &attribs_cmd.dma, GFP_ATOMIC);
3521
+ attribs_cmd.va = dma_alloc_coherent(&adapter->pdev->dev,
3522
+ attribs_cmd.size,
3523
+ &attribs_cmd.dma, GFP_ATOMIC);
35283524 if (!attribs_cmd.va) {
35293525 dev_err(&adapter->pdev->dev, "Memory allocation failure\n");
35303526 status = -ENOMEM;
....@@ -3699,10 +3695,10 @@
36993695
37003696 memset(&get_mac_list_cmd, 0, sizeof(struct be_dma_mem));
37013697 get_mac_list_cmd.size = sizeof(struct be_cmd_resp_get_mac_list);
3702
- get_mac_list_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
3703
- get_mac_list_cmd.size,
3704
- &get_mac_list_cmd.dma,
3705
- GFP_ATOMIC);
3698
+ get_mac_list_cmd.va = dma_alloc_coherent(&adapter->pdev->dev,
3699
+ get_mac_list_cmd.size,
3700
+ &get_mac_list_cmd.dma,
3701
+ GFP_ATOMIC);
37063702
37073703 if (!get_mac_list_cmd.va) {
37083704 dev_err(&adapter->pdev->dev,
....@@ -3829,8 +3825,8 @@
38293825
38303826 memset(&cmd, 0, sizeof(struct be_dma_mem));
38313827 cmd.size = sizeof(struct be_cmd_req_set_mac_list);
3832
- cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
3833
- GFP_KERNEL);
3828
+ cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
3829
+ GFP_KERNEL);
38343830 if (!cmd.va)
38353831 return -ENOMEM;
38363832
....@@ -4035,8 +4031,8 @@
40354031
40364032 memset(&cmd, 0, sizeof(struct be_dma_mem));
40374033 cmd.size = sizeof(struct be_cmd_resp_acpi_wol_magic_config_v1);
4038
- cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
4039
- GFP_ATOMIC);
4034
+ cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
4035
+ GFP_ATOMIC);
40404036 if (!cmd.va) {
40414037 dev_err(&adapter->pdev->dev, "Memory allocation failure\n");
40424038 status = -ENOMEM;
....@@ -4089,9 +4085,9 @@
40894085
40904086 memset(&extfat_cmd, 0, sizeof(struct be_dma_mem));
40914087 extfat_cmd.size = sizeof(struct be_cmd_resp_get_ext_fat_caps);
4092
- extfat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
4093
- extfat_cmd.size, &extfat_cmd.dma,
4094
- GFP_ATOMIC);
4088
+ extfat_cmd.va = dma_alloc_coherent(&adapter->pdev->dev,
4089
+ extfat_cmd.size, &extfat_cmd.dma,
4090
+ GFP_ATOMIC);
40954091 if (!extfat_cmd.va)
40964092 return -ENOMEM;
40974093
....@@ -4127,9 +4123,9 @@
41274123
41284124 memset(&extfat_cmd, 0, sizeof(struct be_dma_mem));
41294125 extfat_cmd.size = sizeof(struct be_cmd_resp_get_ext_fat_caps);
4130
- extfat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
4131
- extfat_cmd.size, &extfat_cmd.dma,
4132
- GFP_ATOMIC);
4126
+ extfat_cmd.va = dma_alloc_coherent(&adapter->pdev->dev,
4127
+ extfat_cmd.size, &extfat_cmd.dma,
4128
+ GFP_ATOMIC);
41334129
41344130 if (!extfat_cmd.va) {
41354131 dev_err(&adapter->pdev->dev, "%s: Memory allocation failure\n",
....@@ -4354,8 +4350,8 @@
43544350
43554351 memset(&cmd, 0, sizeof(struct be_dma_mem));
43564352 cmd.size = sizeof(struct be_cmd_resp_get_func_config);
4357
- cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
4358
- GFP_ATOMIC);
4353
+ cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
4354
+ GFP_ATOMIC);
43594355 if (!cmd.va) {
43604356 dev_err(&adapter->pdev->dev, "Memory alloc failure\n");
43614357 status = -ENOMEM;
....@@ -4452,8 +4448,8 @@
44524448
44534449 memset(&cmd, 0, sizeof(struct be_dma_mem));
44544450 cmd.size = sizeof(struct be_cmd_resp_get_profile_config);
4455
- cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
4456
- GFP_ATOMIC);
4451
+ cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
4452
+ GFP_ATOMIC);
44574453 if (!cmd.va)
44584454 return -ENOMEM;
44594455
....@@ -4539,8 +4535,8 @@
45394535
45404536 memset(&cmd, 0, sizeof(struct be_dma_mem));
45414537 cmd.size = sizeof(struct be_cmd_req_set_profile_config);
4542
- cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
4543
- GFP_ATOMIC);
4538
+ cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
4539
+ GFP_ATOMIC);
45444540 if (!cmd.va)
45454541 return -ENOMEM;
45464542