Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/e1k/e1k.c

    rcde999a rb7fd2a0  
    179179FIBRIL_MUTEX_INITIALIZE(irq_reg_mutex);
    180180
    181 static int e1000_get_address(e1000_t *, nic_address_t *);
     181static errno_t e1000_get_address(e1000_t *, nic_address_t *);
    182182static void e1000_eeprom_get_address(e1000_t *, nic_address_t *);
    183 static int e1000_set_addr(ddf_fun_t *, const nic_address_t *);
    184 
    185 static int e1000_defective_get_mode(ddf_fun_t *, uint32_t *);
    186 static int e1000_defective_set_mode(ddf_fun_t *, uint32_t);
    187 
    188 static int e1000_get_cable_state(ddf_fun_t *, nic_cable_state_t *);
    189 static int e1000_get_device_info(ddf_fun_t *, nic_device_info_t *);
    190 static int e1000_get_operation_mode(ddf_fun_t *, int *,
     183static errno_t e1000_set_addr(ddf_fun_t *, const nic_address_t *);
     184
     185static errno_t e1000_defective_get_mode(ddf_fun_t *, uint32_t *);
     186static errno_t e1000_defective_set_mode(ddf_fun_t *, uint32_t);
     187
     188static errno_t e1000_get_cable_state(ddf_fun_t *, nic_cable_state_t *);
     189static errno_t e1000_get_device_info(ddf_fun_t *, nic_device_info_t *);
     190static errno_t e1000_get_operation_mode(ddf_fun_t *, int *,
    191191    nic_channel_mode_t *, nic_role_t *);
    192 static int e1000_set_operation_mode(ddf_fun_t *, int,
     192static errno_t e1000_set_operation_mode(ddf_fun_t *, int,
    193193    nic_channel_mode_t, nic_role_t);
    194 static int e1000_autoneg_enable(ddf_fun_t *, uint32_t);
    195 static int e1000_autoneg_disable(ddf_fun_t *);
    196 static int e1000_autoneg_restart(ddf_fun_t *);
    197 
    198 static int e1000_vlan_set_tag(ddf_fun_t *, uint16_t, bool, bool);
     194static errno_t e1000_autoneg_enable(ddf_fun_t *, uint32_t);
     195static errno_t e1000_autoneg_disable(ddf_fun_t *);
     196static errno_t e1000_autoneg_restart(ddf_fun_t *);
     197
     198static errno_t e1000_vlan_set_tag(ddf_fun_t *, uint16_t, bool, bool);
    199199
    200200/** Network interface options for E1000 card driver */
     
    219219static ddf_dev_ops_t e1000_dev_ops;
    220220
    221 static int e1000_dev_add(ddf_dev_t *);
     221static errno_t e1000_dev_add(ddf_dev_t *);
    222222
    223223/** Basic driver operations for E1000 driver */
     
    233233
    234234/* The default implementation callbacks */
    235 static int e1000_on_activating(nic_t *);
    236 static int e1000_on_stopping(nic_t *);
     235static errno_t e1000_on_activating(nic_t *);
     236static errno_t e1000_on_stopping(nic_t *);
    237237static void e1000_send_frame(nic_t *, void *, size_t);
    238238
     
    288288 *
    289289 */
    290 static int e1000_get_device_info(ddf_fun_t *dev, nic_device_info_t *info)
     290static errno_t e1000_get_device_info(ddf_fun_t *dev, nic_device_info_t *info)
    291291{
    292292        assert(dev);
     
    316316 *
    317317 */
    318 static int e1000_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
     318static errno_t e1000_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
    319319{
    320320        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
     
    335335 *
    336336 */
    337 static int e1000_get_operation_mode(ddf_fun_t *fun, int *speed,
     337static errno_t e1000_get_operation_mode(ddf_fun_t *fun, int *speed,
    338338    nic_channel_mode_t *duplex, nic_role_t *role)
    339339{
     
    386386 *
    387387 */
    388 static int e1000_set_operation_mode(ddf_fun_t *fun, int speed,
     388static errno_t e1000_set_operation_mode(ddf_fun_t *fun, int speed,
    389389    nic_channel_mode_t duplex, nic_role_t role)
    390390{
     
    434434 *
    435435 */
    436 static int e1000_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)
     436static errno_t e1000_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)
    437437{
    438438        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
     
    462462 *
    463463 */
    464 static int e1000_autoneg_disable(ddf_fun_t *fun)
     464static errno_t e1000_autoneg_disable(ddf_fun_t *fun)
    465465{
    466466        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
     
    490490 *
    491491 */
    492 static int e1000_autoneg_restart(ddf_fun_t *dev)
     492static errno_t e1000_autoneg_restart(ddf_fun_t *dev)
    493493{
    494494        return e1000_autoneg_enable(dev, 0);
     
    501501 *
    502502 */
    503 static int e1000_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)
     503static errno_t e1000_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)
    504504{
    505505        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
     
    522522 *
    523523 */
    524 static int e1000_defective_set_mode(ddf_fun_t *fun, uint32_t mode)
     524static errno_t e1000_defective_set_mode(ddf_fun_t *fun, uint32_t mode)
    525525{
    526526        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    527         int rc = EOK;
     527        errno_t rc = EOK;
    528528       
    529529        fibril_mutex_lock(&e1000->rx_lock);
     
    827827 *
    828828 */
    829 static int e1000_on_multicast_mode_change(nic_t *nic, nic_multicast_mode_t mode,
     829static errno_t e1000_on_multicast_mode_change(nic_t *nic, nic_multicast_mode_t mode,
    830830    const nic_address_t *addr, size_t addr_cnt)
    831831{
    832832        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
    833         int rc = EOK;
     833        errno_t rc = EOK;
    834834       
    835835        fibril_mutex_lock(&e1000->rx_lock);
     
    881881 *
    882882 */
    883 static int e1000_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode,
     883static errno_t e1000_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode,
    884884    const nic_address_t *addr, size_t addr_cnt)
    885885{
    886886        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
    887         int rc = EOK;
     887        errno_t rc = EOK;
    888888       
    889889        fibril_mutex_lock(&e1000->rx_lock);
     
    937937 *
    938938 */
    939 static int e1000_on_broadcast_mode_change(nic_t *nic, nic_broadcast_mode_t mode)
     939static errno_t e1000_on_broadcast_mode_change(nic_t *nic, nic_broadcast_mode_t mode)
    940940{
    941941        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
    942         int rc = EOK;
     942        errno_t rc = EOK;
    943943       
    944944        fibril_mutex_lock(&e1000->rx_lock);
     
    10481048 *
    10491049 */
    1050 static int e1000_vlan_set_tag(ddf_fun_t *fun, uint16_t tag, bool add,
     1050static errno_t e1000_vlan_set_tag(ddf_fun_t *fun, uint16_t tag, bool add,
    10511051    bool strip)
    10521052{
     
    12641264 *
    12651265 */
    1266 inline static int e1000_register_int_handler(nic_t *nic, cap_handle_t *handle)
     1266inline static errno_t e1000_register_int_handler(nic_t *nic, cap_handle_t *handle)
    12671267{
    12681268        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    12751275        e1000_irq_code.cmds[2].addr = e1000->reg_base_phys + E1000_IMC;
    12761276       
    1277         int rc = register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq,
     1277        errno_t rc = register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq,
    12781278            e1000_interrupt_handler, &e1000_irq_code, handle);
    12791279       
     
    13191319 *
    13201320 */
    1321 static int e1000_poll_mode_change(nic_t *nic, nic_poll_mode_t mode,
     1321static errno_t e1000_poll_mode_change(nic_t *nic, nic_poll_mode_t mode,
    13221322    const struct timeval *period)
    13231323{
     
    13731373 *
    13741374 */
    1375 static int e1000_initialize_rx_structure(nic_t *nic)
     1375static errno_t e1000_initialize_rx_structure(nic_t *nic)
    13761376{
    13771377        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    13791379       
    13801380        e1000->rx_ring_virt = AS_AREA_ANY;
    1381         int rc = dmamem_map_anonymous(
     1381        errno_t rc = dmamem_map_anonymous(
    13821382            E1000_RX_FRAME_COUNT * sizeof(e1000_rx_descriptor_t),
    13831383            DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0,
     
    15671567 *
    15681568 */
    1569 static int e1000_initialize_tx_structure(e1000_t *e1000)
     1569static errno_t e1000_initialize_tx_structure(e1000_t *e1000)
    15701570{
    15711571        size_t i;
     
    15791579        e1000->tx_frame_virt = NULL;
    15801580       
    1581         int rc = dmamem_map_anonymous(
     1581        errno_t rc = dmamem_map_anonymous(
    15821582            E1000_TX_FRAME_COUNT * sizeof(e1000_tx_descriptor_t),
    15831583            DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0,
     
    17181718 *
    17191719 */
    1720 static int e1000_reset(nic_t *nic)
     1720static errno_t e1000_reset(nic_t *nic)
    17211721{
    17221722        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    17491749 *
    17501750 */
    1751 static int e1000_on_activating(nic_t *nic)
     1751static errno_t e1000_on_activating(nic_t *nic)
    17521752{
    17531753        assert(nic);
     
    17611761        e1000_enable_interrupts(e1000);
    17621762       
    1763         int rc = hw_res_enable_interrupt(e1000->parent_sess, e1000->irq);
     1763        errno_t rc = hw_res_enable_interrupt(e1000->parent_sess, e1000->irq);
    17641764        if (rc != EOK) {
    17651765                e1000_disable_interrupts(e1000);
     
    17951795 *
    17961796 */
    1797 static int e1000_on_down_unlocked(nic_t *nic)
     1797static errno_t e1000_on_down_unlocked(nic_t *nic)
    17981798{
    17991799        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    18261826 *
    18271827 */
    1828 static int e1000_on_down(nic_t *nic)
     1828static errno_t e1000_on_down(nic_t *nic)
    18291829{
    18301830        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    18341834        fibril_mutex_lock(&e1000->ctrl_lock);
    18351835       
    1836         int rc = e1000_on_down_unlocked(nic);
     1836        errno_t rc = e1000_on_down_unlocked(nic);
    18371837       
    18381838        fibril_mutex_unlock(&e1000->ctrl_lock);
     
    18511851 *
    18521852 */
    1853 static int e1000_on_stopping(nic_t *nic)
     1853static errno_t e1000_on_stopping(nic_t *nic)
    18541854{
    18551855        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    18591859        fibril_mutex_lock(&e1000->ctrl_lock);
    18601860       
    1861         int rc = e1000_on_down_unlocked(nic);
     1861        errno_t rc = e1000_on_down_unlocked(nic);
    18621862        if (rc == EOK)
    18631863                rc = e1000_reset(nic);
     
    19431943 *
    19441944 */
    1945 static int e1000_fill_resource_info(ddf_dev_t *dev,
     1945static errno_t e1000_fill_resource_info(ddf_dev_t *dev,
    19461946    const hw_res_list_parsed_t *hw_resources)
    19471947{
     
    19681968 *
    19691969 */
    1970 static int e1000_get_resource_info(ddf_dev_t *dev)
     1970static errno_t e1000_get_resource_info(ddf_dev_t *dev)
    19711971{
    19721972        assert(dev != NULL);
     
    19771977       
    19781978        /* Get hw resources form parent driver */
    1979         int rc = nic_get_resources(NIC_DATA_DEV(dev), &hw_res_parsed);
     1979        errno_t rc = nic_get_resources(NIC_DATA_DEV(dev), &hw_res_parsed);
    19801980        if (rc != EOK)
    19811981                return rc;
     
    19961996 *
    19971997 */
    1998 static int e1000_device_initialize(ddf_dev_t *dev)
     1998static errno_t e1000_device_initialize(ddf_dev_t *dev)
    19991999{
    20002000        /* Allocate driver data for the device. */
     
    20122012       
    20132013        /* Obtain and fill hardware resources info */
    2014         int rc = e1000_get_resource_info(dev);
     2014        errno_t rc = e1000_get_resource_info(dev);
    20152015        if (rc != EOK) {
    20162016                ddf_msg(LVL_ERROR, "Cannot obtain hardware resources");
     
    21102110 *
    21112111 */
    2112 static int e1000_pio_enable(ddf_dev_t *dev)
     2112static errno_t e1000_pio_enable(ddf_dev_t *dev)
    21132113{
    21142114        e1000_t *e1000 = DRIVER_DATA_DEV(dev);
    21152115       
    2116         int rc = pio_enable(e1000->reg_base_phys, 8 * PAGE_SIZE,
     2116        errno_t rc = pio_enable(e1000->reg_base_phys, 8 * PAGE_SIZE,
    21172117            &e1000->reg_base_virt);
    21182118        if (rc != EOK)
     
    21272127 *
    21282128 */
    2129 int e1000_dev_add(ddf_dev_t *dev)
     2129errno_t e1000_dev_add(ddf_dev_t *dev)
    21302130{
    21312131        ddf_fun_t *fun;
    21322132       
    21332133        /* Initialize device structure for E1000 */
    2134         int rc = e1000_device_initialize(dev);
     2134        errno_t rc = e1000_device_initialize(dev);
    21352135        if (rc != EOK)
    21362136                return rc;
     
    22582258 *
    22592259 */
    2260 static int e1000_get_address(e1000_t *e1000, nic_address_t *address)
     2260static errno_t e1000_get_address(e1000_t *e1000, nic_address_t *address)
    22612261{
    22622262        fibril_mutex_lock(&e1000->rx_lock);
     
    22912291 * @return An error code otherwise
    22922292 */
    2293 static int e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr)
     2293static errno_t e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr)
    22942294{
    22952295        nic_t *nic = NIC_DATA_FUN(fun);
     
    22992299        fibril_mutex_lock(&e1000->tx_lock);
    23002300       
    2301         int rc = nic_report_address(nic, addr);
     2301        errno_t rc = nic_report_address(nic, addr);
    23022302        if (rc == EOK)
    23032303                e1000_write_receive_address(e1000, 0, addr, false);
Note: See TracChangeset for help on using the changeset viewer.