Changes in uspace/srv/net/nil/eth/eth.c [6b82009:9934f7d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
r6b82009 r9934f7d 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 * @param[in] iid The message identifier. 232 * @param[in,out] icall The message parameters. 233 * @param[in] arg Local argument. 231 234 */ 232 235 static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg) … … 238 241 switch (IPC_GET_IMETHOD(*icall)) { 239 242 case NET_NIL_DEVICE_STATE: 240 nil_device_state_msg_local( IPC_GET_DEVICE(*icall),243 nil_device_state_msg_local(0, IPC_GET_DEVICE(*icall), 241 244 IPC_GET_STATE(*icall)); 242 245 async_answer_0(iid, EOK); 243 246 break; 244 247 case NET_NIL_RECEIVED: 245 rc = packet_translate_remote(eth_globals.net_ sess,248 rc = packet_translate_remote(eth_globals.net_phone, 246 249 &packet, IPC_GET_PACKET(*icall)); 247 250 if (rc == EOK) 248 rc = nil_received_msg_local( IPC_GET_DEVICE(*icall),249 packet, 0);251 rc = nil_received_msg_local(0, 252 IPC_GET_DEVICE(*icall), packet, 0); 250 253 251 254 async_answer_0(iid, (sysarg_t) rc); … … 323 326 proto = eth_protos_get_index(ð_globals.protos, 324 327 index); 325 if (proto-> sess) {326 il_mtu_changed_msg(proto-> sess,328 if (proto->phone) { 329 il_mtu_changed_msg(proto->phone, 327 330 device->device_id, device->mtu, 328 331 proto->service); … … 348 351 349 352 configuration = &names[0]; 350 rc = net_get_device_conf_req(eth_globals.net_ sess, device->device_id,353 rc = net_get_device_conf_req(eth_globals.net_phone, device->device_id, 351 354 &configuration, count, &data); 352 355 if (rc != EOK) { … … 377 380 378 381 /* Bind the device driver */ 379 device-> sess= netif_bind_service(device->service, device->device_id,382 device->phone = netif_bind_service(device->service, device->device_id, 380 383 SERVICE_ETHERNET, eth_receiver); 381 if (device-> sess == NULL) {384 if (device->phone < 0) { 382 385 fibril_rwlock_write_unlock(ð_globals.devices_lock); 383 386 free(device); 384 return ENOENT;387 return device->phone; 385 388 } 386 389 387 390 /* Get hardware address */ 388 rc = netif_get_addr_req(device-> sess, device->device_id, &device->addr,391 rc = netif_get_addr_req(device->phone, device->device_id, &device->addr, 389 392 &device->addr_data); 390 393 if (rc != EOK) { … … 506 509 } 507 510 508 int nil_received_msg_local( device_id_t device_id, packet_t *packet,509 services_t target)511 int nil_received_msg_local(int nil_phone, device_id_t device_id, 512 packet_t *packet, services_t target) 510 513 { 511 514 eth_proto_t *proto; … … 529 532 proto = eth_process_packet(flags, packet); 530 533 if (proto) { 531 il_received_msg(proto-> sess, device_id, packet,534 il_received_msg(proto->phone, device_id, packet, 532 535 proto->service); 533 536 } else { 534 537 /* Drop invalid/unknown */ 535 pq_release_remote(eth_globals.net_ sess,538 pq_release_remote(eth_globals.net_phone, 536 539 packet_get_id(packet)); 537 540 } … … 612 615 } 613 616 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) 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) 627 628 { 628 629 eth_proto_t *proto; … … 637 638 proto = eth_protos_find(ð_globals.protos, protocol); 638 639 if (proto) { 639 proto-> sess = sess;640 proto->phone = phone; 640 641 fibril_rwlock_write_unlock(ð_globals.protos_lock); 641 642 return EOK; … … 649 650 proto->service = service; 650 651 proto->protocol = protocol; 651 proto-> sess = sess;652 proto->phone = phone; 652 653 653 654 index = eth_protos_add(ð_globals.protos, protocol, proto); … … 659 660 } 660 661 661 printf("%s: Protocol registered (protocol: %d, service: %d )\n",662 NAME, proto->protocol, proto->service);662 printf("%s: Protocol registered (protocol: %d, service: %d, phone: " 663 "%d)\n", NAME, proto->protocol, proto->service, proto->phone); 663 664 664 665 fibril_rwlock_write_unlock(ð_globals.protos_lock); … … 798 799 ethertype = htons(protocol_map(SERVICE_ETHERNET, sender)); 799 800 if (!ethertype) { 800 pq_release_remote(eth_globals.net_ sess, packet_get_id(packet));801 pq_release_remote(eth_globals.net_phone, packet_get_id(packet)); 801 802 return EINVAL; 802 803 } … … 819 820 if (next == packet) 820 821 packet = tmp; 821 pq_release_remote(eth_globals.net_ sess,822 pq_release_remote(eth_globals.net_phone, 822 823 packet_get_id(next)); 823 824 next = tmp; … … 829 830 /* Send packet queue */ 830 831 if (packet) { 831 netif_send_msg(device-> sess, device_id, packet,832 netif_send_msg(device->phone, device_id, packet, 832 833 SERVICE_ETHERNET); 833 834 } … … 853 854 return EOK; 854 855 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 856 switch (IPC_GET_IMETHOD(*call)) { 861 857 case NET_NIL_DEVICE: … … 863 859 IPC_GET_SERVICE(*call), IPC_GET_MTU(*call)); 864 860 case NET_NIL_SEND: 865 rc = packet_translate_remote(eth_globals.net_ sess, &packet,861 rc = packet_translate_remote(eth_globals.net_phone, &packet, 866 862 IPC_GET_PACKET(*call)); 867 863 if (rc != EOK) … … 892 888 return EOK; 893 889 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)); 894 893 } 895 894
Note:
See TracChangeset
for help on using the changeset viewer.