Something went wrong. Try again.
(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB/* * Copyright (c) 2019, Mellanox Technologies inc. All rights reserved. */
#include <linux/dim.h>
bool dim_on_top(struct dim *dim){ switch (dim->tune_state) { case DIM_PARKING_ON_TOP: case DIM_PARKING_TIRED: return true; case DIM_GOING_RIGHT: return (dim->steps_left > 1) && (dim->steps_right == 1); default: /* DIM_GOING_LEFT */ return (dim->steps_right > 1) && (dim->steps_left == 1); }}EXPORT_SYMBOL(dim_on_top);
void dim_turn(struct dim *dim){ switch (dim->tune_state) { case DIM_PARKING_ON_TOP: case DIM_PARKING_TIRED: break; case DIM_GOING_RIGHT: dim->tune_state = DIM_GOING_LEFT; dim->steps_left = 0; break; case DIM_GOING_LEFT: dim->tune_state = DIM_GOING_RIGHT; dim->steps_right = 0; break; }}EXPORT_SYMBOL(dim_turn);
void dim_park_on_top(struct dim *dim){ dim->steps_right = 0; dim->steps_left = 0; dim->tired = 0; dim->tune_state = DIM_PARKING_ON_TOP;}EXPORT_SYMBOL(dim_park_on_top);
void dim_park_tired(struct dim *dim){ dim->steps_right = 0; dim->steps_left = 0; dim->tune_state = DIM_PARKING_TIRED;}EXPORT_SYMBOL(dim_park_tired);
bool dim_calc_stats(const struct dim_sample *start, const struct dim_sample *end, struct dim_stats *curr_stats){ /* u32 holds up to 71 minutes, should be enough */ u32 delta_us = ktime_us_delta(end->time, start->time); u32 npkts = BIT_GAP(BITS_PER_TYPE(u32), end->pkt_ctr, start->pkt_ctr); u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32), end->byte_ctr, start->byte_ctr); u32 ncomps = BIT_GAP(BITS_PER_TYPE(u32), end->comp_ctr, start->comp_ctr);
if (!delta_us) return false;
/* u32 * USEC_PER_MSEC overflows a 32-bit long */ curr_stats->ppms = DIV_ROUND_UP_ULL((u64)npkts * USEC_PER_MSEC, delta_us); curr_stats->bpms = DIV_ROUND_UP_ULL((u64)nbytes * USEC_PER_MSEC, delta_us); curr_stats->epms = DIV_ROUND_UP(DIM_NEVENTS * USEC_PER_MSEC, delta_us); curr_stats->cpms = DIV_ROUND_UP_ULL((u64)ncomps * USEC_PER_MSEC, delta_us); if (curr_stats->epms != 0) curr_stats->cpe_ratio = DIV_ROUND_DOWN_ULL( curr_stats->cpms * 100, curr_stats->epms); else curr_stats->cpe_ratio = 0;
return true;}EXPORT_SYMBOL(dim_calc_stats);
MODULE_DESCRIPTION("Dynamic Interrupt Moderation (DIM) library");MODULE_LICENSE("Dual BSD/GPL");