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


Ignore:
Timestamp:
2011-07-20T15:26:21Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
efcebe1
Parents:
25bef0ff (diff), a701812 (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

    r25bef0ff r6a44ee4  
    6161/** Probe the existence of the device.
    6262 *
    63  * @param[in] netif_phone Network interface phone.
    6463 * @param[in] device_id   Device identifier.
    6564 * @param[in] irq         Device interrupt number.
     
    7170 *
    7271 */
    73 static int netif_probe_req_local(int netif_phone, device_id_t device_id,
    74     int irq, void *io)
     72static int netif_probe_req_local(device_id_t device_id, int irq, void *io)
    7573{
    7674        fibril_rwlock_write_lock(&netif_globals.lock);
     
    8381/** Send the packet queue.
    8482 *
    85  * @param[in] netif_phone Network interface phone.
    8683 * @param[in] device_id   Device identifier.
    8784 * @param[in] packet      Packet queue.
     
    9390 *
    9491 */
    95 static int netif_send_msg_local(int netif_phone, device_id_t device_id,
    96     packet_t *packet, services_t sender)
     92static int netif_send_msg_local(device_id_t device_id, packet_t *packet,
     93    services_t sender)
    9794{
    9895        fibril_rwlock_write_lock(&netif_globals.lock);
     
    105102/** Start the device.
    106103 *
    107  * @param[in] netif_phone Network interface phone.
    108104 * @param[in] device_id   Device identifier.
    109105 *
     
    115111 *
    116112 */
    117 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)
    118114{
    119115        fibril_rwlock_write_lock(&netif_globals.lock);
     
    128124        int result = netif_start_message(device);
    129125        if (result > NETIF_NULL) {
    130                 int phone = device->nil_phone;
    131                 nil_device_state_msg(phone, device_id, result);
     126                nil_device_state_msg(netif_globals.nil_sess, device_id, result);
    132127                fibril_rwlock_write_unlock(&netif_globals.lock);
    133128                return EOK;
     
    141136/** Stop the device.
    142137 *
    143  * @param[in] netif_phone Network interface phone.
    144138 * @param[in] device_id   Device identifier.
    145139 *
     
    151145 *
    152146 */
    153 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)
    154148{
    155149        fibril_rwlock_write_lock(&netif_globals.lock);
     
    164158        int result = netif_stop_message(device);
    165159        if (result > NETIF_NULL) {
    166                 int phone = device->nil_phone;
    167                 nil_device_state_msg(phone, device_id, result);
     160                nil_device_state_msg(netif_globals.nil_sess, device_id, result);
    168161                fibril_rwlock_write_unlock(&netif_globals.lock);
    169162                return EOK;
     
    219212void netif_pq_release(packet_id_t packet_id)
    220213{
    221         pq_release_remote(netif_globals.net_phone, packet_id);
     214        pq_release_remote(netif_globals.sess, packet_id);
    222215}
    223216
     
    232225packet_t *netif_packet_get_1(size_t content)
    233226{
    234         return packet_get_1_remote(netif_globals.net_phone, content);
     227        return packet_get_1_remote(netif_globals.sess, content);
    235228}
    236229
    237230/** Register the device notification receiver,
    238231 *
    239  * Register a  network interface layer module as the device
     232 * Register a network interface layer module as the device
    240233 * notification receiver.
    241234 *
    242  * @param[in] device_id Device identifier.
    243  * @param[in] phone     Network interface layer module phone.
    244  *
    245  * @return EOK on success.
    246  * @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.
    247238 * @return ELIMIT if there is another module registered.
    248239 *
    249240 */
    250 static int register_message(device_id_t device_id, int phone)
    251 {
    252         netif_device_t *device;
    253         int rc = find_device(device_id, &device);
    254         if (rc != EOK)
    255                 return rc;
    256        
    257         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);
    258246                return ELIMIT;
    259        
    260         device->nil_phone = phone;
     247        }
     248       
     249        netif_globals.nil_sess = sess;
     250       
     251        fibril_rwlock_write_unlock(&netif_globals.lock);
    261252        return EOK;
    262253}
     
    288279        *count = 0;
    289280       
     281        if (!IPC_GET_IMETHOD(*call))
     282                return EOK;
     283       
     284        async_sess_t *callback =
     285            async_callback_receive_start(EXCHANGE_SERIALIZE, call);
     286        if (callback)
     287                return register_message(callback);
     288       
    290289        switch (IPC_GET_IMETHOD(*call)) {
    291         case IPC_M_PHONE_HUNGUP:
    292                 return EOK;
    293        
    294290        case NET_NETIF_PROBE:
    295                 return netif_probe_req_local(0, IPC_GET_DEVICE(*call),
     291                return netif_probe_req_local(IPC_GET_DEVICE(*call),
    296292                    NETIF_GET_IRQ(*call), NETIF_GET_IO(*call));
    297293       
    298         case IPC_M_CONNECT_TO_ME:
    299                 fibril_rwlock_write_lock(&netif_globals.lock);
    300                
    301                 rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));
    302                
    303                 fibril_rwlock_write_unlock(&netif_globals.lock);
    304                 return rc;
    305        
    306294        case NET_NETIF_SEND:
    307                 rc = packet_translate_remote(netif_globals.net_phone, &packet,
     295                rc = packet_translate_remote(netif_globals.sess, &packet,
    308296                    IPC_GET_PACKET(*call));
    309297                if (rc != EOK)
    310298                        return rc;
    311299               
    312                 return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet,
     300                return netif_send_msg_local(IPC_GET_DEVICE(*call), packet,
    313301                    IPC_GET_SENDER(*call));
    314302       
    315303        case NET_NETIF_START:
    316                 return netif_start_req_local(0, IPC_GET_DEVICE(*call));
     304                return netif_start_req_local(IPC_GET_DEVICE(*call));
    317305       
    318306        case NET_NETIF_STATS:
     
    340328       
    341329        case NET_NETIF_STOP:
    342                 return netif_stop_req_local(0, IPC_GET_DEVICE(*call));
     330                return netif_stop_req_local(IPC_GET_DEVICE(*call));
    343331       
    344332        case NET_NETIF_GET_ADDR:
     
    362350 *
    363351 */
    364 static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     352static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall,
     353    void *arg)
    365354{
    366355        /*
     
    385374               
    386375                /* End if said to either by the message or the processing result */
    387                 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
    388                     (res == EHANGUP))
     376                if ((!IPC_GET_IMETHOD(call)) || (res == EHANGUP))
    389377                        return;
    390378               
     
    409397        async_set_client_connection(netif_client_connection);
    410398       
    411         netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
     399        netif_globals.sess = connect_to_service(SERVICE_NETWORKING);
     400        netif_globals.nil_sess = NULL;
    412401        netif_device_map_initialize(&netif_globals.device_map);
    413402       
Note: See TracChangeset for help on using the changeset viewer.