[ofa-general] [ PATCH 3/3 ] RDMA/nes SFP+ cleanup

Glenn Streiff gstreiff at neteffect.com
Mon Apr 28 21:26:43 PDT 2008


Clean up the SFP+ patch.

Signed-off-by: Glenn Streiff <gstreiff at neteffect.com>
---
 drivers/infiniband/hw/nes/nes_hw.c  |  279 ++++++++++++++++++-----------------
 drivers/infiniband/hw/nes/nes_nic.c |   63 ++++----
 2 files changed, 178 insertions(+), 164 deletions(-)

diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 19f2a5b..dce2d66 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -1214,9 +1214,9 @@ int nes_init_phy(struct nes_device *nesd
 	u16 phy_data;
 	u32 temp_phy_data = 0;
 	u32 temp_phy_data2 = 0;
-	u32 i =0;
+	u32 i = 0;
 
-	if ((nesadapter->OneG_Mode) && (nesadapter->phy_type[mac_index] != NES_PHY_TYPE_PUMA_1G)) {
+	if ((nesadapter->OneG_Mode) && (nesadapter->phy_type[ mac_index ] != NES_PHY_TYPE_PUMA_1G)) {
 		nes_debug(NES_DBG_PHY, "1G PHY, mac_index = %d.\n", mac_index);
 		if (nesadapter->phy_type[mac_index] == NES_PHY_TYPE_1G) {
 			printk(PFX "%s: Programming mdc config for 1G\n", __func__);
@@ -1225,17 +1225,17 @@ int nes_init_phy(struct nes_device *nesd
 			nes_write_indexed(nesdev, NES_IDX_MAC_TX_CONFIG, tx_config);
 		}
 
-		nes_read_1G_phy_reg(nesdev, 1, nesadapter->phy_index[mac_index], &phy_data);
+		nes_read_1G_phy_reg(nesdev, 1, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 1 phy address %u = 0x%X.\n",
-				nesadapter->phy_index[mac_index], phy_data);
-		nes_write_1G_phy_reg(nesdev, 23, nesadapter->phy_index[mac_index],  0xb000);
+				nesadapter->phy_index[ mac_index ], phy_data);
+		nes_write_1G_phy_reg(nesdev, 23, nesadapter->phy_index[ mac_index ],  0xb000);
 
 		/* Reset the PHY */
-		nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[mac_index], 0x8000);
+		nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[ mac_index ], 0x8000);
 		udelay(100);
 		counter = 0;
 		do {
-			nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[mac_index], &phy_data);
+			nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[ mac_index ], &phy_data);
 			nes_debug(NES_DBG_PHY, "Phy data from register 0 = 0x%X.\n", phy_data);
 			if (counter++ > 100) break;
 		} while (phy_data & 0x8000);
@@ -1243,145 +1243,156 @@ int nes_init_phy(struct nes_device *nesd
 		/* Setting no phy loopback */
 		phy_data &= 0xbfff;
 		phy_data |= 0x1140;
-		nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[mac_index],  phy_data);
-		nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[mac_index], &phy_data);
+		nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[ mac_index ],  phy_data);
+		nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 0 = 0x%X.\n", phy_data);
 
