Changes in uspace/srv/net/nil/eth/eth.c [6b82009:79ae36dd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
r6b82009 r79ae36dd 59 59 #include <packet_remote.h> 60 60 #include <nil_skel.h> 61 62 // FIXME: remove this header 63 #include <kernel/ipc/ipc_methods.h> 64 61 65 #include "eth.h" 62 66 … … 167 171 INT_MAP_IMPLEMENT(eth_protos, eth_proto_t); 168 172 169 int nil_device_state_msg_local( device_id_t device_id, sysarg_t state)173 int nil_device_state_msg_local(int nil_phone, device_id_t device_id, int state) 170 174 { 171 175 int index; … … 176 180 index--) { 177 181 proto = eth_protos_get_index(ð_globals.protos, index); 178 if ( (proto) && (proto->sess)) {179 il_device_state_msg(proto-> sess, device_id, state,182 if (proto && proto->phone) { 183 il_device_state_msg(proto->phone, device_id, state, 180 184 proto->service); 181 185 } … … 186 190 } 187 191 188 int nil_initialize( async_sess_t *sess)192 int nil_initialize(int net_phone) 189 193 { 190 194 int rc; … … 195 199 fibril_rwlock_write_lock(ð_globals.devices_lock); 196 200 fibril_rwlock_write_lock(ð_globals.protos_lock); 197 eth_globals.net_ sess = sess;201 eth_globals.net_phone = net_phone; 198 202 199 203 eth_globals.broadcast_addr = … … 222 226 } 223 227 224 /** Process IPC messages from the registered device driver modules in an228 /** Processes IPC messages from the registered device driver modules in an 225 229 * infinite loop. 226 230 * 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) 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) 233 235 { 234 236 packet_t *packet; … … 238 240 switch (IPC_GET_IMETHOD(*icall)) { 239 241 case NET_NIL_DEVICE_STATE: 240 nil_device_state_msg_local( IPC_GET_DEVICE(*icall),242 nil_device_state_msg_local(0, IPC_GET_DEVICE(*icall), 241 243 IPC_GET_STATE(*icall)); 242 244 async_answer_0(iid, EOK); 243 245 break; 244 246 case NET_NIL_RECEIVED: 245 rc = packet_translate_remote(eth_globals.net_ sess,247 rc = packet_translate_remote(eth_globals.net_phone, 246 248 &packet, IPC_GET_PACKET(*icall)); 247 249 if (rc == EOK) 248 rc = nil_received_msg_local( IPC_GET_DEVICE(*icall),249 packet, 0);250 rc = nil_received_msg_local(0, 251 IPC_GET_DEVICE(*icall), packet, 0); 250 252 251 253 async_answer_0(iid, (sysarg_t) rc); … … 323 325 proto = eth_protos_get_index(ð_globals.protos, 324 326 index); 325 if (proto-> sess) {326 il_mtu_changed_msg(proto-> sess,327 if (proto->phone) { 328 il_mtu_changed_msg(proto->phone, 327 329 device->device_id, device->mtu, 328 330 proto->service); … … 348 350 349 351 configuration = &names[0]; 350 rc = net_get_device_conf_req(eth_globals.net_ sess, device->device_id,352 rc = net_get_device_conf_req(eth_globals.net_phone, device->device_id, 351 353 &configuration, count, &data); 352 354 if (rc != EOK) { … … 377 379 378 380 /* Bind the device driver */ 379 device-> sess= netif_bind_service(device->service, device->device_id,381 device->phone = netif_bind_service(device->service, device->device_id, 380 382 SERVICE_ETHERNET, eth_receiver); 381 if (device-> sess == NULL) {383 if (device->phone < 0) { 382 384 fibril_rwlock_write_unlock(ð_globals.devices_lock); 383 385 free(device); 384 return ENOENT;386 return device->phone; 385 387 } 386 388 387 389 /* Get hardware address */ 388 rc = netif_get_addr_req(device-> sess, device->device_id, &device->addr,390 rc = netif_get_addr_req(device->phone, device->device_id, &device->addr, 389 391 &device->addr_data); 390 392 if (rc != EOK) { … … 506 508 } 507 509 508 int nil_received_msg_local( device_id_t device_id, packet_t *packet,509 services_t target)510 int nil_received_msg_local(int nil_phone, device_id_t device_id, 511 packet_t *packet, services_t target) 510 512 { 511 513 eth_proto_t *proto; … … 529 531 proto = eth_process_packet(flags, packet); 530 532 if (proto) { 531 il_received_msg(proto-> sess, device_id, packet,533 il_received_msg(proto->phone, device_id, packet, 532 534 proto->service); 533 535 } else { 534 536 /* Drop invalid/unknown */ 535 pq_release_remote(eth_globals.net_ sess,537 pq_release_remote(eth_globals.net_phone, 536 538 packet_get_id(packet)); 537 539 } … … 612 614 } 613 615 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) 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) 627 627 { 628 628 eth_proto_t *proto; … … 637 637 proto = eth_protos_find(ð_globals.protos, protocol); 638 638 if (proto) { 639 proto-> sess = sess;639 proto->phone = phone; 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-> sess = sess;651 proto->phone = phone; 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 )\n",662 NAME, proto->protocol, proto->service);661 printf("%s: Protocol registered (protocol: %d, service: %d, phone: " 662 "%d)\n", NAME, proto->protocol, proto->service, proto->phone); 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_ sess, packet_get_id(packet));800 pq_release_remote(eth_globals.net_phone, 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_ sess,821 pq_release_remote(eth_globals.net_phone, 822 822 packet_get_id(next)); 823 823 next = tmp; … … 829 829 /* Send packet queue */ 830 830 if (packet) { 831 netif_send_msg(device-> sess, device_id, packet,831 netif_send_msg(device->phone, 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 860 855 switch (IPC_GET_IMETHOD(*call)) { 861 856 case NET_NIL_DEVICE: … … 863 858 IPC_GET_SERVICE(*call), IPC_GET_MTU(*call)); 864 859 case NET_NIL_SEND: 865 rc = packet_translate_remote(eth_globals.net_ sess, &packet,860 rc = packet_translate_remote(eth_globals.net_phone, &packet, 866 861 IPC_GET_PACKET(*call)); 867 862 if (rc != EOK) … … 892 887 return EOK; 893 888 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)); 894 892 } 895 893
Note:
See TracChangeset
for help on using the changeset viewer.