Ignore:
File:
1 edited

Legend:

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

    rb7fd2a0 rf300523  
    179179FIBRIL_MUTEX_INITIALIZE(irq_reg_mutex);
    180180
    181 static errno_t e1000_get_address(e1000_t *, nic_address_t *);
     181static int e1000_get_address(e1000_t *, nic_address_t *);
    182182static void e1000_eeprom_get_address(e1000_t *, nic_address_t *);
    183 static errno_t e1000_set_addr(ddf_fun_t *, const nic_address_t *);
    184 
    185 static errno_t e1000_defective_get_mode(ddf_fun_t *, uint32_t *);
    186 static errno_t e1000_defective_set_mode(ddf_fun_t *, uint32_t);
    187 
    188 static errno_t e1000_get_cable_state(ddf_fun_t *, nic_cable_state_t *);
    189 static errno_t e1000_get_device_info(ddf_fun_t *, nic_device_info_t *);
    190 static errno_t e1000_get_operation_mode(ddf_fun_t *, int *,
     183static int e1000_set_addr(ddf_fun_t *, const nic_address_t *);
     184
     185static int e1000_defective_get_mode(ddf_fun_t *, uint32_t *);
     186static int e1000_defective_set_mode(ddf_fun_t *, uint32_t);
     187
     188static int e1000_get_cable_state(ddf_fun_t *, nic_cable_state_t *);
     189static int e1000_get_device_info(ddf_fun_t *, nic_device_info_t *);
     190static int e1000_get_operation_mode(ddf_fun_t *, int *,
    191191    nic_channel_mode_t *, nic_role_t *);
    192 static errno_t e1000_set_operation_mode(ddf_fun_t *, int,
     192static int e1000_set_operation_mode(ddf_fun_t *, int,
    193193    nic_channel_mode_t, nic_role_t);
    194 static errno_t e1000_autoneg_enable(ddf_fun_t *, uint32_t);
    195 static errno_t e1000_autoneg_disable(ddf_fun_t *);
    196 static errno_t e1000_autoneg_restart(ddf_fun_t *);
    197 
    198 static errno_t e1000_vlan_set_tag(ddf_fun_t *, uint16_t, bool, bool);
     194static int e1000_autoneg_enable(ddf_fun_t *, uint32_t);
     195static int e1000_autoneg_disable(ddf_fun_t *);
     196static int e1000_autoneg_restart(ddf_fun_t *);
     197
     198static int 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 errno_t e1000_dev_add(ddf_dev_t *);
     221static int e1000_dev_add(ddf_dev_t *);
    222222
    223223/** Basic driver operations for E1000 driver */
     
    233233
    234234/* The default implementation callbacks */
    235 static errno_t e1000_on_activating(nic_t *);
    236 static errno_t e1000_on_stopping(nic_t *);
     235static int e1000_on_activating(nic_t *);
     236static int e1000_on_stopping(nic_t *);
    237237static void e1000_send_frame(nic_t *, void *, size_t);
    238238
     
    288288 *
    289289 */
    290 static errno_t e1000_get_device_info(ddf_fun_t *dev, nic_device_info_t *info)
     290static int e1000_get_device_info(ddf_fun_t *dev, nic_device_info_t *info)
    291291{
    292292        assert(dev);
     
    316316 *
    317317 */
    318 static errno_t e1000_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
     318static int 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 errno_t e1000_get_operation_mode(ddf_fun_t *fun, int *speed,
     337static int 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 errno_t e1000_set_operation_mode(ddf_fun_t *fun, int speed,
     388static int 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 errno_t e1000_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)
     436static int e1000_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)
    437437{
    438438        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
     
    462462 *
    463463 */
    464 static errno_t e1000_autoneg_disable(ddf_fun_t *fun)
     464static int e1000_autoneg_disable(ddf_fun_t *fun)
    465465{
    466466        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
     
    490490 *
    491491 */
    492 static errno_t e1000_autoneg_restart(ddf_fun_t *dev)
     492static int e1000_autoneg_restart(ddf_fun_t *dev)
    493493{
    494494        return e1000_autoneg_enable(dev, 0);
     
    501501 *
    502502 */
    503 static errno_t e1000_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)
     503static int e1000_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)
    504504{
    505505        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
     
    522522 *
    523523 */
    524 static errno_t e1000_defective_set_mode(ddf_fun_t *fun, uint32_t mode)
     524static int e1000_defective_set_mode(ddf_fun_t *fun, uint32_t mode)
    525525{
    526526        e1000_t *e1000 = DRIVER_DATA_FUN(fun);
    527         errno_t rc = EOK;
     527        int rc = EOK;
    528528       
    529529        fibril_mutex_lock(&e1000->rx_lock);
     
    827827 *
    828828 */
    829 static errno_t e1000_on_multicast_mode_change(nic_t *nic, nic_multicast_mode_t mode,
     829static int 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         errno_t rc = EOK;
     833        int rc = EOK;
    834834       
    835835        fibril_mutex_lock(&e1000->rx_lock);
     
    881881 *
    882882 */
    883 static errno_t e1000_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode,
     883static int 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         errno_t rc = EOK;
     887        int rc = EOK;
    888888       
    889889        fibril_mutex_lock(&e1000->rx_lock);
     
    937937 *
    938938 */
    939 static errno_t e1000_on_broadcast_mode_change(nic_t *nic, nic_broadcast_mode_t mode)
     939static int e1000_on_broadcast_mode_change(nic_t *nic, nic_broadcast_mode_t mode)
    940940{
    941941        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
    942         errno_t rc = EOK;
     942        int rc = EOK;
    943943       
    944944        fibril_mutex_lock(&e1000->rx_lock);
     
    10481048 *
    10491049 */
    1050 static errno_t e1000_vlan_set_tag(ddf_fun_t *fun, uint16_t tag, bool add,
     1050static int e1000_vlan_set_tag(ddf_fun_t *fun, uint16_t tag, bool add,
    10511051    bool strip)
    10521052{
     
    12591259 * @param nic Driver data
    12601260 *
    1261  * @param[out] handle  IRQ capability handle if the handler was registered
    1262  *
    1263  * @return An error code otherwise
    1264  *
    1265  */
    1266 inline static errno_t e1000_register_int_handler(nic_t *nic, cap_handle_t *handle)
     1261 * @return IRQ capability handle if the handler was registered
     1262 * @return Negative error code otherwise
     1263 *
     1264 */
     1265inline static int e1000_register_int_handler(nic_t *nic)
    12671266{
    12681267        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    12751274        e1000_irq_code.cmds[2].addr = e1000->reg_base_phys + E1000_IMC;
    12761275       
    1277         errno_t rc = register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq,
    1278             e1000_interrupt_handler, &e1000_irq_code, handle);
     1276        int cap = register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq,
     1277            e1000_interrupt_handler, &e1000_irq_code);
    12791278       
    12801279        fibril_mutex_unlock(&irq_reg_mutex);
    1281         return rc;
     1280        return cap;
    12821281}
    12831282
     
    13191318 *
    13201319 */
    1321 static errno_t e1000_poll_mode_change(nic_t *nic, nic_poll_mode_t mode,
     1320static int e1000_poll_mode_change(nic_t *nic, nic_poll_mode_t mode,
    13221321    const struct timeval *period)
    13231322{
     
    13701369 *
    13711370 * @return EOK if succeed
    1372  * @return An error code otherwise
    1373  *
    1374  */
    1375 static errno_t e1000_initialize_rx_structure(nic_t *nic)
     1371 * @return Negative error code otherwise
     1372 *
     1373 */
     1374static int e1000_initialize_rx_structure(nic_t *nic)
    13761375{
    13771376        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    13791378       
    13801379        e1000->rx_ring_virt = AS_AREA_ANY;
    1381         errno_t rc = dmamem_map_anonymous(
     1380        int rc = dmamem_map_anonymous(
    13821381            E1000_RX_FRAME_COUNT * sizeof(e1000_rx_descriptor_t),
    13831382            DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0,
     
    15241523 *
    15251524 * @return EOK if succeed
    1526  * @return An error code otherwise
     1525 * @return Negative error code otherwise
    15271526 *
    15281527 */
     
    15671566 *
    15681567 */
    1569 static errno_t e1000_initialize_tx_structure(e1000_t *e1000)
     1568static int e1000_initialize_tx_structure(e1000_t *e1000)
    15701569{
    15711570        size_t i;
     
    15791578        e1000->tx_frame_virt = NULL;
    15801579       
    1581         errno_t rc = dmamem_map_anonymous(
     1580        int rc = dmamem_map_anonymous(
    15821581            E1000_TX_FRAME_COUNT * sizeof(e1000_tx_descriptor_t),
    15831582            DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0,
     
    17181717 *
    17191718 */
    1720 static errno_t e1000_reset(nic_t *nic)
     1719static int e1000_reset(nic_t *nic)
    17211720{
    17221721        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    17491748 *
    17501749 */
    1751 static errno_t e1000_on_activating(nic_t *nic)
     1750static int e1000_on_activating(nic_t *nic)
    17521751{
    17531752        assert(nic);
     
    17611760        e1000_enable_interrupts(e1000);
    17621761       
    1763         errno_t rc = hw_res_enable_interrupt(e1000->parent_sess, e1000->irq);
     1762        int rc = hw_res_enable_interrupt(e1000->parent_sess, e1000->irq);
    17641763        if (rc != EOK) {
    17651764                e1000_disable_interrupts(e1000);
     
    17951794 *
    17961795 */
    1797 static errno_t e1000_on_down_unlocked(nic_t *nic)
     1796static int e1000_on_down_unlocked(nic_t *nic)
    17981797{
    17991798        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    18261825 *
    18271826 */
    1828 static errno_t e1000_on_down(nic_t *nic)
     1827static int e1000_on_down(nic_t *nic)
    18291828{
    18301829        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    18341833        fibril_mutex_lock(&e1000->ctrl_lock);
    18351834       
    1836         errno_t rc = e1000_on_down_unlocked(nic);
     1835        int rc = e1000_on_down_unlocked(nic);
    18371836       
    18381837        fibril_mutex_unlock(&e1000->ctrl_lock);
     
    18511850 *
    18521851 */
    1853 static errno_t e1000_on_stopping(nic_t *nic)
     1852static int e1000_on_stopping(nic_t *nic)
    18541853{
    18551854        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    18591858        fibril_mutex_lock(&e1000->ctrl_lock);
    18601859       
    1861         errno_t rc = e1000_on_down_unlocked(nic);
     1860        int rc = e1000_on_down_unlocked(nic);
    18621861        if (rc == EOK)
    18631862                rc = e1000_reset(nic);
     
    19401939 *
    19411940 * @return EOK if succeed
    1942  * @return An error code otherwise
    1943  *
    1944  */
    1945 static errno_t e1000_fill_resource_info(ddf_dev_t *dev,
     1941 * @return Negative error code otherwise
     1942 *
     1943 */
     1944static int e1000_fill_resource_info(ddf_dev_t *dev,
    19461945    const hw_res_list_parsed_t *hw_resources)
    19471946{
     
    19651964 *
    19661965 * @return EOK if succeed
    1967  * @return An error code otherwise
    1968  *
    1969  */
    1970 static errno_t e1000_get_resource_info(ddf_dev_t *dev)
     1966 * @return Negative error code otherwise
     1967 *
     1968 */
     1969static int e1000_get_resource_info(ddf_dev_t *dev)
    19711970{
    19721971        assert(dev != NULL);
     
    19771976       
    19781977        /* Get hw resources form parent driver */
    1979         errno_t rc = nic_get_resources(NIC_DATA_DEV(dev), &hw_res_parsed);
     1978        int rc = nic_get_resources(NIC_DATA_DEV(dev), &hw_res_parsed);
    19801979        if (rc != EOK)
    19811980                return rc;
     
    19931992 *
    19941993 * @return EOK if succeed
    1995  * @return An error code otherwise
    1996  *
    1997  */
    1998 static errno_t e1000_device_initialize(ddf_dev_t *dev)
     1994 * @return Negative error code otherwise
     1995 *
     1996 */
     1997static int e1000_device_initialize(ddf_dev_t *dev)
    19991998{
    20001999        /* Allocate driver data for the device. */
     
    20122011       
    20132012        /* Obtain and fill hardware resources info */
    2014         errno_t rc = e1000_get_resource_info(dev);
     2013        int rc = e1000_get_resource_info(dev);
    20152014        if (rc != EOK) {
    20162015                ddf_msg(LVL_ERROR, "Cannot obtain hardware resources");
     
    21072106 *
    21082107 * @return EOK if successed
    2109  * @return An error code otherwise
    2110  *
    2111  */
    2112 static errno_t e1000_pio_enable(ddf_dev_t *dev)
     2108 * @return Negative error code otherwise
     2109 *
     2110 */
     2111static int e1000_pio_enable(ddf_dev_t *dev)
    21132112{
    21142113        e1000_t *e1000 = DRIVER_DATA_DEV(dev);
    21152114       
    2116         errno_t rc = pio_enable(e1000->reg_base_phys, 8 * PAGE_SIZE,
     2115        int rc = pio_enable(e1000->reg_base_phys, 8 * PAGE_SIZE,
    21172116            &e1000->reg_base_virt);
    21182117        if (rc != EOK)
     
    21272126 *
    21282127 */
    2129 errno_t e1000_dev_add(ddf_dev_t *dev)
     2128int e1000_dev_add(ddf_dev_t *dev)
    21302129{
    21312130        ddf_fun_t *fun;
    21322131       
    21332132        /* Initialize device structure for E1000 */
    2134         errno_t rc = e1000_device_initialize(dev);
     2133        int rc = e1000_device_initialize(dev);
    21352134        if (rc != EOK)
    21362135                return rc;
     
    21652164        ddf_fun_set_ops(fun, &e1000_dev_ops);
    21662165       
    2167         int irq_cap;
    2168         rc = e1000_register_int_handler(nic, &irq_cap);
    2169         if (rc != EOK) {
     2166        int irq_cap = e1000_register_int_handler(nic);
     2167        if (irq_cap < 0) {
     2168                rc = irq_cap;
    21702169                goto err_fun_create;
    21712170        }
     
    22552254 *
    22562255 * @return EOK if succeed
    2257  * @return An error code otherwise
    2258  *
    2259  */
    2260 static errno_t e1000_get_address(e1000_t *e1000, nic_address_t *address)
     2256 * @return Negative error code otherwise
     2257 *
     2258 */
     2259static int e1000_get_address(e1000_t *e1000, nic_address_t *address)
    22612260{
    22622261        fibril_mutex_lock(&e1000->rx_lock);
     
    22892288 *
    22902289 * @return EOK if succeed
    2291  * @return An error code otherwise
    2292  */
    2293 static errno_t e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr)
     2290 * @return Negative error code otherwise
     2291 */
     2292static int e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr)
    22942293{
    22952294        nic_t *nic = NIC_DATA_FUN(fun);
     
    22992298        fibril_mutex_lock(&e1000->tx_lock);
    23002299       
    2301         errno_t rc = nic_report_address(nic, addr);
     2300        int rc = nic_report_address(nic, addr);
    23022301        if (rc == EOK)
    23032302                e1000_write_receive_address(e1000, 0, addr, false);
Note: See TracChangeset for help on using the changeset viewer.