Mistake on this page?
Report an issue in GitHub or email us
wifi_emac.h
1 /* Copyright (c) 2017 ARM Limited
2  * SPDX-License-Identifier: Apache-2.0
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef WIFI_EMAC_H_
18 #define WIFI_EMAC_H_
19 
20 #include "EMAC.h"
21 #include "cb_wlan_target_data.h"
22 #include "cb_wlan.h"
23 
24 class OdinWiFiEMAC : public EMAC {
25 public:
26  OdinWiFiEMAC();
27 
28  static OdinWiFiEMAC &get_instance();
29 
30  /**
31  * Return maximum transmission unit
32  *
33  * @return MTU in bytes
34  */
35  virtual uint32_t get_mtu_size() const;
36 
37  /**
38  * Return interface name
39  *
40  * @param name Pointer to where the name should be written
41  * @param size Maximum number of character to copy
42  */
43  virtual void get_ifname(char *name, uint8_t size) const;
44 
45  /**
46  * Returns size of the underlying interface HW address size.
47  *
48  * @return HW address size in bytes
49  */
50  virtual uint8_t get_hwaddr_size() const;
51 
52  /**
53  * Return interface-supplied HW address
54  *
55  * Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size
56  *
57  * HW address need not be provided if this interface does not have its own HW
58  * address configuration; stack will choose address from central system
59  * configuration if the function returns false and does not write to addr.
60  *
61  * @param addr HW address for underlying interface
62  * @return true if HW address is available
63  */
64  virtual bool get_hwaddr(uint8_t *addr) const;
65 
66  /**
67  * Set HW address for interface
68  *
69  * Provided address has to be of correct size, see @a get_hwaddr_size
70  *
71  * Called to set the MAC address to actually use - if @a get_hwaddr is provided
72  * the stack would normally use that, but it could be overridden, eg for test
73  * purposes.
74  *
75  * @param addr Address to be set
76  */
77  virtual void set_hwaddr(const uint8_t *addr);
78 
79  /**
80  * Sends the packet over the link
81  *
82  * That can not be called from an interrupt context.
83  *
84  * @param buf Packet to be send
85  * @return True if the packet was send successfully, False otherwise
86  */
87  virtual bool link_out(emac_mem_buf_t *buf);
88 
89  /**
90  * Initializes the HW
91  *
92  * @return True on success, False in case of an error.
93  */
94  virtual bool power_up();
95 
96  /**
97  * Deinitializes the HW
98  *
99  */
100  virtual void power_down();
101 
102  /**
103  * Sets a callback that needs to be called for packets received for that interface
104  *
105  * @param input_cb Function to be register as a callback
106  */
107  virtual void set_link_input_cb(emac_link_input_cb_t input_cb);
108 
109  /**
110  * Sets a callback that needs to be called on link status changes for given interface
111  *
112  * @param state_cb Function to be register as a callback
113  */
114  virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb);
115 
116  /** Sets memory manager that is used to handle memory buffers
117  *
118  * @param mem_mngr Pointer to memory manager
119  */
120  virtual void set_memory_manager(EMACMemoryManager &mem_mngr);
121 
122  virtual uint32_t get_align_preference() const;
123  virtual void add_multicast_group(const uint8_t *address);
124  virtual void remove_multicast_group(const uint8_t *address);
125  virtual void set_all_multicast(bool all);
126 
127 private:
128 
129  emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */
130  emac_link_state_change_cb_t emac_link_state_cb; /**< Link state change callback */
131  EMACMemoryManager *memory_manager;
132 
133  friend cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataFrame* frame, uint32_t size, uint32_t offsetInFrame);
134  friend cb_boolean handleWlanTargetCopyToDataFrame(cbWLANTARGET_dataFrame* frame, uint8_t* buffer, uint32_t size, uint32_t offsetInFrame);
135  friend cbWLANTARGET_dataFrame* handleWlanTargetAllocDataFrame(uint32_t size);
136  friend void handleWlanTargetFreeDataFrame(cbWLANTARGET_dataFrame* frame);
137  friend cb_uint32 handleWlanTargetGetDataFrameSize(cbWLANTARGET_dataFrame* frame);
138 
139  friend void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data);
140  friend void handleWlanPacketIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo);
141  friend void send_wlan_packet(void *buf);
142 };
143 
144 #endif /* WIFI_EMAC_H_ */
virtual uint8_t get_hwaddr_size() const
Returns size of the underlying interface HW address size.
virtual uint32_t get_align_preference() const
Gets memory buffer alignment preference.
virtual bool get_hwaddr(uint8_t *addr) const
Return interface-supplied HW address.
virtual void set_all_multicast(bool all)
Request reception of all multicast packets.
virtual void set_memory_manager(EMACMemoryManager &mem_mngr)
Sets memory manager that is used to handle memory buffers.
virtual void get_ifname(char *name, uint8_t size) const
Return interface name.
virtual bool link_out(emac_mem_buf_t *buf)
Sends the packet over the link.
virtual uint32_t get_mtu_size() const
Return maximum transmission unit.
mbed::Callback< void(emac_mem_buf_t *buf)> emac_link_input_cb_t
Callback to be register with EMAC interface and to be called for received packets.
Definition: EMAC.h:48
virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb)
Sets a callback that needs to be called on link status changes for given interface.
virtual void power_down()
Deinitializes the HW.
virtual void remove_multicast_group(const uint8_t *address)
Remove device from a multicast group.
virtual void set_hwaddr(const uint8_t *addr)
Set HW address for interface.
This interface should be used to abstract low level access to networking hardware All operations rece...
Definition: EMAC.h:32
virtual void set_link_input_cb(emac_link_input_cb_t input_cb)
Sets a callback that needs to be called for packets received for that interface.
virtual bool power_up()
Initializes the HW.
virtual void add_multicast_group(const uint8_t *address)
Add device to a multicast group.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.