Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
emac_util.h
00001 /* 00002 * Copyright (c) 2017, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef EMAC_UTIL_H 00019 #define EMAC_UTIL_H 00020 00021 #define SECOND_TO_US 1000000 00022 #define SECOND_TO_MS 1000 00023 #define MS_TO_US 1000 00024 00025 extern const unsigned char eth_mac_broadcast_addr[]; 00026 00027 // Trace flags 00028 #define TRACE_NONE 0x00 00029 #define TRACE_ETH_FRAMES 0x01 00030 #define TRACE_SUCCESS 0x02 00031 #define TRACE_FAILURE 0x04 00032 #define TRACE_SEND 0x08 00033 // Sets trace level 00034 #define SET_TRACE_LEVEL(level) emac_if_set_trace_level(level) 00035 00036 // Message validation flags 00037 #define BROADCAST 0x01 00038 #define RESPONSE_RECEIVED 0x02 00039 #define INVALID_LENGHT 0x04 00040 #define INVALID_DATA 0x08 00041 #define PRINTED 0x10 00042 // Validates outgoing messages for replies, sets error flags on error 00043 #define VALIDATE_OUTGOING_MESSAGES emac_if_validate_outgoing_msg(); 00044 // Resets message data 00045 #define RESET_OUTGOING_MSG_DATA emac_if_reset_outgoing_msg() 00046 00047 // General error flags 00048 #define TEST_FAILED 0x01 00049 #define MSG_VALID_ERROR 0x02 00050 #define OUT_OF_MSG_DATA 0x04 00051 #define NO_FREE_MEM_BUF 0x08 00052 #define NO_RESPONSE 0x10 00053 00054 #define ERROR_FLAGS emac_if_get_error_flags() 00055 #define RESET_ALL_ERROR_FLAGS emac_if_reset_all_error_flags() 00056 #define PRINT_ERROR_FLAGS emac_if_print_error_flags() 00057 #define SET_ERROR_FLAGS(flags) emac_if_set_error_flags(flags) 00058 #define RESET_ERROR_FLAGS(flags) emac_if_reset_error_flags(flags) 00059 00060 #define ETH_FRAME_HEADER_LEN 28 00061 #define ETH_FRAME_MIN_LEN 60 + 4 00062 #define ETH_FRAME_PADD_LEN 60 00063 #define ETH_MAC_ADDR_LEN 6 00064 00065 #define TIMEOUT 1 00066 #define INPUT 2 00067 00068 #define ETH_MAX_LEN (14 + emac_if_get_mtu_size()) 00069 00070 // Starts test loop. Calls callback function on interval defined by the timeout 00071 // and when input message is received. 00072 #define START_TEST_LOOP(cb_function, timeout) worker_loop_start(cb_function, timeout) 00073 00074 // Ends test loop 00075 #define END_TEST_LOOP { worker_loop_end(); return; } 00076 00077 // Checks if echo server MAC address is known 00078 #define ECHO_SERVER_ADDRESS_KNOWN emac_if_count_echo_server_addr() 00079 00080 int emac_if_find_outgoing_msg(int receipt_number); 00081 void emac_if_free_outgoing_msg(int index); 00082 int emac_if_count_outgoing_msg(void); 00083 void emac_if_reset_outgoing_msg(void); 00084 int emac_if_add_outgoing_msg(int length); 00085 void emac_if_timeout_outgoing_msg(void); 00086 void emac_if_validate_outgoing_msg(void); 00087 void emac_if_set_outgoing_msg_receipt_num(int index, int receipt_number); 00088 void emac_if_set_outgoing_msg_flags(int index, int flags); 00089 00090 void emac_if_add_echo_server_addr(unsigned char *addr); 00091 int emac_if_count_echo_server_addr(void); 00092 unsigned char *emac_if_get_echo_server_addr(int index); 00093 00094 void emac_if_set_error_flags(unsigned int error_flags_value); 00095 unsigned int emac_if_get_error_flags(void); 00096 void emac_if_reset_all_error_flags(void); 00097 void emac_if_reset_error_flags(unsigned int error_flags_value); 00098 void emac_if_print_error_flags(void); 00099 00100 void emac_if_set_trace_level(char trace_level_value); 00101 char emac_if_get_trace_level(); 00102 00103 void emac_if_trace_to_ascii_hex_dump(const char *prefix, int len, char *data); 00104 00105 void emac_if_link_state_change_cb(void *data, bool up); 00106 00107 unsigned char *emac_if_get_own_addr(void); 00108 00109 int emac_if_get_mtu_size(); 00110 void emac_if_set_mtu_size(int mtu_size); 00111 00112 extern void emac_if_link_input_cb(void *buf); 00113 extern void emac_if_link_state_change_cb(bool up); 00114 00115 void emac_if_set_all_multicast(bool all); 00116 void emac_if_add_multicast_group(uint8_t *address); 00117 00118 void emac_if_set_output_memory(bool memory); 00119 void emac_if_set_input_memory(bool memory); 00120 void emac_if_check_memory(bool output); 00121 void emac_if_set_memory(bool memory); 00122 00123 void worker_loop_init(void); 00124 void worker_loop_start(void (*test_step_cb_fnc)(int opt), int timeout); 00125 void worker_loop_end(void); 00126 void worker_loop_link_up_wait(void); 00127 00128 #endif /* EMAC_UTIL_H */
Generated on Tue Aug 9 2022 00:37:06 by
1.7.2