Changeset 7493e7b in mainline for uspace/app/nic/nic.c


Ignore:
Timestamp:
2014-07-13T22:59:27Z (11 years ago)
Author:
Agnieszka Tabaka <nufcia@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
07e647a
Parents:
af2a76c
Message:

Add more information about NIC in 'nic' utility. Fix nic_get_device_info
function in lib/drv.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nic/nic.c

    raf2a76c r7493e7b  
    4545
    4646typedef struct {
     47        nic_device_info_t device_info;
    4748        nic_address_t address;
    4849        nic_cable_state_t link_state;
     50        nic_channel_mode_t duplex;
     51        int speed;
    4952} nic_info_t;
    5053
     
    5962{
    6063        async_sess_t *sess;
     64        nic_role_t role;
    6165        int rc;
    6266
     
    7579        }
    7680
     81        rc = nic_get_device_info(sess, &info->device_info);
     82        if (rc != EOK) {
     83                printf("Error getting NIC device info.\n");
     84                rc = EIO;
     85                goto error;
     86        }
     87
    7788        rc = nic_get_cable_state(sess, &info->link_state);
    7889        if (rc != EOK) {
     
    8192                goto error;
    8293        }
     94
     95        rc = nic_get_operation_mode(sess, &info->speed, &info->duplex, &role);
     96        if (rc != EOK) {
     97                printf("Error getting NIC speed and duplex mode.\n");
     98                rc = EIO;
     99                goto error;
     100        }
     101
    83102
    84103        return EOK;
     
    93112        case NIC_CS_PLUGGED: return "up";
    94113        case NIC_CS_UNPLUGGED: return "down";
     114        default: assert(false); return NULL;
     115        }
     116}
     117
     118static const char *nic_duplex_mode_str(nic_channel_mode_t mode)
     119{
     120        switch (mode) {
     121        case NIC_CM_FULL_DUPLEX: return "full-duplex";
     122        case NIC_CM_HALF_DUPLEX: return "half-duplex";
    95123        default: assert(false); return NULL;
    96124        }
     
    133161        }
    134162
    135         printf("[Address] [Link State] [Service Name]\n");
     163        printf("[Address] [Service Name]\n");
    136164        for (i = 0; i < count; i++) {
    137165                rc = loc_service_get_name(nics[i], &svc_name);
     
    152180                }
    153181
    154                 printf("%s %s %s\n", addr_str,
    155                     nic_link_state_str(nic_info.link_state), svc_name);
     182                printf("%s %s\n", addr_str, svc_name);
     183                printf("\tVendor name: %s\n",
     184                    nic_info.device_info.vendor_name);
     185                printf("\tModel name: %s\n",
     186                    nic_info.device_info.model_name);
     187                printf("\tLink state: %s\n",
     188                    nic_link_state_str(nic_info.link_state));
     189
     190                if (nic_info.link_state == NIC_CS_PLUGGED) {
     191                        printf("\tSpeed: %dMbps %s\n", nic_info.speed,
     192                            nic_duplex_mode_str(nic_info.duplex));
     193                }
    156194
    157195                free(svc_name);
Note: See TracChangeset for help on using the changeset viewer.