Changes in / [f2f4c00:251d4dd] in mainline


Ignore:
Files:
5 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    rf2f4c00 r251d4dd  
    138138        nic/e1k \
    139139        nic/rtl8139 \
    140         nic/rtl8169 \
    141140        block/ahci
    142141
  • uspace/Makefile

    rf2f4c00 r251d4dd  
    154154        drv/nic/ne2k \
    155155        drv/nic/e1k \
    156         drv/nic/rtl8139 \
    157         drv/nic/rtl8169
     156        drv/nic/rtl8139
    158157
    159158## Platform-specific hardware support
  • uspace/app/nic/nic.c

    rf2f4c00 r251d4dd  
    4545
    4646typedef struct {
    47         nic_device_info_t device_info;
    4847        nic_address_t address;
    4948        nic_cable_state_t link_state;
    50         nic_channel_mode_t duplex;
    51         int speed;
    5249} nic_info_t;
    5350
     
    5552{
    5653        printf("syntax:\n");
    57         printf("\t" NAME " [<index> <cmd> [<args...>]]\n");
    58         printf("\t<index> is NIC index number reported by the tool\n");
    59         printf("\t<cmd> is:\n");
    60         printf("\taddr <mac_address> - set MAC address\n");
    61         printf("\tspeed <10|100|1000> - set NIC speed\n");
    62         printf("\tduplex <half|full|simplex> - set duplex mode\n");
    63         printf("\tauto - enable autonegotiation\n");
    64 }
    65 
    66 static async_sess_t *get_nic_by_index(size_t i)
    67 {
    68         int rc;
    69         size_t count;
    70         char *svc_name;
    71         category_id_t nic_cat;
    72         service_id_t *nics = NULL;
    73         async_sess_t *sess;
    74 
    75         rc = loc_category_get_id("nic", &nic_cat, 0);
    76         if (rc != EOK) {
    77                 printf("Error resolving category 'nic'.\n");
    78                 goto error;
    79         }
    80 
    81         rc = loc_category_get_svcs(nic_cat, &nics, &count);
    82         if (rc != EOK) {
    83                 printf("Error getting list of NICs.\n");
    84                 goto error;
    85         }
    86 
    87         rc = loc_service_get_name(nics[i], &svc_name);
    88         if (rc != EOK) {
    89                 printf("Error getting service name.\n");
    90                 goto error;
    91         }
    92 
    93         printf("Using device: %s\n", svc_name);
    94 
    95         sess = loc_service_connect(EXCHANGE_SERIALIZE, nics[i], 0);
    96         if (sess == NULL) {
    97                 printf("Error connecting to service.\n");
    98                 goto error;
    99         }
    100 
    101         return sess;
    102 error:
    103         return NULL;
     54        printf("\t" NAME "\n");
    10455}
    10556
     
    10859{
    10960        async_sess_t *sess;
    110         nic_role_t role;
    11161        int rc;
    11262
    11363        sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id, 0);
    11464        if (sess == NULL) {
    115                 printf("Error connecting to service.\n");
     65                printf("Error connecting '%s'.\n", svc_name);
     66                rc = EIO;
    11667                goto error;
    11768        }
     
    12475        }
    12576
    126         rc = nic_get_device_info(sess, &info->device_info);
    127         if (rc != EOK) {
    128                 printf("Error getting NIC device info.\n");
    129                 rc = EIO;
    130                 goto error;
    131         }
    132 
    13377        rc = nic_get_cable_state(sess, &info->link_state);
    13478        if (rc != EOK) {
     
    13781                goto error;
    13882        }
    139 
    140         rc = nic_get_operation_mode(sess, &info->speed, &info->duplex, &role);
    141         if (rc != EOK) {
    142                 printf("Error getting NIC speed and duplex mode.\n");
    143                 rc = EIO;
    144                 goto error;
    145         }
    146 
    14783
    14884        return EOK;
     
    15793        case NIC_CS_PLUGGED: return "up";
    15894        case NIC_CS_UNPLUGGED: return "down";
    159         default: assert(false); return NULL;
    160         }
    161 }
    162 
    163 static const char *nic_duplex_mode_str(nic_channel_mode_t mode)
    164 {
    165         switch (mode) {
    166         case NIC_CM_FULL_DUPLEX: return "full-duplex";
    167         case NIC_CM_HALF_DUPLEX: return "half-duplex";
    168         case NIC_CM_SIMPLEX: return "simplex";
    16995        default: assert(false); return NULL;
    17096        }
     
    207133        }
    208134
    209         printf("[Index]: [Service Name]\n");
     135        printf("[Address] [Link State] [Service Name]\n");
    210136        for (i = 0; i < count; i++) {
    211137                rc = loc_service_get_name(nics[i], &svc_name);
     
    226152                }
    227153
    228                 printf("%zu: %s\n", i, svc_name);
    229                 printf("\tMAC address: %s\n", addr_str);
    230                 printf("\tVendor name: %s\n",
    231                     nic_info.device_info.vendor_name);
    232                 printf("\tModel name: %s\n",
    233                     nic_info.device_info.model_name);
    234                 printf("\tLink state: %s\n",
    235                     nic_link_state_str(nic_info.link_state));
    236 
    237                 if (nic_info.link_state == NIC_CS_PLUGGED) {
    238                         printf("\tSpeed: %dMbps %s\n", nic_info.speed,
    239                             nic_duplex_mode_str(nic_info.duplex));
    240                 }
     154                printf("%s %s %s\n", addr_str,
     155                    nic_link_state_str(nic_info.link_state), svc_name);
    241156
    242157                free(svc_name);
     
    250165}
    251166
    252 static int nic_set_speed(int i, char *str)
    253 {
    254         async_sess_t *sess;
    255         uint32_t speed;
    256         int oldspeed;
    257         nic_channel_mode_t oldduplex;
    258         nic_role_t oldrole;
    259         int rc;
    260 
    261         rc = str_uint32_t(str, NULL, 10, false, &speed);
    262         if (rc != EOK) {
    263                 printf("Speed must be a numeric value.\n");
    264                 return rc;
    265         }
    266 
    267         if (speed != 10 && speed != 100 && speed != 1000) {
    268                 printf("Speed must be one of: 10, 100, 1000.\n");
    269                 return EINVAL;
    270         }
    271 
    272         sess = get_nic_by_index(i);
    273         if (sess == NULL) {
    274                 printf("Specified NIC doesn't exist or cannot connect to it.\n");
    275                 return EINVAL;
    276         }
    277 
    278         rc = nic_get_operation_mode(sess, &oldspeed, &oldduplex, &oldrole);
    279         if (rc != EOK) {
    280                 printf("Error getting NIC speed and duplex mode.\n");
    281                 return EIO;
    282         }
    283 
    284         return nic_set_operation_mode(sess, speed, oldduplex, oldrole);
    285 }
    286 
    287 static int nic_set_duplex(int i, char *str)
    288 {
    289         async_sess_t *sess;
    290         int oldspeed;
    291         nic_channel_mode_t duplex = NIC_CM_UNKNOWN;
    292         nic_channel_mode_t oldduplex;
    293         nic_role_t oldrole;
    294         int rc;
    295 
    296         if (!str_cmp(str, "half"))
    297                 duplex = NIC_CM_HALF_DUPLEX;
    298 
    299         if (!str_cmp(str, "full"))
    300                 duplex = NIC_CM_FULL_DUPLEX;
    301 
    302         if (!str_cmp(str, "simplex"))
    303                 duplex = NIC_CM_SIMPLEX;
    304 
    305         if (duplex == NIC_CM_UNKNOWN) {
    306                 printf("Invalid duplex specification.\n");
    307                 return EINVAL;
    308         }
    309 
    310         sess = get_nic_by_index(i);
    311         if (sess == NULL) {
    312                 printf("Specified NIC doesn't exist or cannot connect to it.\n");
    313                 return EINVAL;
    314         }
    315 
    316         rc = nic_get_operation_mode(sess, &oldspeed, &oldduplex, &oldrole);
    317         if (rc != EOK) {
    318                 printf("Error getting NIC speed and duplex mode.\n");
    319                 return EIO;
    320         }
    321 
    322         return nic_set_operation_mode(sess, oldspeed, duplex, oldrole);
    323 }
    324 
    325 static int nic_set_autoneg(int i)
    326 {
    327         async_sess_t *sess;
    328         int rc;
    329 
    330         sess = get_nic_by_index(i);
    331         if (sess == NULL) {
    332                 printf("Specified NIC doesn't exist or cannot connect to it.\n");
    333                 return EINVAL;
    334         }
    335 
    336         rc = nic_autoneg_restart(sess);
    337         if (rc != EOK) {
    338                 printf("Error restarting NIC autonegotiation.\n");
    339                 return EIO;
    340         }
    341 
    342         return EOK;
    343 }
    344 
    345 static int nic_set_addr(int i, char *str)
    346 {
    347         async_sess_t *sess;
    348         nic_address_t addr;
    349         int rc, idx;
    350 
    351         sess = get_nic_by_index(i);
    352         if (sess == NULL) {
    353                 printf("Specified NIC doesn't exist or cannot connect to it.\n");
    354                 return EINVAL;
    355         }
    356 
    357         if (str_size(str) != 17) {
    358                 printf("Invalid MAC address specified");
    359                 return EINVAL;
    360         }
    361 
    362         for (idx = 0; idx < 6; idx++) {
    363                 rc = str_uint8_t(&str[idx * 3], NULL, 16, false, &addr.address[idx]);
    364                 if (rc != EOK) {
    365                         printf("Invalid MAC address specified");
    366                         return EINVAL;
    367                 }
    368         }
    369 
    370         return nic_set_address(sess, &addr);
    371 }
    372 
    373167int main(int argc, char *argv[])
    374168{
    375169        int rc;
    376         uint32_t index;
    377170
    378171        if (argc == 1) {
     
    380173                if (rc != EOK)
    381174                        return 1;
    382         } else if (argc >= 3) {
    383                 rc = str_uint32_t(argv[1], NULL, 10, false, &index);
    384                 if (rc != EOK) {
    385                         printf(NAME ": Invalid argument.\n");
    386                         print_syntax();
    387                         return 1;
    388                 }
    389 
    390                 if (!str_cmp(argv[2], "addr"))
    391                         return nic_set_addr(index, argv[3]);
    392 
    393                 if (!str_cmp(argv[2], "speed"))
    394                         return nic_set_speed(index, argv[3]);
    395 
    396                 if (!str_cmp(argv[2], "duplex"))
    397                         return nic_set_duplex(index, argv[3]);
    398 
    399                 if (!str_cmp(argv[2], "auto"))
    400                         return nic_set_autoneg(index);
    401 
    402175        } else {
    403176                printf(NAME ": Invalid argument.\n");
  • uspace/lib/drv/generic/remote_nic.c

    rf2f4c00 r251d4dd  
    288288        async_exch_t *exch = async_exchange_begin(dev_sess);
    289289       
    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)
     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);
    299294                return rc;
    300        
    301         return (int) res;
     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;
    302302}
    303303
  • uspace/lib/drv/include/pci_dev_iface.h

    rf2f4c00 r251d4dd  
    4040#include "ddf/driver.h"
    4141
    42 #define PCI_VENDOR_ID  0x00
    4342#define PCI_DEVICE_ID  0x02
    4443
  • uspace/lib/nic/src/nic_driver.c

    rf2f4c00 r251d4dd  
    4747#include <ops/nic.h>
    4848#include <errno.h>
    49 
    50 #include <io/log.h>
    5149
    5250#include "nic_driver.h"
     
    438436                int rc = nic_ev_addr_changed(nic_data->client_session,
    439437                    address);
    440                 log_msg(LOG_DEFAULT, LVL_WARN, "rc=%d", rc);
    441 
    442438                if (rc != EOK) {
    443439                        fibril_rwlock_write_unlock(&nic_data->main_lock);
  • uspace/lib/nic/src/nic_impl.c

    rf2f4c00 r251d4dd  
    179179
    180180        nic_data->send_frame(nic_data, data, size);
    181         fibril_rwlock_read_unlock(&nic_data->main_lock);
    182181        return EOK;
    183182}
  • uspace/srv/net/ethip/ethip_nic.c

    rf2f4c00 r251d4dd  
    231231    ipc_call_t *call)
    232232{
    233         uint8_t *addr;
    234         size_t size;
    235         int rc;
    236 
    237         rc = async_data_write_accept((void **)&addr, false, 0, 0, 0, &size);
    238         if (rc != EOK) {
    239                 log_msg(LOG_DEFAULT, LVL_DEBUG, "data_write_accept() failed");
    240                 return;
    241         }
    242 
    243         log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_changed(): "
    244             "new addr=%02x:%02x:%02x:%02x:%02x:%02x",
    245             addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
    246 
    247         free(addr);
    248         async_answer_0(callid, EOK);
     233        log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_changed()");
     234        async_answer_0(callid, ENOTSUP);
    249235}
    250236
     
    309295                        break;
    310296                default:
    311                         log_msg(LOG_DEFAULT, LVL_DEBUG, "unknown IPC method: %d", (int) IPC_GET_IMETHOD(call));
    312297                        async_answer_0(callid, ENOTSUP);
    313298                }
Note: See TracChangeset for help on using the changeset viewer.