Changeset a33f0a6 in mainline for uspace/srv/net/nil/eth/eth.c
- Timestamp:
- 2011-08-03T17:34:57Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1940326
- Parents:
- 52a79081 (diff), 3fab770 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
r52a79081 ra33f0a6 59 59 #include <packet_remote.h> 60 60 #include <nil_skel.h> 61 62 61 #include "eth.h" 63 62 … … 168 167 INT_MAP_IMPLEMENT(eth_protos, eth_proto_t); 169 168 170 int nil_device_state_msg_local( int nil_phone, device_id_t device_id, int state)169 int nil_device_state_msg_local(device_id_t device_id, sysarg_t state) 171 170 { 172 171 int index; … … 177 176 index--) { 178 177 proto = eth_protos_get_index(ð_globals.protos, index); 179 if ( proto && proto->phone) {180 il_device_state_msg(proto-> phone, device_id, state,178 if ((proto) && (proto->sess)) { 179 il_device_state_msg(proto->sess, device_id, state, 181 180 proto->service); 182 181 } … … 187 186 } 188 187 189 int nil_initialize( int net_phone)188 int nil_initialize(async_sess_t *sess) 190 189 { 191 190 int rc; … … 196 195 fibril_rwlock_write_lock(ð_globals.devices_lock); 197 196 fibril_rwlock_write_lock(ð_globals.protos_lock); 198 eth_globals.net_ phone = net_phone;197 eth_globals.net_sess = sess; 199 198 200 199 eth_globals.broadcast_addr = … … 223 222 } 224 223 225 /** Process esIPC messages from the registered device driver modules in an224 /** Process IPC messages from the registered device driver modules in an 226 225 * infinite loop. 227 226 * 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) 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) 232 233 { 233 234 packet_t *packet; … … 237 238 switch (IPC_GET_IMETHOD(*icall)) { 238 239 case NET_NIL_DEVICE_STATE: 239 nil_device_state_msg_local( 0,IPC_GET_DEVICE(*icall),240 nil_device_state_msg_local(IPC_GET_DEVICE(*icall), 240 241 IPC_GET_STATE(*icall)); 241 242 async_answer_0(iid, EOK); 242 243 break; 243 244 case NET_NIL_RECEIVED: 244 rc = packet_translate_remote(eth_globals.net_ phone,245 rc = packet_translate_remote(eth_globals.net_sess, 245 246 &packet, IPC_GET_PACKET(*icall)); 246 247 if (rc == EOK) 247 rc = nil_received_msg_local( 0,248 IPC_GET_DEVICE(*icall),packet, 0);248 rc = nil_received_msg_local(IPC_GET_DEVICE(*icall), 249 packet, 0); 249 250 250 251 async_answer_0(iid, (sysarg_t) rc); … … 322 323 proto = eth_protos_get_index(ð_globals.protos, 323 324 index); 324 if (proto-> phone) {325 il_mtu_changed_msg(proto-> phone,325 if (proto->sess) { 326 il_mtu_changed_msg(proto->sess, 326 327 device->device_id, device->mtu, 327 328 proto->service); … … 347 348 348 349 configuration = &names[0]; 349 rc = net_get_device_conf_req(eth_globals.net_ phone, device->device_id,350 rc = net_get_device_conf_req(eth_globals.net_sess, device->device_id, 350 351 &configuration, count, &data); 351 352 if (rc != EOK) { … … 376 377 377 378 /* Bind the device driver */ 378 device-> phone= netif_bind_service(device->service, device->device_id,379 device->sess = netif_bind_service(device->service, device->device_id, 379 380 SERVICE_ETHERNET, eth_receiver); 380 if (device-> phone < 0) {381 if (device->sess == NULL) { 381 382 fibril_rwlock_write_unlock(ð_globals.devices_lock); 382 383 free(device); 383 return device->phone;384 return ENOENT; 384 385 } 385 386 386 387 /* Get hardware address */ 387 rc = netif_get_addr_req(device-> phone, device->device_id, &device->addr,388 rc = netif_get_addr_req(device->sess, device->device_id, &device->addr, 388 389 &device->addr_data); 389 390 if (rc != EOK) { … … 505 506 } 506 507 507 int nil_received_msg_local( int nil_phone, device_id_t device_id,508 packet_t *packet,services_t target)508 int nil_received_msg_local(device_id_t device_id, packet_t *packet, 509 services_t target) 509 510 { 510 511 eth_proto_t *proto; … … 528 529 proto = eth_process_packet(flags, packet); 529 530 if (proto) { 530 il_received_msg(proto-> phone, device_id, packet,531 il_received_msg(proto->sess, device_id, packet, 531 532 proto->service); 532 533 } else { 533 534 /* Drop invalid/unknown */ 534 pq_release_remote(eth_globals.net_ phone,535 pq_release_remote(eth_globals.net_sess, 535 536 packet_get_id(packet)); 536 537 } … … 611 612 } 612 613 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) 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) 624 627 { 625 628 eth_proto_t *proto; … … 634 637 proto = eth_protos_find(ð_globals.protos, protocol); 635 638 if (proto) { 636 proto-> phone = phone;639 proto->sess = sess; 637 640 fibril_rwlock_write_unlock(ð_globals.protos_lock); 638 641 return EOK; … … 646 649 proto->service = service; 647 650 proto->protocol = protocol; 648 proto-> phone = phone;651 proto->sess = sess; 649 652 650 653 index = eth_protos_add(ð_globals.protos, protocol, proto); … … 656 659 } 657 660 658 printf("%s: Protocol registered (protocol: %d, service: %d , phone: "659 "%d)\n", NAME, proto->protocol, proto->service, proto->phone);661 printf("%s: Protocol registered (protocol: %d, service: %d)\n", 662 NAME, proto->protocol, proto->service); 660 663 661 664 fibril_rwlock_write_unlock(ð_globals.protos_lock); … … 795 798 ethertype = htons(protocol_map(SERVICE_ETHERNET, sender)); 796 799 if (!ethertype) { 797 pq_release_remote(eth_globals.net_ phone, packet_get_id(packet));800 pq_release_remote(eth_globals.net_sess, packet_get_id(packet)); 798 801 return EINVAL; 799 802 } … … 816 819 if (next == packet) 817 820 packet = tmp; 818 pq_release_remote(eth_globals.net_ phone,821 pq_release_remote(eth_globals.net_sess, 819 822 packet_get_id(next)); 820 823 next = tmp; … … 826 829 /* Send packet queue */ 827 830 if (packet) { 828 netif_send_msg(device-> phone, device_id, packet,831 netif_send_msg(device->sess, device_id, packet, 829 832 SERVICE_ETHERNET); 830 833 } … … 846 849 847 850 *answer_count = 0; 851 852 if (!IPC_GET_IMETHOD(*call)) 853 return EOK; 854 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 848 860 switch (IPC_GET_IMETHOD(*call)) { 849 case IPC_M_PHONE_HUNGUP:850 return EOK;851 852 861 case NET_NIL_DEVICE: 853 862 return eth_device_message(IPC_GET_DEVICE(*call), 854 863 IPC_GET_SERVICE(*call), IPC_GET_MTU(*call)); 855 864 case NET_NIL_SEND: 856 rc = packet_translate_remote(eth_globals.net_ phone, &packet,865 rc = packet_translate_remote(eth_globals.net_sess, &packet, 857 866 IPC_GET_PACKET(*call)); 858 867 if (rc != EOK) … … 883 892 return EOK; 884 893 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));888 894 } 889 895
Note:
See TracChangeset
for help on using the changeset viewer.