PRODUCT=19/0/1/0 NAME="Power Button" PHYS="LNXPWRBN/button/input0" PROP=0 EV=3 KEY=8000 10000000000000 0 MODALIAS=input:b0019v0000p0001e0000-e0,1,k74,8F,ramlsfw $3ˆÐ× „]d?Öa–ß=¿JJj"T₠ƃq—TÅ£Õ-Ó3/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* Copyright (c) 2019 Mellanox Technologies. */ #ifndef DIM_H #define DIM_H #include #include #include #include #include struct net_device; /* Number of DIM profiles and period mode. */ #define NET_DIM_PARAMS_NUM_PROFILES 5 #define NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE 256 #define NET_DIM_DEFAULT_TX_CQ_PKTS_FROM_EQE 128 #define NET_DIM_DEF_PROFILE_CQE 1 #define NET_DIM_DEF_PROFILE_EQE 1 /* * Number of events between DIM iterations. * Causes a moderation of the algorithm run. */ #define DIM_NEVENTS 64 /* * Is a difference between values justifies taking an action. * We consider 10% difference as significant. */ #define IS_SIGNIFICANT_DIFF(val, ref) \ ((ref) && (((100UL * abs((val) - (ref))) / (ref)) > 10)) /* * Calculate the gap between two values. * Take wrap-around and variable size into consideration. */ #define BIT_GAP(bits, end, start) ((((end) - (start)) + BIT_ULL(bits)) \ & (BIT_ULL(bits) - 1)) /** * struct dim_cq_moder - Structure for CQ moderation values. * Used for communications between DIM and its consumer. * * @usec: CQ timer suggestion (by DIM) * @pkts: CQ packet counter suggestion (by DIM) * @comps: Completion counter * @cq_period_mode: CQ period count mode (from CQE/EQE) * @rcu: for asynchronous kfree_rcu */ struct dim_cq_moder { u16 usec; u16 pkts; u16 comps; u8 cq_period_mode; struct rcu_head rcu; }; #define DIM_PROFILE_RX BIT(0) /* support rx profile modification */ #define DIM_PROFILE_TX BIT(1) /* support tx profile modification */ #define DIM_COALESCE_USEC BIT(0) /* support usec field modification */ #define DIM_COALESCE_PKTS BIT(1) /* support pkts field modification */ #define DIM_COALESCE_COMPS BIT(2) /* support comps field modification */ /** * struct dim_irq_moder - Structure for irq moderation information. * Used to collect irq moderation related information. * * @profile_flags: DIM_PROFILE_* * @coal_flags: DIM_COALESCE_* for Rx and Tx * @dim_rx_mode: Rx DIM period count mode: CQE or EQE * @dim_tx_mode: Tx DIM period count mode: CQE or EQE * @rx_profile: DIM profile list for Rx * @tx_profile: DIM profile list for Tx * @rx_dim_work: Rx DIM worker scheduled by net_dim() * @tx_dim_work: Tx DIM worker scheduled by net_dim() */ struct dim_irq_moder { u8 profile_flags; u8 coal_flags; u8 dim_rx_mode; u8 dim_tx_mode; struct dim_cq_moder __rcu *rx_profile; struct dim_cq_moder __rcu *tx_profile; void (*rx_dim_work)(struct work_struct *work); void (*tx_dim_work)(struct work_struct *work); }; /** * struct dim_sample - Structure for DIM sample data. * Used for communications between DIM and its consumer. * * @time: Sample timestamp * @pkt_ctr: Number of packets * @byte_ctr: Number of bytes * @event_ctr: Number of events * @comp_ctr: Current completion counter */ struct dim_sample { ktime_t time; u32 pkt_ctr; u32 byte_ctr; u16 event_ctr; u32 comp_ctr; }; /** * struct dim_stats - Structure for DIM stats. * Used for holding current measured rates. * * @ppms: Packets per msec * @bpms: Bytes per msec * @epms: Events per msec * @cpms: Completions per msec * @cpe_ratio: Ratio of completions to events */ struct dim_stats { int ppms; /* packets per msec */ int bpms; /* bytes per msec */ int epms; /* events per msec */ int cpms; /* completions per msec */ int cpe_ratio; /* ratio of completions to events */ }; /** * struct dim - Main structure for dynamic interrupt moderation (DIM). * Used for holding all information about a specific DIM instance. * * @state: Algorithm state (see below) * @prev_stats: Measured rates from previous iteration (for comparison) * @start_sample: Sampled data at start of current iteration * @measuring_sample: A &dim_sample that is used to update the cu