-		nes_read_1G_phy_reg(nesdev, 0x17, nesadapter->phy_index[mac_index], &phy_data);
+		nes_read_1G_phy_reg(nesdev, 0x17, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 0x17 = 0x%X.\n", phy_data);
 
-		nes_read_1G_phy_reg(nesdev, 0x1e, nesadapter->phy_index[mac_index], &phy_data);
+		nes_read_1G_phy_reg(nesdev, 0x1e, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 0x1e = 0x%X.\n", phy_data);
 
 		/* Setting the interrupt mask */
-		nes_read_1G_phy_reg(nesdev, 0x19, nesadapter->phy_index[mac_index], &phy_data);
+		nes_read_1G_phy_reg(nesdev, 0x19, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 0x19 = 0x%X.\n", phy_data);
-		nes_write_1G_phy_reg(nesdev, 0x19, nesadapter->phy_index[mac_index], 0xffee);
+		nes_write_1G_phy_reg(nesdev, 0x19, nesadapter->phy_index[ mac_index ], 0xffee);
 
-		nes_read_1G_phy_reg(nesdev, 0x19, nesadapter->phy_index[mac_index], &phy_data);
+		nes_read_1G_phy_reg(nesdev, 0x19, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 0x19 = 0x%X.\n", phy_data);
 
 		/* turning on flow control */
-		nes_read_1G_phy_reg(nesdev, 4, nesadapter->phy_index[mac_index], &phy_data);
+		nes_read_1G_phy_reg(nesdev, 4, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 0x4 = 0x%X.\n", phy_data);
-		nes_write_1G_phy_reg(nesdev, 4, nesadapter->phy_index[mac_index],
+		nes_write_1G_phy_reg(nesdev, 4, nesadapter->phy_index[ mac_index ],
 				(phy_data & ~(0x03E0)) | 0xc00);
-		/* nes_write_1G_phy_reg(nesdev, 4, nesadapter->phy_index[mac_index],
-				phy_data | 0xc00); */
-		nes_read_1G_phy_reg(nesdev, 4, nesadapter->phy_index[mac_index], &phy_data);
+
+		/*
+		 * nes_write_1G_phy_reg(nesdev, 4, nesadapter->phy_index[ mac_index ],
+		 *			phy_data | 0xc00);
+		 */
+		nes_read_1G_phy_reg(nesdev, 4, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 0x4 = 0x%X.\n", phy_data);
 
-		nes_read_1G_phy_reg(nesdev, 9, nesadapter->phy_index[mac_index], &phy_data);
+		nes_read_1G_phy_reg(nesdev, 9, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 0x9 = 0x%X.\n", phy_data);
+
 		/* Clear Half duplex */
-		nes_write_1G_phy_reg(nesdev, 9, nesadapter->phy_index[mac_index],
+		nes_write_1G_phy_reg(nesdev, 9, nesadapter->phy_index[ mac_index ],
 				phy_data & ~(0x0100));
-		nes_read_1G_phy_reg(nesdev, 9, nesadapter->phy_index[mac_index], &phy_data);
+		nes_read_1G_phy_reg(nesdev, 9, nesadapter->phy_index[ mac_index ], &phy_data);
 		nes_debug(NES_DBG_PHY, "Phy data from register 0x9 = 0x%X.\n", phy_data);
 
-		nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[mac_index], &phy_data);
-		nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[mac_index], phy_data | 0x0300);
+		nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[ mac_index ], &phy_data);
+		nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[ mac_index ], phy_data | 0x0300);
 	} else {
-		if ((nesadapter->phy_type[mac_index] == NES_PHY_TYPE_IRIS) || (nesadapter->phy_type[mac_index] == NES_PHY_TYPE_ARGUS)) {
+		if ((nesadapter->phy_type[ mac_index ] == NES_PHY_TYPE_IRIS) ||
+		    (nesadapter->phy_type[ mac_index ] == NES_PHY_TYPE_ARGUS)) {
 			/* setup 10G MDIO operation */
 			tx_config = nes_read_indexed(nesdev, NES_IDX_MAC_TX_CONFIG);
 			tx_config |= 0x14;
 			nes_write_indexed(nesdev, NES_IDX_MAC_TX_CONFIG, tx_config);
 		}
-		if ((nesadapter->phy_type[mac_index] == NES_PHY_TYPE_ARGUS)) {
-			nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7ee);
+		if ((nesadapter->phy_type[ mac_index ] == NES_PHY_TYPE_ARGUS)) {
+			nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x3, 0xd7ee);
 
 			temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
 			mdelay(10);
-			nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7ee);
+			nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x3, 0xd7ee);
 			temp_phy_data2 = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
 
 			/* if firmware is already running (like from a driver un-load/load, don't do anything. */
 			if (temp_phy_data == temp_phy_data2) {
 				/* configure QT2505 AMCC PHY */
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0x0000, 0x8000);
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc300, 0x0000);
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc302, 0x0044);
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc318, 0x0052);
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc319, 0x0008);
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc31a, 0x0098);
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0x0026, 0x0E00);
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0x0027, 0x0000);
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0x0028, 0xA528);
-
-				//remove micro from reset; chip boots from ROM, uploads EEPROM f/w image, uC executes f/w
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc300, 0x0002);
-
-				//wait for heart beat to start to know loading is done
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0x0000, 0x8000);
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xc300, 0x0000);
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xc302, 0x0044);
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xc318, 0x0052);
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xc319, 0x0008);
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xc31a, 0x0098);
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x3, 0x0026, 0x0E00);
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x3, 0x0027, 0x0000);
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x3, 0x0028, 0xA528);
+
+				/*
+				 * remove micro from reset; chip boots from ROM,
+				 * uploads EEPROM f/w image, uC executes f/w
+				 */
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xc300, 0x0002);
+
+				/* wait for heart beat to start to know loading is done */
 				counter = 0;
 				do {
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7ee);
+					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x3, 0xd7ee);
 					temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
 					if (counter++ > 1000) {
 						nes_debug(NES_DBG_PHY, "AMCC PHY- breaking from heartbeat check <this is bad!!!> \n");
 						break;
 					}
 					mdelay(100);
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7ee);
+					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x3, 0xd7ee);
 					temp_phy_data2 = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
 				} while ( (temp_phy_data2 == temp_phy_data) );
 
