Changes in / [5c5f522:3ce5162] in mainline


Ignore:
Location:
uspace/drv/nic/rtl8139
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/rtl8139/defs.h

    r5c5f522 r3ce5162  
    2929/** @file rtl8139_defs.h
    3030 *
    31  * Registers, bit positions and masks definition
    32  * of the RTL8139 network family cards
    33  */
    34 
    35 #ifndef RTL8139_DEFS_H_
    36 #define RTL8139_DEFS_H_
    37 
     31 *  Registers, bit positions and masks definition of the RTL8139 network family
     32 *  cards
     33 */
     34
     35#ifndef RTL8139_DEFS_H_INCLUDED_
     36#define RTL8139_DEFS_H_INCLUDED_
    3837#include <sys/types.h>
    3938#include <libarch/ddi.h>
    4039
    41 /** Size of RTL8139 registers address space */
    42 #define RTL8139_IO_SIZE  256
    43 
    44 /** Maximal transmitted frame length
    45  *
    46  * Maximal transmitted frame length in bytes
    47  * allowed according to the RTL8139 documentation
    48  * (see SIZE part of TSD documentation).
    49  *
    50  */
    51 #define RTL8139_FRAME_MAX_LENGTH  1792
     40
     41/** The size of RTL8139 registers address space */
     42#define RTL8139_IO_SIZE 256
     43
     44/** The maximal transmitted frame length in bytes allowed according to RTL8139
     45 *  documentation (see SIZE part of TSD documentation)
     46 */
     47#define RTL8139_FRAME_MAX_LENGTH 1792
     48
    5249
    5350/** HW version
    5451 *
    55  * As can be detected from HWVERID part of TCR
    56  * (Transmit Configuration Register).
    57  *
    58  */
    59 typedef enum {
     52 *  as can be detected from HWVERID part of TCR
     53 *  (Transmit Configuration Register)
     54 */
     55enum rtl8139_version_id {
    6056        RTL8139 = 0,          /**< RTL8139 */
    6157        RTL8139A,             /**< RTL8139A */
     
    7066        RTL8101,              /**< RTL8101 */
    7167        RTL8139_VER_COUNT     /**< Count of known RTL versions, the last value */
    72 } rtl8139_version_id_t;
     68};
     69
     70extern const char* model_names[RTL8139_VER_COUNT];
    7371
    7472/** Registers of RTL8139 family card offsets from the memory address base */
     
    7775        MAC0  = IDR0,    /**< Alias for IDR0 */
    7876
    79         // 0x06 - 0x07 reserved
     77        // 0x6 - 0x7 reserved
    8078
    8179        MAR0    = 0x08,  /**< Multicast mask registers 8 1b registers sequence */
     
    215213        pio_write_8(io_base + CR9346, RTL8139_REGS_LOCKED);
    216214}
    217 
    218215/** Allow to change Config0-4 and BMCR register  */
    219216static inline void rtl8139_regs_unlock(void *io_base)
     
    420417
    421418/** Maximal runt frame size + 1 */
    422 #define RTL8139_RUNT_MAX_SIZE  64
     419#define RTL8139_RUNT_MAX_SIZE 64
    423420
    424421/** Bits in frame header */
     
    473470
    474471/** Mapping of HW version -> version ID */
    475 struct rtl8139_hwver_map {
    476         uint32_t hwverid;             /**< HW version value in the register */
    477         rtl8139_version_id_t ver_id;  /**< appropriate version id */
     472struct rtl8139_hwver_map { 
     473        uint32_t hwverid;                /**< HW version value in the register */
     474        enum rtl8139_version_id ver_id;  /**< appropriate version id */
    478475};
    479476
    480477/** Mapping of HW version -> version ID */
    481478extern const struct rtl8139_hwver_map rtl8139_versions[RTL8139_VER_COUNT + 1];
    482 extern const char* model_names[RTL8139_VER_COUNT];
    483479
    484480/** Size in the frame header while copying from RxFIFO to Rx buffer */
    485 #define RTL8139_EARLY_SIZE  UINT16_C(0xfff0)
    486 
     481#define RTL8139_EARLY_SIZE UINT16_C(0xfff0)
    487482/** The only supported pause frame time value */
    488 #define RTL8139_PAUSE_VAL  UINT16_C(0xFFFF)
     483#define RTL8139_PAUSE_VAL UINT16_C(0xFFFF)
    489484
    490485/** Size of the frame header in front of the received frame */
    491 #define RTL_FRAME_HEADER_SIZE  4
     486#define RTL_FRAME_HEADER_SIZE 4
    492487
    493488/** 8k buffer */
  • uspace/drv/nic/rtl8139/driver.c

    r5c5f522 r3ce5162  
    5555/** Global mutex for work with shared irq structure */
    5656FIBRIL_MUTEX_INITIALIZE(irq_reg_lock);
    57 
    5857/** Lock interrupt structure mutex */
    59 #define RTL8139_IRQ_STRUCT_LOCK() \
    60         fibril_mutex_lock(&irq_reg_lock)
    61 
     58#define RTL8139_IRQ_STRUCT_LOCK() fibril_mutex_lock(&irq_reg_lock)
    6259/** Unlock interrupt structure mutex */
    63 #define RTL8139_IRQ_STRUCT_UNLOCK() \
    64         fibril_mutex_unlock(&irq_reg_lock)
     60#define RTL8139_IRQ_STRUCT_UNLOCK() fibril_mutex_unlock(&irq_reg_lock)
    6561
    6662/** PCI clock frequency in kHz */
    67 #define RTL8139_PCI_FREQ_KHZ  33000
    68 
    69 #define RTL8139_AUTONEG_CAPS (ETH_AUTONEG_10BASE_T_HALF | \
    70         ETH_AUTONEG_10BASE_T_FULL | ETH_AUTONEG_100BASE_TX_HALF | \
    71         ETH_AUTONEG_100BASE_TX_FULL | ETH_AUTONEG_PAUSE_SYMETRIC)
     63#define RTL8139_PCI_FREQ_KHZ 33000
     64
     65#define RTL8139_AUTONEG_CAPS (ETH_AUTONEG_10BASE_T_HALF \
     66    | ETH_AUTONEG_10BASE_T_FULL | ETH_AUTONEG_100BASE_TX_HALF \
     67    | ETH_AUTONEG_100BASE_TX_FULL | ETH_AUTONEG_PAUSE_SYMETRIC)
    7268
    7369/** Lock transmitter and receiver data
    74  *
    75  * This function shall be called whenever
    76  * both transmitter and receiver locking
    77  * to force safe lock ordering (deadlock prevention)
    78  *
    79  * @param rtl8139 RTL8139 private data
    80  *
     70 *  This function shall be called whenever both transmitter and receiver locking
     71 *  to force safe lock ordering (deadlock prevention)
     72 *
     73 *  @param rtl8139  RTL8139 private data
    8174 */
    8275inline static void rtl8139_lock_all(rtl8139_t *rtl8139)
     
    8982/** Unlock transmitter and receiver data
    9083 *
    91  * @param rtl8139 RTL8139 private data
    92  *
     84 *  @param rtl8139  RTL8139 private data
    9385 */
    9486inline static void rtl8139_unlock_all(rtl8139_t *rtl8139)
     
    465457        pio_write_32(tsd, tsd_value);
    466458        return;
    467        
     459
    468460err_busy_no_inc:
    469461err_size:
     
    521513 *
    522514 * @return The frame list node (not connected)
    523  *
    524515 */
    525516static nic_frame_t *rtl8139_read_frame(nic_t *nic_data,
     
    12241215        ddf_msg(LVL_DEBUG, "The device is initialized");
    12251216        return ret;
    1226        
     1217
    12271218failed:
    12281219        ddf_msg(LVL_ERROR, "The device initialization failed");
     
    13511342
    13521343        return EOK;
    1353        
     1344
    13541345err_fun_bind:
    13551346        ddf_fun_unbind(fun);
  • uspace/drv/nic/rtl8139/driver.h

    r5c5f522 r3ce5162  
    3030#define RTL8139_DRIVER_H_
    3131
     32#include "defs.h"
     33#include "general.h"
    3234#include <sys/types.h>
    3335#include <stdint.h>
    34 #include "defs.h"
    35 #include "general.h"
    3636
    3737/** The driver name */
    38 #define NAME  "rtl8139"
    39 
     38#define NAME "rtl8139"
    4039/** Transmittion buffers count */
    41 #define TX_BUFF_COUNT  4
    42 
    43 /** Size of buffer for one frame (2kB) */
    44 #define TX_BUFF_SIZE  (2 * 1024)
    45 
    46 /** Number of pages to allocate for TxBuffers */
    47 #define TX_PAGES  2
     40#define TX_BUFF_COUNT 4
     41/** Size of buffer for one frame
     42 *  - 2kB
     43 */
     44#define TX_BUFF_SIZE (2 * 1024)
     45/** Count of pages to allocate for TxBuffers */
     46#define TX_PAGES 2
    4847
    4948/** Size of the CRC after the received frame in the receiver buffer */
    50 #define RTL8139_CRC_SIZE  4
     49#define RTL8139_CRC_SIZE 4
    5150
    5251/** The default mode of accepting unicast frames */
    53 #define RTL8139_RCR_UCAST_DEFAULT  RCR_ACCEPT_PHYS_MATCH
    54 
     52#define RTL8139_RCR_UCAST_DEFAULT RCR_ACCEPT_PHYS_MATCH
    5553/** The default mode of accepting multicast frames */
    56 #define RTL8139_RCR_MCAST_DEFAULT  0
    57 
     54#define RTL8139_RCR_MCAST_DEFAULT 0
    5855/** The default mode of accepting broadcast frames */
    59 #define RTL8139_RCR_BCAST_DEFAULT  RCR_ACCEPT_BROADCAST
    60 
     56#define RTL8139_RCR_BCAST_DEFAULT RCR_ACCEPT_BROADCAST
    6157/** The default mode of accepting defect frames */
    62 #define RTL8139_RCR_DEFECT_DEFAULT  0
     58#define RTL8139_RCR_DEFECT_DEFAULT 0
    6359
    6460/** Mask for accepting all multicast */
    65 #define RTL8139_MCAST_MASK_PROMISC  UINT64_MAX
    66 
    67 /** Data */
     61#define RTL8139_MCAST_MASK_PROMISC UINT64_MAX
     62
     63/** Data  */
    6864struct rtl8139_rcr_data {
    6965        /** Configuration part of RCR */
     
    138134
    139135        /** Version of RT8139 controller */
    140         rtl8139_version_id_t hw_version;
     136        enum rtl8139_version_id hw_version;
    141137} rtl8139_t;
     138
    142139
    143140/* ***** Pointers casting - for both amd64 and ia32 ***** */
     
    163160 */
    164161#define IOADDR_TO_PTR(ioaddr) ((void*)((size_t)(ioaddr)))
     162
     163
    165164
    166165/* ***** Bit operation macros ***** */
     
    178177 * @return New value
    179178 */
    180 #define bit_set_part_g(src, value, mask, type) \
     179#define bit_set_part_g( src, value, mask, type ) \
    181180        ((type)(((src) & ~((type)(mask))) | ((value) & (type)(mask))))
    182181
     
    238237        bit_set_part_32(tsd_value, (size) << TSD_SIZE_SHIFT, TSD_SIZE_MASK << TSD_SIZE_SHIFT)
    239238
     239
    240240#endif
  • uspace/drv/nic/rtl8139/general.h

    r5c5f522 r3ce5162  
    3737#include <unistd.h>
    3838
    39 /** Number of microseconds in second */
    40 #define RTL8139_USEC_IN_SEC  1000000
     39extern void* rtl8139_memcpy_wrapped(void *dest, const void *src_buf,
     40    size_t src_offset, size_t src_size, size_t data_size);
     41
    4142
    4243/** Structure for HW timer control */
    43 typedef struct {
     44typedef struct rtl8139_timer_act {
    4445        /** Register value set in the last timer period */
    4546        uint32_t last_val;
    46        
    4747        /** Register value set in the common timer period */
    4848        uint32_t full_val;
    49        
     49
    5050        /** Amount of full register periods in timer period */
    5151        size_t full_skips;
    52        
    5352        /** Remaining full register periods to the next period end */
    5453        size_t full_skips_remains;
    55        
    5654        /** Mark if there is a last run */
    5755        int last_run;
    5856} rtl8139_timer_act_t;
    5957
    60 extern void *rtl8139_memcpy_wrapped(void *, const void *, size_t, size_t,
    61     size_t);
    62 extern int rtl8139_timer_act_init(rtl8139_timer_act_t *, uint32_t,
    63     const struct timeval *);
    64 extern int rtl8139_timer_act_step(rtl8139_timer_act_t *, uint32_t *);
     58/** Count of microseconds in second */
     59#define RTL8139_USEC_IN_SEC 1000000
     60
     61extern int rtl8139_timer_act_init(rtl8139_timer_act_t *ta, uint32_t timer_freq,
     62    const struct timeval *time);
     63extern int rtl8139_timer_act_step(rtl8139_timer_act_t *ta, uint32_t *new_reg);
     64
    6565
    6666#endif
Note: See TracChangeset for help on using the changeset viewer.