Changeset 3bacee1 in mainline for uspace/drv/nic/rtl8139
- Timestamp:
- 2018-04-12T16:27:17Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3cf22f9
- Parents:
- 76d0981d
- git-author:
- Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
- File:
-
- 1 edited
-
uspace/drv/nic/rtl8139/driver.c (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8139/driver.c
r76d0981d r3bacee1 95 95 #ifndef RXBUF_SIZE_FLAGS 96 96 /** Flags for receiver buffer - 16kB default */ 97 #define RXBUF_SIZE_FLAGS RTL8139_RXFLAGS_SIZE_1697 #define RXBUF_SIZE_FLAGS RTL8139_RXFLAGS_SIZE_16 98 98 #endif 99 99 100 100 #if (RXBUF_SIZE_FLAGS > RTL8139_RXFLAGS_SIZE_64) || (RXBUF_SIZE_FLAGS < 0) 101 #error Bad receiver buffer flags size flags101 #error Bad receiver buffer flags size flags 102 102 #endif 103 103 … … 152 152 static void rtl8139_hw_update_rcr(rtl8139_t *rtl8139) 153 153 { 154 uint32_t rcr = rtl8139->rcr_data.rcr_base | rtl8139->rcr_data.ucast_mask 155 | rtl8139->rcr_data.mcast_mask | rtl8139->rcr_data.bcast_mask156 |rtl8139->rcr_data.defect_mask |154 uint32_t rcr = rtl8139->rcr_data.rcr_base | rtl8139->rcr_data.ucast_mask | 155 rtl8139->rcr_data.mcast_mask | rtl8139->rcr_data.bcast_mask | 156 rtl8139->rcr_data.defect_mask | 157 157 (RXBUF_SIZE_FLAGS << RCR_RBLEN_SHIFT); 158 158 … … 199 199 200 200 async_sess_t *pci_sess = 201 ddf_dev_parent_sess_get(nic_get_ddf_dev(rtl8139->nic_data));201 ddf_dev_parent_sess_get(nic_get_ddf_dev(rtl8139->nic_data)); 202 202 203 203 if (bit_val) { … … 243 243 assert(addr); 244 244 245 const uint32_t *val1 = (const uint32_t *)addr->address;246 const uint16_t *val2 = (const uint16_t *)(addr->address + sizeof(uint32_t));245 const uint32_t *val1 = (const uint32_t *)addr->address; 246 const uint16_t *val2 = (const uint16_t *)(addr->address + sizeof(uint32_t)); 247 247 248 248 rtl8139_regs_unlock(rtl8139->io_port); … … 258 258 * @param bits_add The value to or 259 259 */ 260 inline static void rtl8139_hw_reg_add_8(rtl8139_t * rtl8139, size_t reg_offset,260 inline static void rtl8139_hw_reg_add_8(rtl8139_t *rtl8139, size_t reg_offset, 261 261 uint8_t bits_add) 262 262 { … … 272 272 * @param bits_add The mask of bits to remove 273 273 */ 274 inline static void rtl8139_hw_reg_rem_8(rtl8139_t * rtl8139, size_t reg_offset,274 inline static void rtl8139_hw_reg_rem_8(rtl8139_t *rtl8139, size_t reg_offset, 275 275 uint8_t bits_add) 276 276 { … … 288 288 nic_channel_mode_t duplex, nic_role_t); 289 289 290 static errno_t rtl8139_pause_get(ddf_fun_t *, nic_result_t*, nic_result_t*,290 static errno_t rtl8139_pause_get(ddf_fun_t *, nic_result_t *, nic_result_t *, 291 291 uint16_t *); 292 static errno_t rtl8139_pause_set(ddf_fun_t *, int, int, uint16_t);292 static errno_t rtl8139_pause_set(ddf_fun_t *, int, int, uint16_t); 293 293 294 294 static errno_t rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement); … … 303 303 304 304 static errno_t rtl8139_wol_virtue_add(nic_t *nic_data, 305 const nic_wol_virtue_t *virtue);305 const nic_wol_virtue_t *virtue); 306 306 static void rtl8139_wol_virtue_rem(nic_t *nic_data, 307 const nic_wol_virtue_t *virtue);307 const nic_wol_virtue_t *virtue); 308 308 309 309 static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode, … … 434 434 pio_write_8(io_base + CR, CR_RST); 435 435 memory_barrier(); 436 while (pio_read_8(io_base + CR) & CR_RST) {436 while (pio_read_8(io_base + CR) & CR_RST) { 437 437 async_usleep(1); 438 438 read_barrier(); … … 481 481 { 482 482 nic_frame_t *frame = nic_alloc_frame(nic_data, frame_size); 483 if (! frame) {483 if (!frame) { 484 484 ddf_msg(LVL_ERROR, "Can not allocate frame for received frame."); 485 485 return NULL; … … 560 560 while (!rtl8139_hw_buffer_empty(rtl8139)) { 561 561 void *rx_ptr = rx_buffer + rx_offset % RxBUF_SIZE; 562 uint32_t frame_header = uint32_t_le2host( *((uint32_t*)rx_ptr));562 uint32_t frame_header = uint32_t_le2host(*((uint32_t *)rx_ptr)); 563 563 uint16_t size = frame_header >> 16; 564 564 uint16_t frame_size = size - RTL8139_CRC_SIZE; … … 580 580 } 581 581 if (size < RTL8139_RUNT_MAX_SIZE && !(rcs & RSR_RUNT)) { 582 ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (%" PRIx16")", size);582 ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (%" PRIx16 ")", size); 583 583 goto rx_err; 584 584 } … … 680 680 while (tx_used != tx_next) { 681 681 size_t desc_to_check = tx_used % TX_BUFF_COUNT; 682 void * tsd_to_check = rtl8139->io_port + TSD0683 +desc_to_check * sizeof(uint32_t);682 void *tsd_to_check = rtl8139->io_port + TSD0 + 683 desc_to_check * sizeof(uint32_t); 684 684 uint32_t tsd_value = pio_read_32(tsd_to_check); 685 685 … … 757 757 pio_write_32(rtl8139->io_port + TIMERINT, timer_val); 758 758 pio_write_32(rtl8139->io_port + TCTR, 0x0); 759 ddf_msg(LVL_DEBUG, "rtl8139 timer: %" PRIu32"\treceive: %d", timer_val, receive);759 ddf_msg(LVL_DEBUG, "rtl8139 timer: %" PRIu32 "\treceive: %d", timer_val, receive); 760 760 return receive; 761 761 } … … 784 784 receive = rtl8139_poll_interrupt(nic_data); 785 785 } 786 if (! receive)786 if (!receive) 787 787 return; 788 788 } … … 883 883 884 884 /* Write transmittion buffer addresses */ 885 for (i = 0; i < TX_BUFF_COUNT; ++i) {886 uint32_t addr = PTR2U32(rtl8139->tx_buff_phys + i *TX_BUFF_SIZE);887 pio_write_32(io_base + TSAD0 + 4 *i, addr);885 for (i = 0; i < TX_BUFF_COUNT; ++i) { 886 uint32_t addr = PTR2U32(rtl8139->tx_buff_phys + i * TX_BUFF_SIZE); 887 pio_write_32(io_base + TSAD0 + 4 * i, addr); 888 888 } 889 889 rtl8139->tx_next = 0; … … 988 988 nic_set_send_frame_handler(nic_data, rtl8139_send_frame); 989 989 nic_set_state_change_handlers(nic_data, 990 rtl8139_on_activated, NULL, rtl8139_on_stopped);990 rtl8139_on_activated, NULL, rtl8139_on_stopped); 991 991 nic_set_filtering_change_handlers(nic_data, 992 rtl8139_unicast_set, rtl8139_multicast_set, rtl8139_broadcast_set,993 NULL, NULL);992 rtl8139_unicast_set, rtl8139_multicast_set, rtl8139_broadcast_set, 993 NULL, NULL); 994 994 nic_set_wol_virtue_change_handlers(nic_data, 995 rtl8139_wol_virtue_add, rtl8139_wol_virtue_rem);995 rtl8139_wol_virtue_add, rtl8139_wol_virtue_rem); 996 996 nic_set_poll_handlers(nic_data, rtl8139_poll_mode_change, rtl8139_poll); 997 997 … … 1347 1347 assert(addr); 1348 1348 1349 nic_t *nic_data = nic_get_from_ddf_fun((fun));1349 nic_t *nic_data = nic_get_from_ddf_fun((fun)); 1350 1350 rtl8139_t *rtl8139 = nic_get_specific(nic_data); 1351 1351 assert(rtl8139); … … 1354 1354 1355 1355 errno_t rc = nic_report_address(nic_data, addr); 1356 if ( rc != EOK) {1356 if (rc != EOK) { 1357 1357 rtl8139_unlock_all(rtl8139); 1358 1358 return rc; … … 1817 1817 break; 1818 1818 case NIC_UNICAST_LIST: 1819 rtl8139->rcr_data.ucast_mask = RCR_ACCEPT_PHYS_MATCH 1820 |RCR_ACCEPT_ALL_PHYS;1819 rtl8139->rcr_data.ucast_mask = RCR_ACCEPT_PHYS_MATCH | 1820 RCR_ACCEPT_ALL_PHYS; 1821 1821 1822 1822 if (mcast_mode == NIC_MULTICAST_PROMISC) … … 1826 1826 break; 1827 1827 case NIC_UNICAST_PROMISC: 1828 rtl8139->rcr_data.ucast_mask = RCR_ACCEPT_PHYS_MATCH 1829 |RCR_ACCEPT_ALL_PHYS;1828 rtl8139->rcr_data.ucast_mask = RCR_ACCEPT_PHYS_MATCH | 1829 RCR_ACCEPT_ALL_PHYS; 1830 1830 1831 1831 if (mcast_mode == NIC_MULTICAST_PROMISC) … … 1981 1981 */ 1982 1982 static errno_t rtl8139_wol_virtue_add(nic_t *nic_data, 1983 const nic_wol_virtue_t *virtue)1983 const nic_wol_virtue_t *virtue) 1984 1984 { 1985 1985 assert(nic_data); … … 1989 1989 assert(rtl8139); 1990 1990 1991 switch (virtue->type) {1991 switch (virtue->type) { 1992 1992 case NIC_WV_BROADCAST: 1993 1993 rtl8139_hw_reg_add_8(rtl8139, CONFIG5, CONFIG5_BROADCAST_WAKEUP); … … 2008 2008 return EINVAL; 2009 2009 } 2010 if (rtl8139->pm.active++ == 0)2010 if (rtl8139->pm.active++ == 0) 2011 2011 rtl8139_hw_pmen_set(rtl8139, 1); 2012 2012 return EOK; … … 2019 2019 */ 2020 2020 static void rtl8139_wol_virtue_rem(nic_t *nic_data, 2021 const nic_wol_virtue_t *virtue)2021 const nic_wol_virtue_t *virtue) 2022 2022 { 2023 2023 assert(nic_data); … … 2027 2027 assert(rtl8139); 2028 2028 2029 switch (virtue->type) {2029 switch (virtue->type) { 2030 2030 case NIC_WV_BROADCAST: 2031 2031 rtl8139_hw_reg_rem_8(rtl8139, CONFIG5, CONFIG5_BROADCAST_WAKEUP); … … 2070 2070 fibril_mutex_lock(&rtl8139->rx_lock); 2071 2071 2072 switch (mode) {2072 switch (mode) { 2073 2073 case NIC_POLL_IMMEDIATE: 2074 2074 rtl8139->int_mask = RTL_DEFAULT_INTERRUPTS;
Note:
See TracChangeset
for help on using the changeset viewer.