-
-				//wait for tracking to start to know f/w is good to go.
+				/* wait for tracking to start to know f/w is good to go */
 				counter = 0;
 				do {
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7fd);
+					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x3, 0xd7fd);
 					temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
 					if (counter++ > 1000) {
 						nes_debug(NES_DBG_PHY, "AMCC PHY- breaking from status check <this is bad!!!> \n");
 						break;
 					}
 					mdelay(1000);
-//					nes_debug(NES_DBG_PHY, "AMCC PHY- phy_status not ready yet = 0x%02X\n", temp_phy_data);
-				} while ( ((temp_phy_data & 0xff) != 0x50) && ((temp_phy_data & 0xff) != 0x70) );
+					/* nes_debug(NES_DBG_PHY, "AMCC PHY- phy_status not ready yet = 0x%02X\n", temp_phy_data); */
+				} while (((temp_phy_data & 0xff) != 0x50) && ((temp_phy_data & 0xff) != 0x70));
+
+				/* set LOS Control invert RXLOSB_I_PADINV */
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xd003, 0x0000);
 
+				/* set LOS Control to mask of RXLOSB_I */
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xc314, 0x0042);
 
+				/* set LED1 to input mode (LED1 and LED2 share same LED) */
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xd006, 0x0007);
 
+				/* set LED2 to RX link_status and activity */
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xd007, 0x000A);
 
-				//set LOS Control invert RXLOSB_I_PADINV
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xd003, 0x0000);
-				//set LOS Control to mask of RXLOSB_I
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc314, 0x0042);
-				//set LED1 to input mode (LED1 and LED2 share same LED)
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xd006, 0x0007);
-				//set LED2 to RX link_status and activity
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xd007, 0x000A);
-				//set LED3 to RX link_status
-				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xd008, 0x0009);
+				/* set LED3 to RX link_status */
+				nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 0x1, 0xd008, 0x0009);
 
-				// reset the res-calibration on t2 serdes, ensures it is stable after the amcc phy is stable.
+				/*
+				 * reset the res-calibration on t2 serdes, ensures it is stable
+				 * after the amcc phy is stable.
+				 */
 
-				sds_common_control0 = nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_CONTROL0);
+				sds_common_control0  = nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_CONTROL0);
 				sds_common_control0 |= 0x1;
 				nes_write_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_CONTROL0, sds_common_control0);
 
-				//release the res-calibration reset.
+				/* release the res-calibration reset */
 				sds_common_control0 &= 0xfffffffe;
 				nes_write_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_CONTROL0, sds_common_control0);
 
