Changeset 00d7e1b in mainline for uspace/lib
- Timestamp:
- 2011-10-07T20:20:33Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 49bd793b
- Parents:
- e2c50e1
- Location:
- uspace/lib
- Files:
-
- 14 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
re2c50e1 r00d7e1b 67 67 generic/devman.c \ 68 68 generic/device/hw_res.c \ 69 generic/device/hw_res_parsed.c \ 69 70 generic/device/char_dev.c \ 70 71 generic/device/nic.c \ … … 104 105 generic/adt/list.c \ 105 106 generic/adt/hash_table.c \ 107 generic/adt/hash_set.c \ 106 108 generic/adt/dynamic_fifo.c \ 107 109 generic/adt/measured_strings.c \ -
uspace/lib/c/generic/device/nic.c
re2c50e1 r00d7e1b 137 137 138 138 async_exch_t *exch = async_exchange_begin(dev_sess); 139 140 int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), NIC_GET_ADDRESS);141 i f (rc != EOK) {142 143 return rc;144 }145 146 rc = async_data_read_start(exch, address, sizeof(nic_address_t));147 148 async_exchange_end(exch);149 150 return rc;139 aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 140 NIC_GET_ADDRESS, NULL); 141 int rc = async_data_read_start(exch, address, sizeof(nic_address_t)); 142 async_exchange_end(exch); 143 144 sysarg_t res; 145 async_wait_for(aid, &res); 146 147 if (rc != EOK) 148 return rc; 149 150 return (int) res; 151 151 } 152 152 … … 164 164 165 165 async_exch_t *exch = async_exchange_begin(dev_sess); 166 aid_t message_id = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),166 aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 167 167 NIC_SET_ADDRESS, NULL); 168 168 int rc = async_data_write_start(exch, address, sizeof(nic_address_t)); … … 170 170 171 171 sysarg_t res; 172 async_wait_for( message_id, &res);172 async_wait_for(aid, &res); 173 173 174 174 if (rc != EOK) -
uspace/lib/c/include/net/device.h
re2c50e1 r00d7e1b 41 41 #include <adt/int_map.h> 42 42 #include <net/eth_phys.h> 43 #include <bool.h> 43 44 44 45 /** Ethernet address length. */ … … 51 52 #define ARGSMAC(__a) \ 52 53 (__a)[0], (__a)[1], (__a)[2], (__a)[3], (__a)[4], (__a)[5] 54 55 /* Compare MAC address with specific value */ 56 #define MAC_EQUALS_VALUE(__a, __a0, __a1, __a2, __a3, __a4, __a5) \ 57 ((__a)[0] == (__a0) && (__a)[1] == (__a1) && (__a)[2] == (__a2) \ 58 && (__a)[3] == (__a3) && (__a)[4] == (__a4) && (__a)[5] == (__a5)) 59 60 #define MAC_IS_ZERO(__x) \ 61 MAC_EQUALS_VALUE(__x, 0, 0, 0, 0, 0, 0) 53 62 54 63 /** Device identifier to generic type map declaration. */ … … 221 230 } nic_device_stats_t; 222 231 232 /** Errors corresponding to those in the nic_device_stats_t */ 233 typedef enum { 234 NIC_SEC_BUFFER_FULL, 235 NIC_SEC_ABORTED, 236 NIC_SEC_CARRIER_LOST, 237 NIC_SEC_FIFO_OVERRUN, 238 NIC_SEC_HEARTBEAT, 239 NIC_SEC_WINDOW_ERROR, 240 /* Error encountered during TX but with other type of error */ 241 NIC_SEC_OTHER 242 } nic_send_error_cause_t; 243 244 /** Errors corresponding to those in the nic_device_stats_t */ 245 typedef enum { 246 NIC_REC_BUFFER_FULL, 247 NIC_REC_LENGTH, 248 NIC_REC_BUFFER_OVERFLOW, 249 NIC_REC_CRC, 250 NIC_REC_FRAME_ALIGNMENT, 251 NIC_REC_FIFO_OVERRUN, 252 NIC_REC_MISSED, 253 /* Error encountered during RX but with other type of error */ 254 NIC_REC_OTHER 255 } nic_receive_error_cause_t; 256 223 257 /** 224 258 * Information about the NIC that never changes - name, vendor, model, … … 246 280 247 281 /** 282 * Type of the ethernet frame 283 */ 284 typedef enum nic_frame_type { 285 NIC_FRAME_UNICAST, 286 NIC_FRAME_MULTICAST, 287 NIC_FRAME_BROADCAST 288 } nic_frame_type_t; 289 290 /** 248 291 * Specifies which unicast frames is the NIC receiving. 249 292 */ … … 292 335 293 336 /** 337 * Structure passed as argument for virtue NIC_WV_MAGIC_PACKET. 338 */ 339 typedef struct nic_wv_magic_packet_data { 340 uint8_t password[6]; 341 } nic_wv_magic_packet_data_t; 342 343 /** 344 * Structure passed as argument for virtue NIC_WV_DIRECTED_IPV4 345 */ 346 typedef struct nic_wv_ipv4_data { 347 uint8_t address[4]; 348 } nic_wv_ipv4_data_t; 349 350 /** 351 * Structure passed as argument for virtue NIC_WV_DIRECTED_IPV6 352 */ 353 typedef struct nic_wv_ipv6_data { 354 uint8_t address[16]; 355 } nic_wv_ipv6_data_t; 356 357 /** 294 358 * WOL virtue types defining the interpretation of data passed to the virtue. 295 359 * Those tagged with S can have only single virtue active at one moment, those … … 376 440 NIC_POLL_SOFTWARE_PERIODIC 377 441 } nic_poll_mode_t; 442 443 /** 444 * Says if this virtue type is a multi-virtue (there can be multiple virtues of 445 * this type at once). 446 * 447 * @param type 448 * 449 * @return true or false 450 */ 451 static inline int nic_wv_is_multi(nic_wv_type_t type) { 452 switch (type) { 453 case NIC_WV_FULL_MATCH: 454 case NIC_WV_DESTINATION: 455 case NIC_WV_DIRECTED_IPV4: 456 case NIC_WV_DIRECTED_IPV6: 457 return true; 458 default: 459 return false; 460 } 461 } 378 462 379 463 static inline const char *nic_device_state_to_string(nic_device_state_t state) -
uspace/lib/net/generic/generic.c
re2c50e1 r00d7e1b 79 79 { 80 80 async_exch_t *exch = async_exchange_begin(sess); 81 int rc = async_req_ 2_0(exch, message, (sysarg_t) device_id,81 int rc = async_req_3_0(exch, message, (sysarg_t) device_id, 0, 82 82 (sysarg_t) service); 83 83 async_exchange_end(exch); -
uspace/lib/net/generic/net_checksum.c
re2c50e1 r00d7e1b 45 45 #define CRC_DIVIDER_LE 0xedb88320 46 46 47 /** Polynomial used in multicast address hashing */ 48 #define CRC_MCAST_POLYNOMIAL 0x04c11db6 49 47 50 /** Compacts the computed checksum to the 16 bit number adding the carries. 48 51 * … … 221 224 } 222 225 226 /** Compute the standard hash from MAC 227 * 228 * Hashing MAC into 64 possible values and using the value as index to 229 * 64bit number. 230 * 231 * The code is copied from qemu-0.13's implementation of ne2000 and rt8139 232 * drivers, but according to documentation there it originates in FreeBSD. 233 * 234 * @param[in] addr The 6-byte MAC address to be hashed 235 * 236 * @return 64-bit number with only single bit set to 1 237 * 238 */ 239 uint64_t multicast_hash(const uint8_t addr[6]) 240 { 241 uint32_t crc; 242 int carry, i, j; 243 uint8_t b; 244 245 crc = 0xffffffff; 246 for (i = 0; i < 6; i++) { 247 b = addr[i]; 248 for (j = 0; j < 8; j++) { 249 carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01); 250 crc <<= 1; 251 b >>= 1; 252 if (carry) 253 crc = ((crc ^ CRC_MCAST_POLYNOMIAL) | carry); 254 } 255 } 256 257 uint64_t one64 = 1; 258 return one64 << (crc >> 26); 259 } 260 223 261 /** @} 224 262 */ -
uspace/lib/net/il/ip_remote.c
re2c50e1 r00d7e1b 123 123 * 124 124 */ 125 int ip_device_req _remote(async_sess_t *sess, nic_device_id_t device_id,125 int ip_device_req(async_sess_t *sess, nic_device_id_t device_id, 126 126 services_t service) 127 127 { -
uspace/lib/net/include/ip_interface.h
re2c50e1 r00d7e1b 46 46 #define ip_set_gateway_req ip_set_gateway_req_remote 47 47 #define ip_packet_size_req ip_packet_size_req_remote 48 #define ip_device_req ip_device_req_remote49 48 #define ip_add_route_req ip_add_route_req_remote 50 49 #define ip_send_msg ip_send_msg_remote -
uspace/lib/net/include/ip_remote.h
re2c50e1 r00d7e1b 48 48 extern int ip_received_error_msg_remote(async_sess_t *, nic_device_id_t, packet_t *, 49 49 services_t, services_t); 50 extern int ip_device_req _remote(async_sess_t *, nic_device_id_t, services_t);50 extern int ip_device_req(async_sess_t *, nic_device_id_t, services_t); 51 51 extern int ip_add_route_req_remote(async_sess_t *, nic_device_id_t, in_addr_t, 52 52 in_addr_t, in_addr_t); -
uspace/lib/net/include/net_checksum.h
re2c50e1 r00d7e1b 67 67 extern uint16_t flip_checksum(uint16_t); 68 68 extern uint16_t ip_checksum(uint8_t *, size_t); 69 extern uint64_t multicast_hash(const uint8_t addr[6]); 69 70 70 71 #endif -
uspace/lib/net/tl/tl_skel.c
re2c50e1 r00d7e1b 123 123 goto out; 124 124 125 task_retval(0); 125 126 async_manager(); 126 127
Note:
See TracChangeset
for help on using the changeset viewer.