Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Concept of packet in NDIS5.0

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Hi, all

I'm writing a Connection-Oriented NDIS Miniport drvier for an ATM card.
In the miniport driver I must realize the SAR function. And I want to do it
by this (take transfer as an example):

I do the transfer work in MiniportCoSendPackets function. The NDIS call
this functionby giving me a PacketArray. I think every packet in the PacketArray
shoud be thinked as a CPCS-PDU payload (in ATM AAL5). So in order to add a
trailer to every CPCS-PDU, I want to use the NdisCopyFromPacketToPacket() function
with the destination packet's length plusing sizeof the trailer.

But before calling the NdisCopyFromPacketToPacket function, I should first allocate
a destination packet by first allocating packet pool then allocating packet.But
nither of them is relating to buffer operation, they are just descriptors.

So,I want to ask two questions:
1. Whether my method to add trailer for a CPCS-PDU by using
NdisCopyFromPacketToPacket is right?

2.Whether I should call the NdisChainBufferAtBack() function to chain the packet with
buffers?

Thank you for your help.

xhcai
Institute of Modern Communications , SJTU
Shanghai



____________________________
Free Email/SMTP/POP, http://www.bn3.com, Hosting [email protected]

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    I wouldn't copy the packet to add the AAL5 trailer. The only reason to
    maintain a packet is if you are going to give the packet to another
    NDIS aware module. Usually a MiniportCoSendPackets routine is talking
    to a piece of hardware, not another NDIS driver.

    The simplest thing for you to do is copy the contents of the packet
    into a buffer with enough room at the end for an AAL5 trailer,
    calculate the CRC, then start chopping the buffer into 48 byte
    payloads for DMA to the card. Once you get that working, you can
    eliminate the copy and do the calculations directly from the NDIS
    packet. The tough part here is figuring out where the cell payloads
    span NDIS buffers and dealing with that correctly.

    Clark


    > -----Original Message-----
    > From: [email protected]
    > [mailto:[email protected]]On Behalf Of encarta
    > Sent: Monday, April 10, 2000 3:28 AM
    > To: NT Developers Interest List
    > Subject: [ntdev] Concept of packet in NDIS5.0
    >
    >
    > Hi, all
    >
    > I'm writing a Connection-Oriented NDIS Miniport drvier for an
    > ATM card.
    > In the miniport driver I must realize the SAR function. And I
    > want to do it
    > by this (take transfer as an example):
    >
    > I do the transfer work in MiniportCoSendPackets function. The
    > NDIS call
    > this functionby giving me a PacketArray. I think every packet in
    > the PacketArray
    > shoud be thinked as a CPCS-PDU payload (in ATM AAL5). So in order
    > to add a
    > trailer to every CPCS-PDU, I want to use the
    > NdisCopyFromPacketToPacket() function
    > with the destination packet's length plusing sizeof the trailer.
    >
    > But before calling the NdisCopyFromPacketToPacket function, I
    > should first allocate
    > a destination packet by first allocating packet pool then
    > allocating packet.But
    > nither of them is relating to buffer operation, they are just
    descriptors.
    >
    > So,I want to ask two questions:
    > 1. Whether my method to add trailer for a CPCS-PDU by using
    > NdisCopyFromPacketToPacket is right?
    >
    > 2.Whether I should call the NdisChainBufferAtBack() function to
    > chain the packet with
    > buffers?
    >
    > Thank you for your help.
    >
    > xhcai
    > Institute of Modern Communications , SJTU
    > Shanghai
    >
    >
    >
    > ____________________________
    > Free Email/SMTP/POP, http://www.bn3.com, Hosting
    [email protected]
    >
    > ---
    > You are currently subscribed to ntdev as: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    -----BEGIN PGP SIGNATURE-----
    Version: PGP 6.0.2

    iQA/AwUBOPM+yuB0WaKgfXz5EQIKbgCg4kOk3Trb7AloM5vGQowG+vIz6/cAnAgD
    EO1m9V/d2PGLlGnubNyW9u9l
    =nE2U
    -----END PGP SIGNATURE-----
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Hi,Williams

    I've understood your meaning.

    Yes, I shouldn't use the packet again in the hardware related routine.
    So, what I do is first to query the packet information using NdisQueryPacket and
    then use the NdisMoveMemory to copy the buffer in the packet to my temperory buffers
    or DMA buffers.

    Is it right?


    >-----BEGIN PGP SIGNED MESSAGE-----
    >Hash: SHA1
    >
    >I wouldn't copy the packet to add the AAL5 trailer. The only reason to
    >maintain a packet is if you are going to give the packet to another
    >NDIS aware module. Usually a MiniportCoSendPackets routine is talking
    >to a piece of hardware, not another NDIS driver.
    >
    >The simplest thing for you to do is copy the contents of the packet
    >into a buffer with enough room at the end for an AAL5 trailer,
    >calculate the CRC, then start chopping the buffer into 48 byte
    >payloads for DMA to the card. Once you get that working, you can
    >eliminate the copy and do the calculations directly from the NDIS
    >packet. The tough part here is figuring out where the cell payloads
    >span NDIS buffers and dealing with that correctly.
    >
    >Clark

    Best Regards!

    Xiaohua Cai
    Institute of Modern Communications , SJTU
    Shanghai


    ____________________________
    Free Email/SMTP/POP, http://www.bn3.com, Hosting [email protected]
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    That is one way to do it.

    You may find after implementing your segment/transmit routine that
    copying from the packet hurts your performance. If your hardware is a
    bus-master DMA device and can handle multiple DMA's per cell, you may
    want to try and DMA directly from the packet buffers. You could use a
    buffer external to the packet to contain the AAL5 trailer. Each cell
    would be at least two DMA descriptors (one for the cell header and one
    for the cell payload). If a cell payload spans a buffer, you will have
    to use more than one DMA descriptor for the payload.

    But, if your performance is acceptable with the copy, then copying the
    packet data to a temporary buffer will be much simpler.

    Clark


    > -----Original Message-----
    > From: [email protected]
    > [mailto:[email protected]]On Behalf Of encarta
    > Sent: Wednesday, April 12, 2000 7:22 AM
    > To: NT Developers Interest List
    > Subject: [ntdev] Re: [ntdev]: Concept of packet in NDIS5.0
    >
    >
    > Hi,Williams
    >
    > I've understood your meaning.
    >
    > Yes, I shouldn't use the packet again in the hardware related
    routine.
    > So, what I do is first to query the packet information using
    > NdisQueryPacket and
    > then use the NdisMoveMemory to copy the buffer in the packet to
    > my temperory buffers
    > or DMA buffers.
    >
    > Is it right?
    >
    >
    > >-----BEGIN PGP SIGNED MESSAGE-----
    > >Hash: SHA1
    > >
    > >I wouldn't copy the packet to add the AAL5 trailer. The only reason
    to
    > >maintain a packet is if you are going to give the packet to another
    > >NDIS aware module. Usually a MiniportCoSendPackets routine is
    talking
    > >to a piece of hardware, not another NDIS driver.
    > >
    > >The simplest thing for you to do is copy the contents of the packet
    > >into a buffer with enough room at the end for an AAL5 trailer,
    > >calculate the CRC, then start chopping the buffer into 48 byte
    > >payloads for DMA to the card. Once you get that working, you can
    > >eliminate the copy and do the calculations directly from the NDIS
    > >packet. The tough part here is figuring out where the cell payloads
    > >span NDIS buffers and dealing with that correctly.
    > >
    > >Clark
    >
    > Best Regards!
    >
    > Xiaohua Cai
    > Institute of Modern Communications , SJTU
    > Shanghai
    >
    >
    > ____________________________
    > Free Email/SMTP/POP, http://www.bn3.com, Hosting
    [email protected]
    >
    > ---
    > You are currently subscribed to ntdev as: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    -----BEGIN PGP SIGNATURE-----
    Version: PGP 6.0.2

    iQA/AwUBOPSDquB0WaKgfXz5EQLjUgCg/pGr418/WSv4uVqq3DE2wJ+rr6UAoPuV
    LHkCnAUOaM1Fhv0gbGtTF5fb
    =YINj
    -----END PGP SIGNATURE-----
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 16-20 October 2023 Live, Online
Developing Minifilters 13-17 November 2023 Live, Online
Internals & Software Drivers 4-8 Dec 2023 Live, Online
Writing WDF Drivers 10-14 July 2023 Live, Online