Changeset cbfece7 in mainline for uspace/drv/nic
- Timestamp:
- 2014-07-21T22:10:18Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f1fa64
- Parents:
- 96e368a (diff), 54a1ca7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/drv/nic
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
r96e368a rcbfece7 33 33 */ 34 34 35 /* XXX Fix this */36 #define _DDF_DATA_IMPLANT37 38 35 #include <assert.h> 39 36 #include <stdio.h> … … 42 39 #include <align.h> 43 40 #include <byteorder.h> 44 #include <sysinfo.h> 45 #include <ipc/irc.h> 46 #include <ipc/ns.h> 41 #include <irc.h> 42 #include <as.h> 47 43 #include <ddi.h> 48 #include <as.h>49 44 #include <ddf/log.h> 50 45 #include <ddf/interrupt.h> … … 1758 1753 e1000_enable_interrupts(e1000); 1759 1754 1760 nic_enable_interrupt(nic, e1000->irq); 1755 int rc = irc_enable_interrupt(e1000->irq); 1756 if (rc != EOK) { 1757 e1000_disable_interrupts(e1000); 1758 fibril_mutex_unlock(&e1000->ctrl_lock); 1759 fibril_mutex_unlock(&e1000->tx_lock); 1760 fibril_mutex_unlock(&e1000->rx_lock); 1761 return rc; 1762 } 1761 1763 1762 1764 e1000_clear_rx_ring(e1000); … … 1796 1798 e1000_disable_rx(e1000); 1797 1799 1798 nic_disable_interrupt(nic,e1000->irq);1800 irc_disable_interrupt(e1000->irq); 1799 1801 e1000_disable_interrupts(e1000); 1800 1802 … … 2148 2150 nic_set_ddf_fun(nic, fun); 2149 2151 ddf_fun_set_ops(fun, &e1000_dev_ops); 2150 ddf_fun_data_implant(fun, nic);2151 2152 2152 2153 rc = e1000_register_int_handler(nic); 2153 2154 if (rc != EOK) 2154 2155 goto err_fun_create; 2155 2156 rc = nic_connect_to_services(nic);2157 if (rc != EOK)2158 goto err_irq;2159 2156 2160 2157 rc = e1000_initialize_rx_structure(nic); … … 2379 2376 int main(void) 2380 2377 { 2381 int rc = nic_driver_init(NAME); 2382 if (rc != EOK) 2383 return rc; 2378 printf("%s: HelenOS E1000 network adapter driver\n", NAME); 2379 2380 if (nic_driver_init(NAME) != EOK) 2381 return 1; 2384 2382 2385 2383 nic_driver_implement(&e1000_driver_ops, &e1000_dev_ops, … … 2387 2385 2388 2386 ddf_log_init(NAME); 2389 ddf_msg(LVL_NOTE, "HelenOS E1000 driver started");2390 2387 return ddf_driver_main(&e1000_driver); 2391 2388 } -
uspace/drv/nic/ne2k/ne2k.c
r96e368a rcbfece7 38 38 */ 39 39 40 /* XXX Fix this */41 #define _DDF_DATA_IMPLANT42 43 40 #include <stdio.h> 44 41 #include <errno.h> 42 #include <irc.h> 45 43 #include <stdlib.h> 46 44 #include <str_error.h> … … 256 254 if (!ne2k->up) { 257 255 int rc = ne2k_up(ne2k); 256 if (rc != EOK) 257 return rc; 258 259 rc = irc_enable_interrupt(ne2k->irq); 258 260 if (rc != EOK) { 261 ne2k_down(ne2k); 259 262 return rc; 260 263 } 261 262 nic_enable_interrupt(nic_data, ne2k->irq);263 264 } 264 265 return EOK; … … 269 270 ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data); 270 271 271 nic_disable_interrupt(nic_data,ne2k->irq);272 (void) irc_disable_interrupt(ne2k->irq); 272 273 ne2k->receive_configuration = RCR_AB | RCR_AM; 273 274 ne2k_down(ne2k); … … 396 397 } 397 398 398 rc = nic_connect_to_services(nic_data);399 if (rc != EOK) {400 ne2k_dev_cleanup(dev);401 return rc;402 }403 404 399 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0"); 405 400 if (fun == NULL) { … … 407 402 return ENOMEM; 408 403 } 404 409 405 nic_set_ddf_fun(nic_data, fun); 410 406 ddf_fun_set_ops(fun, &ne2k_dev_ops); 411 ddf_fun_data_implant(fun, nic_data);412 407 413 408 rc = ddf_fun_bind(fun); … … 443 438 int main(int argc, char *argv[]) 444 439 { 440 printf("%s: HelenOS NE 2000 network adapter driver\n", NAME); 441 445 442 nic_driver_init(NAME); 446 443 nic_driver_implement(&ne2k_driver_ops, &ne2k_dev_ops, &ne2k_nic_iface); -
uspace/drv/nic/rtl8139/driver.c
r96e368a rcbfece7 27 27 */ 28 28 29 /* XXX Fix this */30 #define _DDF_DATA_IMPLANT31 32 29 #include <assert.h> 33 30 #include <errno.h> … … 35 32 #include <byteorder.h> 36 33 #include <libarch/barrier.h> 37 38 34 #include <as.h> 39 35 #include <ddf/log.h> … … 42 38 #include <nic.h> 43 39 #include <pci_dev_iface.h> 44 45 #include <ipc/irc.h> 46 #include <sysinfo.h> 47 #include <ipc/ns.h> 48 40 #include <irc.h> 41 #include <stdio.h> 49 42 #include <str.h> 50 43 … … 960 953 rtl8139->int_mask = RTL_DEFAULT_INTERRUPTS; 961 954 rtl8139_hw_int_enable(rtl8139); 962 nic_enable_interrupt(nic_data, rtl8139->irq); 955 956 int rc = irc_enable_interrupt(rtl8139->irq); 957 if (rc != EOK) { 958 rtl8139_on_stopped(nic_data); 959 return rc; 960 } 963 961 964 962 ddf_msg(LVL_DEBUG, "Device activated, interrupt %d registered", rtl8139->irq); … … 1325 1323 goto err_pio; 1326 1324 1327 rc = nic_connect_to_services(nic_data);1328 if (rc != EOK) {1329 ddf_msg(LVL_ERROR, "Failed to connect to services (%d)", rc);1330 goto err_irq;1331 }1332 1333 1325 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0"); 1334 1326 if (fun == NULL) { … … 1336 1328 goto err_srv; 1337 1329 } 1330 1338 1331 nic_set_ddf_fun(nic_data, fun); 1339 1332 ddf_fun_set_ops(fun, &rtl8139_dev_ops); 1340 ddf_fun_data_implant(fun, nic_data);1341 1333 1342 1334 rc = ddf_fun_bind(fun); … … 1361 1353 ddf_fun_destroy(fun); 1362 1354 err_srv: 1363 /* XXX Disconnect from services */1364 err_irq:1365 1355 unregister_interrupt_handler(dev, rtl8139->irq); 1366 1356 err_pio: … … 2180 2170 int main(void) 2181 2171 { 2172 printf("%s: HelenOS RTL8139 network adapter driver\n", NAME); 2173 2182 2174 int rc = nic_driver_init(NAME); 2183 2175 if (rc != EOK) 2184 2176 return rc; 2185 nic_driver_implement( 2186 &rtl8139_driver_ops, &rtl8139_dev_ops, &rtl8139_nic_iface); 2177 2178 nic_driver_implement(&rtl8139_driver_ops, &rtl8139_dev_ops, 2179 &rtl8139_nic_iface); 2187 2180 2188 2181 ddf_log_init(NAME); 2189 ddf_msg(LVL_NOTE, "HelenOS RTL8139 driver started");2190 2182 return ddf_driver_main(&rtl8139_driver); 2191 2183 } -
uspace/drv/nic/rtl8169/defs.h
r96e368a rcbfece7 39 39 #include <sys/types.h> 40 40 #include <ddi.h> 41 42 #define PCI_VID_REALTEK 0x10ec 43 #define PCI_VID_DLINK 0x1186 41 44 42 45 /** Size of RTL8169 registers address space */ -
uspace/drv/nic/rtl8169/driver.c
r96e368a rcbfece7 33 33 #include <align.h> 34 34 #include <byteorder.h> 35 #include <irc.h> 35 36 #include <libarch/barrier.h> 36 37 … … 388 389 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 389 390 391 /* Get PCI VID & PID */ 392 rc = pci_config_space_read_16(ddf_dev_parent_sess_get(dev), 393 PCI_VENDOR_ID, &rtl8169->pci_vid); 394 if (rc != EOK) 395 return rc; 396 397 rc = pci_config_space_read_16(ddf_dev_parent_sess_get(dev), 398 PCI_DEVICE_ID, &rtl8169->pci_pid); 399 if (rc != EOK) 400 return rc; 401 390 402 /* Map register space */ 391 403 rc = pio_enable(rtl8169->regs_phys, RTL8169_IO_SIZE, &rtl8169->regs); … … 418 430 uint8_t cr_value = pio_read_8(rtl8169->regs + CR); 419 431 pio_write_8(rtl8169->regs + CR, cr_value | CR_TE | CR_RE); 420 421 rc = nic_connect_to_services(nic_data);422 if (rc != EOK) {423 ddf_msg(LVL_ERROR, "Failed to connect to services (%d)", rc);424 goto err_irq;425 }426 432 427 433 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0"); … … 473 479 int rc; 474 480 475 rtl8169_set_hwaddr(rtl8169, addr); 481 fibril_mutex_lock(&rtl8169->rx_lock); 482 fibril_mutex_lock(&rtl8169->tx_lock); 476 483 477 484 rc = nic_report_address(nic_data, addr); … … 479 486 return rc; 480 487 488 rtl8169_set_hwaddr(rtl8169, addr); 489 490 fibril_mutex_unlock(&rtl8169->rx_lock); 491 fibril_mutex_unlock(&rtl8169->tx_lock); 492 481 493 return EOK; 482 494 } … … 484 496 static int rtl8169_get_device_info(ddf_fun_t *fun, nic_device_info_t *info) 485 497 { 486 487 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "Realtek"); 488 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8169"); 498 nic_t *nic_data = nic_get_from_ddf_fun(fun); 499 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 500 501 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "Unknown"); 502 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "Unknown"); 503 504 if (rtl8169->pci_vid == PCI_VID_REALTEK) 505 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "Realtek"); 506 507 if (rtl8169->pci_vid == PCI_VID_DLINK) 508 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "D-Link"); 509 510 if (rtl8169->pci_pid == 0x8168) 511 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8168"); 512 513 if (rtl8169->pci_pid == 0x8169) 514 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8169"); 515 516 if (rtl8169->pci_pid == 0x8110) 517 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8110"); 489 518 490 519 return EOK; … … 541 570 bmcr &= ~(BMCR_DUPLEX | BMCR_SPD_100 | BMCR_SPD_1000); 542 571 572 /* Disable autonegotiation */ 573 bmcr &= ~BMCR_AN_ENABLE; 574 543 575 if (duplex == NIC_CM_FULL_DUPLEX) 544 576 bmcr |= BMCR_DUPLEX; … … 609 641 static int rtl8169_autoneg_restart(ddf_fun_t *fun) 610 642 { 643 rtl8169_t *rtl8169 = nic_get_specific(nic_get_from_ddf_fun(fun)); 644 uint16_t bmcr = rtl8169_mii_read(rtl8169, MII_BMCR); 645 646 bmcr |= BMCR_AN_ENABLE; 647 rtl8169_mii_write(rtl8169, MII_BMCR, bmcr); 611 648 return EOK; 612 649 } … … 706 743 707 744 pio_write_16(rtl8169->regs + IMR, 0xffff); 708 nic_enable_interrupt(nic_data,rtl8169->irq);745 irc_enable_interrupt(rtl8169->irq); 709 746 710 747 return EOK; … … 888 925 } 889 926 927 /* Receive underrun */ 928 if (isr & INT_RXOVW) { 929 /* just ack.. */ 930 pio_write_16(rtl8169->regs + ISR, INT_RXOVW); 931 } 932 890 933 if (isr & INT_SERR) { 891 934 ddf_msg(LVL_ERROR, "System error interrupt"); -
uspace/drv/nic/rtl8169/driver.h
r96e368a rcbfece7 55 55 /** The irq assigned */ 56 56 int irq; 57 /** PCI Vendor and Product ids */ 58 uint16_t pci_vid; 59 uint16_t pci_pid; 57 60 /** Mask of the turned interupts (IMR value) */ 58 61 uint16_t int_mask;
Note:
See TracChangeset
for help on using the changeset viewer.