Changeset f51f193 in mainline for uspace/lib/net/netif/netif_skel.c


Ignore:
Timestamp:
2011-07-12T03:00:14Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6817eba
Parents:
eca52a8 (diff), 026793d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/netif/netif_skel.c

    reca52a8 rf51f193  
    5454#include <nil_remote.h>
    5555
    56 // FIXME: remove this header
    57 #include <kernel/ipc/ipc_methods.h>
    58 
    5956DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
    6057
     
    6461/** Probe the existence of the device.
    6562 *
    66  * @param[in] netif_phone Network interface phone.
    6763 * @param[in] device_id   Device identifier.
    6864 * @param[in] irq         Device interrupt number.
     
    7470 *
    7571 */
    76 static int netif_probe_req_local(int netif_phone, device_id_t device_id,
    77     int irq, void *io)
     72static int netif_probe_req_local(device_id_t device_id, int irq, void *io)
    7873{
    7974        fibril_rwlock_write_lock(&netif_globals.lock);
     
    8681/** Send the packet queue.
    8782 *
    88  * @param[in] netif_phone Network interface phone.
    8983 * @param[in] device_id   Device identifier.
    9084 * @param[in] packet      Packet queue.
     
    9690 *
    9791 */
    98 static int netif_send_msg_local(int netif_phone, device_id_t device_id,
    99     packet_t *packet, services_t sender)
     92static int netif_send_msg_local(device_id_t device_id, packet_t *packet,
     93    services_t sender)
    10094{
    10195        fibril_rwlock_write_lock(&netif_globals.lock);
     
    108102/** Start the device.
    109103 *
    110  * @param[in] netif_phone Network interface phone.
    111104 * @param[in] device_id   Device identifier.
    112105 *
     
    118111 *
    119112 */
    120 static int netif_start_req_local(int netif_phone, device_id_t device_id)
     113static int netif_start_req_local(device_id_t device_id)
    121114{
    122115        fibril_rwlock_write_lock(&netif_globals.lock);
     
    131124        int result = netif_start_message(device);
    132125        if (result > NETIF_NULL) {
    133                 int phone = device->nil_phone;
    134                 nil_device_state_msg(phone, device_id, result);
     126                nil_device_state_msg(netif_globals.nil_sess, device_id, result);
    135127                fibril_rwlock_write_unlock(&netif_globals.lock);
    136128                return EOK;
     
    144136/** Stop the device.
    145137 *
    146  * @param[in] netif_phone Network interface phone.
    147138 * @param[in] device_id   Device identifier.
    148139 *
     
    154145 *
    155146 */
    156 static int netif_stop_req_local(int netif_phone, device_id_t device_id)
     147static int netif_stop_req_local(device_id_t device_id)
    157148{
    158149        fibril_rwlock_write_lock(&netif_globals.lock);
     
    167158        int result = netif_stop_message(device);
    168159        if (result > NETIF_NULL) {
    169                 int phone = device->nil_phone;
    170                 nil_device_state_msg(phone, device_id, result);
     160                nil_device_state_msg(netif_globals.nil_sess, device_id, result);
    171161                fibril_rwlock_write_unlock(&netif_globals.lock);
    172162                return EOK;
     
    222212void netif_pq_release(packet_id_t packet_id)
    223213{
    224         pq_release_remote(netif_globals.net_phone, packet_id);
     214        pq_release_remote(netif_globals.sess, packet_id);
    225215}
    226216
     
    235225packet_t *netif_packet_get_1(size_t content)
    236226{
    237         return packet_get_1_remote(netif_globals.net_phone, content);
     227        return packet_get_1_remote(netif_globals.sess, content);
    238228}
    239229
    240230/** Register the device notification receiver,
    241231 *
    242  * Register a  network interface layer module as the device
     232 * Register a network interface layer module as the device
    243233 * notification receiver.
    244234 *
    245  * @param[in] device_id Device identifier.
    246  * @param[in] phone     Network interface layer module phone.
    247  *
    248  * @return EOK on success.
    249  * @return ENOENT if there is no such device.
     235 * @param[in] sess      Session to the network interface layer module.
     236 *
     237 * @return EOK on success.
    250238 * @return ELIMIT if there is another module registered.
    251239 *
    252240 */
    253 static int register_message(device_id_t device_id, int phone)
    254 {
    255         netif_device_t *device;
    256         int rc = find_device(device_id, &device);
    257         if (rc != EOK)
    258                 return rc;
    259        
    260         if (device->nil_phone >= 0)
     241static int register_message(async_sess_t *sess)
     242{
     243        fibril_rwlock_write_lock(&netif_globals.lock);
     244        if (netif_globals.nil_sess != NULL) {
     245                fibril_rwlock_write_unlock(&netif_globals.lock);
    261246                return ELIMIT;
    262        
    263         device->nil_phone = phone;
     247        }
     248       
     249        netif_globals.nil_sess = sess;
     250       
     251        fibril_rwlock_write_unlock(&netif_globals.lock);
    264252        return EOK;
    265253}
     
    294282                return EOK;
    295283       
     284        async_sess_t *callback =
     285            async_callback_receive_start(EXCHANGE_SERIALIZE, call);
     286        if (callback)
     287                return register_message(callback);
     288       
    296289        switch (IPC_GET_IMETHOD(*call)) {
    297290        case NET_NETIF_PROBE:
    298                 return netif_probe_req_local(0, IPC_GET_DEVICE(*call),
     291                return netif_probe_req_local(IPC_GET_DEVICE(*call),
    299292                    NETIF_GET_IRQ(*call), NETIF_GET_IO(*call));
    300293       
    301         case IPC_M_CONNECT_TO_ME:
    302                 fibril_rwlock_write_lock(&netif_globals.lock);
    303                
    304                 rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));
    305                
    306                 fibril_rwlock_write_unlock(&netif_globals.lock);
    307                 return rc;
    308        
    309294        case NET_NETIF_SEND:
    310                 rc = packet_translate_remote(netif_globals.net_phone, &packet,
     295                rc = packet_translate_remote(netif_globals.sess, &packet,
    311296                    IPC_GET_PACKET(*call));
    312297                if (rc != EOK)
    313298                        return rc;
    314299               
    315                 return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet,
     300                return netif_send_msg_local(IPC_GET_DEVICE(*call), packet,
    316301                    IPC_GET_SENDER(*call));
    317302       
    318303        case NET_NETIF_START:
    319                 return netif_start_req_local(0, IPC_GET_DEVICE(*call));
     304                return netif_start_req_local(IPC_GET_DEVICE(*call));
    320305       
    321306        case NET_NETIF_STATS:
     
    343328       
    344329        case NET_NETIF_STOP:
    345                 return netif_stop_req_local(0, IPC_GET_DEVICE(*call));
     330                return netif_stop_req_local(IPC_GET_DEVICE(*call));
    346331       
    347332        case NET_NETIF_GET_ADDR:
     
    412397        async_set_client_connection(netif_client_connection);
    413398       
    414         netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
     399        netif_globals.sess = connect_to_service(SERVICE_NETWORKING);
     400        netif_globals.nil_sess = NULL;
    415401        netif_device_map_initialize(&netif_globals.device_map);
    416402       
Note: See TracChangeset for help on using the changeset viewer.