Changeset 7300c37 in mainline


Ignore:
Timestamp:
2011-01-11T01:33:13Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8136102
Parents:
4fc2b3b
Message:

fetching of frames from the network card is still single-threaded, but sending the frames to NIL uses parallelism

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

Legend:

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

    r4fc2b3b r7300c37  
    5454#include <errno.h>
    5555#include <libarch/ddi.h>
    56 #include <netif_skel.h>
    5756#include <net/packet.h>
    58 #include <nil_interface.h>
    5957#include <packet_client.h>
    6058#include "dp8390.h"
     
    344342       
    345343        /* Step 10: */
    346         pio_write_8(ne2k->port + DP_CR, CR_DM_ABORT | CR_STA);
     344        pio_write_8(ne2k->port + DP_CR, CR_PS_P0 | CR_DM_ABORT | CR_STA);
    347345       
    348346        /* Step 11: */
     
    449447}
    450448
    451 static void ne2k_receive_frame(ne2k_t *ne2k, uint8_t page, size_t length,
    452     int nil_phone, device_id_t device_id)
    453 {
    454         packet_t *packet = netif_packet_get_1(length);
    455         if (!packet)
    456                 return;
    457        
    458         void *buf = packet_suffix(packet, length);
     449static frame_t *ne2k_receive_frame(ne2k_t *ne2k, uint8_t page, size_t length)
     450{
     451        frame_t *frame = (frame_t *) malloc(sizeof(frame_t));
     452        if (frame == NULL)
     453                return NULL;
     454       
     455        link_initialize(&frame->link);
     456       
     457        frame->packet = netif_packet_get_1(length);
     458        if (frame->packet == NULL) {
     459                free(frame);
     460                return NULL;
     461        }
     462       
     463        void *buf = packet_suffix(frame->packet, length);
    459464        bzero(buf, length);
    460465        uint8_t last = page + length / DP_PAGE;
     
    473478       
    474479        ne2k->stats.receive_packets++;
    475         nil_received_msg(nil_phone, device_id, packet, SERVICE_NONE);
    476 }
    477 
    478 static void ne2k_receive(ne2k_t *ne2k, int nil_phone, device_id_t device_id)
    479 {
     480        return frame;
     481}
     482
     483static link_t *ne2k_receive(ne2k_t *ne2k)
     484{
     485        /*
     486         * Allocate memory for the list of received frames.
     487         * If the allocation fails here we still receive the
     488         * frames from the network, but they will be lost.
     489         */
     490        link_t *frames = (link_t *) malloc(sizeof(link_t));
     491        if (frames != NULL)
     492                list_initialize(frames);
     493       
    480494        while (true) {
    481495                uint8_t boundary = pio_read_8(ne2k->port + DP_BNRY) + 1;
     
    526540                        ne2k->overruns++;
    527541                        next = current;
    528                 } else if ((header.status & RSR_PRX) && (ne2k->up))
    529                         ne2k_receive_frame(ne2k, boundary, length, nil_phone, device_id);
     542                } else if ((header.status & RSR_PRX) && (ne2k->up)) {
     543                        frame_t *frame = ne2k_receive_frame(ne2k, boundary, length);
     544                        if ((frame != NULL) && (frames != NULL))
     545                                list_append(&frame->link, frames);
     546                }
    530547               
    531548                /*
     
    542559                pio_write_8(ne2k->port + DP_BNRY, next);
    543560        }
    544 }
    545 
    546 void ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, int nil_phone, device_id_t device_id)
    547 {
     561       
     562        return frames;
     563}
     564
     565link_t *ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, uint8_t tsr)
     566{
     567        /* List of received frames */
     568        link_t *frames = NULL;
     569       
    548570        if (isr & (ISR_PTX | ISR_TXE)) {
    549571                if (isr & ISR_TXE)
    550572                        ne2k->stats.send_errors++;
    551573                else {
    552                         uint8_t tsr = pio_read_8(ne2k->port + DP_TSR);
    553                        
    554574                        if (tsr & TSR_PTX)
    555575                                ne2k->stats.send_packets++;
     
    598618        }
    599619       
    600         if (isr & ISR_PRX)
    601                 ne2k_receive(ne2k, nil_phone, device_id);
    602        
    603620        if (isr & ISR_RXE)
    604621                ne2k->stats.receive_errors++;
     
    613630        }
    614631       
     632        if (isr & ISR_PRX)
     633                frames = ne2k_receive(ne2k);
     634       
    615635        if (isr & ISR_RST) {
    616636                /*
     
    624644        pio_write_8(ne2k->port + DP_IMR,
    625645            IMR_PRXE | IMR_PTXE | IMR_RXEE | IMR_TXEE | IMR_OVWE | IMR_CNTE);
     646       
     647        return frames;
    626648}
    627649
  • uspace/srv/hw/netif/dp8390/dp8390.h

    r4fc2b3b r7300c37  
    5050
    5151#include <fibril_synch.h>
     52#include <adt/list.h>
    5253#include <net/packet.h>
     54#include <netif_skel.h>
    5355
    5456/** Module name */
     
    230232} ne2k_t;
    231233
     234typedef struct {
     235        link_t link;
     236        packet_t *packet;
     237} frame_t;
     238
    232239extern int ne2k_probe(ne2k_t *, void *, int);
    233240extern int ne2k_up(ne2k_t *);
    234241extern void ne2k_down(ne2k_t *);
    235242extern void ne2k_send(ne2k_t *, packet_t *);
    236 extern void ne2k_interrupt(ne2k_t *, uint8_t isr, int, device_id_t);
     243extern link_t *ne2k_interrupt(ne2k_t *, uint8_t, uint8_t);
    237244
    238245#endif
  • uspace/srv/hw/netif/dp8390/ne2000.c

    r4fc2b3b r7300c37  
    6868#define IRQ_GET_ISR(call)  ((int) IPC_GET_ARG2(call))
    6969
     70/** Return the TSR from the interrupt call.
     71 *
     72 * @param[in] call The interrupt call.
     73 *
     74 */
     75#define IRQ_GET_TSR(call)  ((int) IPC_GET_ARG3(call))
     76
    7077static int irc_service = 0;
    7178static int irc_phone = -1;
     
    9299                /* Predicate for accepting the interrupt */
    93100                .cmd = CMD_PREDICATE,
    94                 .value = 3,
     101                .value = 4,
    95102                .srcarg = 3
    96103        },
     
    111118        },
    112119        {
     120                /* Read Transmit Status Register */
     121                .cmd = CMD_PIO_READ_8,
     122                .addr = NULL,
     123                .dstarg = 3
     124        },
     125        {
    113126                .cmd = CMD_ACCEPT
    114127        }
     
    125138/** Handle the interrupt notification.
    126139 *
    127  * This is the interrupt notification function.
     140 * This is the interrupt notification function. It is quarantied
     141 * that there is only a single instance of this notification
     142 * function running at one time until the return from the
     143 * ne2k_interrupt() function (where the interrupts are unmasked
     144 * again).
    128145 *
    129146 * @param[in] iid  Interrupt notification identifier.
     
    148165        fibril_rwlock_read_unlock(&netif_globals.lock);
    149166       
    150         if (ne2k != NULL)
    151                 ne2k_interrupt(ne2k, IRQ_GET_ISR(*call), nil_phone, device_id);
     167        if (ne2k != NULL) {
     168                link_t *frames =
     169                    ne2k_interrupt(ne2k, IRQ_GET_ISR(*call), IRQ_GET_TSR(*call));
     170               
     171                if (frames != NULL) {
     172                        while (!list_empty(frames)) {
     173                                frame_t *frame =
     174                                    list_get_instance(frames->next, frame_t, link);
     175                               
     176                                list_remove(&frame->link);
     177                                nil_received_msg(nil_phone, device_id, frame->packet,
     178                                    SERVICE_NONE);
     179                                free(frame);
     180                        }
     181                       
     182                        free(frames);
     183                }
     184        }
    152185}
    153186
Note: See TracChangeset for help on using the changeset viewer.