Changes in uspace/srv/net/nil/eth/eth.c [6b82009:28a3e74] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
r6b82009 r28a3e74 59 59 #include <packet_remote.h> 60 60 #include <nil_skel.h> 61 61 62 #include "eth.h" 62 63 … … 167 168 INT_MAP_IMPLEMENT(eth_protos, eth_proto_t); 168 169 169 int nil_device_state_msg_local( device_id_t device_id, sysarg_t state)170 int nil_device_state_msg_local(int nil_phone, device_id_t device_id, int state) 170 171 { 171 172 int index; … … 176 177 index--) { 177 178 proto = eth_protos_get_index(ð_globals.protos, index); 178 if ( (proto) && (proto->sess)) {179 il_device_state_msg(proto-> sess, device_id, state,179 if (proto && proto->phone) { 180 il_device_state_msg(proto->phone, device_id, state, 180 181 proto->service); 181 182 } … … 186 187 } 187 188 188 int nil_initialize( async_sess_t *sess)189 int nil_initialize(int net_phone) 189 190 { 190 191 int rc; … … 195 196 fibril_rwlock_write_lock(ð_globals.devices_lock); 196 197 fibril_rwlock_write_lock(ð_globals.protos_lock); 197 eth_globals.net_ sess = sess;198 eth_globals.net_phone = net_phone; 198 199 199 200 eth_globals.broadcast_addr = … … 222 223 } 223 224 224 /** Process IPC messages from the registered device driver modules in an225 /** Processes IPC messages from the registered device driver modules in an 225 226 * infinite loop. 226 227 * 227 * @param[in] iid Message identifier. 228 * @param[in,out] icall Message parameters. 229 * @param[in] arg Local argument. 230 * 231 */ 232 static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg) 228 * @param[in] iid The message identifier. 229 * @param[in,out] icall The message parameters. 230 */ 231 static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall) 233 232 { 234 233 packet_t *packet; … … 238 237 switch (IPC_GET_IMETHOD(*icall)) { 239 238 case NET_NIL_DEVICE_STATE: 240 nil_device_state_msg_local( IPC_GET_DEVICE(*icall),239 nil_device_state_msg_local(0, IPC_GET_DEVICE(*icall), 241 240 IPC_GET_STATE(*icall)); 242 241 async_answer_0(iid, EOK); 243 242 break; 244 243 case NET_NIL_RECEIVED: 245 rc = packet_translate_remote(eth_globals.net_ sess,244 rc = packet_translate_remote(eth_globals.net_phone, 246 245 &packet, IPC_GET_PACKET(*icall)); 247 246 if (rc == EOK) 248 rc = nil_received_msg_local( IPC_GET_DEVICE(*icall),249 packet, 0);247 rc = nil_received_msg_local(0, 248 IPC_GET_DEVICE(*icall), packet, 0); 250 249 251 250 async_answer_0(iid, (sysarg_t) rc); … … 323 322 proto = eth_protos_get_index(ð_globals.protos, 324 323 index); 325 if (proto-> sess) {326 il_mtu_changed_msg(proto-> sess,324 if (proto->phone) { 325 il_mtu_changed_msg(proto->phone, 327 326 device->device_id, device->mtu, 328 327 proto->service); … … 348 347 349 348 configuration = &names[0]; 350 rc = net_get_device_conf_req(eth_globals.net_ sess, device->device_id,349 rc = net_get_device_conf_req(eth_globals.net_phone, device->device_id, 351 350 &configuration, count, &data); 352 351 if (rc != EOK) { … … 377 376 378 377 /* Bind the device driver */ 379 device-> sess= netif_bind_service(device->service, device->device_id,378 device->phone = netif_bind_service(device->service, device->device_id, 380 379 SERVICE_ETHERNET, eth_receiver); 381 if (device-> sess == NULL) {380 if (device->phone < 0) { 382 381 fibril_rwlock_write_unlock(ð_globals.devices_lock); 383 382 free(device); 384 return ENOENT;383 return device->phone; 385 384 } 386 385 387 386 /* Get hardware address */ 388 rc = netif_get_addr_req(device-> sess, device->device_id, &device->addr,387 rc = netif_get_addr_req(device->phone, device->device_id, &device->addr, 389 388 &device->addr_data); 390 389 if (rc != EOK) { … … 506 505 } 507 506 508 int nil_received_msg_local( device_id_t device_id, packet_t *packet,509 services_t target)507 int nil_received_msg_local(int nil_phone, device_id_t device_id, 508 packet_t *packet, services_t target) 510 509 { 511 510 eth_proto_t *proto; … … 529 528 proto = eth_process_packet(flags, packet); 530 529 if (proto) { 531 il_received_msg(proto-> sess, device_id, packet,530 il_received_msg(proto->phone, device_id, packet, 532 531 proto->service); 533 532 } else { 534 533 /* Drop invalid/unknown */ 535 pq_release_remote(eth_globals.net_ sess,534 pq_release_remote(eth_globals.net_phone, 536 535 packet_get_id(packet)); 537 536 } … … 612 611 } 613 612 614 /** Register receiving module service. 615 * 616 * Pass received packets for this service. 617 * 618 * @param[in] service Module service. 619 * @param[in] sess Service session. 620 * 621 * @return EOK on success. 622 * @return ENOENT if the service is not known. 623 * @return ENOMEM if there is not enough memory left. 624 * 625 */ 626 static int eth_register_message(services_t service, async_sess_t *sess) 613 /** Registers receiving module service. 614 * 615 * Passes received packets for this service. 616 * 617 * @param[in] service The module service. 618 * @param[in] phone The service phone. 619 * @return EOK on success. 620 * @return ENOENT if the service is not known. 621 * @return ENOMEM if there is not enough memory left. 622 */ 623 static int eth_register_message(services_t service, int phone) 627 624 { 628 625 eth_proto_t *proto; … … 637 634 proto = eth_protos_find(ð_globals.protos, protocol); 638 635 if (proto) { 639 proto-> sess = sess;636 proto->phone = phone; 640 637 fibril_rwlock_write_unlock(ð_globals.protos_lock); 641 638 return EOK; … … 649 646 proto->service = service; 650 647 proto->protocol = protocol; 651 proto-> sess = sess;648 proto->phone = phone; 652 649 653 650 index = eth_protos_add(ð_globals.protos, protocol, proto); … … 659 656 } 660 657 661 printf("%s: Protocol registered (protocol: %d, service: %d )\n",662 NAME, proto->protocol, proto->service);658 printf("%s: Protocol registered (protocol: %d, service: %d, phone: " 659 "%d)\n", NAME, proto->protocol, proto->service, proto->phone); 663 660 664 661 fibril_rwlock_write_unlock(ð_globals.protos_lock); … … 798 795 ethertype = htons(protocol_map(SERVICE_ETHERNET, sender)); 799 796 if (!ethertype) { 800 pq_release_remote(eth_globals.net_ sess, packet_get_id(packet));797 pq_release_remote(eth_globals.net_phone, packet_get_id(packet)); 801 798 return EINVAL; 802 799 } … … 819 816 if (next == packet) 820 817 packet = tmp; 821 pq_release_remote(eth_globals.net_ sess,818 pq_release_remote(eth_globals.net_phone, 822 819 packet_get_id(next)); 823 820 next = tmp; … … 829 826 /* Send packet queue */ 830 827 if (packet) { 831 netif_send_msg(device-> sess, device_id, packet,828 netif_send_msg(device->phone, device_id, packet, 832 829 SERVICE_ETHERNET); 833 830 } … … 849 846 850 847 *answer_count = 0; 851 852 if (!IPC_GET_IMETHOD(*call))848 switch (IPC_GET_IMETHOD(*call)) { 849 case IPC_M_PHONE_HUNGUP: 853 850 return EOK; 854 851 855 async_sess_t *callback =856 async_callback_receive_start(EXCHANGE_SERIALIZE, call);857 if (callback)858 return eth_register_message(NIL_GET_PROTO(*call), callback);859 860 switch (IPC_GET_IMETHOD(*call)) {861 852 case NET_NIL_DEVICE: 862 853 return eth_device_message(IPC_GET_DEVICE(*call), 863 854 IPC_GET_SERVICE(*call), IPC_GET_MTU(*call)); 864 855 case NET_NIL_SEND: 865 rc = packet_translate_remote(eth_globals.net_ sess, &packet,856 rc = packet_translate_remote(eth_globals.net_phone, &packet, 866 857 IPC_GET_PACKET(*call)); 867 858 if (rc != EOK) … … 892 883 return EOK; 893 884 return measured_strings_reply(address, 1); 885 case IPC_M_CONNECT_TO_ME: 886 return eth_register_message(NIL_GET_PROTO(*call), 887 IPC_GET_PHONE(*call)); 894 888 } 895 889
Note:
See TracChangeset
for help on using the changeset viewer.