Hi,
Jan Kiszka wrote:
Qeltaras wrote:
I use debian 2.2r3 with kernel linux 2.4.23 from kernel.org.
I've installed rtai-3.0r4 without error or warning, and the examples run.
I've installed rtnet-0.8, 2 cards 3COM 3C905c
For using the rtnet system:
Firsr I shutdown the traditional network device, and I load the rtai modules,
but when I load the rtnet with the command
"./rtnet/sbin/rtnet start" the ouput is:
3c59x For RTnet www.scyld.com/network/vortex.html 00:0b.0: 3Com PCI 3c905c Tornado at 0xd400. Vers LK1.1.1.16 3c59x: vortex_probe1 fails. Returns -22 00:0c.0: 3Com PCI 3c905c Tornado at 0xd800. Vers LK1.1.1.16 3c59x: vortex_probe1 fails. Returns -22 /usr/local/rtnet/modules/rt_3c59x.o: init_module: No such device can you help me?
-22 (EINVAL) or -12 (ENOMEM)? The latter is returned if the code above fails, i.e. when it is not able to allocate 8 * ~2kB of buffer memory in this case. If it is actually -22, something else must went wrong.
As I have a similar networkcard in my laptop (one using the 3c59x driver) and exactly the same errormessage,
I had a closer look at the problem.
The driver initially did not compile as it didn't seem to be in sync with recent RTnet changes. The attached patch
fixes this. (Being mainly "rtos_irq_t irq_handle" related stuff, and change of the definition of the
interrupthandler signatures, "pci_*state*" functions.)
I straced the issue down to the rt_register_rtnetdev call failing. A look in the implementation of this
function showed:
/* requires at least driver layer version 2.0 */ 338 if (rtdev->vers < RTDEV_VERS_2_0) 339 return -EINVAL;
As EINVAL is defined as 22, this seemed likely to be the issue.
The patch thus adds "rtdev->vers = RTDEV_VERS_2_0", similar to the other RTnet drivers.
At various places "retval = -ENOMEM;" occured without a preciding "if" check, which looks rather strange to
me. Are these assignments supposed to happen?
This patch enables me to compile the driver, load and configure it. As I didn't have a second PC around
to test it, the RTnet functionality is untested. I'm posting this patch as is - there's still some tracing
calls which should be removed. If you prefer to have it cleaned up a little, I'll do that.
With friendly regards, Takis
-- K.U.Leuven, Mechanical Eng., Mechatronics & Robotics Research Group http://people.mech.kuleuven.ac.be/~pissaris/
Index: drivers/experimental/3c59x/rt_3c59x.c
===================================================================
--- drivers/experimental/3c59x/rt_3c59x.c (revision 755)
+++ drivers/experimental/3c59x/rt_3c59x.c (working copy)
@@ -839,6 +839,7 @@
rtos_spinlock_t lock; /* Serialise access to device & its vortex_private */
spinlock_t mdio_lock; /* Serialise access to mdio hardware */
u32 power_state[16];
+ rtos_irq_t irq_handle;
};
/* The action to take with a media selection timer tick.
@@ -887,8 +888,8 @@
static int boomerang_start_xmit(struct rtskb *skb, struct rtnet_device *rtdev);
static int vortex_rx(struct rtnet_device *rtdev, int *packets, rtos_time_t *time_stamp);
static int boomerang_rx(struct rtnet_device *rtdev, int *packets, rtos_time_t *time_stamp);
-static void vortex_interrupt(unsigned int irq, void *rtdev_id);
-static void boomerang_interrupt(unsigned int irq, void *rtdev_id);
+static RTOS_IRQ_HANDLER_PROTO(vortex_interrupt);
+static RTOS_IRQ_HANDLER_PROTO(boomerang_interrupt);
static int vortex_close(struct rtnet_device *rtdev);
static void dump_tx_ring(struct rtnet_device *rtdev);
@@ -1047,7 +1048,8 @@
unsigned int eeprom[0x40], checksum = 0; /* EEPROM contents */
int i, step;
static int printed_version;
- int retval, print_info;
+ int retval = 0;
+ int print_info;
struct vortex_chip_info * const vci = &vortex_info_tbl[chip_idx];
char *print_name;
@@ -1062,7 +1064,7 @@
// *** RTnet ***
rtdev = rt_alloc_etherdev(sizeof(*vp));
- retval = -ENOMEM;
+//retval = -ENOMEM;
if (!rtdev) {
printk (KERN_ERR PFX "unable to allocate etherdev, aborting\n");
goto out;
@@ -1071,6 +1073,7 @@
memset(rtdev->priv, 0, sizeof(*vp));
rt_rtdev_connect(rtdev, &RTDEV_manager);
RTNET_SET_MODULE_OWNER(rtdev);
+ rtdev->vers = RTDEV_VERS_2_0;
// *** RTnet ***
vp = rtdev->priv;
@@ -1125,7 +1128,9 @@
if (pdev) {
/* EISA resources already marked, so only PCI needs to do this here */
/* Ignore return value, because Cardbus drivers already allocate for us */
- if (request_region(ioaddr, vci->io_size, print_name) != NULL)
+ if (!request_region(ioaddr, vci->io_size, print_name))
+ printk(KERN_INFO "rt_3c50x: request region failed\n");
+ else
vp->must_free_region = 1;
/* enable bus-mastering if necessary */
@@ -1158,7 +1163,7 @@
vp->rx_ring = pci_alloc_consistent(pdev, sizeof(struct boom_rx_desc) * RX_RING_SIZE
+ sizeof(struct boom_tx_desc) * TX_RING_SIZE,
&vp->rx_ring_dma);
- retval = -ENOMEM;
+ //retval = -ENOMEM;
if (vp->rx_ring == 0)
goto free_region;
@@ -1190,6 +1195,8 @@
vp->force_fd = vp->full_duplex;
vp->options = option;
+
+ printk("rt_3c50x: read the station address from the EEPROM\n");
/* Read the station address from the EEPROM. */
EL3WINDOW(0);
{
@@ -1224,6 +1231,8 @@
}
if ((checksum != 0x00) && !(vci->drv_flags & IS_TORNADO))
printk(" ***INVALID CHECKSUM %4.4x*** ", checksum);
+ else
+ printk("3c59x: checksum ok\n");
for (i = 0; i < 3; i++)
((u16 *)rtdev->dev_addr)[i] = htons(eeprom[i + 10]);
if (print_info) {
@@ -1281,9 +1290,11 @@
}
/* Extract our information from the EEPROM data. */
+ printk(KERN_INFO "3c59x: extract our information from the EEPROM data...");
vp->info1 = eeprom[13];
vp->info2 = eeprom[15];
vp->capabilities = eeprom[16];
+ printk("done\n");
if (vp->info1 & 0x8000) {
vp->full_duplex = 1;
@@ -1401,15 +1412,22 @@
}
if (rtskb_pool_init(&vp->skb_pool, RX_RING_SIZE*2) < RX_RING_SIZE*2) {
+ printk(KERN_ERR "rt_3c59x: pool init failed\n");
retval = -ENOMEM;
goto free_pool;
}
+ else
+ printk(KERN_INFO "rt_3c59x: pool init succeeded\n");
+
rtdev->stop = vortex_close;
- rtdev->hard_header = &rt_eth_header;
+// rtdev->hard_header = &rt_eth_header;
retval = rt_register_rtnetdev(rtdev);
if (retval)
+ {
+ printk(KERN_ERR "rt_3c59x: rtnet device registration failed %d\n",retval);
goto free_pool;
+ }
return 0;
// *** RTnet ***
@@ -1494,7 +1512,8 @@
if (vp->pdev && vp->enable_wol) {
pci_set_power_state(vp->pdev, 0); /* Go active */
- pci_restore_state(vp->pdev, vp->power_state);
+ //pci_restore_state(vp->pdev, vp->power_state);
+ pci_restore_state(vp->pdev);
}
/* Before initializing select the active media port. */
@@ -1892,13 +1911,13 @@
// *** RTnet ***
rt_stack_connect(rtdev, &STACK_manager);
- if ((retval = rtos_irq_request(rtdev->irq,
+ if ((retval = rtos_irq_request(&vp->irq_handle, rtdev->irq,
(vp->full_bus_master_rx ? boomerang_interrupt : vortex_interrupt),
rtdev))) {
printk(KERN_ERR "%s: Could not reserve IRQ %d\n", rtdev->name, rtdev->irq);
goto out;
}
- rtos_irq_enable(rtdev->irq);
+ rtos_irq_enable(&vp->irq_handle);
// *** RTnet ***
if (vp->full_bus_master_rx) { /* Boomerang bus master. */
@@ -1942,7 +1961,7 @@
out_free_irq:
// *** RTnet ***
- if ( (i=rtos_irq_free(rtdev->irq))<0 )
+ if ( (i=rtos_irq_free(&vp->irq_handle))<0 )
return i;
rt_stack_disconnect(rtdev);
// *** RTnet ***
@@ -2374,7 +2393,7 @@
// *** RTnet ***
rtos_res_lock(&rtdev->xmit_lock);
- rtos_irq_disable(rtdev->irq);
+ rtos_irq_disable(&vp->irq_handle);
rtos_spin_lock(&vp->lock);
// *** RTnet ***
@@ -2399,7 +2418,7 @@
}
outw(DownUnstall, ioaddr + EL3_CMD);
rtos_spin_unlock(&vp->lock);
- rtos_irq_enable(rtdev->irq);
+ rtos_irq_enable(&vp->irq_handle);
rtos_res_unlock(&rtdev->xmit_lock);
//rtdev->trans_start = jiffies;
return 0;
@@ -2413,10 +2432,10 @@
* full_bus_master_tx == 0 && full_bus_master_rx == 0
*/
-static void vortex_interrupt(unsigned int irq, void *rtdev_id)
+static RTOS_IRQ_HANDLER_PROTO(vortex_interrupt)
{
// *** RTnet ***
- struct rtnet_device *rtdev = (struct rtnet_device *)rtdev_id;
+ struct rtnet_device *rtdev = (struct rtnet_device *)RTOS_IRQ_GET_ARG();
int packets = 0;
rtos_time_t time_stamp;
// *** RTnet ***
@@ -2512,11 +2531,12 @@
rtos_print(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n",
rtdev->name, status);
handler_exit:
- rtos_irq_end(rtdev->irq);
+ rtos_irq_end(&vp->irq_handle);
rtos_spin_unlock(&vp->lock);
if (packets > 0)
rt_mark_stack_mgr(rtdev);
- return;
+
+ RTOS_IRQ_RETURN_HANDLED();
}
/*
@@ -2524,10 +2544,10 @@
* full_bus_master_tx == 1 && full_bus_master_rx == 1
*/
-static void boomerang_interrupt(unsigned int irq, void *rtdev_id)
+static RTOS_IRQ_HANDLER_PROTO(boomerang_interrupt)
{
// *** RTnet ***
- struct rtnet_device *rtdev = (struct rtnet_device *)rtdev_id;
+ struct rtnet_device *rtdev = (struct rtnet_device *)RTOS_IRQ_GET_ARG();
int packets = 0;
rtos_time_t time_stamp;
// *** RTnet ***
@@ -2652,11 +2672,12 @@
rtos_print(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n",
rtdev->name, status);
handler_exit:
- rtos_irq_end(rtdev->irq);
+ rtos_irq_end(&vp->irq_handle);
rtos_spin_unlock(&vp->lock);
if (packets > 0)
rt_mark_stack_mgr(rtdev);
- return;
+
+ RTOS_IRQ_RETURN_HANDLED();
}
static int vortex_rx(struct rtnet_device *rtdev, int *packets, rtos_time_t *time_stamp)
@@ -2893,7 +2914,7 @@
outl(0, ioaddr + DownListPtr);
if (vp->pdev && vp->enable_wol) {
- pci_save_state(vp->pdev, vp->power_state);
+ pci_save_state(vp->pdev);
acpi_set_WOL(rtdev);
}
}
@@ -2928,7 +2949,7 @@
#endif
// *** RTnet ***
- if ( (i=rtos_irq_free(rtdev->irq))<0 )
+ if ( (i=rtos_irq_free(&vp->irq_handle))<0 )
return i;
rt_stack_disconnect(rtdev);
@@ -3304,7 +3325,7 @@
if (vp->pdev && vp->enable_wol) {
pci_set_power_state(vp->pdev, 0); /* Go active */
if (vp->pm_state_valid)
- pci_restore_state(vp->pdev, vp->power_state);
+ pci_restore_state(vp->pdev);
}
pci_free_consistent(pdev,

