Changeset 26e7d6d in mainline for uspace/srv/net/nil/eth/eth.c
- Timestamp:
- 2011-09-19T16:31:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a347a11
- Parents:
- 3842a955 (diff), 086290d (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
r3842a955 r26e7d6d 59 59 #include <packet_remote.h> 60 60 #include <nil_skel.h> 61 62 // FIXME: remove this header63 #include <kernel/ipc/ipc_methods.h>64 65 61 #include "eth.h" 66 62 … … 171 167 INT_MAP_IMPLEMENT(eth_protos, eth_proto_t); 172 168 173 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) 174 170 { 175 171 int index; … … 180 176 index--) { 181 177 proto = eth_protos_get_index(ð_globals.protos, index); 182 if ( proto && proto->phone) {183 il_device_state_msg(proto-> phone, device_id, state,178 if ((proto) && (proto->sess)) { 179 il_device_state_msg(proto->sess, device_id, state, 184 180 proto->service); 185 181 } … … 190 186 } 191 187 192 int nil_initialize( int net_phone)188 int nil_initialize(async_sess_t *sess) 193 189 { 194 190 int rc; … … 199 195 fibril_rwlock_write_lock(ð_globals.devices_lock); 200 196 fibril_rwlock_write_lock(ð_globals.protos_lock); 201 eth_globals.net_ phone = net_phone;197 eth_globals.net_sess = sess; 202 198 203 199 eth_globals.broadcast_addr = … … 226 222 } 227 223 228 /** Process esIPC messages from the registered device driver modules in an224 /** Process IPC messages from the registered device driver modules in an 229 225 * infinite loop. 230 226 * 231 * @param[in] iid The message identifier. 232 * @param[in,out] icall The message parameters. 233 * @param[in] arg Local argument. 227 * @param[in] iid Message identifier. 228 * @param[in,out] icall Message parameters. 229 * @param[in] arg Local argument. 230 * 234 231 */ 235 232 static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg) … … 241 238 switch (IPC_GET_IMETHOD(*icall)) { 242 239 case NET_NIL_DEVICE_STATE: 243 nil_device_state_msg_local( 0,IPC_GET_DEVICE(*icall),240 nil_device_state_msg_local(IPC_GET_DEVICE(*icall), 244 241 IPC_GET_STATE(*icall)); 245 242 async_answer_0(iid, EOK); 246 243 break; 247 244 case NET_NIL_RECEIVED: 248 rc = packet_translate_remote(eth_globals.net_ phone,245 rc = packet_translate_remote(eth_globals.net_sess, 249 246 &packet, IPC_GET_PACKET(*icall)); 250 247 if (rc == EOK) 251 rc = nil_received_msg_local( 0,252 IPC_GET_DEVICE(*icall),packet, 0);248 rc = nil_received_msg_local(IPC_GET_DEVICE(*icall), 249 packet, 0); 253 250 254 251 async_answer_0(iid, (sysarg_t) rc); … … 326 323 proto = eth_protos_get_index(ð_globals.protos, 327 324 index); 328 if (proto-> phone) {329 il_mtu_changed_msg(proto-> phone,325 if (proto->sess) { 326 il_mtu_changed_msg(proto->sess, 330 327 device->device_id, device->mtu, 331 328 proto->service); … … 351 348 352 349 configuration = &names[0]; 353 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, 354 351 &configuration, count, &data); 355 352 if (rc != EOK) { … … 380 377 381 378 /* Bind the device driver */ 382 device-> phone= netif_bind_service(device->service, device->device_id,379 device->sess = netif_bind_service(device->service, device->device_id, 383 380 SERVICE_ETHERNET, eth_receiver); 384 if (device-> phone < 0) {381 if (device->sess == NULL) { 385 382 fibril_rwlock_write_unlock(ð_globals.devices_lock); 386 383 free(device); 387 return device->phone;384 return ENOENT; 388 385 } 389 386 390 387 /* Get hardware address */ 391 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, 392 389 &device->addr_data); 393 390 if (rc != EOK) { … … 509 506 } 510 507 511 int nil_received_msg_local( int nil_phone, device_id_t device_id,512 packet_t *packet,services_t target)508 int nil_received_msg_local(device_id_t device_id, packet_t *packet, 509 services_t target) 513 510 { 514 511 eth_proto_t *proto; … … 532 529 proto = eth_process_packet(flags, packet); 533 530 if (proto) { 534 il_received_msg(proto-> phone, device_id, packet,531 il_received_msg(proto->sess, device_id, packet, 535 532 proto->service); 536 533 } else { 537 534 /* Drop invalid/unknown */ 538 pq_release_remote(eth_globals.net_ phone,535 pq_release_remote(eth_globals.net_sess, 539 536 packet_get_id(packet)); 540 537 } … … 615 612 } 616 613 617 /** Registers receiving module service. 618 * 619 * Passes received packets for this service. 620 * 621 * @param[in] service The module service. 622 * @param[in] phone The service phone. 623 * @return EOK on success. 624 * @return ENOENT if the service is not known. 625 * @return ENOMEM if there is not enough memory left. 626 */ 627 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) 628 627 { 629 628 eth_proto_t *proto; … … 638 637 proto = eth_protos_find(ð_globals.protos, protocol); 639 638 if (proto) { 640 proto-> phone = phone;639 proto->sess = sess; 641 640 fibril_rwlock_write_unlock(ð_globals.protos_lock); 642 641 return EOK; … … 650 649 proto->service = service; 651 650 proto->protocol = protocol; 652 proto-> phone = phone;651 proto->sess = sess; 653 652 654 653 index = eth_protos_add(ð_globals.protos, protocol, proto); … … 660 659 } 661 660 662 printf("%s: Protocol registered (protocol: %d, service: %d , phone: "663 "%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); 664 663 665 664 fibril_rwlock_write_unlock(ð_globals.protos_lock); … … 799 798 ethertype = htons(protocol_map(SERVICE_ETHERNET, sender)); 800 799 if (!ethertype) { 801 pq_release_remote(eth_globals.net_ phone, packet_get_id(packet));800 pq_release_remote(eth_globals.net_sess, packet_get_id(packet)); 802 801 return EINVAL; 803 802 } … … 820 819 if (next == packet) 821 820 packet = tmp; 822 pq_release_remote(eth_globals.net_ phone,821 pq_release_remote(eth_globals.net_sess, 823 822 packet_get_id(next)); 824 823 next = tmp; … … 830 829 /* Send packet queue */ 831 830 if (packet) { 832 netif_send_msg(device-> phone, device_id, packet,831 netif_send_msg(device->sess, device_id, packet, 833 832 SERVICE_ETHERNET); 834 833 } … … 854 853 return EOK; 855 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 856 860 switch (IPC_GET_IMETHOD(*call)) { 857 861 case NET_NIL_DEVICE: … … 859 863 IPC_GET_SERVICE(*call), IPC_GET_MTU(*call)); 860 864 case NET_NIL_SEND: 861 rc = packet_translate_remote(eth_globals.net_ phone, &packet,865 rc = packet_translate_remote(eth_globals.net_sess, &packet, 862 866 IPC_GET_PACKET(*call)); 863 867 if (rc != EOK) … … 888 892 return EOK; 889 893 return measured_strings_reply(address, 1); 890 case IPC_M_CONNECT_TO_ME:891 return eth_register_message(NIL_GET_PROTO(*call),892 IPC_GET_PHONE(*call));893 894 } 894 895
Note:
See TracChangeset
for help on using the changeset viewer.