Docstoc

nic

Document Sample
nic Powered By Docstoc
					Network Adapter Driver

          NCTU
  High Speed Network Lab.
                              System Architecture
                                  Media




                                  Network Interface Controller
Simple Data Link Interface




                                   Hardware Dependent Driver



                             Command Queue           Data Queue




                                          User Program



                                                 2         NCTU High Speed Network Lab
             Adapter Rx Process
Coax cable


                              BUS     Rx
        16 byte FIFO                 Buffer
                                     Ring
       CRC     Addr. Filter


               If my addr           DMA



                               3      NCTU High Speed Network Lab
          NIC Rx Procedure
                                                                     Media
            (3)
              Interrupt cup (307)
       Current page register(page1:307)
                                              NIC                      (1)




                                                              FIFO
HOST    Romote start address(308,309)
CPU     Romote byte count      (30a,30b)
            Romote DMA write (300)          Data port
                Data port (310)


                         (5)                            (2)          Local
                                              (4)
                                                                     DMA
 Host Memory
                                           NIC memory

                                    4         NCTU High Speed Network Lab
        NIC Tx Procedure
                                                                   Media
          (1)
       Romote start address(308,309)
       Romote byte count     (30a,30b)
                                            NIC                      (6)




                                                            FIFO
          Romote DMA write (300)
HOST
              Data port (310)
CPU
           (4)
        Remote DMA complete(307)          Data port
       Romote start address(308,309)


                       (2)                            (5)          Local
                                            (3)
                                                                   DMA
Host Memory
                                         NIC memory

                                 5          NCTU High Speed Network Lab
    Buffer Ring Control Points

Set one times when initial:
Page Start Point (PSTART) : Set when Initial
Page Stop Point (PSTOP) : Set when Initial
Update when received packet:
Current Page Point (CURR) : NIC auto update
Boundary Page Point (BNDRY) : manual update
Next Packet Page (next_pkt) : memory variable
                        6       NCTU High Speed Network Lab
        Receive Buffer Ring
                                               Page start
                                               address
                         Buffer #1
                         Buffer #2

    4
                3

                         Buffer #n
                                               Page start
                     2                         address
n           1

         256 bytes
                         7       NCTU High Speed Network Lab
    Rx Buffer Ring Maintain
• When initializing the NIC set :
     BNDRY = PSTART
     CURR = PSTART + 1
     next_pkt = PSTART + 1
• After a packet is DMAed from
  Rx Buffer Ring
     next_pkt = Next Page Pointer
     BNDRY = Next Page Pointer
     if BNDRY < PSTART then BNDRY = PSTOP - 1


                        8     NCTU High Speed Network Lab
Receive Buffer Ring
                                   Current Page
                                     Register

                                           Packet Ends

               4
                                           3
             Status
           next page
           Length(L)
           Length(H)                        2
         n                     1
Current Page               Packet status
  Register

                       9            NCTU High Speed Network Lab
                               Driver ISR
Driver ISR
                            Disable interrupt
                            Save PC Registers



                             Read Interrupt
                             Status Register



                                  Packet        YES
                                Reception?

                                         NO             Reset PRX bit in
                                                        Interrupt Status
                      YES                                   Register
                                  Packet
                              Transmission?

   Reset PTX bit in
   Interrupt Status                      NO
       Register
                                    10           NCTU High Speed Network Lab
  Read Transmit         Send “EOI”                DMA Packet
  Status Register         to 8259                 from Local
                                                 memory to PC


 Inform High Level
      Software         Enable Interrupt         Inform High Level
                         Restore PC                  Software
                          Registers
      Empty
   Transmission                            NO       Receive
      Queue?                IRET                   Buffer Ring
                                                    Empty?
                                                          YES
Transmit Next Packet
     in Queue



   Update Queue
     Pointers


                               11         NCTU High Speed Network Lab
                           Driver Send
    Driver Send



    NIC Ready to      NO
     Transmit?

            YES

 DMA Packet from                Queue Packet in
PC to Local Memory                PC Memory




   Program NIC to
   Transmit Packet
(Command Reg = 26h)



     RETURN
                           12    NCTU High Speed Network Lab
             Note: Enter ISR
  Disable PC Interrupt           CLI
                                 PUSHA
   Save PC Registers



                                 MOV   AL,00H
Disable Adapter Interrupt        WR_NE INTERRUPTMASK


                                 MOV     DX,20h
   Send EOI to 8259              MOV     AL,63h
                                 OUT     DX,AL


  Enable PC Interrupt            STI
                            13     NCTU High Speed Network Lab
             Note: Leave ISR
  Disable PC Interrupt            CLI



                                  MOV   AL,0FFH
Enable Adapter Interrupt          WR_NE INTERRUPTMASK



  Restore PC Registers            POPA
                                  STI
   Enable PC Interrupt



Return to Original Process        IRET
                             14         NCTU High Speed Network Lab

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:7
posted:9/21/2011
language:English
pages:14