Skip to content

Commit 7535485

Browse files
committed
Shorten D(estination)A(ddress) and S(ource)A(ddress), Filtering -> Filter
1 parent fdb5d45 commit 7535485

File tree

7 files changed

+60
-60
lines changed

7 files changed

+60
-60
lines changed

examples/arp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use cortex_m_rt::{entry, exception};
1717
use cortex_m::interrupt::Mutex;
1818
use stm32_eth::{
1919
mac::{
20-
frame_filtering::{FrameFiltering, FrameFilteringMode, Mac},
20+
frame_filtering::{Filter, FilterConfig, Mac},
2121
phy::BarePhy,
2222
Phy,
2323
},
@@ -63,12 +63,12 @@ fn main() -> ! {
6363

6464
let some_mac = if eth_dma.tx_is_running() { 1 } else { 0 };
6565

66-
let frame_filtering = FrameFiltering::filter_destinations(
66+
let frame_filtering = FilterConfig::filter_destinations(
6767
Mac::new([some_mac, some_mac, some_mac, some_mac, some_mac, some_mac]),
6868
&[],
6969
);
7070

71-
eth_mac.configure_filtering(&FrameFilteringMode::Filter(frame_filtering));
71+
eth_mac.configure_frame_filter(&Filter::Filter(frame_filtering));
7272

7373
let mut last_link_up = false;
7474

src/mac/frame_filtering/control.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/// on received control frames,
33
#[derive(Debug, Clone)]
44

5-
pub enum ControlFrameFiltering {
5+
pub enum ControlFrameFilter {
66
/// Prevent all control frames from reaching
77
/// the application.
88
BlockAll,
@@ -16,15 +16,15 @@ pub enum ControlFrameFiltering {
1616
AddressFilter,
1717
}
1818

19-
impl ControlFrameFiltering {
19+
impl ControlFrameFilter {
2020
/// Create a new [`ControlFrameFiltering`] that filters out
2121
/// all control frames.
2222
pub const fn new() -> Self {
2323
Self::BlockAll
2424
}
2525
}
2626

27-
impl Default for ControlFrameFiltering {
27+
impl Default for ControlFrameFilter {
2828
fn default() -> Self {
2929
Self::new()
3030
}

src/mac/frame_filtering/destination.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
/// The type of filtering that the MAC should apply to
2-
/// frames that are to be transmitted.
1+
/// The type of destination address filtering that
2+
/// the MAC should apply to incoming frames.
33
#[derive(Debug, Clone)]
4-
pub struct DestinationAddressFiltering {
4+
pub struct DaFilter {
55
/// Filtering to be performed based on perfect address matches.
6-
pub perfect_filtering: PerfectDestinationAddressFilteringMode,
6+
pub perfect_filtering: PerfectDaFilterMode,
77
/// Enable or disable hash table filtering for destination
88
/// addresses.
99
pub hash_table_filtering: bool,
1010
}
1111

12-
impl DestinationAddressFiltering {
13-
/// Create a new [`DestinationAddressFiltering`] that does
12+
impl DaFilter {
13+
/// Create a new [`DaFilter`] that does
1414
/// not filter any frames.
1515
pub const fn new() -> Self {
1616
Self {
17-
perfect_filtering: PerfectDestinationAddressFilteringMode::new(),
17+
perfect_filtering: PerfectDaFilterMode::new(),
1818
hash_table_filtering: false,
1919
}
2020
}
2121
}
2222

23-
impl Default for DestinationAddressFiltering {
23+
impl Default for DaFilter {
2424
fn default() -> Self {
2525
Self::new()
2626
}
2727
}
2828

2929
/// The type of destination address filtering that
30-
/// the MAC should apply to frames.
30+
/// the MAC should apply to incoming frames.
3131
#[derive(Debug, Clone)]
3232

33-
pub enum PerfectDestinationAddressFilteringMode {
33+
pub enum PerfectDaFilterMode {
3434
/// Filter frames by their Destination Address, based on
3535
/// the addresses configured with [`AddressFilterType::Destination`].
3636
///
@@ -44,15 +44,15 @@ pub enum PerfectDestinationAddressFilteringMode {
4444
Inverse,
4545
}
4646

47-
impl PerfectDestinationAddressFilteringMode {
47+
impl PerfectDaFilterMode {
4848
/// Create a new [`PerfectDestinationAddressFilteringMode`] that filters
4949
/// out all frames.
5050
pub const fn new() -> Self {
5151
Self::Normal
5252
}
5353
}
5454

55-
impl Default for PerfectDestinationAddressFilteringMode {
55+
impl Default for PerfectDaFilterMode {
5656
fn default() -> Self {
5757
Self::new()
5858
}

src/mac/frame_filtering/mod.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ pub use control::*;
2020
/// The frame filtering that the MAC should apply to
2121
/// received Ethernet frames.
2222
#[derive(Debug, Clone)]
23-
pub enum FrameFilteringMode {
23+
pub enum Filter {
2424
/// No frame filtering on any frames.
2525
Promiscuous,
2626
/// Perform frame filtering based on the provided
2727
/// configuration.
28-
Filter(FrameFiltering),
28+
Filter(FilterConfig),
2929
}
3030

31-
impl Default for FrameFilteringMode {
31+
impl Default for Filter {
3232
fn default() -> Self {
3333
Self::Promiscuous
3434
}
3535
}
3636

37-
impl FrameFilteringMode {
37+
impl Filter {
3838
pub(crate) fn configure(&self, eth_mac: &ETHERNET_MAC) {
3939
match self {
40-
FrameFilteringMode::Promiscuous => eth_mac.macffr.write(|w| w.pm().set_bit()),
41-
FrameFilteringMode::Filter(config) => config.configure(eth_mac),
40+
Filter::Promiscuous => eth_mac.macffr.write(|w| w.pm().set_bit()),
41+
Filter::Filter(config) => config.configure(eth_mac),
4242
}
4343
}
4444
}
@@ -49,7 +49,7 @@ impl FrameFilteringMode {
4949
/// The total amount of [`MacAddressFilter`]s in this configuration object may
5050
/// be at most 3.
5151
#[derive(Debug, Clone)]
52-
pub struct FrameFiltering {
52+
pub struct FilterConfig {
5353
/// The MAC address of this station. This address is always
5454
/// used for Destination Address filtering.
5555
pub base_address: Mac,
@@ -59,18 +59,18 @@ pub struct FrameFiltering {
5959

6060
/// Frame filtering applied to frames based on
6161
/// their destination address.
62-
pub destination_address_filter: DestinationAddressFiltering,
62+
pub destination_address_filter: DaFilter,
6363

6464
/// Frame filtering applied to frames based on
6565
/// their source address.
66-
pub source_address_filter: SourceAddressFiltering,
66+
pub source_address_filter: SaFilter,
6767

6868
/// Frame filtering applied to frames based on
6969
/// whether they have a multicast address or not.
70-
pub multicast_address_filter: MulticastAddressFiltering,
70+
pub multicast_address_filter: MulticastAddressFilter,
7171

7272
/// Control frame filtering mode,
73-
pub control_filter: ControlFrameFiltering,
73+
pub control_filter: ControlFrameFilter,
7474

7575
/// Hash table configuration.
7676
pub hash_table_value: HashTableValue,
@@ -89,7 +89,7 @@ pub struct FrameFiltering {
8989
pub receive_all: bool,
9090
}
9191

92-
impl FrameFiltering {
92+
impl FilterConfig {
9393
/// Create a new basic [`FrameFiltering`] that:
9494
/// * Does not filter out frames destined for `station_addr` or an address
9595
/// contained in `extra_address`.
@@ -115,24 +115,24 @@ impl FrameFiltering {
115115
}
116116
}
117117

118-
FrameFiltering {
118+
FilterConfig {
119119
base_address: station_addr,
120120
address_filters,
121-
destination_address_filter: DestinationAddressFiltering {
122-
perfect_filtering: PerfectDestinationAddressFilteringMode::Normal,
121+
destination_address_filter: DaFilter {
122+
perfect_filtering: PerfectDaFilterMode::Normal,
123123
hash_table_filtering: false,
124124
},
125-
source_address_filter: SourceAddressFiltering::Ignore,
126-
multicast_address_filter: MulticastAddressFiltering::PassAll,
127-
control_filter: ControlFrameFiltering::BlockAll,
125+
source_address_filter: SaFilter::Ignore,
126+
multicast_address_filter: MulticastAddressFilter::PassAll,
127+
control_filter: ControlFrameFilter::BlockAll,
128128
hash_table_value: HashTableValue::new(),
129129
filter_broadcast: false,
130130
receive_all: false,
131131
}
132132
}
133133

134134
fn configure(&self, eth_mac: &ETHERNET_MAC) {
135-
let FrameFiltering {
135+
let FilterConfig {
136136
base_address,
137137
address_filters,
138138
destination_address_filter,
@@ -152,28 +152,28 @@ impl FrameFiltering {
152152
.write(|w| w.maca0l().bits(base_address.low()));
153153

154154
let daif = match &destination_address_filter.perfect_filtering {
155-
PerfectDestinationAddressFilteringMode::Normal => false,
156-
PerfectDestinationAddressFilteringMode::Inverse => true,
155+
PerfectDaFilterMode::Normal => false,
156+
PerfectDaFilterMode::Inverse => true,
157157
};
158158
let hu = destination_address_filter.hash_table_filtering;
159159

160160
let (saf, saif) = match &source_address_filter {
161-
SourceAddressFiltering::Ignore => (false, false),
162-
SourceAddressFiltering::Normal => (true, false),
163-
SourceAddressFiltering::Inverse => (true, true),
161+
SaFilter::Ignore => (false, false),
162+
SaFilter::Normal => (true, false),
163+
SaFilter::Inverse => (true, true),
164164
};
165165

166166
let (pam, hm) = match &multicast_address_filter {
167-
MulticastAddressFiltering::PassAll => (true, false),
168-
MulticastAddressFiltering::DestinationAddressHash => (false, true),
169-
MulticastAddressFiltering::DestinationAddress => (false, false),
167+
MulticastAddressFilter::PassAll => (true, false),
168+
MulticastAddressFilter::DestinationAddressHash => (false, true),
169+
MulticastAddressFilter::DestinationAddress => (false, false),
170170
};
171171

172172
let pcf = match &control_filter {
173-
ControlFrameFiltering::BlockAll => 0b00,
174-
ControlFrameFiltering::NoPause => 0b01,
175-
ControlFrameFiltering::AllowAll => 0b10,
176-
ControlFrameFiltering::AddressFilter => 0b11,
173+
ControlFrameFilter::BlockAll => 0b00,
174+
ControlFrameFilter::NoPause => 0b01,
175+
ControlFrameFilter::AllowAll => 0b10,
176+
ControlFrameFilter::AddressFilter => 0b11,
177177
};
178178

179179
macro_rules! next_addr_reg {

src/mac/frame_filtering/multicast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// Multicast address filtering
22
#[derive(Debug, Clone)]
3-
pub enum MulticastAddressFiltering {
3+
pub enum MulticastAddressFilter {
44
/// All received multicast frames are passed to the
55
/// application.
66
PassAll,
@@ -14,15 +14,15 @@ pub enum MulticastAddressFiltering {
1414
DestinationAddress,
1515
}
1616

17-
impl MulticastAddressFiltering {
17+
impl MulticastAddressFilter {
1818
/// Create a new MulticastAddressFiltering that does not
1919
/// filter any multicast frames.
2020
pub const fn new() -> Self {
2121
Self::PassAll
2222
}
2323
}
2424

25-
impl Default for MulticastAddressFiltering {
25+
impl Default for MulticastAddressFilter {
2626
fn default() -> Self {
2727
Self::new()
2828
}

src/mac/frame_filtering/source.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/// The type of frame filtering that the MAC should perform
2-
/// on received frames.
1+
/// The type of source address frame filtering that
2+
/// the MAC should perform to received frames.
33
#[derive(Debug, Clone)]
44

5-
pub enum SourceAddressFiltering {
5+
pub enum SaFilter {
66
/// Source address filtering never fails.
77
Ignore,
88
/// Filter frames by their Source Address, based on
@@ -17,15 +17,15 @@ pub enum SourceAddressFiltering {
1717
Inverse,
1818
}
1919

20-
impl SourceAddressFiltering {
20+
impl SaFilter {
2121
/// Create a new [`SourceAddressFiltering`] that
2222
/// does not filter any frames.
2323
pub const fn new() -> Self {
2424
Self::Inverse
2525
}
2626
}
2727

28-
impl Default for SourceAddressFiltering {
28+
impl Default for SaFilter {
2929
fn default() -> Self {
3030
Self::new()
3131
}

src/mac/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mod consts {
3939
/* For HCLK over 150 MHz */
4040
pub const ETH_MACMIIAR_CR_HCLK_DIV_102: u8 = 4;
4141
}
42-
use self::{consts::*, frame_filtering::FrameFilteringMode};
42+
use self::{consts::*, frame_filtering::Filter};
4343

4444
/// HCLK must be at least 25MHz to use the ethernet peripheral.
4545
/// This (empty) struct is returned to indicate that it is not set
@@ -139,7 +139,7 @@ impl EthernetMAC {
139139
.mmctimr
140140
.modify(|r, w| unsafe { w.bits(r.bits() | (1 << 21)) });
141141

142-
FrameFilteringMode::Promiscuous.configure(&eth_mac);
142+
Filter::Promiscuous.configure(&eth_mac);
143143

144144
let mut me = Self { eth_mac };
145145

@@ -207,7 +207,7 @@ impl EthernetMAC {
207207

208208
/// Configure the frame filtering performed by this MAC.
209209
#[inline(always)]
210-
pub fn configure_filtering(&self, filtering_config: &FrameFilteringMode) {
210+
pub fn configure_frame_filter(&self, filtering_config: &Filter) {
211211
filtering_config.configure(&self.eth_mac);
212212
}
213213
}

0 commit comments

Comments
 (0)