Changes in uspace/lib/net/netif/netif_skel.c [ee2fa30a:9934f7d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/netif/netif_skel.c
ree2fa30a r9934f7d 54 54 #include <nil_remote.h> 55 55 56 // FIXME: remove this header 57 #include <kernel/ipc/ipc_methods.h> 58 56 59 DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t); 57 60 … … 61 64 /** Probe the existence of the device. 62 65 * 66 * @param[in] netif_phone Network interface phone. 63 67 * @param[in] device_id Device identifier. 64 68 * @param[in] irq Device interrupt number. … … 70 74 * 71 75 */ 72 static int netif_probe_req_local(device_id_t device_id, int irq, void *io) 76 static int netif_probe_req_local(int netif_phone, device_id_t device_id, 77 int irq, void *io) 73 78 { 74 79 fibril_rwlock_write_lock(&netif_globals.lock); … … 81 86 /** Send the packet queue. 82 87 * 88 * @param[in] netif_phone Network interface phone. 83 89 * @param[in] device_id Device identifier. 84 90 * @param[in] packet Packet queue. … … 90 96 * 91 97 */ 92 static int netif_send_msg_local( device_id_t device_id, packet_t *packet,93 services_t sender)98 static int netif_send_msg_local(int netif_phone, device_id_t device_id, 99 packet_t *packet, services_t sender) 94 100 { 95 101 fibril_rwlock_write_lock(&netif_globals.lock); … … 102 108 /** Start the device. 103 109 * 110 * @param[in] netif_phone Network interface phone. 104 111 * @param[in] device_id Device identifier. 105 112 * … … 111 118 * 112 119 */ 113 static int netif_start_req_local( device_id_t device_id)120 static int netif_start_req_local(int netif_phone, device_id_t device_id) 114 121 { 115 122 fibril_rwlock_write_lock(&netif_globals.lock); … … 124 131 int result = netif_start_message(device); 125 132 if (result > NETIF_NULL) { 126 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 133 int phone = device->nil_phone; 134 nil_device_state_msg(phone, device_id, result); 127 135 fibril_rwlock_write_unlock(&netif_globals.lock); 128 136 return EOK; … … 136 144 /** Stop the device. 137 145 * 146 * @param[in] netif_phone Network interface phone. 138 147 * @param[in] device_id Device identifier. 139 148 * … … 145 154 * 146 155 */ 147 static int netif_stop_req_local( device_id_t device_id)156 static int netif_stop_req_local(int netif_phone, device_id_t device_id) 148 157 { 149 158 fibril_rwlock_write_lock(&netif_globals.lock); … … 158 167 int result = netif_stop_message(device); 159 168 if (result > NETIF_NULL) { 160 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 169 int phone = device->nil_phone; 170 nil_device_state_msg(phone, device_id, result); 161 171 fibril_rwlock_write_unlock(&netif_globals.lock); 162 172 return EOK; … … 212 222 void netif_pq_release(packet_id_t packet_id) 213 223 { 214 pq_release_remote(netif_globals. sess, packet_id);224 pq_release_remote(netif_globals.net_phone, packet_id); 215 225 } 216 226 … … 225 235 packet_t *netif_packet_get_1(size_t content) 226 236 { 227 return packet_get_1_remote(netif_globals. sess, content);237 return packet_get_1_remote(netif_globals.net_phone, content); 228 238 } 229 239 230 240 /** Register the device notification receiver, 231 241 * 232 * Register a network interface layer module as the device242 * Register a network interface layer module as the device 233 243 * notification receiver. 234 244 * 235 * @param[in] sess Session to the network interface layer module. 236 * 237 * @return EOK on success. 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. 238 250 * @return ELIMIT if there is another module registered. 239 251 * 240 252 */ 241 static 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); 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) 246 261 return ELIMIT; 247 } 248 249 netif_globals.nil_sess = sess; 250 251 fibril_rwlock_write_unlock(&netif_globals.lock); 262 263 device->nil_phone = phone; 252 264 return EOK; 253 265 } … … 282 294 return EOK; 283 295 284 async_sess_t *callback =285 async_callback_receive_start(EXCHANGE_SERIALIZE, call);286 if (callback)287 return register_message(callback);288 289 296 switch (IPC_GET_IMETHOD(*call)) { 290 297 case NET_NETIF_PROBE: 291 return netif_probe_req_local( IPC_GET_DEVICE(*call),298 return netif_probe_req_local(0, IPC_GET_DEVICE(*call), 292 299 NETIF_GET_IRQ(*call), NETIF_GET_IO(*call)); 293 300 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 294 309 case NET_NETIF_SEND: 295 rc = packet_translate_remote(netif_globals. sess, &packet,310 rc = packet_translate_remote(netif_globals.net_phone, &packet, 296 311 IPC_GET_PACKET(*call)); 297 312 if (rc != EOK) 298 313 return rc; 299 314 300 return netif_send_msg_local( IPC_GET_DEVICE(*call), packet,315 return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet, 301 316 IPC_GET_SENDER(*call)); 302 317 303 318 case NET_NETIF_START: 304 return netif_start_req_local( IPC_GET_DEVICE(*call));319 return netif_start_req_local(0, IPC_GET_DEVICE(*call)); 305 320 306 321 case NET_NETIF_STATS: … … 328 343 329 344 case NET_NETIF_STOP: 330 return netif_stop_req_local( IPC_GET_DEVICE(*call));345 return netif_stop_req_local(0, IPC_GET_DEVICE(*call)); 331 346 332 347 case NET_NETIF_GET_ADDR: … … 397 412 async_set_client_connection(netif_client_connection); 398 413 399 netif_globals.sess = connect_to_service(SERVICE_NETWORKING); 400 netif_globals.nil_sess = NULL; 414 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 401 415 netif_device_map_initialize(&netif_globals.device_map); 402 416
Note:
See TracChangeset
for help on using the changeset viewer.