Changes in / [8da2c60:ea75ceb] in mainline
- Location:
- uspace
- Files:
-
- 15 edited
-
drv/nic/e1k/e1k.c (modified) (2 diffs)
-
lib/c/generic/device/nic.c (modified) (2 diffs)
-
lib/c/include/device/nic.h (modified) (1 diff)
-
lib/c/include/net/device.h (modified) (1 diff)
-
lib/c/include/nic/nic.h (modified) (2 diffs)
-
lib/drv/generic/remote_nic.c (modified) (1 diff)
-
lib/drv/include/ops/nic.h (modified) (1 diff)
-
lib/nic/include/nic_driver.h (modified) (1 diff)
-
lib/nic/include/nic_ev.h (modified) (1 diff)
-
lib/nic/include/nic_impl.h (modified) (1 diff)
-
lib/nic/src/nic_driver.c (modified) (4 diffs)
-
lib/nic/src/nic_ev.c (modified) (3 diffs)
-
lib/nic/src/nic_impl.c (modified) (4 diffs)
-
srv/net/nil/eth/eth.c (modified) (8 diffs)
-
srv/net/nil/nildummy/nildummy.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
r8da2c60 rea75ceb 2057 2057 case E1000_82545: 2058 2058 case E1000_82546: 2059 case E1000_82572: 2059 2060 e1000->info.eerd_start = 0x01; 2060 2061 e1000->info.eerd_done = 0x10; … … 2063 2064 break; 2064 2065 case E1000_82547: 2065 case E1000_82572:2066 2066 case E1000_80003ES2: 2067 2067 e1000->info.eerd_start = 0x01; -
uspace/lib/c/generic/device/nic.c
r8da2c60 rea75ceb 81 81 * 82 82 */ 83 int nic_callback_create(async_sess_t *dev_sess, async_client_conn_t cfun,84 void *carg)83 int nic_callback_create(async_sess_t *dev_sess, nic_device_id_t device_id, 84 async_client_conn_t cfun, void *carg) 85 85 { 86 86 ipc_call_t answer; … … 89 89 90 90 async_exch_t *exch = async_exchange_begin(dev_sess); 91 aid_t req = async_send_ 1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),92 NIC_CALLBACK_CREATE, &answer);91 aid_t req = async_send_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 92 NIC_CALLBACK_CREATE, device_id, &answer); 93 93 94 94 rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg); -
uspace/lib/c/include/device/nic.h
r8da2c60 rea75ceb 91 91 92 92 extern int nic_send_frame(async_sess_t *, void *, size_t); 93 extern int nic_callback_create(async_sess_t *, async_client_conn_t, void *); 93 extern int nic_callback_create(async_sess_t *, nic_device_id_t, 94 async_client_conn_t, void *); 94 95 extern int nic_get_state(async_sess_t *, nic_device_state_t *); 95 96 extern int nic_set_state(async_sess_t *, nic_device_state_t); -
uspace/lib/c/include/net/device.h
r8da2c60 rea75ceb 47 47 #define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT 48 48 49 /** Device identifier type. */50 typedef int nic_device_id_t;51 52 /** Invalid device identifier. */53 #define NIC_DEVICE_INVALID_ID (-1)54 55 49 #endif 56 50 -
uspace/lib/c/include/nic/nic.h
r8da2c60 rea75ceb 63 63 #define NIC_MAX_ADDRESS_LENGTH 16 64 64 65 /** Invalid device identifier. */ 66 #define NIC_DEVICE_INVALID_ID (-1) 67 65 68 #define NIC_VENDOR_MAX_LENGTH 64 66 69 #define NIC_MODEL_MAX_LENGTH 64 … … 83 86 84 87 #define NIC_DEVICE_PRINT_FMT "%x" 88 89 /** Device identifier type. */ 90 typedef int nic_device_id_t; 85 91 86 92 /** -
uspace/lib/drv/generic/remote_nic.c
r8da2c60 rea75ceb 69 69 assert(nic_iface->callback_create); 70 70 71 int rc = nic_iface->callback_create(dev); 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); 72 74 async_answer_0(callid, rc); 73 75 } -
uspace/lib/drv/include/ops/nic.h
r8da2c60 rea75ceb 46 46 /** Mandatory methods */ 47 47 int (*send_frame)(ddf_fun_t *, void *, size_t); 48 int (*callback_create)(ddf_fun_t * );48 int (*callback_create)(ddf_fun_t *, nic_device_id_t); 49 49 int (*get_state)(ddf_fun_t *, nic_device_state_t *); 50 50 int (*set_state)(ddf_fun_t *, nic_device_state_t); -
uspace/lib/nic/include/nic_driver.h
r8da2c60 rea75ceb 70 70 */ 71 71 ddf_fun_t *fun; 72 /** Identifier for higher network stack layers */ 73 nic_device_id_t device_id; 72 74 /** Current state of the device */ 73 75 nic_device_state_t state; -
uspace/lib/nic/include/nic_ev.h
r8da2c60 rea75ceb 43 43 #include <sys/types.h> 44 44 45 extern int nic_ev_addr_changed(async_sess_t *, const nic_address_t *); 46 extern int nic_ev_device_state(async_sess_t *, sysarg_t); 47 extern int nic_ev_received(async_sess_t *, void *, size_t); 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); 48 49 49 50 #endif -
uspace/lib/nic/include/nic_impl.h
r8da2c60 rea75ceb 48 48 extern int nic_get_address_impl(ddf_fun_t *dev_fun, nic_address_t *address); 49 49 extern 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 );50 extern int nic_callback_create_impl(ddf_fun_t *dev_fun, int device_id); 51 51 extern int nic_get_state_impl(ddf_fun_t *dev_fun, nic_device_state_t *state); 52 52 extern int nic_set_state_impl(ddf_fun_t *dev_fun, nic_device_state_t state); -
uspace/lib/nic/src/nic_driver.c
r8da2c60 rea75ceb 497 497 if (nic_data->client_session != NULL) { 498 498 int rc = nic_ev_addr_changed(nic_data->client_session, 499 address);499 nic_data->device_id, address); 500 500 if (rc != EOK) { 501 501 fibril_rwlock_write_unlock(&nic_data->main_lock); … … 604 604 } 605 605 fibril_rwlock_write_unlock(&nic_data->stats_lock); 606 nic_ev_received(nic_data->client_session, frame->data,607 frame-> size);606 nic_ev_received(nic_data->client_session, nic_data->device_id, 607 frame->data, frame->size); 608 608 } else { 609 609 switch (frame_type) { … … 639 639 fibril_rwlock_write_unlock(&nic_data->stats_lock); 640 640 641 nic_ev_received(nic_data->client_session, data, size); 641 nic_ev_received(nic_data->client_session, nic_data->device_id, 642 data, size); 642 643 } 643 644 … … 690 691 nic_data->dev = NULL; 691 692 nic_data->fun = NULL; 693 nic_data->device_id = NIC_DEVICE_INVALID_ID; 692 694 nic_data->state = NIC_STATE_STOPPED; 693 695 nic_data->client_session = NULL; -
uspace/lib/nic/src/nic_ev.c
r8da2c60 rea75ceb 42 42 43 43 /** Device address changed. */ 44 int nic_ev_addr_changed(async_sess_t *sess, const nic_address_t *addr) 44 int nic_ev_addr_changed(async_sess_t *sess, nic_device_id_t dev_id, 45 const nic_address_t *addr) 45 46 { 46 47 async_exch_t *exch = async_exchange_begin(sess); 47 48 48 49 ipc_call_t answer; 49 aid_t req = async_send_0(exch, NIC_EV_ADDR_CHANGED, &answer); 50 aid_t req = async_send_1(exch, NIC_EV_ADDR_CHANGED, (sysarg_t) dev_id, 51 &answer); 50 52 sysarg_t retval = async_data_write_start(exch, addr, 51 53 sizeof(nic_address_t)); … … 63 65 64 66 /** Device state changed. */ 65 extern int nic_ev_device_state(async_sess_t *sess, sysarg_t state) 67 extern int nic_ev_device_state(async_sess_t *sess, nic_device_id_t dev_id, 68 sysarg_t state) 66 69 { 67 70 int rc; 68 71 69 72 async_exch_t *exch = async_exchange_begin(sess); 70 rc = async_req_ 1_0(exch, NIC_EV_DEVICE_STATE, state);73 rc = async_req_2_0(exch, NIC_EV_DEVICE_STATE, dev_id, state); 71 74 async_exchange_end(exch); 72 75 … … 75 78 76 79 /** Frame received. */ 77 int nic_ev_received(async_sess_t *sess, void *data, size_t size) 80 int nic_ev_received(async_sess_t *sess, nic_device_id_t dev_id, void *data, 81 size_t size) 78 82 { 79 83 async_exch_t *exch = async_exchange_begin(sess); 80 84 81 85 ipc_call_t answer; 82 aid_t req = async_send_0(exch, NIC_EV_RECEIVED, &answer); 86 aid_t req = async_send_1(exch, NIC_EV_RECEIVED, (sysarg_t) dev_id, 87 &answer); 83 88 sysarg_t retval = async_data_write_start(exch, data, size); 84 89 -
uspace/lib/nic/src/nic_impl.c
r8da2c60 rea75ceb 87 87 } 88 88 if (state == NIC_STATE_ACTIVE) { 89 if (nic_data->client_session == NULL ) {89 if (nic_data->client_session == NULL || nic_data->device_id < 0) { 90 90 fibril_rwlock_write_unlock(&nic_data->main_lock); 91 91 return EINVAL; … … 118 118 /* Notify upper layers that we are reseting the MAC */ 119 119 int rc = nic_ev_addr_changed(nic_data->client_session, 120 &nic_data->default_mac);120 nic_data->device_id, &nic_data->default_mac); 121 121 nic_data->poll_mode = nic_data->default_poll_mode; 122 122 memcpy(&nic_data->poll_period, &nic_data->default_poll_period, … … 150 150 nic_data->state = state; 151 151 152 nic_ev_device_state(nic_data->client_session, state);152 nic_ev_device_state(nic_data->client_session, nic_data->device_id, state); 153 153 154 154 fibril_rwlock_write_unlock(&nic_data->main_lock); … … 187 187 * 188 188 * @param fun 189 * @param device_id ID of the device as used in higher layers 189 190 * 190 191 * @return EOK On success, or negative error code. 191 192 */ 192 int nic_callback_create_impl(ddf_fun_t *fun )193 int nic_callback_create_impl(ddf_fun_t *fun, nic_device_id_t device_id) 193 194 { 194 195 nic_t *nic = (nic_t *) fun->driver_data; 195 196 fibril_rwlock_write_lock(&nic->main_lock); 197 198 nic->device_id = device_id; 196 199 197 200 nic->client_session = async_callback_receive(EXCHANGE_SERIALIZE); -
uspace/srv/net/nil/eth/eth.c
r8da2c60 rea75ceb 173 173 void *arg); 174 174 175 static int eth_device_state( eth_device_t *device, sysarg_t state)175 static int eth_device_state(nic_device_id_t device_id, sysarg_t state) 176 176 { 177 177 int index; … … 183 183 proto = eth_protos_get_index(ð_globals.protos, index); 184 184 if ((proto) && (proto->sess)) { 185 il_device_state_msg(proto->sess, device ->device_id,186 state,proto->service);185 il_device_state_msg(proto->sess, device_id, state, 186 proto->service); 187 187 } 188 188 } … … 347 347 } 348 348 349 rc = nic_callback_create(device->sess, eth_nic_cb_connection, device); 349 rc = nic_callback_create(device->sess, device_id, 350 eth_nic_cb_connection, NULL); 350 351 if (rc != EOK) { 351 352 fibril_rwlock_write_unlock(ð_globals.devices_lock); … … 824 825 } 825 826 826 static int eth_received( eth_device_t *device)827 static int eth_received(nic_device_id_t device_id) 827 828 { 828 829 void *data; … … 844 845 free(data); 845 846 846 return nil_received_msg_local(device ->device_id, packet);847 } 848 849 static int eth_addr_changed( eth_device_t *device)847 return nil_received_msg_local(device_id, packet); 848 } 849 850 static int eth_addr_changed(nic_device_id_t device_id) 850 851 { 851 852 nic_address_t address; … … 865 866 866 867 fibril_rwlock_write_lock(ð_globals.devices_lock); 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(ð_globals.devices_lock); 873 874 /* Notify all upper layer modules */ 875 fibril_rwlock_read_lock(ð_globals.protos_lock); 876 int index; 877 for (index = 0; index < eth_protos_count(ð_globals.protos); index++) { 878 eth_proto_t *proto = eth_protos_get_index(ð_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(ð_globals.protos_lock); 886 return EOK; 868 /* An existing device? */ 869 eth_device_t *device = eth_devices_find(ð_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(ð_globals.devices_lock); 875 876 /* Notify all upper layer modules */ 877 fibril_rwlock_read_lock(ð_globals.protos_lock); 878 int index; 879 for (index = 0; index < eth_protos_count(ð_globals.protos); index++) { 880 eth_proto_t *proto = eth_protos_get_index(ð_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(ð_globals.protos_lock); 888 return EOK; 889 } else { 890 return ENOENT; 891 } 887 892 } 888 893 … … 957 962 static void eth_nic_cb_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 958 963 { 959 eth_device_t *device = (eth_device_t *)arg;960 964 int rc; 961 965 … … 971 975 switch (IPC_GET_IMETHOD(call)) { 972 976 case NIC_EV_DEVICE_STATE: 973 rc = eth_device_state(device, IPC_GET_ARG1(call)); 977 rc = eth_device_state(IPC_GET_ARG1(call), 978 IPC_GET_ARG2(call)); 974 979 async_answer_0(callid, (sysarg_t) rc); 975 980 break; 976 981 case NIC_EV_RECEIVED: 977 rc = eth_received( device);982 rc = eth_received(IPC_GET_ARG1(call)); 978 983 async_answer_0(callid, (sysarg_t) rc); 979 984 break; 980 985 case NIC_EV_ADDR_CHANGED: 981 rc = eth_addr_changed( device);986 rc = eth_addr_changed(IPC_GET_ARG1(call)); 982 987 async_answer_0(callid, (sysarg_t) rc); 983 988 break; -
uspace/srv/net/nil/nildummy/nildummy.c
r8da2c60 rea75ceb 73 73 void *arg); 74 74 75 static int nildummy_device_state(ni ldummy_device_t *device, sysarg_t state)75 static int nildummy_device_state(nic_device_id_t device_id, sysarg_t state) 76 76 { 77 77 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 78 78 if (nildummy_globals.proto.sess) 79 il_device_state_msg(nildummy_globals.proto.sess, 80 device->device_id,state, nildummy_globals.proto.service);79 il_device_state_msg(nildummy_globals.proto.sess, device_id, 80 state, nildummy_globals.proto.service); 81 81 fibril_rwlock_read_unlock(&nildummy_globals.protos_lock); 82 82 … … 84 84 } 85 85 86 static int nildummy_addr_changed(ni ldummy_device_t *device)86 static int nildummy_addr_changed(nic_device_id_t device_id) 87 87 { 88 88 return ENOTSUP; … … 182 182 } 183 183 184 int rc = nic_callback_create(device->sess, nildummy_nic_cb_conn,185 device);184 int rc = nic_callback_create(device->sess, device_id, 185 nildummy_nic_cb_conn, NULL); 186 186 if (rc != EOK) { 187 187 async_hangup(device->sess); … … 383 383 } 384 384 385 static int nildummy_received(ni ldummy_device_t *device)385 static int nildummy_received(nic_device_id_t device_id) 386 386 { 387 387 void *data; … … 401 401 free(pdata); 402 402 403 return nil_received_msg_local(device ->device_id, packet);403 return nil_received_msg_local(device_id, packet); 404 404 } 405 405 … … 465 465 static void nildummy_nic_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 466 466 { 467 nildummy_device_t *device = (nildummy_device_t *)arg;468 467 int rc; 469 468 … … 479 478 switch (IPC_GET_IMETHOD(call)) { 480 479 case NIC_EV_DEVICE_STATE: 481 rc = nildummy_device_state(device, IPC_GET_ARG1(call)); 480 rc = nildummy_device_state(IPC_GET_ARG1(call), 481 IPC_GET_ARG2(call)); 482 482 async_answer_0(callid, (sysarg_t) rc); 483 483 break; 484 484 case NIC_EV_RECEIVED: 485 rc = nildummy_received( device);485 rc = nildummy_received(IPC_GET_ARG1(call)); 486 486 async_answer_0(callid, (sysarg_t) rc); 487 487 break; 488 488 case NIC_EV_ADDR_CHANGED: 489 rc = nildummy_addr_changed( device);489 rc = nildummy_addr_changed(IPC_GET_ARG1(call)); 490 490 async_answer_0(callid, (sysarg_t) rc); 491 491 break;
Note:
See TracChangeset
for help on using the changeset viewer.