-
-				i=0;
-				while (((nes_read32(nesdev->regs+NES_SOFTWARE_RESET) & 0x00000040) != 0x00000040) && (i++ < 5000)) {
+				i = 0;
+				while (((nes_read32(nesdev->regs + NES_SOFTWARE_RESET) & 0x00000040) != 0x00000040)
+						&& (i++ < 5000)) {
 					/* mdelay(1); */
 				}
 
-
-
-				// wait for link train done before moving on, or will get an interupt storm
+				/* wait for link train done before moving on, or will get an interupt storm */
 				counter = 0;
 				do {
-					temp_phy_data = nes_read_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 +(0x200*(nesdev->mac_index&1) ));
+					temp_phy_data = nes_read_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 +
+										(0x200 * (nesdev->mac_index & 1)));
 					if (counter++ > 1000) {
-						nes_debug(NES_DBG_PHY, "AMCC PHY- breaking from link train wait <this is bad, link didnt train!!!>\n");
+						nes_debug(NES_DBG_PHY,
+							"AMCC PHY- breaking from link train wait <this is bad, link didnt train!!!>\n");
 						break;
 					}
 					mdelay(1);
-				} while ( ((temp_phy_data & 0x0f1f0000) != 0x0f0f0000) );
+				} while (((temp_phy_data & 0x0f1f0000) != 0x0f0f0000));
 			}
 		}
 	}
@@ -2271,30 +2282,30 @@ static void nes_process_mac_intr(struct 
 		}
 		nes_debug(NES_DBG_PHY, "Eth SERDES Common Status: 0=0x%08X, 1=0x%08X\n",
 				nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS0),
-				nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS0+0x200));
+				nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS0 + 0x200));
 
-		if (nesadapter->phy_type[mac_index] == NES_PHY_TYPE_PUMA_1G) {
+		if (nesadapter->phy_type[ mac_index ] == NES_PHY_TYPE_PUMA_1G) {
 			switch (mac_index) {
-				case 1:
-				case 3:
-					pcs_control_status = nes_read_indexed(nesdev,
-							NES_IDX_PHY_PCS_CONTROL_STATUS0 + 0x200);
-					break;
-				default:
-					pcs_control_status = nes_read_indexed(nesdev,
-							NES_IDX_PHY_PCS_CONTROL_STATUS0);
-					break;
+			case 1:
+			case 3:
+				pcs_control_status = nes_read_indexed(nesdev,
+						NES_IDX_PHY_PCS_CONTROL_STATUS0 + 0x200);
+				break;
+			default:
+				pcs_control_status = nes_read_indexed(nesdev,
+						NES_IDX_PHY_PCS_CONTROL_STATUS0);
+				break;
 			}
 		} else {
 			pcs_control_status = nes_read_indexed(nesdev,
-					NES_IDX_PHY_PCS_CONTROL_STATUS0 + ((mac_index&1)*0x200));
+					NES_IDX_PHY_PCS_CONTROL_STATUS0 + ((mac_index & 1) * 0x200));
 			pcs_control_status = nes_read_indexed(nesdev,
-					NES_IDX_PHY_PCS_CONTROL_STATUS0 + ((mac_index&1)*0x200));
+					NES_IDX_PHY_PCS_CONTROL_STATUS0 + ((mac_index & 1) * 0x200));
 		}
 
 		nes_debug(NES_DBG_PHY, "PCS PHY Control/Status%u: 0x%08X\n",
 				mac_index, pcs_control_status);
