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

Changeset 8da2c60 in mainline


Ignore:
Timestamp:
2012-01-27T19:12:45Z (8 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
master
Children:
fe56c08a
Parents:
ea75ceb (diff), d81eaf94 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with mainline

Location:
uspace
Files:
15 edited

Legend:

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

    rea75ceb r8da2c60  
    20572057        case E1000_82545:
    20582058        case E1000_82546:
    2059         case E1000_82572:
    20602059                e1000->info.eerd_start = 0x01;
    20612060                e1000->info.eerd_done = 0x10;
     
    20642063                break;
    20652064        case E1000_82547:
     2065        case E1000_82572:
    20662066        case E1000_80003ES2:
    20672067                e1000->info.eerd_start = 0x01;
  • uspace/lib/c/generic/device/nic.c

    rea75ceb r8da2c60  
    8181 *
    8282 */
    83 int nic_callback_create(async_sess_t *dev_sess, nic_device_id_t device_id,
    84     async_client_conn_t cfun, void *carg)
     83int nic_callback_create(async_sess_t *dev_sess, async_client_conn_t cfun,
     84    void *carg)
    8585{
    8686        ipc_call_t answer;
     
    8989       
    9090        async_exch_t *exch = async_exchange_begin(dev_sess);
    91         aid_t req = async_send_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    92             NIC_CALLBACK_CREATE, device_id, &answer);
     91        aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     92            NIC_CALLBACK_CREATE, &answer);
    9393       
    9494        rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg);
  • uspace/lib/c/include/device/nic.h

    rea75ceb r8da2c60  
    9191
    9292extern int nic_send_frame(async_sess_t *, void *, size_t);
    93 extern int nic_callback_create(async_sess_t *, nic_device_id_t,
    94     async_client_conn_t, void *);
     93extern int nic_callback_create(async_sess_t *, async_client_conn_t, void *);
    9594extern int nic_get_state(async_sess_t *, nic_device_state_t *);
    9695extern int nic_set_state(async_sess_t *, nic_device_state_t);
  • uspace/lib/c/include/net/device.h

    rea75ceb r8da2c60  
    4747#define DEVICE_MAP_IMPLEMENT  INT_MAP_IMPLEMENT
    4848
     49/** Device identifier type. */
     50typedef int nic_device_id_t;
     51
     52/** Invalid device identifier. */
     53#define NIC_DEVICE_INVALID_ID  (-1)
     54
    4955#endif
    5056
  • uspace/lib/c/include/nic/nic.h

    rea75ceb r8da2c60  
    6363#define NIC_MAX_ADDRESS_LENGTH  16
    6464
    65 /** Invalid device identifier. */
    66 #define NIC_DEVICE_INVALID_ID  (-1)
    67 
    6865#define NIC_VENDOR_MAX_LENGTH         64
    6966#define NIC_MODEL_MAX_LENGTH          64
     
    8683
    8784#define NIC_DEVICE_PRINT_FMT  "%x"
    88 
    89 /** Device identifier type. */
    90 typedef int nic_device_id_t;
    9185
    9286/**
  • uspace/lib/drv/generic/remote_nic.c

    rea75ceb r8da2c60  
    6969        assert(nic_iface->callback_create);
    7070       
    71         nic_device_id_t device_id = (nic_device_id_t) IPC_GET_ARG2(*call);
    72        
    73         int rc = nic_iface->callback_create(dev, device_id);
     71        int rc = nic_iface->callback_create(dev);
    7472        async_answer_0(callid, rc);
    7573}
  • uspace/lib/drv/include/ops/nic.h

    rea75ceb r8da2c60  
    4646        /** Mandatory methods */
    4747        int (*send_frame)(ddf_fun_t *, void *, size_t);
    48         int (*callback_create)(ddf_fun_t *, nic_device_id_t);
     48        int (*callback_create)(ddf_fun_t *);
    4949        int (*get_state)(ddf_fun_t *, nic_device_state_t *);
    5050        int (*set_state)(ddf_fun_t *, nic_device_state_t);
  • uspace/lib/nic/include/nic_driver.h

    rea75ceb r8da2c60  
    7070         */
    7171        ddf_fun_t *fun;
    72         /** Identifier for higher network stack layers */
    73         nic_device_id_t device_id;
    7472        /** Current state of the device */
    7573        nic_device_state_t state;
  • uspace/lib/nic/include/nic_ev.h

    rea75ceb r8da2c60  
    4343#include <sys/types.h>
    4444
    45 extern int nic_ev_addr_changed(async_sess_t *, nic_device_id_t,
    46     const nic_address_t *);
    47 extern int nic_ev_device_state(async_sess_t *, nic_device_id_t, sysarg_t);
    48 extern int nic_ev_received(async_sess_t *, nic_device_id_t, void *, size_t);
     45extern int nic_ev_addr_changed(async_sess_t *, const nic_address_t *);
     46extern int nic_ev_device_state(async_sess_t *, sysarg_t);
     47extern int nic_ev_received(async_sess_t *, void *, size_t);
    4948
    5049#endif
  • uspace/lib/nic/include/nic_impl.h

    rea75ceb r8da2c60  
    4848extern int nic_get_address_impl(ddf_fun_t *dev_fun, nic_address_t *address);
    4949extern int nic_send_frame_impl(ddf_fun_t *dev_fun, void *data, size_t size);
    50 extern int nic_callback_create_impl(ddf_fun_t *dev_fun, int device_id);
     50extern int nic_callback_create_impl(ddf_fun_t *dev_fun);
    5151extern int nic_get_state_impl(ddf_fun_t *dev_fun, nic_device_state_t *state);
    5252extern int nic_set_state_impl(ddf_fun_t *dev_fun, nic_device_state_t state);
  • uspace/lib/nic/src/nic_driver.c

    rea75ceb r8da2c60  
    497497        if (nic_data->client_session != NULL) {
    498498                int rc = nic_ev_addr_changed(nic_data->client_session,
    499                     nic_data->device_id, address);
     499                    address);
    500500                if (rc != EOK) {
    501501                        fibril_rwlock_write_unlock(&nic_data->main_lock);
     
    604604                }
    605605                fibril_rwlock_write_unlock(&nic_data->stats_lock);
    606                 nic_ev_received(nic_data->client_session, nic_data->device_id,
    607                     frame->data, frame->size);
     606                nic_ev_received(nic_data->client_session, frame->data,
     607                    frame->size);
    608608        } else {
    609609                switch (frame_type) {
     
    639639        fibril_rwlock_write_unlock(&nic_data->stats_lock);
    640640       
    641         nic_ev_received(nic_data->client_session, nic_data->device_id,
    642             data, size);
     641        nic_ev_received(nic_data->client_session, data, size);
    643642}
    644643
     
    691690        nic_data->dev = NULL;
    692691        nic_data->fun = NULL;
    693         nic_data->device_id = NIC_DEVICE_INVALID_ID;
    694692        nic_data->state = NIC_STATE_STOPPED;
    695693        nic_data->client_session = NULL;
  • uspace/lib/nic/src/nic_ev.c

    rea75ceb r8da2c60  
    4242
    4343/** Device address changed. */
    44 int nic_ev_addr_changed(async_sess_t *sess, nic_device_id_t dev_id,
    45     const nic_address_t *addr)
     44int nic_ev_addr_changed(async_sess_t *sess, const nic_address_t *addr)
    4645{
    4746        async_exch_t *exch = async_exchange_begin(sess);
    4847
    4948        ipc_call_t answer;
    50         aid_t req = async_send_1(exch, NIC_EV_ADDR_CHANGED, (sysarg_t) dev_id,
    51             &answer);
     49        aid_t req = async_send_0(exch, NIC_EV_ADDR_CHANGED, &answer);
    5250        sysarg_t retval = async_data_write_start(exch, addr,
    5351            sizeof(nic_address_t));
     
    6563
    6664/** Device state changed. */
    67 extern int nic_ev_device_state(async_sess_t *sess, nic_device_id_t dev_id,
    68     sysarg_t state)
     65extern int nic_ev_device_state(async_sess_t *sess, sysarg_t state)
    6966{
    7067        int rc;
    7168
    7269        async_exch_t *exch = async_exchange_begin(sess);
    73         rc = async_req_2_0(exch, NIC_EV_DEVICE_STATE, dev_id, state);
     70        rc = async_req_1_0(exch, NIC_EV_DEVICE_STATE, state);
    7471        async_exchange_end(exch);
    7572
     
    7875
    7976/** Frame received. */
    80 int nic_ev_received(async_sess_t *sess, nic_device_id_t dev_id, void *data,
    81     size_t size)
     77int nic_ev_received(async_sess_t *sess, void *data, size_t size)
    8278{
    8379        async_exch_t *exch = async_exchange_begin(sess);
    8480
    8581        ipc_call_t answer;
    86         aid_t req = async_send_1(exch, NIC_EV_RECEIVED, (sysarg_t) dev_id,
    87             &answer);
     82        aid_t req = async_send_0(exch, NIC_EV_RECEIVED, &answer);
    8883        sysarg_t retval = async_data_write_start(exch, data, size);
    8984
  • uspace/lib/nic/src/nic_impl.c

    rea75ceb r8da2c60  
    8787        }
    8888        if (state == NIC_STATE_ACTIVE) {
    89                 if (nic_data->client_session == NULL || nic_data->device_id < 0) {
     89                if (nic_data->client_session == NULL) {
    9090                        fibril_rwlock_write_unlock(&nic_data->main_lock);
    9191                        return EINVAL;
     
    118118                /* Notify upper layers that we are reseting the MAC */
    119119                int rc = nic_ev_addr_changed(nic_data->client_session,
    120                         nic_data->device_id, &nic_data->default_mac);
     120                        &nic_data->default_mac);
    121121                nic_data->poll_mode = nic_data->default_poll_mode;
    122122                memcpy(&nic_data->poll_period, &nic_data->default_poll_period,
     
    150150        nic_data->state = state;
    151151
    152         nic_ev_device_state(nic_data->client_session, nic_data->device_id, state);
     152        nic_ev_device_state(nic_data->client_session, state);
    153153
    154154        fibril_rwlock_write_unlock(&nic_data->main_lock);
     
    187187 *
    188188 * @param       fun
    189  * @param       device_id       ID of the device as used in higher layers
    190189 *
    191190 * @return EOK          On success, or negative error code.
    192191 */
    193 int nic_callback_create_impl(ddf_fun_t *fun, nic_device_id_t device_id)
     192int nic_callback_create_impl(ddf_fun_t *fun)
    194193{
    195194        nic_t *nic = (nic_t *) fun->driver_data;
    196195        fibril_rwlock_write_lock(&nic->main_lock);
    197        
    198         nic->device_id = device_id;
    199196       
    200197        nic->client_session = async_callback_receive(EXCHANGE_SERIALIZE);
  • uspace/srv/net/nil/eth/eth.c

    rea75ceb r8da2c60  
    173173    void *arg);
    174174
    175 static int eth_device_state(nic_device_id_t device_id, sysarg_t state)
     175static int eth_device_state(eth_device_t *device, sysarg_t state)
    176176{
    177177        int index;
     
    183183                proto = eth_protos_get_index(&eth_globals.protos, index);
    184184                if ((proto) && (proto->sess)) {
    185                         il_device_state_msg(proto->sess, device_id, state,
    186                             proto->service);
     185                        il_device_state_msg(proto->sess, device->device_id,
     186                            state, proto->service);
    187187                }
    188188        }
     
    347347        }
    348348       
    349         rc = nic_callback_create(device->sess, device_id,
    350             eth_nic_cb_connection, NULL);
     349        rc = nic_callback_create(device->sess, eth_nic_cb_connection, device);
    351350        if (rc != EOK) {
    352351                fibril_rwlock_write_unlock(&eth_globals.devices_lock);
     
    825824}
    826825
    827 static int eth_received(nic_device_id_t device_id)
     826static int eth_received(eth_device_t *device)
    828827{
    829828        void *data;
     
    845844        free(data);
    846845       
    847         return nil_received_msg_local(device_id, packet);
    848 }
    849 
    850 static int eth_addr_changed(nic_device_id_t device_id)
     846        return nil_received_msg_local(device->device_id, packet);
     847}
     848
     849static int eth_addr_changed(eth_device_t *device)
    851850{
    852851        nic_address_t address;
     
    866865
    867866        fibril_rwlock_write_lock(&eth_globals.devices_lock);
    868         /* An existing device? */
    869         eth_device_t *device = eth_devices_find(&eth_globals.devices, device_id);
    870         if (device) {
    871                 printf("Device %d changing address from " PRIMAC " to " PRIMAC "\n",
    872                         device_id, ARGSMAC(device->addr.address), ARGSMAC(address.address));
    873                 memcpy(&device->addr, &address, sizeof (nic_address_t));
    874                 fibril_rwlock_write_unlock(&eth_globals.devices_lock);
    875 
    876                 /* Notify all upper layer modules */
    877                 fibril_rwlock_read_lock(&eth_globals.protos_lock);
    878                 int index;
    879                 for (index = 0; index < eth_protos_count(&eth_globals.protos); index++) {
    880                         eth_proto_t *proto = eth_protos_get_index(&eth_globals.protos, index);
    881                         if (proto->sess != NULL) {
    882                                 il_addr_changed_msg(proto->sess, device->device_id,
    883                                                 ETH_ADDR, address.address);
    884                         }
    885                 }
    886 
    887                 fibril_rwlock_read_unlock(&eth_globals.protos_lock);
    888                 return EOK;
    889         } else {
    890                 return ENOENT;
    891         }
     867
     868        printf("Device %d changing address from " PRIMAC " to " PRIMAC "\n",
     869                device->device_id, ARGSMAC(device->addr.address),
     870                ARGSMAC(address.address));
     871        memcpy(&device->addr, &address, sizeof (nic_address_t));
     872        fibril_rwlock_write_unlock(&eth_globals.devices_lock);
     873
     874        /* Notify all upper layer modules */
     875        fibril_rwlock_read_lock(&eth_globals.protos_lock);
     876        int index;
     877        for (index = 0; index < eth_protos_count(&eth_globals.protos); index++) {
     878                eth_proto_t *proto = eth_protos_get_index(&eth_globals.protos, index);
     879                if (proto->sess != NULL) {
     880                        il_addr_changed_msg(proto->sess, device->device_id,
     881                                        ETH_ADDR, address.address);
     882                }
     883        }
     884
     885        fibril_rwlock_read_unlock(&eth_globals.protos_lock);
     886        return EOK;
    892887}
    893888
     
    962957static void eth_nic_cb_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    963958{
     959        eth_device_t *device = (eth_device_t *)arg;
    964960        int rc;
    965961       
     
    975971                switch (IPC_GET_IMETHOD(call)) {
    976972                case NIC_EV_DEVICE_STATE:
    977                         rc = eth_device_state(IPC_GET_ARG1(call),
    978                             IPC_GET_ARG2(call));
     973                        rc = eth_device_state(device, IPC_GET_ARG1(call));
    979974                        async_answer_0(callid, (sysarg_t) rc);
    980975                        break;
    981976                case NIC_EV_RECEIVED:
    982                         rc = eth_received(IPC_GET_ARG1(call));
     977                        rc = eth_received(device);
    983978                        async_answer_0(callid, (sysarg_t) rc);
    984979                        break;
    985980                case NIC_EV_ADDR_CHANGED:
    986                         rc = eth_addr_changed(IPC_GET_ARG1(call));
     981                        rc = eth_addr_changed(device);
    987982                        async_answer_0(callid, (sysarg_t) rc);
    988983                        break;
  • uspace/srv/net/nil/nildummy/nildummy.c

    rea75ceb r8da2c60  
    7373    void *arg);
    7474
    75 static int nildummy_device_state(nic_device_id_t device_id, sysarg_t state)
     75static int nildummy_device_state(nildummy_device_t *device, sysarg_t state)
    7676{
    7777        fibril_rwlock_read_lock(&nildummy_globals.protos_lock);
    7878        if (nildummy_globals.proto.sess)
    79                 il_device_state_msg(nildummy_globals.proto.sess, device_id,
    80                     state, nildummy_globals.proto.service);
     79                il_device_state_msg(nildummy_globals.proto.sess,
     80                    device->device_id, state, nildummy_globals.proto.service);
    8181        fibril_rwlock_read_unlock(&nildummy_globals.protos_lock);
    8282       
     
    8484}
    8585
    86 static int nildummy_addr_changed(nic_device_id_t device_id)
     86static int nildummy_addr_changed(nildummy_device_t *device)
    8787{
    8888        return ENOTSUP;
     
    182182        }
    183183       
    184         int rc = nic_callback_create(device->sess, device_id,
    185             nildummy_nic_cb_conn, NULL);
     184        int rc = nic_callback_create(device->sess, nildummy_nic_cb_conn,
     185            device);
    186186        if (rc != EOK) {
    187187                async_hangup(device->sess);
     
    383383}
    384384
    385 static int nildummy_received(nic_device_id_t device_id)
     385static int nildummy_received(nildummy_device_t *device)
    386386{
    387387        void *data;
     
    401401        free(pdata);
    402402
    403         return nil_received_msg_local(device_id, packet);
     403        return nil_received_msg_local(device->device_id, packet);
    404404}
    405405
     
    465465static void nildummy_nic_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    466466{
     467        nildummy_device_t *device = (nildummy_device_t *)arg;
    467468        int rc;
    468469       
     
    478479                switch (IPC_GET_IMETHOD(call)) {
    479480                case NIC_EV_DEVICE_STATE:
    480                         rc = nildummy_device_state(IPC_GET_ARG1(call),
    481                             IPC_GET_ARG2(call));
     481                        rc = nildummy_device_state(device, IPC_GET_ARG1(call));
    482482                        async_answer_0(callid, (sysarg_t) rc);
    483483                        break;
    484484                case NIC_EV_RECEIVED:
    485                         rc = nildummy_received(IPC_GET_ARG1(call));
     485                        rc = nildummy_received(device);
    486486                        async_answer_0(callid, (sysarg_t) rc);
    487487                        break;
    488488                case NIC_EV_ADDR_CHANGED:
    489                         rc = nildummy_addr_changed(IPC_GET_ARG1(call));
     489                        rc = nildummy_addr_changed(device);
    490490                        async_answer_0(callid, (sysarg_t) rc);
    491491                        break;
Note: See TracChangeset for help on using the changeset viewer.