Changeset 39d70ec in mainline


Ignore:
Timestamp:
2011-01-06T19:50:04Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aa1e202
Parents:
b187536
Message:

remove additional packet queueing

Location:
uspace/srv/hw/netif/dp8390
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/netif/dp8390/dp8390.c

    rb187536 r39d70ec  
    1212#include <netif_local.h>
    1313#include <net/packet.h>
     14#include <nil_interface.h>
    1415#include <packet_client.h>
    1516#include "dp8390_drv.h"
     
    1819#include "ne2000.h"
    1920
    20 /** Queues the outgoing packet.
    21  *  @param[in] dep The network interface structure.
    22  *  @param[in] packet The outgoing packet.
    23  *  @return EOK on success.
    24  *  @return EINVAL
    25  */
    26 int queue_packet(dpeth_t *dep, packet_t *packet);
    27 
    28 /** Reads a memory block byte by byte.
     21/** Read a memory block byte by byte.
     22 *
    2923 *  @param[in] port The source address.
    3024 *  @param[out] buf The destination buffer.
    3125 *  @param[in] size The memory block size in bytes.
     26 *
    3227 */
    3328static void outsb(port_t port, void * buf, size_t size);
    3429
    35 /** Reads a memory block word by word.
     30/** Read a memory block word by word.
     31 *
    3632 *  @param[in] port The source address.
    3733 *  @param[out] buf The destination buffer.
    3834 *  @param[in] size The memory block size in bytes.
     35 *
    3936 */
    4037static void outsw(port_t port, void * buf, size_t size);
    4138
    42 /* Some clones of the dp8390 and the PC emulator 'Bochs' require the CR_STA
     39/*
     40 * Some clones of the dp8390 and the PC emulator 'Bochs' require the CR_STA
    4341 * on writes to the CR register. Additional CR_STAs do not appear to hurt
    44  * genuine dp8390s
     42 * genuine dp8390s.
    4543 */
    4644#define CR_EXTRA  CR_STA
     
    4947static void dp_reinit(dpeth_t *dep);
    5048static void dp_reset(dpeth_t *dep);
    51 static void dp_recv(dpeth_t *dep);
    52 static void dp_send(dpeth_t *dep);
     49static void dp_recv(int nil_phone, device_id_t device_id, dpeth_t *dep);
    5350static void dp_pio8_getblock(dpeth_t *dep, int page, size_t offset, size_t size, void *dst);
    5451static void dp_pio16_getblock(dpeth_t *dep, int page, size_t offset, size_t size, void *dst);
    55 static int dp_pkt2user(dpeth_t *dep, int page, int length);
     52static int dp_pkt2user(int nil_phone, device_id_t device_id, dpeth_t *dep, int page, int length);
    5653static void dp_pio8_user2nic(dpeth_t *dep, void *buf, size_t offset, int nic_addr, size_t size);
    5754static void dp_pio16_user2nic(dpeth_t *dep, void *buf, size_t offset, int nic_addr, size_t size);
     
    9693                dep->de_flags |= DEF_BROAD;
    9794       
    98 //      dep->de_client = mp->m_source;
    9995        dp_reinit(dep);
    100        
    101 //      reply_mess.m_type = DL_CONF_REPLY;
    102 //      reply_mess.m3_i1 = mp->DL_PORT;
    103 //      reply_mess.m3_i2 = DE_PORT_NR;
    104 //      *(ether_addr_t *) reply_mess.m3_ca1 = dep->de_address;
    105        
    106 //      mess_reply(mp, &reply_mess);
    10796        return EOK;
    10897}
     
    118107}
    119108
    120 int queue_packet(dpeth_t *dep, packet_t *packet)
    121 {
    122         packet_t *tmp;
    123        
    124         if (dep->packet_count >= MAX_PACKETS) {
    125                 netif_pq_release(packet_get_id(packet));
    126                 return ELIMIT;
    127         }
    128        
    129         tmp = dep->packet_queue;
    130         while (pq_next(tmp))
    131                 tmp = pq_next(tmp);
    132        
    133         if (pq_add(&tmp, packet, 0, 0) != EOK)
    134                 return EINVAL;
    135        
    136         if (!dep->packet_count)
    137                 dep->packet_queue = packet;
    138        
    139         ++dep->packet_count;
    140         return EBUSY;
    141 }
    142 
    143109int do_pwrite(dpeth_t *dep, packet_t *packet, int from_int)
    144110{
     
    149115        assert(dep->de_flags & DEF_ENABLED);
    150116       
    151         if ((dep->packet_queue) && (!from_int)) {
    152 //      if (dep->de_flags &DEF_SEND_AVAIL){
    153 //              fprintf(stderr, "dp8390: send already in progress\n");
    154                 return queue_packet(dep, packet);
     117        if (dep->de_flags & DEF_SEND_AVAIL) {
     118                fprintf(stderr, "dp8390: send already in progress\n");
     119                return EBUSY;
    155120        }
    156121       
     
    159124                if (from_int)
    160125                        fprintf(stderr, "dp8390: should not be sending\n");
    161 //              dep->de_flags |= DEF_SEND_AVAIL;
    162                 return queue_packet(dep, packet);
    163         }
    164        
    165 //      assert(!(dep->de_flags &DEF_PACK_SEND));
     126                dep->de_flags |= DEF_SEND_AVAIL;
     127                dep->de_flags &= ~(DEF_PACK_SEND | DEF_PACK_RECV);
     128               
     129                return EBUSY;
     130        }
     131       
     132        assert(!(dep->de_flags & DEF_PACK_SEND));
    166133       
    167134        void *buf = packet_get_data(packet);
     
    191158        dep->de_sendq_head = sendq_head;
    192159       
    193 //      dep->de_flags |= DEF_PACK_SEND;
     160        dep->de_flags |= DEF_PACK_SEND;
     161       
     162        if (from_int)
     163                return EOK;
     164       
     165        dep->de_flags &= ~(DEF_PACK_SEND | DEF_PACK_RECV);
    194166       
    195167        return EOK;
     
    360332                dep->de_sendq[i].sq_filled = 0;
    361333       
    362         dp_send(dep);
     334        dep->de_flags &= ~DEF_SEND_AVAIL;
    363335        dep->de_flags &= ~DEF_STOPPED;
    364336}
    365337
    366 void dp_check_ints(dpeth_t *dep, int isr)
     338void dp_check_ints(int nil_phone, device_id_t device_id, dpeth_t *dep, int isr)
    367339{
    368340        int tsr;
     
    427399                        }
    428400                       
    429 //                      if (dep->de_flags &DEF_SEND_AVAIL)
    430                                 dp_send(dep);
     401                        dep->de_flags &= ~DEF_SEND_AVAIL;
    431402                }
    432403               
    433404                if (isr & ISR_PRX) {
    434405                        /* Only call dp_recv if there is a read request */
    435 //                      if (dep->de_flags) &DEF_READING)
    436                                 dp_recv(dep);
     406//                      if (dep->de_flags) & DEF_READING)
     407                                dp_recv(nil_phone, device_id, dep);
    437408                }
    438409               
     
    478449                dp_reset(dep);
    479450        }
    480 }
    481 
    482 static void dp_recv(dpeth_t *dep)
     451       
     452        dep->de_flags &= ~(DEF_PACK_SEND | DEF_PACK_RECV);
     453}
     454
     455static void dp_recv(int nil_phone, device_id_t device_id, dpeth_t *dep)
    483456{
    484457        dp_rcvhdr_t header;
     
    522495                        next = curr;
    523496                } else if ((header.dr_status & RSR_PRX) && (dep->de_flags & DEF_ENABLED)) {
    524                         r = dp_pkt2user(dep, pageno, length);
     497                        r = dp_pkt2user(nil_phone, device_id, dep, pageno, length);
    525498                        if (r != EOK)
    526499                                return;
     
    539512}
    540513
    541 static void dp_send(dpeth_t *dep)
    542 {
    543         packet_t *packet;
    544        
    545 //      if (!(dep->de_flags &DEF_SEND_AVAIL))
    546 //              return;
    547        
    548         if (dep->packet_queue) {
    549                 packet = dep->packet_queue;
    550                 dep->packet_queue = pq_detach(packet);
    551                 do_pwrite(dep, packet, true);
    552                 netif_pq_release(packet_get_id(packet));
    553                 --dep->packet_count;
    554         }
    555        
    556 //      if (!dep->packet_queue)
    557 //              dep->de_flags &= ~DEF_SEND_AVAIL;
    558 }
    559 
    560514static void dp_pio8_getblock(dpeth_t *dep, int page, size_t offset, size_t size, void *dst)
    561515{
     
    584538}
    585539
    586 static int dp_pkt2user(dpeth_t *dep, int page, int length)
     540static int dp_pkt2user(int nil_phone, device_id_t device_id, dpeth_t *dep, int page, int length)
    587541{
    588542        int last, count;
     
    614568//      dep->de_flags &= ~DEF_READING;
    615569       
    616         if (dep->received_count >= MAX_PACKETS) {
    617                 netif_pq_release(packet_get_id(packet));
    618                 return ELIMIT;
    619         } else {
    620                 if (pq_add(&dep->received_queue, packet, 0, 0) == EOK)
    621                         ++dep->received_count;
    622                 else
    623                         netif_pq_release(packet_get_id(packet));
    624         }
     570        nil_received_msg(nil_phone, device_id, packet, SERVICE_NONE);
    625571       
    626572        return EOK;
  • uspace/srv/hw/netif/dp8390/dp8390.h

    rb187536 r39d70ec  
    219219#define SENDQ_PAGES  6  /* 6 * DP_PAGESIZE >= 1514 bytes */
    220220
    221 /** Maximum number of waiting packets to be sent or received.
    222  */
    223 #define MAX_PACKETS  1024
    224 
    225221typedef struct dpeth {
    226         /** Outgoing packets queue */
    227         packet_t *packet_queue;
    228        
    229         /** Outgoing packets count */
    230         int packet_count;
    231        
    232         /** Received packets queue */
    233         packet_t *received_queue;
    234        
    235         /** Received packets count */
    236         int received_count;
    237        
    238222        /*
    239223         * The de_base_port field is the starting point of the probe.
  • uspace/srv/hw/netif/dp8390/dp8390_drv.h

    rb187536 r39d70ec  
    5656 *  @param[in,out] dep The network interface structure.
    5757 */
    58 void dp_check_ints(dpeth_t *dep, int isr);
     58void dp_check_ints(int nil_phone, device_id_t device_id, dpeth_t *dep, int isr);
    5959
    6060/** Probes and initializes the network interface.
     
    6969 *  @param[in] packet The packet t be sent.
    7070 *  @param[in] from_int The value indicating whether the sending is initialized from the interrupt handler.
    71  *  @returns 
     71 *  @returns
    7272 */
    7373int do_pwrite(dpeth_t * dep, packet_t *packet, int from_int);
  • uspace/srv/hw/netif/dp8390/dp8390_module.c

    rb187536 r39d70ec  
    115115static void irq_handler(ipc_callid_t iid, ipc_call_t *call)
    116116{
     117        device_id_t device_id = IRQ_GET_DEVICE(*call);
    117118        netif_device_t *device;
    118         dpeth_t *dep;
    119         packet_t *received;
    120         device_id_t device_id;
    121         int phone;
    122        
    123         device_id = IRQ_GET_DEVICE(*call);
     119        int nil_phone;
     120        dpeth_t *dep;
     121       
    124122        fibril_rwlock_write_lock(&netif_globals.lock);
    125123       
    126         if (find_device(device_id, &device) != EOK) {
    127                 fibril_rwlock_write_unlock(&netif_globals.lock);
    128                 return;
    129         }
    130        
    131         dep = (dpeth_t *) device->specific;
    132         if (dep->de_mode != DEM_ENABLED) {
    133                 fibril_rwlock_write_unlock(&netif_globals.lock);
    134                 return;
    135         }
    136        
    137         assert(dep->de_flags & DEF_ENABLED);
    138        
    139         dp_check_ints(dep, IRQ_GET_ISR(*call));
    140        
    141         if (dep->received_queue) {
    142                 received = dep->received_queue;
    143                 phone = device->nil_phone;
    144                 dep->received_queue = NULL;
    145                 dep->received_count = 0;
    146                 fibril_rwlock_write_unlock(&netif_globals.lock);
    147                 nil_received_msg(phone, device_id, received, SERVICE_NONE);
     124        if (find_device(device_id, &device) == EOK) {
     125                nil_phone = device->nil_phone;
     126                dep = (dpeth_t *) device->specific;
    148127        } else
    149                 fibril_rwlock_write_unlock(&netif_globals.lock);
     128                dep = NULL;
     129       
     130        fibril_rwlock_write_unlock(&netif_globals.lock);
     131       
     132        if ((dep != NULL) && (dep->de_mode == DEM_ENABLED)) {
     133                assert(dep->de_flags & DEF_ENABLED);
     134                dp_check_ints(nil_phone, device_id, dep, IRQ_GET_ISR(*call));
     135        }
    150136}
    151137
Note: See TracChangeset for help on using the changeset viewer.