-		if ((nesadapter->OneG_Mode) && (nesadapter->phy_type[mac_index] != NES_PHY_TYPE_PUMA_1G)) {
+		if ((nesadapter->OneG_Mode) && (nesadapter->phy_type[ mac_index ] != NES_PHY_TYPE_PUMA_1G)) {
 			u32temp = 0x01010000;
 			if (nesadapter->port_count > 2) {
 				u32temp |= 0x02020000;
@@ -2304,56 +2315,58 @@ static void nes_process_mac_intr(struct 
 				nes_debug(NES_DBG_PHY, "PCS says the link is down\n");
 			}
 		} else {
-			switch (nesadapter->phy_type[mac_index]) {
-				case NES_PHY_TYPE_IRIS:
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 1);
-					temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
-					u32temp = 20;
-					do {
-						nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 1);
-						phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
-						if ((phy_data == temp_phy_data) || (!(--u32temp)))
-							break;
-						temp_phy_data = phy_data;
-					} while (1);
-					nes_debug(NES_DBG_PHY, "%s: Phy data = 0x%04X, link was %s.\n",
-						__func__, phy_data, nesadapter->mac_link_down[mac_index] ? "DOWN" : "UP");
-					break;
-				case NES_PHY_TYPE_ARGUS:
-					//clear the alarms.
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0x0008);
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0xc001);
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0xc002);
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0xc005);
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0xc006);
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 0x9003);
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 0x9004);
-					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 0x9005);
-					//check link status
+			switch (nesadapter->phy_type[ mac_index ]) {
+			case NES_PHY_TYPE_IRIS:
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 1, 1);
+				temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
+				u32temp = 20;
+				do {
+					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 1, 1);
+					phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
+					if ((phy_data == temp_phy_data) || (!(--u32temp)))
+						break;
+					temp_phy_data = phy_data;
+				} while (1);
+				nes_debug(NES_DBG_PHY, "%s: Phy data = 0x%04X, link was %s.\n",
+					__func__, phy_data, nesadapter->mac_link_down[mac_index] ? "DOWN" : "UP");
+				break;
+
+			case NES_PHY_TYPE_ARGUS:
+				//clear the alarms.
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 4, 0x0008);
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 4, 0xc001);
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 4, 0xc002);
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 4, 0xc005);
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 4, 0xc006);
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 1, 0x9003);
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 1, 0x9004);
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 1, 0x9005);
+				//check link status
+				nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[ mac_index ], 1, 1);
+				temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
+				u32temp = 100;
+				do {
 					nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 1);
-					temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
-					u32temp = 100;
-					do {
-						nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 1);
 
