drivers/net/ethernet/airoha/airoha_ppe.c:425 airoha_ppe_foe_get_flow_stats_index() warn: always true condition '(hash >= (2 * 0)) => (0-u32max >= 0)'
From: kernel test robot
Date: Sun Jun 08 2025 - 01:51:37 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8630c59e99363c4b655788fd01134aef9bcd9264
commit: b81e0f2b58be37628b2e12f8dffdd63c84573e75 net: airoha: Add FLOW_CLS_STATS callback support
date: 3 weeks ago
config: powerpc-randconfig-r071-20250608 (https://download.01.org/0day-ci/archive/20250608/202506081343.4g7Ip73n-lkp@xxxxxxxxx/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project f819f46284f2a79790038e1f6649172789734ae8)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506081343.4g7Ip73n-lkp@xxxxxxxxx/
smatch warnings:
drivers/net/ethernet/airoha/airoha_ppe.c:425 airoha_ppe_foe_get_flow_stats_index() warn: always true condition '(hash >= (2 * 0)) => (0-u32max >= 0)'
drivers/net/ethernet/airoha/airoha_ppe.c:442 airoha_ppe_foe_flow_stats_reset() warn: we never enter this loop
drivers/net/ethernet/airoha/airoha_ppe.c:456 airoha_ppe_foe_flow_stats_update() warn: always true condition '(index >= (2 * 0)) => (0-u32max >= 0)'
drivers/net/ethernet/airoha/airoha_ppe.c:1075 airoha_ppe_foe_entry_get_stats() warn: always true condition '(index >= (2 * 0)) => (0-u32max >= 0)'
vim +425 drivers/net/ethernet/airoha/airoha_ppe.c
419
420 static u32 airoha_ppe_foe_get_flow_stats_index(struct airoha_ppe *ppe, u32 hash)
421 {
422 if (!airoha_ppe2_is_enabled(ppe->eth))
423 return hash;
424
> 425 return hash >= PPE_STATS_NUM_ENTRIES ? hash - PPE1_STATS_NUM_ENTRIES
426 : hash;
427 }
428
429 static void airoha_ppe_foe_flow_stat_entry_reset(struct airoha_ppe *ppe,
430 struct airoha_npu *npu,
431 int index)
432 {
433 memset_io(&npu->stats[index], 0, sizeof(*npu->stats));
434 memset(&ppe->foe_stats[index], 0, sizeof(*ppe->foe_stats));
435 }
436
437 static void airoha_ppe_foe_flow_stats_reset(struct airoha_ppe *ppe,
438 struct airoha_npu *npu)
439 {
440 int i;
441
> 442 for (i = 0; i < PPE_STATS_NUM_ENTRIES; i++)
443 airoha_ppe_foe_flow_stat_entry_reset(ppe, npu, i);
444 }
445
446 static void airoha_ppe_foe_flow_stats_update(struct airoha_ppe *ppe,
447 struct airoha_npu *npu,
448 struct airoha_foe_entry *hwe,
449 u32 hash)
450 {
451 int type = FIELD_GET(AIROHA_FOE_IB1_BIND_PACKET_TYPE, hwe->ib1);
452 u32 index, pse_port, val, *data, *ib2, *meter;
453 u8 nbq;
454
455 index = airoha_ppe_foe_get_flow_stats_index(ppe, hash);
> 456 if (index >= PPE_STATS_NUM_ENTRIES)
457 return;
458
459 if (type == PPE_PKT_TYPE_BRIDGE) {
460 data = &hwe->bridge.data;
461 ib2 = &hwe->bridge.ib2;
462 meter = &hwe->bridge.l2.meter;
463 } else if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T) {
464 data = &hwe->ipv6.data;
465 ib2 = &hwe->ipv6.ib2;
466 meter = &hwe->ipv6.meter;
467 } else {
468 data = &hwe->ipv4.data;
469 ib2 = &hwe->ipv4.ib2;
470 meter = &hwe->ipv4.l2.meter;
471 }
472
473 airoha_ppe_foe_flow_stat_entry_reset(ppe, npu, index);
474
475 val = FIELD_GET(AIROHA_FOE_CHANNEL | AIROHA_FOE_QID, *data);
476 *data = (*data & ~AIROHA_FOE_ACTDP) |
477 FIELD_PREP(AIROHA_FOE_ACTDP, val);
478
479 val = *ib2 & (AIROHA_FOE_IB2_NBQ | AIROHA_FOE_IB2_PSE_PORT |
480 AIROHA_FOE_IB2_PSE_QOS | AIROHA_FOE_IB2_FAST_PATH);
481 *meter |= FIELD_PREP(AIROHA_FOE_TUNNEL_MTU, val);
482
483 pse_port = FIELD_GET(AIROHA_FOE_IB2_PSE_PORT, *ib2);
484 nbq = pse_port == 1 ? 6 : 5;
485 *ib2 &= ~(AIROHA_FOE_IB2_NBQ | AIROHA_FOE_IB2_PSE_PORT |
486 AIROHA_FOE_IB2_PSE_QOS);
487 *ib2 |= FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT, 6) |
488 FIELD_PREP(AIROHA_FOE_IB2_NBQ, nbq);
489 }
490
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki