Skip to contentSkip to conversation

nvidia nforce 1.0-261 nvnet for kernel 2.5

PATCH In review Andrew de Quincey 7 participants 23 messages Jul 26, 2003 – Jul 28, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvidia nforce 1.0-261 nvnet for kernel 2.5

Small patch for the latest nvidia nforce 1.0-261 nvnet drivers with kernel 2.5.

--- CUT HERE ---

nvnet/Makefile +14 -6
diff -Naurb nforce-1.0-0261-2.4/nvnet/Makefile nforce-1.0-0261-2.5/nvnet/Makefile
@@ -21,7 +21,7 @@
 #
 # Target
 #
-TARGET = $(MODULE_NAME).o
+TARGET = $(MODULE_NAME).ko
 
 #
 # Networking library
@@ -76,7 +76,8 @@
 CFLAGS = -c -Wall -DLINUX -DMODULE -DEXPORT_SYMTAB -D__KERNEL__ -O \
 	-Wstrict-prototypes -DCONFIG_PM  -fno-strict-aliasing \
         -mpreferred-stack-boundary=2 -march=i686 $(ALIGN) \
-        -DMODULE -I$(SYSINCLUDE) $(ARCHDEFS)
+        -DMODULE -I$(SYSINCLUDE) $(ARCHDEFS) \
+        -I$(KERNSRC)/include/asm/mach-default -DKBUILD_MODNAME=nvnet
 
 #
 # Kernel version
@@ -103,10 +104,17 @@
 
 all: $(TARGET) 
 
-$(TARGET): $(SRC) $(NVNETLIB) $(MCPINCLUDE)
+nvnet.o: $(SRC)
 	$(CC) $(CFLAGS) $(SRC)
-	ld -r -o $(TEMP) $(OBJ) $(NVNETLIB)
-	$(OBJCOPY) --strip-symbol="gcc2_compiled." $(TEMP)
+
+nvnet.mod.c: nvnet.o
+	$(KERNSRC)/scripts/modpost nvnet.o
+
+nvnet.mod.o: nvnet.mod.c
+	$(CC) $(CFLAGS) nvnet.mod.c
+
+$(TARGET): nvnet.o nvnet.mod.o $(NVNETLIB)
+	ld -r -o $(TEMP) nvnet.o nvnet.mod.o $(NVNETLIB)
 	cp $(TEMP) $(TARGET)
 	rm $(TEMP)
 
@@ -139,4 +147,4 @@
 # Delete generated files
 #
 clean:
-	rm -f $(TARGET)
+	rm -f $(TARGET) nvnet.o *.mod.c *.mod.o
nvnet/nvnet.c +8 -3
diff -Naurb nforce-1.0-0261-2.4/nvnet/nvnet.c nforce-1.0-0261-2.5/nvnet/nvnet.c
@@ -26,6 +26,10 @@
 char *common_hdO_version_string = HDO_VERSION_STRING;
 char *common_hdP_version_string = HDP_VERSION_STRING;
 
+// fix for common symbol exported by nvnetlib.o
+char* aPhyAddrAndId[256] = {};
+
+
 /*
  * Driver information
  */ 
@@ -753,7 +757,7 @@
 }
 
 
-static void nvnet_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t nvnet_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
     struct net_device *dev;
     struct nvnet_private *priv;
@@ -765,7 +769,7 @@
                  irq, dev_instance, regs);
 
     if(!dev)
-        return;
+        return IRQ_NONE;
 
     if(priv->hwapi->pfnQueryInterrupt(priv->hwapi->pADCX)) 
     {   
@@ -776,6 +780,7 @@
 
     PRINTK(DEBUG_INTR, "nvnet_interrupt -  Out\n");
 
+    return IRQ_HANDLED;
 }
 
 static int nvnet_close(struct net_device *dev)
