Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Sep 2008 11:41:11 +0300
From:      "Andrey Slusar" <anrays@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   FreeBSD7 and realtek 8111C
Message-ID:  <47e01da70809030141r2cd45f54n4407fd8fde0860d9@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hello!
I have the motherboard with realtek 8111C LAN Card.
On FreeBSD6.3 it's card is work fine with driver from realtek wesite -
rtl_bsd_drv_v175.tgz archive.
Build this driver on 7.0-STABLE is not work. I'm hacked this and
driver is compile without problems, but LAN card works is very
unstable - system hang,
when i'm downoad file ~10 seconds. Maybe there are people who can
bring to mind my hack? I'm attached driver and patch.

-- 
Regards,
Andrey.

[-- Attachment #2 --]
diff -u rtl_bsd_drv_v175/if_rl.c rtl_bsd_drv_v176/if_rl.c
--- rtl_bsd_drv_v175/if_rl.c	2008-03-03 04:10:12.000000000 +0000
+++ rtl_bsd_drv_v176/if_rl.c	2008-09-01 12:48:42.000000000 +0000
@@ -152,8 +152,8 @@
 };
 
 static int	rl_probe			__P((device_t));
-static int	rl_attach			__P((device_t));
-static int	rl_detach			__P((device_t));
+static int	rl_attach			(device_t);
+static int	rl_detach			(device_t);
 static void rl_shutdown			__P((device_t));
 
 static void MP_WritePhyUshort	__P((struct rl_softc*, u_int8_t, u_int16_t));
@@ -311,11 +311,9 @@
  * Attach the interface. Allocate softc structures, do ifmedia
  * setup and ethernet/BPF attach.
  */
-static int rl_attach(dev)
-	device_t		dev;
+static int rl_attach(device_t dev)
 {
-	/*int			s;*/
-	u_char			eaddr[ETHER_ADDR_LEN];
+	u_int8_t		eaddr[ETHER_ADDR_LEN];
 	u_int32_t		command;
 	struct rl_softc		*sc;
 	struct ifnet		*ifp;
@@ -398,7 +396,7 @@
 	sc->rl_bhandle = rman_get_bushandle(sc->rl_res);
 
 	rid = 0;
-	sc->rl_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
+	sc->rl_irq[0] = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
 	    RF_SHAREABLE | RF_ACTIVE);
 
 	if (sc->rl_irq == NULL) {
@@ -408,11 +406,11 @@
 		goto fail;
 	}
 
-	error = bus_setup_intr(dev, sc->rl_irq, INTR_TYPE_NET,
-	    rl_intr, sc, &sc->rl_intrhand);
+	error = bus_setup_intr(dev, sc->rl_irq[0], INTR_TYPE_NET | INTR_MPSAFE,
+	    NULL, rl_intr, sc, &sc->rl_intrhand[0]);
 
 	if (error) {
-		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq);
+		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq[0]);
 		bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res);
 		printf("rl%d: couldn't set up irq\n", unit);
 		goto fail;
@@ -520,8 +518,8 @@
 	} else {
 		printf("rl%d: unknown device ID: %x\n", unit, rl_did);
 		printf("rl%d: mac_vesion: %x\n", unit, mac_version);
-		bus_teardown_intr(dev, sc->rl_irq, sc->rl_intrhand);
-		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq);
+		bus_teardown_intr(dev, sc->rl_irq[0], sc->rl_intrhand[0]);
+		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq[0]);
 		bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res);
 		error = ENXIO;
 		goto fail;
@@ -661,8 +659,8 @@
 
 		if (sc->rl_cdata.rl_rx_buf == NULL) {
 			printf("rl%d: no memory for list buffers!\n", unit);
-			bus_teardown_intr(dev, sc->rl_irq, sc->rl_intrhand);
-			bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq);
+			bus_teardown_intr(dev, sc->rl_irq[0], sc->rl_intrhand[0]);
+			bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq[0]);
 			bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res);
 			error = ENXIO;
 			goto fail;
@@ -838,8 +836,8 @@
 
 	bus_generic_detach(dev);
 
-	bus_teardown_intr(dev, sc->rl_irq, sc->rl_intrhand);
-	bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq);
+	bus_teardown_intr(dev, sc->rl_irq[0], sc->rl_intrhand[0]);
+	bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq[0]);
 	bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res);
 	if(!sc->DESCRIPTOR_MODE)
 		contigfree(sc->rl_cdata.rl_rx_buf, RL_RXBUFLEN + 32, M_DEVBUF);
@@ -915,9 +913,9 @@
 #else
 	CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_WRITECFG);
 	CSR_WRITE_STREAM_4(sc, RL_IDR0,
-	    *(u_int32_t *)(&IFP2ENADDR(sc->rl_ifp)[0]));
+	    *(u_int32_t *)(&IF_LLADDR(sc->rl_ifp)[0]));
 	CSR_WRITE_STREAM_4(sc, RL_IDR4,
-	    *(u_int32_t *)(&IFP2ENADDR(sc->rl_ifp)[4]));
+	    *(u_int32_t *)(&IF_LLADDR(sc->rl_ifp)[4]));
 	CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
 #endif
 
diff -u rtl_bsd_drv_v175/if_rlreg.h rtl_bsd_drv_v176/if_rlreg.h
--- rtl_bsd_drv_v175/if_rlreg.h	2008-02-18 00:09:09.000000000 +0000
+++ rtl_bsd_drv_v176/if_rlreg.h	2008-09-01 12:31:24.000000000 +0000
@@ -508,6 +508,8 @@
 #define MACFG_28	0x28
 #define MACFG_29	0x29
 
+#define RL_MSI_MESSAGES 2
+
 struct rl_softc {
 #if OS_VER<VERSION(6,0)
 	struct arpcom		arpcom;			/* interface info */
@@ -521,8 +523,8 @@
 	bus_space_handle_t	rl_bhandle;		/* bus space handle */
 	bus_space_tag_t		rl_btag;			/* bus space tag */
 	struct resource		*rl_res;
-	struct resource		*rl_irq;
-	void			*rl_intrhand;
+	struct resource		*rl_irq[RL_MSI_MESSAGES];
+	void			*rl_intrhand[RL_MSI_MESSAGES];
 	struct ifmedia		media;			/* Yves: used to instead of MII */
 
 	u_int8_t		rl_unit;			/* interface number */

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47e01da70809030141r2cd45f54n4407fd8fde0860d9>