Thread: [Ndiswrapper-general] Some comments to my code and scather/gather dma
Status: Beta
Brought to you by:
pgiri
From: Stefan <ste...@gy...> - 2003-11-24 08:42:44
|
Hello, I want to send some comments to the code I submitted and some ideas about scather/gather DMA *I can't promise that the code I submitted(NdisInitializeEvent, KeInitializeEvent, NdisUnchainBufferAtBack and others) work perfectly. I had some problems with adapting the code form ReactOS, especially wheter some parameters/Variables should be pointers or not. The code compiles fine and I get no error from it. But it could be that the function just returns with the first possible expection and does not do the expected things. *I added a lot of definitions to the ndis.h file. Maybe some did exist before and I didn't find them. Maybe someone should check for redundance *Scather/Gather DMA: Implementing NdisMInitializeScatherGatherDMA will not be enough, the Miniport driver tries to localize the ethernet package in the memory. The card doesn't get the contents of the package but just the address in the memory and then reads out the contents directly from where it's placed without the need to copy it to the card's IO memory. The function to get the address of the package is not implemented(I suggest it, I have not looked for it) so the driver(or the card) reads from some random address(or 0x0). According to my experiance when experimenting with kernel modules the first time a access to 0x0 causes a terrible kernel panic. Maybe NdisMInitializeScatherGatherDMA is just some function to give the driver and the card permission to do this kind of access. Linux kernel modules have permission to do any hw access without asking for special permission, I don't know how this looks in the Windows world. I will have a look into the Linux Kernel Hacking Guide or similar documentations. Cheers, Stefan |
From: Pontus F. <pon...@ta...> - 2003-11-24 08:57:08
|
On Mon, 2003-11-24 at 10:42, Stefan D=C3=B6singer wrote: > Hello, > I want to send some comments to the code I submitted and some ideas about= =20 > scather/gather DMA >=20 > *I can't promise that the code I submitted(NdisInitializeEvent,=20 > KeInitializeEvent, NdisUnchainBufferAtBack and others) work perfectly. I = had=20 > some problems with adapting the code form ReactOS, especially wheter some= =20 > parameters/Variables should be pointers or not. The code compiles fine an= d I=20 > get no error from it. But it could be that the function just returns with= the=20 > first possible expection and does not do the expected things. About the event stuff: The events are probably never used in any codepath that we hit, so the important thing is that they return success. If you start seeing calls to the actual users of the events we're gonna have to do some hacking to actually implement the events but before this it's not worth the time. > *I added a lot of definitions to the ndis.h file. Maybe some did exist be= fore=20 > and I didn't find them. Maybe someone should check for redundance Ok. Just don't add stuff that we never use. > *Scather/Gather DMA: Implementing NdisMInitializeScatherGatherDMA will no= t be=20 > enough, the Miniport driver tries to localize the ethernet package in the= =20 > memory. The card doesn't get the contents of the package but just the add= ress=20 > in the memory and then reads out the contents directly from where it's pl= aced=20 > without the need to copy it to the card's IO memory. The function to get = the=20 > address of the package is not implemented(I suggest it, I have not looked= for=20 > it) so the driver(or the card) reads from some random address(or 0x0).=20 > According to my experiance when experimenting with kernel modules the fir= st=20 > time a access to 0x0 causes a terrible kernel panic. Maybe=20 > NdisMInitializeScatherGatherDMA is just some function to give the driver = and=20 > the card permission to do this kind of access. Linux kernel modules have=20 > permission to do any hw access without asking for special permission, I d= on't=20 > know how this looks in the Windows world. I will have a look into the Lin= ux=20 > Kernel Hacking Guide or similar documentations. I have not looked into this in detail yet so this may be wrong: NdisMInitializeScatherGatherDMA is a way for the driver to tell the upper layer that "I can handle fragmented buffers". In subsequent calls to sendpacket the driver then expects the upper layer to pass a scatterlist. the driver will then program the hardware with these buffers and the hardware will do the merging of data on the fly. The first thing you should try to do is to keep it as simple as possible. Learn about the scatterlist struct in windows (documented in NdisMInitializeScatherGatherDMA) and then try to pass such a structure to sendpacket and see what happens. There is probably not a need to learn very much about linux's ScatterGather DMA as the moment. I have a driver that uses ScatterGather DMA too so and I'm working on getting it running but I InitializeCards does not return success yet, neither is is crashing so I have some nasty debugging to do here. /Pontus |
From: Stefan <ste...@gy...> - 2003-11-24 12:43:05
|
Am Montag, 24. November 2003 09:57 schrieb Pontus Fuchs: > On Mon, 2003-11-24 at 10:42, Stefan D=C3=B6singer wrote: > > Hello, > > I want to send some comments to the code I submitted and some ideas abo= ut > > scather/gather DMA > > > > *I can't promise that the code I submitted(NdisInitializeEvent, > > KeInitializeEvent, NdisUnchainBufferAtBack and others) work perfectly. I > > had some problems with adapting the code form ReactOS, especially wheter > > some parameters/Variables should be pointers or not. The code compiles > > fine and I get no error from it. But it could be that the function just > > returns with the first possible expection and does not do the expected > > things. > > About the event stuff: > > The events are probably never used in any codepath that we hit, so the > important thing is that they return success. If you start seeing calls > to the actual users of the events we're gonna have to do some hacking to > actually implement the events but before this it's not worth the time. Looks like it. The Centrino driver calls NdisInitialize 5 times, the other= =20 event functions are still unimplementet and not called in the working=20 functions of the driver. > > > *I added a lot of definitions to the ndis.h file. Maybe some did exist > > before and I didn't find them. Maybe someone should check for redundance > > Ok. Just don't add stuff that we never use. Most things I added were related to the events. I copied only the definitio= ns=20 the compiler asked for. Maybe some variables in the structures are not used= =20 right now, I will look through the code and comment them out. > > > *Scather/Gather DMA: Implementing NdisMInitializeScatherGatherDMA will > > not be enough, the Miniport driver tries to localize the ethernet packa= ge > > in the memory. The card doesn't get the contents of the package but just > > the address in the memory and then reads out the contents directly from > > where it's placed without the need to copy it to the card's IO memory. > > The function to get the address of the package is not implemented(I > > suggest it, I have not looked for it) so the driver(or the card) reads > > from some random address(or 0x0). According to my experiance when > > experimenting with kernel modules the first time a access to 0x0 causes= a > > terrible kernel panic. Maybe > > NdisMInitializeScatherGatherDMA is just some function to give the driver > > and the card permission to do this kind of access. Linux kernel modules > > have permission to do any hw access without asking for special > > permission, I don't know how this looks in the Windows world. I will ha= ve > > a look into the Linux Kernel Hacking Guide or similar documentations. > > I have not looked into this in detail yet so this may be wrong: > > NdisMInitializeScatherGatherDMA is a way for the driver to tell the > upper layer that "I can handle fragmented buffers". In subsequent calls > to sendpacket the driver then expects the upper layer to pass a > scatterlist. the driver will then program the hardware with these > buffers and the hardware will do the merging of data on the fly. > > The first thing you should try to do is to keep it as simple as > possible. Learn about the scatterlist struct in windows (documented in > NdisMInitializeScatherGatherDMA) and then try to pass such a structure > to sendpacket and see what happens. There is probably not a need to > learn very much about linux's ScatterGather DMA as the moment. > > I have a driver that uses ScatterGather DMA too so and I'm working on > getting it running but I InitializeCards does not return success yet, > neither is is crashing so I have some nasty debugging to do here. Do you have any written code right now? I could try it with my centrino car= d.=20 My driver's initializion function is content with the NDIS_STATUS_SUCCESS=20 return from NdisMInitializeScatherGatherDMA. If your driver crashes for=20 another reason mine would _maybe_ work. I think the Linux Documentation could help (at least me) understanding the= =20 ScatterGather DMA because there are some code examples. > /Pontus Stefan |
From: Pontus F. <pon...@ta...> - 2003-11-24 12:49:45
|
> Do you have any written code right now? I could try it with my centrino card. > My driver's initializion function is content with the NDIS_STATUS_SUCCESS > return from NdisMInitializeScatherGatherDMA. If your driver crashes for > another reason mine would _maybe_ work. > I think the Linux Documentation could help (at least me) understanding the > ScatterGather DMA because there are some code examples. No written code. My driver does not use scatter/gather DMA. Typically NdisMInitializeScatherGatherDMA should just set a flag in the ndis_handle struct and then return success. Upon hard_xmit this flag should be read and action taken. Scatter/gather is hight hardware dependent, but linux has a framework of useful functions to pass Scatterlists around. /Pontus |
From: Stefan <ste...@gy...> - 2003-11-24 13:14:13
|
Am Montag, 24. November 2003 13:49 schrieb Pontus Fuchs: > > No written code. My driver does not use scatter/gather DMA. Typically > NdisMInitializeScatherGatherDMA should just set a flag in the > ndis_handle struct and then return success. Upon hard_xmit this flag > should be read and action taken. According to the documentation it should check if the necessary hardware resources are available and if the driver has registered as a Ndis driver with Verion >= 5.0. I don't think it's really important to check this because we can assume that every driver is written correctly(Otherwise it would fail under Windows). But if the flags exist in the stuctures why don't check? > > Scatter/gather is hight hardware dependent, but linux has a framework of > useful functions to pass Scatterlists around. It's possible, driverloader shows that. /Stefan |