[PATCH net-next v2 2/2] net: ti: icssg-prueth: Add ethtool RX flow classification support
Meghana Malladi
m-malladi at ti.com
Thu Dec 3 04:14:32 PST 2026
Enable dynamic RX flow classification via ethtool set_rxnfc/get_rxnfc.
Users can install/remove filter rules to steer packets to specific RX flows
based on EtherType patterns via FT3 hardware filters.
- Add RXNFC rule tracking structures and lifecycle management
- Implement ethtool get_rxnfc/set_rxnfc callbacks
- FT3 slot allocation and hardware programming for pattern matching
- RX classifier OR table updates based on active rules
- Max 15 rules per EMAC, using FT3 slots 0-13,15 (slot 14 reserved)
- Reserve FT3 slot 9 when HSR offload is active: classifier 10's OR_EN
(RX_CLASS_OR_DUP_PTP) has slot 9 set, so a user rule there would
inadvertently trigger the HSR PTP duplicate classifier
Known limitation:
- ndev->stats.rx_errors/rx_dropped racy with concurrent NAPIs;
per-cpu stats refactor deferred.
Signed-off-by: Meghana Malladi <m-malladi at ti.com>
---
Changelog for v2-v1:
- prueth_emac_restart(): call icssg_rxnfc_rule_restore() for both ports;
rules were lost after bridge/HSR mode change
- icssg_rxnfc_classifier_update(): RMW for classifier 0 preserves BC|DA_P;
add BC|DA_P to classifiers 1..N with active rules
- icssg_rxnfc_rule_cleanup(): RMW for classifier 0 when clearing FT3 bits
- icssg_rxnfc_rule_add(): change location bound to >= ICSSG_NUM_FT3_SLOTS (16);
slot 15 now reachable explicitly
- emac_get_rxnfc(): set info->data = ICSSG_NUM_FT3_SLOTS | RX_CLS_LOC_SPECIAL in
both GRXCLSRLCNT and GRXCLSRLALL
- allocate_ft3_slot(), icssg_rxnfc_rule_add(): reserve slot 9 in HSR offload mode;
RX_CLASS_OR_DUP_PTP bit 9 in classifier 10's OR_EN causes user rules in slot 9 to
trigger the HSR PTP duplicate path
- icssg_ft3_program_filter(): declare ether_type as __be16; fixes sparse warning
- Remove FT3_CFG_REGISTER_EQUAL and FT3_CFG_REGISTER_VLAN_SKIP;
use FT3_VLAN_MODE_BOTH directly
- Document ndev->stats RMW race as known limitation, deferred
.../net/ethernet/ti/icssg/icssg_classifier.c | 440 +++++++++++++++++-
drivers/net/ethernet/ti/icssg/icssg_ethtool.c | 60 +++
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 7 +
drivers/net/ethernet/ti/icssg/icssg_prueth.h | 3 +-
4 files changed, 508 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_classifier.c b/drivers/net/ethernet/ti/icssg/icssg_classifier.c
index 87a8577093dbb..cf664e93d5c3d 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_classifier.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_classifier.c
@@ -5,6 +5,7 @@
*
*/
+#include <linux/cleanup.h>
#include <linux/etherdevice.h>
#include <linux/types.h>
#include <linux/regmap.h>
@@ -13,7 +14,6 @@
#define ICSSG_NUM_CLASSIFIERS 16
#define ICSSG_NUM_FT1_SLOTS 8
-#define ICSSG_NUM_FT3_SLOTS 16
#define ICSSG_NUM_CLASSIFIERS_IN_USE 5
@@ -105,6 +105,11 @@ enum ft1_cfg_type {
((BIT(slot) << RX_CLASS_FT_FT1_MATCH_SHIFT) & \
RX_CLASS_FT_FT1_MATCH_MASK)
+#define RX_CLASS_FT_FT3_MATCH(slot) \
+ ((BIT(slot) << RX_CLASS_FT_FT3_MATCH_SHIFT) & \
+ RX_CLASS_FT_FT3_MATCH_MASK)
+
+
/* HSR/PRP protocol frame filtering */
#define HSR_PTP_ETHERTYPE_OFFSET 0x12
#define PRP_PTP_ETHERTYPE_OFFSET 0x0C
@@ -120,6 +125,12 @@ enum ft1_cfg_type {
#define CLASSIFIER_PTP_DUP 10
#define CLASSIFIER_HSR_TAG 11
#define FT3_PTP_SLOT 14
+/* FT3 slot 9 is referenced by RX_CLASS_OR_DUP_PTP (bit 9) in classifier 10's
+ * OR_EN. HSR setup never programs the slot 9 FT3 filter, but if a user RXNFC
+ * rule occupies it, classifier 10 fires on that rule's EtherType. Reserve slot
+ * 9 when HSR offload mode is active.
+ */
+#define FT3_HSR_OR_SLOT 9
/* RX class type */
enum rx_class_sel_type {
@@ -532,3 +543,430 @@ void icssg_ft3_hsr_configurations(struct regmap *miig_rt, int slice,
}
}
EXPORT_SYMBOL_GPL(icssg_ft3_hsr_configurations);
+
+/* RX Flow Classification (ethtool) rule management */
+
+/* Allocate free FT3 slot, avoiding reserved slots */
+static int allocate_ft3_slot(struct prueth_emac *emac)
+{
+ u16 used = emac->rxnfc.ft3_slots_used | ICSSG_FT3_RESERVED_SLOTS;
+ int slot;
+
+ /* Slot 9 is implicitly used by the HSR PTP duplicate classifier's OR_EN.
+ * Prevent user rules from triggering it accidentally.
+ */
+ if (emac->prueth->is_hsr_offload_mode)
+ used |= BIT(FT3_HSR_OR_SLOT);
+
+ for (slot = 0; slot < ICSSG_NUM_FT3_SLOTS; slot++) {
+ if (!(used & BIT(slot))) {
+ emac->rxnfc.ft3_slots_used |= BIT(slot);
+ return slot;
+ }
+ }
+ return -ENOSPC;
+}
+
+/* Free allocated FT3 slot */
+static void free_ft3_slot(struct prueth_emac *emac, int slot)
+{
+ emac->rxnfc.ft3_slots_used &= ~BIT(slot);
+}
+
+/* Program FT3 filter slot with ethertype pattern */
+static void icssg_ft3_program_filter(struct regmap *miig_rt, int slice,
+ int slot, struct icssg_rxnfc_rule *rule)
+{
+ const struct ethtool_rx_flow_spec *fs = &rule->flow_spec;
+ __be16 ether_type;
+
+ /* Extract EtherType from flow spec (network byte order) */
+ ether_type = fs->h_u.ether_spec.h_proto;
+
+ /* Deactivate filter before programming */
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_CFG), 0);
+
+ /* EtherType is at byte 12 in standard Ethernet frames */
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_START),
+ PRP_PTP_ETHERTYPE_OFFSET);
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_START_AUTO), 0);
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_START_OFFSET), 0);
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_JUMP_OFFSET), 0);
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_LEN), 0);
+
+ /* FT3 compares a 32-bit LE word at FT3_START. EtherType occupies the
+ * lower 16 bits of that word. FT3_T_MASK=0xFFFF0000 masks the upper
+ * 16 bits (payload bytes), so only the lower 16 bits are compared.
+ *
+ * h_proto is __be16 (network byte order). On LE the raw integer value
+ * equals the lower 16 bits of the LE 32-bit word at the EtherType
+ * offset in the frame — e.g. IPv4 0x0800 BE → h_proto = 0x0008 on LE,
+ * which is exactly what FT3 sees in the lower 16 bits of the word at
+ * byte 12. No conversion needed; using be16_to_cpu() here would invert
+ * the byte order and break the match.
+ * Reference: FT3_PTP_PATTERN = 0xF788 = htons(0x88F7) = raw h_proto value.
+ */
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_T),
+ (__force u32)ether_type);
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_T_MASK), FT3_ETHERTYPE_MASK);
+
+ /* Enable filter: register-equal mode (same value as FT3_VLAN_MODE_BOTH) */
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_CFG),
+ FT3_VLAN_MODE_BOTH);
+}
+
+/* Disable FT3 filter slot */
+static void icssg_ft3_disable_filter(struct regmap *miig_rt, int slice, int slot)
+{
+ regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_CFG), 0);
+}
+
+/* Update RX classifiers for all active FT3 rules.
+ * Classifier N maps to RX flow N (firmware routes classifier-N hits to
+ * UDMA flow rx_flow_id_base + N). Build a per-classifier OR table so
+ * that each target queue gets its own classifier entry.
+ */
+static void icssg_rxnfc_classifier_update(struct prueth_emac *emac)
+{
+ struct prueth *prueth = emac->prueth;
+ struct regmap *miig_rt = prueth->miig_rt;
+ int slice = prueth_emac_slice(emac);
+ u32 or_table[ICSSG_NUM_CLASSIFIERS] = { };
+ struct icssg_rxnfc_rule *rule;
+ int n;
+
+ if (slice < 0)
+ return;
+
+ /* Build per-classifier OR table: classifier index = target queue index */
+ list_for_each_entry(rule, &emac->rxnfc.rules, list) {
+ int cls = rule->queue_index;
+
+ if (cls < emac->rx_flow_num)
+ or_table[cls] |= RX_CLASS_FT_FT3_MATCH(rule->ft3_slot);
+ }
+
+ /* Update OR tables for classifiers 0..rx_flow_num-1 using RMW so that
+ * non-FT3 bits (e.g. RX_CLASS_FT_BC | RX_CLASS_FT_DA_P set by
+ * icssg_class_default()) are preserved. Only the FT3-match field
+ * (RX_CLASS_FT_FT3_MATCH_MASK) is replaced.
+ *
+ * Classifiers 1..N start with OR_EN=0 after icssg_class_default()
+ * (non-SR1 sets num_classifiers=1, leaving them zeroed). Add BC|DA_P
+ * when they carry FT3 rules so that only host-addressed frames are
+ * steered — without it the classifier is a promiscuous EtherType match.
+ *
+ * Use RX_CLASS_N_REG (rx_class_base), NOT RX_CLASS_OR_REG
+ * (rx_class_or_base = rx_class_base + 4): the latter lands on AND_EN
+ * of classifier n+1 instead of OR_EN of classifier n.
+ */
+ for (n = 0; n < emac->rx_flow_num; n++) {
+ u32 val;
+
+ if (n == 0) {
+ /* Classifier 0: RMW to preserve default BC|DA_P bits
+ * set by icssg_class_default().
+ */
+ regmap_read(miig_rt,
+ RX_CLASS_N_REG(slice, n, RX_CLASS_OR_EN), &val);
+ val &= ~RX_CLASS_FT_FT3_MATCH_MASK;
+ val |= or_table[n];
+ } else if (or_table[n]) {
+ /* Classifiers 1..N with active rules: add BC|DA_P so
+ * only host-addressed frames are steered.
+ */
+ val = RX_CLASS_FT_BC | RX_CLASS_FT_DA_P | or_table[n];
+ } else {
+ /* Classifiers 1..N with no rules: clear entirely.
+ * Must not leave BC|DA_P here — it would steal all
+ * host traffic away from classifier 0.
+ */
+ val = 0;
+ }
+ regmap_write(miig_rt, RX_CLASS_N_REG(slice, n, RX_CLASS_OR_EN), val);
+ }
+}
+
+/* Validate rule parameters */
+static int validate_rule(struct prueth_emac *emac,
+ struct ethtool_rx_flow_spec *fs)
+{
+ /* Only ETHER_FLOW supported; reject extension flags */
+ if (fs->flow_type != ETHER_FLOW)
+ return -EOPNOTSUPP;
+
+ /* Only exact EtherType match supported — reject partial proto mask,
+ * non-zero MAC address masks, and flow extension flags.
+ */
+ if (fs->m_u.ether_spec.h_proto != htons(0xFFFF))
+ return -EOPNOTSUPP;
+ if (!is_zero_ether_addr(fs->m_u.ether_spec.h_dest) ||
+ !is_zero_ether_addr(fs->m_u.ether_spec.h_source))
+ return -EOPNOTSUPP;
+
+ /* Check RX queue is valid */
+ if (fs->ring_cookie >= emac->rx_flow_num)
+ return -EINVAL;
+
+ return 0;
+}
+
+/* Check if identical rule already exists */
+static bool rule_exists(struct prueth_emac *emac,
+ struct ethtool_rx_flow_spec *fs)
+{
+ struct icssg_rxnfc_rule *rule;
+
+ list_for_each_entry(rule, &emac->rxnfc.rules, list) {
+ if (rule->flow_spec.flow_type == fs->flow_type &&
+ rule->flow_spec.h_u.ether_spec.h_proto ==
+ fs->h_u.ether_spec.h_proto) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/* Initialize RX flow classification */
+void icssg_rxnfc_rule_init(struct prueth_emac *emac)
+{
+ INIT_LIST_HEAD(&emac->rxnfc.rules);
+ mutex_init(&emac->rxnfc.rxnfc_lock);
+ emac->rxnfc.rxnfc_rule_count = 0;
+ emac->rxnfc.ft3_slots_used = ICSSG_FT3_RESERVED_SLOTS; /* Mark slot 14 reserved */
+}
+EXPORT_SYMBOL_GPL(icssg_rxnfc_rule_init);
+
+/* Restore RX flow classification hardware state from the in-memory rule list.
+ * Call after icssg_class_default() resets the classifier registers on open or
+ * after firmware restart so that existing rules take effect again.
+ */
+void icssg_rxnfc_rule_restore(struct prueth_emac *emac)
+{
+ struct prueth *prueth = emac->prueth;
+ struct regmap *miig_rt = prueth->miig_rt;
+ int slice = prueth_emac_slice(emac);
+ struct icssg_rxnfc_rule *rule;
+
+ if (slice < 0)
+ return;
+
+ guard(mutex)(&emac->rxnfc.rxnfc_lock);
+
+ list_for_each_entry(rule, &emac->rxnfc.rules, list)
+ icssg_ft3_program_filter(miig_rt, slice, rule->ft3_slot, rule);
+
+ icssg_rxnfc_classifier_update(emac);
+}
+EXPORT_SYMBOL_GPL(icssg_rxnfc_rule_restore);
+
+/* Cleanup RX flow classification */
+void icssg_rxnfc_rule_cleanup(struct prueth_emac *emac)
+{
+ struct prueth *prueth = emac->prueth;
+ struct regmap *miig_rt = prueth->miig_rt;
+ int slice = prueth_emac_slice(emac);
+ struct icssg_rxnfc_rule *rule, *tmp;
+ int n;
+
+ if (slice < 0)
+ return;
+
+ guard(mutex)(&emac->rxnfc.rxnfc_lock);
+
+ /* Disable all active FT3 filters */
+ list_for_each_entry_safe(rule, tmp, &emac->rxnfc.rules, list) {
+ icssg_ft3_disable_filter(miig_rt, slice, rule->ft3_slot);
+ free_ft3_slot(emac, rule->ft3_slot);
+ list_del(&rule->list);
+ kfree(rule);
+ }
+
+ emac->rxnfc.rxnfc_rule_count = 0;
+ emac->rxnfc.ft3_slots_used = ICSSG_FT3_RESERVED_SLOTS;
+
+ /* Clear FT3 bits from classifiers 0..rx_flow_num-1. Use RMW for
+ * classifier 0 to preserve its BC|DA_P default-accept bits; for
+ * classifiers 1..N (which had BC|DA_P added by classifier_update)
+ * clear everything since no rules remain to steer traffic there.
+ */
+ for (n = 0; n < emac->rx_flow_num; n++) {
+ u32 val;
+
+ if (n == 0) {
+ regmap_read(miig_rt,
+ RX_CLASS_N_REG(slice, n, RX_CLASS_OR_EN), &val);
+ val &= ~RX_CLASS_FT_FT3_MATCH_MASK;
+ } else {
+ val = 0;
+ }
+ regmap_write(miig_rt, RX_CLASS_N_REG(slice, n, RX_CLASS_OR_EN), val);
+ }
+}
+EXPORT_SYMBOL_GPL(icssg_rxnfc_rule_cleanup);
+
+/* Add a new RX flow classification rule */
+int icssg_rxnfc_rule_add(struct prueth_emac *emac, struct ethtool_rxnfc *info)
+{
+ struct ethtool_rx_flow_spec *fs = &info->fs;
+ struct prueth *prueth = emac->prueth;
+ struct regmap *miig_rt = prueth->miig_rt;
+ int slice = prueth_emac_slice(emac);
+ struct icssg_rxnfc_rule *rule;
+ int ft3_slot;
+ int ret;
+
+ if (slice < 0)
+ return -EINVAL;
+
+ /* Validate rule parameters */
+ ret = validate_rule(emac, fs);
+ if (ret)
+ return ret;
+
+ /* Validate explicit location: reject special specifiers, out-of-range
+ * values, and the reserved slot 14 used by HSR/PRP.
+ * Bound against ICSSG_NUM_FT3_SLOTS (16), not ICSSG_RXNFC_MAX_RULES
+ * (15), so that slot 15 is reachable as an explicit location.
+ */
+ if (fs->location != RX_CLS_LOC_ANY) {
+ if (fs->location >= ICSSG_NUM_FT3_SLOTS ||
+ BIT(fs->location) & ICSSG_FT3_RESERVED_SLOTS ||
+ (emac->prueth->is_hsr_offload_mode &&
+ fs->location == FT3_HSR_OR_SLOT))
+ return -EINVAL;
+ }
+
+ guard(mutex)(&emac->rxnfc.rxnfc_lock);
+
+ /* Check max rules */
+ if (emac->rxnfc.rxnfc_rule_count >= ICSSG_RXNFC_MAX_RULES)
+ return -ENOSPC;
+
+ /* Check for duplicate flow spec */
+ if (rule_exists(emac, fs))
+ return -EEXIST;
+
+ /* Allocate FT3 slot. For explicit locations, the location IS the FT3
+ * slot — this keeps location and slot aligned so rule_del operates on
+ * the correct hardware slot. For RX_CLS_LOC_ANY, auto-allocate the
+ * lowest free slot and assign it as the location.
+ */
+ if (fs->location != RX_CLS_LOC_ANY) {
+ ft3_slot = fs->location;
+ if (emac->rxnfc.ft3_slots_used & BIT(ft3_slot))
+ return -EBUSY;
+ emac->rxnfc.ft3_slots_used |= BIT(ft3_slot);
+ } else {
+ ft3_slot = allocate_ft3_slot(emac);
+ if (ft3_slot < 0)
+ return -ENOSPC;
+ fs->location = ft3_slot;
+ }
+
+ /* Allocate rule structure */
+ rule = kzalloc(sizeof(*rule), GFP_KERNEL);
+ if (!rule) {
+ free_ft3_slot(emac, ft3_slot);
+ return -ENOMEM;
+ }
+
+ /* Program FT3 hardware */
+ rule->flow_spec = *fs;
+ rule->ft3_slot = ft3_slot;
+ rule->queue_index = fs->ring_cookie;
+ rule->location = fs->location;
+
+ icssg_ft3_program_filter(miig_rt, slice, ft3_slot, rule);
+
+ /* Add to rule list */
+ list_add(&rule->list, &emac->rxnfc.rules);
+ emac->rxnfc.rxnfc_rule_count++;
+
+ /* Update classifier */
+ icssg_rxnfc_classifier_update(emac);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(icssg_rxnfc_rule_add);
+
+/* Delete a RX flow classification rule */
+int icssg_rxnfc_rule_del(struct prueth_emac *emac, u32 location)
+{
+ struct prueth *prueth = emac->prueth;
+ struct regmap *miig_rt = prueth->miig_rt;
+ int slice = prueth_emac_slice(emac);
+ struct icssg_rxnfc_rule *rule, *tmp;
+ int ret = -ENOENT;
+
+ if (slice < 0)
+ return -EINVAL;
+
+ guard(mutex)(&emac->rxnfc.rxnfc_lock);
+
+ list_for_each_entry_safe(rule, tmp, &emac->rxnfc.rules, list) {
+ if (rule->location == location) {
+ icssg_ft3_disable_filter(miig_rt, slice, rule->ft3_slot);
+ free_ft3_slot(emac, rule->ft3_slot);
+ list_del(&rule->list);
+ kfree(rule);
+ emac->rxnfc.rxnfc_rule_count--;
+ icssg_rxnfc_classifier_update(emac);
+ ret = 0;
+ break;
+ }
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(icssg_rxnfc_rule_del);
+
+/* Get single RX flow classification rule */
+int icssg_rxnfc_rule_get(struct prueth_emac *emac, u32 location,
+ struct ethtool_rx_flow_spec *fs)
+{
+ struct icssg_rxnfc_rule *rule;
+ int ret = -ENOENT;
+
+ guard(mutex)(&emac->rxnfc.rxnfc_lock);
+
+ list_for_each_entry(rule, &emac->rxnfc.rules, list) {
+ if (rule->location == location) {
+ *fs = rule->flow_spec;
+ ret = 0;
+ break;
+ }
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(icssg_rxnfc_rule_get);
+
+/* Get all RX flow classification rules */
+int icssg_rxnfc_rule_get_all(struct prueth_emac *emac, u32 *rule_locs,
+ u32 rule_locs_capacity, u32 *rule_cnt)
+{
+ struct icssg_rxnfc_rule *rule;
+ u32 count = 0;
+ int ret = 0;
+
+ guard(mutex)(&emac->rxnfc.rxnfc_lock);
+
+ list_for_each_entry(rule, &emac->rxnfc.rules, list) {
+ if (!rule_locs) {
+ /* Caller passed rule_cnt=0: just count active rules */
+ count++;
+ continue;
+ }
+ if (count >= rule_locs_capacity) {
+ ret = -EMSGSIZE;
+ break;
+ }
+ rule_locs[count++] = rule->location;
+ }
+
+ *rule_cnt = count;
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(icssg_rxnfc_rule_get_all);
diff --git a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
index 8af4bba62efa7..b74e1a9706e40 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
@@ -302,6 +302,63 @@ static int emac_set_per_queue_coalesce(struct net_device *ndev, u32 queue,
return 0;
}
+static u32 emac_get_rx_ring_count(struct net_device *ndev)
+{
+ struct prueth_emac *emac = netdev_priv(ndev);
+
+ return emac->rx_flow_num;
+}
+
+static int emac_get_rxnfc(struct net_device *ndev, struct ethtool_rxnfc *info,
+ u32 *rule_locs)
+{
+ struct prueth_emac *emac = netdev_priv(ndev);
+ int ret = 0;
+
+ if (emac->is_sr1)
+ return -EOPNOTSUPP;
+
+ switch (info->cmd) {
+ case ETHTOOL_GRXCLSRLCNT:
+ info->rule_cnt = emac->rxnfc.rxnfc_rule_count;
+ info->data = ICSSG_NUM_FT3_SLOTS | RX_CLS_LOC_SPECIAL;
+ break;
+ case ETHTOOL_GRXCLSRULE:
+ ret = icssg_rxnfc_rule_get(emac, info->fs.location, &info->fs);
+ break;
+ case ETHTOOL_GRXCLSRLALL: {
+ u32 rule_cnt = 0;
+
+ info->data = ICSSG_NUM_FT3_SLOTS | RX_CLS_LOC_SPECIAL;
+ ret = icssg_rxnfc_rule_get_all(emac, rule_locs,
+ info->rule_cnt, &rule_cnt);
+ info->rule_cnt = rule_cnt;
+ break;
+ }
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return ret;
+}
+
+static int emac_set_rxnfc(struct net_device *ndev, struct ethtool_rxnfc *info)
+{
+ struct prueth_emac *emac = netdev_priv(ndev);
+
+ if (emac->is_sr1)
+ return -EOPNOTSUPP;
+
+ switch (info->cmd) {
+ case ETHTOOL_SRXCLSRLINS:
+ return icssg_rxnfc_rule_add(emac, info);
+ case ETHTOOL_SRXCLSRLDEL:
+ return icssg_rxnfc_rule_del(emac, info->fs.location);
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
const struct ethtool_ops icssg_ethtool_ops = {
.get_drvinfo = emac_get_drvinfo,
.get_msglevel = emac_get_msglevel,
@@ -325,5 +382,8 @@ const struct ethtool_ops icssg_ethtool_ops = {
.set_eee = emac_set_eee,
.nway_reset = emac_nway_reset,
.get_rmon_stats = emac_get_rmon_stats,
+ .get_rx_ring_count = emac_get_rx_ring_count,
+ .get_rxnfc = emac_get_rxnfc,
+ .set_rxnfc = emac_set_rxnfc,
};
EXPORT_SYMBOL_GPL(icssg_ethtool_ops);
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index bda6d92a8158d..ecd42abe9a3f9 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -1932,6 +1932,13 @@ static int prueth_emac_restart(struct prueth *prueth)
return ret;
}
+ /* Restore RXNFC rules: prueth_emac_common_start() calls
+ * icssg_class_default() which resets all classifier OR_EN registers,
+ * wiping any active FT3 steering rules.
+ */
+ icssg_rxnfc_rule_restore(emac0);
+ icssg_rxnfc_rule_restore(emac1);
+
/* Enable forwarding for both PRUeth ports */
ret = icssg_set_port_state(emac0, ICSSG_EMAC_PORT_FORWARD);
ret |= icssg_set_port_state(emac1, ICSSG_EMAC_PORT_FORWARD);
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
index 9feb1866d34c9..555b1774e03c6 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
@@ -194,7 +194,8 @@ struct prueth_swdata {
#define ICSSG_MIN_COALESCE_USECS 20
/* RX flow classification (ethtool) */
-#define ICSSG_RXNFC_MAX_RULES 15 /* Max user-installable rules */
+#define ICSSG_NUM_FT3_SLOTS 16 /* Total FT3 filter slots */
+#define ICSSG_RXNFC_MAX_RULES 15 /* Max user-installable rules (slot 14 reserved) */
#define ICSSG_FT3_RESERVED_SLOTS BIT(14) /* Slot 14 reserved for HSR/PRP */
/* RX flow classification rule structure */
--
2.43.0
More information about the linux-arm-kernel
mailing list