Changes in uspace/drv/nic/rtl8169/driver.c [a4666a9:8820544] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8169/driver.c
ra4666a9 r8820544 27 27 */ 28 28 29 #define _DDF_DATA_IMPLANT 30 29 31 #include <assert.h> 30 32 #include <errno.h> … … 328 330 } 329 331 330 static void rtl8169_dev_cleanup(ddf_dev_t *dev)331 {332 assert(dev);333 334 if (ddf_dev_data_get(dev))335 nic_unbind_and_destroy(dev);336 }337 338 332 static int rtl8169_dev_initialize(ddf_dev_t *dev) 339 333 { … … 357 351 failed: 358 352 ddf_msg(LVL_ERROR, "The device initialization failed"); 359 rtl8169_dev_cleanup(dev);353 // rtl8139_dev_cleanup(dev); 360 354 return ret; 361 355 … … 445 439 nic_set_ddf_fun(nic_data, fun); 446 440 ddf_fun_set_ops(fun, &rtl8169_dev_ops); 441 // ddf_fun_data_implant(fun, nic_data); 447 442 448 443 rc = ddf_fun_bind(fun); … … 472 467 err_pio: 473 468 err_destroy: 474 rtl8169_dev_cleanup(dev);469 //rtl8169_dev_cleanup(dev); 475 470 return rc; 476 471 … … 738 733 /* Configure Receive Control Register */ 739 734 uint32_t rcr = pio_read_32(rtl8169->regs + RCR); 740 rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH; 741 rcr |= RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ERROR | RCR_ACCEPT_RUNT; 735 rcr |= RCR_ACCEPT_ALL_PHYS | RCR_ACCEPT_PHYS_MATCH \ 736 | RCR_ACCEPT_BROADCAST | RCR_ACCEPT_ERROR \ 737 | RCR_ACCEPT_RUNT; 742 738 pio_write_32(rtl8169->regs + RCR, rcr); 743 739 pio_write_16(rtl8169->regs + RMS, BUFFER_SIZE); 740 741 ddf_msg(LVL_NOTE, "RCR: 0x%08x", pio_read_32(rtl8169->regs + RCR)); 742 744 743 745 744 pio_write_16(rtl8169->regs + IMR, 0xffff); … … 794 793 } 795 794 796 /** Notify NIC framework about HW filtering state when promisc mode was disabled797 *798 * @param nic_data The NIC data799 * @param mcast_mode Current multicast mode800 * @param was_promisc Sign if the promiscuous mode was active before disabling801 */802 inline static void rtl8169_rcx_promics_rem(nic_t *nic_data,803 nic_multicast_mode_t mcast_mode, uint8_t was_promisc)804 {805 assert(nic_data);806 807 if (was_promisc != 0) {808 if (mcast_mode == NIC_MULTICAST_LIST)809 nic_report_hw_filtering(nic_data, 1, 0, -1);810 else811 nic_report_hw_filtering(nic_data, 1, 1, -1);812 } else {813 nic_report_hw_filtering(nic_data, 1, -1, -1);814 }815 }816 817 795 static int rtl8169_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode, 818 796 const nic_address_t *addr, size_t addr_count) 819 797 { 820 rtl8169_t *rtl8169 = nic_get_specific(nic_data);821 uint32_t rcr = pio_read_32(rtl8169->regs + RCR);822 uint8_t was_promisc = rcr & RCR_ACCEPT_ALL_PHYS;823 nic_multicast_mode_t mcast_mode;824 825 nic_query_multicast(nic_data, &mcast_mode, 0, NULL, NULL);826 827 ddf_msg(LVL_DEBUG, "Unicast RX filter mode: %d", mode);828 829 830 switch (mode) {831 case NIC_UNICAST_BLOCKED:832 rtl8169->rcr_ucast = 0;833 rtl8169_rcx_promics_rem(nic_data, mcast_mode, was_promisc);834 break;835 case NIC_UNICAST_DEFAULT:836 rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH;837 rtl8169_rcx_promics_rem(nic_data, mcast_mode, was_promisc);838 break;839 case NIC_UNICAST_LIST:840 rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS;841 842 if (mcast_mode == NIC_MULTICAST_PROMISC)843 nic_report_hw_filtering(nic_data, 0, 1, -1);844 else845 nic_report_hw_filtering(nic_data, 0, 0, -1);846 break;847 case NIC_UNICAST_PROMISC:848 rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS;849 850 if (mcast_mode == NIC_MULTICAST_PROMISC)851 nic_report_hw_filtering(nic_data, 1, 1, -1);852 else853 nic_report_hw_filtering(nic_data, 1, 0, -1);854 break;855 default:856 return ENOTSUP;857 }858 859 fibril_mutex_lock(&rtl8169->rx_lock);860 861 rcr &= ~(RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS);862 pio_write_32(rtl8169->regs + RCR, rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast);863 ddf_msg(LVL_DEBUG, "new RCR value: 0x%08x", rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast);864 865 fibril_mutex_unlock(&rtl8169->rx_lock);866 798 return EOK; 867 799 } … … 870 802 const nic_address_t *addr, size_t addr_count) 871 803 { 872 rtl8169_t *rtl8169 = nic_get_specific(nic_data);873 uint32_t rcr = pio_read_32(rtl8169->regs + RCR);874 uint64_t mask;875 876 ddf_msg(LVL_DEBUG, "Multicast RX filter mode: %d", mode);877 878 switch (mode) {879 case NIC_MULTICAST_BLOCKED:880 rtl8169->rcr_mcast = 0;881 if ((rtl8169->rcr_ucast & RCR_ACCEPT_ALL_PHYS) != 0)882 nic_report_hw_filtering(nic_data, -1, 0, -1);883 else884 nic_report_hw_filtering(nic_data, -1, 1, -1);885 break;886 case NIC_MULTICAST_LIST:887 mask = nic_mcast_hash(addr, addr_count);888 pio_write_32(rtl8169->regs + MAR0, (uint32_t)mask);889 pio_write_32(rtl8169->regs + MAR0 + 4, (uint32_t)(mask >> 32));890 rtl8169->rcr_mcast = RCR_ACCEPT_MULTICAST;891 nic_report_hw_filtering(nic_data, -1, 0, -1);892 break;893 case NIC_MULTICAST_PROMISC:894 pio_write_32(rtl8169->regs + MAR0, 0xffffffffULL);895 pio_write_32(rtl8169->regs + MAR0 + 4, (uint32_t)(0xffffffffULL >> 32));896 rtl8169->rcr_mcast = RCR_ACCEPT_MULTICAST;897 nic_report_hw_filtering(nic_data, -1, 1, -1);898 break;899 default:900 return ENOTSUP;901 }902 903 fibril_mutex_lock(&rtl8169->rx_lock);904 905 rcr &= ~(RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS);906 pio_write_32(rtl8169->regs + RCR, rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast);907 ddf_msg(LVL_DEBUG, "new RCR value: 0x%08x", rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast);908 909 fibril_mutex_unlock(&rtl8169->rx_lock);910 804 return EOK; 911 805 } … … 913 807 static int rtl8169_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode) 914 808 { 915 rtl8169_t *rtl8169 = nic_get_specific(nic_data);916 917 /* Configure Receive Control Register */918 uint32_t rcr = pio_read_32(rtl8169->regs + RCR);919 920 ddf_msg(LVL_DEBUG, "Broadcast RX filter mode: %d", mode);921 922 switch (mode) {923 case NIC_BROADCAST_BLOCKED:924 rcr &= ~RCR_ACCEPT_BROADCAST;925 break;926 case NIC_BROADCAST_ACCEPTED:927 rcr |= RCR_ACCEPT_BROADCAST;928 break;929 default:930 return ENOTSUP;931 }932 933 pio_write_32(rtl8169->regs + RCR, rcr);934 ddf_msg(LVL_DEBUG," new RCR value: 0x%08x", rcr);935 936 809 return EOK; 937 810 } … … 943 816 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 944 817 rtl8169_descr_t *descr; 945 int sent = 0; 946 947 ddf_msg(LVL_DEBUG, "rtl8169_transmit_done()"); 818 819 ddf_msg(LVL_NOTE, "rtl8169_transmit_done()"); 948 820 949 821 fibril_mutex_lock(&rtl8169->tx_lock); … … 956 828 descr->control &= (~CONTROL_OWN); 957 829 write_barrier(); 958 ddf_msg(LVL_ DEBUG, "TX status for descr %d: 0x%08x", tail, descr->control);830 ddf_msg(LVL_NOTE, "TX status for descr %d: 0x%08x", tail, descr->control); 959 831 960 832 tail = (tail + 1) % TX_BUFFERS_COUNT; 961 sent++; 962 } 963 964 if (sent != 0) 965 nic_set_tx_busy(nic_data, 0); 833 } 966 834 967 835 rtl8169->tx_tail = tail; … … 981 849 int frame_size; 982 850 983 ddf_msg(LVL_ DEBUG, "rtl8169_receive_done()");851 ddf_msg(LVL_NOTE, "rtl8169_receive_done()"); 984 852 985 853 fibril_mutex_lock(&rtl8169->rx_lock); … … 994 862 995 863 if (descr->control & RXSTATUS_RES) { 996 ddf_msg(LVL_ WARN, "error at slot %d: 0x%08x\n", tail, descr->control);864 ddf_msg(LVL_NOTE, "error at slot %d: 0x%08x\n", tail, descr->control); 997 865 tail = (tail + 1) % RX_BUFFERS_COUNT; 998 866 continue; … … 1003 871 1004 872 if (descr->control & CONTROL_LS) { 1005 ddf_msg(LVL_DEBUG, "received message at slot %d, control 0x%08x", tail, descr->control); 873 874 ddf_msg(LVL_NOTE, "received message at slot %d, control 0x%08x", tail, descr->control); 1006 875 1007 876 if (fsidx != tail) … … 1038 907 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 1039 908 1040 ddf_msg(LVL_ DEBUG, "rtl8169_irq_handler(): isr=0x%04x", isr);909 ddf_msg(LVL_NOTE, "rtl8169_irq_handler(): isr=0x%04x", isr); 1041 910 pio_write_16(rtl8169->regs + IMR, 0xffff); 1042 911 … … 1094 963 fibril_mutex_lock(&rtl8169->tx_lock); 1095 964 1096 ddf_msg(LVL_ DEBUG, "send_frame: size: %zu, tx_head=%d tx_tail=%d",965 ddf_msg(LVL_NOTE, "send_frame: size: %zu, tx_head=%d tx_tail=%d", 1097 966 size, rtl8169->tx_head, rtl8169->tx_tail); 1098 967 … … 1117 986 prev = &rtl8169->tx_ring[(head - 1) % TX_BUFFERS_COUNT]; 1118 987 1119 ddf_msg(LVL_ DEBUG, "current_descr=%p, prev_descr=%p", descr, prev);988 ddf_msg(LVL_NOTE, "current_descr=%p, prev_descr=%p", descr, prev); 1120 989 1121 990 descr->control = CONTROL_OWN | CONTROL_FS | CONTROL_LS;
Note:
See TracChangeset
for help on using the changeset viewer.