@@ -1245,7 +1250,7 @@
  */
 static void __devexit nvnet_remove(struct pci_dev *pdev)
 {
-    struct net_device *dev = pdev->driver_data;
+    struct net_device *dev = pci_get_drvdata(pdev);
     struct nvnet_private *priv = dev->priv;
     int i;
 
nvnet/nvnet.h +1 -2
diff -Naurb nforce-1.0-0261-2.4/nvnet/nvnet.h nforce-1.0-0261-2.5/nvnet/nvnet.h
@@ -42,7 +42,6 @@
 #include <asm/io.h>
 #include <asm/bitops.h>
 #include <asm/uaccess.h>
-#include <asm/irq.h>            /* For NR_IRQS only. */
 #include <linux/spinlock.h>
 #include <linux/proc_fs.h>
 
@@ -104,7 +103,7 @@
 static struct net_device_stats *nvnet_stats(struct net_device *dev);
 static int nvnet_config(struct net_device *dev, struct ifmap *map);
 static int nvnet_init(struct net_device *dev);
-static void nvnet_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t nvnet_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 static void nvnet_multicast(struct net_device *dev);
 
 typedef enum {fail, pass} result; /* Boolean pass/fail results */

--- CUT HERE ---

#1 lore raw
Quoted 1 line · Andrew de Quincey

Small patch for the latest nvidia nforce 1.0-261 nvnet drivers with kernel 2.5.

<snip>

I sent a similar patch based on your older one to the Gentoo maintainers a couple of days ago. Did you notice how the module reference counting (MOD_INC/MOD_DEC) seems to have moved out of their wrapper into the binary module (possible GPL violation) or removed completely (oops waiting to happen)? I wonder why.

To be safe, I added the refcounting back where it was in previous versions. Anyway, thanks for making these patches.

-Rahul

#2 lore raw
In reply to Andrew de Quincey
Quoted 1 line · Andrew de Quincey

Small patch for the latest nvidia nforce 1.0-261 nvnet drivers with kernel 2.5.

Further nvnet musings (cc:ing Jeff as net driver maintainer and knowledgeable person).

As I reported here a few days earlier, I tried using the AMD8111 driver with my NForce2 ethernet a few days ago, with the result that no MAC address was being assigned to the card. I suspect that the MAC address is being assigned by the Nvidia driver. Does that make sense?

If so, then using the option in the BIOS to manually set the MAC address might make the AMD driver work. Unfortunately, I have no idea what I should set it to without stomping on the MAC address for other devices.

Any ideas? I hate to rely on a binary only module for something as "simple" as a 10/100 ethernet card.

Thanks,
Rahul

#3 lore raw

Hi,

Quoted 1 line

From nvnet.c:

/*
* Mac address is loaded at boot time into h/w reg, but it's loaded
backwards
* we get the address, save it, and reverse it. The saved value is loaded
* back into address at close time.
*/

PRINTK(DEBUG_INIT, "nvnet_init - get mac address\n");
    priv->hwapi->pfnGetNodeAddress(priv->hwapi->pADCX, priv-
Quoted 1 line

original_mac_addr);

But I don't think the only thing missing is the MAC address. You could try to manually set it in the source itself and see if anything works.

Marcelo Penna Guerra

Quoted 27 lines · Rahul Karnik
Quoted 2 lines · Andrew de Quincey

Small patch for the latest nvidia nforce 1.0-261 nvnet drivers with kernel 2.5.

Further nvnet musings (cc:ing Jeff as net driver maintainer and knowledgeable person).

As I reported here a few days earlier, I tried using the AMD8111 driver with my NForce2 ethernet a few days ago, with the result that no MAC address was being assigned to the card. I suspect that the MAC address is being assigned by the Nvidia driver. Does that make sense?

If so, then using the option in the BIOS to manually set the MAC address might make the AMD driver work. Unfortunately, I have no idea what I should set it to without stomping on the MAC address for other devices.

Any ideas? I hate to rely on a binary only module for something as "simple" as a 10/100 ethernet card.

Thanks,
Rahul

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw
Quoted 11 lines · Marcelo Penna Guerra

Hi,

Quoted 1 line

From nvnet.c:

/*
* Mac address is loaded at boot time into h/w reg, but it's loaded
backwards
* we get the address, save it, and reverse it. The saved value is loaded
* back into address at close time.
*/

Quoted 4 lines
PRINTK(DEBUG_INIT, "nvnet_init - get mac address\n");
    priv->hwapi->pfnGetNodeAddress(priv->hwapi->pADCX, priv-
Quoted 1 line

original_mac_addr);

Well, I wanted to reload the module with debug on, so I tried:

# modprobe -r nvnet
Segmentation fault

#lsmod

At this point lsmod just hung.

Tried shutting down the computer, and it was stuck during shutdown. Seems like the refcounting is not really working, or perhaps there are too many cycles happening. What happens if you do the following with a module:

try_module_get
MOD_INC_USE_COUNT
MOD_DEC_USE_COUNT
module_put

Quoted 1 line

But I don't think the only thing missing is the MAC address. You could try to manually set it in the source itself and see if anything works.

I'll just add it in BIOS and try with AMD8111. No desire to futz around with the nvnet source, where half of what is going on is a complete black box (priv->hwapi, "priv" is definitely *private*).

Thanks,
Rahul

#6 lore raw
Quoted 6 lines · Laurens

Did you guys try out the patch for nvnet which can be found here:

http://www.nforcershq.com/forum/viewtopic.php?t=24127&sid=c91eb257d6f67e0346a33b9664cea22f

This one worked flawless for me, dhcpcd (which is MAC dependend here) worked fine aswell.

Just to clarify, the issue is not with the binary Nvidia module, which works fine when patched. We would just rather not use the binary module, when all other parts of the Nforce2 chipset (all that I use, anyway) are supported by mainline kernels.

Thanks,
Rahul

#7 lore raw
In reply to Rahul Karnik
Quoted 51 lines · Rahul Karnik
Quoted 9 lines · Marcelo Penna Guerra

Hi,

Quoted 1 line

From nvnet.c:

/*
* Mac address is loaded at boot time into h/w reg, but it's loaded
backwards
* we get the address, save it, and reverse it. The saved value is
loaded * back into address at close time.

Quoted 6 lines
     */
PRINTK(DEBUG_INIT, "nvnet_init - get mac address\n");
    priv->hwapi->pfnGetNodeAddress(priv->hwapi->pADCX, priv-
Quoted 1 line

original_mac_addr);

Well, I wanted to reload the module with debug on, so I tried:

# modprobe -r nvnet
Segmentation fault

#lsmod

At this point lsmod just hung.

Tried shutting down the computer, and it was stuck during shutdown. Seems like the refcounting is not really working, or perhaps there are too many cycles happening. What happens if you do the following with a module:

try_module_get
MOD_INC_USE_COUNT
MOD_DEC_USE_COUNT
module_put

Quoted 2 lines

But I don't think the only thing missing is the MAC address. You could try to manually set it in the source itself and see if anything works.

I'll just add it in BIOS and try with AMD8111. No desire to futz around with the nvnet source, where half of what is going on is a complete black box (priv->hwapi, "priv" is definitely *private*).

Thanks,
Rahul

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#8 lore raw
In reply to Rahul Karnik
Quoted 10 lines

Tried shutting down the computer, and it was stuck during shutdown. Seems like the refcounting is not really working, or perhaps there are too many cycles happening. What happens if you do the following with a module:

try_module_get
MOD_INC_USE_COUNT
MOD_DEC_USE_COUNT
module_put

Thanks for pointing this out, they seem to have removed the module reference counting. But really, I don't care whether it can unload or not. I just need it to work. I'm not really interested in perfecting a quick hack to a proprietary driver.

Quoted 6 lines
Quoted 2 lines

But I don't think the only thing missing is the MAC address. You could try to manually set it in the source itself and see if anything works.

I'll just add it in BIOS and try with AMD8111. No desire to futz around with the nvnet source, where half of what is going on is a complete black box (priv->hwapi, "priv" is definitely *private*).

Ah, so THATS who they licensed it from. I didn't think nividia would go to the bother of designing their own ethernet hardware. I'll have a poke about and see if I can find anything out about the MAC address

#9 lore raw
Quoted 1 line · Andrew de Quincey

Ah, so THATS who they licensed it from. I didn't think nividia would go to the bother of designing their own ethernet hardware.

Actually, this is not certain, but it is one of the guesses. So far, Nforce2 = AMD IDE + Intel sound + <unknown> ethernet.

-Rahul

#10 lore raw
Quoted 6 lines · Rahul Karnik
Quoted 2 lines · Andrew de Quincey

Ah, so THATS who they licensed it from. I didn't think nividia would go to the bother of designing their own ethernet hardware.

Actually, this is not certain, but it is one of the guesses. So far, Nforce2 = AMD IDE + Intel sound + <unknown> ethernet.

It certainly loads "better" than the VIA drivers; I'd already tried hacking the PCI IDs into them.

#11 lore raw
In reply to Rahul Karnik
Quoted 6 lines · Rahul Karnik
Quoted 2 lines · Andrew de Quincey

Ah, so THATS who they licensed it from. I didn't think nividia would go to the bother of designing their own ethernet hardware.

Actually, this is not certain, but it is one of the guesses. So far, Nforce2 = AMD IDE + Intel sound + <unknown> ethernet.

Hmm, the MAC address is in a different place on the nvidia hardware.

I've just dumped the mmapped IO space on mine. The MAC address shows up at offset 0xa8, but the amd8111e driver is looking for it at 0x160 (there's just loads of 0x00 there).

