forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/emulex/benet/be_ethtool.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
....@@ -27,7 +23,7 @@
2723 };
2824
2925 enum {DRVSTAT_TX, DRVSTAT_RX, DRVSTAT};
30
-#define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \
26
+#define FIELDINFO(_struct, field) sizeof_field(_struct, field), \
3127 offsetof(_struct, field)
3228 #define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\
3329 FIELDINFO(struct be_tx_stats, field)
....@@ -225,7 +221,6 @@
225221 struct be_adapter *adapter = netdev_priv(netdev);
226222
227223 strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
228
- strlcpy(drvinfo->version, DRV_VER, sizeof(drvinfo->version));
229224 if (!memcmp(adapter->fw_ver, adapter->fw_on_flash, FW_VER_LEN))
230225 strlcpy(drvinfo->fw_version, adapter->fw_ver,
231226 sizeof(drvinfo->fw_version));
....@@ -274,8 +269,8 @@
274269 int status = 0;
275270
276271 read_cmd.size = LANCER_READ_FILE_CHUNK;
277
- read_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, read_cmd.size,
278
- &read_cmd.dma, GFP_ATOMIC);
272
+ read_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, read_cmd.size,
273
+ &read_cmd.dma, GFP_ATOMIC);
279274
280275 if (!read_cmd.va) {
281276 dev_err(&adapter->pdev->dev,
....@@ -333,8 +328,8 @@
333328 et->tx_coalesce_usecs_high = aic->max_eqd;
334329 et->tx_coalesce_usecs_low = aic->min_eqd;
335330
336
- et->use_adaptive_rx_coalesce = aic->enable;
337
- et->use_adaptive_tx_coalesce = aic->enable;
331
+ et->use_adaptive_rx_coalesce = adapter->aic_enabled;
332
+ et->use_adaptive_tx_coalesce = adapter->aic_enabled;
338333
339334 return 0;
340335 }
....@@ -350,8 +345,9 @@
350345 struct be_eq_obj *eqo;
351346 int i;
352347
348
+ adapter->aic_enabled = et->use_adaptive_rx_coalesce;
349
+
353350 for_all_evt_queues(adapter, eqo, i) {
354
- aic->enable = et->use_adaptive_rx_coalesce;
355351 aic->max_eqd = min(et->rx_coalesce_usecs_high, BE_MAX_EQD);
356352 aic->min_eqd = min(et->rx_coalesce_usecs_low, aic->max_eqd);
357353 aic->et_eqd = min(et->rx_coalesce_usecs, aic->max_eqd);
....@@ -575,7 +571,7 @@
575571 break;
576572 }
577573 }
578
- /* fall through */
574
+ fallthrough;
579575 case PHY_TYPE_SFP_PLUS_10GB:
580576 case PHY_TYPE_XFP_10GB:
581577 case PHY_TYPE_SFP_1GB:
....@@ -815,7 +811,7 @@
815811 }
816812
817813 cmd.size = sizeof(struct be_cmd_req_acpi_wol_magic_config);
818
- cmd.va = dma_zalloc_coherent(dev, cmd.size, &cmd.dma, GFP_KERNEL);
814
+ cmd.va = dma_alloc_coherent(dev, cmd.size, &cmd.dma, GFP_KERNEL);
819815 if (!cmd.va)
820816 return -ENOMEM;
821817
....@@ -851,9 +847,9 @@
851847 };
852848
853849 ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test);
854
- ddrdma_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
855
- ddrdma_cmd.size, &ddrdma_cmd.dma,
856
- GFP_KERNEL);
850
+ ddrdma_cmd.va = dma_alloc_coherent(&adapter->pdev->dev,
851
+ ddrdma_cmd.size, &ddrdma_cmd.dma,
852
+ GFP_KERNEL);
857853 if (!ddrdma_cmd.va)
858854 return -ENOMEM;
859855
....@@ -1030,9 +1026,9 @@
10301026
10311027 memset(&eeprom_cmd, 0, sizeof(struct be_dma_mem));
10321028 eeprom_cmd.size = sizeof(struct be_cmd_req_seeprom_read);
1033
- eeprom_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
1034
- eeprom_cmd.size, &eeprom_cmd.dma,
1035
- GFP_KERNEL);
1029
+ eeprom_cmd.va = dma_alloc_coherent(&adapter->pdev->dev,
1030
+ eeprom_cmd.size, &eeprom_cmd.dma,
1031
+ GFP_KERNEL);
10361032
10371033 if (!eeprom_cmd.va)
10381034 return -ENOMEM;
....@@ -1342,7 +1338,7 @@
13421338 return -EOPNOTSUPP;
13431339
13441340 status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
1345
- page_data);
1341
+ 0, PAGE_DATA_LEN, page_data);
13461342 if (!status) {
13471343 if (!page_data[SFP_PLUS_SFF_8472_COMP]) {
13481344 modinfo->type = ETH_MODULE_SFF_8079;
....@@ -1360,25 +1356,32 @@
13601356 {
13611357 struct be_adapter *adapter = netdev_priv(netdev);
13621358 int status;
1359
+ u32 begin, end;
13631360
13641361 if (!check_privilege(adapter, MAX_PRIVILEGES))
13651362 return -EOPNOTSUPP;
13661363
1367
- status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
1368
- data);
1369
- if (status)
1370
- goto err;
1364
+ begin = eeprom->offset;
1365
+ end = eeprom->offset + eeprom->len;
13711366
1372
- if (eeprom->offset + eeprom->len > PAGE_DATA_LEN) {
1373
- status = be_cmd_read_port_transceiver_data(adapter,
1374
- TR_PAGE_A2,
1375
- data +
1376
- PAGE_DATA_LEN);
1367
+ if (begin < PAGE_DATA_LEN) {
1368
+ status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, begin,
1369
+ min_t(u32, end, PAGE_DATA_LEN) - begin,
1370
+ data);
1371
+ if (status)
1372
+ goto err;
1373
+
1374
+ data += PAGE_DATA_LEN - begin;
1375
+ begin = PAGE_DATA_LEN;
1376
+ }
1377
+
1378
+ if (end > PAGE_DATA_LEN) {
1379
+ status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A2,
1380
+ begin - PAGE_DATA_LEN,
1381
+ end - begin, data);
13771382 if (status)
13781383 goto err;
13791384 }
1380
- if (eeprom->offset)
1381
- memcpy(data, data + eeprom->offset, eeprom->len);
13821385 err:
13831386 return be_cmd_status(status);
13841387 }
....@@ -1412,6 +1415,9 @@
14121415 }
14131416
14141417 const struct ethtool_ops be_ethtool_ops = {
1418
+ .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
1419
+ ETHTOOL_COALESCE_USE_ADAPTIVE |
1420
+ ETHTOOL_COALESCE_USECS_LOW_HIGH,
14151421 .get_drvinfo = be_get_drvinfo,
14161422 .get_wol = be_get_wol,
14171423 .set_wol = be_set_wol,