Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 7493e7b in mainline


Ignore:
Timestamp:
2014-07-13T22:59:27Z (6 years ago)
Author:
Agnieszka Tabaka <nufcia@…>
Branches:
master
Children:
07e647a
Parents:
af2a76c
Message:

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

Location:
uspace
Files:
2 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);
  • uspace/lib/drv/generic/remote_nic.c

    raf2a76c r7493e7b  
    288288        async_exch_t *exch = async_exchange_begin(dev_sess);
    289289       
    290         int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    291             NIC_GET_DEVICE_INFO);
    292         if (rc != EOK) {
    293                 async_exchange_end(exch);
     290        aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     291            NIC_GET_DEVICE_INFO, NULL);
     292        int rc = async_data_read_start(exch, device_info, sizeof(nic_device_info_t));
     293        async_exchange_end(exch);
     294
     295        sysarg_t res;
     296        async_wait_for(aid, &res);
     297       
     298        if (rc != EOK)
    294299                return rc;
    295         }
    296        
    297         rc = async_data_read_start(exch, device_info, sizeof(nic_device_info_t));
    298        
    299         async_exchange_end(exch);
    300        
    301         return rc;
     300       
     301        return (int) res;
    302302}
    303303
Note: See TracChangeset for help on using the changeset viewer.