Changeset 6b82009 in mainline for uspace/lib/net/netif
- Timestamp:
- 2011-06-22T20:41:41Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ef09a7a
- Parents:
- 55091847
- Location:
- uspace/lib/net/netif
- Files:
-
- 2 edited
-
netif_remote.c (modified) (11 diffs)
-
netif_skel.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/netif/netif_remote.c
r55091847 r6b82009 38 38 #include <packet_client.h> 39 39 #include <generic.h> 40 #include <async_obsolete.h>41 40 #include <ipc/services.h> 42 41 #include <ipc/netif.h> 43 44 42 #include <net/modules.h> 45 43 #include <adt/measured_strings.h> … … 49 47 /** Return the device local hardware address. 50 48 * 51 * @param[in] netif_phone Network interface phone.52 * @param[in] device_id Device identifier.53 * @param[out] address Device local hardware address.54 * @param[out] data Address data.49 * @param[in] sess Network interface session. 50 * @param[in] device_id Device identifier. 51 * @param[out] address Device local hardware address. 52 * @param[out] data Address data. 55 53 * 56 54 * @return EOK on success. … … 61 59 * 62 60 */ 63 int netif_get_addr_req( int netif_phone, device_id_t device_id,61 int netif_get_addr_req(async_sess_t *sess, device_id_t device_id, 64 62 measured_string_t **address, uint8_t **data) 65 63 { 66 return generic_get_addr_req( netif_phone, NET_NETIF_GET_ADDR, device_id,64 return generic_get_addr_req(sess, NET_NETIF_GET_ADDR, device_id, 67 65 address, data); 68 66 } … … 70 68 /** Probe the existence of the device. 71 69 * 72 * @param[in] netif_phone Network interface phone.73 * @param[in] device_id Device identifier.74 * @param[in] irq Device interrupt number.75 * @param[in] io Device input/output address.70 * @param[in] sess Network interface session. 71 * @param[in] device_id Device identifier. 72 * @param[in] irq Device interrupt number. 73 * @param[in] io Device input/output address. 76 74 * 77 75 * @return EOK on success. … … 80 78 * 81 79 */ 82 int netif_probe_req( int netif_phone, device_id_t device_id, int irq, void *io)80 int netif_probe_req(async_sess_t *sess, device_id_t device_id, int irq, void *io) 83 81 { 84 return async_obsolete_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, 82 async_exch_t *exch = async_exchange_begin(sess); 83 int rc = async_req_3_0(exch, NET_NETIF_PROBE, device_id, (sysarg_t) irq, 85 84 (sysarg_t) io); 85 async_exchange_end(exch); 86 87 return rc; 86 88 } 87 89 88 90 /** Send the packet queue. 89 91 * 90 * @param[in] netif_phone Network interface phone.91 * @param[in] device_id Device identifier.92 * @param[in] packet Packet queue.93 * @param[in] sender Sending module service.92 * @param[in] sess Network interface session. 93 * @param[in] device_id Device identifier. 94 * @param[in] packet Packet queue. 95 * @param[in] sender Sending module service. 94 96 * 95 97 * @return EOK on success. … … 98 100 * 99 101 */ 100 int netif_send_msg( int netif_phone, device_id_t device_id, packet_t *packet,102 int netif_send_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet, 101 103 services_t sender) 102 104 { 103 return generic_send_msg_remote( netif_phone, NET_NETIF_SEND, device_id,105 return generic_send_msg_remote(sess, NET_NETIF_SEND, device_id, 104 106 packet_get_id(packet), sender, 0); 105 107 } … … 107 109 /** Start the device. 108 110 * 109 * @param[in] netif_phone Network interface phone.110 * @param[in] device_id Device identifier.111 * @param[in] sess Network interface session. 112 * @param[in] device_id Device identifier. 111 113 * 112 114 * @return EOK on success. … … 117 119 * 118 120 */ 119 int netif_start_req( int netif_phone, device_id_t device_id)121 int netif_start_req(async_sess_t *sess, device_id_t device_id) 120 122 { 121 return async_obsolete_req_1_0(netif_phone, NET_NETIF_START, device_id); 123 async_exch_t *exch = async_exchange_begin(sess); 124 int rc = async_req_1_0(exch, NET_NETIF_START, device_id); 125 async_exchange_end(exch); 126 127 return rc; 122 128 } 123 129 124 130 /** Stop the device. 125 131 * 126 * @param[in] netif_phone Network interface phone.127 * @param[in] device_id Device identifier.132 * @param[in] sess Network interface session. 133 * @param[in] device_id Device identifier. 128 134 * 129 135 * @return EOK on success. … … 134 140 * 135 141 */ 136 int netif_stop_req( int netif_phone, device_id_t device_id)142 int netif_stop_req(async_sess_t *sess, device_id_t device_id) 137 143 { 138 return async_obsolete_req_1_0(netif_phone, NET_NETIF_STOP, device_id); 144 async_exch_t *exch = async_exchange_begin(sess); 145 int rc = async_req_1_0(exch, NET_NETIF_STOP, device_id); 146 async_exchange_end(exch); 147 148 return rc; 139 149 } 140 150 141 151 /** Return the device usage statistics. 142 152 * 143 * @param[in] netif_phone Network interface phone.144 * @param[in] device_idDevice identifier.145 * @param[out] stats Device usage statistics.153 * @param[in] sess Network interface session. 154 * @param[in] device_id Device identifier. 155 * @param[out] stats Device usage statistics. 146 156 * 147 157 * @return EOK on success. 148 158 * 149 159 */ 150 int netif_stats_req( int netif_phone, device_id_t device_id,160 int netif_stats_req(async_sess_t *sess, device_id_t device_id, 151 161 device_stats_t *stats) 152 162 { … … 154 164 return EBADMEM; 155 165 156 aid_t message_id = async_obsolete_send_1(netif_phone, NET_NETIF_STATS, 166 async_exch_t *exch = async_exchange_begin(sess); 167 aid_t message_id = async_send_1(exch, NET_NETIF_STATS, 157 168 (sysarg_t) device_id, NULL); 158 async_obsolete_data_read_start(netif_phone, stats, sizeof(*stats)); 169 async_data_read_start(exch, stats, sizeof(*stats)); 170 async_exchange_end(exch); 159 171 160 172 sysarg_t result; … … 169 181 * register the message receiver. 170 182 * 171 * @param[in] service The network interface module service.172 * @param[in] device_id The device identifier.173 * @param[in] me The requesting module service.174 * @param[in] receiver The message receiver.183 * @param[in] service Network interface module service. 184 * @param[in] device_id Device identifier. 185 * @param[in] me Requesting module service. 186 * @param[in] receiver Message receiver. 175 187 * 176 * @return The phone of the needed service. 177 * @return EOK on success. 178 * @return Other error codes as defined for the bind_service() 179 * function. 188 * @return Session to the needed service. 189 * @return NULL on failure. 180 190 * 181 191 */ 182 intnetif_bind_service(services_t service, device_id_t device_id,192 async_sess_t *netif_bind_service(services_t service, device_id_t device_id, 183 193 services_t me, async_client_conn_t receiver) 184 194 { -
uspace/lib/net/netif/netif_skel.c
r55091847 r6b82009 54 54 #include <nil_remote.h> 55 55 56 // FIXME: remove this header57 #include <kernel/ipc/ipc_methods.h>58 59 56 DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t); 60 57 … … 64 61 /** Probe the existence of the device. 65 62 * 66 * @param[in] netif_phone Network interface phone.67 63 * @param[in] device_id Device identifier. 68 64 * @param[in] irq Device interrupt number. … … 74 70 * 75 71 */ 76 static int netif_probe_req_local(int netif_phone, device_id_t device_id, 77 int irq, void *io) 72 static int netif_probe_req_local(device_id_t device_id, int irq, void *io) 78 73 { 79 74 fibril_rwlock_write_lock(&netif_globals.lock); … … 86 81 /** Send the packet queue. 87 82 * 88 * @param[in] netif_phone Network interface phone.89 83 * @param[in] device_id Device identifier. 90 84 * @param[in] packet Packet queue. … … 96 90 * 97 91 */ 98 static int netif_send_msg_local( int netif_phone, device_id_t device_id,99 packet_t *packet,services_t sender)92 static int netif_send_msg_local(device_id_t device_id, packet_t *packet, 93 services_t sender) 100 94 { 101 95 fibril_rwlock_write_lock(&netif_globals.lock); … … 108 102 /** Start the device. 109 103 * 110 * @param[in] netif_phone Network interface phone.111 104 * @param[in] device_id Device identifier. 112 105 * … … 118 111 * 119 112 */ 120 static int netif_start_req_local( int netif_phone,device_id_t device_id)113 static int netif_start_req_local(device_id_t device_id) 121 114 { 122 115 fibril_rwlock_write_lock(&netif_globals.lock); … … 131 124 int result = netif_start_message(device); 132 125 if (result > NETIF_NULL) { 133 int phone = device->nil_phone; 134 nil_device_state_msg(phone, device_id, result); 126 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 135 127 fibril_rwlock_write_unlock(&netif_globals.lock); 136 128 return EOK; … … 144 136 /** Stop the device. 145 137 * 146 * @param[in] netif_phone Network interface phone.147 138 * @param[in] device_id Device identifier. 148 139 * … … 154 145 * 155 146 */ 156 static int netif_stop_req_local( int netif_phone,device_id_t device_id)147 static int netif_stop_req_local(device_id_t device_id) 157 148 { 158 149 fibril_rwlock_write_lock(&netif_globals.lock); … … 167 158 int result = netif_stop_message(device); 168 159 if (result > NETIF_NULL) { 169 int phone = device->nil_phone; 170 nil_device_state_msg(phone, device_id, result); 160 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 171 161 fibril_rwlock_write_unlock(&netif_globals.lock); 172 162 return EOK; … … 222 212 void netif_pq_release(packet_id_t packet_id) 223 213 { 224 pq_release_remote(netif_globals. net_phone, packet_id);214 pq_release_remote(netif_globals.sess, packet_id); 225 215 } 226 216 … … 235 225 packet_t *netif_packet_get_1(size_t content) 236 226 { 237 return packet_get_1_remote(netif_globals.net_phone, content); 238 } 239 240 /** Register the device notification receiver, 241 * 242 * Register a network interface layer module as the device 243 * notification receiver. 244 * 245 * @param[in] device_id Device identifier. 246 * @param[in] phone Network interface layer module phone. 247 * 248 * @return EOK on success. 249 * @return ENOENT if there is no such device. 250 * @return ELIMIT if there is another module registered. 251 * 252 */ 253 static int register_message(device_id_t device_id, int phone) 254 { 255 netif_device_t *device; 256 int rc = find_device(device_id, &device); 257 if (rc != EOK) 258 return rc; 259 260 if (device->nil_phone >= 0) 261 return ELIMIT; 262 263 device->nil_phone = phone; 264 return EOK; 227 return packet_get_1_remote(netif_globals.sess, content); 265 228 } 266 229 … … 296 259 switch (IPC_GET_IMETHOD(*call)) { 297 260 case NET_NETIF_PROBE: 298 return netif_probe_req_local( 0,IPC_GET_DEVICE(*call),261 return netif_probe_req_local(IPC_GET_DEVICE(*call), 299 262 NETIF_GET_IRQ(*call), NETIF_GET_IO(*call)); 300 263 301 case IPC_M_CONNECT_TO_ME:302 fibril_rwlock_write_lock(&netif_globals.lock);303 304 rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));305 306 fibril_rwlock_write_unlock(&netif_globals.lock);307 return rc;308 309 264 case NET_NETIF_SEND: 310 rc = packet_translate_remote(netif_globals. net_phone, &packet,265 rc = packet_translate_remote(netif_globals.sess, &packet, 311 266 IPC_GET_PACKET(*call)); 312 267 if (rc != EOK) 313 268 return rc; 314 269 315 return netif_send_msg_local( 0,IPC_GET_DEVICE(*call), packet,270 return netif_send_msg_local(IPC_GET_DEVICE(*call), packet, 316 271 IPC_GET_SENDER(*call)); 317 272 318 273 case NET_NETIF_START: 319 return netif_start_req_local( 0,IPC_GET_DEVICE(*call));274 return netif_start_req_local(IPC_GET_DEVICE(*call)); 320 275 321 276 case NET_NETIF_STATS: … … 343 298 344 299 case NET_NETIF_STOP: 345 return netif_stop_req_local( 0,IPC_GET_DEVICE(*call));300 return netif_stop_req_local(IPC_GET_DEVICE(*call)); 346 301 347 302 case NET_NETIF_GET_ADDR: … … 403 358 * messages in an infinite loop. 404 359 * 360 * @param[in] nil_service Network interface layer service. 361 * 405 362 * @return EOK on success. 406 363 * @return Other error codes as defined for each specific module … … 408 365 * 409 366 */ 410 int netif_module_start( void)367 int netif_module_start(sysarg_t nil_service) 411 368 { 412 369 async_set_client_connection(netif_client_connection); 413 370 414 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 371 netif_globals.sess = connect_to_service(SERVICE_NETWORKING); 372 netif_globals.nil_sess = connect_to_service(nil_service); 415 373 netif_device_map_initialize(&netif_globals.device_map); 416 374
Note:
See TracChangeset
for help on using the changeset viewer.