#12 lore raw
Quoted 1 line · Andrew de Quincey

I've just dumped the mmapped IO space on mine. The MAC address shows up at offset 0xa8, but the amd8111e driver is looking for it at 0x160 (there's just loads of 0x00 there).

Also, as Marcelo -- no, not that one, the other one :) -- there is some funky reversing of the MAC address needed. See the reverse loop in nvnet.c where the MAC address is being read from the registers.

Thanks,
Rahul

Signature · 2 lines
Rahul Karnik
[email protected]
#13 lore raw
In reply to Andrew de Quincey
Quoted 1 line · Andrew de Quincey

I've just dumped the mmapped IO space on mine. The MAC address shows up at offset 0xa8, but the amd8111e driver is looking for it at 0x160 (there's just loads of 0x00 there).

Hmmmm, with this info I am able to get amd8111e to read the correct MAC address, but the network connection does not seem to work anyway. How would we know if this is the right driver anyway?

-Rahul

Signature · 2 lines
Rahul Karnik
[email protected]
#14 lore raw
Quoted 8 lines · Rahul Karnik
Quoted 3 lines · Andrew de Quincey

I've just dumped the mmapped IO space on mine. The MAC address shows up at offset 0xa8, but the amd8111e driver is looking for it at 0x160 (there's just loads of 0x00 there).

