aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mv643xx_eth.c
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2008-03-18 14:36:08 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-16 20:06:48 -0400
commitafdb57a2499a630d82b234307b1fc928088b9174 (patch)
tree2bfef5d9599abd6bfc953fb01af03a5a0946c19e /drivers/net/mv643xx_eth.c
parentc0d0f2caa1cd0f015aa42bbdb10cb8913bb95e4e (diff)
mv643xx_eth: identify ports by struct mv643xx_private *
Instead of identifying individual mv643xx ethernet ports by only their port number, identify them by their struct mv643xx_private *, as just a port number has no meaning when there are multiple mv643xx_eth silicon blocks in the system. Signed-off-by: Lennert Buytenhek <buytenh@marvell.com> Reviewed-by: Tzachi Perelstein <tzachi@marvell.com> Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Diffstat (limited to 'drivers/net/mv643xx_eth.c')
-rw-r--r--drivers/net/mv643xx_eth.c246
1 files changed, 128 insertions, 118 deletions
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index b66d62768077..b31844cb1ab4 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -564,42 +564,44 @@ struct mv643xx_private {
564 564
565/* Static function declarations */ 565/* Static function declarations */
566static void eth_port_init(struct mv643xx_private *mp); 566static void eth_port_init(struct mv643xx_private *mp);
567static void eth_port_reset(unsigned int eth_port_num); 567static void eth_port_reset(struct mv643xx_private *mp);
568static void eth_port_start(struct net_device *dev); 568static void eth_port_start(struct net_device *dev);
569 569
570static void ethernet_phy_reset(unsigned int eth_port_num); 570static void ethernet_phy_reset(struct mv643xx_private *mp);
571 571
572static void eth_port_write_smi_reg(unsigned int eth_port_num, 572static void eth_port_write_smi_reg(struct mv643xx_private *mp,
573 unsigned int phy_reg, unsigned int value); 573 unsigned int phy_reg, unsigned int value);
574 574
575static void eth_port_read_smi_reg(unsigned int eth_port_num, 575static void eth_port_read_smi_reg(struct mv643xx_private *mp,
576 unsigned int phy_reg, unsigned int *value); 576 unsigned int phy_reg, unsigned int *value);
577 577
578static void eth_clear_mib_counters(unsigned int eth_port_num); 578static void eth_clear_mib_counters(struct mv643xx_private *mp);
579 579
580static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp, 580static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp,
581 struct pkt_info *p_pkt_info); 581 struct pkt_info *p_pkt_info);
582static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp, 582static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp,
583 struct pkt_info *p_pkt_info); 583 struct pkt_info *p_pkt_info);
584 584
585static void eth_port_uc_addr_get(unsigned int port_num, unsigned char *p_addr); 585static void eth_port_uc_addr_get(struct mv643xx_private *mp,
586static void eth_port_uc_addr_set(unsigned int port_num, unsigned char *p_addr); 586 unsigned char *p_addr);
587static void eth_port_uc_addr_set(struct mv643xx_private *mp,
588 unsigned char *p_addr);
587static void eth_port_set_multicast_list(struct net_device *); 589static void eth_port_set_multicast_list(struct net_device *);
588static void mv643xx_eth_port_enable_tx(unsigned int port_num, 590static void mv643xx_eth_port_enable_tx(struct mv643xx_private *mp,
589 unsigned int queues); 591 unsigned int queues);
590static void mv643xx_eth_port_enable_rx(unsigned int port_num, 592static void mv643xx_eth_port_enable_rx(struct mv643xx_private *mp,
591 unsigned int queues); 593 unsigned int queues);
592static unsigned int mv643xx_eth_port_disable_tx(unsigned int port_num); 594static unsigned int mv643xx_eth_port_disable_tx(struct mv643xx_private *mp);
593static unsigned int mv643xx_eth_port_disable_rx(unsigned int port_num); 595static unsigned int mv643xx_eth_port_disable_rx(struct mv643xx_private *mp);
594static int mv643xx_eth_open(struct net_device *); 596static int mv643xx_eth_open(struct net_device *);
595static int mv643xx_eth_stop(struct net_device *); 597static int mv643xx_eth_stop(struct net_device *);
596static void eth_port_init_mac_tables(unsigned int eth_port_num); 598static void eth_port_init_mac_tables(struct mv643xx_private *mp);
597#ifdef MV643XX_NAPI 599#ifdef MV643XX_NAPI
598static int mv643xx_poll(struct napi_struct *napi, int budget); 600static int mv643xx_poll(struct napi_struct *napi, int budget);
599#endif 601#endif
600static int ethernet_phy_get(unsigned int eth_port_num); 602static int ethernet_phy_get(struct mv643xx_private *mp);
601static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr); 603static void ethernet_phy_set(struct mv643xx_private *mp, int phy_addr);
602static int ethernet_phy_detect(unsigned int eth_port_num); 604static int ethernet_phy_detect(struct mv643xx_private *mp);
603static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location); 605static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location);
604static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val); 606static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val);
605static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); 607static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
@@ -726,10 +728,9 @@ static inline void mv643xx_eth_rx_refill_descs_timer_wrapper(unsigned long data)
726static void mv643xx_eth_update_mac_address(struct net_device *dev) 728static void mv643xx_eth_update_mac_address(struct net_device *dev)
727{ 729{
728 struct mv643xx_private *mp = netdev_priv(dev); 730 struct mv643xx_private *mp = netdev_priv(dev);
729 unsigned int port_num = mp->port_num;
730 731
731 eth_port_init_mac_tables(port_num); 732 eth_port_init_mac_tables(mp);
732 eth_port_uc_addr_set(port_num, dev->dev_addr); 733 eth_port_uc_addr_set(mp, dev->dev_addr);
733} 734}
734 735
735/* 736/*
@@ -811,7 +812,7 @@ static void mv643xx_eth_tx_timeout_task(struct work_struct *ugly)
811 812
812 netif_stop_queue(dev); 813 netif_stop_queue(dev);
813 814
814 eth_port_reset(mp->port_num); 815 eth_port_reset(mp);
815 eth_port_start(dev); 816 eth_port_start(dev);
816 817
817 if (mp->tx_ring_size - mp->tx_desc_count >= MAX_DESCS_PER_SKB) 818 if (mp->tx_ring_size - mp->tx_desc_count >= MAX_DESCS_PER_SKB)
@@ -1011,14 +1012,14 @@ static void mv643xx_eth_update_pscr(struct net_device *dev,
1011 if ((o_pscr & SERIAL_PORT_ENABLE) == 0) 1012 if ((o_pscr & SERIAL_PORT_ENABLE) == 0)
1012 mv_write(PORT_SERIAL_CONTROL_REG(port_num), n_pscr); 1013 mv_write(PORT_SERIAL_CONTROL_REG(port_num), n_pscr);
1013 else { 1014 else {
1014 queues = mv643xx_eth_port_disable_tx(port_num); 1015 queues = mv643xx_eth_port_disable_tx(mp);
1015 1016
1016 o_pscr &= ~SERIAL_PORT_ENABLE; 1017 o_pscr &= ~SERIAL_PORT_ENABLE;
1017 mv_write(PORT_SERIAL_CONTROL_REG(port_num), o_pscr); 1018 mv_write(PORT_SERIAL_CONTROL_REG(port_num), o_pscr);
1018 mv_write(PORT_SERIAL_CONTROL_REG(port_num), n_pscr); 1019 mv_write(PORT_SERIAL_CONTROL_REG(port_num), n_pscr);
1019 mv_write(PORT_SERIAL_CONTROL_REG(port_num), n_pscr); 1020 mv_write(PORT_SERIAL_CONTROL_REG(port_num), n_pscr);
1020 if (queues) 1021 if (queues)
1021 mv643xx_eth_port_enable_tx(port_num, queues); 1022 mv643xx_eth_port_enable_tx(mp, queues);
1022 } 1023 }
1023 } 1024 }
1024} 1025}
@@ -1059,8 +1060,7 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id)
1059 if (mii_link_ok(&mp->mii)) { 1060 if (mii_link_ok(&mp->mii)) {
1060 mii_ethtool_gset(&mp->mii, &cmd); 1061 mii_ethtool_gset(&mp->mii, &cmd);
1061 mv643xx_eth_update_pscr(dev, &cmd); 1062 mv643xx_eth_update_pscr(dev, &cmd);
1062 mv643xx_eth_port_enable_tx(port_num, 1063 mv643xx_eth_port_enable_tx(mp, ETH_TX_QUEUES_ENABLED);
1063 ETH_TX_QUEUES_ENABLED);
1064 if (!netif_carrier_ok(dev)) { 1064 if (!netif_carrier_ok(dev)) {
1065 netif_carrier_on(dev); 1065 netif_carrier_on(dev);
1066 if (mp->tx_ring_size - mp->tx_desc_count >= 1066 if (mp->tx_ring_size - mp->tx_desc_count >=
@@ -1114,7 +1114,7 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id)
1114 * , and the required delay of the interrupt in usec. 1114 * , and the required delay of the interrupt in usec.
1115 * 1115 *
1116 * INPUT: 1116 * INPUT:
1117 * unsigned int eth_port_num Ethernet port number 1117 * struct mv643xx_private *mp Ethernet port
1118 * unsigned int t_clk t_clk of the MV-643xx chip in HZ units 1118 * unsigned int t_clk t_clk of the MV-643xx chip in HZ units
1119 * unsigned int delay Delay in usec 1119 * unsigned int delay Delay in usec
1120 * 1120 *
@@ -1125,15 +1125,16 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id)
1125 * The interrupt coalescing value set in the gigE port. 1125 * The interrupt coalescing value set in the gigE port.
1126 * 1126 *
1127 */ 1127 */
1128static unsigned int eth_port_set_rx_coal(unsigned int eth_port_num, 1128static unsigned int eth_port_set_rx_coal(struct mv643xx_private *mp,
1129 unsigned int t_clk, unsigned int delay) 1129 unsigned int t_clk, unsigned int delay)
1130{ 1130{
1131 unsigned int port_num = mp->port_num;
1131 unsigned int coal = ((t_clk / 1000000) * delay) / 64; 1132 unsigned int coal = ((t_clk / 1000000) * delay) / 64;
1132 1133
1133 /* Set RX Coalescing mechanism */ 1134 /* Set RX Coalescing mechanism */
1134 mv_write(SDMA_CONFIG_REG(eth_port_num), 1135 mv_write(SDMA_CONFIG_REG(port_num),
1135 ((coal & 0x3fff) << 8) | 1136 ((coal & 0x3fff) << 8) |
1136 (mv_read(SDMA_CONFIG_REG(eth_port_num)) 1137 (mv_read(SDMA_CONFIG_REG(port_num))
1137 & 0xffc000ff)); 1138 & 0xffc000ff));
1138 1139
1139 return coal; 1140 return coal;
@@ -1152,7 +1153,7 @@ static unsigned int eth_port_set_rx_coal(unsigned int eth_port_num,
1152 * MV-643xx chip and the required delay in the interrupt in uSec 1153 * MV-643xx chip and the required delay in the interrupt in uSec
1153 * 1154 *
1154 * INPUT: 1155 * INPUT:
1155 * unsigned int eth_port_num Ethernet port number 1156 * struct mv643xx_private *mp Ethernet port
1156 * unsigned int t_clk t_clk of the MV-643xx chip in HZ units 1157 * unsigned int t_clk t_clk of the MV-643xx chip in HZ units
1157 * unsigned int delay Delay in uSeconds 1158 * unsigned int delay Delay in uSeconds
1158 * 1159 *
@@ -1163,13 +1164,14 @@ static unsigned int eth_port_set_rx_coal(unsigned int eth_port_num,
1163 * The interrupt coalescing value set in the gigE port. 1164 * The interrupt coalescing value set in the gigE port.
1164 * 1165 *
1165 */ 1166 */
1166static unsigned int eth_port_set_tx_coal(unsigned int eth_port_num, 1167static unsigned int eth_port_set_tx_coal(struct mv643xx_private *mp,
1167 unsigned int t_clk, unsigned int delay) 1168 unsigned int t_clk, unsigned int delay)
1168{ 1169{
1169 unsigned int coal; 1170 unsigned int coal = ((t_clk / 1000000) * delay) / 64;
1170 coal = ((t_clk / 1000000) * delay) / 64; 1171
1171 /* Set TX Coalescing mechanism */ 1172 /* Set TX Coalescing mechanism */
1172 mv_write(TX_FIFO_URGENT_THRESHOLD_REG(eth_port_num), coal << 4); 1173 mv_write(TX_FIFO_URGENT_THRESHOLD_REG(mp->port_num), coal << 4);
1174
1173 return coal; 1175 return coal;
1174} 1176}
1175 1177
@@ -1408,11 +1410,11 @@ static int mv643xx_eth_open(struct net_device *dev)
1408 1410
1409#ifdef MV643XX_COAL 1411#ifdef MV643XX_COAL
1410 mp->rx_int_coal = 1412 mp->rx_int_coal =
1411 eth_port_set_rx_coal(port_num, 133000000, MV643XX_RX_COAL); 1413 eth_port_set_rx_coal(mp, 133000000, MV643XX_RX_COAL);
1412#endif 1414#endif
1413 1415
1414 mp->tx_int_coal = 1416 mp->tx_int_coal =
1415 eth_port_set_tx_coal(port_num, 133000000, MV643XX_TX_COAL); 1417 eth_port_set_tx_coal(mp, 133000000, MV643XX_TX_COAL);
1416 1418
1417 /* Unmask phy and link status changes interrupts */ 1419 /* Unmask phy and link status changes interrupts */
1418 mv_write(INTERRUPT_EXTEND_MASK_REG(port_num), ETH_INT_UNMASK_ALL_EXT); 1420 mv_write(INTERRUPT_EXTEND_MASK_REG(port_num), ETH_INT_UNMASK_ALL_EXT);
@@ -1437,7 +1439,7 @@ static void mv643xx_eth_free_tx_rings(struct net_device *dev)
1437 struct mv643xx_private *mp = netdev_priv(dev); 1439 struct mv643xx_private *mp = netdev_priv(dev);
1438 1440
1439 /* Stop Tx Queues */ 1441 /* Stop Tx Queues */
1440 mv643xx_eth_port_disable_tx(mp->port_num); 1442 mv643xx_eth_port_disable_tx(mp);
1441 1443
1442 /* Free outstanding skb's on TX ring */ 1444 /* Free outstanding skb's on TX ring */
1443 mv643xx_eth_free_all_tx_descs(dev); 1445 mv643xx_eth_free_all_tx_descs(dev);
@@ -1455,11 +1457,10 @@ static void mv643xx_eth_free_tx_rings(struct net_device *dev)
1455static void mv643xx_eth_free_rx_rings(struct net_device *dev) 1457static void mv643xx_eth_free_rx_rings(struct net_device *dev)
1456{ 1458{
1457 struct mv643xx_private *mp = netdev_priv(dev); 1459 struct mv643xx_private *mp = netdev_priv(dev);
1458 unsigned int port_num = mp->port_num;
1459 int curr; 1460 int curr;
1460 1461
1461 /* Stop RX Queues */ 1462 /* Stop RX Queues */
1462 mv643xx_eth_port_disable_rx(port_num); 1463 mv643xx_eth_port_disable_rx(mp);
1463 1464
1464 /* Free preallocated skb's on RX rings */ 1465 /* Free preallocated skb's on RX rings */
1465 for (curr = 0; mp->rx_desc_count && curr < mp->rx_ring_size; curr++) { 1466 for (curr = 0; mp->rx_desc_count && curr < mp->rx_ring_size; curr++) {
@@ -1508,7 +1509,7 @@ static int mv643xx_eth_stop(struct net_device *dev)
1508 netif_carrier_off(dev); 1509 netif_carrier_off(dev);
1509 netif_stop_queue(dev); 1510 netif_stop_queue(dev);
1510 1511
1511 eth_port_reset(mp->port_num); 1512 eth_port_reset(mp);
1512 1513
1513 mv643xx_eth_free_tx_rings(dev); 1514 mv643xx_eth_free_tx_rings(dev);
1514 mv643xx_eth_free_rx_rings(dev); 1515 mv643xx_eth_free_rx_rings(dev);
@@ -1701,7 +1702,7 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp,
1701 1702
1702 /* ensure all descriptors are written before poking hardware */ 1703 /* ensure all descriptors are written before poking hardware */
1703 wmb(); 1704 wmb();
1704 mv643xx_eth_port_enable_tx(mp->port_num, ETH_TX_QUEUES_ENABLED); 1705 mv643xx_eth_port_enable_tx(mp, ETH_TX_QUEUES_ENABLED);
1705 1706
1706 mp->tx_desc_count += nr_frags + 1; 1707 mp->tx_desc_count += nr_frags + 1;
1707} 1708}
@@ -1876,7 +1877,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1876 port_num = mp->port_num = pd->port_number; 1877 port_num = mp->port_num = pd->port_number;
1877 1878
1878 /* set default config values */ 1879 /* set default config values */
1879 eth_port_uc_addr_get(port_num, dev->dev_addr); 1880 eth_port_uc_addr_get(mp, dev->dev_addr);
1880 mp->rx_ring_size = PORT_DEFAULT_RECEIVE_QUEUE_SIZE; 1881 mp->rx_ring_size = PORT_DEFAULT_RECEIVE_QUEUE_SIZE;
1881 mp->tx_ring_size = PORT_DEFAULT_TRANSMIT_QUEUE_SIZE; 1882 mp->tx_ring_size = PORT_DEFAULT_TRANSMIT_QUEUE_SIZE;
1882 1883
@@ -1884,7 +1885,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1884 memcpy(dev->dev_addr, pd->mac_addr, 6); 1885 memcpy(dev->dev_addr, pd->mac_addr, 6);
1885 1886
1886 if (pd->phy_addr || pd->force_phy_addr) 1887 if (pd->phy_addr || pd->force_phy_addr)
1887 ethernet_phy_set(port_num, pd->phy_addr); 1888 ethernet_phy_set(mp, pd->phy_addr);
1888 1889
1889 if (pd->rx_queue_size) 1890 if (pd->rx_queue_size)
1890 mp->rx_ring_size = pd->rx_queue_size; 1891 mp->rx_ring_size = pd->rx_queue_size;
@@ -1909,19 +1910,19 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1909 mp->mii.dev = dev; 1910 mp->mii.dev = dev;
1910 mp->mii.mdio_read = mv643xx_mdio_read; 1911 mp->mii.mdio_read = mv643xx_mdio_read;
1911 mp->mii.mdio_write = mv643xx_mdio_write; 1912 mp->mii.mdio_write = mv643xx_mdio_write;
1912 mp->mii.phy_id = ethernet_phy_get(port_num); 1913 mp->mii.phy_id = ethernet_phy_get(mp);
1913 mp->mii.phy_id_mask = 0x3f; 1914 mp->mii.phy_id_mask = 0x3f;
1914 mp->mii.reg_num_mask = 0x1f; 1915 mp->mii.reg_num_mask = 0x1f;
1915 1916
1916 err = ethernet_phy_detect(port_num); 1917 err = ethernet_phy_detect(mp);
1917 if (err) { 1918 if (err) {
1918 pr_debug("MV643xx ethernet port %d: " 1919 pr_debug("MV643xx ethernet port %d: "
1919 "No PHY detected at addr %d\n", 1920 "No PHY detected at addr %d\n",
1920 port_num, ethernet_phy_get(port_num)); 1921 port_num, ethernet_phy_get(mp));
1921 goto out; 1922 goto out;
1922 } 1923 }
1923 1924
1924 ethernet_phy_reset(port_num); 1925 ethernet_phy_reset(mp);
1925 mp->mii.supports_gmii = mii_check_gmii_support(&mp->mii); 1926 mp->mii.supports_gmii = mii_check_gmii_support(&mp->mii);
1926 mv643xx_init_ethtool_cmd(dev, mp->mii.phy_id, speed, duplex, &cmd); 1927 mv643xx_init_ethtool_cmd(dev, mp->mii.phy_id, speed, duplex, &cmd);
1927 mv643xx_eth_update_pscr(dev, &cmd); 1928 mv643xx_eth_update_pscr(dev, &cmd);
@@ -2016,7 +2017,7 @@ static void mv643xx_eth_shutdown(struct platform_device *pdev)
2016 mv_write(INTERRUPT_MASK_REG(port_num), 0); 2017 mv_write(INTERRUPT_MASK_REG(port_num), 0);
2017 mv_read (INTERRUPT_MASK_REG(port_num)); 2018 mv_read (INTERRUPT_MASK_REG(port_num));
2018 2019
2019 eth_port_reset(port_num); 2020 eth_port_reset(mp);
2020} 2021}
2021 2022
2022static struct platform_driver mv643xx_eth_driver = { 2023static struct platform_driver mv643xx_eth_driver = {
@@ -2205,12 +2206,9 @@ MODULE_ALIAS("platform:mv643xx_eth");
2205 * return_info Tx/Rx user resource return information. 2206 * return_info Tx/Rx user resource return information.
2206 */ 2207 */
2207 2208
2208/* PHY routines */
2209static int ethernet_phy_get(unsigned int eth_port_num);
2210static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr);
2211
2212/* Ethernet Port routines */ 2209/* Ethernet Port routines */
2213static void eth_port_set_filter_table_entry(int table, unsigned char entry); 2210static void eth_port_set_filter_table_entry(struct mv643xx_private *mp,
2211 int table, unsigned char entry);
2214 2212
2215/* 2213/*
2216 * eth_port_init - Initialize the Ethernet port driver 2214 * eth_port_init - Initialize the Ethernet port driver
@@ -2240,9 +2238,9 @@ static void eth_port_init(struct mv643xx_private *mp)
2240{ 2238{
2241 mp->rx_resource_err = 0; 2239 mp->rx_resource_err = 0;
2242 2240
2243 eth_port_reset(mp->port_num); 2241 eth_port_reset(mp);
2244 2242
2245 eth_port_init_mac_tables(mp->port_num); 2243 eth_port_init_mac_tables(mp);
2246} 2244}
2247 2245
2248/* 2246/*
@@ -2291,7 +2289,7 @@ static void eth_port_start(struct net_device *dev)
2291 (u32)((struct eth_rx_desc *)mp->rx_desc_dma + rx_curr_desc)); 2289 (u32)((struct eth_rx_desc *)mp->rx_desc_dma + rx_curr_desc));
2292 2290
2293 /* Add the assigned Ethernet address to the port's address table */ 2291 /* Add the assigned Ethernet address to the port's address table */
2294 eth_port_uc_addr_set(port_num, dev->dev_addr); 2292 eth_port_uc_addr_set(mp, dev->dev_addr);
2295 2293
2296 /* Assign port configuration and command. */ 2294 /* Assign port configuration and command. */
2297 mv_write(PORT_CONFIG_REG(port_num), 2295 mv_write(PORT_CONFIG_REG(port_num),
@@ -2321,22 +2319,24 @@ static void eth_port_start(struct net_device *dev)
2321 PORT_SDMA_CONFIG_DEFAULT_VALUE); 2319 PORT_SDMA_CONFIG_DEFAULT_VALUE);
2322 2320
2323 /* Enable port Rx. */ 2321 /* Enable port Rx. */
2324 mv643xx_eth_port_enable_rx(port_num, ETH_RX_QUEUES_ENABLED); 2322 mv643xx_eth_port_enable_rx(mp, ETH_RX_QUEUES_ENABLED);
2325 2323
2326 /* Disable port bandwidth limits by clearing MTU register */ 2324 /* Disable port bandwidth limits by clearing MTU register */
2327 mv_write(MAXIMUM_TRANSMIT_UNIT(port_num), 0); 2325 mv_write(MAXIMUM_TRANSMIT_UNIT(port_num), 0);
2328 2326
2329 /* save phy settings across reset */ 2327 /* save phy settings across reset */
2330 mv643xx_get_settings(dev, &ethtool_cmd); 2328 mv643xx_get_settings(dev, &ethtool_cmd);
2331 ethernet_phy_reset(mp->port_num); 2329 ethernet_phy_reset(mp);
2332 mv643xx_set_settings(dev, &ethtool_cmd); 2330 mv643xx_set_settings(dev, &ethtool_cmd);
2333} 2331}
2334 2332
2335/* 2333/*
2336 * eth_port_uc_addr_set - Write a MAC address into the port's hw registers 2334 * eth_port_uc_addr_set - Write a MAC address into the port's hw registers
2337 */ 2335 */
2338static void eth_port_uc_addr_set(unsigned int port_num, unsigned char *p_addr) 2336static void eth_port_uc_addr_set(struct mv643xx_private *mp,
2337 unsigned char *p_addr)
2339{ 2338{
2339 unsigned int port_num = mp->port_num;
2340 unsigned int mac_h; 2340 unsigned int mac_h;
2341 unsigned int mac_l; 2341 unsigned int mac_l;
2342 int table; 2342 int table;
@@ -2350,14 +2350,16 @@ static void eth_port_uc_addr_set(unsigned int port_num, unsigned char *p_addr)
2350 2350
2351 /* Accept frames with this address */ 2351 /* Accept frames with this address */
2352 table = DA_FILTER_UNICAST_TABLE_BASE(port_num); 2352 table = DA_FILTER_UNICAST_TABLE_BASE(port_num);
2353 eth_port_set_filter_table_entry(table, p_addr[5] & 0x0f); 2353 eth_port_set_filter_table_entry(mp, table, p_addr[5] & 0x0f);
2354} 2354}
2355 2355
2356/* 2356/*
2357 * eth_port_uc_addr_get - Read the MAC address from the port's hw registers 2357 * eth_port_uc_addr_get - Read the MAC address from the port's hw registers
2358 */ 2358 */
2359static void eth_port_uc_addr_get(unsigned int port_num, unsigned char *p_addr) 2359static void eth_port_uc_addr_get(struct mv643xx_private *mp,
2360 unsigned char *p_addr)
2360{ 2361{
2362 unsigned int port_num = mp->port_num;
2361 unsigned int mac_h; 2363 unsigned int mac_h;
2362 unsigned int mac_l; 2364 unsigned int mac_l;
2363 2365
@@ -2381,7 +2383,8 @@ static void eth_port_uc_addr_get(unsigned int port_num, unsigned char *p_addr)
2381 * 3-1 Queue (ETH_Q0=0) 2383 * 3-1 Queue (ETH_Q0=0)
2382 * 7-4 Reserved = 0; 2384 * 7-4 Reserved = 0;
2383 */ 2385 */
2384static void eth_port_set_filter_table_entry(int table, unsigned char entry) 2386static void eth_port_set_filter_table_entry(struct mv643xx_private *mp,
2387 int table, unsigned char entry)
2385{ 2388{
2386 unsigned int table_reg; 2389 unsigned int table_reg;
2387 unsigned int tbl_offset; 2390 unsigned int tbl_offset;
@@ -2410,8 +2413,9 @@ static void eth_port_set_filter_table_entry(int table, unsigned char entry)
2410 * In either case, eth_port_set_filter_table_entry() is then called 2413 * In either case, eth_port_set_filter_table_entry() is then called
2411 * to set to set the actual table entry. 2414 * to set to set the actual table entry.
2412 */ 2415 */
2413static void eth_port_mc_addr(unsigned int eth_port_num, unsigned char *p_addr) 2416static void eth_port_mc_addr(struct mv643xx_private *mp, unsigned char *p_addr)
2414{ 2417{
2418 unsigned int port_num = mp->port_num;
2415 unsigned int mac_h; 2419 unsigned int mac_h;
2416 unsigned int mac_l; 2420 unsigned int mac_l;
2417 unsigned char crc_result = 0; 2421 unsigned char crc_result = 0;
@@ -2422,9 +2426,8 @@ static void eth_port_mc_addr(unsigned int eth_port_num, unsigned char *p_addr)
2422 2426
2423 if ((p_addr[0] == 0x01) && (p_addr[1] == 0x00) && 2427 if ((p_addr[0] == 0x01) && (p_addr[1] == 0x00) &&
2424 (p_addr[2] == 0x5E) && (p_addr[3] == 0x00) && (p_addr[4] == 0x00)) { 2428 (p_addr[2] == 0x5E) && (p_addr[3] == 0x00) && (p_addr[4] == 0x00)) {
2425 table = DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE 2429 table = DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE(port_num);
2426 (eth_port_num); 2430 eth_port_set_filter_table_entry(mp, table, p_addr[5]);
2427 eth_port_set_filter_table_entry(table, p_addr[5]);
2428 return; 2431 return;
2429 } 2432 }
2430 2433
@@ -2496,8 +2499,8 @@ static void eth_port_mc_addr(unsigned int eth_port_num, unsigned char *p_addr)
2496 for (i = 0; i < 8; i++) 2499 for (i = 0; i < 8; i++)
2497 crc_result = crc_result | (crc[i] << i); 2500 crc_result = crc_result | (crc[i] << i);
2498 2501
2499 table = DA_FILTER_OTHER_MULTICAST_TABLE_BASE(eth_port_num); 2502 table = DA_FILTER_OTHER_MULTICAST_TABLE_BASE(port_num);
2500 eth_port_set_filter_table_entry(table, crc_result); 2503 eth_port_set_filter_table_entry(mp, table, crc_result);
2501} 2504}
2502 2505
2503/* 2506/*
@@ -2559,7 +2562,7 @@ static void eth_port_set_multicast_list(struct net_device *dev)
2559 (i < 256) && (mc_list != NULL) && (i < dev->mc_count); 2562 (i < 256) && (mc_list != NULL) && (i < dev->mc_count);
2560 i++, mc_list = mc_list->next) 2563 i++, mc_list = mc_list->next)
2561 if (mc_list->dmi_addrlen == 6) 2564 if (mc_list->dmi_addrlen == 6)
2562 eth_port_mc_addr(eth_port_num, mc_list->dmi_addr); 2565 eth_port_mc_addr(mp, mc_list->dmi_addr);
2563} 2566}
2564 2567
2565/* 2568/*
@@ -2570,7 +2573,7 @@ static void eth_port_set_multicast_list(struct net_device *dev)
2570 * Other Multicast) and set each entry to 0. 2573 * Other Multicast) and set each entry to 0.
2571 * 2574 *
2572 * INPUT: 2575 * INPUT:
2573 * unsigned int eth_port_num Ethernet Port number. 2576 * struct mv643xx_private *mp Ethernet Port.
2574 * 2577 *
2575 * OUTPUT: 2578 * OUTPUT:
2576 * Multicast and Unicast packets are rejected. 2579 * Multicast and Unicast packets are rejected.
@@ -2578,22 +2581,23 @@ static void eth_port_set_multicast_list(struct net_device *dev)
2578 * RETURN: 2581 * RETURN:
2579 * None. 2582 * None.
2580 */ 2583 */
2581static void eth_port_init_mac_tables(unsigned int eth_port_num) 2584static void eth_port_init_mac_tables(struct mv643xx_private *mp)
2582{ 2585{
2586 unsigned int port_num = mp->port_num;
2583 int table_index; 2587 int table_index;
2584 2588
2585 /* Clear DA filter unicast table (Ex_dFUT) */ 2589 /* Clear DA filter unicast table (Ex_dFUT) */
2586 for (table_index = 0; table_index <= 0xC; table_index += 4) 2590 for (table_index = 0; table_index <= 0xC; table_index += 4)
2587 mv_write(DA_FILTER_UNICAST_TABLE_BASE 2591 mv_write(DA_FILTER_UNICAST_TABLE_BASE(port_num) +
2588 (eth_port_num) + table_index, 0); 2592 table_index, 0);
2589 2593
2590 for (table_index = 0; table_index <= 0xFC; table_index += 4) { 2594 for (table_index = 0; table_index <= 0xFC; table_index += 4) {
2591 /* Clear DA filter special multicast table (Ex_dFSMT) */ 2595 /* Clear DA filter special multicast table (Ex_dFSMT) */
2592 mv_write(DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE 2596 mv_write(DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE(port_num) +
2593 (eth_port_num) + table_index, 0); 2597 table_index, 0);
2594 /* Clear DA filter other multicast table (Ex_dFOMT) */ 2598 /* Clear DA filter other multicast table (Ex_dFOMT) */
2595 mv_write(DA_FILTER_OTHER_MULTICAST_TABLE_BASE 2599 mv_write(DA_FILTER_OTHER_MULTICAST_TABLE_BASE(port_num) +
2596 (eth_port_num) + table_index, 0); 2600 table_index, 0);
2597 } 2601 }
2598} 2602}
2599 2603
@@ -2605,7 +2609,7 @@ static void eth_port_init_mac_tables(unsigned int eth_port_num)
2605 * A read from the MIB counter will reset the counter. 2609 * A read from the MIB counter will reset the counter.
2606 * 2610 *
2607 * INPUT: 2611 * INPUT:
2608 * unsigned int eth_port_num Ethernet Port number. 2612 * struct mv643xx_private *mp Ethernet Port.
2609 * 2613 *
2610 * OUTPUT: 2614 * OUTPUT:
2611 * After reading all MIB counters, the counters resets. 2615 * After reading all MIB counters, the counters resets.
@@ -2614,14 +2618,15 @@ static void eth_port_init_mac_tables(unsigned int eth_port_num)
2614 * MIB counter value. 2618 * MIB counter value.
2615 * 2619 *
2616 */ 2620 */
2617static void eth_clear_mib_counters(unsigned int eth_port_num) 2621static void eth_clear_mib_counters(struct mv643xx_private *mp)
2618{ 2622{
2623 unsigned int port_num = mp->port_num;
2619 int i; 2624 int i;
2620 2625
2621 /* Perform dummy reads from MIB counters */ 2626 /* Perform dummy reads from MIB counters */
2622 for (i = ETH_MIB_GOOD_OCTETS_RECEIVED_LOW; i < ETH_MIB_LATE_COLLISION; 2627 for (i = ETH_MIB_GOOD_OCTETS_RECEIVED_LOW; i < ETH_MIB_LATE_COLLISION;
2623 i += 4) 2628 i += 4)
2624 mv_read(MIB_COUNTERS_BASE(eth_port_num) + i); 2629 mv_read(MIB_COUNTERS_BASE(port_num) + i);
2625} 2630}
2626 2631
2627static inline u32 read_mib(struct mv643xx_private *mp, int offset) 2632static inline u32 read_mib(struct mv643xx_private *mp, int offset)
@@ -2662,7 +2667,7 @@ static void eth_update_mib_counters(struct mv643xx_private *mp)
2662 * the specified port. 2667 * the specified port.
2663 * 2668 *
2664 * INPUT: 2669 * INPUT:
2665 * unsigned int eth_port_num Ethernet Port number. 2670 * struct mv643xx_private *mp Ethernet Port.
2666 * 2671 *
2667 * OUTPUT: 2672 * OUTPUT:
2668 * None 2673 * None
@@ -2672,22 +2677,22 @@ static void eth_update_mib_counters(struct mv643xx_private *mp)
2672 * -ENODEV on failure 2677 * -ENODEV on failure
2673 * 2678 *
2674 */ 2679 */
2675static int ethernet_phy_detect(unsigned int port_num) 2680static int ethernet_phy_detect(struct mv643xx_private *mp)
2676{ 2681{
2677 unsigned int phy_reg_data0; 2682 unsigned int phy_reg_data0;
2678 int auto_neg; 2683 int auto_neg;
2679 2684
2680 eth_port_read_smi_reg(port_num, 0, &phy_reg_data0); 2685 eth_port_read_smi_reg(mp, 0, &phy_reg_data0);
2681 auto_neg = phy_reg_data0 & 0x1000; 2686 auto_neg = phy_reg_data0 & 0x1000;
2682 phy_reg_data0 ^= 0x1000; /* invert auto_neg */ 2687 phy_reg_data0 ^= 0x1000; /* invert auto_neg */
2683 eth_port_write_smi_reg(port_num, 0, phy_reg_data0); 2688 eth_port_write_smi_reg(mp, 0, phy_reg_data0);
2684 2689
2685 eth_port_read_smi_reg(port_num, 0, &phy_reg_data0); 2690 eth_port_read_smi_reg(mp, 0, &phy_reg_data0);
2686 if ((phy_reg_data0 & 0x1000) == auto_neg) 2691 if ((phy_reg_data0 & 0x1000) == auto_neg)
2687 return -ENODEV; /* change didn't take */ 2692 return -ENODEV; /* change didn't take */
2688 2693
2689 phy_reg_data0 ^= 0x1000; 2694 phy_reg_data0 ^= 0x1000;
2690 eth_port_write_smi_reg(port_num, 0, phy_reg_data0); 2695 eth_port_write_smi_reg(mp, 0, phy_reg_data0);
2691 return 0; 2696 return 0;
2692} 2697}
2693 2698
@@ -2698,7 +2703,7 @@ static int ethernet_phy_detect(unsigned int port_num)
2698 * This routine returns the given ethernet port PHY address. 2703 * This routine returns the given ethernet port PHY address.
2699 * 2704 *
2700 * INPUT: 2705 * INPUT:
2701 * unsigned int eth_port_num Ethernet Port number. 2706 * struct mv643xx_private *mp Ethernet Port.
2702 * 2707 *
2703 * OUTPUT: 2708 * OUTPUT:
2704 * None. 2709 * None.
@@ -2707,13 +2712,13 @@ static int ethernet_phy_detect(unsigned int port_num)
2707 * PHY address. 2712 * PHY address.
2708 * 2713 *
2709 */ 2714 */
2710static int ethernet_phy_get(unsigned int eth_port_num) 2715static int ethernet_phy_get(struct mv643xx_private *mp)
2711{ 2716{
2712 unsigned int reg_data; 2717 unsigned int reg_data;
2713 2718
2714 reg_data = mv_read(PHY_ADDR_REG); 2719 reg_data = mv_read(PHY_ADDR_REG);
2715 2720
2716 return ((reg_data >> (5 * eth_port_num)) & 0x1f); 2721 return ((reg_data >> (5 * mp->port_num)) & 0x1f);
2717} 2722}
2718 2723
2719/* 2724/*
@@ -2723,7 +2728,7 @@ static int ethernet_phy_get(unsigned int eth_port_num)
2723 * This routine sets the given ethernet port PHY address. 2728 * This routine sets the given ethernet port PHY address.
2724 * 2729 *
2725 * INPUT: 2730 * INPUT:
2726 * unsigned int eth_port_num Ethernet Port number. 2731 * struct mv643xx_private *mp Ethernet Port.
2727 * int phy_addr PHY address. 2732 * int phy_addr PHY address.
2728 * 2733 *
2729 * OUTPUT: 2734 * OUTPUT:
@@ -2733,10 +2738,10 @@ static int ethernet_phy_get(unsigned int eth_port_num)
2733 * None. 2738 * None.
2734 * 2739 *
2735 */ 2740 */
2736static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr) 2741static void ethernet_phy_set(struct mv643xx_private *mp, int phy_addr)
2737{ 2742{
2738 u32 reg_data; 2743 u32 reg_data;
2739 int addr_shift = 5 * eth_port_num; 2744 int addr_shift = 5 * mp->port_num;
2740 2745
2741 reg_data = mv_read(PHY_ADDR_REG); 2746 reg_data = mv_read(PHY_ADDR_REG);
2742 reg_data &= ~(0x1f << addr_shift); 2747 reg_data &= ~(0x1f << addr_shift);
@@ -2751,7 +2756,7 @@ static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr)
2751 * This routine utilizes the SMI interface to reset the ethernet port PHY. 2756 * This routine utilizes the SMI interface to reset the ethernet port PHY.
2752 * 2757 *
2753 * INPUT: 2758 * INPUT:
2754 * unsigned int eth_port_num Ethernet Port number. 2759 * struct mv643xx_private *mp Ethernet Port.
2755 * 2760 *
2756 * OUTPUT: 2761 * OUTPUT:
2757 * The PHY is reset. 2762 * The PHY is reset.
@@ -2760,36 +2765,37 @@ static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr)
2760 * None. 2765 * None.
2761 * 2766 *
2762 */ 2767 */
2763static void ethernet_phy_reset(unsigned int eth_port_num) 2768static void ethernet_phy_reset(struct mv643xx_private *mp)
2764{ 2769{
2765 unsigned int phy_reg_data; 2770 unsigned int phy_reg_data;
2766 2771
2767 /* Reset the PHY */ 2772 /* Reset the PHY */
2768 eth_port_read_smi_reg(eth_port_num, 0, &phy_reg_data); 2773 eth_port_read_smi_reg(mp, 0, &phy_reg_data);
2769 phy_reg_data |= 0x8000; /* Set bit 15 to reset the PHY */ 2774 phy_reg_data |= 0x8000; /* Set bit 15 to reset the PHY */
2770 eth_port_write_smi_reg(eth_port_num, 0, phy_reg_data); 2775 eth_port_write_smi_reg(mp, 0, phy_reg_data);
2771 2776
2772 /* wait for PHY to come out of reset */ 2777 /* wait for PHY to come out of reset */
2773 do { 2778 do {
2774 udelay(1); 2779 udelay(1);
2775 eth_port_read_smi_reg(eth_port_num, 0, &phy_reg_data); 2780 eth_port_read_smi_reg(mp, 0, &phy_reg_data);
2776 } while (phy_reg_data & 0x8000); 2781 } while (phy_reg_data & 0x8000);
2777} 2782}
2778 2783
2779static void mv643xx_eth_port_enable_tx(unsigned int port_num, 2784static void mv643xx_eth_port_enable_tx(struct mv643xx_private *mp,
2780 unsigned int queues) 2785 unsigned int queues)
2781{ 2786{
2782 mv_write(TRANSMIT_QUEUE_COMMAND_REG(port_num), queues); 2787 mv_write(TRANSMIT_QUEUE_COMMAND_REG(mp->port_num), queues);
2783} 2788}
2784 2789
2785static void mv643xx_eth_port_enable_rx(unsigned int port_num, 2790static void mv643xx_eth_port_enable_rx(struct mv643xx_private *mp,
2786 unsigned int queues) 2791 unsigned int queues)
2787{ 2792{
2788 mv_write(RECEIVE_QUEUE_COMMAND_REG(port_num), queues); 2793 mv_write(RECEIVE_QUEUE_COMMAND_REG(mp->port_num), queues);
2789} 2794}
2790 2795
2791static unsigned int mv643xx_eth_port_disable_tx(unsigned int port_num) 2796static unsigned int mv643xx_eth_port_disable_tx(struct mv643xx_private *mp)
2792{ 2797{
2798 unsigned int port_num = mp->port_num;
2793 u32 queues; 2799 u32 queues;
2794 2800
2795 /* Stop Tx port activity. Check port Tx activity. */ 2801 /* Stop Tx port activity. Check port Tx activity. */
@@ -2812,8 +2818,9 @@ static unsigned int mv643xx_eth_port_disable_tx(unsigned int port_num)
2812 return queues; 2818 return queues;
2813} 2819}
2814 2820
2815static unsigned int mv643xx_eth_port_disable_rx(unsigned int port_num) 2821static unsigned int mv643xx_eth_port_disable_rx(struct mv643xx_private *mp)
2816{ 2822{
2823 unsigned int port_num = mp->port_num;
2817 u32 queues; 2824 u32 queues;
2818 2825
2819 /* Stop Rx port activity. Check port Rx activity. */ 2826 /* Stop Rx port activity. Check port Rx activity. */
@@ -2840,7 +2847,7 @@ static unsigned int mv643xx_eth_port_disable_rx(unsigned int port_num)
2840 * idle state after this command is performed and the port is disabled. 2847 * idle state after this command is performed and the port is disabled.
2841 * 2848 *
2842 * INPUT: 2849 * INPUT:
2843 * unsigned int eth_port_num Ethernet Port number. 2850 * struct mv643xx_private *mp Ethernet Port.
2844 * 2851 *
2845 * OUTPUT: 2852 * OUTPUT:
2846 * Channel activity is halted. 2853 * Channel activity is halted.
@@ -2849,15 +2856,16 @@ static unsigned int mv643xx_eth_port_disable_rx(unsigned int port_num)
2849 * None. 2856 * None.
2850 * 2857 *
2851 */ 2858 */
2852static void eth_port_reset(unsigned int port_num) 2859static void eth_port_reset(struct mv643xx_private *mp)
2853{ 2860{
2861 unsigned int port_num = mp->port_num;
2854 unsigned int reg_data; 2862 unsigned int reg_data;
2855 2863
2856 mv643xx_eth_port_disable_tx(port_num); 2864 mv643xx_eth_port_disable_tx(mp);
2857 mv643xx_eth_port_disable_rx(port_num); 2865 mv643xx_eth_port_disable_rx(mp);
2858 2866
2859 /* Clear all MIB counters */ 2867 /* Clear all MIB counters */
2860 eth_clear_mib_counters(port_num); 2868 eth_clear_mib_counters(mp);
2861 2869
2862 /* Reset the Enable bit in the Configuration Register */ 2870 /* Reset the Enable bit in the Configuration Register */
2863 reg_data = mv_read(PORT_SERIAL_CONTROL_REG(port_num)); 2871 reg_data = mv_read(PORT_SERIAL_CONTROL_REG(port_num));
@@ -2876,7 +2884,7 @@ static void eth_port_reset(unsigned int port_num)
2876 * order to perform PHY register read. 2884 * order to perform PHY register read.
2877 * 2885 *
2878 * INPUT: 2886 * INPUT:
2879 * unsigned int port_num Ethernet Port number. 2887 * struct mv643xx_private *mp Ethernet Port.
2880 * unsigned int phy_reg PHY register address offset. 2888 * unsigned int phy_reg PHY register address offset.
2881 * unsigned int *value Register value buffer. 2889 * unsigned int *value Register value buffer.
2882 * 2890 *
@@ -2888,10 +2896,10 @@ static void eth_port_reset(unsigned int port_num)
2888 * true otherwise. 2896 * true otherwise.
2889 * 2897 *
2890 */ 2898 */
2891static void eth_port_read_smi_reg(unsigned int port_num, 2899static void eth_port_read_smi_reg(struct mv643xx_private *mp,
2892 unsigned int phy_reg, unsigned int *value) 2900 unsigned int phy_reg, unsigned int *value)
2893{ 2901{
2894 int phy_addr = ethernet_phy_get(port_num); 2902 int phy_addr = ethernet_phy_get(mp);
2895 unsigned long flags; 2903 unsigned long flags;
2896 int i; 2904 int i;
2897 2905
@@ -2901,7 +2909,8 @@ static void eth_port_read_smi_reg(unsigned int port_num,
2901 /* wait for the SMI register to become available */ 2909 /* wait for the SMI register to become available */
2902 for (i = 0; mv_read(SMI_REG) & ETH_SMI_BUSY; i++) { 2910 for (i = 0; mv_read(SMI_REG) & ETH_SMI_BUSY; i++) {
2903 if (i == PHY_WAIT_ITERATIONS) { 2911 if (i == PHY_WAIT_ITERATIONS) {
2904 printk("mv643xx PHY busy timeout, port %d\n", port_num); 2912 printk("mv643xx PHY busy timeout, port %d\n",
2913 mp->port_num);
2905 goto out; 2914 goto out;
2906 } 2915 }
2907 udelay(PHY_WAIT_MICRO_SECONDS); 2916 udelay(PHY_WAIT_MICRO_SECONDS);
@@ -2913,7 +2922,8 @@ static void eth_port_read_smi_reg(unsigned int port_num,
2913 /* now wait for the data to be valid */ 2922 /* now wait for the data to be valid */
2914 for (i = 0; !(mv_read(SMI_REG) & ETH_SMI_READ_VALID); i++) { 2923 for (i = 0; !(mv_read(SMI_REG) & ETH_SMI_READ_VALID); i++) {
2915 if (i == PHY_WAIT_ITERATIONS) { 2924 if (i == PHY_WAIT_ITERATIONS) {
2916 printk("mv643xx PHY read timeout, port %d\n", port_num); 2925 printk("mv643xx PHY read timeout, port %d\n",
2926 mp->port_num);
2917 goto out; 2927 goto out;
2918 } 2928 }
2919 udelay(PHY_WAIT_MICRO_SECONDS); 2929 udelay(PHY_WAIT_MICRO_SECONDS);
@@ -2932,7 +2942,7 @@ out:
2932 * order to perform writes to PHY registers. 2942 * order to perform writes to PHY registers.
2933 * 2943 *
2934 * INPUT: 2944 * INPUT:
2935 * unsigned int eth_port_num Ethernet Port number. 2945 * struct mv643xx_private *mp Ethernet Port.
2936 * unsigned int phy_reg PHY register address offset. 2946 * unsigned int phy_reg PHY register address offset.
2937 * unsigned int value Register value. 2947 * unsigned int value Register value.
2938 * 2948 *
@@ -2944,14 +2954,14 @@ out:
2944 * true otherwise. 2954 * true otherwise.
2945 * 2955 *
2946 */ 2956 */
2947static void eth_port_write_smi_reg(unsigned int eth_port_num, 2957static void eth_port_write_smi_reg(struct mv643xx_private *mp,
2948 unsigned int phy_reg, unsigned int value) 2958 unsigned int phy_reg, unsigned int value)
2949{ 2959{
2950 int phy_addr; 2960 int phy_addr;
2951 int i; 2961 int i;
2952 unsigned long flags; 2962 unsigned long flags;
2953 2963
2954 phy_addr = ethernet_phy_get(eth_port_num); 2964 phy_addr = ethernet_phy_get(mp);
2955 2965
2956 /* the SMI register is a shared resource */ 2966 /* the SMI register is a shared resource */
2957 spin_lock_irqsave(&mv643xx_eth_phy_lock, flags); 2967 spin_lock_irqsave(&mv643xx_eth_phy_lock, flags);
@@ -2960,7 +2970,7 @@ static void eth_port_write_smi_reg(unsigned int eth_port_num,
2960 for (i = 0; mv_read(SMI_REG) & ETH_SMI_BUSY; i++) { 2970 for (i = 0; mv_read(SMI_REG) & ETH_SMI_BUSY; i++) {
2961 if (i == PHY_WAIT_ITERATIONS) { 2971 if (i == PHY_WAIT_ITERATIONS) {
2962 printk("mv643xx PHY busy timeout, port %d\n", 2972 printk("mv643xx PHY busy timeout, port %d\n",
2963 eth_port_num); 2973 mp->port_num);
2964 goto out; 2974 goto out;
2965 } 2975 }
2966 udelay(PHY_WAIT_MICRO_SECONDS); 2976 udelay(PHY_WAIT_MICRO_SECONDS);
@@ -2977,17 +2987,17 @@ out:
2977 */ 2987 */
2978static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location) 2988static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location)
2979{ 2989{
2980 int val;
2981 struct mv643xx_private *mp = netdev_priv(dev); 2990 struct mv643xx_private *mp = netdev_priv(dev);
2991 int val;
2982 2992
2983 eth_port_read_smi_reg(mp->port_num, location, &val); 2993 eth_port_read_smi_reg(mp, location, &val);
2984 return val; 2994 return val;
2985} 2995}
2986 2996
2987static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val) 2997static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val)
2988{ 2998{
2989 struct mv643xx_private *mp = netdev_priv(dev); 2999 struct mv643xx_private *mp = netdev_priv(dev);
2990 eth_port_write_smi_reg(mp->port_num, location, val); 3000 eth_port_write_smi_reg(mp, location, val);
2991} 3001}
2992 3002
2993/* 3003/*