1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
// SPDX-License-Identifier: GPL-2.0+
/* Copyright 2025 NXP */
#include <linux/device.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/string_choices.h>
#include "enetc_pf_common.h"
#include "enetc4_debugfs.h"
static void enetc_vf_state_lock(struct enetc_pf *pf, int vf_id)
{
struct enetc_vf_state *vf_state;
if (vf_id < 0)
return;
vf_state = &pf->vf_state[vf_id];
mutex_lock(&vf_state->lock);
}
static void enetc_vf_state_unlock(struct enetc_pf *pf, int vf_id)
{
struct enetc_vf_state *vf_state;
if (vf_id < 0)
return;
vf_state = &pf->vf_state[vf_id];
mutex_unlock(&vf_state->lock);
}
static void enetc_show_si_mac_hash_filter(struct seq_file *s, int si_id)
{
struct enetc_pf *pf = enetc_si_priv(s->private);
struct enetc_hw *hw = &pf->si->hw;
u32 hash_h, hash_l;
enetc_vf_state_lock(pf, si_id - 1);
hash_l = enetc_port_rd(hw, ENETC4_PSIUMHFR0(si_id));
hash_h = enetc_port_rd(hw, ENETC4_PSIUMHFR1(si_id));
seq_printf(s, "SI %d unicast MAC hash filter: 0x%08x%08x\n",
si_id, hash_h, hash_l);
hash_l = enetc_port_rd(hw, ENETC4_PSIMMHFR0(si_id));
hash_h = enetc_port_rd(hw, ENETC4_PSIMMHFR1(si_id));
seq_printf(s, "SI %d multicast MAC hash filter: 0x%08x%08x\n",
si_id, hash_h, hash_l);
enetc_vf_state_unlock(pf, si_id - 1);
}
static int enetc_mac_filter_show(struct seq_file *s, void *data)
{
struct enetc_pf *pf = enetc_si_priv(s->private);
struct enetc_hw *hw = &pf->si->hw;
int num_si = pf->total_vfs + 1;
struct maft_entry_data maft;
struct ntmp_user *user;
u32 val, entry_id;
int err = 0;
int i;
/* Prevent concurrent access from causing PSIPMMR to be modified */
spin_lock(&pf->si->gen_lock);
val = enetc_port_rd(hw, ENETC4_PSIPMMR);
spin_unlock(&pf->si->gen_lock);
for (i = 0; i < num_si; i++) {
seq_printf(s, "SI %d Unicast Promiscuous mode: %s\n", i,
str_enabled_disabled(PSIPMMR_SI_MAC_UP(i) & val));
seq_printf(s, "SI %d Multicast Promiscuous mode: %s\n", i,
str_enabled_disabled(PSIPMMR_SI_MAC_MP(i) & val));
}
rtnl_lock();
/* MAC hash filter table */
for (i = 0; i < num_si; i++)
enetc_show_si_mac_hash_filter(s, i);
user = &pf->si->ntmp_user;
if (bitmap_empty(user->maft_eid_bitmap, user->maft_num_entries))
goto unlock_rtnl;
/* MAC address filter table */
seq_puts(s, "MAC address filter table\n");
for_each_set_bit(entry_id, user->maft_eid_bitmap,
user->maft_num_entries) {
memset(&maft, 0, sizeof(maft));
err = ntmp_maft_query_entry(user, entry_id, &maft);
if (err)
goto unlock_rtnl;
seq_printf(s, "Entry %d, MAC: %pM, SI bitmap: 0x%04x\n",
entry_id, maft.keye.mac_addr,
le16_to_cpu(maft.cfge.si_bitmap));
}
unlock_rtnl:
rtnl_unlock();
return err;
}
DEFINE_SHOW_ATTRIBUTE(enetc_mac_filter);
void enetc_create_debugfs(struct enetc_si *si)
{
struct dentry *root;
root = debugfs_create_dir(pci_name(si->pdev), NULL);
if (IS_ERR(root))
return;
si->debugfs_root = root;
debugfs_create_file("mac_filter", 0444, root, si, &enetc_mac_filter_fops);
}
void enetc_remove_debugfs(struct enetc_si *si)
{
debugfs_remove(si->debugfs_root);
si->debugfs_root = NULL;
}
|