Hmmmm, with this info I am able to get amd8111e to read the correct MAC address, but the network connection does not seem to work anyway. How would we know if this is the right driver anyway?

Hmm, I have a suspicion it is not unfortunately, given the change in location of the MAC address. Or maybe nvidia have displaced the configuration registers by some amount?

#15 lore raw
Quoted 1 line · Andrew de Quincey

Hmm, I have a suspicion it is not unfortunately, given the change in location of the MAC address. Or maybe nvidia have displaced the configuration registers by some amount?

Dunno. Look in the list archives for earlier discussions on the topic. It seems AMD audio is a clone of Intel audio, which is why Intel audio works for NForce. Since both audio and ethernet match, it seems unlikely that Nvidia would license a completely different ethernet chip, but who knows?

Anyway, I want to put as much info out there as possible for someone to use as they wish. So here's another tip:

00:04.0 Ethernet controller: nVidia Corporation nForce2 Ethernet Controller (rev a1) 00: de 10 66 00 07 00 b0 00 a1 00 00 02 00 00 00 00
10: 00 00 00 e0 01 c4 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 62 14 0c 57
30: 00 00 00 00 44 00 00 00 00 00 00 00 0b 01 01 14
40: 62 14 0c 57 01 00 02 fe 00 01 00 00 04 00 00 00
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Note the first row reads:
00: de 10 66 00 07 00 b0 00 a1 00 00 02 00 00 00 00

Before nvnet loads, the same row reads:
00: de 10 66 00 03 00 b0 00 a1 00 00 02 00 00 00 00