-						phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
-						if ((phy_data == temp_phy_data) || (!(--u32temp)))
-							break;
-						temp_phy_data = phy_data;
-					} while (1);
-					nes_debug(NES_DBG_PHY, "%s: Phy data = 0x%04X, link was %s.\n",
-						__func__, phy_data, nesadapter->mac_link_down ? "DOWN" : "UP");
-					break;
-				case NES_PHY_TYPE_PUMA_1G:
-					if (mac_index < 2) {
-						pcs_val = pcs_mask = 0x01010000;
-					} else {
-						pcs_val = pcs_mask = 0x02020000;
-					}
-					/* fall through */
-				default:
-					phy_data = (pcs_val == (pcs_control_status & pcs_mask)) ? 0x4 : 0x0;
-					break;
+					phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
+					if ((phy_data == temp_phy_data) || (!(--u32temp)))
+						break;
+					temp_phy_data = phy_data;
+				} while (1);
+				nes_debug(NES_DBG_PHY, "%s: Phy data = 0x%04X, link was %s.\n",
+					__func__, phy_data, nesadapter->mac_link_down ? "DOWN" : "UP");
+				break;
+
+			case NES_PHY_TYPE_PUMA_1G:
+				if (mac_index < 2) {
+					pcs_val = pcs_mask = 0x01010000;
+				} else {
+					pcs_val = pcs_mask = 0x02020000;
+				}
+				/* fall through */
+			default:
+				phy_data = (pcs_val == (pcs_control_status & pcs_mask)) ? 0x4 : 0x0;
+				break;
 			}
 		}
 
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
index 5ba9dd3..939887a 100644
--- a/drivers/infiniband/hw/nes/nes_nic.c
+++ b/drivers/infiniband/hw/nes/nes_nic.c
@@ -1376,20 +1376,20 @@ static int nes_netdev_get_settings(struc
 	u16 phy_data;
 
 	et_cmd->duplex = DUPLEX_FULL;
-	et_cmd->port = PORT_MII;
+	et_cmd->port   = PORT_MII;
 
 	if (nesadapter->OneG_Mode) {
 		et_cmd->speed = SPEED_1000;
-		if (nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_PUMA_1G) {
-			et_cmd->supported = SUPPORTED_1000baseT_Full;
+		if (nesadapter->phy_type[ nesdev->mac_index ] == NES_PHY_TYPE_PUMA_1G) {
+			et_cmd->supported   = SUPPORTED_1000baseT_Full;
 			et_cmd->advertising = ADVERTISED_1000baseT_Full;
-			et_cmd->autoneg = AUTONEG_DISABLE;
+			et_cmd->autoneg     = AUTONEG_DISABLE;
 			et_cmd->transceiver = XCVR_INTERNAL;
 			et_cmd->phy_address = nesdev->mac_index;
 		} else {
-			et_cmd->supported = SUPPORTED_1000baseT_Full|SUPPORTED_Autoneg;
-			et_cmd->advertising = ADVERTISED_1000baseT_Full|ADVERTISED_Autoneg;
-			nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[nesdev->mac_index],
+			et_cmd->supported   = SUPPORTED_1000baseT_Full  | SUPPORTED_Autoneg;
+			et_cmd->advertising = ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg;
+			nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[ nesdev->mac_index ],
 					&phy_data);
 			if (phy_data&0x1000) {
 				et_cmd->autoneg = AUTONEG_ENABLE;
@@ -1400,20 +1400,20 @@ static int nes_netdev_get_settings(struc
 			et_cmd->phy_address = nesadapter->phy_index[nesdev->mac_index];
 		}
 	} else {
-		if ( (nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_IRIS) ||
-                      (nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_ARGUS) ) {
+		if ((nesadapter->phy_type[ nesdev->mac_index ] == NES_PHY_TYPE_IRIS) ||
+		    (nesadapter->phy_type[ nesdev->mac_index ] == NES_PHY_TYPE_ARGUS)) {
 			et_cmd->transceiver = XCVR_EXTERNAL;
-			et_cmd->port = PORT_FIBRE;
-			et_cmd->supported = SUPPORTED_FIBRE;
+			et_cmd->port        = PORT_FIBRE;
+			et_cmd->supported   = SUPPORTED_FIBRE;
 			et_cmd->advertising = ADVERTISED_FIBRE;
-			et_cmd->phy_address = nesadapter->phy_index[nesdev->mac_index];
+			et_cmd->phy_address = nesadapter->phy_index[ nesdev->mac_index ];
 		} else {
 			et_cmd->transceiver = XCVR_INTERNAL;
-			et_cmd->supported = SUPPORTED_10000baseT_Full;
+			et_cmd->supported   = SUPPORTED_10000baseT_Full;
 			et_cmd->advertising = ADVERTISED_10000baseT_Full;
 			et_cmd->phy_address = nesdev->mac_index;
 		}
-		et_cmd->speed = SPEED_10000;
+		et_cmd->speed   = SPEED_10000;
 		et_cmd->autoneg = AUTONEG_DISABLE;
 	}
 	et_cmd->maxtxpkt = 511;
@@ -1432,17 +1432,18 @@ static int nes_netdev_set_settings(struc
 	struct nes_adapter *nesadapter = nesdev->nesadapter;
 	u16 phy_data;
 
-	if ((nesadapter->OneG_Mode) && (nesadapter->phy_type[nesdev->mac_index] != NES_PHY_TYPE_PUMA_1G)) {
-		nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[nesdev->mac_index],
+	if ((nesadapter->OneG_Mode) &&
+	    (nesadapter->phy_type[ nesdev->mac_index ] != NES_PHY_TYPE_PUMA_1G)) {
+		nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[ nesdev->mac_index ],
 				&phy_data);
 		if (et_cmd->autoneg) {
 			/* Turn on Full duplex, Autoneg, and restart autonegotiation */
 			phy_data |= 0x1300;
 		} else {
-			// Turn off autoneg
+			/* Turn off autoneg */
 			phy_data &= ~0x1000;
 		}
-		nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[nesdev->mac_index],
+		nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[ nesdev->mac_index ],
 				phy_data);
 	}
 
@@ -1628,13 +1629,13 @@ struct net_device *nes_netdev_init(struc
 	    ((PCI_FUNC(nesdev->pcidev->devfn) == nesdev->mac_index) ||
 	     ((nesdev->nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_PUMA_1G) &&
 	      (((PCI_FUNC(nesdev->pcidev->devfn) == 1) && (nesdev->mac_index == 2)) ||
-	       ((PCI_FUNC(nesdev->pcidev->devfn) == 2) && (nesdev->mac_index == 1)) ) ) ) ) {
-/* PUMA HACK
-		nes_debug(NES_DBG_INIT, "Setting up PHY interrupt mask. Using register index 0x%04X\n",
-				NES_IDX_PHY_PCS_CONTROL_STATUS0+(0x200*(nesvnic->logical_port&1)));
-*/
+	       ((PCI_FUNC(nesdev->pcidev->devfn) == 2) && (nesdev->mac_index == 1)))))){
+		/*
+		 * nes_debug(NES_DBG_INIT, "Setting up PHY interrupt mask. Using register index 0x%04X\n",
+		 *		NES_IDX_PHY_PCS_CONTROL_STATUS0 + (0x200 * (nesvnic->logical_port & 1)));
+		 */
 		u32temp = nes_read_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 +
-				(0x200*(nesdev->mac_index&1)));
+				(0x200*(nesdev->mac_index & 1)));
 		if (nesdev->nesadapter->phy_type[nesdev->mac_index] != NES_PHY_TYPE_PUMA_1G) {
 			u32temp |= 0x00200000;
 			nes_write_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 +
@@ -1645,14 +1646,14 @@ struct net_device *nes_netdev_init(struc
 				(0x200*(nesdev->mac_index&1)) );
 
 		if ((u32temp&0x0f1f0000) == 0x0f0f0000) {
-			if (nesdev->nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_IRIS) {
+			if (nesdev->nesadapter->phy_type[ nesdev->mac_index ] == NES_PHY_TYPE_IRIS) {
 				nes_init_phy(nesdev);
-				nes_read_10G_phy_reg(nesdev, nesdev->nesadapter->phy_index[nesdev->mac_index], 1, 1);
+				nes_read_10G_phy_reg(nesdev, nesdev->nesadapter->phy_index[ nesdev->mac_index ], 1, 1);
 				temp_phy_data = (u16)nes_read_indexed(nesdev,
 									NES_IDX_MAC_MDIO_CONTROL);
 				u32temp = 20;
 				do {
-					nes_read_10G_phy_reg(nesdev, nesdev->nesadapter->phy_index[nesdev->mac_index], 1, 1);
+					nes_read_10G_phy_reg(nesdev, nesdev->nesadapter->phy_index[ nesdev->mac_index ], 1, 1);
 					phy_data = (u16)nes_read_indexed(nesdev,
 									NES_IDX_MAC_MDIO_CONTROL);
 					if ((phy_data == temp_phy_data) || (!(--u32temp)))
@@ -1669,11 +1670,11 @@ struct net_device *nes_netdev_init(struc
 				nes_debug(NES_DBG_INIT, "The Link is UP!!.\n");
 				nesvnic->linkup = 1;
 			}
-		} else if (nesdev->nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_PUMA_1G) {
+		} else if (nesdev->nesadapter->phy_type[ nesdev->mac_index ] == NES_PHY_TYPE_PUMA_1G) {
 			nes_debug(NES_DBG_INIT, "mac_index=%d, logical_port=%d, u32temp=0x%04X, PCI_FUNC=%d\n",
 				nesdev->mac_index, nesvnic->logical_port, u32temp, PCI_FUNC(nesdev->pcidev->devfn));
-			if (((nesdev->mac_index < 2) && ((u32temp&0x01010000) == 0x01010000) ) ||
-				((nesdev->mac_index > 1) && ((u32temp&0x02020000) == 0x02020000) ) )  {
+			if (((nesdev->mac_index < 2) && ((u32temp&0x01010000) == 0x01010000)) ||
+			    ((nesdev->mac_index > 1) && ((u32temp&0x02020000) == 0x02020000))) {
 				nes_debug(NES_DBG_INIT, "The Link is UP!!.\n");
 				nesvnic->linkup = 1;
 			}
@@ -1683,7 +1684,7 @@ struct net_device *nes_netdev_init(struc
 		nes_debug(NES_DBG_INIT, "Phy interrupt status = 0x%X.\n", u32temp);
 		nes_write_indexed(nesdev, NES_IDX_MAC_INT_STATUS + (0x200 * nesdev->mac_index), u32temp);
 
-		if (nesdev->nesadapter->phy_type[nesdev->mac_index] != NES_PHY_TYPE_IRIS)
+		if (nesdev->nesadapter->phy_type[ nesdev->mac_index ] != NES_PHY_TYPE_IRIS)
 			nes_init_phy(nesdev);
 
 	}



More information about the general mailing list