Ignore:
Timestamp:
2010-04-09T12:54:57Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1caa3c2
Parents:
24ab58b3
Message:

networking overhaul:

  • separation of conserns
  • removal of (almost all) overlaping symbols, libnetif is not needed anymore
  • again, it is possible to build the networking in multiple architecture configurations (however, currently only the bundling netif and nil layers is supported, more to come)
  • code style updates and fixes (still a huge amount of work to do)
File:
1 edited

Legend:

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

    r24ab58b3 r14f1db0  
    5050#include <net_device.h>
    5151#include <nil_interface.h>
    52 #include <netif.h>
    53 #include <netif_module.h>
     52#include <netif_interface.h>
     53#include <netif_local.h>
    5454
    5555#include "dp8390.h"
     
    9595};
    9696
    97 /** Network interface module global data.
    98  */
    99 netif_globals_t netif_globals;
    100 
    10197/** Handles the interrupt messages.
    10298 *  This is the interrupt handler callback function.
     
    104100 *  @param[in] call The interrupt message.
    105101 */
    106 void irq_handler(ipc_callid_t iid, ipc_call_t * call);
    107 
    108 /** Changes the network interface state.
    109  *  @param[in,out] device The network interface.
    110  *  @param[in] state The new state.
    111  *  @returns The new state.
    112  */
    113 int change_state(device_ref device, device_state_t state);
    114 
    115 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    116         return ENOTSUP;
    117 }
    118 
    119 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){
    120         ERROR_DECLARE;
    121 
    122         device_ref device;
    123         eth_stat_t * de_stat;
    124 
    125         if(! stats){
    126                 return EBADMEM;
    127         }
    128         ERROR_PROPAGATE(find_device(device_id, &device));
    129         de_stat = &((dpeth_t *) device->specific)->de_stat;
    130         null_device_stats(stats);
    131         stats->receive_errors = de_stat->ets_recvErr;
    132         stats->send_errors = de_stat->ets_sendErr;
    133         stats->receive_crc_errors = de_stat->ets_CRCerr;
    134         stats->receive_frame_errors = de_stat->ets_frameAll;
    135         stats->receive_missed_errors = de_stat->ets_missedP;
    136         stats->receive_packets = de_stat->ets_packetR;
    137         stats->send_packets = de_stat->ets_packetT;
    138         stats->collisions = de_stat->ets_collision;
    139         stats->send_aborted_errors = de_stat->ets_transAb;
    140         stats->send_carrier_errors = de_stat->ets_carrSense;
    141         stats->send_heartbeat_errors = de_stat->ets_CDheartbeat;
    142         stats->send_window_errors = de_stat->ets_OWC;
    143         return EOK;
    144 }
    145 
    146 int netif_get_addr_message(device_id_t device_id, measured_string_ref address){
    147         ERROR_DECLARE;
    148 
    149         device_ref device;
    150 
    151         if(! address){
    152                 return EBADMEM;
    153         }
    154         ERROR_PROPAGATE(find_device(device_id, &device));
    155         address->value = (char *) (&((dpeth_t *) device->specific)->de_address);
    156         address->length = CONVERT_SIZE(ether_addr_t, char, 1);
    157         return EOK;
    158 }
    159 
    160 void irq_handler(ipc_callid_t iid, ipc_call_t * call)
     102static void irq_handler(ipc_callid_t iid, ipc_call_t * call)
    161103{
    162         device_ref device;
     104        netif_device_t * device;
    163105        dpeth_t * dep;
    164106        packet_t received;
     
    203145}
    204146
     147/** Changes the network interface state.
     148 *  @param[in,out] device The network interface.
     149 *  @param[in] state The new state.
     150 *  @returns The new state.
     151 */
     152static int change_state(netif_device_t * device, device_state_t state)
     153{
     154        if (device->state != state) {
     155                device->state = state;
     156               
     157                printf("%s: State changed to %s\n", NAME,
     158                    (state == NETIF_ACTIVE) ? "active" : "stopped");
     159               
     160                return state;
     161        }
     162       
     163        return EOK;
     164}
     165
     166int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     167        return ENOTSUP;
     168}
     169
     170int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){
     171        ERROR_DECLARE;
     172
     173        netif_device_t * device;
     174        eth_stat_t * de_stat;
     175
     176        if(! stats){
     177                return EBADMEM;
     178        }
     179        ERROR_PROPAGATE(find_device(device_id, &device));
     180        de_stat = &((dpeth_t *) device->specific)->de_stat;
     181        null_device_stats(stats);
     182        stats->receive_errors = de_stat->ets_recvErr;
     183        stats->send_errors = de_stat->ets_sendErr;
     184        stats->receive_crc_errors = de_stat->ets_CRCerr;
     185        stats->receive_frame_errors = de_stat->ets_frameAll;
     186        stats->receive_missed_errors = de_stat->ets_missedP;
     187        stats->receive_packets = de_stat->ets_packetR;
     188        stats->send_packets = de_stat->ets_packetT;
     189        stats->collisions = de_stat->ets_collision;
     190        stats->send_aborted_errors = de_stat->ets_transAb;
     191        stats->send_carrier_errors = de_stat->ets_carrSense;
     192        stats->send_heartbeat_errors = de_stat->ets_CDheartbeat;
     193        stats->send_window_errors = de_stat->ets_OWC;
     194        return EOK;
     195}
     196
     197int netif_get_addr_message(device_id_t device_id, measured_string_ref address){
     198        ERROR_DECLARE;
     199
     200        netif_device_t * device;
     201
     202        if(! address){
     203                return EBADMEM;
     204        }
     205        ERROR_PROPAGATE(find_device(device_id, &device));
     206        address->value = (char *) (&((dpeth_t *) device->specific)->de_address);
     207        address->length = CONVERT_SIZE(ether_addr_t, char, 1);
     208        return EOK;
     209}
     210
     211
     212
    205213int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){
    206214        ERROR_DECLARE;
    207215
    208         device_ref device;
    209         dpeth_t * dep;
    210 
    211         device = (device_ref) malloc(sizeof(device_t));
     216        netif_device_t * device;
     217        dpeth_t * dep;
     218
     219        device = (netif_device_t *) malloc(sizeof(netif_device_t));
    212220        if(! device){
    213221                return ENOMEM;
     
    218226                return ENOMEM;
    219227        }
    220         bzero(device, sizeof(device_t));
     228        bzero(device, sizeof(netif_device_t));
    221229        bzero(dep, sizeof(dpeth_t));
    222230        device->device_id = device_id;
     
    233241                return ERROR_CODE;
    234242        }
    235         if(ERROR_OCCURRED(device_map_add(&netif_globals.device_map, device->device_id, device))){
     243        if(ERROR_OCCURRED(netif_device_map_add(&netif_globals.device_map, device->device_id, device))){
    236244                free(dep);
    237245                free(device);
     
    244252        ERROR_DECLARE;
    245253
    246         device_ref device;
     254        netif_device_t * device;
    247255        dpeth_t * dep;
    248256        packet_t next;
     
    271279}
    272280
    273 int netif_start_message(device_ref device){
     281int netif_start_message(netif_device_t * device){
    274282        ERROR_DECLARE;
    275283
     
    290298}
    291299
    292 int netif_stop_message(device_ref device){
     300int netif_stop_message(netif_device_t * device){
    293301        dpeth_t * dep;
    294302
     
    302310}
    303311
    304 int change_state(device_ref device, device_state_t state)
    305 {
    306         if (device->state != state) {
    307                 device->state = state;
    308                
    309                 printf("%s: State changed to %s\n", NAME,
    310                     (state == NETIF_ACTIVE) ? "active" : "stopped");
    311                
    312                 return state;
    313         }
    314        
    315         return EOK;
    316 }
    317 
    318312int netif_initialize(void){
    319313        ipcarg_t phonehash;
     
    323317        return REGISTER_ME(SERVICE_DP8390, &phonehash);
    324318}
    325 
    326 #ifdef CONFIG_NETWORKING_modular
    327 
    328 #include <netif_standalone.h>
    329319
    330320/** Default thread for new connections.
     
    386376}
    387377
    388 #endif /* CONFIG_NETWORKING_modular */
    389 
    390 
    391378/** @}
    392379 */
Note: See TracChangeset for help on using the changeset viewer.