diff --git a/src/Kbuild b/src/Kbuild index 0ec95436..e1bc4a3e 100644 --- a/src/Kbuild +++ b/src/Kbuild @@ -215,6 +215,9 @@ endif # Check for DIM $(eval $(call add_compat_flag,$(srctree)/include/linux/dim.h,net_dim_get_rx,COMPAT_HAVE_DIM)) +# Check for DIM sample by reference +$(eval $(call add_compat_flag,$(srctree)/include/linux/dim.h,"^void net_dim.*struct dim_sample \*end_sample",COMPAT_DIM_PASS_BY_REF)) + # Check for netif_set_real_num_queues $(eval $(call add_compat_flag,$(srctree)/include/linux/netdevice.h,netif_set_real_num_queues,COMPAT__HAVE_NETIF_SET_REAL_NUM_QUEUES)) diff --git a/src/nfd3/dp.c b/src/nfd3/dp.c index 6dd82b50..f41c2352 100644 --- a/src/nfd3/dp.c +++ b/src/nfd3/dp.c @@ -1239,7 +1239,7 @@ int nfp_nfd3_poll(struct napi_struct *napi, int budget) } while (u64_stats_fetch_retry(&r_vec->rx_sync, start)); dim_update_sample(r_vec->event_ctr, pkts, bytes, &dim_sample); - net_dim(&r_vec->rx_dim, dim_sample); + compat__net_dim(&r_vec->rx_dim, &dim_sample); } if (r_vec->nfp_net->tx_coalesce_adapt_on && r_vec->tx_ring) { @@ -1254,7 +1254,7 @@ int nfp_nfd3_poll(struct napi_struct *napi, int budget) } while (u64_stats_fetch_retry(&r_vec->tx_sync, start)); dim_update_sample(r_vec->event_ctr, pkts, bytes, &dim_sample); - net_dim(&r_vec->tx_dim, dim_sample); + compat__net_dim(&r_vec->tx_dim, &dim_sample); } #endif diff --git a/src/nfdk/dp.c b/src/nfdk/dp.c index 987ab8e7..8b23e2d9 100644 --- a/src/nfdk/dp.c +++ b/src/nfdk/dp.c @@ -1348,7 +1348,7 @@ int nfp_nfdk_poll(struct napi_struct *napi, int budget) } while (u64_stats_fetch_retry(&r_vec->rx_sync, start)); dim_update_sample(r_vec->event_ctr, pkts, bytes, &dim_sample); - net_dim(&r_vec->rx_dim, dim_sample); + compat__net_dim(&r_vec->rx_dim, &dim_sample); } if (r_vec->nfp_net->tx_coalesce_adapt_on && r_vec->tx_ring) { @@ -1363,7 +1363,7 @@ int nfp_nfdk_poll(struct napi_struct *napi, int budget) } while (u64_stats_fetch_retry(&r_vec->tx_sync, start)); dim_update_sample(r_vec->event_ctr, pkts, bytes, &dim_sample); - net_dim(&r_vec->tx_dim, dim_sample); + compat__net_dim(&r_vec->tx_dim, &dim_sample); } #endif diff --git a/src/nfp_net_compat.c b/src/nfp_net_compat.c index 7416b5d5..7820c44f 100644 --- a/src/nfp_net_compat.c +++ b/src/nfp_net_compat.c @@ -263,3 +263,17 @@ __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...) } #endif #endif + +/* kernel commit: 61bf0009a765 ("dim: pass dim_sample to net_dim() by reference") + * converted the 'net_dim' function to take in end_sample by reference. Add the + * applicable compat function code. Use this compat__ function instead of doing + * this everywhere in the rest of the source code. + */ +void compat__net_dim(struct dim *dim, const struct dim_sample *end_sample) +{ +#ifdef COMPAT_DIM_PASS_BY_REF + net_dim(dim, end_sample); +#else + net_dim(dim, *end_sample); +#endif +} diff --git a/src/nfp_net_compat.h b/src/nfp_net_compat.h index 3539c6ea..f0ae26ac 100644 --- a/src/nfp_net_compat.h +++ b/src/nfp_net_compat.h @@ -1731,4 +1731,19 @@ static inline bool flow_rule_match_has_control_flags(struct flow_rule *rule, return flow_rule_has_control_flags(match.mask->flags, extack); } #endif + +/** + * net_dim - main DIM algorithm entry point + * @dim: DIM instance information + * @end_sample: Current data measurement + * + * Called by the consumer. + * This is the main logic of the algorithm, where data is processed in order + * to decide on next required action. + * + * A compat version is needed, as end_sample changed from being passed by value + * to being passed as reference. + */ +void compat__net_dim(struct dim *dim, const struct dim_sample *end_sample); + #endif /* _NFP_NET_COMPAT_H_ */