Changeset 1bc35b5 in mainline
- Timestamp:
- 2012-01-19T08:13:45Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d8da56b
- Parents:
- 3ea725e
- Location:
- uspace
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
r3ea725e r1bc35b5 52 52 #include <nil_remote.h> 53 53 #include <ops/nic.h> 54 #include <packet_client.h>55 #include <packet_remote.h>56 #include <net/packet_header.h>57 54 #include "e1k.h" 58 55 … … 62 59 63 60 /* Must be power of 8 */ 64 #define E1000_RX_ PACKETS_COUNT 12865 #define E1000_TX_ PACKETS_COUNT 12861 #define E1000_RX_FRAME_COUNT 128 62 #define E1000_TX_FRAME_COUNT 128 66 63 67 64 #define E1000_RECEIVE_ADDRESS 16 68 65 69 /** Maximum sending packetsize */66 /** Maximum sending frame size */ 70 67 #define E1000_MAX_SEND_FRAME_SIZE 2048 71 /** Maximum receiving packetsize */72 #define E1000_MAX_RECEIVE_ PACKET_SIZE 204868 /** Maximum receiving frmae size */ 69 #define E1000_MAX_RECEIVE_FRAME_SIZE 2048 73 70 74 71 /** nic_driver_data_t* -> e1000_t* cast */ … … 137 134 void *rx_ring_virt; 138 135 139 /** Packets in rx ring */ 140 packet_t **rx_ring_packets; 136 /** Ring of RX frames, physical address */ 137 void **rx_frame_phys; 138 /** Ring of RX frames, virtual address */ 139 void **rx_frame_virt; 141 140 142 141 /** VLAN tag */ 143 142 uint16_t vlan_tag; 144 143 145 /** Add VLAN tag to packet*/144 /** Add VLAN tag to frame */ 146 145 bool vlan_tag_add; 147 146 … … 477 476 } 478 477 479 /** Get state of acceptance of weird packets478 /** Get state of acceptance of weird frames 480 479 * 481 480 * @param device Device to check … … 495 494 }; 496 495 497 /** Set acceptance of weird packets496 /** Set acceptance of weird frames 498 497 * 499 498 * @param device Device to update … … 679 678 } 680 679 681 /** Disable receiving packets for default address680 /** Disable receiving frames for default address 682 681 * 683 682 * @param e1000 E1000 data structure … … 691 690 } 692 691 693 /** Enable receiving packets for default address692 /** Enable receiving frames for default address 694 693 * 695 694 * @param e1000 E1000 data structure … … 751 750 } 752 751 753 /** Enable accepting of broadcast packets752 /** Enable accepting of broadcast frames 754 753 * 755 754 * @param e1000 E1000 data structure … … 763 762 } 764 763 765 /** Disable accepting of broadcast packets764 /** Disable accepting of broadcast frames 766 765 * 767 766 * @param e1000 E1000 data structure … … 799 798 } 800 799 801 /** Set multicast packets acceptance mode800 /** Set multicast frames acceptance mode 802 801 * 803 802 * @param nic NIC device to update … … 853 852 } 854 853 855 /** Set unicast packets acceptance mode854 /** Set unicast frames acceptance mode 856 855 * 857 856 * @param nic NIC device to update … … 911 910 } 912 911 913 /** Set broadcast packets acceptance mode912 /** Set broadcast frames acceptance mode 914 913 * 915 914 * @param nic NIC device to update … … 996 995 if (vlan_mask) { 997 996 /* 998 * Disable receiving, so that packetmatching997 * Disable receiving, so that frame matching 999 998 * partially written VLAN is not received. 1000 999 */ … … 1063 1062 } 1064 1063 1065 /** Fill receive descriptor with new empty packet1066 * 1067 * Store packet in e1000->rx_ring_packets1064 /** Fill receive descriptor with new empty buffer 1065 * 1066 * Store frame in e1000->rx_frame_phys 1068 1067 * 1069 1068 * @param nic NIC data stricture … … 1074 1073 { 1075 1074 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 1076 packet_t *packet = 1077 nic_alloc_packet(nic, E1000_MAX_RECEIVE_PACKET_SIZE); 1078 1079 assert(packet); 1080 1081 *(e1000->rx_ring_packets + offset) = packet; 1075 1082 1076 e1000_rx_descriptor_t *rx_descriptor = (e1000_rx_descriptor_t *) 1083 1077 (e1000->rx_ring_virt + offset * sizeof(e1000_rx_descriptor_t)); 1084 1078 1085 void *phys; 1086 int rc = 1087 nic_dma_lock_packet(packet, E1000_MAX_RECEIVE_PACKET_SIZE, &phys); 1088 1089 if (rc == EOK) 1090 rx_descriptor->phys_addr = PTR_TO_U64(phys + packet->data_start); 1091 else 1092 rx_descriptor->phys_addr = 0; 1093 1079 rx_descriptor->phys_addr = PTR_TO_U64(e1000->rx_frame_phys[offset]); 1094 1080 rx_descriptor->length = 0; 1095 1081 rx_descriptor->checksum = 0; … … 1155 1141 } 1156 1142 1157 /** Receive packets1143 /** Receive frames 1158 1144 * 1159 1145 * @param nic NIC data 1160 1146 * 1161 1147 */ 1162 static void e1000_receive_ packets(nic_t *nic)1148 static void e1000_receive_frames(nic_t *nic) 1163 1149 { 1164 1150 e1000_t *e1000 = DRIVER_DATA_NIC(nic); … … 1167 1153 1168 1154 uint32_t *tail_addr = E1000_REG_ADDR(e1000, E1000_RDT); 1169 uint32_t next_tail = e1000_inc_tail(*tail_addr, E1000_RX_ PACKETS_COUNT);1155 uint32_t next_tail = e1000_inc_tail(*tail_addr, E1000_RX_FRAME_COUNT); 1170 1156 1171 1157 e1000_rx_descriptor_t *rx_descriptor = (e1000_rx_descriptor_t *) … … 1173 1159 1174 1160 while (rx_descriptor->status & 0x01) { 1175 uint32_t packet_size = rx_descriptor->length - E1000_CRC_SIZE;1161 uint32_t frame_size = rx_descriptor->length - E1000_CRC_SIZE; 1176 1162 1177 packet_t *packet = *(e1000->rx_ring_packets + next_tail); 1178 packet_suffix(packet, packet_size); 1179 1180 nic_dma_unlock_packet(packet, E1000_MAX_RECEIVE_PACKET_SIZE); 1181 nic_received_packet(nic, packet); 1163 nic_frame_t *frame = nic_alloc_frame(nic, frame_size); 1164 if (frame != NULL) { 1165 memcpy(frame->data, e1000->rx_frame_virt[next_tail], frame_size); 1166 nic_received_frame(nic, frame); 1167 } else { 1168 ddf_msg(LVL_ERROR, "Memory allocation failed. Frame dropped."); 1169 } 1182 1170 1183 1171 e1000_fill_new_rx_descriptor(nic, next_tail); 1184 1172 1185 *tail_addr = e1000_inc_tail(*tail_addr, E1000_RX_ PACKETS_COUNT);1186 next_tail = e1000_inc_tail(*tail_addr, E1000_RX_ PACKETS_COUNT);1173 *tail_addr = e1000_inc_tail(*tail_addr, E1000_RX_FRAME_COUNT); 1174 next_tail = e1000_inc_tail(*tail_addr, E1000_RX_FRAME_COUNT); 1187 1175 1188 1176 rx_descriptor = (e1000_rx_descriptor_t *) … … 1225 1213 { 1226 1214 if (icr & ICR_RXT0) 1227 e1000_receive_ packets(nic);1215 e1000_receive_frames(nic); 1228 1216 } 1229 1217 … … 1274 1262 } 1275 1263 1276 /** Force receiving all packets in the receive buffer1264 /** Force receiving all frames in the receive buffer 1277 1265 * 1278 1266 * @param nic NIC data … … 1347 1335 static void e1000_initialize_rx_registers(e1000_t *e1000) 1348 1336 { 1349 E1000_REG_WRITE(e1000, E1000_RDLEN, E1000_RX_ PACKETS_COUNT * 16);1337 E1000_REG_WRITE(e1000, E1000_RDLEN, E1000_RX_FRAME_COUNT * 16); 1350 1338 E1000_REG_WRITE(e1000, E1000_RDH, 0); 1351 1339 1352 1340 /* It is not posible to let HW use all descriptors */ 1353 E1000_REG_WRITE(e1000, E1000_RDT, E1000_RX_ PACKETS_COUNT - 1);1341 E1000_REG_WRITE(e1000, E1000_RDT, E1000_RX_FRAME_COUNT - 1); 1354 1342 1355 1343 /* Set Broadcast Enable Bit */ … … 1371 1359 1372 1360 int rc = dmamem_map_anonymous( 1373 E1000_RX_ PACKETS_COUNT * sizeof(e1000_rx_descriptor_t),1361 E1000_RX_FRAME_COUNT * sizeof(e1000_rx_descriptor_t), 1374 1362 AS_AREA_READ | AS_AREA_WRITE, 0, &e1000->rx_ring_phys, 1375 1363 &e1000->rx_ring_virt); … … 1382 1370 (uint32_t) PTR_TO_U64(e1000->rx_ring_phys)); 1383 1371 1384 e1000->rx_ring_packets = 1385 malloc(E1000_RX_PACKETS_COUNT * sizeof(packet_t *)); 1386 // FIXME: Check return value 1387 1372 e1000->rx_frame_phys = 1373 calloc(E1000_RX_FRAME_COUNT, sizeof(void *)); 1374 e1000->rx_frame_virt = 1375 calloc(E1000_RX_FRAME_COUNT, sizeof(void *)); 1376 if (e1000->rx_frame_phys == NULL || e1000->rx_frame_virt == NULL) { 1377 rc = ENOMEM; 1378 goto error; 1379 } 1380 1381 size_t i; 1382 void *frame_virt; 1383 void *frame_phys; 1384 1385 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) { 1386 rc = dmamem_map_anonymous( 1387 E1000_MAX_SEND_FRAME_SIZE, AS_AREA_READ | AS_AREA_WRITE, 1388 0, &frame_phys, &frame_virt); 1389 if (rc != EOK) 1390 goto error; 1391 1392 e1000->rx_frame_virt[i] = frame_virt; 1393 e1000->rx_frame_phys[i] = frame_phys; 1394 } 1395 1396 /* Write descriptor */ 1397 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) 1398 e1000_fill_new_rx_descriptor(nic, i); 1399 1400 e1000_initialize_rx_registers(e1000); 1401 1402 fibril_mutex_unlock(&e1000->rx_lock); 1403 return EOK; 1404 error: 1405 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) { 1406 if (e1000->rx_frame_virt[i] != NULL) { 1407 dmamem_unmap_anonymous(e1000->rx_frame_virt[i]); 1408 e1000->rx_frame_virt[i] = NULL; 1409 e1000->rx_frame_phys[i] = NULL; 1410 } 1411 } 1412 if (e1000->rx_frame_phys != NULL) { 1413 free(e1000->rx_frame_phys); 1414 e1000->rx_frame_phys = NULL; 1415 } 1416 if (e1000->rx_frame_virt != NULL) { 1417 free(e1000->rx_frame_virt); 1418 e1000->rx_frame_phys = NULL; 1419 } 1420 return rc; 1421 } 1422 1423 /** Uninitialize receive structure 1424 * 1425 * @param nic NIC data 1426 * 1427 */ 1428 static void e1000_uninitialize_rx_structure(nic_t *nic) 1429 { 1430 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 1431 1432 /* Write descriptor */ 1433 for (unsigned int offset = 0; offset < E1000_RX_FRAME_COUNT; offset++) { 1434 dmamem_unmap_anonymous(e1000->rx_frame_virt[offset]); 1435 e1000->rx_frame_virt[offset] = NULL; 1436 e1000->rx_frame_phys[offset] = NULL; 1437 } 1438 1439 free(e1000->rx_frame_virt); 1440 free(e1000->rx_frame_phys); 1441 e1000->rx_frame_virt = NULL; 1442 e1000->rx_frame_phys = NULL; 1443 dmamem_unmap_anonymous(e1000->rx_ring_virt); 1444 } 1445 1446 /** Clear receive descriptor ring 1447 * 1448 * @param e1000 E1000 data 1449 * 1450 */ 1451 static void e1000_clear_rx_ring(e1000_t *e1000) 1452 { 1388 1453 /* Write descriptor */ 1389 1454 for (unsigned int offset = 0; 1390 offset < E1000_RX_PACKETS_COUNT; 1391 offset++) 1392 e1000_fill_new_rx_descriptor(nic, offset); 1393 1394 e1000_initialize_rx_registers(e1000); 1395 1396 fibril_mutex_unlock(&e1000->rx_lock); 1397 return EOK; 1398 } 1399 1400 /** Uninitialize receive structure 1401 * 1402 * @param nic NIC data 1403 * 1404 */ 1405 static void e1000_uninitialize_rx_structure(nic_t *nic) 1406 { 1407 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 1408 1409 /* Write descriptor */ 1410 for (unsigned int offset = 0; 1411 offset < E1000_RX_PACKETS_COUNT; 1412 offset++) { 1413 packet_t *packet = *(e1000->rx_ring_packets + offset); 1414 nic_dma_unlock_packet(packet, E1000_MAX_RECEIVE_PACKET_SIZE); 1415 nic_release_packet(nic, packet); 1416 } 1417 1418 free(e1000->rx_ring_packets); 1419 dmamem_unmap_anonymous(e1000->rx_ring_virt); 1420 } 1421 1422 /** Clear receive descriptor ring 1423 * 1424 * @param e1000 E1000 data 1425 * 1426 */ 1427 static void e1000_clear_rx_ring(e1000_t *e1000) 1428 { 1429 /* Write descriptor */ 1430 for (unsigned int offset = 0; 1431 offset < E1000_RX_PACKETS_COUNT; 1455 offset < E1000_RX_FRAME_COUNT; 1432 1456 offset++) 1433 1457 e1000_clear_rx_descriptor(e1000, offset); … … 1498 1522 static void e1000_initialize_tx_registers(e1000_t *e1000) 1499 1523 { 1500 E1000_REG_WRITE(e1000, E1000_TDLEN, E1000_TX_ PACKETS_COUNT * 16);1524 E1000_REG_WRITE(e1000, E1000_TDLEN, E1000_TX_FRAME_COUNT * 16); 1501 1525 E1000_REG_WRITE(e1000, E1000_TDH, 0); 1502 1526 E1000_REG_WRITE(e1000, E1000_TDT, 0); … … 1530 1554 1531 1555 int rc = dmamem_map_anonymous( 1532 E1000_TX_ PACKETS_COUNT * sizeof(e1000_tx_descriptor_t),1556 E1000_TX_FRAME_COUNT * sizeof(e1000_tx_descriptor_t), 1533 1557 AS_AREA_READ | AS_AREA_WRITE, 0, &e1000->tx_ring_phys, 1534 1558 &e1000->tx_ring_virt); … … 1537 1561 1538 1562 bzero(e1000->tx_ring_virt, 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 *));1563 E1000_TX_FRAME_COUNT * sizeof(e1000_tx_descriptor_t)); 1564 1565 e1000->tx_frame_phys = calloc(E1000_TX_FRAME_COUNT, sizeof(void *)); 1566 e1000->tx_frame_virt = calloc(E1000_TX_FRAME_COUNT, sizeof(void *)); 1543 1567 1544 1568 if (e1000->tx_frame_phys == NULL || e1000->tx_frame_virt == NULL) { … … 1547 1571 } 1548 1572 1549 for (i = 0; i < E1000_TX_ PACKETS_COUNT; i++) {1573 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1550 1574 rc = dmamem_map_anonymous( 1551 1575 E1000_MAX_SEND_FRAME_SIZE, AS_AREA_READ | AS_AREA_WRITE, … … 1572 1596 1573 1597 if (e1000->tx_frame_phys != NULL && e1000->tx_frame_virt != NULL) { 1574 for (i = 0; i < E1000_TX_ PACKETS_COUNT; i++) {1598 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1575 1599 if (e1000->tx_frame_virt[i] != NULL) { 1576 1600 dmamem_unmap_anonymous(e1000->tx_frame_virt[i]); … … 1603 1627 size_t i; 1604 1628 1605 for (i = 0; i < E1000_TX_ PACKETS_COUNT; i++) {1629 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1606 1630 dmamem_unmap_anonymous(e1000->tx_frame_virt[i]); 1607 1631 e1000->tx_frame_virt[i] = NULL; … … 1630 1654 /* Write descriptor */ 1631 1655 for (unsigned int offset = 0; 1632 offset < E1000_TX_ PACKETS_COUNT;1656 offset < E1000_TX_FRAME_COUNT; 1633 1657 offset++) 1634 1658 e1000_clear_tx_descriptor(nic, offset); … … 1687 1711 } 1688 1712 1689 /** Activate the device to receive and transmit packets1713 /** Activate the device to receive and transmit frames 1690 1714 * 1691 1715 * @param nic NIC driver data … … 2283 2307 2284 2308 if (!descriptor_available) { 2285 /* Packetlost */2309 /* Frame lost */ 2286 2310 fibril_mutex_unlock(&e1000->tx_lock); 2287 2311 return; … … 2312 2336 2313 2337 tdt++; 2314 if (tdt == E1000_TX_ PACKETS_COUNT)2338 if (tdt == E1000_TX_FRAME_COUNT) 2315 2339 tdt = 0; 2316 2340 -
uspace/drv/nic/e1k/e1k.h
r3ea725e r1bc35b5 39 39 #include <stdint.h> 40 40 41 /** Ethernet CRC size after packetreceived in rx_descriptor */41 /** Ethernet CRC size after frame received in rx_descriptor */ 42 42 #define E1000_CRC_SIZE 4 43 43 … … 109 109 /** Transmit descriptor COMMAND field bits */ 110 110 typedef enum { 111 TXDESCRIPTOR_COMMAND_VLE = (1 << 6), /**< VLAN PacketEnable */111 TXDESCRIPTOR_COMMAND_VLE = (1 << 6), /**< VLAN frame Enable */ 112 112 TXDESCRIPTOR_COMMAND_RS = (1 << 3), /**< Report Status */ 113 113 TXDESCRIPTOR_COMMAND_IFCS = (1 << 1), /**< Insert FCS */ -
uspace/drv/nic/ne2k/dp8390.c
r3ea725e r1bc35b5 59 59 #include <stdio.h> 60 60 #include <libarch/ddi.h> 61 #include <net/packet.h>62 #include <packet_client.h>63 61 #include "dp8390.h" 64 62 … … 76 74 uint8_t status; 77 75 78 /** Pointer to next packet*/76 /** Pointer to next frame */ 79 77 uint8_t next; 80 78 … … 393 391 /* 394 392 * Reset the transmit ring. If we were transmitting a frame, 395 * we pretend that the packetis processed. Higher layers will396 * retransmit if the packetwasn't actually sent.393 * we pretend that the frame is processed. Higher layers will 394 * retransmit if the frame wasn't actually sent. 397 395 */ 398 396 ne2k->sq.dirty = false; … … 448 446 return NULL; 449 447 450 void *buf = packet_suffix(frame->packet, length); 451 bzero(buf, length); 448 bzero(frame->data, length); 452 449 uint8_t last = page + length / DP_PAGE; 453 450 … … 455 452 size_t left = (ne2k->stop_page - page) * DP_PAGE 456 453 - sizeof(recv_header_t); 457 ne2k_download(ne2k, buf, page * DP_PAGE + sizeof(recv_header_t),454 ne2k_download(ne2k, frame->data, page * DP_PAGE + sizeof(recv_header_t), 458 455 left); 459 ne2k_download(ne2k, buf+ left, ne2k->start_page * DP_PAGE,456 ne2k_download(ne2k, frame->data + left, ne2k->start_page * DP_PAGE, 460 457 length - left); 461 458 } else { 462 ne2k_download(ne2k, buf, page * DP_PAGE + sizeof(recv_header_t),459 ne2k_download(ne2k, frame->data, page * DP_PAGE + sizeof(recv_header_t), 463 460 length); 464 461 } … … 541 538 * Update the boundary pointer 542 539 * to the value of the page 543 * prior to the next packetto540 * prior to the next frame to 544 541 * be processed. 545 542 */ … … 584 581 fibril_mutex_lock(&ne2k->sq_mutex); 585 582 if (ne2k->sq.dirty) { 586 /* Prepare the buffer for next packet*/583 /* Prepare the buffer for next frame */ 587 584 ne2k->sq.dirty = false; 588 585 ne2k->sq.size = 0; -
uspace/drv/nic/ne2k/ne2k.c
r3ea725e r1bc35b5 261 261 /* Note: some frame with previous physical address may slip to NIL here 262 262 * (for a moment the filtering is not exact), but ethernet should be OK with 263 * that. Some packetmay also be lost, but this is not a problem.263 * that. Some frames may also be lost, but this is not a problem. 264 264 */ 265 265 ne2k_set_physical_address((ne2k_t *) nic_get_specific(nic_data), address); -
uspace/drv/nic/rtl8139/defs.h
r3ea725e r1bc35b5 42 42 #define RTL8139_IO_SIZE 256 43 43 44 /** The maximal transmitted packetlength in bytes allowed according to RTL813944 /** The maximal transmitted frame length in bytes allowed according to RTL8139 45 45 * documentation (see SIZE part of TSD documentation) 46 46 */ 47 #define RTL8139_ PACKET_MAX_LENGTH 179247 #define RTL8139_FRAME_MAX_LENGTH 1792 48 48 49 49 … … 94 94 95 95 CR = 0x37, /**< Command register, 1b */ 96 CAPR = 0x38, /**< Current address of packetread, 2b */96 CAPR = 0x38, /**< Current address of frame read, 2b */ 97 97 CBA = 0x3a, /**< Current buffer address, 2b */ 98 98 … … 282 282 RCR_MulERINT = 1 << 17, /**< Multiple early interrupt select */ 283 283 284 /** Minimal error packetlength (1 = 8B, 0 = 64B). If AER/AR is set, RER8284 /** Minimal error frame length (1 = 8B, 0 = 64B). If AER/AR is set, RER8 285 285 * is "Don't care" 286 286 */ … … 302 302 303 303 RCR_WRAP = 1 << 7, /**< Rx buffer wrapped */ 304 RCR_ACCEPT_ERROR = 1 << 5, /**< Accept error packet*/305 RCR_ACCEPT_RUNT = 1 << 4, /**< Accept Runt (8-64 bytes) packets */304 RCR_ACCEPT_ERROR = 1 << 5, /**< Accept error frame */ 305 RCR_ACCEPT_RUNT = 1 << 4, /**< Accept Runt (8-64 bytes) frames */ 306 306 RCR_ACCEPT_BROADCAST = 1 << 3, /**< Accept broadcast */ 307 307 RCR_ACCEPT_MULTICAST = 1 << 2, /**< Accept multicast */ 308 308 RCR_ACCEPT_PHYS_MATCH = 1 << 1, /**< Accept device MAC address match */ 309 RCR_ACCEPT_ALL_PHYS = 1 << 0, /**< Accept all packets with309 RCR_ACCEPT_ALL_PHYS = 1 << 0, /**< Accept all frames with 310 310 * phys. desticnation 311 311 */ … … 362 362 ANAR_ACK = (1 << 14), /**< Capability reception acknowledge */ 363 363 ANAR_REMOTE_FAULT = (1 << 13), /**< Remote fault detection capability */ 364 ANAR_PAUSE = (1 << 10), /**< Symetric pause packetcapability */364 ANAR_PAUSE = (1 << 10), /**< Symetric pause frame capability */ 365 365 ANAR_100T4 = (1 << 9), /**< T4, not supported by the device */ 366 366 ANAR_100TX_FD = (1 << 8), /**< 100BASE_TX full duplex */ … … 399 399 CONFIG3_GNT_SELECT = (1 << 7), /**< Gnt select */ 400 400 CONFIG3_PARM_EN = (1 << 6), /**< Parameter enabled (100MBit mode) */ 401 CONFIG3_MAGIC = (1 << 5), /**< WoL Magic packetenable */401 CONFIG3_MAGIC = (1 << 5), /**< WoL Magic frame enable */ 402 402 CONFIG3_LINK_UP = (1 << 4), /**< Wakeup if link is reestablished */ 403 403 CONFIG3_CLKRUN_EN = (1 << 2), /**< CLKRUN enabled */ /* TODO: check what does it mean */ … … 416 416 }; 417 417 418 /** Maximal runt packetsize + 1 */418 /** Maximal runt frame size + 1 */ 419 419 #define RTL8139_RUNT_MAX_SIZE 64 420 420 421 /** Bits in packetheader */422 enum rtl8139_ packet_header {421 /** Bits in frame header */ 422 enum rtl8139_frame_header { 423 423 RSR_MAR = (1 << 15), /**< Multicast received */ 424 424 RSR_PAM = (1 << 14), /**< Physical address match */ … … 426 426 427 427 RSR_ISE = (1 << 5), /**< Invalid symbol error, 100BASE-TX only */ 428 RSR_RUNT = (1 << 4), /**< Runt packet(< RTL8139_RUNT_MAX_SIZE bytes) */429 430 RSR_LONG = (1 << 3), /**< Long packet(size > 4k bytes) */428 RSR_RUNT = (1 << 4), /**< Runt frame (< RTL8139_RUNT_MAX_SIZE bytes) */ 429 430 RSR_LONG = (1 << 3), /**< Long frmae (size > 4k bytes) */ 431 431 RSR_CRC = (1 << 2), /**< CRC error */ 432 432 RSR_FAE = (1 << 1), /**< Frame alignment error */ 433 RSR_ROK = (1 << 0) /**< Good packetreceived */433 RSR_ROK = (1 << 0) /**< Good frame received */ 434 434 }; 435 435 … … 451 451 */ 452 452 453 APPEND_CRC = 1 << 16, /**< Append CRC at the end of a packet*/453 APPEND_CRC = 1 << 16, /**< Append CRC at the end of a frame */ 454 454 455 455 MXTxDMA_SHIFT = 8, /**< Max. DMA Burst per TxDMA shift, burst = 16^value */ … … 459 459 TX_RETRY_COUNT_SIZE = 4, /**< Retries before aborting size */ 460 460 461 CLEAR_ABORT = 1 << 0 /**< Retransmit aborted packetat the last461 CLEAR_ABORT = 1 << 0 /**< Retransmit aborted frame at the last 462 462 * transmitted descriptor 463 463 */ … … 478 478 extern const struct rtl8139_hwver_map rtl8139_versions[RTL8139_VER_COUNT + 1]; 479 479 480 /** Size in the packetheader while copying from RxFIFO to Rx buffer */480 /** Size in the frame header while copying from RxFIFO to Rx buffer */ 481 481 #define RTL8139_EARLY_SIZE UINT16_C(0xfff0) 482 /** The only supported pause packettime value */482 /** The only supported pause frame time value */ 483 483 #define RTL8139_PAUSE_VAL UINT16_C(0xFFFF) 484 484 485 /** Size of the packetheader in front of the received frame */486 #define RTL_ PACKET_HEADER_SIZE 4485 /** Size of the frame header in front of the received frame */ 486 #define RTL_FRAME_HEADER_SIZE 4 487 487 488 488 /** 8k buffer */ -
uspace/drv/nic/rtl8139/driver.c
r3ea725e r1bc35b5 39 39 #include <io/log.h> 40 40 #include <nic.h> 41 #include <packet_client.h>41 //#include <packet_client.h> 42 42 #include <device/pci.h> 43 43 … … 152 152 } 153 153 154 /** Update the mask of accepted packets in the RCR register according to154 /** Update the mask of accepted frames in the RCR register according to 155 155 * rcr_accept_mode value in rtl8139_t 156 156 * … … 170 170 } 171 171 172 /** Fill the mask of accepted multicast packets in the card registers172 /** Fill the mask of accepted multicast frames in the card registers 173 173 * 174 174 * @param rtl8139 The rtl8139 private data … … 394 394 #define rtl8139_tbuf_busy(tsd) ((pio_read_32(tsd) & TSD_OWN) == 0) 395 395 396 /** Send packetwith the hardware396 /** Send frame with the hardware 397 397 * 398 398 * note: the main_lock is locked when framework calls this function … … 412 412 ddf_msg(LVL_DEBUG, "Sending frame"); 413 413 414 if (size > RTL8139_ PACKET_MAX_LENGTH) {414 if (size > RTL8139_FRAME_MAX_LENGTH) { 415 415 ddf_msg(LVL_ERROR, "Send frame: frame too long, %zu bytes", 416 416 size); … … 437 437 fibril_mutex_unlock(&rtl8139->tx_lock); 438 438 439 /* Get address of the buffer descriptor and packetdata */439 /* Get address of the buffer descriptor and frame data */ 440 440 void *tsd = rtl8139->io_port + TSD0 + tx_curr * 4; 441 441 void *buf_addr = rtl8139->tx_buff[tx_curr]; … … 505 505 } 506 506 507 /** Create packetstructure from the buffer data507 /** Create frame structure from the buffer data 508 508 * 509 509 * @param nic_data NIC driver data 510 510 * @param rx_buffer The receiver buffer 511 511 * @param rx_size The buffer size 512 * @param packet_startThe offset where packet data start513 * @param packet_size The size of the packetdata514 * 515 * @return The packetlist node (not connected)516 */ 517 static nic_frame_t *rtl8139_read_ packet(nic_t *nic_data,518 void *rx_buffer, size_t rx_size, size_t packet_start, size_t packet_size)519 { 520 nic_frame_t *frame = nic_alloc_frame(nic_data, packet_size);512 * @param frame_start The offset where packet data start 513 * @param frame_size The size of the frame data 514 * 515 * @return The frame list node (not connected) 516 */ 517 static nic_frame_t *rtl8139_read_frame(nic_t *nic_data, 518 void *rx_buffer, size_t rx_size, size_t frame_start, size_t frame_size) 519 { 520 nic_frame_t *frame = nic_alloc_frame(nic_data, frame_size); 521 521 if (! frame) { 522 ddf_msg(LVL_ERROR, "Can not allocate frame for received packet.");522 ddf_msg(LVL_ERROR, "Can not allocate frame for received frame."); 523 523 return NULL; 524 524 } 525 525 526 void *packet_data = packet_suffix(frame->packet, packet_size); 527 if (!packet_data) { 528 ddf_msg(LVL_ERROR, "Can not get the packet suffix."); 529 nic_release_frame(nic_data, frame); 530 return NULL; 531 } 532 533 void *ret = rtl8139_memcpy_wrapped(packet_data, rx_buffer, packet_start, 534 RxBUF_SIZE, packet_size); 526 void *ret = rtl8139_memcpy_wrapped(frame->data, rx_buffer, frame_start, 527 RxBUF_SIZE, frame_size); 535 528 if (ret == NULL) { 536 529 nic_release_frame(nic_data, frame); … … 568 561 } 569 562 570 /** Receive all packets in queue563 /** Receive all frames in queue 571 564 * 572 565 * @param nic_data The controller data 573 * @return The linked list of packet_list_t nodes, each containing one packet574 */ 575 static nic_frame_list_t *rtl8139_ packet_receive(nic_t *nic_data)566 * @return The linked list of nic_frame_list_t nodes, each containing one frame 567 */ 568 static nic_frame_list_t *rtl8139_frame_receive(nic_t *nic_data) 576 569 { 577 570 rtl8139_t *rtl8139 = nic_get_specific(nic_data); … … 581 574 nic_frame_list_t *frames = nic_alloc_frame_list(); 582 575 if (!frames) 583 ddf_msg(LVL_ERROR, "Can not allocate frame list for received packets.");576 ddf_msg(LVL_ERROR, "Can not allocate frame list for received frames."); 584 577 585 578 void *rx_buffer = rtl8139->rx_buff_virt; … … 605 598 while (!rtl8139_hw_buffer_empty(rtl8139)) { 606 599 void *rx_ptr = rx_buffer + rx_offset % RxBUF_SIZE; 607 uint32_t packet_header = uint32_t_le2host( *((uint32_t*)rx_ptr) );608 uint16_t size = packet_header >> 16;609 uint16_t packet_size = size - RTL8139_CRC_SIZE;610 /* received packet flags in packetheader */611 uint16_t rcs = (uint16_t) packet_header;600 uint32_t frame_header = uint32_t_le2host( *((uint32_t*)rx_ptr) ); 601 uint16_t size = frame_header >> 16; 602 uint16_t frame_size = size - RTL8139_CRC_SIZE; 603 /* received frame flags in frame header */ 604 uint16_t rcs = (uint16_t) frame_header; 612 605 613 606 if (size == RTL8139_EARLY_SIZE) { 614 /* The packetcopying is still in progress, break receiving */607 /* The frame copying is still in progress, break receiving */ 615 608 ddf_msg(LVL_DEBUG, "Early threshold reached, not completely coppied"); 616 609 break; … … 618 611 619 612 /* Check if the header is valid, otherwise we are lost in the buffer */ 620 if (size == 0 || size > RTL8139_ PACKET_MAX_LENGTH) {613 if (size == 0 || size > RTL8139_FRAME_MAX_LENGTH) { 621 614 ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (size: %4"PRIu16", " 622 "header 0x%4"PRIx16". Offset: %zu)", size, packet_header,615 "header 0x%4"PRIx16". Offset: %zu)", size, frame_header, 623 616 rx_offset); 624 617 goto rx_err; … … 629 622 } 630 623 631 cur_read += size + RTL_ PACKET_HEADER_SIZE;624 cur_read += size + RTL_FRAME_HEADER_SIZE; 632 625 if (cur_read > max_read) 633 626 break; 634 627 635 628 if (frames) { 636 nic_frame_t *frame = rtl8139_read_ packet(nic_data, rx_buffer,637 RxBUF_SIZE, rx_offset + RTL_ PACKET_HEADER_SIZE, packet_size);629 nic_frame_t *frame = rtl8139_read_frame(nic_data, rx_buffer, 630 RxBUF_SIZE, rx_offset + RTL_FRAME_HEADER_SIZE, frame_size); 638 631 639 632 if (frame) … … 642 635 643 636 /* Update offset */ 644 rx_offset = ALIGN_UP(rx_offset + size + RTL_ PACKET_HEADER_SIZE, 4);645 646 /* Write lesser value to prevent overflow into unread packet637 rx_offset = ALIGN_UP(rx_offset + size + RTL_FRAME_HEADER_SIZE, 4); 638 639 /* Write lesser value to prevent overflow into unread frame 647 640 * (the recomendation from the RealTech rtl8139 programming guide) 648 641 */ … … 727 720 tx_used++; 728 721 729 /* If the packetwas sent */722 /* If the frame was sent */ 730 723 if (tsd_value & TSD_TOK) { 731 724 size_t size = REG_GET_VAL(tsd_value, TSD_SIZE); … … 757 750 } 758 751 759 /** Receive all packets from the buffer752 /** Receive all frames from the buffer 760 753 * 761 754 * @param rtl8139 driver private data 762 755 */ 763 static void rtl8139_receive_ packets(nic_t *nic_data)756 static void rtl8139_receive_frames(nic_t *nic_data) 764 757 { 765 758 assert(nic_data); … … 769 762 770 763 fibril_mutex_lock(&rtl8139->rx_lock); 771 nic_frame_list_t *frames = rtl8139_ packet_receive(nic_data);764 nic_frame_list_t *frames = rtl8139_frame_receive(nic_data); 772 765 fibril_mutex_unlock(&rtl8139->rx_lock); 773 766 … … 825 818 } 826 819 827 /* Check transmittion interrupts first to allow transmit next packets820 /* Check transmittion interrupts first to allow transmit next frames 828 821 * sooner 829 822 */ … … 832 825 } 833 826 if (isr & INT_ROK) { 834 rtl8139_receive_ packets(nic_data);827 rtl8139_receive_frames(nic_data); 835 828 } 836 829 if (isr & (INT_RER | INT_RXOVW | INT_FIFOOVW)) { … … 933 926 } 934 927 935 /** Activate the device to receive and transmit packets928 /** Activate the device to receive and transmit frames 936 929 * 937 930 * @param nic_data The nic driver data … … 1213 1206 goto failed; 1214 1207 1215 /* Set default packetacceptance */1208 /* Set default frame acceptance */ 1216 1209 rtl8139->rcr_data.ucast_mask = RTL8139_RCR_UCAST_DEFAULT; 1217 1210 rtl8139->rcr_data.mcast_mask = RTL8139_RCR_MCAST_DEFAULT; 1218 1211 rtl8139->rcr_data.bcast_mask = RTL8139_RCR_BCAST_DEFAULT; 1219 1212 rtl8139->rcr_data.defect_mask = RTL8139_RCR_DEFECT_DEFAULT; 1220 /* Set receiver early treshold to 8/16 of packetlength */1213 /* Set receiver early treshold to 8/16 of frame length */ 1221 1214 rtl8139->rcr_data.rcr_base = (0x8 << RCR_ERTH_SHIFT); 1222 1215 … … 1477 1470 }; 1478 1471 1479 /** Check if pause packetoperations are valid in current situation1472 /** Check if pause frame operations are valid in current situation 1480 1473 * 1481 1474 * @param rtl8139 RTL8139 private structure … … 1502 1495 } 1503 1496 1504 /** Get current pause packetconfiguration1497 /** Get current pause frame configuration 1505 1498 * 1506 1499 * Values are filled with NIC_RESULT_NOT_AVAILABLE if the value has no sense in … … 1508 1501 * 1509 1502 * @param[in] fun The DDF structure of the RTL8139 1510 * @param[out] we_send Sign if local constroller sends pause packets1511 * @param[out] we_receive Sign if local constroller receives pause packets1512 * @param[out] time Time filled in pause packets. 0xFFFF in rtl81391503 * @param[out] we_send Sign if local constroller sends pause frame 1504 * @param[out] we_receive Sign if local constroller receives pause frame 1505 * @param[out] time Time filled in pause frames. 0xFFFF in rtl8139 1513 1506 * 1514 1507 * @return EOK if succeed … … 1540 1533 }; 1541 1534 1542 /** Set current pause packetconfiguration1535 /** Set current pause frame configuration 1543 1536 * 1544 1537 * @param fun The DDF structure of the RTL8139 1545 * @param allow_send Sign if local constroller sends pause packets1546 * @param allow_receive Sign if local constroller receives pause packets1538 * @param allow_send Sign if local constroller sends pause frame 1539 * @param allow_receive Sign if local constroller receives pause frames 1547 1540 * @param time Time to use, ignored (not supported by device) 1548 1541 * 1549 * @return EOK if succeed, INVAL if the pause packethas no sence1542 * @return EOK if succeed, INVAL if the pause frame has no sence 1550 1543 */ 1551 1544 static int rtl8139_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive, … … 1796 1789 } 1797 1790 1798 /** Set unicast packets acceptance mode1791 /** Set unicast frames acceptance mode 1799 1792 * 1800 1793 * @param nic_data The nic device to update … … 1854 1847 } 1855 1848 1856 /** Set multicast packets acceptance mode1849 /** Set multicast frames acceptance mode 1857 1850 * 1858 1851 * @param nic_data The nic device to update … … 1899 1892 } 1900 1893 1901 /** Set broadcast packets acceptance mode1894 /** Set broadcast frames acceptance mode 1902 1895 * 1903 1896 * @param nic_data The nic device to update … … 1929 1922 } 1930 1923 1931 /** Get state of acceptance of weird packets1924 /** Get state of acceptance of weird frames 1932 1925 * 1933 1926 * @param[in] device The device to check … … 1951 1944 }; 1952 1945 1953 /** Set acceptance of weird packets1946 /** Set acceptance of weird frames 1954 1947 * 1955 1948 * @param device The device to update … … 2127 2120 } 2128 2121 2129 /** Force receiving all packets in the receive buffer2122 /** Force receiving all frames in the receive buffer 2130 2123 * 2131 2124 * @param device The device to receive -
uspace/drv/nic/rtl8139/driver.h
r3ea725e r1bc35b5 39 39 /** Transmittion buffers count */ 40 40 #define TX_BUFF_COUNT 4 41 /** Size of buffer for one packet41 /** Size of buffer for one frame 42 42 * - 2kB 43 43 */ … … 49 49 #define RTL8139_CRC_SIZE 4 50 50 51 /** The default mode of accepting unicast packets */51 /** The default mode of accepting unicast frames */ 52 52 #define RTL8139_RCR_UCAST_DEFAULT RCR_ACCEPT_PHYS_MATCH 53 /** The default mode of accepting multicast packets */53 /** The default mode of accepting multicast frames */ 54 54 #define RTL8139_RCR_MCAST_DEFAULT 0 55 /** The default mode of accepting broadcast packets */55 /** The default mode of accepting broadcast frames */ 56 56 #define RTL8139_RCR_BCAST_DEFAULT RCR_ACCEPT_BROADCAST 57 /** The default mode of accepting defect packets */57 /** The default mode of accepting defect frames */ 58 58 #define RTL8139_RCR_DEFECT_DEFAULT 0 59 59 … … 112 112 size_t tx_used; 113 113 114 /** Buffer for receiving packets */114 /** Buffer for receiving frames */ 115 115 void *rx_buff_phys; 116 116 void *rx_buff_virt; -
uspace/lib/net/include/nil_remote.h
r3ea725e r1bc35b5 39 39 #include <generic.h> 40 40 #include <async.h> 41 #include <sys/types.h> 41 42 42 43 #define nil_bind_service(service, device_id, me, receiver) \ … … 61 62 size_t); 62 63 extern int nil_device_state_msg(async_sess_t *, nic_device_id_t, sysarg_t); 63 extern int nil_received_msg(async_sess_t *, nic_device_id_t, packet_id_t);64 extern int nil_received_msg(async_sess_t *, nic_device_id_t, void *, size_t); 64 65 extern int nil_addr_changed_msg(async_sess_t *, nic_device_id_t, 65 66 const nic_address_t *); -
uspace/lib/net/nil/nil_remote.c
r3ea725e r1bc35b5 77 77 */ 78 78 int nil_received_msg(async_sess_t *sess, nic_device_id_t device_id, 79 packet_id_t packet_id)79 void *data, size_t size) 80 80 { 81 return generic_received_msg_remote(sess, NET_NIL_RECEIVED, 82 device_id, packet_id, 0, 0); 81 async_exch_t *exch = async_exchange_begin(sess); 82 83 ipc_call_t answer; 84 aid_t req = async_send_1(exch, NET_NIL_RECEIVED, (sysarg_t) device_id, 85 &answer); 86 sysarg_t retval = async_data_write_start(exch, data, size); 87 88 async_exchange_end(exch); 89 90 if (retval != EOK) { 91 async_wait_for(req, NULL); 92 return retval; 93 } 94 95 async_wait_for(req, &retval); 96 return retval; 83 97 } 84 98 -
uspace/lib/nic/include/nic.h
r3ea725e r1bc35b5 61 61 62 62 /** 63 * Simple structure for sending the allocated frames (packets) in a list.63 * Simple structure for sending lists of frames. 64 64 */ 65 65 typedef struct { 66 66 link_t link; 67 packet_t *packet; 67 void *data; 68 size_t size; 68 69 } nic_frame_t; 69 70 … … 233 234 extern int nic_report_poll_mode(nic_t *, nic_poll_mode_t, struct timeval *); 234 235 extern void nic_query_address(nic_t *, nic_address_t *); 235 extern void nic_received_packet(nic_t *, packet_t *);236 236 extern void nic_received_noneth_packet(nic_t *, packet_t *); 237 237 extern void nic_received_frame(nic_t *, nic_frame_t *); -
uspace/lib/nic/include/nic_rx_control.h
r3ea725e r1bc35b5 120 120 const nic_address_t *prev_addr, const nic_address_t *curr_addr); 121 121 extern int nic_rxc_check(const nic_rxc_t *rxc, 122 const packet_t *packet, nic_frame_type_t *frame_type);122 const void *data, size_t size, nic_frame_type_t *frame_type); 123 123 extern void nic_rxc_hw_filtering(nic_rxc_t *rxc, 124 124 int unicast_exact, int multicast_exact, int vlan_exact); -
uspace/lib/nic/src/nic_driver.c
r3ea725e r1bc35b5 290 290 * 291 291 * @param nic_data The NIC driver data 292 * @param packet_size Size of packet 293 * @param offload_size Size of packet offload 292 * @param size Frame size in bytes 294 293 * @return pointer to allocated frame if success, NULL otherwise 295 294 */ 296 nic_frame_t *nic_alloc_frame(nic_t *nic_data, size_t packet_size)295 nic_frame_t *nic_alloc_frame(nic_t *nic_data, size_t size) 297 296 { 298 297 nic_frame_t *frame; … … 313 312 } 314 313 315 packet_t *packet = nic_alloc_packet(nic_data, packet_size);316 if ( !packet) {314 frame->data = malloc(size); 315 if (frame->data == NULL) { 317 316 free(frame); 318 317 return NULL; 319 318 } 320 319 321 frame-> packet = packet;320 frame->size = size; 322 321 return frame; 323 322 } … … 332 331 if (!frame) 333 332 return; 334 if (frame->packet != NULL) { 335 nic_release_packet(nic_data, frame->packet); 336 } 333 334 if (frame->data != NULL) { 335 free(frame->data); 336 frame->data = NULL; 337 frame->size = 0; 338 } 339 337 340 fibril_mutex_lock(&nic_globals.lock); 338 341 if (nic_globals.frame_cache_size >= NIC_GLOBALS_MAX_CACHE_SIZE) { … … 622 625 623 626 /** 624 * Provided for correct naming conventions.625 * The packetis checked by filters and then sent up to the NIL layer or626 * discarded , the frame is released.627 * 628 * @param nic_data 629 * @param frame The frame containing received packet627 * This is the function that the driver should call when it receives a frame. 628 * The frame is checked by filters and then sent up to the NIL layer or 629 * discarded. The frame is released. 630 * 631 * @param nic_data 632 * @param frame The received frame 630 633 */ 631 634 void nic_received_frame(nic_t *nic_data, nic_frame_t *frame) 632 {633 nic_received_packet(nic_data, frame->packet);634 frame->packet = NULL;635 nic_release_frame(nic_data, frame);636 }637 638 /**639 * This is the function that the driver should call when it receives a packet.640 * The packet is checked by filters and then sent up to the NIL layer or641 * discarded.642 *643 * @param nic_data644 * @param packet The received packet645 */646 void nic_received_packet(nic_t *nic_data, packet_t *packet)647 635 { 648 636 /* Note: this function must not lock main lock, because loopback driver 649 637 * calls it inside write_packet handler (with locked main lock) */ 650 packet_id_t pid = packet_get_id(packet);651 652 638 fibril_rwlock_read_lock(&nic_data->rxc_lock); 653 639 nic_frame_type_t frame_type; 654 int check = nic_rxc_check(&nic_data->rx_control, packet, &frame_type); 640 int check = nic_rxc_check(&nic_data->rx_control, frame->data, 641 frame->size, &frame_type); 655 642 fibril_rwlock_read_unlock(&nic_data->rxc_lock); 656 643 /* Update statistics */ … … 659 646 if (nic_data->state == NIC_STATE_ACTIVE && check) { 660 647 nic_data->stats.receive_packets++; 661 nic_data->stats.receive_bytes += packet_get_data_length(packet);648 nic_data->stats.receive_bytes += frame->size; 662 649 switch (frame_type) { 663 650 case NIC_FRAME_MULTICAST: … … 671 658 } 672 659 fibril_rwlock_write_unlock(&nic_data->stats_lock); 673 nil_received_msg(nic_data->nil_session, nic_data->device_id, pid); 660 nil_received_msg(nic_data->nil_session, nic_data->device_id, 661 frame->data, frame->size); 674 662 } else { 675 663 switch (frame_type) { … … 685 673 } 686 674 fibril_rwlock_write_unlock(&nic_data->stats_lock); 687 nic_release_packet(nic_data, packet);688 }675 } 676 nic_release_frame(nic_data, frame); 689 677 } 690 678 … … 705 693 706 694 nil_received_msg(nic_data->nil_session, nic_data->device_id, 707 packet_get_ id(packet));695 packet_get_data(packet), packet_get_data_length(packet)); 708 696 } 709 697 … … 726 714 727 715 list_remove(&frame->link); 728 nic_received_packet(nic_data, frame->packet); 729 frame->packet = NULL; 730 nic_release_frame(nic_data, frame); 716 nic_received_frame(nic_data, frame); 731 717 } 732 718 nic_driver_release_frame_list(frames); -
uspace/lib/nic/src/nic_rx_control.c
r3ea725e r1bc35b5 392 392 * 393 393 * @param rxc 394 * @param packetThe probed frame394 * @param frame The probed frame 395 395 * 396 396 * @return True if the frame passes, false if it does not 397 397 */ 398 int nic_rxc_check(const nic_rxc_t *rxc, const packet_t *packet,398 int nic_rxc_check(const nic_rxc_t *rxc, const void *data, size_t size, 399 399 nic_frame_type_t *frame_type) 400 400 { 401 401 assert(frame_type != NULL); 402 uint8_t *dest_addr = (uint8_t *) packet + packet->data_start;402 uint8_t *dest_addr = (uint8_t *) data; 403 403 uint8_t *src_addr = dest_addr + ETH_ADDR; 404 405 if (size < 2 * ETH_ADDR) 406 return false; 404 407 405 408 if (dest_addr[0] & 1) { … … 448 451 if (!rxc->vlan_exact && rxc->vlan_mask != NULL) { 449 452 vlan_header_t *vlan_header = (vlan_header_t *) 450 ((uint8_t *) packet + packet->data_start+ 2 * ETH_ADDR);453 ((uint8_t *) data + 2 * ETH_ADDR); 451 454 if (vlan_header->tpid_upper == VLAN_TPID_UPPER && 452 455 vlan_header->tpid_lower == VLAN_TPID_LOWER) { -
uspace/srv/net/nil/eth/eth.c
r3ea725e r1bc35b5 814 814 } 815 815 816 static int eth_received(nic_device_id_t device_id) 817 { 818 void *data; 819 size_t size; 820 int rc; 821 822 rc = async_data_write_accept(&data, false, 0, 0, 0, &size); 823 if (rc != EOK) 824 return rc; 825 826 packet_t *packet = packet_get_1_remote(eth_globals.net_sess, size); 827 if (packet == NULL) 828 return ENOMEM; 829 830 void *pdata = packet_suffix(packet, size); 831 memcpy(pdata, data, size); 832 free(data); 833 834 return nil_received_msg_local(device_id, packet); 835 } 836 816 837 static int eth_addr_changed(nic_device_id_t device_id) 817 838 { … … 926 947 return EOK; 927 948 case NET_NIL_RECEIVED: 928 rc = packet_translate_remote(eth_globals.net_sess, &packet, 929 IPC_GET_ARG2(*call)); 930 if (rc == EOK) 931 rc = nil_received_msg_local(IPC_GET_ARG1(*call), packet); 932 949 rc = eth_received(IPC_GET_ARG1(*call)); 933 950 async_answer_0(callid, (sysarg_t) rc); 934 951 return rc; -
uspace/srv/net/nil/nildummy/nildummy.c
r3ea725e r1bc35b5 370 370 } 371 371 372 static int nildummy_received(nic_device_id_t device_id) 373 { 374 void *data; 375 size_t size; 376 int rc; 377 378 rc = async_data_write_accept(&data, false, 0, 0, 0, &size); 379 if (rc != EOK) 380 return rc; 381 382 packet_t *packet = packet_get_1_remote(nildummy_globals.net_sess, size); 383 if (packet == NULL) 384 return ENOMEM; 385 386 void *pdata = packet_suffix(packet, size); 387 memcpy(pdata, data, size); 388 free(pdata); 389 390 return nil_received_msg_local(device_id, packet); 391 } 392 372 393 int nil_module_message(ipc_callid_t callid, ipc_call_t *call, 373 394 ipc_call_t *answer, size_t *answer_count) … … 431 452 432 453 case NET_NIL_RECEIVED: 433 rc = packet_translate_remote(nildummy_globals.net_sess, &packet, 434 IPC_GET_ARG2(*call)); 435 if (rc == EOK) 436 rc = nil_received_msg_local(IPC_GET_ARG1(*call), packet); 437 454 rc = nildummy_received(IPC_GET_ARG1(*call)); 438 455 async_answer_0(callid, (sysarg_t) rc); 439 456 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.