Changeset c62a8275 in mainline
- Timestamp:
- 2014-09-01T11:17:23Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a4666a9
- Parents:
- f93ba6d (diff), 320bd52 (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. - Location:
- uspace
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nic/nic.c
rf93ba6d rc62a8275 49 49 nic_cable_state_t link_state; 50 50 nic_channel_mode_t duplex; 51 nic_unicast_mode_t unicast_mode; 52 nic_multicast_mode_t multicast_mode; 53 nic_broadcast_mode_t broadcast_mode; 51 54 int speed; 52 55 } nic_info_t; … … 62 65 printf("\tduplex <half|full|simplex> - set duplex mode\n"); 63 66 printf("\tauto - enable autonegotiation\n"); 67 printf("\tunicast <block|default|list|promisc> - set unicast receive filtering\n"); 68 printf("\tmulticast <block|list|promisc> - set multicast receive filtering\n"); 69 printf("\tbroadcast <block|allow> - block or allow incoming broadcast frames\n"); 64 70 } 65 71 … … 145 151 } 146 152 153 rc = nic_unicast_get_mode(sess, &info->unicast_mode, 0, NULL, NULL); 154 if (rc != EOK) { 155 printf("Error gettinc NIC unicast receive mode.\n"); 156 rc = EIO; 157 goto error; 158 } 159 160 rc = nic_multicast_get_mode(sess, &info->multicast_mode, 0, NULL, NULL); 161 if (rc != EOK) { 162 printf("Error gettinc NIC multicast receive mode.\n"); 163 rc = EIO; 164 goto error; 165 } 166 167 rc = nic_broadcast_get_mode(sess, &info->broadcast_mode); 168 if (rc != EOK) { 169 printf("Error gettinc NIC broadcast receive mode.\n"); 170 rc = EIO; 171 goto error; 172 } 147 173 148 174 return EOK; … … 167 193 case NIC_CM_HALF_DUPLEX: return "half-duplex"; 168 194 case NIC_CM_SIMPLEX: return "simplex"; 195 default: assert(false); return NULL; 196 } 197 } 198 199 static const char *nic_unicast_mode_str(nic_unicast_mode_t mode) 200 { 201 switch (mode) { 202 case NIC_UNICAST_UNKNOWN: return "unknown"; 203 case NIC_UNICAST_BLOCKED: return "blocked"; 204 case NIC_UNICAST_DEFAULT: return "default"; 205 case NIC_UNICAST_LIST: return "list"; 206 case NIC_UNICAST_PROMISC: return "promisc"; 207 default: assert(false); return NULL; 208 } 209 } 210 211 static const char *nic_multicast_mode_str(nic_unicast_mode_t mode) 212 { 213 switch (mode) { 214 case NIC_MULTICAST_UNKNOWN: return "unknown"; 215 case NIC_MULTICAST_BLOCKED: return "blocked"; 216 case NIC_MULTICAST_LIST: return "list"; 217 case NIC_MULTICAST_PROMISC: return "promisc"; 218 default: assert(false); return NULL; 219 } 220 } 221 222 static const char *nic_broadcast_mode_str(nic_unicast_mode_t mode) 223 { 224 switch (mode) { 225 case NIC_BROADCAST_UNKNOWN: return "unknown"; 226 case NIC_BROADCAST_BLOCKED: return "blocked"; 227 case NIC_BROADCAST_ACCEPTED: return "accepted"; 169 228 default: assert(false); return NULL; 170 229 } … … 234 293 printf("\tLink state: %s\n", 235 294 nic_link_state_str(nic_info.link_state)); 295 printf("\tUnicast receive mode: %s\n", 296 nic_unicast_mode_str(nic_info.unicast_mode)); 297 printf("\tMulticast receive mode: %s\n", 298 nic_multicast_mode_str(nic_info.multicast_mode)); 299 printf("\tBroadcast receive mode: %s\n", 300 nic_broadcast_mode_str(nic_info.broadcast_mode)); 236 301 237 302 if (nic_info.link_state == NIC_CS_PLUGGED) { … … 369 434 370 435 return nic_set_address(sess, &addr); 436 } 437 438 static int nic_set_rx_unicast(int i, char *str) 439 { 440 async_sess_t *sess; 441 442 sess = get_nic_by_index(i); 443 if (sess == NULL) { 444 printf("Specified NIC doesn't exist or cannot connect to it.\n"); 445 return EINVAL; 446 } 447 448 if (!str_cmp(str, "block")) { 449 nic_unicast_set_mode(sess, NIC_UNICAST_BLOCKED, NULL, 0); 450 return EOK; 451 } 452 453 if (!str_cmp(str, "default")) { 454 nic_unicast_set_mode(sess, NIC_UNICAST_DEFAULT, NULL, 0); 455 return EOK; 456 } 457 458 if (!str_cmp(str, "list")) { 459 nic_unicast_set_mode(sess, NIC_UNICAST_LIST, NULL, 0); 460 return EOK; 461 } 462 463 if (!str_cmp(str, "promisc")) { 464 nic_unicast_set_mode(sess, NIC_UNICAST_PROMISC, NULL, 0); 465 return EOK; 466 } 467 468 469 printf("Invalid pameter - should be one of: block, default, promisc\n"); 470 return EINVAL; 471 } 472 473 static int nic_set_rx_multicast(int i, char *str) 474 { 475 async_sess_t *sess; 476 477 sess = get_nic_by_index(i); 478 if (sess == NULL) { 479 printf("Specified NIC doesn't exist or cannot connect to it.\n"); 480 return EINVAL; 481 } 482 483 if (!str_cmp(str, "block")) { 484 nic_multicast_set_mode(sess, NIC_MULTICAST_BLOCKED, NULL, 0); 485 return EOK; 486 } 487 488 if (!str_cmp(str, "list")) { 489 nic_multicast_set_mode(sess, NIC_MULTICAST_LIST, NULL, 0); 490 return EOK; 491 } 492 493 if (!str_cmp(str, "promisc")) { 494 nic_multicast_set_mode(sess, NIC_MULTICAST_PROMISC, NULL, 0); 495 return EOK; 496 } 497 498 printf("Invalid pameter - should be one of: block, promisc\n"); 499 return EINVAL; 500 } 501 502 static int nic_set_rx_broadcast(int i, char *str) 503 { 504 async_sess_t *sess; 505 506 sess = get_nic_by_index(i); 507 if (sess == NULL) { 508 printf("Specified NIC doesn't exist or cannot connect to it.\n"); 509 return EINVAL; 510 } 511 512 if (!str_cmp(str, "block")) { 513 nic_broadcast_set_mode(sess, NIC_BROADCAST_BLOCKED); 514 return EOK; 515 } 516 517 if (!str_cmp(str, "accept")) { 518 nic_broadcast_set_mode(sess, NIC_BROADCAST_ACCEPTED); 519 return EOK; 520 } 521 522 printf("Invalid pameter - should be 'block' or 'accept'\n"); 523 return EINVAL; 371 524 } 372 525 … … 400 553 return nic_set_autoneg(index); 401 554 555 if (!str_cmp(argv[2], "unicast")) 556 return nic_set_rx_unicast(index, argv[3]); 557 558 if (!str_cmp(argv[2], "multicast")) 559 return nic_set_rx_multicast(index, argv[3]); 560 561 if (!str_cmp(argv[2], "broadcast")) 562 return nic_set_rx_broadcast(index, argv[3]); 563 402 564 } else { 403 565 printf(NAME ": Invalid argument.\n"); -
uspace/drv/nic/rtl8169/driver.c
rf93ba6d rc62a8275 27 27 */ 28 28 29 #define _DDF_DATA_IMPLANT30 31 29 #include <assert.h> 32 30 #include <errno.h> … … 330 328 } 331 329 330 static void rtl8169_dev_cleanup(ddf_dev_t *dev) 331 { 332 assert(dev); 333 334 if (ddf_dev_data_get(dev)) 335 nic_unbind_and_destroy(dev); 336 } 337 332 338 static int rtl8169_dev_initialize(ddf_dev_t *dev) 333 339 { … … 351 357 failed: 352 358 ddf_msg(LVL_ERROR, "The device initialization failed"); 353 // rtl8139_dev_cleanup(dev);359 rtl8169_dev_cleanup(dev); 354 360 return ret; 355 361 … … 439 445 nic_set_ddf_fun(nic_data, fun); 440 446 ddf_fun_set_ops(fun, &rtl8169_dev_ops); 441 // ddf_fun_data_implant(fun, nic_data);442 447 443 448 rc = ddf_fun_bind(fun); … … 467 472 err_pio: 468 473 err_destroy: 469 //rtl8169_dev_cleanup(dev);474 rtl8169_dev_cleanup(dev); 470 475 return rc; 471 476 … … 733 738 /* Configure Receive Control Register */ 734 739 uint32_t rcr = pio_read_32(rtl8169->regs + RCR); 735 rcr |= RCR_ACCEPT_ALL_PHYS | RCR_ACCEPT_PHYS_MATCH \ 736 | RCR_ACCEPT_BROADCAST | RCR_ACCEPT_ERROR \ 737 | RCR_ACCEPT_RUNT; 740 rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH; 741 rcr |= RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ERROR | RCR_ACCEPT_RUNT; 738 742 pio_write_32(rtl8169->regs + RCR, rcr); 739 743 pio_write_16(rtl8169->regs + RMS, BUFFER_SIZE); 740 741 ddf_msg(LVL_NOTE, "RCR: 0x%08x", pio_read_32(rtl8169->regs + RCR));742 743 744 744 745 pio_write_16(rtl8169->regs + IMR, 0xffff); … … 793 794 } 794 795 796 /** Notify NIC framework about HW filtering state when promisc mode was disabled 797 * 798 * @param nic_data The NIC data 799 * @param mcast_mode Current multicast mode 800 * @param was_promisc Sign if the promiscuous mode was active before disabling 801 */ 802 inline static void rtl8169_rcx_promics_rem(nic_t *nic_data, 803 nic_multicast_mode_t mcast_mode, uint8_t was_promisc) 804 { 805 assert(nic_data); 806 807 if (was_promisc != 0) { 808 if (mcast_mode == NIC_MULTICAST_LIST) 809 nic_report_hw_filtering(nic_data, 1, 0, -1); 810 else 811 nic_report_hw_filtering(nic_data, 1, 1, -1); 812 } else { 813 nic_report_hw_filtering(nic_data, 1, -1, -1); 814 } 815 } 816 795 817 static int rtl8169_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode, 796 818 const nic_address_t *addr, size_t addr_count) 797 819 { 820 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 821 uint32_t rcr = pio_read_32(rtl8169->regs + RCR); 822 uint8_t was_promisc = rcr & RCR_ACCEPT_ALL_PHYS; 823 nic_multicast_mode_t mcast_mode; 824 825 nic_query_multicast(nic_data, &mcast_mode, 0, NULL, NULL); 826 827 ddf_msg(LVL_DEBUG, "Unicast RX filter mode: %d", mode); 828 829 830 switch (mode) { 831 case NIC_UNICAST_BLOCKED: 832 rtl8169->rcr_ucast = 0; 833 rtl8169_rcx_promics_rem(nic_data, mcast_mode, was_promisc); 834 break; 835 case NIC_UNICAST_DEFAULT: 836 rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH; 837 rtl8169_rcx_promics_rem(nic_data, mcast_mode, was_promisc); 838 break; 839 case NIC_UNICAST_LIST: 840 rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS; 841 842 if (mcast_mode == NIC_MULTICAST_PROMISC) 843 nic_report_hw_filtering(nic_data, 0, 1, -1); 844 else 845 nic_report_hw_filtering(nic_data, 0, 0, -1); 846 break; 847 case NIC_UNICAST_PROMISC: 848 rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS; 849 850 if (mcast_mode == NIC_MULTICAST_PROMISC) 851 nic_report_hw_filtering(nic_data, 1, 1, -1); 852 else 853 nic_report_hw_filtering(nic_data, 1, 0, -1); 854 break; 855 default: 856 return ENOTSUP; 857 } 858 859 fibril_mutex_lock(&rtl8169->rx_lock); 860 861 rcr &= ~(RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS); 862 pio_write_32(rtl8169->regs + RCR, rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast); 863 ddf_msg(LVL_DEBUG, "new RCR value: 0x%08x", rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast); 864 865 fibril_mutex_unlock(&rtl8169->rx_lock); 798 866 return EOK; 799 867 } … … 802 870 const nic_address_t *addr, size_t addr_count) 803 871 { 872 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 873 uint32_t rcr = pio_read_32(rtl8169->regs + RCR); 874 uint64_t mask; 875 876 ddf_msg(LVL_DEBUG, "Multicast RX filter mode: %d", mode); 877 878 switch (mode) { 879 case NIC_MULTICAST_BLOCKED: 880 rtl8169->rcr_mcast = 0; 881 if ((rtl8169->rcr_ucast & RCR_ACCEPT_ALL_PHYS) != 0) 882 nic_report_hw_filtering(nic_data, -1, 0, -1); 883 else 884 nic_report_hw_filtering(nic_data, -1, 1, -1); 885 break; 886 case NIC_MULTICAST_LIST: 887 mask = nic_mcast_hash(addr, addr_count); 888 pio_write_32(rtl8169->regs + MAR0, (uint32_t)mask); 889 pio_write_32(rtl8169->regs + MAR0 + 4, (uint32_t)(mask >> 32)); 890 rtl8169->rcr_mcast = RCR_ACCEPT_MULTICAST; 891 nic_report_hw_filtering(nic_data, -1, 0, -1); 892 break; 893 case NIC_MULTICAST_PROMISC: 894 pio_write_32(rtl8169->regs + MAR0, 0xffffffffULL); 895 pio_write_32(rtl8169->regs + MAR0 + 4, (uint32_t)(0xffffffffULL >> 32)); 896 rtl8169->rcr_mcast = RCR_ACCEPT_MULTICAST; 897 nic_report_hw_filtering(nic_data, -1, 1, -1); 898 break; 899 default: 900 return ENOTSUP; 901 } 902 903 fibril_mutex_lock(&rtl8169->rx_lock); 904 905 rcr &= ~(RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS); 906 pio_write_32(rtl8169->regs + RCR, rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast); 907 ddf_msg(LVL_DEBUG, "new RCR value: 0x%08x", rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast); 908 909 fibril_mutex_unlock(&rtl8169->rx_lock); 804 910 return EOK; 805 911 } … … 807 913 static int rtl8169_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode) 808 914 { 915 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 916 917 /* Configure Receive Control Register */ 918 uint32_t rcr = pio_read_32(rtl8169->regs + RCR); 919 920 ddf_msg(LVL_DEBUG, "Broadcast RX filter mode: %d", mode); 921 922 switch (mode) { 923 case NIC_BROADCAST_BLOCKED: 924 rcr &= RCR_ACCEPT_BROADCAST; 925 break; 926 case NIC_BROADCAST_ACCEPTED: 927 rcr |= RCR_ACCEPT_BROADCAST; 928 break; 929 default: 930 return ENOTSUP; 931 } 932 933 pio_write_32(rtl8169->regs + RCR, rcr); 934 ddf_msg(LVL_DEBUG," new RCR value: 0x%08x", rcr); 935 809 936 return EOK; 810 937 } … … 816 943 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 817 944 rtl8169_descr_t *descr; 818 819 ddf_msg(LVL_NOTE, "rtl8169_transmit_done()"); 945 int sent = 0; 946 947 ddf_msg(LVL_DEBUG, "rtl8169_transmit_done()"); 820 948 821 949 fibril_mutex_lock(&rtl8169->tx_lock); … … 828 956 descr->control &= (~CONTROL_OWN); 829 957 write_barrier(); 830 ddf_msg(LVL_ NOTE, "TX status for descr %d: 0x%08x", tail, descr->control);958 ddf_msg(LVL_DEBUG, "TX status for descr %d: 0x%08x", tail, descr->control); 831 959 832 960 tail = (tail + 1) % TX_BUFFERS_COUNT; 833 } 961 sent++; 962 } 963 964 if (sent != 0) 965 nic_set_tx_busy(nic_data, 0); 834 966 835 967 rtl8169->tx_tail = tail; … … 849 981 int frame_size; 850 982 851 ddf_msg(LVL_ NOTE, "rtl8169_receive_done()");983 ddf_msg(LVL_DEBUG, "rtl8169_receive_done()"); 852 984 853 985 fibril_mutex_lock(&rtl8169->rx_lock); … … 862 994 863 995 if (descr->control & RXSTATUS_RES) { 864 ddf_msg(LVL_ NOTE, "error at slot %d: 0x%08x\n", tail, descr->control);996 ddf_msg(LVL_WARN, "error at slot %d: 0x%08x\n", tail, descr->control); 865 997 tail = (tail + 1) % RX_BUFFERS_COUNT; 866 998 continue; … … 871 1003 872 1004 if (descr->control & CONTROL_LS) { 873 874 ddf_msg(LVL_NOTE, "received message at slot %d, control 0x%08x", tail, descr->control); 1005 ddf_msg(LVL_DEBUG, "received message at slot %d, control 0x%08x", tail, descr->control); 875 1006 876 1007 if (fsidx != tail) … … 907 1038 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 908 1039 909 ddf_msg(LVL_ NOTE, "rtl8169_irq_handler(): isr=0x%04x", isr);1040 ddf_msg(LVL_DEBUG, "rtl8169_irq_handler(): isr=0x%04x", isr); 910 1041 pio_write_16(rtl8169->regs + IMR, 0xffff); 911 1042 … … 963 1094 fibril_mutex_lock(&rtl8169->tx_lock); 964 1095 965 ddf_msg(LVL_ NOTE, "send_frame: size: %zu, tx_head=%d tx_tail=%d",1096 ddf_msg(LVL_DEBUG, "send_frame: size: %zu, tx_head=%d tx_tail=%d", 966 1097 size, rtl8169->tx_head, rtl8169->tx_tail); 967 1098 … … 986 1117 prev = &rtl8169->tx_ring[(head - 1) % TX_BUFFERS_COUNT]; 987 1118 988 ddf_msg(LVL_ NOTE, "current_descr=%p, prev_descr=%p", descr, prev);1119 ddf_msg(LVL_DEBUG, "current_descr=%p, prev_descr=%p", descr, prev); 989 1120 990 1121 descr->control = CONTROL_OWN | CONTROL_FS | CONTROL_LS; -
uspace/drv/nic/rtl8169/driver.h
rf93ba6d rc62a8275 86 86 size_t tx_used; 87 87 88 /** Receive Control Register masks */ 89 uint32_t rcr_ucast; 90 uint32_t rcr_mcast; 91 88 92 /** Lock for receiver */ 89 93 fibril_mutex_t rx_lock; -
uspace/lib/c/generic/iplink.c
rf93ba6d rc62a8275 171 171 } 172 172 173 int iplink_set_mac48(iplink_t *iplink, addr48_t mac) 174 { 175 async_exch_t *exch = async_exchange_begin(iplink->sess); 176 177 ipc_call_t answer; 178 aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer); 179 180 int rc = async_data_read_start(exch, mac, sizeof(addr48_t)); 181 182 loc_exchange_end(exch); 183 184 if (rc != EOK) { 185 async_forget(req); 186 return rc; 187 } 188 189 sysarg_t retval; 190 async_wait_for(req, &retval); 191 192 return (int) retval; 193 } 194 195 173 196 int iplink_addr_add(iplink_t *iplink, inet_addr_t *addr) 174 197 { … … 230 253 free(sdu.data); 231 254 async_answer_0(iid, rc); 255 } 256 257 static void iplink_ev_change_addr(iplink_t *iplink, ipc_callid_t iid, 258 ipc_call_t *icall) 259 { 260 addr48_t *addr; 261 size_t size; 262 263 int rc = async_data_write_accept((void **)&addr, false, 264 sizeof(addr48_t), sizeof(addr48_t), 0, &size); 265 if (rc != EOK) { 266 async_answer_0(iid, rc); 267 return; 268 } 269 270 rc = iplink->ev_ops->change_addr(iplink, *addr); 271 free(addr); 272 async_answer_0(iid, EOK); 232 273 } 233 274 … … 249 290 iplink_ev_recv(iplink, callid, &call); 250 291 break; 292 case IPLINK_EV_CHANGE_ADDR: 293 iplink_ev_change_addr(iplink, callid, &call); 251 294 default: 252 295 async_answer_0(callid, ENOTSUP); -
uspace/lib/c/generic/iplink_srv.c
rf93ba6d rc62a8275 81 81 } 82 82 83 static void iplink_set_mac48_srv(iplink_srv_t *srv, ipc_callid_t iid, 84 ipc_call_t *icall) 85 { 86 int rc; 87 size_t size; 88 addr48_t mac; 89 ipc_callid_t callid; 90 91 rc = async_data_write_receive(&callid, &size); 92 if (rc != EOK) { 93 async_answer_0(callid, (sysarg_t) rc); 94 async_answer_0(iid, (sysarg_t) rc); 95 } 96 97 rc = srv->ops->set_mac48(srv, &mac); 98 if (rc != EOK) { 99 async_answer_0(iid, rc); 100 return; 101 } 102 103 rc = async_data_read_finalize(callid, &mac, sizeof(addr48_t)); 104 if (rc != EOK) 105 async_answer_0(callid, rc); 106 107 async_answer_0(iid, (sysarg_t) rc); 108 } 109 83 110 static void iplink_addr_add_srv(iplink_srv_t *srv, ipc_callid_t iid, 84 111 ipc_call_t *icall) … … 252 279 iplink_get_mac48_srv(srv, callid, &call); 253 280 break; 281 case IPLINK_SET_MAC48: 282 iplink_set_mac48_srv(srv, callid, &call); 283 break; 254 284 case IPLINK_SEND: 255 285 iplink_send_srv(srv, callid, &call); … … 300 330 } 301 331 332 int iplink_ev_change_addr(iplink_srv_t *srv, addr48_t *addr) 333 { 334 if (srv->client_sess == NULL) 335 return EIO; 336 337 async_exch_t *exch = async_exchange_begin(srv->client_sess); 338 339 ipc_call_t answer; 340 aid_t req = async_send_0(exch, IPLINK_EV_CHANGE_ADDR, &answer); 341 342 int rc = async_data_write_start(exch, addr, sizeof(addr48_t)); 343 async_exchange_end(exch); 344 345 if (rc != EOK) { 346 async_forget(req); 347 return rc; 348 } 349 350 sysarg_t retval; 351 async_wait_for(req, &retval); 352 if (retval != EOK) 353 return retval; 354 355 return EOK; 356 } 357 302 358 /** @} 303 359 */ -
uspace/lib/c/include/inet/iplink.h
rf93ba6d rc62a8275 78 78 typedef struct iplink_ev_ops { 79 79 int (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t); 80 int (*change_addr)(iplink_t *, addr48_t); 80 81 } iplink_ev_ops_t; 81 82 … … 88 89 extern int iplink_get_mtu(iplink_t *, size_t *); 89 90 extern int iplink_get_mac48(iplink_t *, addr48_t *); 91 extern int iplink_set_mac48(iplink_t *, addr48_t); 90 92 91 93 #endif -
uspace/lib/c/include/inet/iplink_srv.h
rf93ba6d rc62a8275 59 59 int (*get_mtu)(iplink_srv_t *, size_t *); 60 60 int (*get_mac48)(iplink_srv_t *, addr48_t *); 61 int (*set_mac48)(iplink_srv_t *, addr48_t *); 61 62 int (*addr_add)(iplink_srv_t *, inet_addr_t *); 62 63 int (*addr_remove)(iplink_srv_t *, inet_addr_t *); … … 67 68 extern int iplink_conn(ipc_callid_t, ipc_call_t *, void *); 68 69 extern int iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t); 70 extern int iplink_ev_change_addr(iplink_srv_t *, addr48_t *); 69 71 70 72 #endif -
uspace/lib/c/include/ipc/iplink.h
rf93ba6d rc62a8275 41 41 IPLINK_GET_MTU = IPC_FIRST_USER_METHOD, 42 42 IPLINK_GET_MAC48, 43 IPLINK_SET_MAC48, 43 44 IPLINK_SEND, 44 45 IPLINK_SEND6, … … 48 49 49 50 typedef enum { 50 IPLINK_EV_RECV = IPC_FIRST_USER_METHOD 51 IPLINK_EV_RECV = IPC_FIRST_USER_METHOD, 52 IPLINK_EV_CHANGE_ADDR, 51 53 } iplink_event_t; 52 54 -
uspace/lib/nic/src/nic_driver.c
rf93ba6d rc62a8275 47 47 #include <ops/nic.h> 48 48 #include <errno.h> 49 50 #include <io/log.h>51 49 52 50 #include "nic_driver.h" … … 438 436 int rc = nic_ev_addr_changed(nic_data->client_session, 439 437 address); 440 log_msg(LOG_DEFAULT, LVL_WARN, "rc=%d", rc);441 438 442 439 if (rc != EOK) { -
uspace/srv/net/ethip/ethip.c
rf93ba6d rc62a8275 59 59 static int ethip_get_mtu(iplink_srv_t *srv, size_t *mtu); 60 60 static int ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac); 61 static int ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac); 61 62 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr); 62 63 static int ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr); … … 71 72 .get_mtu = ethip_get_mtu, 72 73 .get_mac48 = ethip_get_mac48, 74 .set_mac48 = ethip_set_mac48, 73 75 .addr_add = ethip_addr_add, 74 76 .addr_remove = ethip_addr_remove … … 284 286 } 285 287 288 static int ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac) 289 { 290 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_set_mac48()"); 291 292 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; 293 addr48(*mac, nic->mac_addr); 294 295 return EOK; 296 } 297 286 298 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr) 287 299 { -
uspace/srv/net/ethip/ethip_nic.c
rf93ba6d rc62a8275 245 245 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); 246 246 247 memcpy(&nic->mac_addr, addr, sizeof(nic->mac_addr)); 248 249 rc = iplink_ev_change_addr(&nic->iplink, &nic->mac_addr); 250 if (rc != EOK) { 251 log_msg(LOG_DEFAULT, LVL_DEBUG, "iplink_ev_change_addr() failed"); 252 return; 253 } 254 247 255 free(addr); 248 256 async_answer_0(callid, EOK); … … 309 317 break; 310 318 default: 311 log_msg(LOG_DEFAULT, LVL_DEBUG, "unknown IPC method: % d", (int)IPC_GET_IMETHOD(call));319 log_msg(LOG_DEFAULT, LVL_DEBUG, "unknown IPC method: %" PRIun, IPC_GET_IMETHOD(call)); 312 320 async_answer_0(callid, ENOTSUP); 313 321 } -
uspace/srv/net/inetsrv/inet_link.c
rf93ba6d rc62a8275 55 55 56 56 static int inet_iplink_recv(iplink_t *, iplink_recv_sdu_t *, ip_ver_t); 57 static int inet_iplink_change_addr(iplink_t *, addr48_t); 57 58 static inet_link_t *inet_link_get_by_id_locked(sysarg_t); 58 59 59 60 static iplink_ev_ops_t inet_iplink_ev_ops = { 60 .recv = inet_iplink_recv 61 .recv = inet_iplink_recv, 62 .change_addr = inet_iplink_change_addr, 61 63 }; 62 64 … … 110 112 111 113 return rc; 114 } 115 116 static int inet_iplink_change_addr(iplink_t *iplink, addr48_t mac) 117 { 118 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_iplink_change_addr(): " 119 "new addr=%02x:%02x:%02x:%02x:%02x:%02x", 120 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); 121 122 list_foreach(inet_links, link_list, inet_link_t, ilink) { 123 if (ilink->sess == iplink->sess) 124 memcpy(&ilink->mac, mac, sizeof(addr48_t)); 125 } 126 127 return EOK; 112 128 } 113 129
Note:
See TracChangeset
for help on using the changeset viewer.