Don't know if that is significant.

-Rahul

Signature · 2 lines
Rahul Karnik
[email protected]
#16 lore raw
Quoted 5 lines · Rahul Karnik

Dunno. Look in the list archives for earlier discussions on the topic. It seems AMD audio is a clone of Intel audio, which is why Intel audio works for NForce. Since both audio and ethernet match, it seems unlikely that Nvidia would license a completely different ethernet chip, but who knows?

AMD's older network component is the AMD PCnet32, which is a very different chip.

#17 lore raw
Quoted 3 lines · Alan Cox
Quoted 1 line · Rahul Karnik

Dunno. Look in the list archives for earlier discussions on the topic. It seems AMD audio is a clone of Intel audio, which is why Intel audio works for NForce. Since both audio and ethernet match, it seems unlikely

s/ethernet/IDE, oops.

Quoted 5 lines
Quoted 1 line

that Nvidia would license a completely different ethernet chip, but who knows?

AMD's older network component is the AMD PCnet32, which is a very different chip.

Yes we tried that as well, with no success. See:

http://marc.theaimsgroup.com/?l=linux-kernel&m=105831948827945&w=2

As far as I can tell, NForce is based on AMD8111, at least for IDE and sound. Unfortunately, ethernet is a no-go so far with amd8111e.

Thanks,
Rahul

Signature · 2 lines
Rahul Karnik
[email protected]
#18 lore raw

I read somewhere that this NIC is supposed to be based on the realtek fast ethernet NIC (rtl8139), could that be worth looking into?

I did modprobe that driver when I first tested 2.6, it loaded without errors but nothing happened.

Laurens

#19 lore raw
In reply to Andrew de Quincey

One can set the MAC address manually via ifconfig.

So, try modprobing amd8111e with the nforce pci ids, then manually setting the MAC address, and see if that works.

(just make sure the MAC address you make up is unique)

Jeff

#20 lore raw

No luck here, Jeff ... if the hardware is really based on AMD8111 as it appears to be (i2c and ide are similar), they surelly changed more registers. It'll take some time to RE it.

And I don't know how important is this information, but it doesn't get the iobase addr either and it can't be manually set in ifconfig.

Marcelo Penna Guerra

Quoted 8 lines · Jeff Garzik

One can set the MAC address manually via ifconfig.

So, try modprobing amd8111e with the nforce pci ids, then manually setting the MAC address, and see if that works.

(just make sure the MAC address you make up is unique)

Jeff

#21 lore raw
Quoted 3 lines · Marcelo Penna Guerra

No luck here, Jeff ... if the hardware is really based on AMD8111 as it appears to be (i2c and ide are similar), they surelly changed more registers. It'll take some time to RE it.

Hmm, If they had licensed it, I don't see why they would have changed the registers that much; they didn't for the other hardware they licensed. Judging by the size of nvnetlib.o, there isn't really that much to it (which is nice from an RE point of view)

#22 lore raw
In reply to Rahul Karnik
Quoted 7 lines · Rahul Karnik
Quoted 2 lines · Andrew de Quincey

Small patch for the latest nvidia nforce 1.0-261 nvnet drivers with kernel 2.5.

Further nvnet musings (cc:ing Jeff as net driver maintainer and knowledgeable person).

Quoted 8 lines

As I reported here a few days earlier, I tried using the AMD8111 driver with my NForce2 ethernet a few days ago, with the result that no MAC address was being assigned to the card. I suspect that the MAC address is being assigned by the Nvidia driver. Does that make sense?

If so, then using the option in the BIOS to manually set the MAC address might make the AMD driver work. Unfortunately, I have no idea what I should set it to without stomping on the MAC address for other devices.

my mac address is printed on a little sticker on top of the parallel port (inside the case) on a leadtek NCR18Gpro(?)

--Brian Jackson

Quoted 6 lines

Any ideas? I hate to rely on a binary only module for something as "simple" as a 10/100 ethernet card.

Thanks,
Rahul

Signature · 2 lines
OpenGFS -- http://opengfs.sourceforge.net
Home -- http://www.brianandsara.net