Changeset 8ff0bd2 in mainline for uspace/srv/net/nil/eth/eth.c
- Timestamp:
- 2011-09-04T11:30:58Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 03bc76a
- Parents:
- d2c67e7 (diff), deac215e (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
rd2c67e7 r8ff0bd2 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 */ 234 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) 235 233 { 236 234 packet_t *packet; … … 240 238 switch (IPC_GET_IMETHOD(*icall)) { 241 239 case NET_NIL_DEVICE_STATE: 242 nil_device_state_msg_local( 0,IPC_GET_DEVICE(*icall),240 nil_device_state_msg_local(IPC_GET_DEVICE(*icall), 243 241 IPC_GET_STATE(*icall)); 244 242 async_answer_0(iid, EOK); 245 243 break; 246 244 case NET_NIL_RECEIVED: 247 rc = packet_translate_remote(eth_globals.net_ phone,245 rc = packet_translate_remote(eth_globals.net_sess, 248 246 &packet, IPC_GET_PACKET(*icall)); 249 247 if (rc == EOK) 250 rc = nil_received_msg_local( 0,251 IPC_GET_DEVICE(*icall),packet, 0);248 rc = nil_received_msg_local(IPC_GET_DEVICE(*icall), 249 packet, 0); 252 250 253 251 async_answer_0(iid, (sysarg_t) rc); … … 325 323 proto = eth_protos_get_index(ð_globals.protos, 326 324 index); 327 if (proto-> phone) {328 il_mtu_changed_msg(proto-> phone,325 if (proto->sess) { 326 il_mtu_changed_msg(proto->sess, 329 327 device->device_id, device->mtu, 330 328 proto->service); … … 350 348 351 349 configuration = &names[0]; 352 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, 353 351 &configuration, count, &data); 354 352 if (rc != EOK) { … … 379 377 380 378 /* Bind the device driver */ 381 device-> phone= netif_bind_service(device->service, device->device_id,379 device->sess = netif_bind_service(device->service, device->device_id, 382 380 SERVICE_ETHERNET, eth_receiver); 383 if (device-> phone < 0) {381 if (device->sess == NULL) { 384 382 fibril_rwlock_write_unlock(ð_globals.devices_lock); 385 383 free(device); 386 return device->phone;384 return ENOENT; 387 385 } 388 386 389 387 /* Get hardware address */ 390 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, 391 389 &device->addr_data); 392 390 if (rc != EOK) { … … 508 506 } 509 507 510 int nil_received_msg_local( int nil_phone, device_id_t device_id,511 packet_t *packet,services_t target)508 int nil_received_msg_local(device_id_t device_id, packet_t *packet, 509 services_t target) 512 510 { 513 511 eth_proto_t *proto; … … 531 529 proto = eth_process_packet(flags, packet); 532 530 if (proto) { 533 il_received_msg(proto-> phone, device_id, packet,531 il_received_msg(proto->sess, device_id, packet, 534 532 proto->service); 535 533 } else { 536 534 /* Drop invalid/unknown */ 537 pq_release_remote(eth_globals.net_ phone,535 pq_release_remote(eth_globals.net_sess, 538 536 packet_get_id(packet)); 539 537 } … … 614 612 } 615 613 616 /** Registers receiving module service. 617 * 618 * Passes received packets for this service. 619 * 620 * @param[in] service The module service. 621 * @param[in] phone The service phone. 622 * @return EOK on success. 623 * @return ENOENT if the service is not known. 624 * @return ENOMEM if there is not enough memory left. 625 */ 626 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) 627 627 { 628 628 eth_proto_t *proto; … … 637 637 proto = eth_protos_find(ð_globals.protos, protocol); 638 638 if (proto) { 639 proto-> phone = phone;639 proto->sess = sess; 640 640 fibril_rwlock_write_unlock(ð_globals.protos_lock); 641 641 return EOK; … … 649 649 proto->service = service; 650 650 proto->protocol = protocol; 651 proto-> phone = phone;651 proto->sess = sess; 652 652 653 653 index = eth_protos_add(ð_globals.protos, protocol, proto); … … 659 659 } 660 660 661 printf("%s: Protocol registered (protocol: %d, service: %d , phone: "662 "%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); 663 663 664 664 fibril_rwlock_write_unlock(ð_globals.protos_lock); … … 798 798 ethertype = htons(protocol_map(SERVICE_ETHERNET, sender)); 799 799 if (!ethertype) { 800 pq_release_remote(eth_globals.net_ phone, packet_get_id(packet));800 pq_release_remote(eth_globals.net_sess, packet_get_id(packet)); 801 801 return EINVAL; 802 802 } … … 819 819 if (next == packet) 820 820 packet = tmp; 821 pq_release_remote(eth_globals.net_ phone,821 pq_release_remote(eth_globals.net_sess, 822 822 packet_get_id(next)); 823 823 next = tmp; … … 829 829 /* Send packet queue */ 830 830 if (packet) { 831 netif_send_msg(device-> phone, device_id, packet,831 netif_send_msg(device->sess, device_id, packet, 832 832 SERVICE_ETHERNET); 833 833 } … … 853 853 return EOK; 854 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 855 860 switch (IPC_GET_IMETHOD(*call)) { 856 861 case NET_NIL_DEVICE: … … 858 863 IPC_GET_SERVICE(*call), IPC_GET_MTU(*call)); 859 864 case NET_NIL_SEND: 860 rc = packet_translate_remote(eth_globals.net_ phone, &packet,865 rc = packet_translate_remote(eth_globals.net_sess, &packet, 861 866 IPC_GET_PACKET(*call)); 862 867 if (rc != EOK) … … 887 892 return EOK; 888 893 return measured_strings_reply(address, 1); 889 case IPC_M_CONNECT_TO_ME:890 return eth_register_message(NIL_GET_PROTO(*call),891 IPC_GET_PHONE(*call));892 894 } 893 895
Note:
See TracChangeset
for help on using the changeset viewer.