Skip to content

Commit 31d86d5

Browse files
committed
Extend EMAC multicast APIs
1 parent 9d4da12 commit 31d86d5

File tree

5 files changed

+70
-6
lines changed

5 files changed

+70
-6
lines changed

features/netsocket/EMAC.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,20 @@ class EMAC {
155155
*
156156
* @param address A multicast group hardware address
157157
*/
158-
virtual void add_multicast_group(uint8_t *address) = 0;
158+
virtual void add_multicast_group(const uint8_t *address) = 0;
159+
160+
/** Remove device from a multicast group
161+
*
162+
* @param address A multicast group hardware address
163+
*/
164+
virtual void remove_multicast_group(const uint8_t *address) = 0;
165+
166+
/** Request reception of all multicast packets
167+
*
168+
* @param all True to receive all multicasts
169+
* False to receive only multicasts addressed to specified groups
170+
*/
171+
virtual void set_all_multicast(bool all) = 0;
159172

160173
/** Sets memory manager that is used to handle memory buffers
161174
*

features/netsocket/emac-drivers/TARGET_Freescale/k64f_emac.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,24 @@ void K64F_EMAC::set_link_state_cb(emac_link_state_change_cb_t state_cb)
569569
emac_link_state_cb = state_cb;
570570
}
571571

572-
void K64F_EMAC::add_multicast_group(uint8_t *addr)
572+
void K64F_EMAC::add_multicast_group(const uint8_t *addr)
573573
{
574-
ENET_AddMulticastGroup(ENET, addr);
574+
ENET_AddMulticastGroup(ENET, const_cast<uint8_t *>(addr));
575+
}
576+
577+
void K64F_EMAC::remove_multicast_group(const uint8_t *addr)
578+
{
579+
// ENET HAL doesn't reference count - ENET_LeaveMulticastGroup just maps
580+
// address to filter bit, and clears that bit, even if shared by other
581+
// addresses. So don't attempt anything for now.
582+
}
583+
584+
void K64F_EMAC::set_all_multicast(bool all)
585+
{
586+
if (all) {
587+
ENET->GAUR = 0xFFFFFFFFu;
588+
ENET->GALR = 0xFFFFFFFFu;
589+
}
575590
}
576591

577592
void K64F_EMAC::power_down()

features/netsocket/emac-drivers/TARGET_Freescale/k64f_emac.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,20 @@ class K64F_EMAC : public EMAC {
115115
*
116116
* @param address A multicast group hardware address
117117
*/
118-
virtual void add_multicast_group(uint8_t *address);
118+
virtual void add_multicast_group(const uint8_t *address);
119+
120+
/** Remove device from a multicast group
121+
*
122+
* @param address A multicast group hardware address
123+
*/
124+
virtual void remove_multicast_group(const uint8_t *address);
125+
126+
/** Request reception of all multicast packets
127+
*
128+
* @param all True to receive all multicasts
129+
* False to receive only multicasts addressed to specified groups
130+
*/
131+
virtual void set_all_multicast(bool all);
119132

120133
/** Sets memory manager that is used to handle memory buffers
121134
*

features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,17 @@ void STM32_EMAC::set_link_state_cb(emac_link_state_change_cb_t state_cb)
519519
emac_link_state_cb = state_cb;
520520
}
521521

522-
void STM32_EMAC::add_multicast_group(uint8_t *addr)
522+
void STM32_EMAC::add_multicast_group(const uint8_t *addr)
523+
{
524+
/* No-op at this stage */
525+
}
526+
527+
void STM32_EMAC::remove_multicast_group(const uint8_t *addr)
528+
{
529+
/* No-op at this stage */
530+
}
531+
532+
void STM32_EMAC::set_all_multicast(bool all)
523533
{
524534
/* No-op at this stage */
525535
}

features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,20 @@ class STM32_EMAC : public EMAC {
126126
*
127127
* @param address A multicast group hardware address
128128
*/
129-
virtual void add_multicast_group(uint8_t *address);
129+
virtual void add_multicast_group(const uint8_t *address);
130+
131+
/** Remove device from a multicast group
132+
*
133+
* @param address A multicast group hardware address
134+
*/
135+
virtual void remove_multicast_group(const uint8_t *address);
136+
137+
/** Request reception of all multicast packets
138+
*
139+
* @param all True to receive all multicasts
140+
* False to receive only multicasts addressed to specified groups
141+
*/
142+
virtual void set_all_multicast(bool all);
130143

131144
/** Sets memory manager that is used to handle memory buffers
132145
*

0 commit comments

Comments
 (0)