Changeset 7493e7b in mainline
- Timestamp:
- 2014-07-13T22:59:27Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 07e647a
- Parents:
- af2a76c
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nic/nic.c
raf2a76c r7493e7b 45 45 46 46 typedef struct { 47 nic_device_info_t device_info; 47 48 nic_address_t address; 48 49 nic_cable_state_t link_state; 50 nic_channel_mode_t duplex; 51 int speed; 49 52 } nic_info_t; 50 53 … … 59 62 { 60 63 async_sess_t *sess; 64 nic_role_t role; 61 65 int rc; 62 66 … … 75 79 } 76 80 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 77 88 rc = nic_get_cable_state(sess, &info->link_state); 78 89 if (rc != EOK) { … … 81 92 goto error; 82 93 } 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 83 102 84 103 return EOK; … … 93 112 case NIC_CS_PLUGGED: return "up"; 94 113 case NIC_CS_UNPLUGGED: return "down"; 114 default: assert(false); return NULL; 115 } 116 } 117 118 static 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"; 95 123 default: assert(false); return NULL; 96 124 } … … 133 161 } 134 162 135 printf("[Address] [ Link State] [Service Name]\n");163 printf("[Address] [Service Name]\n"); 136 164 for (i = 0; i < count; i++) { 137 165 rc = loc_service_get_name(nics[i], &svc_name); … … 152 180 } 153 181 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 } 156 194 157 195 free(svc_name); -
uspace/lib/drv/generic/remote_nic.c
raf2a76c r7493e7b 288 288 async_exch_t *exch = async_exchange_begin(dev_sess); 289 289 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) 294 299 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; 302 302 } 303 303
Note:
See TracChangeset
for help on using the changeset viewer.