Skip to content

Commit bae51fe

Browse files
vcgomesJeff Kirsher
authored andcommitted
igb: Enable nfc filters to specify MAC addresses
This allows igb_add_filter()/igb_erase_filter() to work on filters that include MAC addresses (both source and destination). For now, this only exposes the functionality, the next commit glues ethtool into this. Later in this series, these APIs are used to allow offloading of cls_flower filters. Signed-off-by: Vinicius Costa Gomes <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 872f923 commit bae51fe

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

drivers/net/ethernet/intel/igb/igb.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ struct hwmon_buff {
442442
enum igb_filter_match_flags {
443443
IGB_FILTER_FLAG_ETHER_TYPE = 0x1,
444444
IGB_FILTER_FLAG_VLAN_TCI = 0x2,
445+
IGB_FILTER_FLAG_SRC_MAC_ADDR = 0x4,
446+
IGB_FILTER_FLAG_DST_MAC_ADDR = 0x8,
445447
};
446448

447449
#define IGB_MAX_RXNFC_FILTERS 16
@@ -456,6 +458,8 @@ struct igb_nfc_input {
456458
u8 match_flags;
457459
__be16 etype;
458460
__be16 vlan_tci;
461+
u8 src_addr[ETH_ALEN];
462+
u8 dst_addr[ETH_ALEN];
459463
};
460464

461465
struct igb_nfc_filter {

drivers/net/ethernet/intel/igb/igb_ethtool.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,6 +2776,25 @@ int igb_add_filter(struct igb_adapter *adapter, struct igb_nfc_filter *input)
27762776
return err;
27772777
}
27782778

2779+
if (input->filter.match_flags & IGB_FILTER_FLAG_DST_MAC_ADDR) {
2780+
err = igb_add_mac_steering_filter(adapter,
2781+
input->filter.dst_addr,
2782+
input->action, 0);
2783+
err = min_t(int, err, 0);
2784+
if (err)
2785+
return err;
2786+
}
2787+
2788+
if (input->filter.match_flags & IGB_FILTER_FLAG_SRC_MAC_ADDR) {
2789+
err = igb_add_mac_steering_filter(adapter,
2790+
input->filter.src_addr,
2791+
input->action,
2792+
IGB_MAC_STATE_SRC_ADDR);
2793+
err = min_t(int, err, 0);
2794+
if (err)
2795+
return err;
2796+
}
2797+
27792798
if (input->filter.match_flags & IGB_FILTER_FLAG_VLAN_TCI)
27802799
err = igb_rxnfc_write_vlan_prio_filter(adapter, input);
27812800

@@ -2824,6 +2843,15 @@ int igb_erase_filter(struct igb_adapter *adapter, struct igb_nfc_filter *input)
28242843
igb_clear_vlan_prio_filter(adapter,
28252844
ntohs(input->filter.vlan_tci));
28262845

2846+
if (input->filter.match_flags & IGB_FILTER_FLAG_SRC_MAC_ADDR)
2847+
igb_del_mac_steering_filter(adapter, input->filter.src_addr,
2848+
input->action,
2849+
IGB_MAC_STATE_SRC_ADDR);
2850+
2851+
if (input->filter.match_flags & IGB_FILTER_FLAG_DST_MAC_ADDR)
2852+
igb_del_mac_steering_filter(adapter, input->filter.dst_addr,
2853+
input->action, 0);
2854+
28272855
return 0;
28282856
}
28292857

0 commit comments

Comments
 (0)