diff options
author | Mithlesh Thukral <mithlesh@netxen.com> | 2007-04-20 10:52:37 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 11:01:05 -0400 |
commit | 3176ff3ee71bddbd1d68e6a9e28dbcf0a2960c95 (patch) | |
tree | 260ba783bbd24bf21f17c11f9a6f06a7c50a9fc6 /drivers/net/netxen/netxen_nic_ethtool.c | |
parent | d52df4a35af569071fda3f4eb08e47cc7023f094 (diff) |
NetXen: Use multiple PCI functions
NetXen: Make driver use multiple PCI functions.
This patch will make NetXen driver work with multiple PCI functions. This will
make the usage of memory resources as well as interrupts more independent
among different functions which results in better throughput. This change has
been done after the multiport support is added in firmware.
Signed-off by: Mithlesh Thukral <mithlesh@netxen.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_ethtool.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_ethtool.c | 83 |
1 files changed, 38 insertions, 45 deletions
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index ee1b5a24cbe7..c400f264ea43 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c | |||
@@ -50,8 +50,8 @@ struct netxen_nic_stats { | |||
50 | int stat_offset; | 50 | int stat_offset; |
51 | }; | 51 | }; |
52 | 52 | ||
53 | #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \ | 53 | #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \ |
54 | offsetof(struct netxen_port, m) | 54 | offsetof(struct netxen_adapter, m) |
55 | 55 | ||
56 | #define NETXEN_NIC_PORT_WINDOW 0x10000 | 56 | #define NETXEN_NIC_PORT_WINDOW 0x10000 |
57 | #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF | 57 | #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF |
@@ -100,8 +100,7 @@ static int netxen_nic_get_eeprom_len(struct net_device *dev) | |||
100 | static void | 100 | static void |
101 | netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | 101 | netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) |
102 | { | 102 | { |
103 | struct netxen_port *port = netdev_priv(dev); | 103 | struct netxen_adapter *adapter = netdev_priv(dev); |
104 | struct netxen_adapter *adapter = port->adapter; | ||
105 | u32 fw_major = 0; | 104 | u32 fw_major = 0; |
106 | u32 fw_minor = 0; | 105 | u32 fw_minor = 0; |
107 | u32 fw_build = 0; | 106 | u32 fw_build = 0; |
@@ -115,7 +114,7 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |||
115 | fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB)); | 114 | fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB)); |
116 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); | 115 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); |
117 | 116 | ||
118 | strncpy(drvinfo->bus_info, pci_name(port->pdev), 32); | 117 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
119 | drvinfo->n_stats = NETXEN_NIC_STATS_LEN; | 118 | drvinfo->n_stats = NETXEN_NIC_STATS_LEN; |
120 | drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN; | 119 | drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN; |
121 | drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; | 120 | drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; |
@@ -125,8 +124,7 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |||
125 | static int | 124 | static int |
126 | netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 125 | netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
127 | { | 126 | { |
128 | struct netxen_port *port = netdev_priv(dev); | 127 | struct netxen_adapter *adapter = netdev_priv(dev); |
129 | struct netxen_adapter *adapter = port->adapter; | ||
130 | struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg; | 128 | struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg; |
131 | 129 | ||
132 | /* read which mode */ | 130 | /* read which mode */ |
@@ -146,8 +144,8 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
146 | ecmd->port = PORT_TP; | 144 | ecmd->port = PORT_TP; |
147 | 145 | ||
148 | if (netif_running(dev)) { | 146 | if (netif_running(dev)) { |
149 | ecmd->speed = port->link_speed; | 147 | ecmd->speed = adapter->link_speed; |
150 | ecmd->duplex = port->link_duplex; | 148 | ecmd->duplex = adapter->link_duplex; |
151 | } else | 149 | } else |
152 | return -EIO; /* link absent */ | 150 | return -EIO; /* link absent */ |
153 | } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { | 151 | } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { |
@@ -165,7 +163,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
165 | } else | 163 | } else |
166 | return -EIO; | 164 | return -EIO; |
167 | 165 | ||
168 | ecmd->phy_address = port->portnum; | 166 | ecmd->phy_address = adapter->portnum; |
169 | ecmd->transceiver = XCVR_EXTERNAL; | 167 | ecmd->transceiver = XCVR_EXTERNAL; |
170 | 168 | ||
171 | switch ((netxen_brdtype_t) boardinfo->board_type) { | 169 | switch ((netxen_brdtype_t) boardinfo->board_type) { |
@@ -179,7 +177,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
179 | ecmd->port = PORT_TP; | 177 | ecmd->port = PORT_TP; |
180 | ecmd->autoneg = (boardinfo->board_type == | 178 | ecmd->autoneg = (boardinfo->board_type == |
181 | NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? | 179 | NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? |
182 | (AUTONEG_DISABLE) : (port->link_autoneg); | 180 | (AUTONEG_DISABLE) : (adapter->link_autoneg); |
183 | break; | 181 | break; |
184 | case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: | 182 | case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: |
185 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: | 183 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: |
@@ -206,23 +204,22 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
206 | static int | 204 | static int |
207 | netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 205 | netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
208 | { | 206 | { |
209 | struct netxen_port *port = netdev_priv(dev); | 207 | struct netxen_adapter *adapter = netdev_priv(dev); |
210 | struct netxen_adapter *adapter = port->adapter; | ||
211 | __u32 status; | 208 | __u32 status; |
212 | 209 | ||
213 | /* read which mode */ | 210 | /* read which mode */ |
214 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 211 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
215 | /* autonegotiation */ | 212 | /* autonegotiation */ |
216 | if (adapter->phy_write | 213 | if (adapter->phy_write |
217 | && adapter->phy_write(adapter, port->portnum, | 214 | && adapter->phy_write(adapter, adapter->portnum, |
218 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, | 215 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
219 | ecmd->autoneg) != 0) | 216 | ecmd->autoneg) != 0) |
220 | return -EIO; | 217 | return -EIO; |
221 | else | 218 | else |
222 | port->link_autoneg = ecmd->autoneg; | 219 | adapter->link_autoneg = ecmd->autoneg; |
223 | 220 | ||
224 | if (adapter->phy_read | 221 | if (adapter->phy_read |
225 | && adapter->phy_read(adapter, port->portnum, | 222 | && adapter->phy_read(adapter, adapter->portnum, |
226 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 223 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
227 | &status) != 0) | 224 | &status) != 0) |
228 | return -EIO; | 225 | return -EIO; |
@@ -245,13 +242,13 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
245 | if (ecmd->duplex == DUPLEX_FULL) | 242 | if (ecmd->duplex == DUPLEX_FULL) |
246 | netxen_set_phy_duplex(status); | 243 | netxen_set_phy_duplex(status); |
247 | if (adapter->phy_write | 244 | if (adapter->phy_write |
248 | && adapter->phy_write(adapter, port->portnum, | 245 | && adapter->phy_write(adapter, adapter->portnum, |
249 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 246 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
250 | *((int *)&status)) != 0) | 247 | *((int *)&status)) != 0) |
251 | return -EIO; | 248 | return -EIO; |
252 | else { | 249 | else { |
253 | port->link_speed = ecmd->speed; | 250 | adapter->link_speed = ecmd->speed; |
254 | port->link_duplex = ecmd->duplex; | 251 | adapter->link_duplex = ecmd->duplex; |
255 | } | 252 | } |
256 | } else | 253 | } else |
257 | return -EOPNOTSUPP; | 254 | return -EOPNOTSUPP; |
@@ -360,15 +357,14 @@ static struct netxen_niu_regs niu_registers[] = { | |||
360 | static void | 357 | static void |
361 | netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) | 358 | netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) |
362 | { | 359 | { |
363 | struct netxen_port *port = netdev_priv(dev); | 360 | struct netxen_adapter *adapter = netdev_priv(dev); |
364 | struct netxen_adapter *adapter = port->adapter; | ||
365 | __u32 mode, *regs_buff = p; | 361 | __u32 mode, *regs_buff = p; |
366 | void __iomem *addr; | 362 | void __iomem *addr; |
367 | int i, window; | 363 | int i, window; |
368 | 364 | ||
369 | memset(p, 0, NETXEN_NIC_REGS_LEN); | 365 | memset(p, 0, NETXEN_NIC_REGS_LEN); |
370 | regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | | 366 | regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | |
371 | (port->pdev)->device; | 367 | (adapter->pdev)->device; |
372 | /* which mode */ | 368 | /* which mode */ |
373 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, ®s_buff[0]); | 369 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, ®s_buff[0]); |
374 | mode = regs_buff[0]; | 370 | mode = regs_buff[0]; |
@@ -383,7 +379,8 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) | |||
383 | for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { | 379 | for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { |
384 | /* GB: port specific registers */ | 380 | /* GB: port specific registers */ |
385 | if (mode == 0 && i >= 19) | 381 | if (mode == 0 && i >= 19) |
386 | window = port->portnum * NETXEN_NIC_PORT_WINDOW; | 382 | window = adapter->portnum * |
383 | NETXEN_NIC_PORT_WINDOW; | ||
387 | 384 | ||
388 | NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode]. | 385 | NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode]. |
389 | reg[i - 3] + window, | 386 | reg[i - 3] + window, |
@@ -395,15 +392,14 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) | |||
395 | 392 | ||
396 | static u32 netxen_nic_test_link(struct net_device *dev) | 393 | static u32 netxen_nic_test_link(struct net_device *dev) |
397 | { | 394 | { |
398 | struct netxen_port *port = netdev_priv(dev); | 395 | struct netxen_adapter *adapter = netdev_priv(dev); |
399 | struct netxen_adapter *adapter = port->adapter; | ||
400 | __u32 status; | 396 | __u32 status; |
401 | int val; | 397 | int val; |
402 | 398 | ||
403 | /* read which mode */ | 399 | /* read which mode */ |
404 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 400 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
405 | if (adapter->phy_read | 401 | if (adapter->phy_read |
406 | && adapter->phy_read(adapter, port->portnum, | 402 | && adapter->phy_read(adapter, adapter->portnum, |
407 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 403 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
408 | &status) != 0) | 404 | &status) != 0) |
409 | return -EIO; | 405 | return -EIO; |
@@ -422,15 +418,15 @@ static int | |||
422 | netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | 418 | netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, |
423 | u8 * bytes) | 419 | u8 * bytes) |
424 | { | 420 | { |
425 | struct netxen_port *port = netdev_priv(dev); | 421 | struct netxen_adapter *adapter = netdev_priv(dev); |
426 | struct netxen_adapter *adapter = port->adapter; | ||
427 | int offset; | 422 | int offset; |
428 | int ret; | 423 | int ret; |
429 | 424 | ||
430 | if (eeprom->len == 0) | 425 | if (eeprom->len == 0) |
431 | return -EINVAL; | 426 | return -EINVAL; |
432 | 427 | ||
433 | eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16); | 428 | eeprom->magic = (adapter->pdev)->vendor | |
429 | ((adapter->pdev)->device << 16); | ||
434 | offset = eeprom->offset; | 430 | offset = eeprom->offset; |
435 | 431 | ||
436 | ret = netxen_rom_fast_read_words(adapter, offset, bytes, | 432 | ret = netxen_rom_fast_read_words(adapter, offset, bytes, |
@@ -445,8 +441,7 @@ static int | |||
445 | netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | 441 | netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, |
446 | u8 * bytes) | 442 | u8 * bytes) |
447 | { | 443 | { |
448 | struct netxen_port *port = netdev_priv(dev); | 444 | struct netxen_adapter *adapter = netdev_priv(dev); |
449 | struct netxen_adapter *adapter = port->adapter; | ||
450 | int offset = eeprom->offset; | 445 | int offset = eeprom->offset; |
451 | static int flash_start; | 446 | static int flash_start; |
452 | static int ready_to_flash; | 447 | static int ready_to_flash; |
@@ -516,8 +511,7 @@ netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | |||
516 | static void | 511 | static void |
517 | netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) | 512 | netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) |
518 | { | 513 | { |
519 | struct netxen_port *port = netdev_priv(dev); | 514 | struct netxen_adapter *adapter = netdev_priv(dev); |
520 | struct netxen_adapter *adapter = port->adapter; | ||
521 | int i; | 515 | int i; |
522 | 516 | ||
523 | ring->rx_pending = 0; | 517 | ring->rx_pending = 0; |
@@ -541,19 +535,18 @@ static void | |||
541 | netxen_nic_get_pauseparam(struct net_device *dev, | 535 | netxen_nic_get_pauseparam(struct net_device *dev, |
542 | struct ethtool_pauseparam *pause) | 536 | struct ethtool_pauseparam *pause) |
543 | { | 537 | { |
544 | struct netxen_port *port = netdev_priv(dev); | 538 | struct netxen_adapter *adapter = netdev_priv(dev); |
545 | struct netxen_adapter *adapter = port->adapter; | ||
546 | __u32 val; | 539 | __u32 val; |
547 | 540 | ||
548 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 541 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
549 | /* get flow control settings */ | 542 | /* get flow control settings */ |
550 | netxen_nic_read_w0(adapter, | 543 | netxen_nic_read_w0(adapter, |
551 | NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), | 544 | NETXEN_NIU_GB_MAC_CONFIG_0(adapter->portnum), |
552 | &val); | 545 | &val); |
553 | pause->rx_pause = netxen_gb_get_rx_flowctl(val); | 546 | pause->rx_pause = netxen_gb_get_rx_flowctl(val); |
554 | pause->tx_pause = netxen_gb_get_tx_flowctl(val); | 547 | pause->tx_pause = netxen_gb_get_tx_flowctl(val); |
555 | /* get autoneg settings */ | 548 | /* get autoneg settings */ |
556 | pause->autoneg = port->link_autoneg; | 549 | pause->autoneg = adapter->link_autoneg; |
557 | } | 550 | } |
558 | } | 551 | } |
559 | 552 | ||
@@ -561,8 +554,7 @@ static int | |||
561 | netxen_nic_set_pauseparam(struct net_device *dev, | 554 | netxen_nic_set_pauseparam(struct net_device *dev, |
562 | struct ethtool_pauseparam *pause) | 555 | struct ethtool_pauseparam *pause) |
563 | { | 556 | { |
564 | struct netxen_port *port = netdev_priv(dev); | 557 | struct netxen_adapter *adapter = netdev_priv(dev); |
565 | struct netxen_adapter *adapter = port->adapter; | ||
566 | __u32 val; | 558 | __u32 val; |
567 | unsigned int autoneg; | 559 | unsigned int autoneg; |
568 | 560 | ||
@@ -570,7 +562,7 @@ netxen_nic_set_pauseparam(struct net_device *dev, | |||
570 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 562 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
571 | /* set flow control */ | 563 | /* set flow control */ |
572 | netxen_nic_read_w0(adapter, | 564 | netxen_nic_read_w0(adapter, |
573 | NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), | 565 | NETXEN_NIU_GB_MAC_CONFIG_0(adapter->portnum), |
574 | (u32 *) & val); | 566 | (u32 *) & val); |
575 | if (pause->tx_pause) | 567 | if (pause->tx_pause) |
576 | netxen_gb_tx_flowctl(val); | 568 | netxen_gb_tx_flowctl(val); |
@@ -582,17 +574,17 @@ netxen_nic_set_pauseparam(struct net_device *dev, | |||
582 | netxen_gb_unset_rx_flowctl(val); | 574 | netxen_gb_unset_rx_flowctl(val); |
583 | 575 | ||
584 | netxen_nic_write_w0(adapter, | 576 | netxen_nic_write_w0(adapter, |
585 | NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), | 577 | NETXEN_NIU_GB_MAC_CONFIG_0(adapter->portnum), |
586 | *&val); | 578 | *&val); |
587 | /* set autoneg */ | 579 | /* set autoneg */ |
588 | autoneg = pause->autoneg; | 580 | autoneg = pause->autoneg; |
589 | if (adapter->phy_write | 581 | if (adapter->phy_write |
590 | && adapter->phy_write(adapter, port->portnum, | 582 | && adapter->phy_write(adapter, adapter->portnum, |
591 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, | 583 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
592 | autoneg) != 0) | 584 | autoneg) != 0) |
593 | return -EIO; | 585 | return -EIO; |
594 | else { | 586 | else { |
595 | port->link_autoneg = pause->autoneg; | 587 | adapter->link_autoneg = pause->autoneg; |
596 | return 0; | 588 | return 0; |
597 | } | 589 | } |
598 | } else | 590 | } else |
@@ -675,12 +667,13 @@ static void | |||
675 | netxen_nic_get_ethtool_stats(struct net_device *dev, | 667 | netxen_nic_get_ethtool_stats(struct net_device *dev, |
676 | struct ethtool_stats *stats, u64 * data) | 668 | struct ethtool_stats *stats, u64 * data) |
677 | { | 669 | { |
678 | struct netxen_port *port = netdev_priv(dev); | 670 | struct netxen_adapter *adapter = netdev_priv(dev); |
679 | int index; | 671 | int index; |
680 | 672 | ||
681 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { | 673 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { |
682 | char *p = | 674 | char *p = |
683 | (char *)port + netxen_nic_gstrings_stats[index].stat_offset; | 675 | (char *)adapter + |
676 | netxen_nic_gstrings_stats[index].stat_offset; | ||
684 | data[index] = | 677 | data[index] = |
685 | (netxen_nic_gstrings_stats[index].sizeof_stat == | 678 | (netxen_nic_gstrings_stats[index].sizeof_stat == |
686 | sizeof(u64)) ? *(u64 *) p : *(u32 *) p; | 679 | sizeof(u64)) ? *(u64 *) p : *(u32 *) p; |