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.
Dependents: blinky_max32630fthr
ethernet_mac_api.h
00001 /* 00002 * Copyright (c) 2016 ARM Limited. All rights reserved. 00003 * 00004 * SPDX-License-Identifier: LicenseRef-PBL 00005 * 00006 * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * https://www.mbed.com/licenses/PBL-1.0 00010 * 00011 * See the License for the specific language governing permissions and limitations under the License. 00012 * 00013 */ 00014 00015 /** \file ethernet_mac_api.h 00016 * \brief Ethernet MAC API 00017 */ 00018 00019 #ifndef ETHERNET_MAC_API_H 00020 #define ETHERNET_MAC_API_H 00021 00022 #include <inttypes.h> 00023 #include "platform/arm_hal_phy.h" 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 #define ETHERTYPE_IPV4 0x0800 00030 #define ETHERTYPE_ARP 0x0806 00031 #define ETHERTYPE_802_1Q_TAG 0x8100 00032 #define ETHERTYPE_IPV6 0x86dd 00033 00034 typedef struct eth_mac_api_s eth_mac_api_t; 00035 00036 typedef struct eth_data_conf_s { 00037 uint8_t msduHandle; 00038 uint8_t status; 00039 }eth_data_conf_t; 00040 00041 typedef struct eth_data_req_s { 00042 uint16_t msduLength; 00043 uint8_t *msdu; 00044 uint8_t *srcAddress; 00045 uint8_t *dstAddress; 00046 uint16_t etehernet_type; 00047 uint8_t msduHandle; 00048 } eth_data_req_t; 00049 00050 typedef struct eth_data_ind_s { 00051 uint16_t msduLength; 00052 uint8_t *msdu; 00053 uint8_t srcAddress[6]; 00054 uint8_t dstAddress[6]; 00055 uint16_t etehernet_type; 00056 uint8_t link_quality; 00057 int8_t dbm; 00058 }eth_data_ind_t; 00059 00060 /** 00061 * @brief Creates ethernet MAC API instance which will use driver given 00062 * @param driver_id Ethernet driver id. Must be valid 00063 * @return New MAC instance if successful, NULL otherwise 00064 */ 00065 extern eth_mac_api_t *ethernet_mac_create(int8_t driver_id); 00066 00067 /** 00068 * @brief Destroy ethernet MAC API instance 00069 * Call this only for freeing all allocated memory and when mac is total unused 00070 * 00071 * @param mac_api Removed mac class pointer 00072 * @return -1 Unknow MAC 00073 * @return 0 Mac class is removed 00074 */ 00075 extern int8_t ethernet_mac_destroy(eth_mac_api_t *mac_api); 00076 00077 /** 00078 * @brief data_request data request call 00079 * @param api API to handle the request 00080 * @param data Data containing request parameters 00081 */ 00082 typedef void data_request(const eth_mac_api_t* api, const eth_data_req_t *data); 00083 00084 /** 00085 * @brief data_confirm confirm is called as a response to data_request 00086 * @param api The API which handled the request 00087 * @param data Data containing confirm parameters 00088 */ 00089 typedef void data_confirm(const eth_mac_api_t* api, const eth_data_conf_t *data ); 00090 00091 /** 00092 * @brief data_indication Data indication is called when MAC layer has received data 00093 * @param api The API which handled the response 00094 * @param data Data containing indication parameters 00095 */ 00096 typedef void data_indication(const eth_mac_api_t* api, const eth_data_ind_t *data ); 00097 00098 /** 00099 * @brief Set 48 bit address from MAC 00100 * @param api API to handle the request 00101 * @param mac48 Pointer having mac address to be set 00102 * @return 0 if successful, -1 otherwise 00103 */ 00104 typedef int8_t eth_mac_mac48_address_set(const eth_mac_api_t* api, const uint8_t *mac48); 00105 00106 /** 00107 * @brief Read 48 bit address from MAC 00108 * @param api API to handle the request 00109 * @param mac48_buf Pointer where mac address can be written 00110 * @return 0 if successful, -1 otherwise 00111 */ 00112 typedef int8_t eth_mac_mac48_address_get(const eth_mac_api_t* api, uint8_t *mac48_buf); 00113 00114 /** 00115 * @brief Upper layer will call this function, when MAC is taken into use 00116 * @param api API to initialize 00117 * @param conf_cb Callback for confirm type of messages 00118 * @param ind_cb Callback for indication type of messages 00119 * @param parent_id Upper layer identifier 00120 * @return 0 if success; -1 if api is NULL or not found 00121 */ 00122 typedef int8_t eth_mac_api_initialize(eth_mac_api_t *api, data_confirm *conf_cb, 00123 data_indication *ind_cb, uint8_t parent_id); 00124 00125 struct eth_mac_api_s { 00126 eth_mac_api_initialize *mac_initialize; 00127 00128 data_request *data_req; 00129 data_confirm *data_conf_cb; 00130 data_indication *data_ind_cb; 00131 00132 eth_mac_mac48_address_set *mac48_set; 00133 eth_mac_mac48_address_get *mac48_get; 00134 00135 uint8_t parent_id; 00136 bool address_resolution_needed; //Normal ethernet should set this true and tunnel or slip false 00137 }; 00138 00139 #ifdef __cplusplus 00140 } 00141 #endif 00142 00143 #endif // ETHERNET_MAC_API_H
Generated on Tue Jul 12 2022 14:21:04 by
1.7.2
