20 #include <linux/ethtool.h>
30 #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \
31 offsetof(_struct, field)
32 #define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\
33 FIELDINFO(struct be_tx_stats, field)
34 #define DRVSTAT_RX_INFO(field) #field, DRVSTAT_RX,\
35 FIELDINFO(struct be_rx_stats, field)
36 #define DRVSTAT_INFO(field) #field, DRVSTAT,\
37 FIELDINFO(struct be_drv_stats, field)
120 #define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats)
141 #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats))
159 #define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats))
164 "External Loopback test",
169 #define ETHTOOL_TESTS_NUM ARRAY_SIZE(et_self_tests)
170 #define BE_MAC_LOOPBACK 0x0
171 #define BE_PHY_LOOPBACK 0x1
172 #define BE_ONE_PORT_EXT_LOOPBACK 0x2
173 #define BE_NO_LOOPBACK 0xff
175 static void be_get_drvinfo(
struct net_device *netdev,
181 memset(fw_on_flash, 0 ,
sizeof(fw_on_flash));
203 u32 data_read = 0, eof;
208 memset(&data_len_cmd, 0,
sizeof(data_len_cmd));
211 file_name, &data_read, &eof, &addn_status);
217 lancer_cmd_read_file(
struct be_adapter *adapter,
u8 *file_name,
221 u32 read_len = 0, total_read_len = 0, chunk_size;
232 "Memory allocation failure while reading dump\n");
236 while ((total_read_len < buf_len) && !eof) {
237 chunk_size =
min_t(
u32, (buf_len - total_read_len),
239 chunk_size =
ALIGN(chunk_size, 4);
241 total_read_len, file_name, &read_len,
244 memcpy(buf + total_read_len, read_cmd.va, read_len);
245 total_read_len += read_len;
261 struct be_adapter *adapter = netdev_priv(netdev);
266 log_size = lancer_cmd_get_file_len(adapter,
277 struct be_adapter *adapter = netdev_priv(netdev);
289 static int be_get_coalesce(
struct net_device *netdev,
292 struct be_adapter *adapter = netdev_priv(netdev);
313 static int be_set_coalesce(
struct net_device *netdev,
316 struct be_adapter *adapter = netdev_priv(netdev);
331 be_get_ethtool_stats(
struct net_device *netdev,
334 struct be_adapter *adapter = netdev_priv(netdev);
350 start = u64_stats_fetch_begin_bh(&stats->
sync);
352 data[base + 1] = stats->
rx_pkts;
353 }
while (u64_stats_fetch_retry_bh(&stats->
sync,
start));
356 p = (
u8 *)stats + et_rx_stats[i].
offset;
357 data[base +
i] = *(
u32 *)p;
371 start = u64_stats_fetch_begin_bh(&stats->
sync);
373 p = (
u8 *)stats + et_tx_stats[i].
offset;
375 (et_tx_stats[
i].
size ==
sizeof(
u64)) ?
378 }
while (u64_stats_fetch_retry_bh(&stats->
sync,
start));
387 struct be_adapter *adapter = netdev_priv(netdev);
396 for (i = 0; i < adapter->
num_rx_qs; i++) {
399 et_rx_stats[j].
desc);
403 for (i = 0; i < adapter->
num_tx_qs; i++) {
406 et_tx_stats[j].
desc);
420 static int be_get_sset_count(
struct net_device *netdev,
int stringset)
422 struct be_adapter *adapter = netdev_priv(netdev);
428 return ETHTOOL_STATS_NUM +
436 static u32 be_get_port_type(
u32 phy_type,
u32 dac_cable_len)
481 if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
494 if (if_speeds & BE_SUPPORTED_SPEED_10GBPS)
496 if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
501 if (if_speeds & BE_SUPPORTED_SPEED_10GBPS)
503 if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
505 if (if_speeds & BE_SUPPORTED_SPEED_100MBPS)
524 struct be_adapter *adapter = netdev_priv(netdev);
529 if (adapter->
phy.link_speed < 0) {
534 ethtool_cmd_speed_set(ecmd, link_speed);
541 convert_to_et_setting(adapter->
phy.interface_type,
542 adapter->
phy.auto_speeds_supported |
543 adapter->
phy.fixed_speeds_supported);
545 convert_to_et_setting(adapter->
phy.interface_type,
546 adapter->
phy.auto_speeds_supported);
548 ecmd->
port = be_get_port_type(adapter->
phy.interface_type,
549 adapter->
phy.dac_cable_len);
551 if (adapter->
phy.auto_speeds_supported) {
562 switch (adapter->
phy.interface_type) {
573 adapter->
phy.link_speed = ethtool_cmd_speed(ecmd);
574 adapter->
phy.port_type = ecmd->
port;
580 ethtool_cmd_speed_set(ecmd, adapter->
phy.link_speed);
581 ecmd->
port = adapter->
phy.port_type;
594 static void be_get_ringparam(
struct net_device *netdev,
597 struct be_adapter *adapter = netdev_priv(netdev);
606 struct be_adapter *adapter = netdev_priv(netdev);
615 struct be_adapter *adapter = netdev_priv(netdev);
626 dev_warn(&adapter->
pdev->dev,
"Pause param set failed.\n");
635 struct be_adapter *adapter = netdev_priv(netdev);
665 struct be_adapter *adapter = netdev_priv(netdev);
678 struct be_adapter *adapter = netdev_priv(netdev);
691 adapter->
wol =
false;
702 0x5a5a5a5a5a5a5a5aULL, 0xa5a5a5a5a5a5a5a5ULL
708 if (!ddrdma_cmd.va) {
709 dev_err(&adapter->
pdev->dev,
"Memory allocation failure\n");
713 for (i = 0; i < 2; i++) {
726 static u64 be_loopback_test(
struct be_adapter *adapter,
u8 loopback_type,
742 struct be_adapter *adapter = netdev_priv(netdev);
763 if (!
lancer_chip(adapter) && be_test_ddr_dma(adapter) != 0) {
772 }
else if (!link_status) {
781 struct be_adapter *adapter = netdev_priv(netdev);
789 struct be_adapter *adapter = netdev_priv(netdev);
792 return lancer_cmd_get_file_len(adapter,
795 return lancer_cmd_get_file_len(adapter,
806 struct be_adapter *adapter = netdev_priv(netdev);
830 if (!eeprom_cmd.va) {
832 "Memory allocation failure. Could not read eeprom\n");
839 resp = eeprom_cmd.va;
850 struct be_adapter *adapter = netdev_priv(netdev);
853 dev_err(&adapter->
pdev->dev,
"Operation not supported\n");
871 if (!extfat_cmd.va) {
872 dev_err(&adapter->
pdev->dev,
"%s: Memory allocation failure\n",
882 for (j = 0; j < num_modes; j++) {
883 if (cfgs->
module[i].trace_lvl[j].mode ==
885 cfgs->
module[
i].trace_lvl[
j].dbg_lvl =
893 "Message level set failed\n");
895 dev_err(&adapter->
pdev->dev,
"Message level get failed\n");
904 static void be_set_msg_level(
struct net_device *netdev,
u32 level)
906 struct be_adapter *adapter = netdev_priv(netdev);
909 dev_err(&adapter->
pdev->dev,
"Operation not supported\n");
917 be_set_fw_log_level(adapter, level & NETIF_MSG_HW ?
925 .get_settings = be_get_settings,
926 .get_drvinfo = be_get_drvinfo,
927 .get_wol = be_get_wol,
928 .set_wol = be_set_wol,
930 .get_eeprom_len = be_get_eeprom_len,
931 .get_eeprom = be_read_eeprom,
932 .get_coalesce = be_get_coalesce,
933 .set_coalesce = be_set_coalesce,
934 .get_ringparam = be_get_ringparam,
935 .get_pauseparam = be_get_pauseparam,
936 .set_pauseparam = be_set_pauseparam,
937 .get_strings = be_get_stat_strings,
938 .set_phys_id = be_set_phys_id,
939 .get_msglevel = be_get_msg_level,
940 .set_msglevel = be_set_msg_level,
941 .get_sset_count = be_get_sset_count,
942 .get_ethtool_stats = be_get_ethtool_stats,
943 .get_regs_len = be_get_reg_len,
944 .get_regs = be_get_regs,
945 .flash_device = be_do_flash,
946 .self_test = be_self_test,