Changeset 6d8455d in mainline
- Timestamp:
- 2012-01-14T11:07:34Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f302586
- Parents:
- f991b6b
- Location:
- uspace
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
rf991b6b r6d8455d 67 67 #define E1000_RECEIVE_ADDRESS 16 68 68 69 /** Maximum sending packet size */ 70 #define E1000_MAX_SEND_FRAME_SIZE 2048 69 71 /** Maximum receiving packet size */ 70 72 #define E1000_MAX_RECEIVE_PACKET_SIZE 2048 … … 125 127 void *tx_ring_virt; 126 128 127 /** Packets in tx ring */ 128 packet_t **tx_ring_packets; 129 /** Ring of TX frames, physical address */ 130 void **tx_frame_phys; 131 /** Ring of TX frames, virtual address */ 132 void **tx_frame_virt; 129 133 130 134 /** Physical rx ring address */ … … 223 227 static int e1000_on_activating(nic_t *); 224 228 static int e1000_on_stopping(nic_t *); 225 static void e1000_ write_packet(nic_t *, packet_t *);229 static void e1000_send_frame(nic_t *, void *, size_t); 226 230 227 231 /** Commands to deal with interrupt … … 1126 1130 (e1000->tx_ring_virt + offset * sizeof(e1000_tx_descriptor_t)); 1127 1131 1128 if (tx_descriptor->length) {1129 packet_t *old_packet = *(e1000->tx_ring_packets + offset);1130 if (old_packet)1131 nic_release_packet(nic, old_packet);1132 }1133 1134 1132 tx_descriptor->phys_addr = 0; 1135 1133 tx_descriptor->length = 0; … … 1522 1520 static int e1000_initialize_tx_structure(e1000_t *e1000) 1523 1521 { 1522 size_t i; 1523 1524 1524 fibril_mutex_lock(&e1000->tx_lock); 1525 1526 e1000->tx_ring_phys = NULL; 1527 e1000->tx_ring_virt = NULL; 1528 e1000->tx_frame_phys = NULL; 1529 e1000->tx_frame_virt = NULL; 1525 1530 1526 1531 int rc = dmamem_map_anonymous( … … 1529 1534 &e1000->tx_ring_virt); 1530 1535 if (rc != EOK) 1531 return rc;1536 goto error; 1532 1537 1533 1538 bzero(e1000->tx_ring_virt, 1534 1539 E1000_TX_PACKETS_COUNT * sizeof(e1000_tx_descriptor_t)); 1540 1541 e1000->tx_frame_phys = calloc(E1000_TX_PACKETS_COUNT, sizeof(void *)); 1542 e1000->tx_frame_virt = calloc(E1000_TX_PACKETS_COUNT, sizeof(void *)); 1543 1544 if (e1000->tx_frame_phys == NULL || e1000->tx_frame_virt == NULL) { 1545 rc = ENOMEM; 1546 goto error; 1547 } 1548 1549 for (i = 0; i < E1000_TX_PACKETS_COUNT; i++) { 1550 rc = dmamem_map_anonymous( 1551 E1000_MAX_SEND_FRAME_SIZE, AS_AREA_READ | AS_AREA_WRITE, 1552 0, &e1000->tx_frame_phys[i], &e1000->tx_frame_virt[i]); 1553 if (rc != EOK) 1554 goto error; 1555 } 1535 1556 1536 1557 E1000_REG_WRITE(e1000, E1000_TDBAH, … … 1539 1560 (uint32_t) PTR_TO_U64(e1000->tx_ring_phys)); 1540 1561 1541 e1000->tx_ring_packets =1542 malloc(E1000_TX_PACKETS_COUNT * sizeof(packet_t *));1543 // FIXME: Check return value1544 1545 1562 e1000_initialize_tx_registers(e1000); 1546 1563 1547 1564 fibril_mutex_unlock(&e1000->tx_lock); 1548 1565 return EOK; 1566 1567 error: 1568 if (e1000->tx_ring_virt != NULL) { 1569 dmamem_unmap_anonymous(e1000->tx_ring_virt); 1570 e1000->tx_ring_virt = NULL; 1571 } 1572 1573 if (e1000->tx_frame_phys != NULL && e1000->tx_frame_virt != NULL) { 1574 for (i = 0; i < E1000_TX_PACKETS_COUNT; i++) { 1575 if (e1000->tx_frame_virt[i] != NULL) { 1576 dmamem_unmap_anonymous(e1000->tx_frame_virt[i]); 1577 e1000->tx_frame_virt[i] = NULL; 1578 e1000->tx_frame_phys[i] = NULL; 1579 } 1580 } 1581 } 1582 1583 if (e1000->tx_frame_phys != NULL) { 1584 free(e1000->tx_frame_phys); 1585 e1000->tx_frame_phys = NULL; 1586 } 1587 1588 if (e1000->tx_frame_virt != NULL) { 1589 free(e1000->tx_frame_virt); 1590 e1000->tx_frame_phys = NULL; 1591 } 1592 1593 return rc; 1549 1594 } 1550 1595 … … 1556 1601 static void e1000_uninitialize_tx_structure(e1000_t *e1000) 1557 1602 { 1558 free(e1000->tx_ring_packets); 1603 size_t i; 1604 1605 for (i = 0; i < E1000_TX_PACKETS_COUNT; i++) { 1606 dmamem_unmap_anonymous(e1000->tx_frame_virt[i]); 1607 e1000->tx_frame_virt[i] = NULL; 1608 e1000->tx_frame_phys[i] = NULL; 1609 } 1610 1611 if (e1000->tx_frame_phys != NULL) { 1612 free(e1000->tx_frame_phys); 1613 e1000->tx_frame_phys = NULL; 1614 } 1615 1616 if (e1000->tx_frame_virt != NULL) { 1617 free(e1000->tx_frame_virt); 1618 e1000->tx_frame_phys = NULL; 1619 } 1559 1620 dmamem_unmap_anonymous(e1000->tx_ring_virt); 1560 1621 } … … 1771 1832 1772 1833 nic_set_specific(nic, e1000); 1773 nic_set_ write_packet_handler(nic, e1000_write_packet);1834 nic_set_send_frame_handler(nic, e1000_send_frame); 1774 1835 nic_set_state_change_handlers(nic, e1000_on_activating, 1775 1836 e1000_on_down, e1000_on_stopping); … … 2190 2251 } 2191 2252 2192 /** Send packet2253 /** Send frame 2193 2254 * 2194 2255 * @param nic NIC driver data structure 2195 * @param packet Packet to send 2256 * @param data Frame data 2257 * @param size Frame size in bytes 2196 2258 * 2197 2259 * @return EOK if succeed … … 2199 2261 * 2200 2262 */ 2201 static void e1000_ write_packet(nic_t *nic, packet_t *packet)2263 static void e1000_send_frame(nic_t *nic, void *data, size_t size) 2202 2264 { 2203 2265 assert(nic); … … 2217 2279 2218 2280 /* Descriptor done */ 2219 if (tx_descriptor_addr->status & TXDESCRIPTOR_STATUS_DD) {2281 if (tx_descriptor_addr->status & TXDESCRIPTOR_STATUS_DD) 2220 2282 descriptor_available = true; 2221 packet_t *old_packet = *(e1000->tx_ring_packets + tdt);2222 if (old_packet) {2223 size_t old_packet_size = packet_get_data_length(old_packet);2224 nic_dma_unlock_packet(old_packet, old_packet_size);2225 nic_release_packet(nic, old_packet);2226 }2227 }2228 2283 2229 2284 if (!descriptor_available) { … … 2233 2288 } 2234 2289 2235 size_t packet_size = packet_get_data_length(packet); 2236 2237 void *phys; 2238 int rc = nic_dma_lock_packet(packet, packet_size, &phys); 2239 if (rc != EOK) { 2240 fibril_mutex_unlock(&e1000->tx_lock); 2241 return; 2242 } 2243 2244 *(e1000->tx_ring_packets + tdt) = packet; 2245 2246 tx_descriptor_addr->phys_addr = 2247 PTR_TO_U64(phys + packet->data_start); 2248 tx_descriptor_addr->length = packet_size; 2290 memcpy(e1000->tx_frame_virt[tdt], data, size); 2291 2292 tx_descriptor_addr->phys_addr = PTR_TO_U64(e1000->tx_frame_phys[tdt]); 2293 tx_descriptor_addr->length = size; 2249 2294 2250 2295 /* -
uspace/drv/nic/lo/lo.c
rf991b6b r6d8455d 59 59 }; 60 60 61 static void lo_ write_packet(nic_t *nic_data, packet_t *packet)61 static void lo_send_frame(nic_t *nic_data, void *data, size_t size) 62 62 { 63 nic_report_send_ok(nic_data, 1, packet_get_data_length(packet)); 63 packet_t *packet; 64 int rc; 65 66 packet = nic_alloc_packet(nic_data, size); 67 if (packet == NULL) 68 return; 69 70 rc = packet_copy_data(packet, data, size); 71 if (rc != EOK) 72 return; 73 74 nic_report_send_ok(nic_data, 1, size); 64 75 nic_received_noneth_packet(nic_data, packet); 65 76 } … … 88 99 89 100 dev->driver_data = nic_data; 90 nic_set_ write_packet_handler(nic_data, lo_write_packet);101 nic_set_send_frame_handler(nic_data, lo_send_frame); 91 102 92 103 int rc = nic_connect_to_services(nic_data); -
uspace/drv/nic/ne2k/dp8390.c
rf991b6b r6d8455d 404 404 * 405 405 * @param[in,out] ne2k Network interface structure. 406 * @param[in] packet Frame to be sent. 407 * 408 */ 409 void ne2k_send(nic_t *nic_data, packet_t *packet) 406 * @param[in] data Pointer to frame data 407 * @param[in] size Frame size in bytes 408 * 409 */ 410 void ne2k_send(nic_t *nic_data, void *data, size_t size) 410 411 { 411 412 ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data); … … 419 420 fibril_condvar_wait(&ne2k->sq_cv, &ne2k->sq_mutex); 420 421 } 421 void *buf = packet_get_data(packet);422 size_t size = packet_get_data_length(packet);423 422 424 423 if ((size < ETH_MIN_PACK_SIZE) || (size > ETH_MAX_PACK_SIZE_TAGGED)) { … … 428 427 429 428 /* Upload the frame to the ethernet card */ 430 ne2k_upload(ne2k, buf, ne2k->sq.page * DP_PAGE, size);429 ne2k_upload(ne2k, data, ne2k->sq.page * DP_PAGE, size); 431 430 ne2k->sq.dirty = true; 432 431 ne2k->sq.size = size; … … 438 437 pio_write_8(ne2k->port + DP_CR, CR_TXP | CR_STA); 439 438 fibril_mutex_unlock(&ne2k->sq_mutex); 440 441 /* Relase packet */442 nic_release_packet(nic_data, packet);443 439 } 444 440 -
uspace/drv/nic/ne2k/dp8390.h
rf991b6b r6d8455d 262 262 extern int ne2k_up(ne2k_t *); 263 263 extern void ne2k_down(ne2k_t *); 264 extern void ne2k_send(nic_t *, packet_t *);264 extern void ne2k_send(nic_t *, void *, size_t); 265 265 extern void ne2k_interrupt(nic_t *, uint8_t, uint8_t); 266 266 extern packet_t *ne2k_alloc_packet(nic_t *, size_t); -
uspace/drv/nic/ne2k/ne2k.c
rf991b6b r6d8455d 343 343 return ENOMEM; 344 344 345 nic_set_ write_packet_handler(nic_data, ne2k_send);345 nic_set_send_frame_handler(nic_data, ne2k_send); 346 346 nic_set_state_change_handlers(nic_data, 347 347 ne2k_on_activating, NULL, ne2k_on_stopping); -
uspace/drv/nic/rtl8139/driver.c
rf991b6b r6d8455d 389 389 static int rtl8139_on_activated(nic_t *nic_data); 390 390 static int rtl8139_on_stopped(nic_t *nic_data); 391 static void rtl8139_ write_packet(nic_t *nic_data, packet_t *packet);391 static void rtl8139_send_frame(nic_t *nic_data, void *data, size_t size); 392 392 393 393 /** Check if the transmit buffer is busy */ … … 399 399 * 400 400 * @param nic_data The nic driver data structure 401 * @param packet The packet to send 401 * @param data Frame data 402 * @param size Frame size in bytes 402 403 * 403 404 * @return EOK if succeed, error code in the case of error 404 405 */ 405 static void rtl8139_ write_packet(nic_t *nic_data, packet_t *packet)406 static void rtl8139_send_frame(nic_t *nic_data, void *data, size_t size) 406 407 { 407 408 assert(nic_data); … … 409 410 rtl8139_t *rtl8139 = nic_get_specific(nic_data); 410 411 assert(rtl8139); 411 ddf_msg(LVL_DEBUG, "Sending packet"); 412 413 /* Get the packet data and check if it can be send */ 414 size_t packet_length = packet_get_data_length(packet); 415 void *packet_data = packet_get_data(packet); 416 417 assert(packet_data); 418 419 if ((packet_length > RTL8139_PACKET_MAX_LENGTH) || !packet_data) { 420 ddf_msg(LVL_ERROR, "Write packet length error: data %p, length %z", 421 packet_data, packet_length); 412 ddf_msg(LVL_DEBUG, "Sending frame"); 413 414 if (size > RTL8139_PACKET_MAX_LENGTH) { 415 ddf_msg(LVL_ERROR, "Send frame: frame too long, %zu bytes", 416 size); 422 417 nic_report_send_error(rtl8139->nic_data, NIC_SEC_OTHER, 1); 423 418 goto err_size; 424 419 } 425 420 426 assert(( packet_length & TSD_SIZE_MASK) == packet_length);421 assert((size & TSD_SIZE_MASK) == size); 427 422 428 423 /* Lock transmitter structure for obtaining next buffer */ … … 449 444 assert(!rtl8139_tbuf_busy(tsd)); 450 445 451 /* Write packetdata to the buffer, set the size to TSD and clear OWN bit */452 memcpy(buf_addr, packet_data, packet_length);446 /* Write frame data to the buffer, set the size to TSD and clear OWN bit */ 447 memcpy(buf_addr, data, size); 453 448 454 449 /* Set size of the data to send */ 455 450 uint32_t tsd_value = pio_read_32(tsd); 456 tsd_value = rtl8139_tsd_set_size(tsd_value, packet_length);451 tsd_value = rtl8139_tsd_set_size(tsd_value, size); 457 452 pio_write_32(tsd, tsd_value); 458 453 … … 462 457 tsd_value &= ~(uint32_t)TSD_OWN; 463 458 pio_write_32(tsd, tsd_value); 464 nic_release_packet(nic_data, packet);465 459 return; 466 460 467 461 err_busy_no_inc: 468 462 err_size: 469 nic_release_packet(nic_data, packet);470 463 return; 471 464 }; … … 1022 1015 rtl8139->nic_data = nic_data; 1023 1016 nic_set_specific(nic_data, rtl8139); 1024 nic_set_ write_packet_handler(nic_data, rtl8139_write_packet);1017 nic_set_send_frame_handler(nic_data, rtl8139_send_frame); 1025 1018 nic_set_state_change_handlers(nic_data, 1026 1019 rtl8139_on_activated, NULL, rtl8139_on_stopped); -
uspace/lib/c/generic/device/nic.c
rf991b6b r6d8455d 44 44 #include <ipc/services.h> 45 45 46 /** Send a packet through the device 47 * 48 * @param[in] dev_sess 49 * @param[in] packet_id Id of the sent packet 50 * 51 * @return EOK If the operation was successfully completed 52 * 53 */ 54 int nic_send_message(async_sess_t *dev_sess, packet_id_t packet_id) 55 { 56 async_exch_t *exch = async_exchange_begin(dev_sess); 57 int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 58 NIC_SEND_MESSAGE, packet_id); 59 async_exchange_end(exch); 60 61 return rc; 46 /** Send frame from NIC 47 * 48 * @param[in] dev_sess 49 * @param[in] data Frame data 50 * @param[in] size Frame size in bytes 51 * 52 * @return EOK If the operation was successfully completed 53 * 54 */ 55 int nic_send_frame(async_sess_t *dev_sess, void *data, size_t size) 56 { 57 async_exch_t *exch = async_exchange_begin(dev_sess); 58 59 ipc_call_t answer; 60 aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 61 NIC_SEND_MESSAGE, &answer); 62 sysarg_t retval = async_data_write_start(exch, data, size); 63 64 async_exchange_end(exch); 65 66 if (retval != EOK) { 67 async_wait_for(req, NULL); 68 return retval; 69 } 70 71 async_wait_for(req, &retval); 72 return retval; 62 73 } 63 74 -
uspace/lib/c/include/device/nic.h
rf991b6b r6d8455d 85 85 } nic_funcs_t; 86 86 87 extern int nic_send_ message(async_sess_t *, packet_id_t);87 extern int nic_send_frame(async_sess_t *, void *, size_t); 88 88 extern int nic_connect_to_nil(async_sess_t *, services_t, nic_device_id_t); 89 89 extern int nic_get_state(async_sess_t *, nic_device_state_t *); -
uspace/lib/drv/generic/remote_nic.c
rf991b6b r6d8455d 39 39 #include <errno.h> 40 40 #include <ipc/services.h> 41 #include <adt/measured_strings.h>42 41 #include <sys/time.h> 43 42 #include "ops/nic.h" 44 43 45 static void remote_nic_send_message(ddf_fun_t *dev, void *iface, 46 ipc_callid_t callid, ipc_call_t *call) 47 { 48 nic_iface_t *nic_iface = (nic_iface_t *) iface; 49 assert(nic_iface->send_message); 50 51 packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); 52 53 int rc = nic_iface->send_message(dev, packet_id); 54 async_answer_0(callid, rc); 44 static void remote_nic_send_frame(ddf_fun_t *dev, void *iface, 45 ipc_callid_t callid, ipc_call_t *call) 46 { 47 nic_iface_t *nic_iface = (nic_iface_t *) iface; 48 assert(nic_iface->send_frame); 49 50 void *data; 51 size_t size; 52 int rc; 53 54 rc = async_data_write_accept(&data, false, 0, 0, 0, &size); 55 if (rc != EOK) { 56 async_answer_0(callid, EINVAL); 57 return; 58 } 59 60 rc = nic_iface->send_frame(dev, data, size); 61 async_answer_0(callid, rc); 62 free(data); 55 63 } 56 64 … … 1194 1202 */ 1195 1203 static remote_iface_func_ptr_t remote_nic_iface_ops[] = { 1196 &remote_nic_send_ message,1204 &remote_nic_send_frame, 1197 1205 &remote_nic_connect_to_nil, 1198 1206 &remote_nic_get_state, -
uspace/lib/drv/include/ops/nic.h
rf991b6b r6d8455d 37 37 #define LIBDRV_OPS_NIC_H_ 38 38 39 #include <net/packet.h>40 39 #include <ipc/services.h> 41 40 #include <net/device.h> … … 46 45 typedef struct nic_iface { 47 46 /** Mandatory methods */ 48 int (*send_ message)(ddf_fun_t *, packet_id_t);47 int (*send_frame)(ddf_fun_t *, void *, size_t); 49 48 int (*connect_to_nil)(ddf_fun_t *, services_t, nic_device_id_t); 50 49 int (*get_state)(ddf_fun_t *, nic_device_state_t *); -
uspace/lib/nic/include/nic.h
rf991b6b r6d8455d 77 77 * 78 78 * @param nic_data 79 * @param packet Pointer to the packet to be sent 80 */ 81 typedef void (*write_packet_handler)(nic_t *, packet_t *); 79 * @param data Pointer to frame data 80 * @param size Size of frame data in bytes 81 */ 82 typedef void (*send_frame_handler)(nic_t *, void *, size_t); 82 83 /** 83 84 * The handler for transitions between driver states. … … 206 207 extern int nic_get_resources(nic_t *, hw_res_list_parsed_t *); 207 208 extern void nic_set_specific(nic_t *, void *); 208 extern void nic_set_ write_packet_handler(nic_t *, write_packet_handler);209 extern void nic_set_send_frame_handler(nic_t *, send_frame_handler); 209 210 extern void nic_set_state_change_handlers(nic_t *, 210 211 state_change_handler, state_change_handler, state_change_handler); -
uspace/lib/nic/include/nic_driver.h
rf991b6b r6d8455d 134 134 * Called with the main_lock locked for reading. 135 135 */ 136 write_packet_handler write_packet;136 send_frame_handler send_frame; 137 137 /** 138 138 * Event handler called when device goes to the ACTIVE state. -
uspace/lib/nic/include/nic_impl.h
rf991b6b r6d8455d 48 48 49 49 extern int nic_get_address_impl(ddf_fun_t *dev_fun, nic_address_t *address); 50 extern int nic_send_ message_impl(ddf_fun_t *dev_fun, packet_id_t packet_id);50 extern int nic_send_frame_impl(ddf_fun_t *dev_fun, void *data, size_t size); 51 51 extern int nic_connect_to_nil_impl(ddf_fun_t *dev_fun, services_t nil_service, 52 52 int device_id); -
uspace/lib/nic/src/nic_driver.c
rf991b6b r6d8455d 114 114 if (!iface->set_state) 115 115 iface->set_state = nic_set_state_impl; 116 if (!iface->send_ message)117 iface->send_ message = nic_send_message_impl;116 if (!iface->send_frame) 117 iface->send_frame = nic_send_frame_impl; 118 118 if (!iface->connect_to_nil) 119 119 iface->connect_to_nil = nic_connect_to_nil_impl; … … 168 168 * 169 169 * @param nic_data 170 * @param wpfunc Function handling the write_packetrequest171 */ 172 void nic_set_ write_packet_handler(nic_t *nic_data, write_packet_handler wpfunc)173 { 174 nic_data-> write_packet = wpfunc;170 * @param sffunc Function handling the send_frame request 171 */ 172 void nic_set_send_frame_handler(nic_t *nic_data, send_frame_handler sffunc) 173 { 174 nic_data->send_frame = sffunc; 175 175 } 176 176 … … 765 765 nic_data->poll_mode = NIC_POLL_IMMEDIATE; 766 766 nic_data->default_poll_mode = NIC_POLL_IMMEDIATE; 767 nic_data-> write_packet= NULL;767 nic_data->send_frame = NULL; 768 768 nic_data->on_activating = NULL; 769 769 nic_data->on_going_down = NULL; -
uspace/lib/nic/src/nic_impl.c
rf991b6b r6d8455d 39 39 #include <ipc/services.h> 40 40 #include <ns.h> 41 #include <packet_client.h>42 #include <packet_remote.h>43 41 #include "nic_driver.h" 44 42 #include "nic_impl.h" … … 159 157 160 158 /** 161 * Default implementation of the send_ message method.159 * Default implementation of the send_frame method. 162 160 * Send messages to the network. 163 161 * 164 162 * @param fun 165 * @param packet_id ID of the first packet in a queue of sent packets 163 * @param data Frame data 164 * @param size Frame size in bytes 166 165 * 167 166 * @return EOK If the message was sent 168 * @return EBUSY If the device is not in state when the packet can be set. 169 * @return EINVAL If the packet ID is invalid 170 */ 171 int nic_send_message_impl(ddf_fun_t *fun, packet_id_t packet_id) 172 { 173 nic_t *nic_data = (nic_t *) fun->driver_data; 174 packet_t *packet, *next; 167 * @return EBUSY If the device is not in state when the frame can be sent. 168 */ 169 int nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size) 170 { 171 nic_t *nic_data = (nic_t *) fun->driver_data; 175 172 176 173 fibril_rwlock_read_lock(&nic_data->main_lock); 177 174 if (nic_data->state != NIC_STATE_ACTIVE || nic_data->tx_busy) { 178 175 fibril_rwlock_read_unlock(&nic_data->main_lock); 179 pq_release_remote(nic_data->net_session, packet_id);180 176 return EBUSY; 181 177 } 182 178 183 int rc = packet_translate_remote(nic_data->net_session, &packet, packet_id); 184 185 if (rc != EOK) { 186 fibril_rwlock_read_unlock(&nic_data->main_lock); 187 return EINVAL; 188 } 189 190 /* 191 * Process the packet queue. Each sent packet must be detached from the 192 * queue and destroyed. This is why the cycle differs from loopback's 193 * cycle, where the packets are immediately used in upper layers and 194 * therefore they must not be destroyed (released). 195 */ 196 assert(nic_data->write_packet != NULL); 197 do { 198 next = pq_detach(packet); 199 nic_data->write_packet(nic_data, packet); 200 packet = next; 201 } while (packet); 202 fibril_rwlock_read_unlock(&nic_data->main_lock); 179 nic_data->send_frame(nic_data, data, size); 203 180 return EOK; 204 181 } -
uspace/srv/net/nil/eth/eth.c
rf991b6b r6d8455d 802 802 next = tmp; 803 803 } else { 804 nic_send_frame(device->sess, packet_get_data(next), 805 packet_get_data_length(next)); 804 806 next = pq_next(next); 805 807 } 806 808 } while (next); 807 809 808 /* Send packet queue */ 809 if (packet) 810 nic_send_message(device->sess, packet_get_id(packet)); 810 pq_release_remote(eth_globals.net_sess, packet_get_id(packet)); 811 811 812 812 fibril_rwlock_read_unlock(ð_globals.devices_lock); -
uspace/srv/net/nil/nildummy/nildummy.c
rf991b6b r6d8455d 345 345 services_t sender) 346 346 { 347 packet_t *p; 348 347 349 fibril_rwlock_read_lock(&nildummy_globals.devices_lock); 348 350 … … 354 356 } 355 357 356 /* Send packet queue */ 357 if (packet) 358 nic_send_message(device->sess, packet_get_id(packet)); 358 p = packet; 359 do { 360 nic_send_frame(device->sess, packet_get_data(p), 361 packet_get_data_length(p)); 362 p = pq_next(p); 363 } while (p != NULL); 364 365 pq_release_remote(nildummy_globals.net_sess, packet_get_id(packet)); 359 366 360 367 fibril_rwlock_read_unlock(&nildummy_globals.devices_lock);
Note:
See TracChangeset
for help on using the changeset viewer.