Changeset cfb79747 in mainline for uspace/drv/nic/rtl8139


Ignore:
Timestamp:
2012-02-14T22:06:15Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a31aad1
Parents:
199112e4 (diff), e10d41a (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.
Message:

Merge mainline changes.

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

Legend:

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

    r199112e4 rcfb79747  
    2929/** @file rtl8139_defs.h
    3030 *
    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_
     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
    3738#include <sys/types.h>
    3839#include <libarch/ddi.h>
    3940
    40 
    41 /** The size of RTL8139 registers address space */
    42 #define RTL8139_IO_SIZE 256
    43 
    44 /** The maximal transmitted packet length in bytes allowed according to RTL8139
    45  *  documentation (see SIZE part of TSD documentation)
    46  */
    47 #define RTL8139_PACKET_MAX_LENGTH 1792
    48 
     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
    4952
    5053/** HW version
    5154 *
    52  *  as can be detected from HWVERID part of TCR
    53  *  (Transmit Configuration Register)
    54  */
    55 enum rtl8139_version_id {
     55 * As can be detected from HWVERID part of TCR
     56 * (Transmit Configuration Register).
     57 *
     58 */
     59typedef enum {
    5660        RTL8139 = 0,          /**< RTL8139 */
    5761        RTL8139A,             /**< RTL8139A */
     
    6670        RTL8101,              /**< RTL8101 */
    6771        RTL8139_VER_COUNT     /**< Count of known RTL versions, the last value */
    68 };
    69 
    70 extern const char* model_names[RTL8139_VER_COUNT];
     72} rtl8139_version_id_t;
    7173
    7274/** Registers of RTL8139 family card offsets from the memory address base */
     
    7577        MAC0  = IDR0,    /**< Alias for IDR0 */
    7678
    77         // 0x6 - 0x7 reserved
     79        // 0x06 - 0x07 reserved
    7880
    7981        MAR0    = 0x08,  /**< Multicast mask registers 8 1b registers sequence */
     
    9496
    9597        CR      = 0x37,  /**< Command register, 1b */
    96         CAPR    = 0x38,  /**< Current address of packet read, 2b */
     98        CAPR    = 0x38,  /**< Current address of frame read, 2b */
    9799        CBA     = 0x3a,  /**< Current buffer address, 2b */
    98100
     
    213215        pio_write_8(io_base + CR9346, RTL8139_REGS_LOCKED);
    214216}
     217
    215218/** Allow to change Config0-4 and BMCR register  */
    216219static inline void rtl8139_regs_unlock(void *io_base)
     
    282285        RCR_MulERINT = 1 << 17,    /**< Multiple early interrupt select */
    283286
    284         /** Minimal error packet length (1 = 8B, 0 = 64B). If AER/AR is set, RER8
     287        /** Minimal error frame length (1 = 8B, 0 = 64B). If AER/AR is set, RER8
    285288         * is "Don't care"
    286289         */
     
    302305
    303306        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 */
     307        RCR_ACCEPT_ERROR      = 1 << 5,  /**< Accept error frame */
     308        RCR_ACCEPT_RUNT       = 1 << 4,  /**< Accept Runt (8-64 bytes) frames */
    306309        RCR_ACCEPT_BROADCAST  = 1 << 3,  /**< Accept broadcast */
    307310        RCR_ACCEPT_MULTICAST  = 1 << 2,  /**< Accept multicast */
    308311        RCR_ACCEPT_PHYS_MATCH = 1 << 1,  /**< Accept device MAC address match */
    309         RCR_ACCEPT_ALL_PHYS   = 1 << 0,  /**< Accept all packets with
     312        RCR_ACCEPT_ALL_PHYS   = 1 << 0,  /**< Accept all frames with
    310313                                          * phys. desticnation
    311314                                                                          */
     
    362365        ANAR_ACK          = (1 << 14),  /**< Capability reception acknowledge */
    363366        ANAR_REMOTE_FAULT = (1 << 13),  /**< Remote fault detection capability */
    364         ANAR_PAUSE        = (1 << 10),  /**< Symetric pause packet capability */
     367        ANAR_PAUSE        = (1 << 10),  /**< Symetric pause frame capability */
    365368        ANAR_100T4        = (1 << 9),   /**< T4, not supported by the device */
    366369        ANAR_100TX_FD     = (1 << 8),   /**< 100BASE_TX full duplex */
     
    399402        CONFIG3_GNT_SELECT = (1 << 7),  /**< Gnt select */
    400403        CONFIG3_PARM_EN    = (1 << 6),  /**< Parameter enabled (100MBit mode) */
    401         CONFIG3_MAGIC      = (1 << 5),  /**< WoL Magic packet enable */
     404        CONFIG3_MAGIC      = (1 << 5),  /**< WoL Magic frame enable */
    402405        CONFIG3_LINK_UP    = (1 << 4),  /**< Wakeup if link is reestablished */
    403406        CONFIG3_CLKRUN_EN  = (1 << 2),  /**< CLKRUN enabled */ /* TODO: check what does it mean */
     
    416419};
    417420
    418 /** Maximal runt packet size + 1 */
    419 #define RTL8139_RUNT_MAX_SIZE 64
    420 
    421 /** Bits in packet header */
    422 enum rtl8139_packet_header {
     421/** Maximal runt frame size + 1 */
     422#define RTL8139_RUNT_MAX_SIZE  64
     423
     424/** Bits in frame header */
     425enum rtl8139_frame_header {
    423426        RSR_MAR  = (1 << 15),  /**< Multicast received */
    424427        RSR_PAM  = (1 << 14),  /**< Physical address match */
     
    426429
    427430        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) */
     431        RSR_RUNT = (1 << 4),   /**< Runt frame (< RTL8139_RUNT_MAX_SIZE bytes) */
     432
     433        RSR_LONG = (1 << 3),   /**< Long frame (size > 4k bytes) */
    431434        RSR_CRC  = (1 << 2),   /**< CRC error */
    432435        RSR_FAE  = (1 << 1),   /**< Frame alignment error */
    433         RSR_ROK  = (1 << 0)    /**< Good packet received */
     436        RSR_ROK  = (1 << 0)    /**< Good frame received */
    434437};
    435438
     
    451454                                                                          */
    452455
    453         APPEND_CRC = 1 << 16,        /**< Append CRC at the end of a packet */
     456        APPEND_CRC = 1 << 16,        /**< Append CRC at the end of a frame */
    454457
    455458        MXTxDMA_SHIFT = 8,  /**< Max. DMA Burst per TxDMA shift, burst = 16^value */
     
    459462        TX_RETRY_COUNT_SIZE  = 4,            /**< Retries before aborting size */
    460463
    461         CLEAR_ABORT = 1 << 0    /**< Retransmit aborted packet at the last
     464        CLEAR_ABORT = 1 << 0    /**< Retransmit aborted frame at the last
    462465                                  *  transmitted descriptor
    463466                                                          */
     
    470473
    471474/** Mapping of HW version -> version ID */
    472 struct rtl8139_hwver_map { 
    473         uint32_t hwverid;                /**< HW version value in the register */
    474         enum rtl8139_version_id ver_id;  /**< appropriate version id */
     475struct rtl8139_hwver_map {
     476        uint32_t hwverid;             /**< HW version value in the register */
     477        rtl8139_version_id_t ver_id;  /**< appropriate version id */
    475478};
    476479
    477480/** Mapping of HW version -> version ID */
    478481extern const struct rtl8139_hwver_map rtl8139_versions[RTL8139_VER_COUNT + 1];
    479 
    480 /** Size in the packet header while copying from RxFIFO to Rx buffer */
    481 #define RTL8139_EARLY_SIZE UINT16_C(0xfff0)
    482 /** The only supported pause packet time value */
    483 #define RTL8139_PAUSE_VAL UINT16_C(0xFFFF)
    484 
    485 /** Size of the packet header in front of the received frame */
    486 #define RTL_PACKET_HEADER_SIZE 4
     482extern const char* model_names[RTL8139_VER_COUNT];
     483
     484/** Size in the frame header while copying from RxFIFO to Rx buffer */
     485#define RTL8139_EARLY_SIZE  UINT16_C(0xfff0)
     486
     487/** The only supported pause frame time value */
     488#define RTL8139_PAUSE_VAL  UINT16_C(0xFFFF)
     489
     490/** Size of the frame header in front of the received frame */
     491#define RTL_FRAME_HEADER_SIZE  4
    487492
    488493/** 8k buffer */
  • uspace/drv/nic/rtl8139/driver.c

    r199112e4 rcfb79747  
    3939#include <io/log.h>
    4040#include <nic.h>
    41 #include <packet_client.h>
    4241#include <device/pci.h>
    4342
     
    5655/** Global mutex for work with shared irq structure */
    5756FIBRIL_MUTEX_INITIALIZE(irq_reg_lock);
     57
    5858/** Lock interrupt structure mutex */
    59 #define RTL8139_IRQ_STRUCT_LOCK() fibril_mutex_lock(&irq_reg_lock)
     59#define RTL8139_IRQ_STRUCT_LOCK() \
     60        fibril_mutex_lock(&irq_reg_lock)
     61
    6062/** Unlock interrupt structure mutex */
    61 #define RTL8139_IRQ_STRUCT_UNLOCK() fibril_mutex_unlock(&irq_reg_lock)
     63#define RTL8139_IRQ_STRUCT_UNLOCK() \
     64        fibril_mutex_unlock(&irq_reg_lock)
    6265
    6366/** PCI clock frequency in kHz */
    64 #define RTL8139_PCI_FREQ_KHZ 33000
    65 
    66 #define RTL8139_AUTONEG_CAPS (ETH_AUTONEG_10BASE_T_HALF \
    67     | ETH_AUTONEG_10BASE_T_FULL | ETH_AUTONEG_100BASE_TX_HALF \
    68     | ETH_AUTONEG_100BASE_TX_FULL | ETH_AUTONEG_PAUSE_SYMETRIC)
     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)
    6972
    7073/** Lock transmitter and receiver data
    71  *  This function shall be called whenever both transmitter and receiver locking
    72  *  to force safe lock ordering (deadlock prevention)
    73  *
    74  *  @param rtl8139  RTL8139 private 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 *
    7581 */
    7682inline static void rtl8139_lock_all(rtl8139_t *rtl8139)
     
    8389/** Unlock transmitter and receiver data
    8490 *
    85  *  @param rtl8139  RTL8139 private data
     91 * @param rtl8139 RTL8139 private data
     92 *
    8693 */
    8794inline static void rtl8139_unlock_all(rtl8139_t *rtl8139)
     
    152159}
    153160
    154 /** Update the mask of accepted packets in the RCR register according to
     161/** Update the mask of accepted frames in the RCR register according to
    155162 * rcr_accept_mode value in rtl8139_t
    156163 *
     
    170177}
    171178
    172 /** Fill the mask of accepted multicast packets in the card registers
     179/** Fill the mask of accepted multicast frames in the card registers
    173180 *
    174181 *  @param rtl8139  The rtl8139 private data
     
    394401#define rtl8139_tbuf_busy(tsd) ((pio_read_32(tsd) & TSD_OWN) == 0)
    395402
    396 /** Send packet with the hardware
     403/** Send frame with the hardware
    397404 *
    398405 * note: the main_lock is locked when framework calls this function
     
    412419        ddf_msg(LVL_DEBUG, "Sending frame");
    413420
    414         if (size > RTL8139_PACKET_MAX_LENGTH) {
     421        if (size > RTL8139_FRAME_MAX_LENGTH) {
    415422                ddf_msg(LVL_ERROR, "Send frame: frame too long, %zu bytes",
    416423                    size);
     
    437444        fibril_mutex_unlock(&rtl8139->tx_lock);
    438445
    439         /* Get address of the buffer descriptor and packet data */
     446        /* Get address of the buffer descriptor and frame data */
    440447        void *tsd = rtl8139->io_port + TSD0 + tx_curr * 4;
    441448        void *buf_addr = rtl8139->tx_buff[tx_curr];
     
    458465        pio_write_32(tsd, tsd_value);
    459466        return;
    460 
     467       
    461468err_busy_no_inc:
    462469err_size:
     
    505512}
    506513
    507 /** Create packet structure from the buffer data
     514/** Create frame structure from the buffer data
    508515 *
    509516 * @param nic_data      NIC driver data
    510517 * @param rx_buffer     The receiver buffer
    511518 * @param rx_size       The buffer size
    512  * @param packet_start  The offset where packet data start
    513  * @param packet_size   The size of the packet data
    514  *
    515  * @return The packet   list 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);
     519 * @param frame_start   The offset where packet data start
     520 * @param frame_size    The size of the frame data
     521 *
     522 * @return The frame list node (not connected)
     523 *
     524 */
     525static nic_frame_t *rtl8139_read_frame(nic_t *nic_data,
     526    void *rx_buffer, size_t rx_size, size_t frame_start, size_t frame_size)
     527{
     528        nic_frame_t *frame = nic_alloc_frame(nic_data, frame_size);
    521529        if (! frame) {
    522                 ddf_msg(LVL_ERROR, "Can not allocate frame for received packet.");
     530                ddf_msg(LVL_ERROR, "Can not allocate frame for received frame.");
    523531                return NULL;
    524532        }
    525533
    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);
     534        void *ret = rtl8139_memcpy_wrapped(frame->data, rx_buffer, frame_start,
     535            RxBUF_SIZE, frame_size);
    535536        if (ret == NULL) {
    536537                nic_release_frame(nic_data, frame);
     
    568569}
    569570
    570 /** Receive all packets in queue
     571/** Receive all frames in queue
    571572 *
    572573 *  @param nic_data  The controller data
    573  *  @return The linked list of packet_list_t nodes, each containing one packet
    574  */
    575 static nic_frame_list_t *rtl8139_packet_receive(nic_t *nic_data)
     574 *  @return The linked list of nic_frame_list_t nodes, each containing one frame
     575 */
     576static nic_frame_list_t *rtl8139_frame_receive(nic_t *nic_data)
    576577{
    577578        rtl8139_t *rtl8139 = nic_get_specific(nic_data);
     
    581582        nic_frame_list_t *frames = nic_alloc_frame_list();
    582583        if (!frames)
    583                 ddf_msg(LVL_ERROR, "Can not allocate frame list for received packets.");
     584                ddf_msg(LVL_ERROR, "Can not allocate frame list for received frames.");
    584585
    585586        void *rx_buffer = rtl8139->rx_buff_virt;
     
    605606        while (!rtl8139_hw_buffer_empty(rtl8139)) {
    606607                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 packet header */
    611                 uint16_t rcs = (uint16_t) packet_header;
     608                uint32_t frame_header = uint32_t_le2host( *((uint32_t*)rx_ptr) );
     609                uint16_t size = frame_header >> 16;
     610                uint16_t frame_size = size - RTL8139_CRC_SIZE;
     611                /* received frame flags in frame header */
     612                uint16_t rcs = (uint16_t) frame_header;
    612613
    613614                if (size == RTL8139_EARLY_SIZE) {
    614                         /* The packet copying is still in progress, break receiving */
     615                        /* The frame copying is still in progress, break receiving */
    615616                        ddf_msg(LVL_DEBUG, "Early threshold reached, not completely coppied");
    616617                        break;
     
    618619
    619620                /* Check if the header is valid, otherwise we are lost in the buffer */
    620                 if (size == 0 || size > RTL8139_PACKET_MAX_LENGTH) {
     621                if (size == 0 || size > RTL8139_FRAME_MAX_LENGTH) {
    621622                        ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (size: %4"PRIu16", "
    622                             "header 0x%4"PRIx16". Offset: %zu)", size, packet_header,
     623                            "header 0x%4"PRIx16". Offset: %zu)", size, frame_header,
    623624                            rx_offset);
    624625                        goto rx_err;
     
    629630                }
    630631
    631                 cur_read += size + RTL_PACKET_HEADER_SIZE;
     632                cur_read += size + RTL_FRAME_HEADER_SIZE;
    632633                if (cur_read > max_read)
    633634                        break;
    634635
    635636                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);
     637                        nic_frame_t *frame = rtl8139_read_frame(nic_data, rx_buffer,
     638                            RxBUF_SIZE, rx_offset + RTL_FRAME_HEADER_SIZE, frame_size);
    638639
    639640                        if (frame)
     
    642643
    643644                /* 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 packet
     645                rx_offset = ALIGN_UP(rx_offset + size + RTL_FRAME_HEADER_SIZE, 4);
     646
     647                /* Write lesser value to prevent overflow into unread frame
    647648                 * (the recomendation from the RealTech rtl8139 programming guide)
    648649                 */
     
    735736                tx_used++;
    736737
    737                 /* If the packet was sent */
     738                /* If the frame was sent */
    738739                if (tsd_value & TSD_TOK) {
    739740                        size_t size = REG_GET_VAL(tsd_value, TSD_SIZE);
     
    765766}
    766767
    767 /** Receive all packets from the buffer
     768/** Receive all frames from the buffer
    768769 *
    769770 *  @param rtl8139  driver private data
    770771 */
    771 static void rtl8139_receive_packets(nic_t *nic_data)
     772static void rtl8139_receive_frames(nic_t *nic_data)
    772773{
    773774        assert(nic_data);
     
    777778
    778779        fibril_mutex_lock(&rtl8139->rx_lock);
    779         nic_frame_list_t *frames = rtl8139_packet_receive(nic_data);
     780        nic_frame_list_t *frames = rtl8139_frame_receive(nic_data);
    780781        fibril_mutex_unlock(&rtl8139->rx_lock);
    781782
     
    833834        }
    834835
    835         /* Check transmittion interrupts first to allow transmit next packets
     836        /* Check transmittion interrupts first to allow transmit next frames
    836837         * sooner
    837838         */
     
    840841        }
    841842        if (isr & INT_ROK) {
    842                 rtl8139_receive_packets(nic_data);
     843                rtl8139_receive_frames(nic_data);
    843844        }
    844845        if (isr & (INT_RER | INT_RXOVW | INT_FIFOOVW)) {
     
    942943}
    943944
    944 /** Activate the device to receive and transmit packets
     945/** Activate the device to receive and transmit frames
    945946 *
    946947 *  @param nic_data  The nic driver data
     
    12221223                goto failed;
    12231224
    1224         /* Set default packet acceptance */
     1225        /* Set default frame acceptance */
    12251226        rtl8139->rcr_data.ucast_mask = RTL8139_RCR_UCAST_DEFAULT;
    12261227        rtl8139->rcr_data.mcast_mask = RTL8139_RCR_MCAST_DEFAULT;
    12271228        rtl8139->rcr_data.bcast_mask = RTL8139_RCR_BCAST_DEFAULT;
    12281229        rtl8139->rcr_data.defect_mask = RTL8139_RCR_DEFECT_DEFAULT;
    1229         /* Set receiver early treshold to 8/16 of packet length */
     1230        /* Set receiver early treshold to 8/16 of frame length */
    12301231        rtl8139->rcr_data.rcr_base = (0x8 << RCR_ERTH_SHIFT);
    12311232
    12321233        ddf_msg(LVL_DEBUG, "The device is initialized");
    12331234        return ret;
    1234 
     1235       
    12351236failed:
    12361237        ddf_msg(LVL_ERROR, "The device initialization failed");
     
    12971298int rtl8139_dev_add(ddf_dev_t *dev)
    12981299{
     1300        ddf_fun_t *fun;
     1301
    12991302        assert(dev);
    13001303        ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %d)", dev->name, dev->handle);
     
    13331336        }
    13341337
    1335         rc = nic_register_as_ddf_fun(nic_data, &rtl8139_dev_ops);
     1338        fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0");
     1339        if (fun == NULL) {
     1340                ddf_msg(LVL_ERROR, "Failed creating device function");
     1341                goto err_srv;
     1342        }
     1343        nic_set_ddf_fun(nic_data, fun);
     1344        fun->ops = &rtl8139_dev_ops;
     1345        fun->driver_data = nic_data;
     1346
     1347        rc = ddf_fun_bind(fun);
    13361348        if (rc != EOK) {
    1337                 ddf_msg(LVL_ERROR, "Failed to register as DDF function - error %d", rc);
    1338                 goto err_irq;
     1349                ddf_msg(LVL_ERROR, "Failed binding device function");
     1350                goto err_fun_create;
     1351        }
     1352        rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC);
     1353        if (rc != EOK) {
     1354                ddf_msg(LVL_ERROR, "Failed adding function to category");
     1355                goto err_fun_bind;
    13391356        }
    13401357
     
    13431360
    13441361        return EOK;
    1345 
     1362       
     1363err_fun_bind:
     1364        ddf_fun_unbind(fun);
     1365err_fun_create:
     1366        ddf_fun_destroy(fun);
     1367err_srv:
     1368        /* XXX Disconnect from services */
    13461369err_irq:
    13471370        unregister_interrupt_handler(dev, rtl8139->irq);
     
    14861509};
    14871510
    1488 /** Check if pause packet operations are valid in current situation
     1511/** Check if pause frame operations are valid in current situation
    14891512 *
    14901513 *  @param rtl8139  RTL8139 private structure
     
    15111534}
    15121535
    1513 /** Get current pause packet configuration
     1536/** Get current pause frame configuration
    15141537 *
    15151538 *  Values are filled with NIC_RESULT_NOT_AVAILABLE if the value has no sense in
     
    15171540 *
    15181541 *  @param[in]  fun         The DDF structure of the RTL8139
    1519  *  @param[out] we_send     Sign if local constroller sends pause packets
    1520  *  @param[out] we_receive  Sign if local constroller receives pause packets
    1521  *  @param[out] time        Time filled in pause packets. 0xFFFF in rtl8139
     1542 *  @param[out] we_send     Sign if local constroller sends pause frame
     1543 *  @param[out] we_receive  Sign if local constroller receives pause frame
     1544 *  @param[out] time        Time filled in pause frames. 0xFFFF in rtl8139
    15221545 *
    15231546 *  @return EOK if succeed
     
    15491572};
    15501573
    1551 /** Set current pause packet configuration
     1574/** Set current pause frame configuration
    15521575 *
    15531576 *  @param fun            The DDF structure of the RTL8139
    1554  *  @param allow_send     Sign if local constroller sends pause packets
    1555  *  @param allow_receive  Sign if local constroller receives pause packets
     1577 *  @param allow_send     Sign if local constroller sends pause frame
     1578 *  @param allow_receive  Sign if local constroller receives pause frames
    15561579 *  @param time           Time to use, ignored (not supported by device)
    15571580 *
    1558  *  @return EOK if succeed, INVAL if the pause packet has no sence
     1581 *  @return EOK if succeed, INVAL if the pause frame has no sence
    15591582 */
    15601583static int rtl8139_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive,
     
    18051828}
    18061829
    1807 /** Set unicast packets acceptance mode
     1830/** Set unicast frames acceptance mode
    18081831 *
    18091832 *  @param nic_data  The nic device to update
     
    18631886}
    18641887
    1865 /** Set multicast packets acceptance mode
     1888/** Set multicast frames acceptance mode
    18661889 *
    18671890 *  @param nic_data  The nic device to update
     
    19081931}
    19091932
    1910 /** Set broadcast packets acceptance mode
     1933/** Set broadcast frames acceptance mode
    19111934 *
    19121935 *  @param nic_data  The nic device to update
     
    19381961}
    19391962
    1940 /** Get state of acceptance of weird packets
     1963/** Get state of acceptance of weird frames
    19411964 *
    19421965 *  @param[in]  device  The device to check
     
    19601983};
    19611984
    1962 /** Set acceptance of weird packets
     1985/** Set acceptance of weird frames
    19631986 *
    19641987 *  @param device  The device to update
     
    21362159}
    21372160
    2138 /** Force receiving all packets in the receive buffer
     2161/** Force receiving all frames in the receive buffer
    21392162 *
    21402163 *  @param device  The device to receive
  • uspace/drv/nic/rtl8139/driver.h

    r199112e4 rcfb79747  
    3030#define RTL8139_DRIVER_H_
    3131
     32#include <sys/types.h>
     33#include <stdint.h>
    3234#include "defs.h"
    3335#include "general.h"
    34 #include <sys/types.h>
    35 #include <stdint.h>
    3636
    3737/** The driver name */
    38 #define NAME "rtl8139"
     38#define NAME  "rtl8139"
     39
    3940/** Transmittion buffers count */
    40 #define TX_BUFF_COUNT 4
    41 /** Size of buffer for one packet
    42  *  - 2kB
    43  */
    44 #define TX_BUFF_SIZE (2 * 1024)
    45 /** Count of pages to allocate for TxBuffers */
    46 #define TX_PAGES 2
     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
    4748
    4849/** Size of the CRC after the received frame in the receiver buffer */
    49 #define RTL8139_CRC_SIZE 4
    50 
    51 /** The default mode of accepting unicast packets */
    52 #define RTL8139_RCR_UCAST_DEFAULT RCR_ACCEPT_PHYS_MATCH
    53 /** The default mode of accepting multicast packets */
    54 #define RTL8139_RCR_MCAST_DEFAULT 0
    55 /** The default mode of accepting broadcast packets */
    56 #define RTL8139_RCR_BCAST_DEFAULT RCR_ACCEPT_BROADCAST
    57 /** The default mode of accepting defect packets */
    58 #define RTL8139_RCR_DEFECT_DEFAULT 0
     50#define RTL8139_CRC_SIZE  4
     51
     52/** The default mode of accepting unicast frames */
     53#define RTL8139_RCR_UCAST_DEFAULT  RCR_ACCEPT_PHYS_MATCH
     54
     55/** The default mode of accepting multicast frames */
     56#define RTL8139_RCR_MCAST_DEFAULT  0
     57
     58/** The default mode of accepting broadcast frames */
     59#define RTL8139_RCR_BCAST_DEFAULT  RCR_ACCEPT_BROADCAST
     60
     61/** The default mode of accepting defect frames */
     62#define RTL8139_RCR_DEFECT_DEFAULT  0
    5963
    6064/** Mask for accepting all multicast */
    61 #define RTL8139_MCAST_MASK_PROMISC UINT64_MAX
    62 
    63 /** Data  */
     65#define RTL8139_MCAST_MASK_PROMISC  UINT64_MAX
     66
     67/** Data */
    6468struct rtl8139_rcr_data {
    6569        /** Configuration part of RCR */
     
    112116        size_t tx_used;
    113117
    114         /** Buffer for receiving packets */
     118        /** Buffer for receiving frames */
    115119        void *rx_buff_phys;
    116120        void *rx_buff_virt;
     
    134138
    135139        /** Version of RT8139 controller */
    136         enum rtl8139_version_id hw_version;
     140        rtl8139_version_id_t hw_version;
    137141} rtl8139_t;
    138 
    139142
    140143/* ***** Pointers casting - for both amd64 and ia32 ***** */
     
    160163 */
    161164#define IOADDR_TO_PTR(ioaddr) ((void*)((size_t)(ioaddr)))
    162 
    163 
    164165
    165166/* ***** Bit operation macros ***** */
     
    177178 * @return New value
    178179 */
    179 #define bit_set_part_g( src, value, mask, type ) \
     180#define bit_set_part_g(src, value, mask, type) \
    180181        ((type)(((src) & ~((type)(mask))) | ((value) & (type)(mask))))
    181182
     
    237238        bit_set_part_32(tsd_value, (size) << TSD_SIZE_SHIFT, TSD_SIZE_MASK << TSD_SIZE_SHIFT)
    238239
    239 
    240240#endif
  • uspace/drv/nic/rtl8139/general.h

    r199112e4 rcfb79747  
    2929/** @file
    3030 *
    31  *  General functions and structures used in rtl8139 driver
     31 * General functions and structures used in rtl8139 driver
    3232 */
    3333
     
    3737#include <unistd.h>
    3838
    39 extern void* rtl8139_memcpy_wrapped(void *dest, const void *src_buf,
    40     size_t src_offset, size_t src_size, size_t data_size);
    41 
     39/** Number of microseconds in second */
     40#define RTL8139_USEC_IN_SEC  1000000
    4241
    4342/** Structure for HW timer control */
    44 typedef struct rtl8139_timer_act {
     43typedef struct {
    4544        /** Register value set in the last timer period */
    4645        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       
    5253        /** Remaining full register periods to the next period end */
    5354        size_t full_skips_remains;
     55       
    5456        /** Mark if there is a last run */
    5557        int last_run;
    5658} rtl8139_timer_act_t;
    5759
    58 /** Count of microseconds in second */
    59 #define RTL8139_USEC_IN_SEC 1000000
    60 
    61 extern int rtl8139_timer_act_init(rtl8139_timer_act_t *ta, uint32_t timer_freq,
    62     const struct timeval *time);
    63 extern int rtl8139_timer_act_step(rtl8139_timer_act_t *ta, uint32_t *new_reg);
    64 
     60extern void *rtl8139_memcpy_wrapped(void *, const void *, size_t, size_t,
     61    size_t);
     62extern int rtl8139_timer_act_init(rtl8139_timer_act_t *, uint32_t,
     63    const struct timeval *);
     64extern int rtl8139_timer_act_step(rtl8139_timer_act_t *, uint32_t *);
    6565
    6666#endif
Note: See TracChangeset for help on using the changeset viewer.