18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 #include <linux/ethtool.h>
21 #include <linux/netdevice.h>
22 #include <linux/types.h>
23 #include <linux/sched.h>
34 #define MAX_QUEUE_NAME_LEN 4
39 } bnx2x_q_stats_arr[] = {
42 8,
"[%s]: rx_ucast_packets" },
44 8,
"[%s]: rx_mcast_packets" },
46 8,
"[%s]: rx_bcast_packets" },
49 4,
"[%s]: rx_phy_ip_err_discards"},
51 4,
"[%s]: rx_skb_alloc_discard" },
56 8,
"[%s]: tx_ucast_packets" },
58 8,
"[%s]: tx_mcast_packets" },
60 8,
"[%s]: tx_bcast_packets" },
62 8,
"[%s]: tpa_aggregations" },
64 8,
"[%s]: tpa_aggregated_frames"},
68 #define BNX2X_NUM_Q_STATS ARRAY_SIZE(bnx2x_q_stats_arr)
74 #define STATS_FLAGS_PORT 1
75 #define STATS_FLAGS_FUNC 2
76 #define STATS_FLAGS_BOTH (STATS_FLAGS_FUNC | STATS_FLAGS_PORT)
78 } bnx2x_stats_arr[] = {
184 #define BNX2X_NUM_STATS ARRAY_SIZE(bnx2x_stats_arr)
185 static int bnx2x_get_port_type(
struct bnx2x *bp)
216 struct bnx2x *bp = netdev_priv(dev);
221 (bp->
port.supported[cfg_idx ^ 1] &
232 ethtool_cmd_speed_set(cmd, bp->
link_vars.line_speed);
235 ethtool_cmd_speed_set(
247 cmd->
port = bnx2x_get_port_type(bp);
289 " supported 0x%x advertising 0x%x speed %u\n"
290 " duplex %d port %d phy_address %d transceiver %d\n"
291 " autoneg %d maxtxpkt %d maxrxpkt %d\n",
293 ethtool_cmd_speed(cmd),
302 struct bnx2x *bp = netdev_priv(dev);
303 u32 advertising, cfg_idx, old_multi_phy_config, new_multi_phy_config;
310 " supported 0x%x advertising 0x%x speed %u\n"
311 " duplex %d port %d phy_address %d transceiver %d\n"
312 " autoneg %d maxtxpkt %d maxrxpkt %d\n",
314 ethtool_cmd_speed(cmd),
318 speed = ethtool_cmd_speed(cmd);
334 "To set speed BC %X or higher is required, please upgrade BC\n",
339 part = (speed * 100) / line_speed;
341 if (line_speed < speed || !part) {
343 "Speed setting should be in a range from 1%% to 100%% of actual line speed\n");
357 old_multi_phy_config = bp->
link_params.multi_phy_config;
363 if (!(bp->
port.supported[0] & SUPPORTED_TP ||
364 bp->
port.supported[1] & SUPPORTED_TP)) {
383 if (!(bp->
port.supported[0] & SUPPORTED_FIBRE ||
384 bp->
port.supported[1] & SUPPORTED_FIBRE)) {
403 new_multi_phy_config = bp->
link_params.multi_phy_config;
407 bp->
link_params.multi_phy_config = old_multi_phy_config;
411 u32 an_supported_speed = bp->
port.supported[cfg_idx];
424 "Advertisement parameters are not supported\n");
471 if (!(bp->
port.supported[cfg_idx] &
474 "10M full not supported\n");
481 if (!(bp->
port.supported[cfg_idx] &
484 "10M half not supported\n");
495 if (!(bp->
port.supported[cfg_idx] &
498 "100M full not supported\n");
505 if (!(bp->
port.supported[cfg_idx] &
508 "100M half not supported\n");
520 "1G half not supported\n");
524 if (!(bp->
port.supported[cfg_idx] &
527 "1G full not supported\n");
538 "2.5G half not supported\n");
542 if (!(bp->
port.supported[cfg_idx]
545 "2.5G full not supported\n");
556 "10G half not supported\n");
560 if (!(bp->
port.supported[cfg_idx]
565 "10G full not supported\n");
580 bp->
port.advertising[cfg_idx] = advertising;
584 " req_duplex %d advertising 0x%x\n",
587 bp->
port.advertising[cfg_idx]);
590 bp->
link_params.multi_phy_config = new_multi_phy_config;
591 if (netif_running(dev)) {
599 #define IS_E1_ONLINE(info) (((info) & RI_E1_ONLINE) == RI_E1_ONLINE)
600 #define IS_E1H_ONLINE(info) (((info) & RI_E1H_ONLINE) == RI_E1H_ONLINE)
601 #define IS_E2_ONLINE(info) (((info) & RI_E2_ONLINE) == RI_E2_ONLINE)
602 #define IS_E3_ONLINE(info) (((info) & RI_E3_ONLINE) == RI_E3_ONLINE)
603 #define IS_E3B0_ONLINE(info) (((info) & RI_E3B0_ONLINE) == RI_E3B0_ONLINE)
605 static bool bnx2x_is_reg_online(
struct bnx2x *bp,
623 static const u32 *__bnx2x_get_page_addr_ar(
struct bnx2x *bp)
633 static u32 __bnx2x_get_page_reg_num(
struct bnx2x *bp)
643 static const u32 *__bnx2x_get_page_write_ar(
struct bnx2x *bp)
646 return page_write_regs_e2;
648 return page_write_regs_e3;
653 static u32 __bnx2x_get_page_write_num(
struct bnx2x *bp)
663 static const struct reg_addr *__bnx2x_get_page_read_ar(
struct bnx2x *bp)
666 return page_read_regs_e2;
668 return page_read_regs_e3;
673 static u32 __bnx2x_get_page_read_num(
struct bnx2x *bp)
683 static int __bnx2x_get_regs_len(
struct bnx2x *bp)
685 int num_pages = __bnx2x_get_page_reg_num(bp);
686 int page_write_num = __bnx2x_get_page_write_num(bp);
687 const struct reg_addr *page_read_addr = __bnx2x_get_page_read_ar(bp);
688 int page_read_num = __bnx2x_get_page_read_num(bp);
693 if (bnx2x_is_reg_online(bp, ®_addrs[i]))
694 regdump_len += reg_addrs[
i].size;
697 for (j = 0; j < page_write_num; j++)
698 for (k = 0; k < page_read_num; k++)
699 if (bnx2x_is_reg_online(bp, &page_read_addr[k]))
700 regdump_len += page_read_addr[
k].
size;
705 static int bnx2x_get_regs_len(
struct net_device *dev)
707 struct bnx2x *bp = netdev_priv(dev);
710 regdump_len = __bnx2x_get_regs_len(bp);
712 regdump_len +=
sizeof(
struct dump_hdr);
728 static void bnx2x_read_pages_regs(
struct bnx2x *bp,
u32 *
p)
732 const u32 *page_addr = __bnx2x_get_page_addr_ar(bp);
734 int num_pages = __bnx2x_get_page_reg_num(bp);
736 const u32 *write_addr = __bnx2x_get_page_write_ar(bp);
738 int write_num = __bnx2x_get_page_write_num(bp);
740 const struct reg_addr *read_addr = __bnx2x_get_page_read_ar(bp);
742 int read_num = __bnx2x_get_page_read_num(bp);
745 for (j = 0; j < write_num; j++) {
746 REG_WR(bp, write_addr[j], page_addr[i]);
747 for (k = 0; k < read_num; k++)
748 if (bnx2x_is_reg_online(bp, &read_addr[k]))
750 read_addr[
k].
size; n++)
752 read_addr[k].
addr + n*4);
757 static void __bnx2x_get_regs(
struct bnx2x *bp,
u32 *p)
763 if (bnx2x_is_reg_online(bp, ®_addrs[i]))
764 for (j = 0; j < reg_addrs[
i].size; j++)
768 bnx2x_read_pages_regs(bp, p);
771 static void bnx2x_get_regs(
struct net_device *dev,
775 struct bnx2x *bp = netdev_priv(dev);
781 if (!netif_running(bp->
dev))
788 bnx2x_disable_blocks_parity(bp);
790 dump_hdr.
hdr_size = (
sizeof(
struct dump_hdr) / 4) - 1;
805 memcpy(p, &dump_hdr,
sizeof(
struct dump_hdr));
809 __bnx2x_get_regs(bp, p);
812 bnx2x_clear_blocks_parity(bp);
813 bnx2x_enable_blocks_parity(bp);
816 static void bnx2x_get_drvinfo(
struct net_device *dev,
819 struct bnx2x *bp = netdev_priv(dev);
825 phy_fw_ver[0] =
'\0';
831 (bp->
common.bc_ver & 0xff0000) >> 16,
832 (bp->
common.bc_ver & 0xff00) >> 8,
833 (bp->
common.bc_ver & 0xff),
834 ((phy_fw_ver[0] !=
'\0') ?
" phy " :
""), phy_fw_ver);
844 struct bnx2x *bp = netdev_priv(dev);
861 struct bnx2x *bp = netdev_priv(dev);
882 struct bnx2x *bp = netdev_priv(dev);
889 struct bnx2x *bp = netdev_priv(dev);
899 static int bnx2x_nway_reset(
struct net_device *dev)
901 struct bnx2x *bp = netdev_priv(dev);
906 if (netif_running(dev)) {
917 struct bnx2x *bp = netdev_priv(dev);
925 static int bnx2x_get_eeprom_len(
struct net_device *dev)
927 struct bnx2x *bp = netdev_priv(dev);
929 return bp->
common.flash_size;
945 static int bnx2x_acquire_nvram_lock(
struct bnx2x *bp)
963 for (i = 0; i < count*10; i++) {
973 "cannot get access to nvram interface\n");
980 static int bnx2x_release_nvram_lock(
struct bnx2x *bp)
995 for (i = 0; i < count*10; i++) {
1005 "cannot free access to nvram interface\n");
1014 static void bnx2x_enable_nvram_access(
struct bnx2x *bp)
1026 static void bnx2x_disable_nvram_access(
struct bnx2x *bp)
1065 for (i = 0; i <
count; i++) {
1081 "nvram read timeout expired\n");
1085 static int bnx2x_nvram_read(
struct bnx2x *bp,
u32 offset,
u8 *ret_buf,
1092 if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) {
1094 "Invalid parameter: offset 0x%x buf_size 0x%x\n",
1099 if (offset + buf_size > bp->
common.flash_size) {
1101 "Invalid parameter: offset (0x%x) + buf_size (0x%x) > flash_size (0x%x)\n",
1102 offset, buf_size, bp->
common.flash_size);
1107 rc = bnx2x_acquire_nvram_lock(bp);
1112 bnx2x_enable_nvram_access(bp);
1116 while ((buf_size >
sizeof(
u32)) && (rc == 0)) {
1117 rc = bnx2x_nvram_read_dword(bp, offset, &val, cmd_flags);
1118 memcpy(ret_buf, &val, 4);
1121 offset +=
sizeof(
u32);
1122 ret_buf +=
sizeof(
u32);
1123 buf_size -=
sizeof(
u32);
1129 rc = bnx2x_nvram_read_dword(bp, offset, &val, cmd_flags);
1130 memcpy(ret_buf, &val, 4);
1134 bnx2x_disable_nvram_access(bp);
1135 bnx2x_release_nvram_lock(bp);
1140 static int bnx2x_get_eeprom(
struct net_device *dev,
1143 struct bnx2x *bp = netdev_priv(dev);
1146 if (!netif_running(dev)) {
1148 "cannot access eeprom when the interface is down\n");
1153 " magic 0x%x offset 0x%x (%d) len 0x%x (%d)\n",
1155 eeprom->
len, eeprom->
len);
1159 rc = bnx2x_nvram_read(bp, eeprom->
offset, eebuf, eeprom->
len);
1164 static int bnx2x_get_module_eeprom(
struct net_device *dev,
1168 struct bnx2x *bp = netdev_priv(dev);
1169 int rc = 0, phy_idx;
1171 int remaining_len = ee->
len, xfer_size;
1172 unsigned int page_off = ee->
offset;
1174 if (!netif_running(dev)) {
1176 "cannot access eeprom when the interface is down\n");
1182 while (!rc && remaining_len > 0) {
1190 remaining_len -= xfer_size;
1191 user_data += xfer_size;
1192 page_off += xfer_size;
1199 static int bnx2x_get_module_info(
struct net_device *dev,
1202 struct bnx2x *bp = netdev_priv(dev);
1204 if (!netif_running(dev)) {
1206 "cannot access eeprom when the interface is down\n");
1211 switch (bp->
link_params.phy[phy_idx].media_type) {
1223 static int bnx2x_nvram_write_dword(
struct bnx2x *bp,
u32 offset,
u32 val,
1251 for (i = 0; i <
count; i++) {
1262 "nvram write timeout expired\n");
1266 #define BYTE_OFFSET(offset) (8 * (offset & 0x03))
1276 if (offset + buf_size > bp->
common.flash_size) {
1278 "Invalid parameter: offset (0x%x) + buf_size (0x%x) > flash_size (0x%x)\n",
1279 offset, buf_size, bp->
common.flash_size);
1284 rc = bnx2x_acquire_nvram_lock(bp);
1289 bnx2x_enable_nvram_access(bp);
1292 align_offset = (offset & ~0x03);
1293 rc = bnx2x_nvram_read_dword(bp, align_offset, &val, cmd_flags);
1303 rc = bnx2x_nvram_write_dword(bp, align_offset, val,
1308 bnx2x_disable_nvram_access(bp);
1309 bnx2x_release_nvram_lock(bp);
1323 return bnx2x_nvram_write1(bp, offset, data_buf, buf_size);
1325 if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) {
1327 "Invalid parameter: offset 0x%x buf_size 0x%x\n",
1332 if (offset + buf_size > bp->
common.flash_size) {
1334 "Invalid parameter: offset (0x%x) + buf_size (0x%x) > flash_size (0x%x)\n",
1335 offset, buf_size, bp->
common.flash_size);
1340 rc = bnx2x_acquire_nvram_lock(bp);
1345 bnx2x_enable_nvram_access(bp);
1349 while ((written_so_far < buf_size) && (rc == 0)) {
1350 if (written_so_far == (buf_size -
sizeof(
u32)))
1357 memcpy(&val, data_buf, 4);
1359 rc = bnx2x_nvram_write_dword(bp, offset, val, cmd_flags);
1362 offset +=
sizeof(
u32);
1363 data_buf +=
sizeof(
u32);
1364 written_so_far +=
sizeof(
u32);
1369 bnx2x_disable_nvram_access(bp);
1370 bnx2x_release_nvram_lock(bp);
1375 static int bnx2x_set_eeprom(
struct net_device *dev,
1378 struct bnx2x *bp = netdev_priv(dev);
1382 if (!netif_running(dev)) {
1384 "cannot access eeprom when the interface is down\n");
1389 " magic 0x%x offset 0x%x (%d) len 0x%x (%d)\n",
1391 eeprom->
len, eeprom->
len);
1396 if ((eeprom->
magic >= 0x50485900) && (eeprom->
magic <= 0x504859FF) &&
1399 "wrong magic or interface is not pmf\n");
1405 dev_info.port_hw_config[port].external_phy_config);
1407 if (eeprom->
magic == 0x50485950) {
1421 }
else if (eeprom->
magic == 0x50485952) {
1433 }
else if (eeprom->
magic == 0x53985943) {
1454 rc = bnx2x_nvram_write(bp, eeprom->
offset, eebuf, eeprom->
len);
1459 static int bnx2x_get_coalesce(
struct net_device *dev,
1462 struct bnx2x *bp = netdev_priv(dev);
1472 static int bnx2x_set_coalesce(
struct net_device *dev,
1475 struct bnx2x *bp = netdev_priv(dev);
1485 if (netif_running(dev))
1491 static void bnx2x_get_ringparam(
struct net_device *dev,
1494 struct bnx2x *bp = netdev_priv(dev);
1507 static int bnx2x_set_ringparam(
struct net_device *dev,
1510 struct bnx2x *bp = netdev_priv(dev);
1514 "Handling parity error recovery. Try again later\n");
1533 static void bnx2x_get_pauseparam(
struct net_device *dev,
1536 struct bnx2x *bp = netdev_priv(dev);
1554 " autoneg %d rx_pause %d tx_pause %d\n",
1558 static int bnx2x_set_pauseparam(
struct net_device *dev,
1561 struct bnx2x *bp = netdev_priv(dev);
1567 " autoneg %d rx_pause %d tx_pause %d\n",
1582 if (!(bp->
port.supported[cfg_idx] & SUPPORTED_Autoneg)) {
1600 "req_flow_ctrl 0x%x\n", bp->
link_params.req_flow_ctrl[cfg_idx]);
1602 if (netif_running(dev)) {
1611 "register_test (offline) ",
1612 "memory_test (offline) ",
1613 "int_loopback_test (offline)",
1614 "ext_loopback_test (offline)",
1615 "nvram_test (online) ",
1616 "interrupt_test (online) ",
1617 "link_test (online) "
1620 static u32 bnx2x_eee_to_adv(
u32 eee_adv)
1634 static u32 bnx2x_adv_to_eee(
u32 modes,
u32 shift)
1644 return eee_adv << shift;
1649 struct bnx2x *bp = netdev_priv(dev);
1682 struct bnx2x *bp = netdev_priv(dev);
1701 advertised = bnx2x_adv_to_eee(edata->
advertised,
1705 "Direct manipulation of EEE advertisement is not supported\n");
1711 "Maximal Tx Lpi timer supported is %x(u)\n",
1718 "Minimal Tx Lpi timer supported is %d(u)\n",
1741 if (netif_running(dev)) {
1760 #define BNX2X_CHIP_MASK_E1 (1 << BNX2X_CHIP_E1_OFST)
1761 #define BNX2X_CHIP_MASK_E1H (1 << BNX2X_CHIP_E1H_OFST)
1762 #define BNX2X_CHIP_MASK_E2 (1 << BNX2X_CHIP_E2_OFST)
1763 #define BNX2X_CHIP_MASK_E3 (1 << BNX2X_CHIP_E3_OFST)
1764 #define BNX2X_CHIP_MASK_E3B0 (1 << BNX2X_CHIP_E3B0_OFST)
1766 #define BNX2X_CHIP_MASK_ALL ((1 << BNX2X_CHIP_MAX_OFST) - 1)
1767 #define BNX2X_CHIP_MASK_E1X (BNX2X_CHIP_MASK_E1 | BNX2X_CHIP_MASK_E1H)
1769 static int bnx2x_test_registers(
struct bnx2x *bp)
1774 static const struct {
1860 if (!netif_running(bp->
dev)) {
1862 "cannot access eeprom when the interface is down\n");
1879 for (idx = 0; idx < 2; idx++) {
1886 wr_val = 0xffffffff;
1890 for (i = 0; reg_tbl[
i].offset0 != 0xffffffff; i++) {
1892 if (!(
hw & reg_tbl[i].
hw))
1895 offset = reg_tbl[
i].offset0 + port*reg_tbl[
i].offset1;
1896 mask = reg_tbl[
i].mask;
1898 save_val =
REG_RD(bp, offset);
1900 REG_WR(bp, offset, wr_val & mask);
1902 val =
REG_RD(bp, offset);
1905 REG_WR(bp, offset, save_val);
1908 if ((val & mask) != (wr_val & mask)) {
1910 "offset 0x%x: val 0x%x != 0x%x mask 0x%x\n",
1911 offset, val, wr_val, mask);
1923 static int bnx2x_test_memory(
struct bnx2x *bp)
1927 static const struct {
1942 static const struct {
1948 {0x3ffc0, 0, 0, 0} },
1954 {0x3ffc0, 0, 0, 0} },
1956 {0x3ffc0, 0, 0, 0} },
1958 {0x3ffc1, 0, 0, 0} },
1960 {
NULL, 0xffffffff, {0, 0, 0, 0} }
1963 if (!netif_running(bp->
dev)) {
1965 "cannot access eeprom when the interface is down\n");
1979 for (i = 0; prty_tbl[
i].offset != 0xffffffff; i++) {
1980 val =
REG_RD(bp, prty_tbl[i].offset);
1981 if (val & ~(prty_tbl[i].hw_mask[index])) {
1983 "%s is 0x%x\n", prty_tbl[i].
name, val);
1989 for (i = 0; mem_tbl[
i].offset != 0xffffffff; i++)
1990 for (j = 0; j < mem_tbl[
i].size; j++)
1991 REG_RD(bp, mem_tbl[i].offset + j*4);
1994 for (i = 0; prty_tbl[
i].offset != 0xffffffff; i++) {
1995 val =
REG_RD(bp, prty_tbl[i].offset);
1996 if (val & ~(prty_tbl[i].hw_mask[index])) {
1998 "%s is 0x%x\n", prty_tbl[i].
name, val);
2009 static void bnx2x_wait_for_link(
struct bnx2x *bp,
u8 link_up,
u8 is_serdes)
2026 "Timeout waiting for link init\n");
2030 static int bnx2x_run_loopback(
struct bnx2x *bp,
int loopback_mode)
2032 unsigned int pkt_size, num_pkts,
i;
2038 u16 tx_start_idx, tx_idx;
2039 u16 rx_start_idx, rx_idx;
2040 u16 pkt_prod, bd_prod;
2045 u8 cqe_fp_flags, cqe_fp_type;
2054 switch (loopback_mode) {
2064 if (bp->
port.supported[cfg_idx] &
2079 "Can't configure external loopback\n");
2095 goto test_loopback_exit;
2097 packet =
skb_put(skb, pkt_size);
2101 for (i =
ETH_HLEN; i < pkt_size; i++)
2102 packet[i] = (
unsigned char) (i & 0xff);
2109 goto test_loopback_exit;
2117 netdev_tx_sent_queue(txq, skb->
len);
2144 u16 global_data = 0;
2152 u32 parsing_data = 0;
2175 if (tx_idx != tx_start_idx + num_pkts)
2176 goto test_loopback_exit;
2193 if (rx_idx != rx_start_idx + num_pkts)
2194 goto test_loopback_exit;
2200 goto test_loopback_rx_exit;
2203 if (len != pkt_size)
2204 goto test_loopback_rx_exit;
2211 for (i =
ETH_HLEN; i < pkt_size; i++)
2212 if (*(data + i) != (
unsigned char) (i & 0xff))
2213 goto test_loopback_rx_exit;
2217 test_loopback_rx_exit:
2234 static int bnx2x_test_loopback(
struct bnx2x *bp)
2241 if (!netif_running(bp->
dev))
2265 static int bnx2x_test_ext_loopback(
struct bnx2x *bp)
2274 if (!netif_running(bp->
dev))
2281 "Can't perform self-test, nic_load (for external lb) failed\n");
2284 bnx2x_wait_for_link(bp, 1, is_serdes);
2297 #define CRC32_RESIDUAL 0xdebb20e3
2299 static int bnx2x_test_nvram(
struct bnx2x *bp)
2301 static const struct {
2325 goto test_nvram_exit;
2329 rc = bnx2x_nvram_read(bp, 0, data, 4);
2332 "magic value read (rc %d)\n", rc);
2333 goto test_nvram_exit;
2337 if (magic != 0x669955aa) {
2339 "wrong magic value (0x%08x)\n", magic);
2341 goto test_nvram_exit;
2344 for (i = 0; nvram_tbl[
i].size; i++) {
2346 rc = bnx2x_nvram_read(bp, nvram_tbl[i].offset, data,
2350 "nvram_tbl[%d] read data (rc %d)\n", i, rc);
2351 goto test_nvram_exit;
2357 "nvram_tbl[%d] wrong crc value (0x%08x)\n", i, crc);
2359 goto test_nvram_exit;
2369 static int bnx2x_test_intr(
struct bnx2x *bp)
2373 if (!netif_running(bp->
dev)) {
2375 "cannot access eeprom when the interface is down\n");
2387 static void bnx2x_self_test(
struct net_device *dev,
2390 struct bnx2x *bp = netdev_priv(dev);
2396 "Handling parity error recovery. Try again later\n");
2401 "Self-test command parameters: offline = %d, external_lb = %d\n",
2407 if (!netif_running(dev)) {
2409 "Can't perform self-test when interface is down\n");
2433 "Can't perform self-test, nic_load (for offline) failed\n");
2438 bnx2x_wait_for_link(bp, 1, is_serdes);
2440 if (bnx2x_test_registers(bp) != 0) {
2444 if (bnx2x_test_memory(bp) != 0) {
2449 buf[2] = bnx2x_test_loopback(bp);
2454 buf[3] = bnx2x_test_ext_loopback(bp);
2468 "Can't perform self-test, nic_load (for online) failed\n");
2472 bnx2x_wait_for_link(bp, link_up, is_serdes);
2474 if (bnx2x_test_nvram(bp) != 0) {
2481 if (bnx2x_test_intr(bp) != 0) {
2497 #ifdef BNX2X_EXTRA_DEBUG
2502 #define IS_PORT_STAT(i) \
2503 ((bnx2x_stats_arr[i].flags & STATS_FLAGS_BOTH) == STATS_FLAGS_PORT)
2504 #define IS_FUNC_STAT(i) (bnx2x_stats_arr[i].flags & STATS_FLAGS_FUNC)
2505 #define IS_MF_MODE_STAT(bp) \
2506 (IS_MF(bp) && !(bp->msg_enable & BNX2X_MSG_STATS))
2511 static int bnx2x_num_stat_queues(
struct bnx2x *bp)
2516 static int bnx2x_get_sset_count(
struct net_device *dev,
int stringset)
2518 struct bnx2x *bp = netdev_priv(dev);
2521 switch (stringset) {
2524 num_stats = bnx2x_num_stat_queues(bp) *
2545 static void bnx2x_get_strings(
struct net_device *dev,
u32 stringset,
u8 *buf)
2547 struct bnx2x *bp = netdev_priv(dev);
2551 switch (stringset) {
2556 memset(queue_name, 0,
sizeof(queue_name));
2561 bnx2x_q_stats_arr[j].
string,
2572 bnx2x_stats_arr[i].
string);
2584 memcpy(buf, bnx2x_tests_str_arr + start,
2589 static void bnx2x_get_ethtool_stats(
struct net_device *dev,
2592 struct bnx2x *bp = netdev_priv(dev);
2600 if (bnx2x_q_stats_arr[j].
size == 0) {
2605 offset = (hw_stats +
2606 bnx2x_q_stats_arr[
j].offset);
2607 if (bnx2x_q_stats_arr[j].
size == 4) {
2609 buf[k +
j] = (
u64) *offset;
2613 buf[k +
j] =
HILO_U64(*offset, *(offset + 1));
2623 if (bnx2x_stats_arr[i].
size == 0) {
2629 offset = (hw_stats + bnx2x_stats_arr[
i].offset);
2630 if (bnx2x_stats_arr[i].
size == 4) {
2632 buf[k +
j] = (
u64) *offset;
2637 buf[k +
j] =
HILO_U64(*offset, *(offset + 1));
2642 static int bnx2x_set_phys_id(
struct net_device *dev,
2645 struct bnx2x *bp = netdev_priv(dev);
2647 if (!netif_running(dev)) {
2649 "cannot access eeprom when the interface is down\n");
2653 if (!bp->
port.pmf) {
2720 struct bnx2x *bp = netdev_priv(dev);
2722 switch (info->
cmd) {
2727 return bnx2x_get_rss_flags(bp, info);
2736 int udp_rss_requested;
2739 "Set rss flags command parameters: flow type = %d, data = %llu\n",
2749 "Command parameters not supported\n");
2760 udp_rss_requested = 1;
2762 udp_rss_requested = 0;
2769 "rss re-configured, UDP 4-tupple %s\n",
2770 udp_rss_requested ?
"enabled" :
"disabled");
2777 "rss re-configured, UDP 4-tupple %s\n",
2778 udp_rss_requested ?
"enabled" :
"disabled");
2787 "Command parameters not supported\n");
2805 "Command parameters not supported\n");
2817 struct bnx2x *bp = netdev_priv(dev);
2819 switch (info->
cmd) {
2821 return bnx2x_set_rss_flags(bp, info);
2828 static u32 bnx2x_get_rxfh_indir_size(
struct net_device *dev)
2833 static int bnx2x_get_rxfh_indir(
struct net_device *dev,
u32 *indir)
2835 struct bnx2x *bp = netdev_priv(dev);
2852 indir[i] = ind_table[i] - bp->
fp->cl_id;
2857 static int bnx2x_set_rxfh_indir(
struct net_device *dev,
const u32 *indir)
2859 struct bnx2x *bp = netdev_priv(dev);
2875 return bnx2x_config_rss_eth(bp,
false);
2884 static void bnx2x_get_channels(
struct net_device *dev,
2887 struct bnx2x *bp = netdev_priv(dev);
2901 static void bnx2x_change_num_queues(
struct bnx2x *bp,
int num_rss)
2903 bnx2x_disable_msi(bp);
2914 static int bnx2x_set_channels(
struct net_device *dev,
2917 struct bnx2x *bp = netdev_priv(dev);
2921 "set-channels command parameters: rx = %d, tx = %d, other = %d, combined = %d\n",
2945 if (
unlikely(!netif_running(dev))) {
2954 static const struct ethtool_ops bnx2x_ethtool_ops = {
2955 .get_settings = bnx2x_get_settings,
2956 .set_settings = bnx2x_set_settings,
2957 .get_drvinfo = bnx2x_get_drvinfo,
2958 .get_regs_len = bnx2x_get_regs_len,
2959 .get_regs = bnx2x_get_regs,
2960 .get_wol = bnx2x_get_wol,
2961 .set_wol = bnx2x_set_wol,
2962 .get_msglevel = bnx2x_get_msglevel,
2963 .set_msglevel = bnx2x_set_msglevel,
2964 .nway_reset = bnx2x_nway_reset,
2965 .get_link = bnx2x_get_link,
2966 .get_eeprom_len = bnx2x_get_eeprom_len,
2967 .get_eeprom = bnx2x_get_eeprom,
2968 .set_eeprom = bnx2x_set_eeprom,
2969 .get_coalesce = bnx2x_get_coalesce,
2970 .set_coalesce = bnx2x_set_coalesce,
2971 .get_ringparam = bnx2x_get_ringparam,
2972 .set_ringparam = bnx2x_set_ringparam,
2973 .get_pauseparam = bnx2x_get_pauseparam,
2974 .set_pauseparam = bnx2x_set_pauseparam,
2975 .self_test = bnx2x_self_test,
2976 .get_sset_count = bnx2x_get_sset_count,
2977 .get_strings = bnx2x_get_strings,
2978 .set_phys_id = bnx2x_set_phys_id,
2979 .get_ethtool_stats = bnx2x_get_ethtool_stats,
2980 .get_rxnfc = bnx2x_get_rxnfc,
2981 .set_rxnfc = bnx2x_set_rxnfc,
2982 .get_rxfh_indir_size = bnx2x_get_rxfh_indir_size,
2983 .get_rxfh_indir = bnx2x_get_rxfh_indir,
2984 .set_rxfh_indir = bnx2x_set_rxfh_indir,
2985 .get_channels = bnx2x_get_channels,
2986 .set_channels = bnx2x_set_channels,
2987 .get_module_info = bnx2x_get_module_info,
2988 .get_module_eeprom = bnx2x_get_module_eeprom,
2989 .get_eee = bnx2x_get_eee,
2990 .set_eee = bnx2x_set_eee,