Re: [PATCH 10/14 v2] nes: eeprom and phy routines

2007-10-31 Thread Roland Dreier
  +/* TODO: deal with EEPROM endian issues */

This is pretty scary.  Is the driver broken on big-endian systems now?

  +/*
  +Everything you wanted to know about CRC algorithms, but were afraid to ask
  + for fear that errors in your understanding might be detected. Version  : 
  3.

etc etc... can all this be replaced with what's in lib/crc32.c?  (I
hope so)

 - R.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 10/14 v2] nes: eeprom and phy routines

2007-10-31 Thread Glenn Grundstrom
   +/*
   +Everything you wanted to know about CRC algorithms, but 
 were afraid to ask
   + for fear that errors in your understanding might be 
 detected. Version  : 3.
 
 etc etc... can all this be replaced with what's in lib/crc32.c?  (I
 hope so)

Replacing this code is already in the works.

Glenn.

 
  - R.
 
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/14 v2] nes: eeprom and phy routines

2007-10-19 Thread ggrundstrom
Misc eeprom, phy, and debug routines.

Signed-off-by: Glenn Grundstrom [EMAIL PROTECTED]
---

--- NULL1969-12-31 18:00:00.0 -0600
+++ ofa_kernel-1.3/drivers/infiniband/hw/nes/nes_utils.c2007-10-19 
09:43:32.0 -0500
@@ -0,0 +1,873 @@
+/*
+ * Copyright (c) 2006 - 2007 NetEffect, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/netdevice.h
+#include linux/etherdevice.h
+#include linux/ethtool.h
+#include linux/mii.h
+#include linux/if_vlan.h
+#include linux/crc32.h
+#include linux/in.h
+#include linux/ip.h
+#include linux/tcp.h
+#include linux/init.h
+
+#include asm/io.h
+#include asm/irq.h
+#include asm/byteorder.h
+
+#include nes.h
+
+#define BITMASK(X) (1L  (X))
+#define NES_CRC_WID 32
+
+static u16 nes_read16_eeprom(void __iomem *addr, u16 offset);
+
+static u32 nesCRCTable[256];
+static u32 nesCRCInitialized = 0;
+
+static u32 nesCRCWidMask(u32);
+static u32 nes_crc_table_gen(u32 *, u32, u32, u32);
+static u32 reflect(u32, u32);
+static u32 byte_swap(u32, u32);
+
+u32 mh_detected;
+u32 mh_pauses_sent;
+
+/**
+ * nes_read_eeprom_values -
+ */
+int nes_read_eeprom_values(struct nes_device *nesdev, struct nes_adapter 
*nesadapter)
+{
+   u32 mac_addr_low;
+   u16 mac_addr_high;
+   u16 eeprom_data;
+   u16 eeprom_offset;
+   u16 next_section_address;
+   u32 index;
+
+   /* TODO: deal with EEPROM endian issues */
+   if (nesadapter-firmware_eeprom_offset == 0) {
+   /* Read the EEPROM Parameters */
+   eeprom_data = nes_read16_eeprom(nesdev-regs, 0);
+   nes_debug(NES_DBG_HW, EEPROM Offset 0  = 0x%04X\n, 
eeprom_data);
+   eeprom_offset = 2 + (((eeprom_data  0x007f)  3) 
+   ((eeprom_data  0x0080)  7));
+   nes_debug(NES_DBG_HW, Firmware Offset = 0x%04X\n, 
eeprom_offset);
+   nesadapter-firmware_eeprom_offset = eeprom_offset;
+   eeprom_data = nes_read16_eeprom(nesdev-regs, eeprom_offset + 
4);
+   if (eeprom_data != 0x5746) {
+   nes_debug(NES_DBG_HW, Not a valid Firmware Image = 
0x%04X\n, eeprom_data);
+   return -1;
+   }
+
+   eeprom_data = nes_read16_eeprom(nesdev-regs, eeprom_offset + 
2);
+   nes_debug(NES_DBG_HW, EEPROM Offset %u  = 0x%04X\n,
+   eeprom_offset + 2, eeprom_data);
+   eeprom_offset += ((eeprom_data  0x00ff)  3)  ((eeprom_data 
 0x0100)  8);
+   nes_debug(NES_DBG_HW, Software Offset = 0x%04X\n, 
eeprom_offset);
+   nesadapter-software_eeprom_offset = eeprom_offset;
+   eeprom_data = nes_read16_eeprom(nesdev-regs, eeprom_offset + 
4);
+   if (eeprom_data != 0x5753) {
+   printk(Not a valid Software Image = 0x%04X\n, 
eeprom_data);
+   return -1;
+   }
+
+   eeprom_data = nes_read16_eeprom(nesdev-regs, eeprom_offset + 
2);
+   nes_debug(NES_DBG_HW, EEPROM Offset %u (next section)  = 
0x%04X\n,
+   eeprom_offset + 2, eeprom_data);
+   next_section_address = eeprom_offset + (((eeprom_data  0x00ff) 
 3) 
+   ((eeprom_data  0x0100)  8));
+   eeprom_data = nes_read16_eeprom(nesdev-regs, 
next_section_address + 4);
+   if (eeprom_data != 0x414d) {
+   nes_debug(NES_DBG_HW, EEPROM Changed offset should be 
0x414d but was 0x%04X\n,
+